|
1 | 1 | <script lang="ts"> |
2 | 2 | import type { PluginActionResponseDto, PluginFilterResponseDto } from '@immich/sdk'; |
3 | | - import { Icon, Modal, ModalBody, Text } from '@immich/ui'; |
| 3 | + import { Modal, ModalBody, Text } from '@immich/ui'; |
4 | 4 | import { mdiFilterOutline, mdiPlayCircleOutline } from '@mdi/js'; |
5 | 5 | import { t } from 'svelte-i18n'; |
6 | 6 |
|
|
18 | 18 | const handleSelect = (type: StepType, item: PluginFilterResponseDto | PluginActionResponseDto) => { |
19 | 19 | onClose({ type, item }); |
20 | 20 | }; |
| 21 | +
|
| 22 | + const getModalTitle = () => { |
| 23 | + if (type === 'filter') { |
| 24 | + return $t('add_filter'); |
| 25 | + } else if (type === 'action') { |
| 26 | + return $t('add_action'); |
| 27 | + } else { |
| 28 | + return $t('add_workflow_step'); |
| 29 | + } |
| 30 | + }; |
| 31 | +
|
| 32 | + const getModalIcon = () => { |
| 33 | + if (type === 'filter') { |
| 34 | + return mdiFilterOutline; |
| 35 | + } else if (type === 'action') { |
| 36 | + return mdiPlayCircleOutline; |
| 37 | + } else { |
| 38 | + return false; |
| 39 | + } |
| 40 | + }; |
21 | 41 | </script> |
22 | 42 |
|
23 | | -<Modal title={$t('add_workflow_step')} icon={false} onClose={() => onClose()}> |
| 43 | +{#snippet stepButton(title: string, description?: string, onclick?: () => void)} |
| 44 | + <button |
| 45 | + type="button" |
| 46 | + {onclick} |
| 47 | + class="flex items-start gap-3 p-3 rounded-lg text-left bg-light-100 hover:border-primary border text-dark" |
| 48 | + > |
| 49 | + <div class="flex-1"> |
| 50 | + <Text color="primary" class="font-medium">{title}</Text> |
| 51 | + {#if description} |
| 52 | + <Text size="small" class="mt-1">{description}</Text> |
| 53 | + {/if} |
| 54 | + </div> |
| 55 | + </button> |
| 56 | +{/snippet} |
| 57 | + |
| 58 | +<Modal title={getModalTitle()} icon={getModalIcon()} onClose={() => onClose()}> |
24 | 59 | <ModalBody> |
25 | 60 | <div class="space-y-6"> |
26 | 61 | <!-- Filters Section --> |
27 | 62 | {#if filters.length > 0 && (!type || type === 'filter')} |
28 | | - <div class="flex items-center gap-2 mb-3"> |
29 | | - <div class="h-6 w-6 rounded-md bg-warning-100 flex items-center justify-center"> |
30 | | - <Icon icon={mdiFilterOutline} size="16" class="text-warning" /> |
31 | | - </div> |
32 | | - <h3 class="text-sm font-semibold">Filters</h3> |
33 | | - </div> |
34 | 63 | <div class="grid grid-cols-1 gap-2"> |
35 | 64 | {#each filters as filter (filter.id)} |
36 | | - <button |
37 | | - type="button" |
38 | | - onclick={() => handleSelect('filter', filter)} |
39 | | - class="flex items-start gap-3 p-3 rounded-lg border bg-light-100 hover:border-warning-500 dark:hover:border-warning-500 text-left" |
40 | | - > |
41 | | - <div class="flex-1"> |
42 | | - <p class="font-medium text-sm">{filter.title}</p> |
43 | | - {#if filter.description} |
44 | | - <p class="text-xs text-light-500 mt-1">{filter.description}</p> |
45 | | - {/if} |
46 | | - </div> |
47 | | - </button> |
| 65 | + {@render stepButton(filter.title, filter.description, () => handleSelect('filter', filter))} |
48 | 66 | {/each} |
49 | 67 | </div> |
50 | 68 | {/if} |
51 | 69 |
|
52 | 70 | <!-- Actions Section --> |
53 | 71 | {#if actions.length > 0 && (!type || type === 'action')} |
54 | | - <div> |
55 | | - <div class="flex items-center gap-2 mb-3"> |
56 | | - <div class="h-6 w-6 rounded-md bg-success-50 flex items-center justify-center"> |
57 | | - <Icon icon={mdiPlayCircleOutline} size="16" class="text-success" /> |
58 | | - </div> |
59 | | - <h3 class="text-sm font-semibold">Actions</h3> |
60 | | - </div> |
61 | | - <div class="grid grid-cols-1 gap-2"> |
62 | | - {#each actions as action (action.id)} |
63 | | - <button |
64 | | - type="button" |
65 | | - onclick={() => handleSelect('action', action)} |
66 | | - class="flex items-start gap-3 p-3 rounded-lg border bg-light-100 hover:border-success-500 dark:hover:border-success-500 text-left" |
67 | | - > |
68 | | - <div class="flex-1"> |
69 | | - <p class="font-medium text-sm">{action.title}</p> |
70 | | - {#if action.description} |
71 | | - <Text size="small" class="text-light-500 mt-1">{action.description}</Text> |
72 | | - {/if} |
73 | | - </div> |
74 | | - </button> |
75 | | - {/each} |
76 | | - </div> |
| 72 | + <div class="grid grid-cols-1 gap-2"> |
| 73 | + {#each actions as action (action.id)} |
| 74 | + {@render stepButton(action.title, action.description, () => handleSelect('action', action))} |
| 75 | + {/each} |
77 | 76 | </div> |
78 | 77 | {/if} |
79 | 78 | </div> |
|
0 commit comments