mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* Select: Expose AsyncSelectProps interface * DashboardPicker: Add a generic DashboardPicker component * Dashboard Service: improve types * Explore: allow saving explore state in a new panel in an existing dashboard * Handle saving provisioned dashboards error * Improve test coverage * simplify test setup * Strip base path from url when redirecting to a dashboard * Keep existing variables when saving to an existing dashboard * group assertions in test * SearchCard: handle undefined in meta.updated * Change required error message * Add to dashboard alternative * Add to existing is working * Add to dashboard form * remove default add-panel when creating a dashboard from explore * types cleanup * remove unneeded BE change * simplify selector * Add explore2Dashboard feature toggle * add tests * Small refactor & add tests * small DashboardPicker improvements * use partial from lodash * Better error handling * improve tests & disable button when there are no queries * rename addPanelToDashboard function * remove localStorage item if opening tab fails * UI touchups & tracking * Fix tests & remove close reporting * remove echologger debug * fix adding a panel to an existing dashboard * Enable explore2Dashboard by default and add docs * Ensure each panel in dashboards has a valid ID * force CI restart Co-authored-by: Elfo404 <me@giordanoricci.com>
32 lines
937 B
TypeScript
32 lines
937 B
TypeScript
import React, { useState } from 'react';
|
|
import { ExploreId } from 'app/types';
|
|
import { AddToDashboardModal } from './AddToDashboardModal';
|
|
import { ToolbarButton } from '@grafana/ui';
|
|
import { useSelector } from 'react-redux';
|
|
import { getExploreItemSelector } from '../state/selectors';
|
|
|
|
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"
|
|
onClick={() => setIsOpen(true)}
|
|
aria-label="Add to dashboard"
|
|
disabled={!explorePaneHasQueries}
|
|
>
|
|
Add to dashboard
|
|
</ToolbarButton>
|
|
|
|
{isOpen && <AddToDashboardModal onClose={() => setIsOpen(false)} exploreId={exploreId} />}
|
|
</>
|
|
);
|
|
};
|