From 88a1a3b41ce39848a6a4dd700c754413c14b7a2f Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Mon, 11 Mar 2024 15:27:00 -0400 Subject: [PATCH] Fixes to maintenance stuff --- app/assets/locales/en.json | 3 ++- app/javascript/App.jsx | 1 - .../admin/site_settings/administration/LinksForm.jsx | 4 ++-- .../admin/site_settings/administration/TextForm.jsx | 9 +++++---- .../admin/site_settings/useUpdateSiteSetting.jsx | 3 +++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/assets/locales/en.json b/app/assets/locales/en.json index 8891595a78..edd28bdebd 100644 --- a/app/assets/locales/en.json +++ b/app/assets/locales/en.json @@ -413,7 +413,8 @@ "brand_image_deleted": "The brand image has been deleted.", "privacy_policy_updated": "The privacy policy has been updated.", "helpcenter_updated": "The help center link has been updated.", - "terms_of_service_updated": "The terms of service have been updated." + "terms_of_service_updated": "The terms of service have been updated.", + "maintenance_updated": "The maintenance banner has been updated." }, "recording": { "recording_visibility_updated": "The recording visibility has been updated.", diff --git a/app/javascript/App.jsx b/app/javascript/App.jsx index 24f693ec20..b53dc64152 100644 --- a/app/javascript/App.jsx +++ b/app/javascript/App.jsx @@ -50,7 +50,6 @@ export default function App() { progress: undefined, theme: 'light', className: 'text-center', - onClose: () => localStorage.setItem('maintenanceClosedAt', new Date().toISOString()), }); localStorage.setItem('maintenanceBannerId', toastId); } diff --git a/app/javascript/components/admin/site_settings/administration/LinksForm.jsx b/app/javascript/components/admin/site_settings/administration/LinksForm.jsx index 1540b52088..e74dce969a 100644 --- a/app/javascript/components/admin/site_settings/administration/LinksForm.jsx +++ b/app/javascript/components/admin/site_settings/administration/LinksForm.jsx @@ -27,7 +27,7 @@ export default function LinksForm({ id, value, mutation: useUpdateSiteSettingsAP const updateSiteSettingsAPI = useUpdateSiteSettingsAPI(); const { t } = useTranslation(); - const { methods, fields } = useLinksForm({ defaultValues: { value } }); + const { methods, fields } = useLinksForm({ defaultValues: { value: value } }); return (
@@ -48,5 +48,5 @@ export default function LinksForm({ id, value, mutation: useUpdateSiteSettingsAP LinksForm.propTypes = { id: PropTypes.string.isRequired, mutation: PropTypes.func.isRequired, - value: PropTypes.string.isRequired, + value: PropTypes.string, }; diff --git a/app/javascript/components/admin/site_settings/administration/TextForm.jsx b/app/javascript/components/admin/site_settings/administration/TextForm.jsx index 4659bfbc25..6f8fcd78f7 100644 --- a/app/javascript/components/admin/site_settings/administration/TextForm.jsx +++ b/app/javascript/components/admin/site_settings/administration/TextForm.jsx @@ -29,12 +29,13 @@ export default function TextForm({ id, value, mutation: useUpdateSiteSettingsAPI const { t } = useTranslation(); const maintenanceBannerId = localStorage.getItem('maintenanceBannerId'); - const { methods, fields } = useTextForm({ defaultValues: { value } }); + const { methods, fields } = useTextForm({ defaultValues: { value: value } }); // Function to clear the form const clearForm = () => { - methods.reset({ value: '' }); - toast.dismiss(maintenanceBannerId); + methods.reset({ value: '' }); + toast.dismiss(maintenanceBannerId); + updateSiteSettingsAPI.mutate('') }; return ( @@ -60,5 +61,5 @@ export default function TextForm({ id, value, mutation: useUpdateSiteSettingsAPI TextForm.propTypes = { id: PropTypes.string.isRequired, mutation: PropTypes.func.isRequired, - value: PropTypes.string.isRequired, + value: PropTypes.string, }; diff --git a/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx b/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx index e9a68b43ab..9b3725952f 100644 --- a/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx +++ b/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx @@ -60,6 +60,9 @@ export default function useUpdateSiteSetting(name) { case 'TermsOfService': toast.success(t('toast.success.site_settings.terms_of_service_updated')); break; + case 'Maintenance': + toast.success(t('toast.success.site_settings.maintenance_updated')); + break; default: toast.success(t('toast.success.site_settings.site_setting_updated')); }