import React, { useState } from 'react'; import { Card, Icon, IconButton, Tooltip, useStyles } from '@grafana/ui'; import { css } from 'emotion'; import { GrafanaTheme } from '@grafana/data'; import { LibraryPanelDTO } from '../../types'; import { DeleteLibraryPanelModal } from '../DeleteLibraryPanelModal/DeleteLibraryPanelModal'; export interface LibraryPanelCardProps { libraryPanel: LibraryPanelDTO; onClick?: (panel: LibraryPanelDTO) => void; onDelete?: (panel: LibraryPanelDTO) => void; showSecondaryActions?: boolean; formatDate?: (dateString: string) => string; } export const LibraryPanelCard: React.FC = ({ libraryPanel, children, onClick, onDelete, formatDate, showSecondaryActions, }) => { const styles = useStyles(getStyles); const [showDeletionModal, setShowDeletionModal] = useState(false); const onDeletePanel = () => { onDelete?.(libraryPanel); setShowDeletionModal(false); }; return ( <> onClick(libraryPanel) : undefined}> Reusable panel
{libraryPanel.meta.connectedDashboards}
Last edited {formatDate?.(libraryPanel.meta.updated ?? '') ?? libraryPanel.meta.updated} by{' '} {libraryPanel.meta.updatedBy.name}
{/* Commenting this out as tagging isn't implemented yet. */} {children && {children}} {showSecondaryActions && ( setShowDeletionModal(true)} /> {/* Commenting this out as panel favoriting hasn't been implemented yet. */} )}
{showDeletionModal && ( setShowDeletionModal(false)} /> )} ); }; const getStyles = (theme: GrafanaTheme) => { return { tooltip: css` display: inline; `, detailIcon: css` margin-right: 0.5ch; `, panelIcon: css` color: ${theme.colors.textWeak}; `, tagList: css` align-self: center; `, }; };