mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Disable uninstall while cloud uninstall is not completed (#81907)
This commit is contained in:
parent
7f77be8f85
commit
4910a901de
@ -168,4 +168,79 @@ describe('InstallControlsButton', () => {
|
||||
expect(button).toBeEnabled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('uninstall button on prem', () => {
|
||||
const store = configureStore({
|
||||
plugins: getPluginsStateMock([]),
|
||||
});
|
||||
|
||||
it('should be disabled when is Installing', () => {
|
||||
store.dispatch({ type: 'plugins/uninstall/pending' });
|
||||
render(
|
||||
<TestProvider store={store}>
|
||||
<InstallControlsButton plugin={{ ...plugin }} pluginStatus={PluginStatus.UNINSTALL} />
|
||||
</TestProvider>
|
||||
);
|
||||
const button = screen.getByText('Uninstalling').closest('button');
|
||||
expect(button).toBeDisabled();
|
||||
});
|
||||
|
||||
it('should be enabled when it is not Installing', () => {
|
||||
store.dispatch({ type: 'plugins/uninstall/fulfilled', payload: { id: '', changes: {} } });
|
||||
render(
|
||||
<TestProvider store={store}>
|
||||
<InstallControlsButton plugin={{ ...plugin }} pluginStatus={PluginStatus.UNINSTALL} />
|
||||
</TestProvider>
|
||||
);
|
||||
const button = screen.getByText('Uninstall').closest('button');
|
||||
expect(button).toBeEnabled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('uninstall button on managed instance', () => {
|
||||
const oldFeatureTogglesManagedPluginsInstall = config.featureToggles.managedPluginsInstall;
|
||||
const oldPluginAdminExternalManageEnabled = config.pluginAdminExternalManageEnabled;
|
||||
|
||||
beforeAll(() => {
|
||||
config.featureToggles.managedPluginsInstall = true;
|
||||
config.pluginAdminExternalManageEnabled = true;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
config.featureToggles.managedPluginsInstall = oldFeatureTogglesManagedPluginsInstall;
|
||||
config.pluginAdminExternalManageEnabled = oldPluginAdminExternalManageEnabled;
|
||||
});
|
||||
|
||||
const store = configureStore({
|
||||
plugins: getPluginsStateMock([]),
|
||||
});
|
||||
|
||||
it('should be disabled when isInstalling=false but isUninstallingFromInstance=true', () => {
|
||||
store.dispatch({ type: 'plugins/uninstall/fulfilled', payload: { id: '', changes: {} } });
|
||||
render(
|
||||
<TestProvider store={store}>
|
||||
<InstallControlsButton
|
||||
plugin={{ ...plugin, isUninstallingFromInstance: true }}
|
||||
pluginStatus={PluginStatus.UNINSTALL}
|
||||
/>
|
||||
</TestProvider>
|
||||
);
|
||||
const button = screen.getByText('Uninstall').closest('button');
|
||||
expect(button).toBeDisabled();
|
||||
});
|
||||
|
||||
it('should be enabled when isInstalling=false and isUninstallingFromInstance=false', () => {
|
||||
store.dispatch({ type: 'plugins/uninstall/fulfilled', payload: { id: '', changes: {} } });
|
||||
render(
|
||||
<TestProvider store={store}>
|
||||
<InstallControlsButton
|
||||
plugin={{ ...plugin, isUninstallingFromInstance: false }}
|
||||
pluginStatus={PluginStatus.UNINSTALL}
|
||||
/>
|
||||
</TestProvider>
|
||||
);
|
||||
const button = screen.getByText('Uninstall').closest('button');
|
||||
expect(button).toBeEnabled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -114,6 +114,11 @@ export function InstallControlsButton({
|
||||
};
|
||||
|
||||
if (pluginStatus === PluginStatus.UNINSTALL) {
|
||||
const disableUninstall =
|
||||
config.pluginAdminExternalManageEnabled && configCore.featureToggles.managedPluginsInstall
|
||||
? plugin.isUninstallingFromInstance
|
||||
: isUninstalling;
|
||||
|
||||
return (
|
||||
<>
|
||||
<ConfirmModal
|
||||
@ -126,7 +131,7 @@ export function InstallControlsButton({
|
||||
onDismiss={hideConfirmModal}
|
||||
/>
|
||||
<HorizontalGroup align="flex-start" width="auto" height="auto">
|
||||
<Button variant="destructive" disabled={isUninstalling} onClick={showConfirmModal}>
|
||||
<Button variant="destructive" disabled={disableUninstall} onClick={showConfirmModal}>
|
||||
{uninstallBtnText}
|
||||
</Button>
|
||||
</HorizontalGroup>
|
||||
|
@ -60,6 +60,8 @@ export function mergeLocalsAndRemotes({
|
||||
instancesMap.has(remotePlugin.slug) &&
|
||||
catalogPlugin.hasUpdate &&
|
||||
catalogPlugin.installedVersion !== instancePlugin?.version;
|
||||
|
||||
catalogPlugin.isUninstallingFromInstance = Boolean(localCounterpart) && !instancesMap.has(remotePlugin.slug);
|
||||
}
|
||||
|
||||
catalogPlugins.push(catalogPlugin);
|
||||
|
@ -62,6 +62,7 @@ export interface CatalogPlugin extends WithAccessControlMetadata {
|
||||
// instance plugins may not be fully installed, which means a new instance
|
||||
// running the plugin didn't started yet
|
||||
isFullyInstalled?: boolean;
|
||||
isUninstallingFromInstance?: boolean;
|
||||
isUpdatingFromInstance?: boolean;
|
||||
iam?: IdentityAccessManagement;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user