add ids in getPanelFrameOptions

This commit is contained in:
joshhunt
2025-08-26 13:24:58 +01:00
parent c244e42787
commit b7a665d2af
@@ -1,5 +1,3 @@
import { v4 as uuidv4 } from 'uuid';
import { selectors } from '@grafana/e2e-selectors'; import { selectors } from '@grafana/e2e-selectors';
import { t } from '@grafana/i18n'; import { t } from '@grafana/i18n';
import { config } from '@grafana/runtime'; import { config } from '@grafana/runtime';
@@ -22,8 +20,8 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
isOpenDefault: true, isOpenDefault: true,
}); });
const panelFrameTitleId = uuidv4(); const panelFrameTitleId = 'panel-frame-title';
const descriptionId = uuidv4(); const descriptionId = 'panel-frame-description';
const setPanelTitle = (title: string) => { const setPanelTitle = (title: string) => {
const input = document.getElementById(panelFrameTitleId); const input = document.getElementById(panelFrameTitleId);
@@ -91,7 +89,7 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
.addItem( .addItem(
new OptionsPaneItemDescriptor({ new OptionsPaneItemDescriptor({
title: t('dashboard.get-panel-frame-category.title.transparent-background', 'Transparent background'), title: t('dashboard.get-panel-frame-category.title.transparent-background', 'Transparent background'),
id: uuidv4(), id: 'panel-frame-transparent-bg',
render: function renderTransparent(descriptor) { render: function renderTransparent(descriptor) {
return ( return (
<Switch <Switch
@@ -107,13 +105,13 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
.addCategory( .addCategory(
new OptionsPaneCategoryDescriptor({ new OptionsPaneCategoryDescriptor({
title: t('dashboard.get-panel-frame-category.title.panel-links', 'Panel links'), title: t('dashboard.get-panel-frame-category.title.panel-links', 'Panel links'),
id: 'Panel links', id: 'panel-frame-links-category',
isOpenDefault: false, isOpenDefault: false,
itemsCount: panel.links?.length, itemsCount: panel.links?.length,
}).addItem( }).addItem(
new OptionsPaneItemDescriptor({ new OptionsPaneItemDescriptor({
title: t('dashboard.get-panel-frame-category.title.panel-links', 'Panel links'), title: t('dashboard.get-panel-frame-category.title.panel-links', 'Panel links'),
id: uuidv4(), id: 'panel-frame-links-category',
render: function renderLinks() { render: function renderLinks() {
return ( return (
<DataLinksInlineEditor <DataLinksInlineEditor
@@ -130,13 +128,13 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
.addCategory( .addCategory(
new OptionsPaneCategoryDescriptor({ new OptionsPaneCategoryDescriptor({
title: t('dashboard.get-panel-frame-category.title.repeat-options', 'Repeat options'), title: t('dashboard.get-panel-frame-category.title.repeat-options', 'Repeat options'),
id: 'Repeat options', id: 'panel-frame-repeat',
isOpenDefault: false, isOpenDefault: false,
}) })
.addItem( .addItem(
new OptionsPaneItemDescriptor({ new OptionsPaneItemDescriptor({
title: t('dashboard.get-panel-frame-category.title.repeat-by-variable', 'Repeat by variable'), title: t('dashboard.get-panel-frame-category.title.repeat-by-variable', 'Repeat by variable'),
id: uuidv4(), id: 'panel-frame-repeat-by-variable',
description: description:
'Repeat this panel for each value in the selected variable. This is not visible while in edit mode. You need to go back to dashboard and then update the variable or reload the dashboard.', 'Repeat this panel for each value in the selected variable. This is not visible while in edit mode. You need to go back to dashboard and then update the variable or reload the dashboard.',
render: function renderRepeatOptions(descriptor) { render: function renderRepeatOptions(descriptor) {
@@ -155,6 +153,7 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
.addItem( .addItem(
new OptionsPaneItemDescriptor({ new OptionsPaneItemDescriptor({
title: t('dashboard.get-panel-frame-category.title.repeat-direction', 'Repeat direction'), title: t('dashboard.get-panel-frame-category.title.repeat-direction', 'Repeat direction'),
id: 'panel-frame-repeat-direction',
showIf: () => !!panel.repeat, showIf: () => !!panel.repeat,
render: function renderRepeatOptions() { render: function renderRepeatOptions() {
const directionOptions = [ const directionOptions = [
@@ -181,7 +180,7 @@ export function getPanelFrameCategory(props: OptionPaneRenderProps): OptionsPane
.addItem( .addItem(
new OptionsPaneItemDescriptor({ new OptionsPaneItemDescriptor({
title: t('dashboard.get-panel-frame-category.title.max-per-row', 'Max per row'), title: t('dashboard.get-panel-frame-category.title.max-per-row', 'Max per row'),
id: uuidv4(), id: 'panel-frame-repeat-max-per-row',
showIf: () => Boolean(panel.repeat && panel.repeatDirection === 'h'), showIf: () => Boolean(panel.repeat && panel.repeatDirection === 'h'),
render: function renderOption(descriptor) { render: function renderOption(descriptor) {
const maxPerRowOptions = [2, 3, 4, 6, 8, 12].map((value) => ({ label: value.toString(), value })); const maxPerRowOptions = [2, 3, 4, 6, 8, 12].map((value) => ({ label: value.toString(), value }));