PluginCatalog: Update message about insufficient permissions (#67664)

Changed so we map the enum into different message.
This commit is contained in:
Marcus Andersson 2023-05-03 09:53:33 +02:00 committed by GitHub
parent 76284ed3a6
commit 21d28c1cb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,8 +58,7 @@ export const InstallControlsWarning = ({ plugin, pluginStatus, latestCompatibleV
} }
if (!hasPermission && !isExternallyManaged) { if (!hasPermission && !isExternallyManaged) {
const message = `You do not have permission to ${pluginStatus} this plugin.`; return <div className={styles.message}>{statusToMessage(pluginStatus)}</div>;
return <div className={styles.message}>{message}</div>;
} }
if (!plugin.isPublished) { if (!plugin.isPublished) {
@ -101,3 +100,17 @@ export const getStyles = (theme: GrafanaTheme2) => {
`, `,
}; };
}; };
function statusToMessage(status: PluginStatus): string {
switch (status) {
case PluginStatus.INSTALL:
case PluginStatus.REINSTALL:
return `You do not have permission to install this plugin.`;
case PluginStatus.UNINSTALL:
return `You do not have permission to uninstall this plugin.`;
case PluginStatus.UPDATE:
return `You do not have permission to update this plugin.`;
default:
return `You do not have permission to manage this plugin.`;
}
}