feat: add Select All checkbox for credential workspace sharing#6401
feat: add Select All checkbox for credential workspace sharing#6401xxiaoxiong wants to merge 1 commit into
Conversation
Fixes FlowiseAI#5639 When managing credential sharing across multiple workspaces, users had to manually check/uncheck each workspace individually. This was tedious and time-consuming, especially when unsharing a credential from all workspaces. Solution: Add a "Select All" checkbox above the workspace list that allows users to: - Check all workspaces with one click - Uncheck all workspaces with one click - Automatically updates when individual checkboxes are toggled Changes: **packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsx** - Import Checkbox and FormControlLabel from MUI - Add `selectAll` state to track the select-all checkbox - Add `handleSelectAllChange` to toggle all workspace checkboxes - Add useEffect to sync selectAll state with individual row changes - Add UI: "Select All" checkbox above the workspace grid - Position: right-aligned next to "Workspaces" label Features: 1. **One-click select all**: Check the "Select All" box to share with all workspaces 2. **One-click deselect all**: Uncheck to unshare from all workspaces 3. **Smart sync**: Checkbox automatically unchecks if any individual workspace is unchecked 4. **Clean UI**: Positioned next to "Workspaces" label, doesn't clutter the interface Testing: 1. Go to Credentials page 2. Click the share icon (⋮ menu → Share) on any credential 3. ✅ See "Select All" checkbox in the top-right 4. Click "Select All" 5. ✅ All workspace checkboxes are checked 6. Click "Select All" again 7. ✅ All workspace checkboxes are unchecked 8. Check "Select All", then uncheck one workspace manually 9. ✅ "Select All" checkbox automatically unchecks 10. Click Save 11. ✅ Only selected workspaces receive the credential Before: Had to scroll and click each workspace individually After: One click to select/deselect all workspaces
There was a problem hiding this comment.
Code Review
This pull request introduces a 'Select All' functionality to the ShareWithWorkspaceDialog, allowing users to toggle the shared status of all workspaces simultaneously. The feedback suggests simplifying the logic for determining the select-all state and disabling the checkbox when no workspaces are available to prevent confusing UI interactions.
| const allSelected = outputSchema.every((row) => row.shared) | ||
| const noneSelected = outputSchema.every((row) => !row.shared) | ||
| setSelectAll(allSelected ? true : noneSelected ? false : false) |
There was a problem hiding this comment.
The logic for setting selectAll can be simplified. The current ternary expression allSelected ? true : noneSelected ? false : false is equivalent to just allSelected, as both branches of the inner ternary return false. Additionally, consider implementing the indeterminate state for the checkbox (using the indeterminate prop) to provide better visual feedback when only some workspaces are selected.
| const allSelected = outputSchema.every((row) => row.shared) | |
| const noneSelected = outputSchema.every((row) => !row.shared) | |
| setSelectAll(allSelected ? true : noneSelected ? false : false) | |
| const allSelected = outputSchema.every((row) => row.shared) | |
| setSelectAll(allSelected) |
| <Stack direction='row' alignItems='center' justifyContent='space-between' sx={{ mb: 1 }}> | ||
| <Typography variant='overline'>Workspaces</Typography> | ||
| <FormControlLabel | ||
| control={<Checkbox checked={selectAll} onChange={handleSelectAllChange} size='small' />} |
There was a problem hiding this comment.
The "Select All" checkbox should be disabled if there are no workspaces available to select (e.g., when the user only has one workspace, which is filtered out from this list). This prevents confusing UI interactions where the checkbox can be toggled despite having no effect.
| control={<Checkbox checked={selectAll} onChange={handleSelectAllChange} size='small' />} | |
| control={<Checkbox checked={selectAll} onChange={handleSelectAllChange} size='small' disabled={outputSchema.length === 0} />} |
Description
Fixes #5639
When managing credential sharing across multiple workspaces, users had to manually check/uncheck each workspace individually. This was tedious and time-consuming, especially when unsharing a credential from all workspaces.
Problem
Current behavior:
User quote from issue:
Solution
Add a "Select All" checkbox above the workspace list that allows users to:
Changes
packages/ui/src/ui-component/dialog/ShareWithWorkspaceDialog.jsxFeatures
1. One-Click Select All
2. One-Click Deselect All
3. Smart Synchronization
4. Clean UI Integration
UI/UX
Before
After
Testing
Manual Testing
Basic select all:
Basic deselect all:
Smart sync (all → some):
Smart sync (some → all):
Save functionality:
Reopen dialog:
Edge Cases
No workspaces:
All already shared:
None shared:
Implementation Details
State Management
selectAllstate tracks the checkboxhandleSelectAllChangeupdates all rows when checkbox is toggleduseEffectsyncsselectAllwith individual row changesoutputSchema.every()to determine if all/none are selectedPerformance
Accessibility
Type of Change
Checklist