From 766ca373b98a0ea0aad13a3990533fab17122b6a Mon Sep 17 00:00:00 2001 From: Vincent T Date: Wed, 20 Nov 2024 14:28:17 -0500 Subject: [PATCH] plugin-catalog: Rework installed list to include all plugins Signed-off-by: Vincent T --- .../src/components/plugins/InstalledList.tsx | 141 ++++++++++++++---- plugin-catalog/src/index.tsx | 7 + 2 files changed, 115 insertions(+), 33 deletions(-) diff --git a/plugin-catalog/src/components/plugins/InstalledList.tsx b/plugin-catalog/src/components/plugins/InstalledList.tsx index 61addb7b..e6d17867 100644 --- a/plugin-catalog/src/components/plugins/InstalledList.tsx +++ b/plugin-catalog/src/components/plugins/InstalledList.tsx @@ -17,46 +17,108 @@ interface Plugin { export interface PurePluginInstalledListProps { installedPlugins: Plugin[] | null; + otherInstalledPlugins: any[] | null; error: string | null; } -export function PurePluginInstalledList({ installedPlugins, error }: PurePluginInstalledListProps) { +export function PurePluginInstalledList({ installedPlugins, otherInstalledPlugins, error }: PurePluginInstalledListProps) { return ( {error ? ( {`Error loading Installed plugins: ${error}`} ) : ( - ( - - - {plugin.pluginTitle} - - - ), - }, - { - label: 'Version', - getter: plugin => plugin.pluginVersion, - }, - { - label: 'Repo', - getter: plugin => plugin.repoName, - }, - { - label: 'Author', - getter: plugin => plugin.author, - }, - ]} - emptyMessage="No plugins installed" - data={installedPlugins || []} - /> + + + + Installed from the Plugin Catalog + ( + + + {plugin.pluginTitle} + + + ), + }, + { + label: 'Version', + getter: plugin => plugin.pluginVersion, + }, + { + label: 'Repo', + getter: plugin => plugin.repoName, + }, + { + label: 'Author', + getter: plugin => plugin.author, + }, + ]} + emptyMessage="No plugins installed" + data={installedPlugins || []} + /> + + + + Other Installed Plugins + + ( + + + {otherInstalledPlugins.name} + + + ), + }, + { + label: 'Version', + getter: otherInstalledPlugins => otherInstalledPlugins.version, + }, + { + label: 'Repo', + getter: plugin => plugin.repoName, + }, + { + label: 'Author', + getter: plugin => plugin.author, + }, + ]} + emptyMessage="No plugins installed" + data={otherInstalledPlugins || []} + /> + + + + + + )} ); @@ -64,6 +126,7 @@ export function PurePluginInstalledList({ installedPlugins, error }: PurePluginI export function PluginInstalledList() { const [installedPlugins, setInstalledPlugins] = useState(null); + const [otherInstalledPlugins, setOtherInstalledPlugins] = useState(null); const [error, setError] = useState(null); useEffect(() => { @@ -81,8 +144,20 @@ export function PluginInstalledList() { } } + async function fetchOtherInstalledPlugins() { + const storedPlugins = localStorage.getItem('headlampPluginSettings'); + if (storedPlugins) { + const parsedPlugins = JSON.parse(storedPlugins); + setOtherInstalledPlugins(parsedPlugins); + console.log('other plugins', storedPlugins) + } else { + setOtherInstalledPlugins([]); + } + } + fetchInstalledPlugins(); + fetchOtherInstalledPlugins(); }, []); - return ; + return ; } diff --git a/plugin-catalog/src/index.tsx b/plugin-catalog/src/index.tsx index ec99cc3f..f640d882 100644 --- a/plugin-catalog/src/index.tsx +++ b/plugin-catalog/src/index.tsx @@ -80,4 +80,11 @@ if (Headlamp.isRunningAsApp()) { }); } +registerRoute({ + path: '/settings/plugins/:name', + exact: true, + noAuthRequired: true, + useClusterURL: false, +}) + registerPluginSettings('@headlamp-k8s/plugin-catalog', Settings, true);