|
1 | 1 | <script lang="ts"> |
2 | 2 | import emptyWorkflows from '$lib/assets/empty-workflows.svg'; |
3 | 3 | import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte'; |
| 4 | + import OnEvents from '$lib/components/OnEvents.svelte'; |
4 | 5 | import EmptyPlaceholder from '$lib/components/shared-components/empty-placeholder.svelte'; |
5 | 6 | import { |
6 | 7 | getWorkflowActions, |
7 | 8 | getWorkflowShowSchemaAction, |
8 | 9 | handleCreateWorkflow, |
9 | | - handleDeleteWorkflow, |
10 | | - handleToggleWorkflowEnabled, |
11 | 10 | type WorkflowPayload, |
12 | 11 | } from '$lib/services/workflow.service'; |
13 | 12 | import type { PluginFilterResponseDto, WorkflowResponseDto } from '@immich/sdk'; |
|
91 | 90 |
|
92 | 91 | const getJson = (workflow: WorkflowResponseDto) => JSON.stringify(constructPayload(workflow), null, 2); |
93 | 92 |
|
94 | | - const onToggleEnabled = async (workflow: WorkflowResponseDto) => { |
95 | | - const updated = await handleToggleWorkflowEnabled(workflow); |
96 | | - if (updated) { |
97 | | - workflows = workflows.map((w) => (w.id === updated.id ? updated : w)); |
98 | | - } |
| 93 | + const onWorkflowUpdate = (updatedWorkflow: WorkflowResponseDto) => { |
| 94 | + workflows = workflows.map((currentWorkflow) => |
| 95 | + currentWorkflow.id === updatedWorkflow.id ? updatedWorkflow : currentWorkflow, |
| 96 | + ); |
99 | 97 | }; |
100 | 98 |
|
101 | | - const onDeleteWorkflow = async (workflow: WorkflowResponseDto) => { |
102 | | - const deleted = await handleDeleteWorkflow(workflow); |
103 | | - if (deleted) { |
104 | | - workflows = workflows.filter((w) => w.id !== workflow.id); |
105 | | - } |
| 99 | + const onWorkflowDelete = (deletedWorkflow: WorkflowResponseDto) => { |
| 100 | + workflows = workflows.filter((currentWorkflow) => currentWorkflow.id !== deletedWorkflow.id); |
106 | 101 | }; |
107 | 102 |
|
108 | 103 | const getFilterLabel = (filterId: string) => { |
|
135 | 130 | target: event.currentTarget as HTMLElement, |
136 | 131 | position: 'top-left', |
137 | 132 | items: [ |
138 | | - { |
139 | | - ...ToggleEnabled, |
140 | | - onAction: () => void onToggleEnabled(workflow), |
141 | | - }, |
| 133 | + ToggleEnabled, |
142 | 134 | Edit, |
143 | 135 | getWorkflowShowSchemaAction($t, expandedWorkflows.has(workflow.id), () => toggleShowingSchema(workflow.id)), |
144 | 136 | MenuItemType.Divider, |
145 | | - { |
146 | | - ...Delete, |
147 | | - onAction: () => void onDeleteWorkflow(workflow), |
148 | | - }, |
| 137 | + Delete, |
149 | 138 | ], |
150 | 139 | }); |
151 | 140 | }; |
152 | 141 | </script> |
153 | 142 |
|
| 143 | +<OnEvents {onWorkflowUpdate} {onWorkflowDelete} /> |
| 144 | + |
154 | 145 | {#snippet chipItem(title: string)} |
155 | 146 | <span class="rounded-xl border border-gray-200/80 px-3 py-1.5 text-sm dark:border-gray-600 bg-light"> |
156 | 147 | <span class="font-medium text-dark">{title}</span> |
|
0 commit comments