mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Bug: Allow to uninstall a deprecated plugin (#74444)
This commit is contained in:
parent
29238c19fd
commit
8cb93bf3e7
@ -69,4 +69,24 @@ describe('InstallControlsButton', () => {
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
it("should allow to uninstall a plugin even if it's unpublished", () => {
|
||||
render(
|
||||
<TestProvider>
|
||||
<InstallControlsButton plugin={{ ...plugin, isPublished: false }} pluginStatus={PluginStatus.UNINSTALL} />
|
||||
</TestProvider>
|
||||
);
|
||||
const el = screen.getByRole('button');
|
||||
expect(el).toHaveTextContent(/uninstall/i);
|
||||
expect(el).toBeVisible();
|
||||
});
|
||||
|
||||
it('should not render install or upgrade buttons if the plugin is unpublished', () => {
|
||||
render(
|
||||
<TestProvider>
|
||||
<InstallControlsButton plugin={{ ...plugin, isPublished: false }} pluginStatus={PluginStatus.INSTALL} />
|
||||
</TestProvider>
|
||||
);
|
||||
expect(screen.queryByRole('button')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -17,6 +17,7 @@ type InstallControlsButtonProps = {
|
||||
plugin: CatalogPlugin;
|
||||
pluginStatus: PluginStatus;
|
||||
latestCompatibleVersion?: Version;
|
||||
hasInstallWarning?: boolean;
|
||||
setNeedReload?: (needReload: boolean) => void;
|
||||
};
|
||||
|
||||
@ -24,6 +25,7 @@ export function InstallControlsButton({
|
||||
plugin,
|
||||
pluginStatus,
|
||||
latestCompatibleVersion,
|
||||
hasInstallWarning,
|
||||
setNeedReload,
|
||||
}: InstallControlsButtonProps) {
|
||||
const dispatch = useDispatch();
|
||||
@ -110,6 +112,11 @@ export function InstallControlsButton({
|
||||
);
|
||||
}
|
||||
|
||||
if (!plugin.isPublished || hasInstallWarning) {
|
||||
// Cannot be updated or installed
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pluginStatus === PluginStatus.UPDATE) {
|
||||
return (
|
||||
<HorizontalGroup align="flex-start" width="auto" height="auto">
|
||||
|
@ -33,15 +33,14 @@ export const PluginActions = ({ plugin }: Props) => {
|
||||
? PluginStatus.UPDATE
|
||||
: PluginStatus.UNINSTALL
|
||||
: PluginStatus.INSTALL;
|
||||
const isInstallControlsDisabled =
|
||||
plugin.isCore || plugin.isDisabled || !isInstallControlsEnabled() || hasInstallWarning;
|
||||
const isInstallControlsDisabled = plugin.isCore || plugin.isDisabled || !isInstallControlsEnabled();
|
||||
|
||||
return (
|
||||
<VerticalGroup>
|
||||
<HorizontalGroup>
|
||||
{!isInstallControlsDisabled && (
|
||||
<>
|
||||
{isExternallyManaged ? (
|
||||
{isExternallyManaged && !hasInstallWarning ? (
|
||||
<ExternallyManagedButton
|
||||
pluginId={plugin.id}
|
||||
pluginStatus={pluginStatus}
|
||||
@ -53,6 +52,7 @@ export const PluginActions = ({ plugin }: Props) => {
|
||||
latestCompatibleVersion={latestCompatibleVersion}
|
||||
pluginStatus={pluginStatus}
|
||||
setNeedReload={setNeedReload}
|
||||
hasInstallWarning={hasInstallWarning}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
@ -325,12 +325,13 @@ describe('Plugin details page', () => {
|
||||
expect(await queryByRole('button', { name: /install/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not display install button for enterprise plugins if license is invalid', async () => {
|
||||
it('should not display install button for enterprise plugins if license is invalid (but allow uninstall)', async () => {
|
||||
config.licenseInfo.enabledFeatures = {};
|
||||
|
||||
const { queryByRole, queryByText } = renderPluginDetails({ id, isInstalled: true, isEnterprise: true });
|
||||
|
||||
expect(await queryByRole('button', { name: /install/i })).not.toBeInTheDocument();
|
||||
expect(await queryByRole('button', { name: /Install/ })).not.toBeInTheDocument();
|
||||
expect(await queryByRole('button', { name: /Uninstall/ })).toBeInTheDocument();
|
||||
expect(queryByText(/no valid Grafana Enterprise license detected/i)).toBeInTheDocument();
|
||||
expect(queryByRole('link', { name: /learn more/i })).toBeInTheDocument();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user