diff --git a/public/app/features/plugins/admin/helpers.ts b/public/app/features/plugins/admin/helpers.ts index 667c89d6223..e6c9b460916 100644 --- a/public/app/features/plugins/admin/helpers.ts +++ b/public/app/features/plugins/admin/helpers.ts @@ -1,8 +1,10 @@ import { config } from '@grafana/runtime'; import { gt } from 'semver'; import { PluginSignatureStatus, dateTimeParse, PluginError } from '@grafana/data'; -import { CatalogPlugin, LocalPlugin, RemotePlugin } from './types'; import { contextSrv } from 'app/core/services/context_srv'; +import { getBackendSrv } from 'app/core/services/backend_srv'; +import { Settings } from 'app/core/config'; +import { CatalogPlugin, LocalPlugin, RemotePlugin } from './types'; export function isGrafanaAdmin(): boolean { return config.bootData.user.isGrafanaAdmin; @@ -221,3 +223,11 @@ function groupErrorsByPluginId(errors: PluginError[] = []): Record); } + +// Updates the core Grafana config to have the correct list available panels +export const updatePanels = () => + getBackendSrv() + .get('/api/frontend/settings') + .then((settings: Settings) => { + config.panels = settings.panels; + }); diff --git a/public/app/features/plugins/admin/state/actions.ts b/public/app/features/plugins/admin/state/actions.ts index 67db4275c71..33eba69813e 100644 --- a/public/app/features/plugins/admin/state/actions.ts +++ b/public/app/features/plugins/admin/state/actions.ts @@ -5,6 +5,7 @@ import { StoreState, ThunkResult } from 'app/types'; import { importPanelPlugin } from 'app/features/plugins/plugin_loader'; import { getCatalogPlugins, getPluginDetails, installPlugin, uninstallPlugin } from '../api'; import { STATE_PREFIX } from '../constants'; +import { updatePanels } from '../helpers'; import { CatalogPlugin } from '../types'; export const fetchAll = createAsyncThunk(`${STATE_PREFIX}/fetchAll`, async (_, thunkApi) => { @@ -28,16 +29,16 @@ export const fetchDetails = createAsyncThunk(`${STATE_PREFIX}/fetchDetails`, asy } }); +// We are also using the install API endpoint to update the plugin export const install = createAsyncThunk( `${STATE_PREFIX}/install`, async ({ id, version, isUpdating = false }: { id: string; version: string; isUpdating?: boolean }, thunkApi) => { const changes = isUpdating ? { isInstalled: true, hasUpdate: false } : { isInstalled: true }; try { await installPlugin(id, version); - return { - id, - changes, - } as Update; + await updatePanels(); + + return { id, changes } as Update; } catch (e) { return thunkApi.rejectWithValue('Unknown error.'); } @@ -47,6 +48,8 @@ export const install = createAsyncThunk( export const uninstall = createAsyncThunk(`${STATE_PREFIX}/uninstall`, async (id: string, thunkApi) => { try { await uninstallPlugin(id); + await updatePanels(); + return { id, changes: { isInstalled: false },