diff --git a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.test.tsx b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.test.tsx
index eda80c9c822..77bdb1f096e 100644
--- a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.test.tsx
+++ b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.test.tsx
@@ -4,7 +4,9 @@ import { TestProvider } from 'test/helpers/TestProvider';
import { PluginSignatureStatus } from '@grafana/data';
import { config } from '@grafana/runtime';
+import { configureStore } from 'app/store/configureStore';
+import { getPluginsStateMock } from '../../__mocks__';
import { CatalogPlugin, PluginStatus } from '../../types';
import { InstallControlsButton } from './InstallControlsButton';
@@ -91,4 +93,79 @@ describe('InstallControlsButton', () => {
);
expect(screen.queryByRole('button')).not.toBeInTheDocument();
});
+
+ describe('update button on prem', () => {
+ const store = configureStore({
+ plugins: getPluginsStateMock([]),
+ });
+
+ it('should be disabled when is Installing', () => {
+ store.dispatch({ type: 'plugins/install/pending' });
+ render(
+
+
+
+ );
+ const button = screen.getByText('Updating').closest('button');
+ expect(button).toBeDisabled();
+ });
+
+ it('should be enabled when it is not Installing', () => {
+ store.dispatch({ type: 'plugins/install/fulfilled', payload: { id: '', changes: {} } });
+ render(
+
+
+
+ );
+ const button = screen.getByText('Update').closest('button');
+ expect(button).toBeEnabled();
+ });
+ });
+
+ describe('update 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 isUpdatingFromInstance=true', () => {
+ store.dispatch({ type: 'plugins/install/fulfilled', payload: { id: '', changes: {} } });
+ render(
+
+
+
+ );
+ const button = screen.getByText('Update').closest('button');
+ expect(button).toBeDisabled();
+ });
+
+ it('should be enabled when isInstalling=false and isUpdatingFromInstance=false', () => {
+ store.dispatch({ type: 'plugins/install/fulfilled', payload: { id: '', changes: {} } });
+ render(
+
+
+
+ );
+ const button = screen.getByText('Update').closest('button');
+ expect(button).toBeEnabled();
+ });
+ });
});
diff --git a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx
index 74689dabd84..68411e2fbdd 100644
--- a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx
+++ b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx
@@ -140,9 +140,14 @@ export function InstallControlsButton({
}
if (pluginStatus === PluginStatus.UPDATE) {
+ const disableUpdate =
+ config.pluginAdminExternalManageEnabled && configCore.featureToggles.managedPluginsInstall
+ ? plugin.isUpdatingFromInstance
+ : isInstalling;
+
return (
-