From 817a2bf8ae292a5f4c4fd434d3775928f4e43b98 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 3 Oct 2021 16:24:23 -0700 Subject: [PATCH] Use grid and server SWR for settings box --- .../scripts/components/admin/AdminBox.tsx | 46 +++++++++---------- .../admin/servers/ServerSettingsContainer.tsx | 20 +++----- .../servers/settings/BaseSettingsBox.tsx | 43 +++++------------ 3 files changed, 39 insertions(+), 70 deletions(-) diff --git a/resources/scripts/components/admin/AdminBox.tsx b/resources/scripts/components/admin/AdminBox.tsx index d7e570690..847fc7076 100644 --- a/resources/scripts/components/admin/AdminBox.tsx +++ b/resources/scripts/components/admin/AdminBox.tsx @@ -1,11 +1,12 @@ -import React, { memo } from 'react'; +import React from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; import tw from 'twin.macro'; -import isEqual from 'react-fast-compare'; +import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; interface Props { icon?: IconProp; + isLoading?: boolean; title: string | React.ReactNode; className?: string; padding?: boolean; @@ -13,28 +14,23 @@ interface Props { button?: React.ReactNode; } -const AdminBox = ({ icon, title, className, padding, children, button }: Props) => { - if (padding === undefined) { - padding = true; - } - - return ( -
-
- {typeof title === 'string' ? -

- {icon && }{title} -

- : - title - } - {button} -
-
- {children} -
+const AdminBox = ({ icon, title, className, isLoading, children, button }: Props) => ( +
+ +
+ {typeof title === 'string' ? +

+ {icon && }{title} +

+ : + title + } + {button}
- ); -}; +
+ {children} +
+
+); -export default memo(AdminBox, isEqual); +export default AdminBox; diff --git a/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx b/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx index 2d6de477c..bc8d9ce4f 100644 --- a/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx +++ b/resources/scripts/components/admin/servers/ServerSettingsContainer.tsx @@ -4,7 +4,7 @@ import ServerDeleteButton from '@/components/admin/servers/ServerDeleteButton'; import Label from '@/components/elements/Label'; import Select from '@/components/elements/Select'; import SelectField, { AsyncSelectField, Option } from '@/components/elements/SelectField'; -import { faBalanceScale, faCogs, faConciergeBell, faNetworkWired } from '@fortawesome/free-solid-svg-icons'; +import { faBalanceScale, faConciergeBell, faNetworkWired } from '@fortawesome/free-solid-svg-icons'; import React from 'react'; import AdminBox from '@/components/admin/AdminBox'; import { useHistory } from 'react-router-dom'; @@ -258,24 +258,16 @@ export default function ServerSettingsContainer2 ({ server }: { server: Server }
-
- +
+
- -
+
- -
- -
+
-
-
- -
- +
{ +export default () => { + const { data: server } = getServerDetails(); const { isSubmitting } = useFormikContext(); + if (!server) return null; + return ( - - -
-
- -
- -
- -
-
- -
-
- -
+ +
+ + +
);