Skip to content

Commit 0ec9409

Browse files
authored
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.
1 parent 62a53d0 commit 0ec9409

File tree

1 file changed

+45
-56
lines changed

1 file changed

+45
-56
lines changed

frontend/src/pages/org/workflow-detail.ts

Lines changed: 45 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { localized, msg, str } from "@lit/localize";
22
import type { SlSelect } from "@shoelace-style/shoelace";
3-
import { html, type PropertyValues, type TemplateResult } from "lit";
3+
import { html, nothing, type PropertyValues, type TemplateResult } from "lit";
44
import { customElement, property, state } from "lit/decorators.js";
55
import { choose } from "lit/directives/choose.js";
66
import { ifDefined } from "lit/directives/if-defined.js";
@@ -646,25 +646,7 @@ export class WorkflowDetail extends BtrixElement {
646646
</sl-button>
647647
</sl-button-group>
648648
`,
649-
() => html`
650-
<sl-tooltip
651-
content=${msg(
652-
"Org Storage Full or Monthly Execution Minutes Reached",
653-
)}
654-
?disabled=${!this.org?.storageQuotaReached &&
655-
!this.org?.execMinutesQuotaReached}
656-
>
657-
<sl-button
658-
size="small"
659-
variant="primary"
660-
?disabled=${archivingDisabled}
661-
@click=${() => void this.runNow()}
662-
>
663-
<sl-icon name="play" slot="prefix"></sl-icon>
664-
<span>${msg("Run Crawl")}</span>
665-
</sl-button>
666-
</sl-tooltip>
667-
`,
649+
this.renderRunNowButton,
668650
)}
669651
670652
<sl-dropdown placement="bottom-end" distance="4" hoist>
@@ -1097,23 +1079,25 @@ export class WorkflowDetail extends BtrixElement {
10971079
></sl-icon>
10981080
${msg("Replay Latest Crawl")}</sl-button
10991081
>
1082+
1083+
${when(
1084+
this.isCrawler,
1085+
() =>
1086+
html` <sl-button
1087+
href=${`${this.navigate.orgBasePath}/workflows/${workflow.id}/crawls/${workflow.lastCrawlId}#qa`}
1088+
size="small"
1089+
@click=${this.navigate.link}
1090+
>
1091+
<sl-icon
1092+
slot="prefix"
1093+
name="clipboard2-data-fill"
1094+
library="default"
1095+
></sl-icon>
1096+
${msg("QA Latest Crawl")}
1097+
</sl-button>`,
1098+
)}
11001099
`,
1101-
)}
1102-
${when(
1103-
this.isCrawler && this.workflow,
1104-
(workflow) =>
1105-
html` <sl-button
1106-
href=${`${this.navigate.orgBasePath}/workflows/${workflow.id}/crawls/${workflow.lastCrawlId}#qa`}
1107-
size="small"
1108-
@click=${this.navigate.link}
1109-
>
1110-
<sl-icon
1111-
slot="prefix"
1112-
name="clipboard2-data-fill"
1113-
library="default"
1114-
></sl-icon>
1115-
${msg("QA Latest Crawl")}
1116-
</sl-button>`,
1100+
() => (this.isCrawler ? this.renderRunNowButton() : nothing),
11171101
)}
11181102
</div>
11191103
</section>
@@ -1161,6 +1145,27 @@ export class WorkflowDetail extends BtrixElement {
11611145
`;
11621146
}
11631147

1148+
private readonly renderRunNowButton = () => {
1149+
return html`
1150+
<sl-tooltip
1151+
content=${msg("Org Storage Full or Monthly Execution Minutes Reached")}
1152+
?disabled=${!this.org?.storageQuotaReached &&
1153+
!this.org?.execMinutesQuotaReached}
1154+
>
1155+
<sl-button
1156+
size="small"
1157+
variant="primary"
1158+
?disabled=${this.org?.storageQuotaReached ||
1159+
this.org?.execMinutesQuotaReached}
1160+
@click=${() => void this.runNow()}
1161+
>
1162+
<sl-icon name="play" slot="prefix"></sl-icon>
1163+
${msg("Run Crawl")}
1164+
</sl-button>
1165+
</sl-tooltip>
1166+
`;
1167+
};
1168+
11641169
private renderNoCrawlLogs() {
11651170
return html`
11661171
<section
@@ -1169,26 +1174,10 @@ export class WorkflowDetail extends BtrixElement {
11691174
<p class="text-base font-medium">
11701175
${msg("Logs will show here after you run a crawl.")}
11711176
</p>
1172-
<div class="mt-4">
1173-
<sl-tooltip
1174-
content=${msg(
1175-
"Org Storage Full or Monthly Execution Minutes Reached",
1176-
)}
1177-
?disabled=${!this.org?.storageQuotaReached &&
1178-
!this.org?.execMinutesQuotaReached}
1179-
>
1180-
<sl-button
1181-
size="small"
1182-
variant="primary"
1183-
?disabled=${this.org?.storageQuotaReached ||
1184-
this.org?.execMinutesQuotaReached}
1185-
@click=${() => void this.runNow()}
1186-
>
1187-
<sl-icon name="play" slot="prefix"></sl-icon>
1188-
${msg("Run Crawl")}
1189-
</sl-button>
1190-
</sl-tooltip>
1191-
</div>
1177+
${when(
1178+
this.isCrawler,
1179+
() => html` <div class="mt-4">${this.renderRunNowButton()}</div> `,
1180+
)}
11921181
</section>
11931182
`;
11941183
}

0 commit comments

Comments
 (0)