Skip to content

[FEATURE] Add panel-level repeat variable support#149

Open
adrianSepiol wants to merge 1 commit into
perses:mainfrom
adrianSepiol:feature/panel-level-repeat
Open

[FEATURE] Add panel-level repeat variable support#149
adrianSepiol wants to merge 1 commit into
perses:mainfrom
adrianSepiol:feature/panel-level-repeat

Conversation

@adrianSepiol

@adrianSepiol adrianSepiol commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

@adrianSepiol
adrianSepiol requested a review from a team as a code owner June 1, 2026 17:22
@shahrokni

Copy link
Copy Markdown
Contributor

@adrianSepiol
Could you please check the two following pipelines. It seems they are failing. ci/build and ci/type-check`` And please before that, rebase` with main.

@adrianSepiol

Copy link
Copy Markdown
Contributor Author

@adrianSepiol Could you please check the two following pipelines. It seems they are failing. ci/build and ci/type-check And please before that, ``rebase` with main.

@shahrokni Pipelines are failing because of PR mentioned in description that needs to be merged for this to work: perses/spec#32

@adrianSepiol
adrianSepiol force-pushed the feature/panel-level-repeat branch 2 times, most recently from c42f663 to b611f9c Compare June 10, 2026 06:53
@adrianSepiol

Copy link
Copy Markdown
Contributor Author

Removed "mode" option after comments from @AntoineThebaud in perses/perses#2936. I've updated description of PR.

@adrianSepiol
adrianSepiol force-pushed the feature/panel-level-repeat branch from b611f9c to 23fe7b8 Compare June 11, 2026 10:16
@adrianSepiol
adrianSepiol marked this pull request as draft July 10, 2026 07:20
@adrianSepiol
adrianSepiol force-pushed the feature/panel-level-repeat branch 10 times, most recently from ddec28f to 9a6a842 Compare July 20, 2026 12:37
Signed-off-by: Adrian Sepiół <a.sepiol@sap.com>
@adrianSepiol
adrianSepiol force-pushed the feature/panel-level-repeat branch from 9a6a842 to b83e228 Compare July 20, 2026 12:49
@adrianSepiol
adrianSepiol marked this pull request as ready for review July 20, 2026 12:58
@adrianSepiol

Copy link
Copy Markdown
Contributor Author

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?: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the value could be negative when the container is very narrow, relative to perRow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panel repeat

3 participants