From de859426c7e2e19de215f525c72169ef673fa27d Mon Sep 17 00:00:00 2001 From: Cody Mitchell Date: Thu, 24 Oct 2024 16:14:30 -0400 Subject: [PATCH] fix: more updates based on PR feedback --- src/Messages.js | 21 +++++++++++++++++++ .../access-management/AddUserGroupModal.tsx | 17 ++++++++------- .../access-management/UserGroupsTable.tsx | 12 +++++------ .../access-management/UsersTable.tsx | 10 ++++----- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/Messages.js b/src/Messages.js index 09693ec1e..92d2340ad 100644 --- a/src/Messages.js +++ b/src/Messages.js @@ -2123,6 +2123,21 @@ export default defineMessages({ description: 'Add to user group label', defaultMessage: 'Add to user group', }, + usersAndUserGroupsEditUserGroup: { + id: 'usersAndUserGroupsEditUserGroup', + description: 'Edit user group label', + defaultMessage: 'Edit user group', + }, + usersAndUserGroupsDeleteUserGroup: { + id: 'usersAndUserGroupsDeleteUserGroup', + description: 'Delete user group label', + defaultMessage: 'Delete user group', + }, + usersAndUserGroupsRemoveFromGroup: { + id: 'usersAndUserGroupsAddToGroup', + description: 'Remove from user group label', + defaultMessage: 'Remove from user group', + }, usersAndUserGroupsCancel: { id: 'usersAndUserGroupsCancel', description: 'Cancel add user label', @@ -2153,6 +2168,12 @@ export default defineMessages({ description: 'No isnt Org Admin label', defaultMessage: 'No', }, + usersAndUserGroupsAddUserDescription: { + id: 'usersAndUserGroupsAddUserDescription', + description: 'Description within add user to user group modal', + defaultMessage: + 'Select a user group to add {{numUsers} {plural}} to. These are all the user groups in your account. To manage user groups, go to user groups.}', + }, assignedUserGroupsTooltipHeader: { id: 'assignedUserGroupsTooltipHeader', description: 'header for assigned user groups tooltip', diff --git a/src/smart-components/access-management/AddUserGroupModal.tsx b/src/smart-components/access-management/AddUserGroupModal.tsx index 306f8fa52..9610ea11a 100644 --- a/src/smart-components/access-management/AddUserGroupModal.tsx +++ b/src/smart-components/access-management/AddUserGroupModal.tsx @@ -3,7 +3,7 @@ import React from 'react'; import UserGroupsTable from './UserGroupsTable'; import { useDispatch } from 'react-redux'; import { addMembersToGroup } from '../../redux/actions/group-actions'; -import { useIntl } from 'react-intl'; +import { FormattedMessage, useIntl } from 'react-intl'; import messages from '../../Messages'; interface AddUserGroupModalProps { @@ -41,13 +41,16 @@ export const AddUserGroupModal: React.FunctionComponent {intl.formatMessage(messages['usersAndUserGroupsCancel'])} , ]} - ouiaId={'add-user-group-modal'} + ouiaId="add-user-group-modal" > - Select a user group to add{' '} - - {selectedUsers.length} user{selectedUsers.length > 1 && 's'}{' '} - - to. These are all the user groups in your account. To manage user groups, go to user groups. + {text}, + count: selectedUsers.length, + plural: selectedUsers.length > 1 ? 'users' : 'user', + }} + /> console.log('EDIT USER GROUP') }, - { title: 'Delete user group', onClick: () => console.log('DELETE USER GROUP') }, -]; - const PER_PAGE_OPTIONS = [ { title: '5', value: 5 }, { title: '10', value: 10 }, @@ -48,6 +43,11 @@ const UserGroupsTable: React.FunctionComponent = ({ const dispatch = useDispatch(); const intl = useIntl(); + const rowActions = [ + { title: intl.formatMessage(messages['usersAndUserGroupsEditUserGroup']), onClick: () => console.log('EDIT USER GROUP') }, + { title: intl.formatMessage(messages['usersAndUserGroupsDeleteUserGroup']), onClick: () => console.log('DELETE USER GROUP') }, + ]; + const { groups, totalCount } = useSelector((state: RBACStore) => ({ groups: state.groupReducer?.groups?.data || [], totalCount: state.groupReducer?.groups?.meta.count || 0, @@ -125,7 +125,7 @@ const UserGroupsTable: React.FunctionComponent = ({ group.workspaces || '?', // not currently in API formatDistanceToNow(new Date(group.modified), { addSuffix: true }), enableActions && { - cell: , + cell: , props: { isActionCell: true }, }, ], diff --git a/src/smart-components/access-management/UsersTable.tsx b/src/smart-components/access-management/UsersTable.tsx index 7241c2749..03b14f03d 100644 --- a/src/smart-components/access-management/UsersTable.tsx +++ b/src/smart-components/access-management/UsersTable.tsx @@ -32,16 +32,16 @@ interface UsersTableProps { } const UsersTable: React.FunctionComponent = ({ onAddUserClick }) => { + const dispatch = useDispatch(); + const intl = useIntl(); + const rowActions = (user: UserProps) => { return [ - { title: 'Add to user group', onClick: () => onAddUserClick([user]) }, - { title: 'Remove from user group', onClick: () => console.log('REMOVE FROM USER GROUP') }, + { title: intl.formatMessage(messages['usersAndUserGroupsAddToGroup']), onClick: () => onAddUserClick([user]) }, + { title: intl.formatMessage(messages['usersAndUserGroupsRemoveFromGroup']), onClick: () => console.log('REMOVE FROM USER GROUP') }, ]; }; - const dispatch = useDispatch(); - const intl = useIntl(); - const { users, totalCount } = useSelector((state: RBACStore) => ({ users: state.userReducer.users.data || [], totalCount: state.userReducer.users.meta.count,