refactor(web): use callbacks for admin setting events (#10997)

This commit is contained in:
Michel Heusschen 2024-07-10 15:57:18 +02:00 committed by GitHub
parent 545b206076
commit 1dd1d36120
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 125 additions and 153 deletions

View file

@ -1,9 +1,8 @@
<script lang="ts">
import type { SystemConfigDto } from '@immich/sdk';
import { isEqual } from 'lodash-es';
import { createEventDispatcher } from 'svelte';
import { fade } from 'svelte/transition';
import type { SettingsEventType } from '../admin-settings';
import type { SettingsResetEvent, SettingsSaveEvent } from '../admin-settings';
import SettingTextarea from '$lib/components/shared-components/settings/setting-textarea.svelte';
import SettingButtonsRow from '$lib/components/shared-components/settings/setting-buttons-row.svelte';
import { t } from 'svelte-i18n';
@ -12,8 +11,8 @@
export let defaultConfig: SystemConfigDto;
export let config: SystemConfigDto; // this is the config that is being edited
export let disabled = false;
const dispatch = createEventDispatcher<SettingsEventType>();
export let onReset: SettingsResetEvent;
export let onSave: SettingsSaveEvent;
</script>
<div>
@ -30,8 +29,8 @@
/>
<SettingButtonsRow
on:reset={({ detail }) => dispatch('reset', { ...detail, configKeys: ['theme'] })}
on:save={() => dispatch('save', { theme: config.theme })}
onReset={(options) => onReset({ ...options, configKeys: ['theme'] })}
onSave={() => onSave({ theme: config.theme })}
showResetToDefault={!isEqual(savedConfig, defaultConfig)}
{disabled}
/>