= ({
{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: ,
+ cell: (
+ console.log('EDIT USER GROUP'),
+ },
+ {
+ title: intl.formatMessage(messages['usersAndUserGroupsDeleteUserGroup']),
+ onClick: () => handleDeleteModalToggle([group]),
+ },
+ ]}
+ rowData={group}
+ isDisabled={group.platform_default || group.system}
+ />
+ ),
props: { isActionCell: true },
},
],
@@ -161,6 +178,21 @@ 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)));
+ setIsDeleteModalOpen(false);
+ fetchData({
+ limit: perPage,
+ offset: (page - 1) * perPage,
+ orderBy: 'name',
+ count: totalCount || 0,
+ });
+ };
const paginationComponent = (
= ({
);
return (
-
-
+ {isDeleteModalOpen && (
+ setIsDeleteModalOpen(false)}
+ onConfirm={() => {
+ handleDeleteGroups(currentGroups);
+ }}
+ >
+ {text},
+ count: currentGroups.length,
+ plural: currentGroups.length > 1 ? intl.formatMessage(messages.groups) : intl.formatMessage(messages.group),
+ name: currentGroups[0]?.name,
+ }}
/>
- }
- pagination={React.cloneElement(paginationComponent, { isCompact: true })}
- />
- {isLoading ? (
-
- ) : (
-
+
)}
-
-
+
+
+ }
+ actions={
+
+ console.log('EDIT USER GROUP')}
+ >
+ {intl.formatMessage(messages.usersAndUserGroupsEditUserGroup)}
+
+ {
+ handleDeleteModalToggle(groups.filter((group) => selected.some((selectedRow: DataViewTrObject) => selectedRow.id === group.uuid)));
+ }}
+ >
+ {intl.formatMessage(messages.usersAndUserGroupsDeleteUserGroup)}
+
+
+ }
+ pagination={React.cloneElement(paginationComponent, { isCompact: true })}
+ />
+ {isLoading ? (
+
+ ) : (
+
+ )}
+
+
+
);
};
diff --git a/src/smart-components/access-management/users-and-user-groups.tsx b/src/smart-components/access-management/users-and-user-groups.tsx
index d510b6868..08ff15542 100644
--- a/src/smart-components/access-management/users-and-user-groups.tsx
+++ b/src/smart-components/access-management/users-and-user-groups.tsx
@@ -8,10 +8,10 @@ import UserGroupsTable from './UserGroupsTable';
import { useLocation, useNavigate } from 'react-router-dom';
import AddUserGroupModal from './AddUserGroupModal';
import { User } from '../../redux/reducers/user-reducer';
-import UserDetailsDrawer from './UserDetailsDrawer';
import { Group } from '../../redux/reducers/group-reducer';
import GroupDetailsDrawer from './GroupDetailsDrawer';
import { DataViewEventsProvider } from '@patternfly/react-data-view';
+import UserDetailsDrawer from './UserDetailsDrawer';
const TAB_NAMES = ['users', 'user-groups'];