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

Comment on lines +16 to +44
#httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"

#batchMode: "batch" | "individual"

#contentType: "none" | "json" | "text"

#baseAction: {
name: string
icon?: string
confirmMessage?: string
enabled: bool | *true
bodyTemplate?: string
batchMode: #batchMode | *"individual"
}

#eventAction: {
#baseAction
type: "event"
eventName: string
}

#webhookAction: {
#baseAction
type: "webhook"
url: string
method: #httpMethod | *"POST"
contentType: #contentType | *"none"
headers?: [string]: string
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Some defs can be merged up imho:

Suggested change
#httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"
#batchMode: "batch" | "individual"
#contentType: "none" | "json" | "text"
#baseAction: {
name: string
icon?: string
confirmMessage?: string
enabled: bool | *true
bodyTemplate?: string
batchMode: #batchMode | *"individual"
}
#eventAction: {
#baseAction
type: "event"
eventName: string
}
#webhookAction: {
#baseAction
type: "webhook"
url: string
method: #httpMethod | *"POST"
contentType: #contentType | *"none"
headers?: [string]: string
}
#baseAction: {
name: string
icon?: string
confirmMessage?: string
enabled: bool | *true
bodyTemplate?: string
batchMode: "batch" | *"individual"
}
#eventAction: {
#baseAction
type: "event"
eventName: string
}
#webhookAction: {
#baseAction
type: "webhook"
url: string
method: "GET" | *"POST" | "PUT" | "PATCH" | "DELETE"
contentType: *"none" | "json" | "text"
headers?: [string]: string
}

Comment on lines +46 to +48
#itemAction:
(#eventAction & {type: "event"}) |
(#webhookAction & {type: "webhook"})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be simplified to

Suggested change
#itemAction:
(#eventAction & {type: "event"}) |
(#webhookAction & {type: "webhook"})
#itemAction: #eventAction | #webhookAction


#actions: {
enabled: bool | *true
actionsList: [#itemAction, ...]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
actionsList: [#itemAction, ...]
actionsList: [...#itemAction]

[#itemAction, ...] actually means "a list starting by an itemAction followed by any structs"

Comment on lines +53 to +54
displayInHeader?: bool | *true
displayWithItem?: bool | *true
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want/need to define default values for these optional attributes?

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.

/>

<Stack direction="row" spacing={2}>
<TextField
Copy link
Member

@Gladorme Gladorme Jan 28, 2026

Choose a reason for hiding this comment

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

When I tested manually, when I type something, I lose focus after 1 char. Same issue on all fields of this components :/

): 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 😅

{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

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