[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
9a6a842 to
b83e228
Compare
|
Hi @jgbernalp @Gladorme, I've moved this pr to ready for review with new Layout tab that we have discussed. |
Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
…tainer is narrower than combined gaps, and consolidate VariableDefinitionGroup to plugin-system model Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
de926ba to
7891364
Compare
…ndered panels per repeat variable Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
7891364 to
e32d1fe
Compare
|
Hi @jgbernalp, I adjusted code to your comments. Could you have another look? |
| repeatVariable: z | ||
| .object({ | ||
| value: z.string(), | ||
| maxPer: z.number().optional(), |
There was a problem hiding this comment.
we should add max and min, if 0 is passed then it will create runtime errors with division by 0 or infinite loops
| maxPer: z.number().optional(), | |
| maxPer: z.number().int().min(1).max(48).optional() |
| if (Array.isArray(variableState.value) && variableState.value.length > 0) { | ||
| return variableState.value; | ||
| } | ||
| return variableState.options?.map((option) => option.value) ?? []; |
There was a problem hiding this comment.
Can variableState.value be a string? if so their options are mapped, is this the intended behavior?
| <Typography sx={{ fontStyle: 'italic' }}>None</Typography> | ||
| </MenuItem> | ||
| {variableDefinitionGroups.flatMap(({ source, definitions }) => { | ||
| const listDefs = definitions.filter((def) => def.kind === 'ListVariable'); |
There was a problem hiding this comment.
if there is a list variable that does not support multiple choices then is not a good candidate for repetition
|
|
||
| import { Layout, Layouts } from 'react-grid-layout'; | ||
| import { DEFAULT_MAX_PER_ROW, DEFAULT_REPEAT_ALIGNMENT, VariableStateMap } from '@perses-dev/plugin-system'; | ||
| import { DEFAULT_MARGIN, ROW_HEIGHT } from '@perses-dev/dashboards'; |
There was a problem hiding this comment.
This imports should be relative as this is the dashboards package. Maybe we can extract this constants into dashboards/src/constants/grid.ts and import from there in other files as well
|
|
||
| expect(await screen.findByText('Layout preview (2 panels)')).toBeInTheDocument(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
we probably should add some tests for more invalid cases, like an invalid maxPer or a result with a single option
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: