From a709eeae5da4da23aa4407e1fba496f52076956e Mon Sep 17 00:00:00 2001 From: Ruben Thoms <69145689+rubenthoms@users.noreply.github.com> Date: Mon, 11 Sep 2023 17:23:11 +0200 Subject: [PATCH] Fixed/improved multiple components (#299) --- .../selectEnsemblesDialog.tsx | 1 + .../Settings/private-components/setting.tsx | 27 +++--- .../private-components/syncSettings.tsx | 97 ++++++++++--------- .../src/lib/components/Checkbox/checkbox.tsx | 2 +- .../src/lib/components/Dropdown/dropdown.tsx | 9 +- .../lib/components/RadioGroup/radioGroup.tsx | 16 +-- .../private-components/tag.tsx | 14 ++- .../SmartNodeSelector/smartNodeSelector.tsx | 2 +- .../src/lib/hooks/useElementBoundingRect.ts | 2 + 9 files changed, 90 insertions(+), 80 deletions(-) diff --git a/frontend/src/framework/internal/components/SelectEnsemblesDialog/selectEnsemblesDialog.tsx b/frontend/src/framework/internal/components/SelectEnsemblesDialog/selectEnsemblesDialog.tsx index b53b73022..f3be24941 100644 --- a/frontend/src/framework/internal/components/SelectEnsemblesDialog/selectEnsemblesDialog.tsx +++ b/frontend/src/framework/internal/components/SelectEnsemblesDialog/selectEnsemblesDialog.tsx @@ -174,6 +174,7 @@ export const SelectEnsemblesDialog: React.FC = (prop } + showCloseCross >
diff --git a/frontend/src/framework/internal/components/Settings/private-components/setting.tsx b/frontend/src/framework/internal/components/Settings/private-components/setting.tsx index f01ab1765..1fe3f9530 100644 --- a/frontend/src/framework/internal/components/Settings/private-components/setting.tsx +++ b/frontend/src/framework/internal/components/Settings/private-components/setting.tsx @@ -7,6 +7,7 @@ import { ErrorBoundary } from "@framework/internal/components/ErrorBoundary"; import { useImportState } from "@framework/internal/hooks/moduleHooks"; import { Cog6ToothIcon } from "@heroicons/react/20/solid"; import { CircularProgress } from "@lib/components/CircularProgress"; +import { resolveClassNames } from "@lib/utils/resolveClassNames"; type SettingProps = { moduleInstance: ModuleInstance; @@ -71,10 +72,10 @@ export const Setting: React.FC = (props) => { return (
@@ -86,14 +87,16 @@ export const Setting: React.FC = (props) => { {props.moduleInstance.getTitle()}
-
- +
+
+ +
diff --git a/frontend/src/framework/internal/components/Settings/private-components/syncSettings.tsx b/frontend/src/framework/internal/components/Settings/private-components/syncSettings.tsx index 2f7c7d272..908b875c6 100644 --- a/frontend/src/framework/internal/components/Settings/private-components/syncSettings.tsx +++ b/frontend/src/framework/internal/components/Settings/private-components/syncSettings.tsx @@ -69,54 +69,59 @@ export const SyncSettings: React.FC = (props) => { return true; } + function makeContent() { + const syncableSettingKeys = activeModuleInstance?.getModule().getSyncableSettingKeys() ?? []; + + if (activeModuleId === "" || activeModuleInstance === undefined) { + return
No module selected
; + } + + if (syncableSettingKeys.length === 0) { + return
No syncable settings
; + } + + return ( + + + + + + + + + + {syncableSettingKeys.map((setting) => { + const globallySynced = isGlobalSyncSetting(setting); + return ( + + + + + + ); + })} + +
+ + + +
+ handleGlobalSyncSettingChange(setting, e.target.checked)} + /> + + handleSyncSettingChange(setting, e.target.checked)} + /> + {SyncSettingsMeta[setting].name}
+ ); + } + return ( } visible={drawerContent === DrawerContent.SyncSettings}> - {activeModuleId === "" || activeModuleInstance === undefined ? ( -
No module selected
- ) : ( - - - - - - - - - - {activeModuleInstance - .getModule() - .getSyncableSettingKeys() - .map((setting) => { - const globallySynced = isGlobalSyncSetting(setting); - return ( - - - - - - ); - })} - -
- - - -
- - handleGlobalSyncSettingChange(setting, e.target.checked) - } - /> - - handleSyncSettingChange(setting, e.target.checked)} - /> - {SyncSettingsMeta[setting].name}
- )} + {makeContent()}
); }; diff --git a/frontend/src/lib/components/Checkbox/checkbox.tsx b/frontend/src/lib/components/Checkbox/checkbox.tsx index d3a639cc9..f2d1649a9 100644 --- a/frontend/src/lib/components/Checkbox/checkbox.tsx +++ b/frontend/src/lib/components/Checkbox/checkbox.tsx @@ -50,7 +50,7 @@ export const Checkbox: React.FC = (props) => { {props.label && ( diff --git a/frontend/src/lib/components/Dropdown/dropdown.tsx b/frontend/src/lib/components/Dropdown/dropdown.tsx index 6cdb4dfe1..870f38617 100644 --- a/frontend/src/lib/components/Dropdown/dropdown.tsx +++ b/frontend/src/lib/components/Dropdown/dropdown.tsx @@ -166,14 +166,7 @@ export const Dropdown = withDefaults()(defaultProps, (props) => { setOptionIndexWithFocusToCurrentSelection(); } } - }, [ - inputBoundingRect, - dropdownVisible, - filteredOptions, - selection, - setOptionIndexWithFocusToCurrentSelection, - setStartIndex, - ]); + }, [inputBoundingRect, dropdownVisible, filteredOptions, selection]); const handleOptionClick = React.useCallback( (value: string) => { diff --git a/frontend/src/lib/components/RadioGroup/radioGroup.tsx b/frontend/src/lib/components/RadioGroup/radioGroup.tsx index 1c5f78562..cc262e619 100644 --- a/frontend/src/lib/components/RadioGroup/radioGroup.tsx +++ b/frontend/src/lib/components/RadioGroup/radioGroup.tsx @@ -35,32 +35,32 @@ type RadioProps = { const Radio: React.FC = (props) => { return ( -