mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
refactor(web): use callbacks for admin setting events (#10997)
This commit is contained in:
parent
545b206076
commit
1dd1d36120
20 changed files with 125 additions and 153 deletions
|
|
@ -1,9 +1,8 @@
|
|||
<script lang="ts">
|
||||
import { sendTestEmail, 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 SettingInputField, {
|
||||
SettingInputFieldType,
|
||||
} from '$lib/components/shared-components/settings/setting-input-field.svelte';
|
||||
|
|
@ -24,8 +23,10 @@
|
|||
export let defaultConfig: SystemConfigDto;
|
||||
export let config: SystemConfigDto; // this is the config that is being edited
|
||||
export let disabled = false;
|
||||
export let onReset: SettingsResetEvent;
|
||||
export let onSave: SettingsSaveEvent;
|
||||
|
||||
let isSending = false;
|
||||
const dispatch = createEventDispatcher<SettingsEventType>();
|
||||
|
||||
const handleSendTestEmail = async () => {
|
||||
if (isSending) {
|
||||
|
|
@ -56,7 +57,7 @@
|
|||
});
|
||||
|
||||
if (!disabled) {
|
||||
dispatch('save', { notifications: config.notifications });
|
||||
onSave({ notifications: config.notifications });
|
||||
}
|
||||
} catch (error) {
|
||||
handleError(error, $t('admin.notification_email_test_email_failed'));
|
||||
|
|
@ -156,8 +157,8 @@
|
|||
</div>
|
||||
|
||||
<SettingButtonsRow
|
||||
on:reset={({ detail }) => dispatch('reset', { ...detail, configKeys: ['notifications'] })}
|
||||
on:save={() => dispatch('save', { notifications: config.notifications })}
|
||||
onReset={(options) => onReset({ ...options, configKeys: ['notifications'] })}
|
||||
onSave={() => onSave({ notifications: config.notifications })}
|
||||
showResetToDefault={!isEqual(savedConfig, defaultConfig)}
|
||||
{disabled}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue