From b47f8b429ee11e2f640175b9dda998a5ba6c54f9 Mon Sep 17 00:00:00 2001 From: Nathan Marrs Date: Tue, 2 Apr 2024 10:04:36 -0600 Subject: [PATCH] Canvas: Hide background image size editor options for SVG based elements (#85419) --- public/app/features/canvas/runtime/element.tsx | 2 +- public/app/plugins/panel/canvas/editor/options.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/app/features/canvas/runtime/element.tsx b/public/app/features/canvas/runtime/element.tsx index 3e92b3efae7..5b2c17f673c 100644 --- a/public/app/features/canvas/runtime/element.tsx +++ b/public/app/features/canvas/runtime/element.tsx @@ -20,7 +20,7 @@ import { Scene } from './scene'; let counter = 0; -const SVGElements = new Set(['parallelogram', 'triangle', 'cloud', 'ellipse']); +export const SVGElements = new Set(['parallelogram', 'triangle', 'cloud', 'ellipse']); export class ElementState implements LayerElement { // UID necessary for moveable to work (for now) diff --git a/public/app/plugins/panel/canvas/editor/options.ts b/public/app/plugins/panel/canvas/editor/options.ts index fb461163dde..5d968aa5e61 100644 --- a/public/app/plugins/panel/canvas/editor/options.ts +++ b/public/app/plugins/panel/canvas/editor/options.ts @@ -2,6 +2,7 @@ import { capitalize } from 'lodash'; import { PanelOptionsSupplier } from '@grafana/data/src/panel/PanelPlugin'; import { CanvasConnection, CanvasElementOptions, ConnectionDirection } from 'app/features/canvas'; +import { SVGElements } from 'app/features/canvas/runtime/element'; import { ColorDimensionEditor, ResourceDimensionEditor, ScaleDimensionEditor } from 'app/features/dimensions/editors'; import { BackgroundSizeEditor } from 'app/features/dimensions/editors/BackgroundSizeEditor'; @@ -61,6 +62,15 @@ export const optionBuilder: OptionSuppliers = { settings: { resourceType: 'image', }, + showIf: () => { + // Do not show image size editor for SVG based elements + // See https://github.com/grafana/grafana/issues/84843#issuecomment-2010921066 for additional context + if (context.options?.type) { + return !SVGElements.has(context.options.type); + } + + return true; + }, }); },