mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
Dashboard: Disable image renderer link for unsaved dashboards (#41249)
This commit is contained in:
parent
f8d75726e7
commit
9fc5193ecd
@ -7,6 +7,7 @@ import { initTemplateSrv } from '../../../../../test/helpers/initTemplateSrv';
|
||||
import { variableAdapters } from '../../../variables/adapters';
|
||||
import { createQueryVariableAdapter } from '../../../variables/query/adapter';
|
||||
import { PanelModel } from '../../state';
|
||||
import { getDefaultTimeRange } from '@grafana/data';
|
||||
|
||||
jest.mock('app/features/dashboard/services/TimeSrv', () => ({
|
||||
getTimeSrv: () => ({
|
||||
@ -76,6 +77,7 @@ function shareLinkScenario(description: string, scenarioFn: (ctx: ScenarioContex
|
||||
mount: (propOverrides?: any) => {
|
||||
const props: any = {
|
||||
panel: undefined,
|
||||
dashboard: { time: getDefaultTimeRange() },
|
||||
};
|
||||
|
||||
Object.assign(props, propOverrides);
|
||||
|
@ -81,10 +81,11 @@ export class ShareLink extends PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { panel } = this.props;
|
||||
const isRelativeTime = this.props.dashboard ? this.props.dashboard.time.to === 'now' : false;
|
||||
const { panel, dashboard } = this.props;
|
||||
const isRelativeTime = dashboard ? dashboard.time.to === 'now' : false;
|
||||
const { useCurrentTimeRange, useShortUrl, selectedTheme, shareUrl, imageUrl } = this.state;
|
||||
const selectors = e2eSelectors.pages.SharePanelModal;
|
||||
const isDashboardSaved = Boolean(dashboard.id);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -122,13 +123,25 @@ export class ShareLink extends PureComponent<Props, State> {
|
||||
/>
|
||||
</Field>
|
||||
</FieldSet>
|
||||
|
||||
{panel && config.rendererAvailable && (
|
||||
<div className="gf-form">
|
||||
<a href={imageUrl} target="_blank" rel="noreferrer" aria-label={selectors.linkToRenderedImage}>
|
||||
<Icon name="camera" /> Direct link rendered image
|
||||
</a>
|
||||
</div>
|
||||
<>
|
||||
{isDashboardSaved && (
|
||||
<div className="gf-form">
|
||||
<a href={imageUrl} target="_blank" rel="noreferrer" aria-label={selectors.linkToRenderedImage}>
|
||||
<Icon name="camera" /> Direct link rendered image
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isDashboardSaved && (
|
||||
<Alert severity="info" title="Dashboard is not saved" bottomSpacing={0}>
|
||||
To render a panel image, you must save the dashboard first.
|
||||
</Alert>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{panel && !config.rendererAvailable && (
|
||||
<Alert severity="info" title="Image renderer plugin not installed" bottomSpacing={0}>
|
||||
<>To render a panel image, you must install the </>
|
||||
|
Loading…
Reference in New Issue
Block a user