mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -06:00
Plugins: Don't show uninstall button for core plugins in catalog (#36671)
* fix(catalog): don't show un/install buttons if core plugin * test(catalog): add PluginDetails test case for core plugins
This commit is contained in:
parent
607c5d2555
commit
dcc6663801
@ -78,8 +78,13 @@ export const InstallControls = ({ localPlugin, remotePlugin }: Props) => {
|
||||
|
||||
const isDevelopmentBuild = Boolean(localPlugin?.dev);
|
||||
const isEnterprise = remotePlugin?.status === 'enterprise';
|
||||
const isCore = remotePlugin?.internal || localPlugin?.signature === 'internal';
|
||||
const hasPermission = isGrafanaAdmin();
|
||||
|
||||
if (isCore) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isEnterprise && !config.licenseInfo?.hasValidLicense) {
|
||||
return (
|
||||
<div className={styles.message}>
|
||||
|
@ -17,7 +17,9 @@ jest.mock('@grafana/runtime', () => {
|
||||
case `${GRAFANA_API_ROOT}/plugins/enterprise/versions`:
|
||||
return Promise.resolve([]);
|
||||
case API_ROOT:
|
||||
return Promise.resolve([localPlugin()]);
|
||||
return Promise.resolve([localPlugin(), corePlugin()]);
|
||||
case `${GRAFANA_API_ROOT}/plugins/core`:
|
||||
return Promise.resolve(corePlugin());
|
||||
case `${GRAFANA_API_ROOT}/plugins/not-installed`:
|
||||
return Promise.resolve(remotePlugin());
|
||||
case `${GRAFANA_API_ROOT}/plugins/enterprise`:
|
||||
@ -48,8 +50,7 @@ describe('Plugin details page', () => {
|
||||
|
||||
const expected = 'Install';
|
||||
|
||||
await waitFor(() => getByText(expected));
|
||||
expect(getByText(expected)).toBeInTheDocument();
|
||||
await waitFor(() => expect(getByText(expected)).toBeInTheDocument());
|
||||
});
|
||||
|
||||
it('should not display install button for enterprise plugins', async () => {
|
||||
@ -57,8 +58,12 @@ describe('Plugin details page', () => {
|
||||
|
||||
const expected = "Marketplace doesn't support installing Enterprise plugins yet. Stay tuned!";
|
||||
|
||||
await waitFor(() => getByText(expected));
|
||||
expect(getByText(expected)).toBeInTheDocument();
|
||||
await waitFor(() => expect(getByText(expected)).toBeInTheDocument());
|
||||
});
|
||||
|
||||
it('should not display install / uninstall buttons for core plugins', async () => {
|
||||
const { queryByRole } = setup('core');
|
||||
await waitFor(() => expect(queryByRole('button', { name: /(un)?install/i })).not.toBeInTheDocument());
|
||||
});
|
||||
});
|
||||
|
||||
@ -130,3 +135,35 @@ function localPlugin(plugin: Partial<LocalPlugin> = {}): LocalPlugin {
|
||||
...plugin,
|
||||
};
|
||||
}
|
||||
|
||||
function corePlugin(plugin: Partial<LocalPlugin> = {}): LocalPlugin {
|
||||
return {
|
||||
category: 'sql',
|
||||
defaultNavUrl: '/plugins/postgres/',
|
||||
dev: false,
|
||||
enabled: true,
|
||||
hasUpdate: false,
|
||||
id: 'core',
|
||||
info: {
|
||||
author: { name: 'Grafana Labs', url: 'https://grafana.com' },
|
||||
build: {},
|
||||
description: 'Data source for PostgreSQL and compatible databases',
|
||||
links: [],
|
||||
logos: {
|
||||
small: 'public/app/plugins/datasource/postgres/img/postgresql_logo.svg',
|
||||
large: 'public/app/plugins/datasource/postgres/img/postgresql_logo.svg',
|
||||
},
|
||||
updated: '',
|
||||
version: '',
|
||||
},
|
||||
latestVersion: '',
|
||||
name: 'PostgreSQL',
|
||||
pinned: false,
|
||||
signature: 'internal',
|
||||
signatureOrg: '',
|
||||
signatureType: '',
|
||||
state: '',
|
||||
type: 'datasource',
|
||||
...plugin,
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user