mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* Explore: remove topnav * PageToolbar: fix left items margin when no title or page icon is set * add missing key prop & fix tests * use canvas variant in live logs * avoid rendering empty space * fix test * avoid disabling split resize button when live tailing * minor touchups * Update packages/grafana-ui/src/components/PageLayout/PageToolbar.tsx Co-authored-by: Torkel Ödegaard <torkel@grafana.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
35 lines
935 B
TypeScript
35 lines
935 B
TypeScript
import React, { useState } from 'react';
|
|
|
|
import { ToolbarButton } from '@grafana/ui';
|
|
import { ExploreId, useSelector } 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 (
|
|
<>
|
|
<ToolbarButton
|
|
icon="apps"
|
|
variant="canvas"
|
|
onClick={() => setIsOpen(true)}
|
|
aria-label="Add to dashboard"
|
|
disabled={!explorePaneHasQueries}
|
|
>
|
|
Add to dashboard
|
|
</ToolbarButton>
|
|
|
|
{isOpen && <AddToDashboardModal onClose={() => setIsOpen(false)} exploreId={exploreId} />}
|
|
</>
|
|
);
|
|
};
|