Skip to content

feat(rls-frontend): Add new buttons to select/deselect all datasets/roles in RLS#32996

Closed
bmaquet wants to merge 2 commits into
apache:masterfrom
bmaquet:feat/rls-select-deselect-all-button
Closed

feat(rls-frontend): Add new buttons to select/deselect all datasets/roles in RLS#32996
bmaquet wants to merge 2 commits into
apache:masterfrom
bmaquet:feat/rls-select-deselect-all-button

Conversation

@bmaquet
Copy link
Copy Markdown
Contributor

@bmaquet bmaquet commented Apr 3, 2025

SUMMARY

This PR introduces "Select All" and "Deselect All" buttons to the Table & Roles elements of the Row Level Security (RLS) configuration interface. This enhancement aims to improve user experience, particularly when managing a large number of tables or roles, by allowing bulk selection and deselection instead of requiring individual clicks for each item. The implementation adds two distinct buttons to trigger these actions, updating the selection state accordingly.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE

Screenshot 2025-04-03 at 12 59 20

AFTER

Screenshot 2025-04-03 at 13 02 44

TESTING INSTRUCTIONS

  1. Navigate to the Row Level Security configuration section.
  2. Click on Datasets or Roles boxes
  3. Observe the presence of the new "Select All" and "Deselect All" buttons.
  4. If starting with no items selected, click "Select All". Verify that all relevant items (e.g., tables, roles) are now selected.
  5. Click "Deselect All". Verify that all items are now deselected.
  6. Manually select a subset of items.
  7. Click "Deselect All". Verify all are deselected.
  8. Manually select a subset of items.
  9. Click "Select All". Verify all are selected.

ADDITIONAL INFORMATION

  • Has associated issue: (Fill in if applicable, e.g., Fixes #123)
  • Required feature flags: (Fill in if applicable)
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API (Implicitly, via UI interaction)
  • Removes existing feature or API

@dosubot dosubot Bot added the authentication:row-level-security Related to Row Level Security label Apr 3, 2025
Copy link
Copy Markdown

@korbit-ai korbit-ai Bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Readability Complex Inline Event Handler ▹ view 🧠 Not in scope
Error Handling Missing error handling in API request ▹ view 🧠 Not in standard
Performance Redundant API Call for Select All ▹ view 🧠 Not in scope
Files scanned
File Path Reviewed
superset-frontend/src/features/rls/RowLevelSecurityModal.tsx

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • On any given comment that Korbit raises on your pull request, you can have a discussion with Korbit by replying to the comment.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Feedback and Support

Comment on lines +357 to +368
SupersetClient.get({
endpoint: `/api/v1/rowlevelsecurity/related/${entityType}?q=${query}`,
}).then(response => {
const allEntities = response.json.result.map(
(item: { value: number; text: string }) => ({
key: item.value,
label: item.text,
value: item.value,
}),
);
updateRuleState(entityType, allEntities || []);
});

This comment was marked as resolved.

Comment on lines +357 to +359
SupersetClient.get({
endpoint: `/api/v1/rowlevelsecurity/related/${entityType}?q=${query}`,
}).then(response => {

This comment was marked as resolved.

Comment on lines +346 to +370
const createDropdownRender = useCallback(
(entityType: 'tables' | 'roles') => (menu: React.ReactNode) => (
<>
<StyledDropdownContainer>
<StyledDropdownButton
type="button"
onClick={() => {
const query = rison.encode({
page: 0,
page_size: -1,
});
SupersetClient.get({
endpoint: `/api/v1/rowlevelsecurity/related/${entityType}?q=${query}`,
}).then(response => {
const allEntities = response.json.result.map(
(item: { value: number; text: string }) => ({
key: item.value,
label: item.text,
value: item.value,
}),
);
updateRuleState(entityType, allEntities || []);
});
}}
>

This comment was marked as resolved.

margin-top: ${({ theme }) => theme.gridUnit}px;
`;

const StyledDropdownContainer = styled.div`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR adds a lot of styled elements. Do you think that in support of Theming efforts underway, we could either:
a) Just go with "vanilla" AntD components and minimize style overrides
b) Move these styles into the root component behind a new prop so that they're reusable rather than bespoke for this one instance?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment @rusackas !
I wasn't aware of the new theming efforts. I can definitely do either of these. Which one would you suggest?

Copy link
Copy Markdown
Contributor Author

@bmaquet bmaquet Apr 3, 2025

Choose a reason for hiding this comment

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

"Vanilla" AntD would look like this (default type)

Screenshot 2025-04-03 at 17 48 26
Screenshot 2025-04-03 at 17 48 33

@rusackas
Copy link
Copy Markdown
Member

rusackas commented Apr 3, 2025

@michael-s-molina @geido actually, didn't we have a prop for the Select component to add a "Select All" option, rather than adding these buttons?

@michael-s-molina
Copy link
Copy Markdown
Member

michael-s-molina commented Apr 3, 2025

@michael-s-molina @geido actually, didn't we have a prop for the Select component to add a "Select All" option, rather than adding these buttons?

Yes, it's the allowSelectAll which is available only to the sync select. Implementing Select All for asynchronous selects has many challenges as you can see in #20143.

@bmaquet
Copy link
Copy Markdown
Contributor Author

bmaquet commented Apr 4, 2025

@michael-s-molina @geido actually, didn't we have a prop for the Select component to add a "Select All" option, rather than adding these buttons?

Yes, it's the allowSelectAll which is available only to the sync select. Implementing Select All for asynchronous selects has many challenges as you can see in #20143.

Thanks for the context about challenges with AsyncSelect @michael-s-molina

What would be the suggested design decision here then? Go ahead with custom buttons for this use case without implementing Select All for the AsyncSelect component, or close the PR entirely and come back to it if/when the AsyncSelect challenges can be overcome?

@mistercrunch
Copy link
Copy Markdown
Member

mistercrunch commented Apr 9, 2025

Oh! about theming, there's been a fair amount of work on the template_less branch moving <Select> to antd v5 and should probably hold off here. Sorry this is pretty unusual for us as we rarely have massive feature branches like that one.

Would recommend either re-opening the PR against template_less or holding off until it's merged.

Since I'm here, and about design, note that the Select component has an allowClear prop, and that common implementation for "select all" is through an (all) special first element. Tagging @kasiazjc for design input Oh I see now some of this has been covered with more context...

Sorry about the confusion - but let's try to avoid merge conflicts. As far as ETA I think we're almost there for merging the theming / antd-v5 branch, waiting for v5.0 to be officially voted through to merge into master

@bmaquet
Copy link
Copy Markdown
Contributor Author

bmaquet commented Apr 10, 2025

Oh! about theming, there's been a fair amount of work on the template_less branch moving <Select> to antd v5 and should probably hold off here. Sorry this is pretty unusual for us as we rarely have massive feature branches like that one.

Would recommend either re-opening the PR against template_less or holding off until it's merged.

Since I'm here, and about design, note that the Select component has an allowClear prop, and that common implementation for "select all" is through an (all) special first element. Tagging @kasiazjc for design input Oh I see now some of this has been covered with more context...

Sorry about the confusion - but let's try to avoid merge conflicts. As far as ETA I think we're almost there for merging the theming / antd-v5 branch, waiting for v5.0 to be officially voted through to merge into master

Thanks for the extra context. I'll close this PR and wait until the theming PR is merged to revisit.

@bmaquet bmaquet closed this Apr 10, 2025
@mistercrunch
Copy link
Copy Markdown
Member

[... getting back to try and get that big feature branch merged so it's easier to accept this type of contribution ...]

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

Labels

authentication:row-level-security Related to Row Level Security size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants