diff --git a/src/redux/reducers/group-reducer.ts b/src/redux/reducers/group-reducer.ts index 42170eddd..118fdfe72 100644 --- a/src/redux/reducers/group-reducer.ts +++ b/src/redux/reducers/group-reducer.ts @@ -26,6 +26,7 @@ export interface Group { modified?: string; admin_default?: boolean; platform_default?: boolean; + system?: boolean; } export interface GroupStore { diff --git a/src/smart-components/access-management/UserGroupsTable.tsx b/src/smart-components/access-management/UserGroupsTable.tsx index ac3e49a53..a5846bfc9 100644 --- a/src/smart-components/access-management/UserGroupsTable.tsx +++ b/src/smart-components/access-management/UserGroupsTable.tsx @@ -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']; @@ -121,7 +121,7 @@ const UserGroupsTable: React.FunctionComponent = ({ (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, @@ -133,10 +133,10 @@ const UserGroupsTable: React.FunctionComponent = ({
{intl.formatMessage(messages['usersAndUserGroupsNoDescription'])}
), 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: ( = ({ }, ]} rowData={group} + isDisabled={group.platform_default || group.system} /> ), props: { isActionCell: true }, @@ -166,6 +167,10 @@ const UserGroupsTable: React.FunctionComponent = ({ 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))); @@ -195,15 +200,7 @@ const UserGroupsTable: React.FunctionComponent = ({ 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)} @@ -249,11 +246,13 @@ const UserGroupsTable: React.FunctionComponent = ({ { 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)} /> }