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,11 +1079,10 @@ export class WorkflowDetail extends BtrixElement {
></sl-icon> ></sl-icon>
${msg("Replay Latest Crawl")}</sl-button ${msg("Replay Latest Crawl")}</sl-button
> >
`,
)}
${when( ${when(
this.isCrawler && this.workflow, this.isCrawler,
(workflow) => () =>
html` <sl-button html` <sl-button
href=${`${this.navigate.orgBasePath}/workflows/${workflow.id}/crawls/${workflow.lastCrawlId}#qa`} href=${`${this.navigate.orgBasePath}/workflows/${workflow.id}/crawls/${workflow.lastCrawlId}#qa`}
size="small" size="small"
@ -1115,6 +1096,9 @@ export class WorkflowDetail extends BtrixElement {
${msg("QA Latest Crawl")} ${msg("QA Latest Crawl")}
</sl-button>`, </sl-button>`,
)} )}
`,
() => (this.isCrawler ? this.renderRunNowButton() : nothing),
)}
</div> </div>
</section> </section>
`; `;
@ -1161,19 +1145,10 @@ export class WorkflowDetail extends BtrixElement {
`; `;
} }
private renderNoCrawlLogs() { private readonly renderRunNowButton = () => {
return html` return html`
<section
class="flex h-56 min-h-max flex-col items-center justify-center rounded-lg border p-4"
>
<p class="text-base font-medium">
${msg("Logs will show here after you run a crawl.")}
</p>
<div class="mt-4">
<sl-tooltip <sl-tooltip
content=${msg( content=${msg("Org Storage Full or Monthly Execution Minutes Reached")}
"Org Storage Full or Monthly Execution Minutes Reached",
)}
?disabled=${!this.org?.storageQuotaReached && ?disabled=${!this.org?.storageQuotaReached &&
!this.org?.execMinutesQuotaReached} !this.org?.execMinutesQuotaReached}
> >
@ -1188,7 +1163,21 @@ export class WorkflowDetail extends BtrixElement {
${msg("Run Crawl")} ${msg("Run Crawl")}
</sl-button> </sl-button>
</sl-tooltip> </sl-tooltip>
</div> `;
};
private renderNoCrawlLogs() {
return html`
<section
class="flex h-56 min-h-max flex-col items-center justify-center rounded-lg border p-4"
>
<p class="text-base font-medium">
${msg("Logs will show here after you run a crawl.")}
</p>
${when(
this.isCrawler,
() => html` <div class="mt-4">${this.renderRunNowButton()}</div> `,
)}
</section> </section>
`; `;
} }