diff --git a/ui/app/composables/useConditions.ts b/ui/app/composables/useConditions.ts index f432c992..b3c7487c 100644 --- a/ui/app/composables/useConditions.ts +++ b/ui/app/composables/useConditions.ts @@ -49,7 +49,6 @@ const throwInstead = ref(false); /** * Notification composable for showing success/error messages. */ -const notify = useNotification(); /** * Sorts conditions by priority (descending - higher number first), then name (A-Z). @@ -102,7 +101,7 @@ const ensureSuccess = async (response: Response): Promise => { const handleError = (error: unknown): void => { const message = error instanceof Error ? error.message : 'Unexpected error occurred.'; lastError.value = message; - notify.error(message); + useNotification().error(message); }; /** @@ -212,7 +211,7 @@ const createCondition = async ( const created = await parse_api_response(json); updateConditions(created); - notify.success('Condition created.'); + useNotification().success('Condition created.'); lastError.value = null; if (callback) { @@ -263,7 +262,7 @@ const updateCondition = async ( const updated = await parse_api_response(json); updateConditions(updated); - notify.success(`Condition '${updated.name}' updated.`); + useNotification().success(`Condition '${updated.name}' updated.`); lastError.value = null; if (callback) { @@ -314,7 +313,7 @@ const patchCondition = async ( const updated = await parse_api_response(json); updateConditions(updated); - notify.success(`Condition '${updated.name}' updated.`); + useNotification().success(`Condition '${updated.name}' updated.`); lastError.value = null; if (callback) { @@ -352,7 +351,7 @@ const deleteCondition = async ( await ensureSuccess(response); removeCondition(id); - notify.success('Condition deleted.'); + useNotification().success('Condition deleted.'); lastError.value = null; if (callback) { diff --git a/ui/app/composables/usePresets.ts b/ui/app/composables/usePresets.ts index c8d03fdd..e9021129 100644 --- a/ui/app/composables/usePresets.ts +++ b/ui/app/composables/usePresets.ts @@ -39,7 +39,6 @@ const throwInstead = ref(false); /** * Notification composable for showing success/error messages. */ -const notify = useNotification(); /** * Sorts presets by priority (descending), then name (A-Z). @@ -92,7 +91,7 @@ const ensureSuccess = async (response: Response): Promise => { const handleError = (error: unknown): void => { const message = error instanceof Error ? error.message : 'Unexpected error occurred.'; lastError.value = message; - notify.error(message); + useNotification().error(message); }; /** @@ -199,7 +198,7 @@ const createPreset = async ( const created = await parse_api_response(json); updatePresets(created); - notify.success('Preset created.'); + useNotification().success('Preset created.'); lastError.value = null; if (callback) { @@ -254,7 +253,7 @@ const updatePreset = async ( const updated = await parse_api_response(json); updatePresets(updated); - notify.success(`Preset '${updated.name}' updated.`); + useNotification().success(`Preset '${updated.name}' updated.`); lastError.value = null; if (callback) { @@ -309,7 +308,7 @@ const patchPreset = async ( const updated = await parse_api_response(json); updatePresets(updated); - notify.success(`Preset '${updated.name}' updated.`); + useNotification().success(`Preset '${updated.name}' updated.`); lastError.value = null; if (callback) { @@ -347,7 +346,7 @@ const deletePreset = async ( await ensureSuccess(response); removePreset(id); - notify.success('Preset deleted.'); + useNotification().success('Preset deleted.'); lastError.value = null; if (callback) { diff --git a/ui/app/composables/useTaskDefinitions.ts b/ui/app/composables/useTaskDefinitions.ts index c100152f..04c4b4f9 100644 --- a/ui/app/composables/useTaskDefinitions.ts +++ b/ui/app/composables/useTaskDefinitions.ts @@ -41,7 +41,6 @@ const throwInstead = ref(false); /** * Notification composable for showing success/error messages. */ -const notify = useNotification(); /** * Sorts task definition summaries by priority (ascending), then name (A-Z). @@ -83,7 +82,7 @@ const ensureSuccess = async (response: Response): Promise => { const handleError = (error: unknown): void => { const message = error instanceof Error ? error.message : 'Unexpected error occurred.'; lastError.value = message; - notify.error(message); + useNotification().error(message); }; /** @@ -194,7 +193,7 @@ const createDefinition = async ( updated_at: payload.updated_at, }); - notify.success('Task definition created.'); + useNotification().success('Task definition created.'); lastError.value = null; return payload; } catch (error) { @@ -234,7 +233,7 @@ const updateDefinition = async ( updated_at: payload.updated_at, }); - notify.success('Task definition updated.'); + useNotification().success('Task definition updated.'); lastError.value = null; return payload; } catch (error) { @@ -255,7 +254,7 @@ const deleteDefinition = async (id: number): Promise => { await ensureSuccess(response); removeSummary(id); - notify.success('Task definition deleted.'); + useNotification().success('Task definition deleted.'); lastError.value = null; return true; } catch (error) { @@ -295,7 +294,7 @@ const toggleEnabled = async ( updated_at: payload.updated_at, }); - notify.success(`Task definition ${enabled ? 'enabled' : 'disabled'}.`); + useNotification().success(`Task definition ${enabled ? 'enabled' : 'disabled'}.`); lastError.value = null; return payload; } catch (error) { diff --git a/ui/app/composables/useTasks.ts b/ui/app/composables/useTasks.ts index e08a4658..7ccdc0c4 100644 --- a/ui/app/composables/useTasks.ts +++ b/ui/app/composables/useTasks.ts @@ -48,7 +48,6 @@ const throwInstead = ref(false); /** * Notification composable for showing success/error messages. */ -const notify = useNotification(); /** * Sorts tasks by name (A-Z). @@ -95,7 +94,7 @@ const ensureSuccess = async (response: Response): Promise => { const handleError = (error: unknown): void => { const message = error instanceof Error ? error.message : 'Unexpected error occurred.'; lastError.value = message; - notify.error(message); + useNotification().error(message); }; /** @@ -202,7 +201,7 @@ const createTask = async ( const created = await parse_api_response>(json); if (Array.isArray(created)) { - notify.success(`${created.length} tasks created.`); + useNotification().success(`${created.length} tasks created.`); created.forEach((t) => updateTasksList(t)); lastError.value = null; @@ -214,7 +213,7 @@ const createTask = async ( } updateTasksList(created); - notify.success('Task created.'); + useNotification().success('Task created.'); lastError.value = null; if (callback) { @@ -264,7 +263,7 @@ const updateTask = async ( const updated = await parse_api_response(json); updateTasksList(updated); - notify.success(`Task '${updated.name}' updated.`); + useNotification().success(`Task '${updated.name}' updated.`); lastError.value = null; if (callback) { @@ -311,7 +310,7 @@ const patchTask = async ( const updated = await parse_api_response(json); updateTasksList(updated); - notify.success(`Task '${updated.name}' updated.`); + useNotification().success(`Task '${updated.name}' updated.`); lastError.value = null; if (callback) { @@ -349,7 +348,7 @@ const deleteTask = async ( await ensureSuccess(response); removeTask(id); - notify.success('Task deleted.'); + useNotification().success('Task deleted.'); lastError.value = null; if (callback) { @@ -408,7 +407,7 @@ const markTaskItems = async (id: number): Promise => { const json = await response.json(); const message = json.message || 'All items marked as downloaded.'; - notify.success(message); + useNotification().success(message); lastError.value = null; return message; } catch (error) { @@ -431,7 +430,7 @@ const unmarkTaskItems = async (id: number): Promise => { const json = await response.json(); const message = json.message || 'All items removed from archive.'; - notify.success(message); + useNotification().success(message); lastError.value = null; return message; } catch (error) { @@ -454,7 +453,7 @@ const generateTaskMetadata = async (id: number): Promise(json); - notify.success('Metadata generation completed.'); + useNotification().success('Metadata generation completed.'); lastError.value = null; return metadata; } catch (error) { diff --git a/ui/tests/setup.ts b/ui/tests/setup.ts index 9cf8167e..bb14349b 100644 --- a/ui/tests/setup.ts +++ b/ui/tests/setup.ts @@ -17,6 +17,7 @@ globalThis.requestAnimationFrame = window.requestAnimationFrame globalThis.cancelAnimationFrame = window.cancelAnimationFrame globalThis.localStorage = window.localStorage globalThis.sessionStorage = window.sessionStorage +globalThis.Storage = window.Storage if (!globalThis.crypto) { globalThis.crypto = window.crypto