Skip to content

Commit

Permalink
fix: changes from pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyWMitchell committed Nov 15, 2024
1 parent 3b08e37 commit dc7fc11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/redux/reducers/group-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface Group {
modified?: string;
admin_default?: boolean;
platform_default?: boolean;
system?: boolean;
}

export interface GroupStore {
Expand Down
31 changes: 15 additions & 16 deletions src/smart-components/access-management/UserGroupsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { formatDistanceToNow } from 'date-fns';
import { FormattedMessage, useIntl } from 'react-intl';
import messages from '../../Messages';
import { Group } from '../../redux/reducers/group-reducer';
import { EventTypes, useDataViewEventsContext } from '@patternfly/react-data-view';
import { DataViewTrObject, EventTypes, useDataViewEventsContext } from '@patternfly/react-data-view';
import { WarningModal } from '@patternfly/react-component-groups';

const COLUMNS: string[] = ['User group name', 'Description', 'Users', 'Service accounts', 'Roles', 'Workspaces', 'Last modified'];
Expand Down Expand Up @@ -121,7 +121,7 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
(event.target.matches('td') || event.target.matches('tr')) && trigger(EventTypes.rowClick, group);
};

return groups.map((group: any) => ({
return groups.map((group: Group) => ({
id: group.uuid,
row: [
group.name,
Expand All @@ -133,10 +133,10 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
<div className="pf-v5-u-color-400">{intl.formatMessage(messages['usersAndUserGroupsNoDescription'])}</div>
),
group.principalCount,
group.serviceAccounts || '?', // not currently in API
'?', // not currently in API
group.roleCount,
group.workspaces || '?', // not currently in API
formatDistanceToNow(new Date(group.modified), { addSuffix: true }),
'?', // not currently in API
group.modified ? formatDistanceToNow(new Date(group.modified), { addSuffix: true }) : '',
enableActions && {
cell: (
<ActionsColumn
Expand All @@ -151,6 +151,7 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
},
]}
rowData={group}
isDisabled={group.platform_default || group.system}
/>
),
props: { isActionCell: true },
Expand All @@ -166,6 +167,10 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({

const pageSelected = rows.length > 0 && rows.every(isSelected);
const pagePartiallySelected = !pageSelected && rows.some(isSelected);
const isRowSystemOrPlatformDefault = (selectedRow: any) => {
const group = groups.find((group) => group.uuid === selectedRow.id);
return group?.platform_default || group?.system;
};

const handleDeleteGroups = async (groupsToDelete: Group[]) => {
await dispatch(removeGroups(groupsToDelete.map((group) => group.uuid)));
Expand Down Expand Up @@ -195,15 +200,7 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
<WarningModal
ouiaId={`${ouiaId}-remove-user-modal`}
isOpen={isDeleteModalOpen}
title={
<FormattedMessage
{...messages.deleteUserGroupModalTitle}
values={{
count: currentGroups.length,
plural: currentGroups.length > 1 ? intl.formatMessage(messages.groups) : intl.formatMessage(messages.group),
}}
/>
}
title={intl.formatMessage(messages.deleteUserGroupModalTitle, { count: currentGroups.length })}
withCheckbox
checkboxLabel={intl.formatMessage(messages.understandActionIrreversible)}
confirmButtonLabel={intl.formatMessage(messages.remove)}
Expand Down Expand Up @@ -249,11 +246,13 @@ const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
{
title: intl.formatMessage(messages.usersAndUserGroupsDeleteUserGroup),
onClick: () => {
handleDeleteModalToggle(groups.filter((group) => selected.some((selectedGroup) => selectedGroup.id === group.uuid)));
handleDeleteModalToggle(
groups.filter((group) => selected.some((selectedRow: DataViewTrObject) => selectedRow.id === group.uuid))
);
},
},
]}
isDisabled={selected.length === 0}
isDisabled={selected.length === 0 || selected.some(isRowSystemOrPlatformDefault)}
/>
</div>
}
Expand Down

0 comments on commit dc7fc11

Please sign in to comment.