High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat: workflow actions (#28639)
Jason Rasmussencf991e7b1be8
diff --git a/i18n/en.json b/i18n/en.jsonindex cb8cc9c3f9..4ebd24b56b 100644--- a/i18n/en.json+++ b/i18n/en.json@@ -840,6 +840,7 @@"copy_error": "Copy error","copy_file_path": "Copy file path","copy_image": "Copy Image",+ "copy_json": "Copy JSON","copy_link": "Copy link","copy_link_to_clipboard": "Copy link to clipboard","copy_password": "Copy password",@@ -979,6 +980,8 @@"downloading_media": "Downloading media","drag_to_reorder": "Drag to reorder","drop_files_to_upload": "Drop files anywhere to upload",+ "duplicate": "Duplicate",+ "duplicate_workflow": "Duplicate workflow","duplicates": "Duplicates","duplicates_description": "Resolve each group by indicating which, if any, are duplicates.","duration": "Duration",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f380d940d1..64cf0d3d85 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -609,7 +609,7 @@ importers:version: 10.0.1([email protected]([email protected]))'@nestjs/cli':specifier: ^11.0.2- version: 11.0.21(@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])([email protected])([email protected])+ version: 11.0.21(@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])([email protected])([email protected])'@nestjs/schematics':specifier: ^11.0.0@@ -618,7 +618,7 @@ importers:version: 11.1.21(@nestjs/[email protected]([email protected])([email protected]))(@nestjs/[email protected])(@nestjs/[email protected])'@swc/core':specifier: ^1.4.14- version: 1.15.33(@swc/[email protected])+ version: 1.15.33(@swc/[email protected])'@types/archiver':specifier: ^7.0.0version: 7.0.0@@ -738,7 +738,7 @@ importers:unplugin-swc:specifier: ^1.4.5vite-tsconfig-paths:specifier: ^6.0.0version: 6.1.1([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))@@ -758,8 +758,8 @@ importers:specifier: workspace:*version: link:../packages/sdk'@immich/ui':- specifier: ^0.79.0- version: 0.79.0(@sveltejs/[email protected](@opentelemetry/[email protected])(@sveltejs/[email protected]([email protected](@typescript-eslint/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))+ specifier: ^0.79.2+ version: 0.79.2(@sveltejs/[email protected](@opentelemetry/[email protected])(@sveltejs/[email protected]([email protected](@typescript-eslint/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))'@mapbox/mapbox-gl-rtl-text':specifier: 0.4.0version: 0.4.0@@ -1691,6 +1691,10 @@ packages:resolution: {integrity: sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==}engines: {node: '>=6.9.0'}+ '@babel/[email protected]':+ resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==}+ engines: {node: '>=6.9.0'}+'@babel/[email protected]':resolution: {integrity: sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ==}engines: {node: '>=6.9.0'}@@ -3204,8 +3208,8 @@ packages:resolution: {integrity: sha512-O1SJ+BbeFVsUTF4af1MfagJZM+lPgLjI8lQ3SZNjpo8SGJReSbUl2ii03OKuGni/G0yp2GnRLpOTNSHYGtVrcg==}hasBin: true- '@immich/[email protected]':- resolution: {integrity: sha512-UEQZrP8CTc4Kth1xCV8/6Xmk1P51GQKISC7vKqcrM0BO0fxCaNwJK8Ocn6R8baVqH52JYfPb1yQR9bweBnCjXw==}+ '@immich/[email protected]':+ resolution: {integrity: sha512-tnpYhYHrjrFJK18QglRMzPUtHv6q5V6tW38HiAraQJBv7MCg+yaJDrdF8omM2L5F311FGlv1PZLJYvmR4e49PA==}peerDependencies:'@sveltejs/kit': ^2.13.0svelte: ^5.0.0@@ -4982,8 +4986,8 @@ packages:'@swc/[email protected]':resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}- '@swc/[email protected]':- resolution: {integrity: sha512-jI/VAmtdjB/RnI8GTnokyX7Ug8c+g+ffD6QRLa6XQewtnGyukKkKSk3wLTM3b5cjt1jNh9x0jfVlagdN2gDKQg==}+ '@swc/[email protected]':+ resolution: {integrity: sha512-/e2Ly3Docn9kYByap6TV4oquJ3wQuz3c+kC74riqtkwU9CwTMeuj6t2rW+bRr4pyOx/CYQM4wr0RgaKQwGEz0A==}'@swc/[email protected]':resolution: {integrity: sha512-lyMwd7WGgG79RS7EERZV3T8wMdmPq3xwyg+1nmAM64kIhx5yl+juO2PYIHb7vTiPgPCj8LYjsNV2T5wiQHUEaw==}@@ -13787,6 +13791,8 @@ snapshots:'@babel/[email protected]': {}+ '@babel/[email protected]': {}+'@babel/[email protected]':dependencies:'@babel/code-frame': 7.29.0@@ -15879,7 +15885,7 @@ snapshots:pg-connection-string: 2.13.0postgres: 3.4.9- '@immich/[email protected](@sveltejs/[email protected](@opentelemetry/[email protected])(@sveltejs/[email protected]([email protected](@typescript-eslint/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))':+ '@immich/[email protected](@sveltejs/[email protected](@opentelemetry/[email protected])(@sveltejs/[email protected]([email protected](@typescript-eslint/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])))([email protected](@typescript-eslint/[email protected]))':dependencies:'@internationalized/date': 3.12.1'@mdi/js': 7.4.47@@ -16035,7 +16041,7 @@ snapshots:'@internationalized/[email protected]':dependencies:- '@swc/helpers': 0.5.21+ '@swc/helpers': 0.5.22'@ioredis/[email protected]': {}@@ -16438,7 +16444,7 @@ snapshots:bullmq: 5.76.10tslib: 2.8.1- '@nestjs/[email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])([email protected])([email protected])':+ '@nestjs/[email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])([email protected])([email protected])':dependencies:'@angular-devkit/core': 19.2.24([email protected])'@angular-devkit/schematics': 19.2.24([email protected])@@ -16449,17 +16455,17 @@ snapshots:chokidar: 4.0.3cli-table3: 0.6.5commander: 4.1.1- fork-ts-checker-webpack-plugin: 9.1.0([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]))+ fork-ts-checker-webpack-plugin: 9.1.0([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]))glob: 13.0.6node-emoji: 1.11.0ora: 5.4.1tsconfig-paths: 4.2.0tsconfig-paths-webpack-plugin: 4.2.0typescript: 5.9.3- webpack: 5.106.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])+ webpack: 5.106.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])webpack-node-externals: 3.0.0optionalDependencies:- '@swc/core': 1.15.33(@swc/[email protected])+ '@swc/core': 1.15.33(@swc/[email protected])transitivePeerDependencies:- '@minify-html/node'- '@swc/css'@@ -17438,7 +17444,7 @@ snapshots:dependencies:- '@babel/runtime': 7.29.2+ '@babel/runtime': 7.29.7invariant: 2.2.4prop-types: 15.8.1react: 19.2.6@@ -17647,7 +17653,7 @@ snapshots:'@swc/[email protected]':optional: true- '@swc/[email protected](@swc/[email protected])':+ '@swc/[email protected](@swc/[email protected])':dependencies:'@swc/counter': 0.1.3'@swc/types': 0.1.26@@ -17664,11 +17670,11 @@ snapshots:'@swc/core-win32-arm64-msvc': 1.15.33'@swc/core-win32-ia32-msvc': 1.15.33'@swc/core-win32-x64-msvc': 1.15.33- '@swc/helpers': 0.5.21+ '@swc/helpers': 0.5.22'@swc/[email protected]': {}- '@swc/[email protected]':+ '@swc/[email protected]':dependencies:tslib: 2.8.1@@ -21084,7 +21090,7 @@ snapshots:cross-spawn: 7.0.6signal-exit: 4.1.0- [email protected]([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])):+ [email protected]([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])):dependencies:'@babel/code-frame': 7.29.0chalk: 4.1.2@@ -21099,7 +21105,7 @@ snapshots:semver: 7.8.0tapable: 2.3.3typescript: 5.9.3- webpack: 5.106.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])+ webpack: 5.106.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])@@ -25761,15 +25767,15 @@ snapshots:- bare-abort-controller- react-native-b4a- [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])):+ [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])):dependencies:'@jridgewell/trace-mapping': 0.3.31jest-worker: 27.5.1schema-utils: 4.3.3terser: 5.47.1- webpack: 5.106.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])+ webpack: 5.106.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])optionalDependencies:- '@swc/core': 1.15.33(@swc/[email protected])+ '@swc/core': 1.15.33(@swc/[email protected])esbuild: 0.28.0lightningcss: 1.32.0@@ -26176,10 +26182,10 @@ snapshots:dependencies:'@rollup/pluginutils': 5.3.0([email protected])- '@swc/core': 1.15.33(@swc/[email protected])+ '@swc/core': 1.15.33(@swc/[email protected])load-tsconfig: 0.2.5unplugin: 2.3.11transitivePeerDependencies:@@ -26578,7 +26584,7 @@ snapshots:- [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]):+ [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]):dependencies:'@types/eslint-scope': 3.7.7'@types/estree': 1.0.9@@ -26602,7 +26608,7 @@ snapshots:neo-async: 2.6.2schema-utils: 4.3.3tapable: 2.3.3- terser-webpack-plugin: 5.6.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]))+ terser-webpack-plugin: 5.6.0(@swc/[email protected](@swc/[email protected]))([email protected])([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]))watchpack: 2.5.1webpack-sources: 3.4.1transitivePeerDependencies:diff --git a/web/package.json b/web/package.jsonindex aa6e3a2692..2fb37daaed 100644--- a/web/package.json+++ b/web/package.json@@ -27,7 +27,7 @@"@formatjs/icu-messageformat-parser": "^3.0.0","@immich/justified-layout-wasm": "^0.4.3","@immich/sdk": "workspace:*",- "@immich/ui": "^0.79.0",+ "@immich/ui": "^0.79.2","@mapbox/mapbox-gl-rtl-text": "0.4.0","@mdi/js": "^7.4.47","@noble/hashes": "^2.2.0",diff --git a/web/src/lib/modals/WorkflowDuplicateModal.svelte b/web/src/lib/modals/WorkflowDuplicateModal.sveltenew file mode 100644index 0000000000..0b1286d499--- /dev/null+++ b/web/src/lib/modals/WorkflowDuplicateModal.svelte@@ -0,0 +1,53 @@+<script lang="ts">+ import { goto } from '$app/navigation';+ import { Route } from '$lib/route';+ import { handleCreateWorkflow } from '$lib/services/workflow.service';+ import { WorkflowTrigger, type WorkflowResponseDto } from '@immich/sdk';+ import { Field, FormModal, Input, Textarea, VStack } from '@immich/ui';+ import { t } from 'svelte-i18n';++ type Props = {+ workflow: WorkflowResponseDto;+ onClose: () => void;+ };++ const { workflow, onClose }: Props = $props();++ let name = $state(workflow.name ?? '');+ let description = $state(workflow.description ?? '');+ let trigger = $state<WorkflowTrigger>(workflow.trigger);++ const onSubmit = async () => {+ const response = await handleCreateWorkflow({+ name,+ description,+ trigger,+ steps: workflow.steps,+ enabled: false,+ });++ if (response) {+ await goto(Route.viewWorkflow({ id: response.id }));+ onClose();+ }+ };+</script>++<FormModal+ title={$t('duplicate_workflow')}+ {onClose}+ {onSubmit}+ disabled={!name || !trigger}+ size="medium"+ submitText={$t('create')}+>+ <VStack gap={4}>+ <Field label={$t('name')} required>+ <Input placeholder={$t('workflow_name')} bind:value={name} />+ </Field>++ <Field label={$t('description')}>+ <Textarea grow placeholder={$t('workflow_description')} bind:value={description} />+ </Field>+ </VStack>+</FormModal>diff --git a/web/src/lib/services/asset.service.ts b/web/src/lib/services/asset.service.tsindex b0d89ebd57..8804c23ec2 100644--- a/web/src/lib/services/asset.service.ts+++ b/web/src/lib/services/asset.service.ts@@ -42,7 +42,7 @@ import AssetAddToAlbumModal from '$lib/modals/AssetAddToAlbumModal.svelte';import AssetTagModal from '$lib/modals/AssetTagModal.svelte';import SharedLinkCreateModal from '$lib/modals/SharedLinkCreateModal.svelte';import { getAssetMediaUrl, getSharedLink, sleep } from '$lib/utils';-import { downloadUrl } from '$lib/utils/asset-utils';+import { downloadUrl } from '$lib/utils';import { handleError } from '$lib/utils/handle-error';import { getFormatter } from '$lib/utils/i18n';diff --git a/web/src/lib/services/system-config.service.ts b/web/src/lib/services/system-config.service.tsindex da9e535da6..cc7c961d1e 100644--- a/web/src/lib/services/system-config.service.ts+++ b/web/src/lib/services/system-config.service.ts@@ -3,10 +3,8 @@ import { toastManager, type ActionItem } from '@immich/ui';import { mdiContentCopy, mdiDownload, mdiUpload } from '@mdi/js';import { isEqual } from 'lodash-es';import type { MessageFormatter } from 'svelte-i18n';-import { downloadManager } from '$lib/managers/download-manager.svelte';import { eventManager } from '$lib/managers/event-manager.svelte';-import { copyToClipboard } from '$lib/utils';-import { downloadBlob } from '$lib/utils/asset-utils';+import { copyToClipboard, downloadJson } from '$lib/utils';import { handleError } from '$lib/utils/handle-error';import { getFormatter } from '$lib/utils/i18n';@@ -19,7 +17,7 @@ export const getSystemConfigActions = (title: $t('copy_to_clipboard'),description: $t('admin.copy_config_to_clipboard_description'),icon: mdiContentCopy,- onAction: () => handleCopyToClipboard(config),+ onAction: () => copyToClipboard(config),shortcuts: { shift: true, key: 'c' },};@@ -27,7 +25,7 @@ export const getSystemConfigActions = (title: $t('export_as_json'),description: $t('admin.export_config_as_json_description'),icon: mdiDownload,- onAction: () => handleDownloadConfig(config),+ onAction: () => downloadJson(config, 'immich-config.json'),shortcuts: [{ shift: true, key: 's' },{ shift: true, key: 'd' },@@ -65,31 +63,6 @@ export const handleSystemConfigSave = async (update: Partial<SystemConfigDto>) =}};-// https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify/43636793#43636793-const jsonReplacer = (_key: string, value: unknown) =>- value instanceof Object && !Array.isArray(value)- ? Object.keys(value)- .sort()- // eslint-disable-next-line unicorn/no-array-reduce- .reduce((sorted: { [key: string]: unknown }, key) => {- sorted[key] = (value as { [key: string]: unknown })[key];- return sorted;- }, {})- : value;--export const handleCopyToClipboard = async (config: SystemConfigDto) => {- await copyToClipboard(JSON.stringify(config, jsonReplacer, 2));-};--export const handleDownloadConfig = (config: SystemConfigDto) => {- const blob = new Blob([JSON.stringify(config, jsonReplacer, 2)], { type: 'application/json' });- const downloadKey = 'immich-config.json';- downloadManager.add(downloadKey, blob.size);- downloadManager.update(downloadKey, blob.size);- downloadBlob(blob, downloadKey);- setTimeout(() => downloadManager.clear(downloadKey), 5000);-};-export const handleUploadConfig = () => {const input = globalThis.document.createElement('input');input.setAttribute('type', 'file');diff --git a/web/src/lib/services/workflow.service.ts b/web/src/lib/services/workflow.service.tsindex 55b263ec83..79358b9ee4 100644--- a/web/src/lib/services/workflow.service.ts+++ b/web/src/lib/services/workflow.service.ts@@ -10,12 +10,25 @@ import {type WorkflowUpdateDto,} from '@immich/sdk';import { modalManager, toastManager, type ActionItem } from '@immich/ui';-import { mdiCodeJson, mdiDelete, mdiFileDocumentMultipleOutline, mdiPause, mdiPencil, mdiPlay, mdiPlus } from '@mdi/js';+import {+ mdiCodeJson,+ mdiContentCopy,+ mdiContentDuplicate,+ mdiDeleteOutline,+ mdiDownload,+ mdiFileDocumentMultipleOutline,+ mdiPause,+ mdiPencil,+ mdiPlay,+ mdiPlus,+} from '@mdi/js';import type { MessageFormatter } from 'svelte-i18n';import { goto } from '$app/navigation';import { eventManager } from '$lib/managers/event-manager.svelte';+import WorkflowDuplicateModal from '$lib/modals/WorkflowDuplicateModal.svelte';import WorkflowTemplatePicker from '$lib/modals/WorkflowTemplatePicker.svelte';import { Route } from '$lib/route';+import { copyToClipboard, downloadJson } from '$lib/utils';import { handleError } from '$lib/utils/handle-error';import { getFormatter } from '$lib/utils/i18n';@@ -47,10 +60,50 @@ export const getWorkflowActions = ($t: MessageFormatter, workflow: WorkflowRespoconst ToggleEnabled: ActionItem = {title: workflow.enabled ? $t('disable') : $t('enable'),icon: workflow.enabled ? mdiPause : mdiPlay,- color: workflow.enabled ? 'danger' : 'primary',onAction: () => handleUpdateWorkflow(workflow.id, { enabled: !workflow.enabled }),};+ const CopyJson: ActionItem = {+ title: $t('copy_json'),+ icon: mdiContentCopy,+ onAction: () =>+ copyToClipboard(+ JSON.stringify(+ {+ name: workflow.name,+ description: workflow.description,+ enabled: workflow.enabled,+ trigger: workflow.trigger,+ steps: workflow.steps,+ },+ null,+ 2,+ ),+ ),+ };++ const Download: ActionItem = {+ title: $t('download'),+ icon: mdiDownload,+ onAction: () =>+ downloadJson(+ {+ name: workflow.name,+ description: workflow.description,+ enabled: workflow.enabled,+ trigger: workflow.trigger,+ steps: workflow.steps,+ },+ 'workflow.json',+ ),+ };++ const Duplicate: ActionItem = {+ title: $t('duplicate'),+ icon: mdiContentDuplicate,+ onAction: async () => modalManager.show(WorkflowDuplicateModal, { workflow }),+ };+const Edit: ActionItem = {title: $t('edit'),icon: mdiPencil,@@ -59,14 +112,12 @@ export const getWorkflowActions = ($t: MessageFormatter, workflow: WorkflowRespoconst Delete: ActionItem = {title: $t('delete'),- icon: mdiDelete,+ icon: mdiDeleteOutline,color: 'danger',- onAction: async () => {- await handleDeleteWorkflow(workflow);- },+ onAction: () => handleDeleteWorkflow(workflow),};- return { ToggleEnabled, Edit, Delete };+ return { CopyJson, Download, Duplicate, ToggleEnabled, Edit, Delete };};export const getWorkflowShowSchemaAction = (@@ -85,10 +136,10 @@ export const handleCreateWorkflow = async (dto: WorkflowCreateDto) => {try {const response = await createWorkflow({ workflowCreateDto: dto });eventManager.emit('WorkflowCreate', response);- return true;+ toastManager.success();+ return response;} catch (error) {handleError(error, $t('errors.unable_to_create'));- return false;}};diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.tsindex 73063a8292..397e32e136 100644--- a/web/src/lib/utils.ts+++ b/web/src/lib/utils.ts@@ -24,6 +24,7 @@ import { init, register, t } from 'svelte-i18n';import { derived, get } from 'svelte/store';import { defaultLang, locales } from '$lib/constants';import { authManager } from '$lib/managers/auth-manager.svelte';+import { downloadManager } from '$lib/managers/download-manager.svelte';import { alwaysLoadOriginalFile, lang } from '$lib/stores/preferences.store';import { isWebCompatibleImage } from '$lib/utils/asset-utils';import { handleError } from '$lib/utils/handle-error';@@ -249,17 +250,53 @@ export const getProfileImageUrl = (user: UserResponseDto) =>export const getPeopleThumbnailUrl = (person: PersonResponseDto, updatedAt?: string) =>createUrl(getPeopleThumbnailPath(person.id), { updatedAt: updatedAt ?? person.updatedAt });-export const copyToClipboard = async (secret: string) => {+export const copyToClipboard = async (secret: string | unknown) => {const $t = get(t);try {- await navigator.clipboard.writeText(secret);+ const value = typeof secret === 'string' ? secret : JSON.stringify(secret, jsonReplacer, 2);+ await navigator.clipboard.writeText(value);toastManager.info($t('copied_to_clipboard'));} catch (error) {handleError(error, $t('errors.unable_to_copy_to_clipboard'));}};+// https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify/43636793#43636793+const jsonReplacer = (_key: string, value: unknown) =>+ value instanceof Object && !Array.isArray(value)+ ? Object.keys(value)+ .sort()+ // eslint-disable-next-line unicorn/no-array-reduce+ .reduce((sorted: { [key: string]: unknown }, key) => {+ sorted[key] = (value as { [key: string]: unknown })[key];+ return sorted;+ }, {})+ : value;++export const downloadUrl = (url: string, filename: string) => {+ const anchor = document.createElement('a');+ anchor.href = url;+ anchor.download = filename;++ document.body.append(anchor);+ anchor.click();+ anchor.remove();++ URL.revokeObjectURL(url);+};++export const downloadBlob = (data: Blob, filename: string) => downloadUrl(URL.createObjectURL(data), filename);++export const downloadJson = (data: unknown, filename: string) => {+ const blob = new Blob([JSON.stringify(data, jsonReplacer, 2)], { type: 'application/json' });+ const downloadKey = filename;+ downloadManager.add(downloadKey, blob.size);+ downloadManager.update(downloadKey, blob.size);+ downloadBlob(blob, downloadKey);+ setTimeout(() => downloadManager.clear(downloadKey), 5000);+};+export const oauth = {isCallback: (location: Location) => {const search = location.search;diff --git a/web/src/lib/utils/asset-utils.ts b/web/src/lib/utils/asset-utils.tsindex 1c5ab8e2d9..ced71d80b4 100644--- a/web/src/lib/utils/asset-utils.ts+++ b/web/src/lib/utils/asset-utils.ts@@ -26,7 +26,7 @@ import { authManager } from '$lib/managers/auth-manager.svelte';import { downloadManager } from '$lib/managers/download-manager.svelte';import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';import type { TimelineAsset } from '$lib/managers/timeline-manager/types';-import { downloadRequest, withError } from '$lib/utils';+import { downloadBlob, downloadRequest, withError } from '$lib/utils';import { getByteUnitString } from '$lib/utils/byte-units';import { getFormatter } from '$lib/utils/i18n';import { navigate } from '$lib/utils/navigation';@@ -73,32 +73,6 @@ export const removeTag = async ({return assetIds;};-export const downloadBlob = (data: Blob, filename: string) => {- const url = URL.createObjectURL(data);-- const anchor = document.createElement('a');- anchor.href = url;- anchor.download = filename;-- document.body.append(anchor);- anchor.click();- anchor.remove();-- URL.revokeObjectURL(url);-};--export const downloadUrl = (url: string, filename: string) => {- const anchor = document.createElement('a');- anchor.href = url;- anchor.download = filename;-- document.body.append(anchor);- anchor.click();- anchor.remove();-- URL.revokeObjectURL(url);-};-export const downloadArchive = async (fileName: string, options: Omit<DownloadInfoDto, 'archiveSize'>) => {const archiveSize = authManager.authenticated ? authManager.preferences.download.archiveSize : undefined;const dto = { ...options, archiveSize };diff --git a/web/src/routes/(user)/workflows/+page.svelte b/web/src/routes/(user)/workflows/+page.svelteindex 49addc83d1..ffb48e9909 100644--- a/web/src/routes/(user)/workflows/+page.svelte+++ b/web/src/routes/(user)/workflows/+page.svelte@@ -16,12 +16,11 @@CardTitle,CodeBlock,Container,+ ContextMenuButton,Icon,- IconButton,MenuItemType,- menuManager,} from '@immich/ui';- import { mdiClose, mdiDotsVertical, mdiFlashOutline } from '@mdi/js';+ import { mdiClose, mdiFlashOutline } from '@mdi/js';import { t } from 'svelte-i18n';import { SvelteSet } from 'svelte/reactivity';import type { PageData } from './$types';@@ -36,7 +35,7 @@const expandedIds = new SvelteSet<string>();- const toggleExpanded = (id: string) => {+ const onToggleExpand = (id: string) => {if (expandedIds.has(id)) {expandedIds.delete(id);} else {@@ -44,21 +43,6 @@}};- const showWorkflowMenu = (event: MouseEvent, workflow: WorkflowResponseDto) => {- const { ToggleEnabled, Edit, Delete } = getWorkflowActions($t, workflow);- void menuManager.show({- target: event.currentTarget as HTMLElement,- position: 'top-left',- items: [- ToggleEnabled,- Edit,- getWorkflowShowSchemaAction($t, expandedIds.has(workflow.id), () => toggleExpanded(workflow.id)),- MenuItemType.Divider,- Delete,- ],- });- };-const { Create, UseTemplate } = $derived(getWorkflowsActions($t));const onWorkflowCreate = async (response: WorkflowResponseDto) => {@@ -91,6 +75,8 @@{:else}<div class="my-6 flex flex-col gap-3">{#each workflows as workflow (workflow.id)}+ {@const { ToggleEnabled, Duplicate, Edit, Delete } = getWorkflowActions($t, workflow)}+<Card class="group shadow-none transition-colors hover:border-primary"><CardHeader><a@@ -128,17 +114,16 @@{/if}</div>- <IconButton- shape="round"- variant="ghost"- color="secondary"- icon={mdiDotsVertical}- aria-label={$t('menu')}- onclick={(event: MouseEvent) => {- event.preventDefault();- event.stopPropagation();- showWorkflowMenu(event, workflow);- }}+ <ContextMenuButton+ position="top-left"+ items={[+ ToggleEnabled,+ Edit,+ Duplicate,+ getWorkflowShowSchemaAction($t, expandedIds.has(workflow.id), () => onToggleExpand(workflow.id)),+ MenuItemType.Divider,+ Delete,+ ]}/></a>@@ -152,7 +137,7 @@fullWidthvariant="ghost"color="secondary"- onclick={() => toggleExpanded(workflow.id)}+ onclick={() => onToggleExpand(workflow.id)}>{$t('close')}</Button>diff --git a/web/src/routes/(user)/workflows/[workflowId]/+page.svelte b/web/src/routes/(user)/workflows/[workflowId]/+page.svelteindex 050d9dd605..d013b1d5e6 100644--- a/web/src/routes/(user)/workflows/[workflowId]/+page.svelte+++ b/web/src/routes/(user)/workflows/[workflowId]/+page.svelte@@ -6,7 +6,7 @@import WorkflowEditStepModal from '$lib/modals/WorkflowEditStepModal.svelte';import WorkflowTriggerPicker from '$lib/modals/WorkflowTriggerPicker.svelte';import { Route } from '$lib/route';- import { handleUpdateWorkflow } from '$lib/services/workflow.service';+ import { getWorkflowActions, handleUpdateWorkflow } from '$lib/services/workflow.service';import { getTriggerDescription, getTriggerName } from '$lib/utils/workflow';import type { WorkflowResponseDto, WorkflowStepDto, WorkflowUpdateDto } from '@immich/sdk';import {@@ -83,7 +83,7 @@let dropTargetIndex = $state<number | null>(null);const workflowSummary = $derived({ name, description, trigger, steps });- const workflowJsonContent = $derived<WorkflowJsonContent>({ description, enabled, name, steps, trigger });+ const workflowJsonContent = $derived<WorkflowJsonContent>({ name, description, enabled, trigger, steps });const hasChanges = $derived(enabled !== savedWorkflow.enabled ||@@ -217,6 +217,12 @@}};+ const onWorkflowDelete = async (response: WorkflowResponseDto) => {+ if (id === response.id) {+ await goto(Route.workflows());+ }+ };+const confirmNavigation = async () => {if (!hasChanges) {return true;@@ -273,60 +279,73 @@}});});++ const { Download, Duplicate, CopyJson, Delete } = $derived(+ getWorkflowActions($t, { ...savedWorkflow, name, description, enabled, trigger, steps }),+ );</script>-<OnEvents {onWorkflowUpdate} />+<OnEvents {onWorkflowUpdate} {onWorkflowDelete} /><AppShell class=""><AppShellBar>- <ActionBar static {onClose} translations={{ close: $t('back') }} closeIcon={mdiArrowLeft}>+ <ActionBar+ shape="round"+ static+ {onClose}+ translations={{ close: $t('back') }}+ closeIcon={mdiArrowLeft}+ actions={[Duplicate, CopyJson, Download, Delete].map((item) => ({ ...item, color: undefined }))}+ ><ControlBarHeader><ControlBarTitle>{data.workflow.name}</ControlBarTitle><ControlBarDescription>{data.workflow.description}</ControlBarDescription></ControlBarHeader><ControlBarContent class="flex items-center justify-end gap-6">- <div class="flex gap-1 rounded-full border border-light-200 bg-light p-1" role="group">+ {#if hasChanges}<Button- variant={editMode === 'visual' ? 'filled' : 'ghost'}- color={editMode === 'visual' ? 'primary' : 'secondary'}+ variant="filled"size="small"- leadingIcon={mdiFormatListBulletedSquare}- aria-pressed={editMode === 'visual'}- onclick={() => (editMode = 'visual')}- shape="round"+ color="primary"+ leadingIcon={mdiContentSave}+ disabled={!hasChanges || isSaving}+ loading={isSaving}+ onclick={saveWorkflow}>- {$t('visual')}+ {$t('save')}</Button>- <Button- variant={editMode === 'json' ? 'filled' : 'ghost'}- color={editMode === 'json' ? 'primary' : 'secondary'}- size="small"- leadingIcon={mdiCodeJson}- aria-pressed={editMode === 'json'}- onclick={() => (editMode = 'json')}- shape="round"- >- JSON- </Button>- </div>-- <Button- variant="filled"- size="small"- color="primary"- leadingIcon={mdiContentSave}- disabled={!hasChanges || isSaving}- loading={isSaving}- onclick={saveWorkflow}- >- {$t('save')}- </Button>+ {/if}</ControlBarContent></ActionBar></AppShellBar><Container size="medium" class="pt-8 pb-24" center><VStack gap={4}>+ <div class="flex gap-1 rounded-full border border-light-200 bg-light p-1" role="group">+ <Button+ variant={editMode === 'visual' ? 'filled' : 'ghost'}+ color={editMode === 'visual' ? 'primary' : 'secondary'}+ size="small"+ leadingIcon={mdiFormatListBulletedSquare}+ aria-pressed={editMode === 'visual'}+ onclick={() => (editMode = 'visual')}+ shape="round"+ >+ {$t('visual')}+ </Button>+ <Button+ variant={editMode === 'json' ? 'filled' : 'ghost'}+ color={editMode === 'json' ? 'primary' : 'secondary'}+ size="small"+ leadingIcon={mdiCodeJson}+ aria-pressed={editMode === 'json'}+ onclick={() => (editMode = 'json')}+ shape="round"+ >+ JSON+ </Button>+ </div>+{#if editMode === 'visual'}<Card class="shadow-none" expandable><CardHeader>@@ -354,9 +373,8 @@bind:value={() => name ?? '', (value) => (name = value || null)}/></Field>- <Field label={$t('description')} for="workflow-description">+ <Field label={$t('description')}><Textarea- id="workflow-description"growplaceholder={$t('workflow_description')}bind:value={() => description ?? '', (value) => (description = value || null)}