From e756c91d7b9d17ebec44ca562bd4286ef1e5061f Mon Sep 17 00:00:00 2001 From: Jacek Chmielewski Date: Wed, 11 Mar 2026 12:19:36 +0100 Subject: [PATCH 1/2] add snackbars to all settings pages, fix form state in client behavior settings --- .../settings/SettingsClientPage/SettingsClientPage.tsx | 8 ++++++++ .../SettingsEnrollmentPage/SettingsEnrollmentPage.tsx | 7 +++++++ .../SettingsGatewayNotificationsPage.tsx | 10 +++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/web/src/pages/settings/SettingsClientPage/SettingsClientPage.tsx b/web/src/pages/settings/SettingsClientPage/SettingsClientPage.tsx index fffe590bfa..6d0efcf348 100644 --- a/web/src/pages/settings/SettingsClientPage/SettingsClientPage.tsx +++ b/web/src/pages/settings/SettingsClientPage/SettingsClientPage.tsx @@ -24,6 +24,7 @@ import api from '../../../shared/api/api'; import { businessBadgeProps } from '../../../shared/components/badges/BusinessBadge'; import { Controls } from '../../../shared/components/Controls/Controls'; import { Button } from '../../../shared/defguard-ui/components/Button/Button'; +import { Snackbar } from '../../../shared/defguard-ui/providers/snackbar/snackbar'; import { useAppForm } from '../../../shared/form'; import { formChangeLogic } from '../../../shared/formLogic'; import { openModal } from '../../../shared/hooks/modalControls/modalsSubjects'; @@ -78,6 +79,12 @@ const Content = () => { meta: { invalidate: [['enterprise_settings'], ['settings']], }, + onSuccess: () => { + Snackbar.success(m.settings_msg_saved()); + }, + onError: () => { + Snackbar.error(m.settings_msg_save_failed()); + }, }); const defaultValues = useMemo((): FormFields => { @@ -105,6 +112,7 @@ const Content = () => { const { result } = canUseBusinessFeature(licenseInfo); if (result) { await patchSettings(value); + form.reset(value); } else { openModal(ModalName.LicenseExpired, { licenseTier: licenseInfo?.tier, diff --git a/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx b/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx index ce3c04c209..c02a2dfcaf 100644 --- a/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx +++ b/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx @@ -12,6 +12,7 @@ import { SettingsCard } from '../../../shared/components/SettingsCard/SettingsCa import { SettingsHeader } from '../../../shared/components/SettingsHeader/SettingsHeader'; import { SettingsLayout } from '../../../shared/components/SettingsLayout/SettingsLayout'; import { Button } from '../../../shared/defguard-ui/components/Button/Button'; +import { Snackbar } from '../../../shared/defguard-ui/providers/snackbar/snackbar'; import { SizedBox } from '../../../shared/defguard-ui/components/SizedBox/SizedBox'; import { ThemeSpacing } from '../../../shared/defguard-ui/types'; import { isPresent } from '../../../shared/defguard-ui/utils/isPresent'; @@ -87,6 +88,12 @@ const Content = ({ settings }: { settings: Settings }) => { meta: { invalidate: ['settings'], }, + onSuccess: () => { + Snackbar.success(m.settings_msg_saved()); + }, + onError: () => { + Snackbar.error(m.settings_msg_save_failed()); + }, }); const defaultValues = useMemo( diff --git a/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx b/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx index 85c9705929..6dd5828cdc 100644 --- a/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx +++ b/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx @@ -14,6 +14,7 @@ import { SettingsLayout } from '../../../shared/components/SettingsLayout/Settin import { Button } from '../../../shared/defguard-ui/components/Button/Button'; import { Fold } from '../../../shared/defguard-ui/components/Fold/Fold'; import { InfoBanner } from '../../../shared/defguard-ui/components/InfoBanner/InfoBanner'; +import { Snackbar } from '../../../shared/defguard-ui/providers/snackbar/snackbar'; import { SizedBox } from '../../../shared/defguard-ui/components/SizedBox/SizedBox'; import { ThemeSpacing } from '../../../shared/defguard-ui/types'; import { isPresent } from '../../../shared/defguard-ui/utils/isPresent'; @@ -83,6 +84,12 @@ const Content = ({ settings }: { settings: SettingsGatewayNotifications }) => { meta: { invalidate: ['settings'], }, + onSuccess: () => { + Snackbar.success(m.settings_msg_saved()); + }, + onError: () => { + Snackbar.error(m.settings_msg_save_failed()); + }, }); const form = useAppForm({ @@ -93,7 +100,8 @@ const Content = ({ settings }: { settings: SettingsGatewayNotifications }) => { onChange: formSchema, }, onSubmit: async ({ value }) => { - mutateAsync(value); + await mutateAsync(value); + form.reset(value); }, }); From 7b4838272dafc93f6b7a980bbd4365c59b8d78bd Mon Sep 17 00:00:00 2001 From: Jacek Chmielewski Date: Wed, 11 Mar 2026 12:27:36 +0100 Subject: [PATCH 2/2] lint fixes --- .../settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx | 2 +- .../SettingsGatewayNotificationsPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx b/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx index c02a2dfcaf..97377822b1 100644 --- a/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx +++ b/web/src/pages/settings/SettingsEnrollmentPage/SettingsEnrollmentPage.tsx @@ -12,8 +12,8 @@ import { SettingsCard } from '../../../shared/components/SettingsCard/SettingsCa import { SettingsHeader } from '../../../shared/components/SettingsHeader/SettingsHeader'; import { SettingsLayout } from '../../../shared/components/SettingsLayout/SettingsLayout'; import { Button } from '../../../shared/defguard-ui/components/Button/Button'; -import { Snackbar } from '../../../shared/defguard-ui/providers/snackbar/snackbar'; import { SizedBox } from '../../../shared/defguard-ui/components/SizedBox/SizedBox'; +import { Snackbar } from '../../../shared/defguard-ui/providers/snackbar/snackbar'; import { ThemeSpacing } from '../../../shared/defguard-ui/types'; import { isPresent } from '../../../shared/defguard-ui/utils/isPresent'; import { useAppForm } from '../../../shared/form'; diff --git a/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx b/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx index 6dd5828cdc..ccf181d949 100644 --- a/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx +++ b/web/src/pages/settings/SettingsGatewayNotificationsPage/SettingsGatewayNotificationsPage.tsx @@ -14,8 +14,8 @@ import { SettingsLayout } from '../../../shared/components/SettingsLayout/Settin import { Button } from '../../../shared/defguard-ui/components/Button/Button'; import { Fold } from '../../../shared/defguard-ui/components/Fold/Fold'; import { InfoBanner } from '../../../shared/defguard-ui/components/InfoBanner/InfoBanner'; -import { Snackbar } from '../../../shared/defguard-ui/providers/snackbar/snackbar'; import { SizedBox } from '../../../shared/defguard-ui/components/SizedBox/SizedBox'; +import { Snackbar } from '../../../shared/defguard-ui/providers/snackbar/snackbar'; import { ThemeSpacing } from '../../../shared/defguard-ui/types'; import { isPresent } from '../../../shared/defguard-ui/utils/isPresent'; import { useAppForm } from '../../../shared/form';