Skip to content

Commit

Permalink
frontend: PluginSettings: Use author for plugin origin
Browse files Browse the repository at this point in the history
This change makes the formatting of the plugin names consistent, using
the plugin author for the origin value. When the author is not set, the
default origin is "Unknown".

Fixes: #2544

Signed-off-by: Evangelos Skopelitis <[email protected]>
  • Loading branch information
skoeva committed Nov 14, 2024
1 parent d24fc9f commit 9e7c439
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions frontend/src/components/App/PluginSettings/PluginSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
name: name ?? plugin.name,
origin: plugin.origin ?? rawOrigin?.substring(1) ?? t('translation|Unknown'),
};
})
);

/**
* useEffect to control the rendering of the save button.
Expand Down Expand Up @@ -202,9 +217,9 @@ export function PluginSettingsPure(props: PluginSettingsPureProps) {
header: t('translation|Origin'),
Cell: ({ row: { original: plugin } }: { row: MRT_Row<PluginInfo> }) => {
const url = plugin?.homepage || plugin?.repository?.url;
return plugin?.origin ? (
return plugin.origin ? (
url ? (
<Link href={url}>{plugin?.origin}</Link>
<Link href={url}>{plugin.origin}</Link>
) : (
plugin?.origin
)
Expand Down

0 comments on commit 9e7c439

Please sign in to comment.