Canvas: Hide background image size editor options for SVG based elements (#85419)

This commit is contained in:
Nathan Marrs 2024-04-02 10:04:36 -06:00 committed by GitHub
parent a360cf0c85
commit b47f8b429e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -20,7 +20,7 @@ import { Scene } from './scene';
let counter = 0;
const SVGElements = new Set<string>(['parallelogram', 'triangle', 'cloud', 'ellipse']);
export const SVGElements = new Set<string>(['parallelogram', 'triangle', 'cloud', 'ellipse']);
export class ElementState implements LayerElement {
// UID necessary for moveable to work (for now)

View File

@ -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;
},
});
},