diff --git a/e2e-tests/tests/pluginSetting.spec.ts b/e2e-tests/tests/pluginSetting.spec.ts index 88609b210a..de63755adf 100644 --- a/e2e-tests/tests/pluginSetting.spec.ts +++ b/e2e-tests/tests/pluginSetting.spec.ts @@ -20,7 +20,7 @@ test('plugin settings page should have a table', async ({ page }) => { test('pod counter plugin should have setting option', async ({ page }) => { const headlampPage = new HeadlampPage(page); - const pluginName = '@kinvolk/headlamp-pod-counter'; + const pluginName = 'headlamp-pod-counter'; await headlampPage.authenticate(); await headlampPage.navigateTopage('/settings/plugins', /Plugin/); diff --git a/frontend/src/components/App/PluginSettings/PluginSettings.tsx b/frontend/src/components/App/PluginSettings/PluginSettings.tsx index 3135cb314c..f4621c4199 100644 --- a/frontend/src/components/App/PluginSettings/PluginSettings.tsx +++ b/frontend/src/components/App/PluginSettings/PluginSettings.tsx @@ -100,8 +100,23 @@ export function PluginSettingsPure(props: PluginSettingsPureProps) { /** enableSave state enables the save button when changes are made to the plugin list */ const [enableSave, setEnableSave] = useState(false); - /** pluginChanges state is the array of plugin data and any current changes made by the user to a plugin's "Enable" field via toggler */ - const [pluginChanges, setPluginChanges] = useState(() => pluginArr.map((p: any) => p)); + /** + * pluginChanges state is the array of plugin data and any current changes made by the user to a plugin's "Enable" field via toggler. + * The name and origin fields are split for consistency. + */ + const [pluginChanges, setPluginChanges] = useState(() => + pluginArr.map((plugin: PluginInfo) => { + const [rawOrigin, name] = plugin.name.includes('@') + ? plugin.name.split(/\/(.+)/) + : [null, plugin.name]; + + return { + ...plugin, + displayName: name ?? plugin.name, + origin: plugin.origin ?? rawOrigin?.substring(1) ?? t('translation|Unknown'), + }; + }) + ); /** * useEffect to control the rendering of the save button. @@ -186,7 +201,7 @@ export function PluginSettingsPure(props: PluginSettingsPureProps) { params={{ name: plugin.name }} align="right" > - {plugin.name} + {plugin.displayName} {plugin.version} @@ -202,9 +217,9 @@ export function PluginSettingsPure(props: PluginSettingsPureProps) { header: t('translation|Origin'), Cell: ({ row: { original: plugin } }: { row: MRT_Row }) => { const url = plugin?.homepage || plugin?.repository?.url; - return plugin?.origin ? ( + return plugin.origin ? ( url ? ( - {plugin?.origin} + {plugin.origin} ) : ( plugin?.origin ) diff --git a/frontend/src/components/App/PluginSettings/__snapshots__/PluginSettings.DefaultSaveEnable.stories.storyshot b/frontend/src/components/App/PluginSettings/__snapshots__/PluginSettings.DefaultSaveEnable.stories.storyshot index b128024ebb..be3e076f1d 100644 --- a/frontend/src/components/App/PluginSettings/__snapshots__/PluginSettings.DefaultSaveEnable.stories.storyshot +++ b/frontend/src/components/App/PluginSettings/__snapshots__/PluginSettings.DefaultSaveEnable.stories.storyshot @@ -488,7 +488,12 @@ class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignLeft MuiTableCell-sizeMedium css-ac5fut-MuiTableCell-root" data-index="2" > - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown + - Unknown + + Unknown +