diff --git a/eslint-suppressions.json b/eslint-suppressions.json index cb0b7d897ff..b8933b5bc36 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -2610,11 +2610,6 @@ "count": 2 } }, - "public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx": { - "no-restricted-syntax": { - "count": 1 - } - }, "public/app/features/live/centrifuge/LiveDataStream.ts": { "@typescript-eslint/consistent-type-assertions": { "count": 1 diff --git a/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx b/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx index ebf2c37ea41..35125b16adb 100644 --- a/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx +++ b/public/app/features/library-panels/components/LibraryPanelCard/LibraryPanelCard.tsx @@ -4,7 +4,7 @@ import Skeleton from 'react-loading-skeleton'; import { GrafanaTheme2 } from '@grafana/data'; import { Trans } from '@grafana/i18n'; -import { config } from '@grafana/runtime'; +import { usePanelPluginMeta } from '@grafana/runtime/internal'; import { Icon, Link, useStyles2 } from '@grafana/ui'; import { SkeletonComponent, attachSkeleton } from '@grafana/ui/unstable'; import { getPanelPluginNotFound } from 'app/features/panel/components/PanelPluginError'; @@ -30,7 +30,8 @@ const LibraryPanelCardComponent = ({ libraryPanel, onClick, onDelete, showSecond setShowDeletionModal(false); }; - const panelPlugin = config.panels[libraryPanel.model.type] ?? getPanelPluginNotFound(libraryPanel.model.type).meta; + const { value: panelPluginMeta } = usePanelPluginMeta(libraryPanel.model.type); + const panelPlugin = panelPluginMeta ?? getPanelPluginNotFound(libraryPanel.model.type).meta; return ( <> diff --git a/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx b/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx index 8645dfb4c4e..895ab264bd4 100644 --- a/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx +++ b/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx @@ -35,17 +35,21 @@ const timeseries: PanelPluginMeta = { sort: 1, }; -jest.mock('@grafana/runtime', () => ({ - ...jest.requireActual('@grafana/runtime'), - config: { - ...jest.requireActual('@grafana/runtime').config, - panels: { - timeseries: { - info: { logos: { small: '' } }, - name: 'Time Series', - }, +jest.mock('@grafana/runtime/internal', () => ({ + ...jest.requireActual('@grafana/runtime/internal'), + usePanelPluginMeta: jest.fn((type: string) => ({ + value: { + id: type, + name: type === 'timeseries' ? 'Time Series' : 'Graph', + info: { logos: { small: '', large: '' } }, + baseUrl: '', + type: 'panel', + module: '', + sort: 0, }, - }, + loading: false, + error: undefined, + })), })); const getLibraryPanelsSpy = jest.spyOn(api, 'getLibraryPanels');