@@ -1643,7 +1676,7 @@ export class WorkflowDetail extends BtrixElement {
private readonly confirmDeleteCrawl = (crawl: Crawl) => {
this.crawlToDelete = crawl;
- this.openDialogName = "delete";
+ this.openDialogName = "deleteCrawl";
};
private async deleteCrawl(crawl: Crawl) {
diff --git a/frontend/src/pages/org/workflows-list.ts b/frontend/src/pages/org/workflows-list.ts
index 6761b1b459..e7f39c81d4 100644
--- a/frontend/src/pages/org/workflows-list.ts
+++ b/frontend/src/pages/org/workflows-list.ts
@@ -1,7 +1,11 @@
import { localized, msg, str } from "@lit/localize";
-import type { SlCheckbox, SlSelectEvent } from "@shoelace-style/shoelace";
+import type {
+ SlCheckbox,
+ SlDialog,
+ SlSelectEvent,
+} from "@shoelace-style/shoelace";
import { html, type PropertyValues } from "lit";
-import { customElement, state } from "lit/decorators.js";
+import { customElement, query, state } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { when } from "lit/directives/when.js";
import queryString from "query-string";
@@ -21,6 +25,7 @@ import { type SelectEvent } from "@/components/ui/search-combobox";
import type { SelectJobTypeEvent } from "@/features/crawl-workflows/new-workflow-dialog";
import { pageHeader } from "@/layouts/pageHeader";
import scopeTypeLabels from "@/strings/crawl-workflows/scopeType";
+import { deleteConfirmation } from "@/strings/ui";
import type { APIPaginatedList, APIPaginationQuery } from "@/types/api";
import { NewWorkflowOnlyScopeType } from "@/types/workflow";
import { isApiError } from "@/utils/api";
@@ -91,6 +96,9 @@ export class WorkflowsList extends BtrixElement {
@state()
private fetchErrorStatusCode?: number;
+ @state()
+ private workflowToDelete?: ListWorkflow;
+
@state()
private orderBy: {
field: SortField;
@@ -106,6 +114,9 @@ export class WorkflowsList extends BtrixElement {
@state()
private filterByCurrentUser = false;
+ @query("#deleteDialog")
+ private readonly deleteDialog?: SlDialog | null;
+
// For fuzzy search:
private readonly searchKeys = ["name", "firstSeed"];
@@ -311,12 +322,52 @@ export class WorkflowsList extends BtrixElement {
`,
- () =>
- this.workflows
- ? this.workflows.total
- ? this.renderWorkflowList()
- : this.renderEmptyState()
- : this.renderLoading(),
+ () => html`
+
+ ${this.workflows
+ ? this.workflows.total
+ ? this.renderWorkflowList()
+ : this.renderEmptyState()
+ : this.renderLoading()}
+
+ `,
+ )}
+ ${this.renderDialogs()}
+ `;
+ }
+
+ private renderDialogs() {
+ return html`
+ ${when(
+ this.workflowToDelete,
+ (workflow) => html`
+
+ ${deleteConfirmation(this.renderName(workflow))}
+
+ void this.deleteDialog?.hide()}
+ >${msg("Cancel")}
+ {
+ void this.deleteDialog?.hide();
+
+ try {
+ await this.delete(workflow);
+ this.workflowToDelete = undefined;
+ } catch {
+ void this.deleteDialog?.show();
+ }
+ }}
+ >${msg("Delete Workflow")}
+
+
+ `,
)}
`;
}
@@ -598,7 +649,11 @@ export class WorkflowsList extends BtrixElement {
void this.delete(workflow)}
+ @click=${async () => {
+ this.workflowToDelete = workflow;
+ await this.updateComplete;
+ void this.deleteDialog?.show();
+ }}
>
${msg("Delete Workflow")}
diff --git a/frontend/src/strings/ui.ts b/frontend/src/strings/ui.ts
new file mode 100644
index 0000000000..95c560639a
--- /dev/null
+++ b/frontend/src/strings/ui.ts
@@ -0,0 +1,9 @@
+import { msg } from "@lit/localize";
+import { html, type TemplateResult } from "lit";
+
+// TODO Refactor all generic confirmation messages to use utility
+export const deleteConfirmation = (name: string | TemplateResult) =>
+ msg(html`
+ Are you sure you want to delete
+ ${name}?
+ `);