Skip to content

Commit 89374b5

Browse files
committed
plugin-catalog: Rework installed list to include all plugins
Signed-off-by: Vincent T <[email protected]>
1 parent c677ea6 commit 89374b5

File tree

2 files changed

+109
-33
lines changed

2 files changed

+109
-33
lines changed

plugin-catalog/src/components/plugins/InstalledList.tsx

Lines changed: 108 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,116 @@ interface Plugin {
1717

1818
export interface PurePluginInstalledListProps {
1919
installedPlugins: Plugin[] | null;
20+
otherInstalledPlugins: any[] | null;
2021
error: string | null;
2122
}
2223

23-
export function PurePluginInstalledList({ installedPlugins, error }: PurePluginInstalledListProps) {
24+
export function PurePluginInstalledList({ installedPlugins, otherInstalledPlugins, error }: PurePluginInstalledListProps) {
2425
return (
2526
<SectionBox title="Installed" textAlign="center" paddingTop={2}>
2627
{error ? (
2728
<Typography>{`Error loading Installed plugins: ${error}`}</Typography>
2829
) : (
29-
<SimpleTable
30-
columns={[
31-
{
32-
label: 'Name',
33-
getter: plugin => (
34-
<Box>
35-
<Link
36-
routeName="/plugin-catalog/:repoName/:pluginName"
37-
params={{ repoName: plugin.repoName, pluginName: plugin.folderName }}
38-
>
39-
{plugin.pluginTitle}
40-
</Link>
41-
</Box>
42-
),
43-
},
44-
{
45-
label: 'Version',
46-
getter: plugin => plugin.pluginVersion,
47-
},
48-
{
49-
label: 'Repo',
50-
getter: plugin => plugin.repoName,
51-
},
52-
{
53-
label: 'Author',
54-
getter: plugin => plugin.author,
55-
},
56-
]}
57-
emptyMessage="No plugins installed"
58-
data={installedPlugins || []}
59-
/>
30+
<Box sx={{
31+
display: 'flex',
32+
flexDirection: 'column',
33+
gap: 2,
34+
}} >
35+
36+
<Box sx={{
37+
display: 'flex',
38+
flexDirection: 'column',
39+
gap: 2,
40+
alignItems: 'start',
41+
}}>
42+
<Typography variant="h6" components="h2">Installed from the Plugin Catalog</Typography>
43+
<SimpleTable
44+
columns={[
45+
{
46+
label: 'Name',
47+
getter: plugin => (
48+
<Box>
49+
<Link
50+
routeName="/plugin-catalog/:repoName/:pluginName"
51+
params={{ repoName: plugin.repoName, pluginName: plugin.folderName }}
52+
>
53+
{plugin.pluginTitle}
54+
</Link>
55+
</Box>
56+
),
57+
},
58+
{
59+
label: 'Version',
60+
getter: plugin => plugin.pluginVersion,
61+
},
62+
{
63+
label: 'Repo',
64+
getter: plugin => plugin.repoName,
65+
},
66+
{
67+
label: 'Author',
68+
getter: plugin => plugin.author,
69+
},
70+
]}
71+
emptyMessage="No plugins installed"
72+
data={installedPlugins || []}
73+
/>
74+
</Box>
75+
76+
<Box sx={{
77+
display: 'flex',
78+
flexDirection: 'column',
79+
gap: 2,
80+
alignItems: 'start',
81+
82+
}}>
83+
<Typography variant="h6" components="h2">Other Installed Plugins</Typography>
84+
85+
<SimpleTable
86+
columns={[
87+
{
88+
label: 'Name',
89+
getter: otherInstalledPlugins => (
90+
<Box>
91+
<Link
92+
routeName={`pluginDetails`}
93+
params={{ name: otherInstalledPlugins.name }}
94+
>
95+
{otherInstalledPlugins.name}
96+
</Link>
97+
</Box>
98+
),
99+
},
100+
{
101+
label: 'Version',
102+
getter: otherInstalledPlugins => otherInstalledPlugins.version,
103+
},
104+
{
105+
label: 'Repo',
106+
getter: plugin => plugin.repoName,
107+
},
108+
{
109+
label: 'Author',
110+
getter: plugin => plugin.author,
111+
},
112+
]}
113+
emptyMessage="No plugins installed"
114+
data={otherInstalledPlugins || []}
115+
/>
116+
</Box>
117+
118+
119+
120+
121+
</Box>
60122
)}
61123
</SectionBox>
62124
);
63125
}
64126

65127
export function PluginInstalledList() {
66128
const [installedPlugins, setInstalledPlugins] = useState<Plugin[] | null>(null);
129+
const [otherInstalledPlugins, setOtherInstalledPlugins] = useState<Plugin[] | null>(null);
67130
const [error, setError] = useState<string | null>(null);
68131

69132
useEffect(() => {
@@ -81,8 +144,20 @@ export function PluginInstalledList() {
81144
}
82145
}
83146

147+
async function fetchOtherInstalledPlugins() {
148+
const storedPlugins = localStorage.getItem('headlampPluginSettings');
149+
if (storedPlugins) {
150+
const parsedPlugins = JSON.parse(storedPlugins);
151+
setOtherInstalledPlugins(parsedPlugins);
152+
console.log('other plugins', storedPlugins)
153+
} else {
154+
setOtherInstalledPlugins([]);
155+
}
156+
}
157+
84158
fetchInstalledPlugins();
159+
fetchOtherInstalledPlugins();
85160
}, []);
86161

87-
return <PurePluginInstalledList installedPlugins={installedPlugins} error={error} />;
162+
return <PurePluginInstalledList installedPlugins={installedPlugins} otherInstalledPlugins={otherInstalledPlugins} error={error} />;
88163
}

plugin-catalog/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,5 @@ if (Headlamp.isRunningAsApp()) {
8080
});
8181
}
8282

83+
8384
registerPluginSettings('@headlamp-k8s/plugin-catalog', Settings, true);

0 commit comments

Comments
 (0)