Skip to content

Commit

Permalink
fix: more updates based on PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyWMitchell committed Oct 24, 2024
1 parent 7f6b7d0 commit de85942
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
21 changes: 21 additions & 0 deletions src/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 {<b>{numUsers} {plural}</b>} 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',
Expand Down
17 changes: 10 additions & 7 deletions src/smart-components/access-management/AddUserGroupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -41,13 +41,16 @@ export const AddUserGroupModal: React.FunctionComponent<AddUserGroupModalProps>
{intl.formatMessage(messages['usersAndUserGroupsCancel'])}
</Button>,
]}
ouiaId={'add-user-group-modal'}
ouiaId="add-user-group-modal"
>
Select a user group to add{' '}
<span className="pf-v5-u-font-weight-bold">
{selectedUsers.length} user{selectedUsers.length > 1 && 's'}{' '}
</span>
to. These are all the user groups in your account. To manage user groups, go to user groups.
<FormattedMessage
{...messages['usersAndUserGroupsAddUserDescription']}
values={{
b: (text) => <b>{text}</b>,
count: selectedUsers.length,
plural: selectedUsers.length > 1 ? 'users' : 'user',
}}
/>
<UserGroupsTable
defaultPerPage={10}
useUrlParams={false}
Expand Down
12 changes: 6 additions & 6 deletions src/smart-components/access-management/UserGroupsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ import messages from '../../Messages';

const COLUMNS: string[] = ['User group name', 'Description', 'Users', 'Service accounts', 'Roles', 'Workspaces', 'Last modified'];

const ROW_ACTIONS = [
{ title: 'Edit user group', onClick: () => 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 },
Expand All @@ -48,6 +43,11 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
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,
Expand Down Expand Up @@ -125,7 +125,7 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
group.workspaces || '?', // not currently in API
formatDistanceToNow(new Date(group.modified), { addSuffix: true }),
enableActions && {
cell: <ActionsColumn items={ROW_ACTIONS} />,
cell: <ActionsColumn items={rowActions} />,
props: { isActionCell: true },
},
],
Expand Down
10 changes: 5 additions & 5 deletions src/smart-components/access-management/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ interface UsersTableProps {
}

const UsersTable: React.FunctionComponent<UsersTableProps> = ({ 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,
Expand Down

0 comments on commit de85942

Please sign in to comment.