fix: Show correct button for workflow without crawls (#2590)

Shows "Run Now" button instead of "QA Latest Crawl" in workflow "Watch"
tab when there aren't any crawls.
This commit is contained in:
sua yoo 2025-05-06 14:31:26 -07:00 committed by GitHub
parent 62a53d01d6
commit 0ec94098a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
import { localized, msg, str } from "@lit/localize"; import { localized, msg, str } from "@lit/localize";
import type { SlSelect } from "@shoelace-style/shoelace"; import type { SlSelect } from "@shoelace-style/shoelace";
import { html, type PropertyValues, type TemplateResult } from "lit"; import { html, nothing, type PropertyValues, type TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators.js"; import { customElement, property, state } from "lit/decorators.js";
import { choose } from "lit/directives/choose.js"; import { choose } from "lit/directives/choose.js";
import { ifDefined } from "lit/directives/if-defined.js"; import { ifDefined } from "lit/directives/if-defined.js";
@ -646,25 +646,7 @@ export class WorkflowDetail extends BtrixElement {
</sl-button> </sl-button>
</sl-button-group> </sl-button-group>
`, `,
() => html` this.renderRunNowButton,
<sl-tooltip
content=${msg(
"Org Storage Full or Monthly Execution Minutes Reached",
)}
?disabled=${!this.org?.storageQuotaReached &&
!this.org?.execMinutesQuotaReached}
>
<sl-button
size="small"
variant="primary"
?disabled=${archivingDisabled}
@click=${() => void this.runNow()}
>
<sl-icon name="play" slot="prefix"></sl-icon>
<span>${msg("Run Crawl")}</span>
</sl-button>
</sl-tooltip>
`,
)} )}
<sl-dropdown placement="bottom-end" distance="4" hoist> <sl-dropdown placement="bottom-end" distance="4" hoist>
@ -1097,23 +1079,25 @@ export class WorkflowDetail extends BtrixElement {
></sl-icon> ></sl-icon>
${msg("Replay Latest Crawl")}</sl-button ${msg("Replay Latest Crawl")}</sl-button
> >
${when(
this.isCrawler,
() =>
html` <sl-button
href=${`${this.navigate.orgBasePath}/workflows/${workflow.id}/crawls/${workflow.lastCrawlId}#qa`}
size="small"
@click=${this.navigate.link}
>
<sl-icon
slot="prefix"
name="clipboard2-data-fill"
library="default"
></sl-icon>
${msg("QA Latest Crawl")}
</sl-button>`,
)}
`, `,
)} () => (this.isCrawler ? this.renderRunNowButton() : nothing),
${when(
this.isCrawler && this.workflow,
(workflow) =>
html` <sl-button
href=${`${this.navigate.orgBasePath}/workflows/${workflow.id}/crawls/${workflow.lastCrawlId}#qa`}
size="small"
@click=${this.navigate.link}
>
<sl-icon
slot="prefix"
name="clipboard2-data-fill"
library="default"
></sl-icon>
${msg("QA Latest Crawl")}
</sl-button>`,
)} )}
</div> </div>
</section> </section>
@ -1161,6 +1145,27 @@ export class WorkflowDetail extends BtrixElement {
`; `;
} }
private readonly renderRunNowButton = () => {
return html`
<sl-tooltip
content=${msg("Org Storage Full or Monthly Execution Minutes Reached")}
?disabled=${!this.org?.storageQuotaReached &&
!this.org?.execMinutesQuotaReached}
>
<sl-button
size="small"
variant="primary"
?disabled=${this.org?.storageQuotaReached ||
this.org?.execMinutesQuotaReached}
@click=${() => void this.runNow()}
>
<sl-icon name="play" slot="prefix"></sl-icon>
${msg("Run Crawl")}
</sl-button>
</sl-tooltip>
`;
};
private renderNoCrawlLogs() { private renderNoCrawlLogs() {
return html` return html`
<section <section
@ -1169,26 +1174,10 @@ export class WorkflowDetail extends BtrixElement {
<p class="text-base font-medium"> <p class="text-base font-medium">
${msg("Logs will show here after you run a crawl.")} ${msg("Logs will show here after you run a crawl.")}
</p> </p>
<div class="mt-4"> ${when(
<sl-tooltip this.isCrawler,
content=${msg( () => html` <div class="mt-4">${this.renderRunNowButton()}</div> `,
"Org Storage Full or Monthly Execution Minutes Reached", )}
)}
?disabled=${!this.org?.storageQuotaReached &&
!this.org?.execMinutesQuotaReached}
>
<sl-button
size="small"
variant="primary"
?disabled=${this.org?.storageQuotaReached ||
this.org?.execMinutesQuotaReached}
@click=${() => void this.runNow()}
>
<sl-icon name="play" slot="prefix"></sl-icon>
${msg("Run Crawl")}
</sl-button>
</sl-tooltip>
</div>
</section> </section>
`; `;
} }