LibraryPanels: Fixes crash in libray panels list when panel plugin is not found (#35907)

This commit is contained in:
Torkel Ödegaard 2021-06-18 08:03:42 +02:00 committed by GitHub
parent 503c3b8f66
commit 941936cf97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,12 @@
import React, { useState } from 'react';
import { css } from '@emotion/css';
import { GrafanaTheme2, PanelPluginMeta } from '@grafana/data';
import { config } from '@grafana/runtime';
import { GrafanaTheme2 } from '@grafana/data';
import { Icon, Link, useStyles2 } from '@grafana/ui';
import { LibraryElementDTO } from '../../types';
import { PanelTypeCard } from 'app/features/dashboard/components/VizTypePicker/PanelTypeCard';
import { DeleteLibraryPanelModal } from '../DeleteLibraryPanelModal/DeleteLibraryPanelModal';
import { config } from '@grafana/runtime';
import { getPanelPluginNotFound } from 'app/features/dashboard/dashgrid/PanelPluginError';
export interface LibraryPanelCardProps {
libraryPanel: LibraryElementDTO;
@ -28,7 +28,7 @@ export const LibraryPanelCard: React.FC<LibraryPanelCardProps & { children?: JSX
setShowDeletionModal(false);
};
const panelPlugin = config.panels[libraryPanel.model.type] ?? ({} as PanelPluginMeta);
const panelPlugin = config.panels[libraryPanel.model.type] ?? getPanelPluginNotFound(libraryPanel.model.type).meta;
return (
<>