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: create edit user group page #1732

Merged

Conversation

CodyWMitchell
Copy link
Contributor

@CodyWMitchell CodyWMitchell commented Dec 13, 2024

Description

Created the Edit User Group page

  • I can edit an existing user group by performing any or all of the following actions:
  • I can rename the user group.
  • I can update the description of the user group.
  • I am notified if the updated user group name has already been used for my organization.
  • I can confirm or cancel the request.
  • Upon cancellation, I am redirected to the previous page/task.
  • Upon saving, I am presented with a success message and redirected to the User Group list.
  • I am presented with an error message if the user group is not saved successfully.

Will be handled in future ticket

  • I can add or remove principal users and service accounts from the user group from their respective tabs.

Currently values are diffed and displayed, then logged to the console. Another ticket will handle sending out the appropriate requests.

RHCLOUD-32236

Improve the integration between DataView and data-driven-forms, and potentially create a custom DataView component which could simplify this logic and enable disabling the submit button when no changes have been made here:
RHCLOUD-37436 & RHCLOUD-37435


Screenshots

After:

image


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

@CodyWMitchell CodyWMitchell requested a review from a team as a code owner December 13, 2024 15:33
@CodyWMitchell CodyWMitchell mentioned this pull request Dec 13, 2024
18 tasks
@CodyWMitchell CodyWMitchell force-pushed the edit-user-groups-page branch 4 times, most recently from 8595f6c to 4893df8 Compare January 7, 2025 07:13
@fhlavac
Copy link
Contributor

fhlavac commented Jan 7, 2025

@CodyWMitchell the navigation and breadcrumbs needs to be fixed to highlight and show correctly
image

after changes introduced in #1735, there should be also /user-groups section in the URL

@fhlavac
Copy link
Contributor

fhlavac commented Jan 7, 2025

we should introduce some loading state to prevent this from happening
chrome-capture-2025-1-7

@@ -75,6 +76,10 @@ const getRoutes = ({ enableServiceAccounts, isITLess, isWorkspacesFlag, isCommon
},
],
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

should be a child route

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
Rendering this as a child route adds the Users and Users Groups header above - is there a way to avoid this?

Comment on lines 39 to 50
{ type: validatorTypes.REQUIRED },
(value: string) => {
if (value === group?.name) {
return undefined;
}

const isDuplicate = allGroups.some(
(existingGroup) => existingGroup.name.toLowerCase() === value?.toLowerCase() && existingGroup.uuid !== groupId
);

return isDuplicate ? intl.formatMessage(Messages.groupNameTakenTitle) : undefined;
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will work correctly. The groups' response is paginated so you probably won't get all the data to validate properly. Mabe we could reuse the denounced validator currently used in former add group wizard.


return (
<React.Fragment>
<ContentHeader title={intl.formatMessage(Messages.usersAndUserGroupsEditUserGroup)} subtitle={''} />
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
<ContentHeader title={intl.formatMessage(Messages.usersAndUserGroupsEditUserGroup)} subtitle={''} />
<ContentHeader title={intl.formatMessage(Messages.usersAndUserGroupsEditUserGroup)} />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like typescript requires the subtitle prop in the ContentHeader, it's not marked as optional. I see an error when I remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, I see. I'll open an issue in the component groups

import { ServiceAccountsState } from '../../redux/reducers/service-account-reducer';
import { LAST_PAGE, ServiceAccount } from '../../helpers/service-account/service-account-helper';
import { BulkSelect, BulkSelectValue } from '@patternfly/react-component-groups';
import DateFormat from '@redhat-cloud-services/frontend-components/DateFormat';
Copy link
Contributor

Choose a reason for hiding this comment

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

we should rather use PatternFly Timestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The mocks show the time formatted as 1 month ago. I didn't see a straightforward way to do this with the PatternFly Timestamp in the docs without defining it custom somehow.
image


return (
<React.Fragment>
<FormGroup label="Select users and/or service accounts">
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be localized

<React.Fragment>
<FormGroup label="Select users and/or service accounts">
<Tabs activeKey={activeTabKey} onSelect={handleTabSelect}>
<Tab eventKey={0} title="Users">
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be localized

/>
}
/>
<DataViewTable variant="compact" columns={['Org Admin', 'Username', 'Email', 'First name', 'Last name', 'Status']} rows={rows} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be localized

@fhlavac
Copy link
Contributor

fhlavac commented Jan 7, 2025

Compared to mockups we should have local breadcrumbs and the "Name" field should be required
image

image

@fhlavac
Copy link
Contributor

fhlavac commented Jan 7, 2025

It would be also nice to disable "Submit" button when there are no changes - it should be pretty easy using the form state

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could just reuse the existingUsersTable, what do you think? Also, it might be good to add loading state when changing pages (the UsersTable already has them)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since selection is being used for enabling and disabling users here - with the mocks showing the Org Admin column shuffled around and no action buttons - I made this into its own component instead of reusing the users table. I can try to make the original users table work for both cases if you think that's better though. Either way, I'll make sure to add loading states to this version. 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

@CodyWMitchell columns shuffled around is an interesting thing --it might be good to ask Margot, who prepared the mockups if that's intentional. But, I agree that this table will probably be much simpler than the regular Users view - it's probably a safer solution in this case 👍

Comment on lines 57 to 62
const calculateTotalCount = () => {
if (!serviceAccounts) return 0;
const currentCount = (page - 1) * perPage + serviceAccounts.length;
return status === LAST_PAGE ? currentCount : currentCount + 1;
};
const totalCount = calculateTotalCount();
Copy link
Contributor

Choose a reason for hiding this comment

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

could be memoized

@fhlavac
Copy link
Contributor

fhlavac commented Jan 7, 2025

@CodyWMitchell looks good! Just few comments

@fhlavac
Copy link
Contributor

fhlavac commented Jan 24, 2025

@CodyWMitchell when opening the detail, the URL should contain access-management, not user-access
image

Also, the link to groups in the local breadcrumbs has the same issue

@fhlavac
Copy link
Contributor

fhlavac commented Jan 24, 2025

The submit button looks to be enabled even if the form is pristine
image

If it is a more complex thing, we can also create a separate ticket to fix that so as not to block this one.

@fhlavac
Copy link
Contributor

fhlavac commented Jan 24, 2025

chrome-capture-2025-1-24
After submitting the form, the table does not seem to be updated.

@fhlavac
Copy link
Contributor

fhlavac commented Jan 24, 2025

@CodyWMitchell just three small comments, it looks much better now! Thank you 🙂

@karelhala
Copy link
Contributor

@fhlavac for the breadcrumbs the workspaces effort has them broken and we'll have to fix a few of the screens. For the pristine state, that's connected to DDF and DW interaction and we'll have to write custom component and fix it in tech debt. As for the non updated values @CodyWMitchell will create a ticket to address this in a different ticket since this looks like API race condition.

@karelhala karelhala merged commit 6ee38d3 into RedHatInsights:master Jan 29, 2025
9 of 11 checks passed
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