From 9e59b22fd6f494cb059394021952d7ceaad4a52c Mon Sep 17 00:00:00 2001 From: Hugo Carreira Date: Wed, 17 Jul 2024 15:49:46 +0100 Subject: [PATCH 1/3] Disabled plugin dropdown while fetching --- src/components/PluginSelector/PluginSelector.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/PluginSelector/PluginSelector.tsx b/src/components/PluginSelector/PluginSelector.tsx index 04e3a1c..9221711 100644 --- a/src/components/PluginSelector/PluginSelector.tsx +++ b/src/components/PluginSelector/PluginSelector.tsx @@ -31,6 +31,7 @@ export default function PluginSelector({ plugin: string; onPluginChange: (plugin: string) => void; }) { + const [wereFetched, setWereFetched] = React.useState(false); const [plugins, setPlugins] = React.useState< { displayName: string; name: string }[] >([]); @@ -39,7 +40,7 @@ export default function PluginSelector({ React.useEffect(() => { const expired = checkExpired(); - if (expired) { + if (expired || wereFetched) { return; } const url = new URL(window.config.VITE_API_BASE_URL || process.env.VITE_API_BASE_URL || ""); @@ -55,9 +56,10 @@ export default function PluginSelector({ } response.json().then((data) => { setPlugins(data); + setWereFetched(true); }); }); - }, [checkExpired, credential?.credential]); + }, [checkExpired, credential?.credential, wereFetched, setWereFetched]); return ( @@ -65,7 +67,7 @@ export default function PluginSelector({ Plugin Date: Wed, 17 Jul 2024 16:58:13 +0100 Subject: [PATCH 3/3] Sorted plugins by name --- src/components/PluginSelector/PluginSelector.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/PluginSelector/PluginSelector.tsx b/src/components/PluginSelector/PluginSelector.tsx index ce58bc9..2d4ea73 100644 --- a/src/components/PluginSelector/PluginSelector.tsx +++ b/src/components/PluginSelector/PluginSelector.tsx @@ -88,7 +88,9 @@ export default function PluginSelector({ )} MenuProps={MenuProps} > - {plugins.map(({ displayName, name }) => ( + {plugins + .sort((a, b) => a.displayName.toLowerCase() > b.displayName.toLowerCase() ? 1 : -1) + .map(({ displayName, name }) => ( {displayName}