diff --git a/public/app/features/plugins/admin/components/InstallControls.tsx b/public/app/features/plugins/admin/components/InstallControls.tsx index 5d1d4c5c9ca..62a3de8892e 100644 --- a/public/app/features/plugins/admin/components/InstallControls.tsx +++ b/public/app/features/plugins/admin/components/InstallControls.tsx @@ -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 (
diff --git a/public/app/features/plugins/admin/pages/PluginDetails.test.tsx b/public/app/features/plugins/admin/pages/PluginDetails.test.tsx index 58ce2954960..609ffc0769a 100644 --- a/public/app/features/plugins/admin/pages/PluginDetails.test.tsx +++ b/public/app/features/plugins/admin/pages/PluginDetails.test.tsx @@ -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 { ...plugin, }; } + +function corePlugin(plugin: Partial = {}): 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, + }; +}