import React, { useState } from 'react'; import { useSelector } from 'react-redux'; import { ToolbarButton } from '@grafana/ui'; import { ExploreId } from 'app/types'; import { getExploreItemSelector } from '../state/selectors'; import { AddToDashboardModal } from './AddToDashboardModal'; interface Props { exploreId: ExploreId; } export const AddToDashboard = ({ exploreId }: Props) => { const [isOpen, setIsOpen] = useState(false); const selectExploreItem = getExploreItemSelector(exploreId); const explorePaneHasQueries = !!useSelector(selectExploreItem)?.queries?.length; return ( <> setIsOpen(true)} aria-label="Add to dashboard" disabled={!explorePaneHasQueries} > Add to dashboard {isOpen && setIsOpen(false)} exploreId={exploreId} />} ); };