Skip to content

Conversation

@jgbernalp
Copy link
Contributor

@jgbernalp jgbernalp commented Jan 20, 2026

Description

This PR adds a new Actions and selection features. perses/perses#3788. This allows to define actions based on selected data, for example calling an HTTP request with the interpolated data from multiple rows selection.

Two new Providers were added to the main Panel component, yes we have more providers but users don't have to configure these two, plugin developers can just use the hooks without any issue as they are resilient to undefined context:

  • SelectionContext: allows to share the selected items between the plugin panel and the panel header. This will allow in the future to use selections from time series or other panel plugins.
  • ItemActionsContext: allows to execute the actions configured in the plugin spec, either from the table row or the panel header.

I split into 3 commits so is easier to review:

  1. b33ab5d adds the selection provider, adding a selection configuration option to common cue package
  2. 43747e2 Improves the interpolation formats and moves the functions to the components package, re exporting in plugins for backwards compatibility
  3. 9c52f39 Adds the item actions provider, connecting the selections and actions, adds an actions configuration option to common cue package. The actions and selections integration was added to the table component for plugins to use. Other plugin integrations will follow.

Screenshots

Screen.Recording.2026-01-23.at.20.41.34.mov
Screenshot 2026-01-23 at 20 58 23 Screenshot 2026-01-23 at 20 59 05

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.

@jgbernalp jgbernalp changed the title Selection provider Selection provider and Selection actions Jan 20, 2026
@jgbernalp jgbernalp changed the title Selection provider and Selection actions [FEATURE] Selection provider and Selection actions Jan 20, 2026
@jgbernalp jgbernalp changed the title [FEATURE] Selection provider and Selection actions [FEATURE] Selection provider and Item actions Jan 23, 2026
@jgbernalp jgbernalp force-pushed the selection-provider branch 4 times, most recently from 249c863 to 9c52f39 Compare January 23, 2026 20:04
@jgbernalp jgbernalp marked this pull request as ready for review January 23, 2026 20:10
@jgbernalp jgbernalp requested review from a team and AntoineThebaud as code owners January 23, 2026 20:10
@jgbernalp jgbernalp requested a review from Gladorme January 23, 2026 20:10
Copy link
Contributor

@AntoineThebaud AntoineThebaud left a comment

Choose a reason for hiding this comment

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

Review of the CUE part

Copy link
Member

@Gladorme Gladorme left a comment

Choose a reason for hiding this comment

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

I think item actions are super interesting for embedded usage, maybe a little less for Perses App.

Idea for the future, add a provider for adding supported custom events, it will be useful for autocomplete (who can know all custom events :p) and remove the "custom event" option if there is no custom event supported (like currently in Perses App).

About the webhook, I did not test it, but can we have some CORS issues due to this? Maybe we want to allow to pass by the proxy too (like datasources) at some point?

}
return matches;
}
// Re-export all variable interpolation utilities from @perses-dev/components for backwards compatibility
Copy link
Member

Choose a reason for hiding this comment

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

Any reason(s) to move everything to @perses-dev/components? Circular deps?
Look like more runtime stuff than components to me 👀

And ItemActionsOptionsEditor + SelectionOptionsEditor, I would see them in @perses-dev/components instead.

Copy link
Contributor Author

@jgbernalp jgbernalp Jan 29, 2026

Choose a reason for hiding this comment

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

Yes I moved to components or they will create a circular dependency. Re exported as all the plugins currently consume this from the plugin-system so I wanted to avoid big breaking changes for a single release.

I left the new ItemSelectionActionsOptionsEditor in plugin-system as other plugin related editors are there. We can move/refactor these components to the components in a different PR.

): SelectionState<T, Id> & { hasContext: boolean } {
const ctx = useContext(SelectionContext);

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Not fan of this useEffect, but I guess no others choices. This provider is complex to understand, some comments would be welcomed 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some comments. The useEffect avoids registering the getId function on every render.

{isCollapsed ? <ChevronRight /> : <ChevronDown />}
</IconButton>

<Typography variant="subtitle2">{eventAction.name ?? 'Event Action'}</Typography>
Copy link
Member

Choose a reason for hiding this comment

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

I have the feeling the typo is huge. Can we use the same as colum settings / cell settings?

Image Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the UI to mimic the column settings. Also merged the selection and item actions, so the selection option is only in one place.

Screenshot 2026-01-29 at 17 12 42

…mers

Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
@jgbernalp
Copy link
Contributor Author

I think item actions are super interesting for embedded usage, maybe a little less for Perses App.

Idea for the future, add a provider for adding supported custom events, it will be useful for autocomplete (who can know all custom events :p) and remove the "custom event" option if there is no custom event supported (like currently in Perses App).

About the webhook, I did not test it, but can we have some CORS issues due to this? Maybe we want to allow to pass by the proxy too (like datasources) at some point?

Yes we can have some CORS issues, I thought about the proxy configuration. But wanted t keep the initial change "small" 😅

@jgbernalp jgbernalp force-pushed the selection-provider branch 2 times, most recently from 529c9b3 to f54133f Compare January 29, 2026 17:03
…erpolation

Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
@Gladorme
Copy link
Member

Hmmm, I keep getting the following error, when I try to go on Selections or Item Actions of table panel:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of `TableSelectionsEditor`.

Did you already had this issue? 👀
Normally, everything is up to date on my side and all repo are linked to shared

@jgbernalp
Copy link
Contributor Author

jgbernalp commented Jan 30, 2026

These are the steps I follow in my local setup. Having perses, shared and plugins repo folders as siblings:

  • perses: main branch
  • plugins: selection-provider branch
  • shared: selection-provider branch
# from shared using https://github.com/perses/shared/pull/32
npm i
npm run build
./scripts/link-with-perses/link-with-perses.sh --perses
./scripts/link-with-perses/link-with-perses.sh --plugins

# from perses
./scripts/api_backend_dev.sh --e2e
cd ui
npm i
cd app
npm run start:shared

# from plugins
../perses/bin/percli login
../perses/bin/percli plugin start table

Copy link
Member

@Gladorme Gladorme left a comment

Choose a reason for hiding this comment

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

I retried and it's working fine (strange). lgtm

@jgbernalp jgbernalp merged commit bbf1d00 into main Jan 30, 2026
11 checks passed
@jgbernalp jgbernalp deleted the selection-provider branch January 30, 2026 16:07
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.

4 participants