[FEATURE] Add panel-level repeat variable model#32
Conversation
0c5361e to
0e593be
Compare
5289d45 to
73a8a20
Compare
ibakshay
left a comment
There was a problem hiding this comment.
Thank you for the PR! Added few comments.
There was a problem hiding this comment.
Pull request overview
Adds a panel-level “repeat variable” model to the dashboard layout spec so an individual grid item/panel can be repeated based on a variable, and exposes the needed layout fields in the panel editor model.
Changes:
- Introduces
repeatVariableas an object on grid items (TS/Go/Java/CUE) with fields likevalue,maxPer, andalignment. - Extends panel editor values/schema to include a
layoutDefinition(width/height + optional repeat variable). - Adds Go JSON unmarshal tests for grid items containing the new repeat variable object.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| ts/src/schema/panel.ts | Adds zod schemas for panel editor layoutDefinition and repeat variable. |
| ts/src/dashboard/panel.ts | Extends exported PanelEditorValues with layoutDefinition. |
| ts/src/dashboard/layout.ts | Adds RepeatVariable model and repeatVariable on GridItemDefinition. |
| java/src/main/java/dev/perses/spec/dashboard/Layout.java | Adds RepeatVariable to GridItem. |
| go/dashboard/layout.go | Adds RepeatVariable structs/types and repeatVariable on GridItem. |
| go/dashboard/layout_test.go | Adds JSON unmarshal test cases for the new repeat variable object. |
| cue/dashboard/layout_go_gen.cue | Updates generated CUE schema to include repeat variable object on grid items. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
73a8a20 to
954d1d9
Compare
f88e3d5 to
1da3efd
Compare
Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
1da3efd to
ea0c4d0
Compare
ibakshay
left a comment
There was a problem hiding this comment.
LGTM! @AntoineThebaud Do you also want to have a look?
|
|
||
| export const layoutDefinitionSchema = z.object({ | ||
| repeatVariable: repeatVariableSchema.optional(), | ||
| width: z.number().int().positive(), |
There was a problem hiding this comment.
Panel Editor is only for panel spec, layout is not really handled here (at least currently). Because JSON tab, will only output panel spec, if you do change on layout, nothing will change in JSON. Maybe we need to add two JSON tabs, if we add layout to this editor.
And it's supposing all layouts are using GridItem, that is the case currently. But I don't know if it will always be the case 🤔
After, I don't think it's a better to add a new editor just for layout. And put spec and layout in same editor can be fine.
Ping @Nexucis / @jgbernalp if have strong opinion on this
There was a problem hiding this comment.
As @Gladorme points out the layout is only a property of a dashboard. Panels really should not care which layout was selected for them. We are in the process of adding a new Tab layout in addition to the Grid. I don't think we need a specific editor for layout as it would be configured visually by adding panel groups. Nothing wrong with this code but this schema should be moved to the layout.ts.
There was a problem hiding this comment.
Move zod schema to layout.ts.
There was a problem hiding this comment.
I don't think we need a specific editor for layout as it would be configured visually by adding panel groups
In the current state, panel repeat is not configured by panel groups, but at panel level instead
|
|
||
| #RepeatVariable: { | ||
| value: string @go(Value) | ||
| maxPer?: null | int @go(MaxPer,*int) |
There was a problem hiding this comment.
More link to implem than spec, but what happen if there is two panels next to each other without repeat variable. And you enable it on one with maxPer: 2. Will it do 2 rows?
- 1 panel (without repeat), empty
- panel repeat, panel repeat
There was a problem hiding this comment.
maxPer refers to rows inside grid item. By default the grid item will extend it's width to full grid width when setting repeat panel on given item (inspired by grafana) but after that you can change its width and the panels will be fit into rows based on maxPer variable.
demo.mov
Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
|
LGTM, I'll let @Gladorme approve |
| /** | ||
| * Panel values that can be edited in the panel editor. | ||
| */ | ||
| export interface PanelEditorValues { |
There was a problem hiding this comment.
Not introduced by the PR, but this PanelEditorValues + zod schema (buildPanelEditorSchema + panelEditorSchema) should be at the panel editor level in perses/shared. Make no sense to have UI interface/code here 🤔 I will need to move it later
|
@adrianSepiol I checked again and the structure looks good to me. The repeat variable is part of the layout item rather than the panel itself, which I think is the right direction. Other than @Gladorme comments regarding the misplaced interface, that is a pre existing issue, we can proceed. |
|
Ok for structure me too, except for the panel editor value. |
…cern Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
Related to: perses/perses#2936
Model for repeat variable on panel level.