feat: Enable deleting workflow from list (#2042)
Adds back workflow list menu item to delete workflow if it's never been run.
This commit is contained in:
parent
2ca9632057
commit
25b1928d44
@ -702,24 +702,19 @@ export class WorkflowDetail extends LiteElement {
|
|||||||
<sl-icon name="files" slot="prefix"></sl-icon>
|
<sl-icon name="files" slot="prefix"></sl-icon>
|
||||||
${msg("Duplicate Workflow")}
|
${msg("Duplicate Workflow")}
|
||||||
</sl-menu-item>
|
</sl-menu-item>
|
||||||
${when(!this.lastCrawlId, () => {
|
${when(
|
||||||
const shouldDeactivate = workflow.crawlCount && !workflow.inactive;
|
!this.lastCrawlId,
|
||||||
return html`
|
() => html`
|
||||||
<sl-divider></sl-divider>
|
<sl-divider></sl-divider>
|
||||||
<sl-menu-item
|
<sl-menu-item
|
||||||
style="--sl-color-neutral-700: var(--danger)"
|
style="--sl-color-neutral-700: var(--danger)"
|
||||||
@click=${() =>
|
@click=${() => void this.delete()}
|
||||||
shouldDeactivate
|
|
||||||
? void this.deactivate()
|
|
||||||
: void this.delete()}
|
|
||||||
>
|
>
|
||||||
<sl-icon name="trash3" slot="prefix"></sl-icon>
|
<sl-icon name="trash3" slot="prefix"></sl-icon>
|
||||||
${shouldDeactivate
|
${msg("Delete Workflow")}
|
||||||
? msg("Deactivate Workflow")
|
|
||||||
: msg("Delete Workflow")}
|
|
||||||
</sl-menu-item>
|
</sl-menu-item>
|
||||||
`;
|
`,
|
||||||
})}
|
)}
|
||||||
</sl-menu>
|
</sl-menu>
|
||||||
</sl-dropdown>
|
</sl-dropdown>
|
||||||
`;
|
`;
|
||||||
@ -1477,41 +1472,9 @@ export class WorkflowDetail extends LiteElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deactivate(): Promise<void> {
|
|
||||||
if (!this.workflow) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.apiFetch(
|
|
||||||
`/orgs/${this.orgId}/crawlconfigs/${this.workflow.id}`,
|
|
||||||
{
|
|
||||||
method: "DELETE",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
this.workflow = {
|
|
||||||
...this.workflow,
|
|
||||||
inactive: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.notify({
|
|
||||||
message: msg(html`Deactivated <strong>${this.renderName()}</strong>.`),
|
|
||||||
variant: "success",
|
|
||||||
icon: "check2-circle",
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
this.notify({
|
|
||||||
message: msg("Sorry, couldn't deactivate Workflow at this time."),
|
|
||||||
variant: "danger",
|
|
||||||
icon: "exclamation-octagon",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async delete(): Promise<void> {
|
private async delete(): Promise<void> {
|
||||||
if (!this.workflow) return;
|
if (!this.workflow) return;
|
||||||
|
|
||||||
const isDeactivating = this.workflow.crawlCount > 0;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.apiFetch(
|
await this.apiFetch(
|
||||||
`/orgs/${this.orgId}/crawlconfigs/${this.workflow.id}`,
|
`/orgs/${this.orgId}/crawlconfigs/${this.workflow.id}`,
|
||||||
@ -1523,17 +1486,15 @@ export class WorkflowDetail extends LiteElement {
|
|||||||
this.navTo(`${this.orgBasePath}/workflows/crawls`);
|
this.navTo(`${this.orgBasePath}/workflows/crawls`);
|
||||||
|
|
||||||
this.notify({
|
this.notify({
|
||||||
message: isDeactivating
|
message: msg(
|
||||||
? msg(html`Deactivated <strong>${this.renderName()}</strong>.`)
|
html`Deleted <strong>${this.renderName()}</strong> Workflow.`,
|
||||||
: msg(html`Deleted <strong>${this.renderName()}</strong>.`),
|
),
|
||||||
variant: "success",
|
variant: "success",
|
||||||
icon: "check2-circle",
|
icon: "check2-circle",
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
this.notify({
|
this.notify({
|
||||||
message: isDeactivating
|
message: msg("Sorry, couldn't delete Workflow at this time."),
|
||||||
? msg("Sorry, couldn't deactivate Workflow at this time.")
|
|
||||||
: msg("Sorry, couldn't delete Workflow at this time."),
|
|
||||||
variant: "danger",
|
variant: "danger",
|
||||||
icon: "exclamation-octagon",
|
icon: "exclamation-octagon",
|
||||||
});
|
});
|
||||||
|
|||||||
@ -500,14 +500,28 @@ export class WorkflowsList extends LiteElement {
|
|||||||
</sl-menu-item>
|
</sl-menu-item>
|
||||||
${when(
|
${when(
|
||||||
this.appState.isCrawler,
|
this.appState.isCrawler,
|
||||||
() =>
|
() => html`
|
||||||
html` <sl-menu-item
|
<sl-menu-item
|
||||||
?disabled=${isArchivingDisabled(this.org, true)}
|
?disabled=${isArchivingDisabled(this.org, true)}
|
||||||
@click=${() => void this.duplicateConfig(workflow)}
|
@click=${() => void this.duplicateConfig(workflow)}
|
||||||
>
|
>
|
||||||
<sl-icon name="files" slot="prefix"></sl-icon>
|
<sl-icon name="files" slot="prefix"></sl-icon>
|
||||||
${msg("Duplicate Workflow")}
|
${msg("Duplicate Workflow")}
|
||||||
</sl-menu-item>`,
|
</sl-menu-item>
|
||||||
|
${when(
|
||||||
|
!workflow.lastCrawlId,
|
||||||
|
() => html`
|
||||||
|
<sl-divider></sl-divider>
|
||||||
|
<sl-menu-item
|
||||||
|
style="--sl-color-neutral-700: var(--danger)"
|
||||||
|
@click=${() => void this.delete(workflow)}
|
||||||
|
>
|
||||||
|
<sl-icon name="trash3" slot="prefix"></sl-icon>
|
||||||
|
${msg("Delete Workflow")}
|
||||||
|
</sl-menu-item>
|
||||||
|
`,
|
||||||
|
)}
|
||||||
|
`,
|
||||||
)}
|
)}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -656,29 +670,6 @@ export class WorkflowsList extends LiteElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deactivate(workflow: ListWorkflow): Promise<void> {
|
|
||||||
try {
|
|
||||||
await this.apiFetch(`/orgs/${this.orgId}/crawlconfigs/${workflow.id}`, {
|
|
||||||
method: "DELETE",
|
|
||||||
});
|
|
||||||
|
|
||||||
void this.fetchWorkflows();
|
|
||||||
this.notify({
|
|
||||||
message: msg(
|
|
||||||
html`Deactivated <strong>${this.renderName(workflow)}</strong>.`,
|
|
||||||
),
|
|
||||||
variant: "success",
|
|
||||||
icon: "check2-circle",
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
this.notify({
|
|
||||||
message: msg("Sorry, couldn't deactivate Workflow at this time."),
|
|
||||||
variant: "danger",
|
|
||||||
icon: "exclamation-octagon",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async delete(workflow: ListWorkflow): Promise<void> {
|
private async delete(workflow: ListWorkflow): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await this.apiFetch(`/orgs/${this.orgId}/crawlconfigs/${workflow.id}`, {
|
await this.apiFetch(`/orgs/${this.orgId}/crawlconfigs/${workflow.id}`, {
|
||||||
@ -688,7 +679,7 @@ export class WorkflowsList extends LiteElement {
|
|||||||
void this.fetchWorkflows();
|
void this.fetchWorkflows();
|
||||||
this.notify({
|
this.notify({
|
||||||
message: msg(
|
message: msg(
|
||||||
html`Deleted <strong>${this.renderName(workflow)}</strong>.`,
|
html`Deleted <strong>${this.renderName(workflow)}</strong> Workflow.`,
|
||||||
),
|
),
|
||||||
variant: "success",
|
variant: "success",
|
||||||
icon: "check2-circle",
|
icon: "check2-circle",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user