mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* Share button works now. Removed add to dashboard button for now * WIP explore link * Remove settings dropdown for now * Use getExploreUrl to generate explore link * Fix conflicts * Update betterer * Navigate to a new trail when the recent trails list is empty * Address PR comments
29 lines
778 B
TypeScript
29 lines
778 B
TypeScript
import React, { useState } from 'react';
|
|
import { useLocation } from 'react-use';
|
|
|
|
import { ToolbarButton } from '@grafana/ui';
|
|
|
|
import { DataTrail } from './DataTrail';
|
|
import { getUrlForTrail } from './utils';
|
|
|
|
interface ShareTrailButtonState {
|
|
trail: DataTrail;
|
|
}
|
|
|
|
export const ShareTrailButton = ({ trail }: ShareTrailButtonState) => {
|
|
const { origin } = useLocation();
|
|
const [tooltip, setTooltip] = useState('Copy url');
|
|
|
|
const onShare = () => {
|
|
if (navigator.clipboard) {
|
|
navigator.clipboard.writeText(origin + getUrlForTrail(trail));
|
|
setTooltip('Copied!');
|
|
setTimeout(() => {
|
|
setTooltip('Copy url');
|
|
}, 2000);
|
|
}
|
|
};
|
|
|
|
return <ToolbarButton variant={'canvas'} icon={'share-alt'} tooltip={tooltip} onClick={onShare} />;
|
|
};
|