[FEATURE] Add panel-level repeat variable support#149
Conversation
|
@adrianSepiol |
@shahrokni Pipelines are failing because of PR mentioned in description that needs to be merged for this to work: perses/spec#32 |
c42f663 to
b611f9c
Compare
|
Removed "mode" option after comments from @AntoineThebaud in perses/perses#2936. I've updated description of PR. |
b611f9c to
23fe7b8
Compare
ddec28f to
9a6a842
Compare
Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
9a6a842 to
b83e228
Compare
|
Hi @jgbernalp @Gladorme, I've moved this pr to ready for review with new Layout tab that we have discussed. |
| layoutDefinition?: { | ||
| width: number; | ||
| height: number; | ||
| repeatVariable?: { |
There was a problem hiding this comment.
do we have a limit on the total number of repetitions, what if a variable value produces 1K options. It seems a lot of panels would be created in that case and I see no configurable value to set a max
| // limitations under the License. | ||
|
|
||
| export * from './LayoutEditor'; | ||
| export * from './RepeatLayoutPreview'; |
There was a problem hiding this comment.
| export * from './RepeatLayoutPreview'; | |
| export * from './RepeatLayoutPreview'; | |
| export * from './RepeatVariableEditor'; |
| const currentGroup = state.panelGroups[panelGroupId]; | ||
| const layoutIndex = currentGroup?.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId); | ||
| if (currentGroup === undefined || layoutIndex === undefined || layoutIndex === -1) { | ||
| throw new Error(`Could not find layout for panel group item ${panelGroupItemId}`); |
There was a problem hiding this comment.
| throw new Error(`Could not find layout for panel group item ${panelGroupItemId}`); | |
| throw new Error(`Could not find layout for panel group item ${JSON.stringify(panelGroupItemId)}`); |
| } | ||
| const currentLayout = currentGroup.itemLayouts[layoutIndex]; | ||
| if (currentLayout === undefined) { | ||
| throw new Error(`Could not find layout for panel group item ${panelGroupItemId}`); |
There was a problem hiding this comment.
| throw new Error(`Could not find layout for panel group item ${panelGroupItemId}`); | |
| throw new Error(`Could not find layout for panel group item ${JSON.stringify(panelGroupItemId)}`); |
| import { GridItemContent } from './GridItemContent'; | ||
| import { RepeatGridItemContent } from './RepeatGridItemContent'; | ||
|
|
||
| const DEFAULT_MARGIN = 10; |
There was a problem hiding this comment.
Should we import this from Row.tsx?
| // Provide actions to the panel when in edit mode | ||
| let editHandlers: PanelProps['editHandlers'] = undefined; | ||
| if (isEditMode) { | ||
| if (canModify && !readonly) { |
There was a problem hiding this comment.
canModify already checks readonly
| * A group of non-overridden variable definitions sharing a common source/scope. | ||
| * `source` is undefined for dashboard-scoped variables. | ||
| */ | ||
| export interface VariableDefinitionGroup { |
There was a problem hiding this comment.
The same interface is in the plugin system package. We should use it from a single place either dashboards or plugin-system but not both.
| } | ||
| return result; | ||
| }, [variableValues, perRow]); | ||
| const perPanelWidth = useMemo(() => Math.floor((width - itemGap * (perRow - 1)) / perRow), [itemGap, perRow, width]); |
There was a problem hiding this comment.
It seems the value could be negative when the container is very narrow, relative to perRow.
Closes: perses/perses#2936
Needs: perses/spec#32
Description
Adds support for repeat panel based on variable. Uses only selected values from dropdown are used.
Screenshots
In below recording you can notice that width of panel is expanded when you select repeat variable and height is used for single tile. If you don't fill 'Max per row' all tiles will be fitted into single row.
layout-editor.mov
In this one you can see how the panel will behave when the amount of selected values will change. You can enter edit mode only with first panel.
Screen.Recording.2026-06-10.at.09.00.11.mov
Group repeat has priority over panel repeat.
Screen.Recording.2026-06-01.at.19.14.58.mov
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: