Skip to content

Commit d6e83db

Browse files
authored
devex: Refactor workflow action menus into component (#2776)
- Adds new `<btrix-workflow-action-menu>` component that consolidates action menu from workflow list and detail views + update Storybook docs. - Adds `.menu-item-success` and `.menu-item-danger` classes + update background color on hover and focus to match Figma design.\
1 parent c0cf6e6 commit d6e83db

File tree

14 files changed

+690
-237
lines changed

14 files changed

+690
-237
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import user from "@/__mocks__/api/users/me";
2+
3+
// API v1.18.0
4+
export default {
5+
name: "",
6+
description: null,
7+
created: "2025-01-23T06:23:32Z",
8+
createdBy: user.id,
9+
modified: "2025-01-28T19:53:15Z",
10+
modifiedBy: user.id,
11+
autoAddCollections: [],
12+
inactive: false,
13+
rev: 2,
14+
crawlAttemptCount: 3,
15+
crawlCount: 3,
16+
crawlSuccessfulCount: 3,
17+
totalSize: 61275,
18+
lastCrawlId: "manual-20250205210838-a5e3cf23-f3c",
19+
lastCrawlStartTime: "2025-02-05T21:08:38Z",
20+
lastStartedBy: user.id,
21+
lastCrawlTime: "2025-02-05T21:09:20Z",
22+
lastCrawlState: "complete",
23+
lastCrawlSize: 61275,
24+
lastRun: "2025-02-05T21:09:20Z",
25+
isCrawlRunning: false,
26+
crawlFilenameTemplate: null,
27+
id: "a5f3cf23-f3ce-4ceb-a232-f2946185370f",
28+
schedule: "",
29+
jobType: "custom",
30+
config: {
31+
seeds: null,
32+
seedFileId: null,
33+
scopeType: "page",
34+
include: null,
35+
exclude: [],
36+
depth: -1,
37+
limit: null,
38+
extraHops: 0,
39+
lang: "en",
40+
blockAds: false,
41+
behaviorTimeout: null,
42+
pageLoadTimeout: null,
43+
pageExtraDelay: null,
44+
postLoadDelay: null,
45+
workers: null,
46+
headless: null,
47+
generateWACZ: null,
48+
combineWARC: null,
49+
useSitemap: false,
50+
failOnFailedSeed: false,
51+
logging: null,
52+
behaviors: "autoscroll,autoplay,autofetch,siteSpecific",
53+
customBehaviors: [],
54+
userAgent: "",
55+
selectLinks: ["a[href]->href"],
56+
clickSelector: "a",
57+
},
58+
tags: [],
59+
crawlTimeout: 0,
60+
maxCrawlSize: 0,
61+
scale: 1,
62+
browserWindows: 4,
63+
oid: "x_example_org_id_x",
64+
profileid: null,
65+
crawlerChannel: "beta",
66+
proxyId: null,
67+
firstSeed: "https://example.com/",
68+
seedCount: 1,
69+
lastCrawlStopping: false,
70+
lastCrawlShouldPause: false,
71+
lastCrawlPausedAt: null,
72+
lastCrawlPausedExpiry: null,
73+
profileName: null,
74+
createdByName: user.name,
75+
modifiedByName: user.name,
76+
lastStartedByName: user.name,
77+
};

frontend/src/components/ui/overflow-dropdown.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { ifDefined } from "lit/directives/if-defined.js";
1212

1313
import { TailwindElement } from "@/classes/TailwindElement";
14+
import type { WorkflowActionMenu } from "@/features/crawl-workflows/workflow-action-menu/workflow-action-menu";
1415

1516
/**
1617
* Dropdown for additional actions.
@@ -40,15 +41,22 @@ export class OverflowDropdown extends TailwindElement {
4041
@query("sl-dropdown")
4142
private readonly dropdown?: SlDropdown;
4243

43-
@queryAssignedElements({ selector: "sl-menu", flatten: true })
44-
private readonly menu!: SlMenu[];
44+
@queryAssignedElements({
45+
selector: "sl-menu, btrix-workflow-action-menu",
46+
flatten: true,
47+
})
48+
private readonly menu!: (SlMenu | WorkflowActionMenu)[];
4549

4650
render() {
4751
return html`
4852
<sl-dropdown
4953
?disabled=${!this.hasMenuItems}
5054
hoist
5155
distance=${ifDefined(this.raised ? "4" : undefined)}
56+
@btrix-select=${() => {
57+
void this.dropdown?.hide();
58+
this.dropdown?.focusOnTrigger();
59+
}}
5260
>
5361
<btrix-button
5462
slot="trigger"

frontend/src/events/btrix-select.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export type BtrixSelectEvent<T = unknown> = CustomEvent<{ item: T }>;
2+
3+
declare global {
4+
interface GlobalEventHandlersEventMap {
5+
"btrix-select": BtrixSelectEvent;
6+
}
7+
}

frontend/src/features/crawl-workflows/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import("./link-selector-table");
55
import("./new-workflow-dialog");
66
import("./queue-exclusion-form");
77
import("./queue-exclusion-table");
8+
import("./workflow-action-menu/workflow-action-menu");
89
import("./workflow-editor");
910
import("./workflow-list");
1011
import("./workflow-schedule-filter");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { WorkflowActionMenu } from "./workflow-action-menu";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { BtrixSelectEvent } from "@/events/btrix-select";
2+
3+
export enum Action {
4+
Run = "run",
5+
TogglePauseResume = "togglePauseResume",
6+
Stop = "stop",
7+
Cancel = "cancel",
8+
EditBrowserWindows = "editBrowserWindows",
9+
EditExclusions = "editExclusions",
10+
Duplicate = "duplicate",
11+
Delete = "delete",
12+
}
13+
14+
export type BtrixSelectActionEvent = BtrixSelectEvent<{ action: Action }>;

0 commit comments

Comments
 (0)