Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rolestable): delete roles modal #1696

Merged
merged 3 commits into from
Nov 14, 2024
Merged

feat(rolestable): delete roles modal #1696

merged 3 commits into from
Nov 14, 2024

Conversation

InsaneZein
Copy link
Contributor

@InsaneZein InsaneZein commented Nov 6, 2024

Description

This allows user to delete Roles. Currently deleting roles api doesn't exist so in the meantime, clicking "delete role" button will just spit out a console.log message.

RHCLOUD-32241


Screenshots

Checklist ☑️

  • PR only fixes one issue or story
  • Change reviewed for extraneous code
  • UI best practices adhered to
  • Commits squashed and meaningfully named
  • All PR checks pass locally (build, lint, test, E2E)

  • (Optional) QE: Needs QE attention (OUIA changed, perceived impact to tests, no test coverage)
  • (Optional) QE: Has been mentioned
  • (Optional) UX: Needs UX attention (end user UX modified, missing designs)
  • (Optional) UX: Has been mentioned

@InsaneZein InsaneZein requested a review from a team November 6, 2024 20:03
@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.

Project coverage is 45.73%. Comparing base (966361c) to head (d21baf8).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/smart-components/role/RolesTable.tsx 0.00% 25 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1696      +/-   ##
==========================================
- Coverage   45.85%   45.73%   -0.13%     
==========================================
  Files         182      182              
  Lines        4883     4896      +13     
  Branches     1377     1379       +2     
==========================================
  Hits         2239     2239              
- Misses       2428     2441      +13     
  Partials      216      216              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@InsaneZein
Copy link
Contributor Author

I realized that sometimes selectedRole is undefined so the modal shows undefined instead of the role name.

Copy link
Contributor

@karelhala karelhala left a comment

Choose a reason for hiding this comment

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

Looks like some of the messages needs to be changed to role's messages. Also when I pulled the PR I found it's missing the toolbar actions which should allow to remove multiple roles.

confirmButtonVariant={ButtonVariant.danger}
onClose={() => setIsDeleteModalOpen(false)}
onConfirm={() => {
console.log(`Deleting ${currentRole?.display_name}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to console.log

Suggested change
console.log(`Deleting ${currentRole?.display_name}`);

<WarningModal
ouiaId={`${ouiaId}-remove-role-modal`}
isOpen={isDeleteModalOpen}
title={intl.formatMessage(messages.deleteUserModalTitle)}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a different message, right now it says Remove from user groups? it should say Remove role?

{ title: 'Edit role', onClick: () => console.log('Editing role') },
{
title: 'Delete role',
onClick: (event: KeyboardEvent | React.MouseEvent, rowId: number, rowData: any) => handleModalToggle(event, rowData),
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to use rowData you have direct access to the role.

Suggested change
onClick: (event: KeyboardEvent | React.MouseEvent, rowId: number, rowData: any) => handleModalToggle(event, rowData),
onClick: (event: KeyboardEvent | React.MouseEvent) => handleModalToggle(event, role),

{isDeleteModalOpen && (
<WarningModal
ouiaId={`${ouiaId}-remove-role-modal`}
isOpen={isDeleteModalOpen}
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the mocks the modal is missing checkbox

Suggested change
isOpen={isDeleteModalOpen}
isOpen={isDeleteModalOpen}
withCheckbox

@karelhala
Copy link
Contributor

@InsaneZein I've checked the API and it has a delete role option https://console.redhat.com/docs/api/rbac/v1#operations-Role-deleteRole it should however be available only on custom roles. If the role is custom can be checked in role definition if system = false

Copy link
Contributor

@karelhala karelhala left a comment

Choose a reason for hiding this comment

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

The modal is using groups messages and looks like this:
Screenshot 2024-11-13 at 9 17 04

But the messages should be:
@
image-2024-09-09-12-24-18-530

The DataView is missing an action button to remove multiple roles. Also selecting single item selects the whole table.

@InsaneZein
Copy link
Contributor Author

Ah ok the task made it sound like this was just for deleting a singular Role. I can work on adding an action button to delete multiple roles in another PR.

@InsaneZein
Copy link
Contributor Author

/retest

@karelhala karelhala merged commit 546a465 into master Nov 14, 2024
11 checks passed
@InsaneZein InsaneZein deleted the delete-role branch November 14, 2024 14:38
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.

3 participants