feat(dashboards-ng): support bulk add from widget catalog#2033
feat(dashboards-ng): support bulk add from widget catalog#2033chintankavathia wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a bulk selection feature to the widget catalog, allowing users to add multiple widgets to the dashboard simultaneously. The implementation includes UI updates for bulk mode, state management using signals, and updated event emitters. Feedback focuses on ensuring the parent component correctly binds to the new bulk output, preventing unintended selection toggles during search or initialization, and refining the CdkListbox integration and type definitions for better type safety and accessibility.
3683127 to
6f608d6
Compare
|
@panch1739 Please have a look. |
panch1739
left a comment
There was a problem hiding this comment.
@chintankavathia Question, the bulk action button is just for demo purposes? Otherwise we should just have the checkboxes always there 🤔
No its part of the component. I had to keep that explicitly because widgets which requires configurations can not be selected for bulk add. Let me know if you have a better way to handle that situation |
68b050a to
213675f
Compare
a465285 to
3b38089
Compare
Adds an opt-in multi-select mode to the widget catalog, letting users
pick several widgets and add them to a dashboard in one go instead of
opening the catalog once per widget.
To enable it, set `enableMultiSelect` on `<si-flexible-dashboard>`:
```
<si-flexible-dashboard
[widgetCatalog]="widgets"
[enableMultiSelect]="true"
/>
```
When enabled, the catalog shows selectable items and a confirmation
action that adds all chosen widgets to the dashboard at once. The
default single-select behavior is unchanged when the flag is omitted.
To support widgets that need configuration before they can render, a
new optional `setupPending` property has been added to `WidgetConfig`.
When `setupPending` is `true`, the dashboard renders a placeholder for
that widget and prompts the user to complete setup. Once the user
confirms the configuration, `setupPending` flips to `false` and the
placeholder is replaced by the actual widget instance. This keeps the
bulk-add flow fast while still allowing widgets that require user
input to be configured afterwards.
DEPRECATED: `SiWidgetCatalogComponent.selected` is deprecated in favor
of `selectedWidgets` and `hasSelection`. The old property only ever
holds the first selected widget and is not updated in multi-select
mode. It will be removed in one of the next major releases. Only
relevant if you extend `SiWidgetCatalogComponent`.
```
BREAKING CHANGE: `SiWidgetCatalogComponent.closed` signature changed
from `output<Omit<WidgetConfig, 'id'> | undefined>` to
`output<Omit<WidgetConfig, 'id'>[] | undefined>`. In single-select mode
the array always contains exactly one entry.
This only affects code that either:
- subclasses `SiWidgetCatalogComponent` and overrides `closed` or
calls `this.closed.emit(...)`, or
- uses `<si-widget-catalog>` directly in a template and subscribes
to `(closed)`.
Migration for subclasses:
- Update overridden output type to
`Omit<WidgetConfig, 'id'>[] | undefined`.
- Wrap `emit(config)` calls as `emit([config])`.
Migration for direct template consumers:
Before:
```
onClosed(config: Omit<WidgetConfig, 'id'> | undefined) {
if (config) this.addWidget(config);
}
```
After:
```
onClosed(configs: Omit<WidgetConfig, 'id'>[] | undefined) {
configs?.forEach(config => this.addWidget(config));
}
```
3b38089 to
cef677c
Compare
Adds an opt-in multi-select mode to the widget catalog, letting users pick several widgets and add them to a dashboard in one go instead of opening the catalog once per widget.
Documentation.
Examples.
Dashboards Demo.
Playwright report.
Coverage Reports: