-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin-catalog: Rework installed list to include all plugins #117
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,53 +17,124 @@ 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 ( | ||
<SectionBox title="Installed" textAlign="center" paddingTop={2}> | ||
{error ? ( | ||
<Typography>{`Error loading Installed plugins: ${error}`}</Typography> | ||
) : ( | ||
<SimpleTable | ||
columns={[ | ||
{ | ||
label: 'Name', | ||
getter: plugin => ( | ||
<Box> | ||
<Link | ||
routeName="/plugin-catalog/:repoName/:pluginName" | ||
params={{ repoName: plugin.repoName, pluginName: plugin.folderName }} | ||
> | ||
{plugin.pluginTitle} | ||
</Link> | ||
</Box> | ||
), | ||
}, | ||
{ | ||
label: 'Version', | ||
getter: plugin => plugin.pluginVersion, | ||
}, | ||
{ | ||
label: 'Repo', | ||
getter: plugin => plugin.repoName, | ||
}, | ||
{ | ||
label: 'Author', | ||
getter: plugin => plugin.author, | ||
}, | ||
]} | ||
emptyMessage="No plugins installed" | ||
data={installedPlugins || []} | ||
/> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: 2, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: 2, | ||
alignItems: 'start', | ||
}} | ||
> | ||
<Typography variant="h6" components="h2"> | ||
Installed from the Plugin Catalog | ||
</Typography> | ||
<SimpleTable | ||
columns={[ | ||
{ | ||
label: 'Name', | ||
getter: plugin => ( | ||
<Box> | ||
<Link | ||
routeName="/plugin-catalog/:repoName/:pluginName" | ||
params={{ repoName: plugin.repoName, pluginName: plugin.folderName }} | ||
> | ||
{plugin.pluginTitle} | ||
</Link> | ||
</Box> | ||
), | ||
}, | ||
{ | ||
label: 'Version', | ||
getter: plugin => plugin.pluginVersion, | ||
}, | ||
{ | ||
label: 'Repo', | ||
getter: plugin => plugin.repoName, | ||
}, | ||
{ | ||
label: 'Author', | ||
getter: plugin => plugin.author, | ||
}, | ||
]} | ||
emptyMessage="No plugins installed" | ||
data={installedPlugins || []} | ||
/> | ||
</Box> | ||
|
||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: 2, | ||
alignItems: 'start', | ||
}} | ||
> | ||
<Typography variant="h6" components="h2"> | ||
Other Installed Plugins | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here we could use |
||
</Typography> | ||
|
||
<SimpleTable | ||
columns={[ | ||
{ | ||
label: 'Name', | ||
getter: otherInstalledPlugins => ( | ||
<Box> | ||
<Link | ||
routeName={`pluginDetails`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This lliteral is not replacing any var, so it may be |
||
params={{ name: otherInstalledPlugins.name }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should (in a different commit) make sure that the names of plugins are separated into org+name. We can use the org as the author. See: |
||
> | ||
{otherInstalledPlugins.name} | ||
</Link> | ||
</Box> | ||
), | ||
}, | ||
{ | ||
label: 'Version', | ||
getter: otherInstalledPlugins => otherInstalledPlugins.version, | ||
}, | ||
{ | ||
label: 'Repo', | ||
getter: plugin => plugin.repoName, | ||
}, | ||
{ | ||
label: 'Author', | ||
getter: plugin => plugin.author, | ||
}, | ||
]} | ||
emptyMessage="No plugins installed" | ||
data={otherInstalledPlugins || []} | ||
/> | ||
</Box> | ||
</Box> | ||
)} | ||
</SectionBox> | ||
); | ||
} | ||
|
||
export function PluginInstalledList() { | ||
const [installedPlugins, setInstalledPlugins] = useState<Plugin[] | null>(null); | ||
const [otherInstalledPlugins, setOtherInstalledPlugins] = useState<Plugin[] | null>(null); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
|
@@ -81,8 +152,25 @@ export function PluginInstalledList() { | |
} | ||
} | ||
|
||
function fetchOtherInstalledPlugins() { | ||
const storedPlugins = localStorage.getItem('headlampPluginSettings'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the correct way to get the plugins? I think there's currently an issue related to this, since it mentions plugins settings but we have the package.json stored there, although it's likely a bug. |
||
if (storedPlugins) { | ||
const parsedPlugins = JSON.parse(storedPlugins); | ||
setOtherInstalledPlugins(parsedPlugins); | ||
} else { | ||
setOtherInstalledPlugins([]); | ||
} | ||
} | ||
|
||
fetchInstalledPlugins(); | ||
fetchOtherInstalledPlugins(); | ||
}, []); | ||
|
||
return <PurePluginInstalledList installedPlugins={installedPlugins} error={error} />; | ||
return ( | ||
<PurePluginInstalledList | ||
installedPlugins={installedPlugins} | ||
otherInstalledPlugins={otherInstalledPlugins} | ||
error={error} | ||
/> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title of the section is already "Installed". So here we could just have
Plugins from the Catalog
.