import React, { ComponentType } from 'react'; import { PanelData } from '@grafana/data'; import { PanelModel } from '../../state'; export interface PanelInspectActionProps { panel: PanelModel; data?: PanelData; } export interface PanelInspectAction { title: string; description: string; component: ComponentType; } export interface PanelInspectActionSupplier { getActions: (panel: PanelModel) => PanelInspectAction[] | null; } // const dummySupplier: PanelInspectActionSupplier = { // getActions: (panel: PanelModel) => { // return [ // { // title: 'Do something', // description: 'that thingy', // // eslint-disable-next-line react/display-name // component: ({ panel }) => { // return ( //
// DO THING ONE. Panel:
{JSON.stringify(panel.targets)}
//
// ); // }, // }, // { // title: 'Do something else', // description: 'another thing', // // eslint-disable-next-line react/display-name // component: ({ panel }) => { // return ( //
// DO THING TWO. Panel:
{JSON.stringify(panel.targets)}
//
// ); // }, // }, // ]; // }, // }; // In Grafana 8.1, this can be improved and moved to `@grafana/runtime` // NOTE: This is an internal/experimental API/hack and will change! // (window as any).grafanaPanelInspectActionSupplier = dummySupplier; interface InspectActionsTabProps { panel: PanelModel; data?: PanelData; } export const InspectActionsTab: React.FC = ({ panel, data }) => { const supplier = (window as any).grafanaPanelInspectActionSupplier as PanelInspectActionSupplier; if (!supplier) { return
Missing actions
; } const actions = supplier.getActions(panel); if (!actions?.length) { return
No actions avaliable
; } return (
{actions.map((a, idx) => (

{a.title}

{a.description}
))}
); };