Canvas: Adhere editing state to dashboard editable state (#87883)

This commit is contained in:
Nathan Marrs 2024-05-15 18:17:50 -06:00 committed by GitHub
parent a17340ea8b
commit 431fdd4bab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,7 @@ import { PanelContext, PanelContextRoot } from '@grafana/ui';
import { CanvasFrameOptions } from 'app/features/canvas'; import { CanvasFrameOptions } from 'app/features/canvas';
import { ElementState } from 'app/features/canvas/runtime/element'; import { ElementState } from 'app/features/canvas/runtime/element';
import { Scene } from 'app/features/canvas/runtime/scene'; import { Scene } from 'app/features/canvas/runtime/scene';
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { PanelEditEnteredEvent, PanelEditExitedEvent } from 'app/types/events'; import { PanelEditEnteredEvent, PanelEditExitedEvent } from 'app/types/events';
import { SetBackground } from './components/SetBackground'; import { SetBackground } from './components/SetBackground';
@ -61,11 +62,16 @@ export class CanvasPanel extends Component<Props, State> {
moveableAction: false, moveableAction: false,
}; };
// TODO: Will need to update this approach for dashboard scenes
// migration (new dashboard edit experience)
const dashboard = getDashboardSrv().getCurrent();
const allowEditing = this.props.options.inlineEditing && dashboard?.editable;
// Only the initial options are ever used. // Only the initial options are ever used.
// later changes are all controlled by the scene // later changes are all controlled by the scene
this.scene = new Scene( this.scene = new Scene(
this.props.options.root, this.props.options.root,
this.props.options.inlineEditing, allowEditing,
this.props.options.showAdvancedTypes, this.props.options.showAdvancedTypes,
this.props.options.panZoom, this.props.options.panZoom,
this.props.options.infinitePan, this.props.options.infinitePan,