Skip to content

Commit a7bf9e8

Browse files
Workspace users dialog update (#1399)
Co-authored-by: João Vilaça <[email protected]>
1 parent 0821f65 commit a7bf9e8

18 files changed

+394
-702
lines changed

web_ui/packages/ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export {
101101
type DimensionValue,
102102
type SpectrumRangeCalendarProps,
103103
type CellProps,
104+
type SpectrumTooltipProps,
104105
} from '@adobe/react-spectrum';
105106

106107
export { dimensionValue, useStyleProps, useUnwrapDOMRef, useMediaQuery } from '@react-spectrum/utils';

web_ui/src/pages/user-management/users/actions/remove-user-dialog.component.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ export const RemoveUserDialog = ({ organizationId, user, activeUser, onDeleting
3838
} catch (_error: unknown) {}
3939
};
4040

41-
const email = user.email;
42-
4341
return (
4442
<AlertDialog
4543
title='Delete'
@@ -50,10 +48,10 @@ export const RemoveUserDialog = ({ organizationId, user, activeUser, onDeleting
5048
>
5149
<Flex direction={'column'} gap={'size-150'}>
5250
<Text>
53-
This user account of {email} will be permanently deleted from your Geti™ organization. After
51+
This user account of {user.email} will be permanently deleted from your Geti™ organization. After
5452
deleting the account, the user will not be able to log in again with this account.
5553
</Text>
56-
<Text>Are you sure you want to delete {email}?</Text>
54+
<Text>Are you sure you want to delete {user.email}?</Text>
5755
</Flex>
5856
</AlertDialog>
5957
);

web_ui/src/pages/user-management/users/users-table/users-table.component.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { NotFound } from '../../../../shared/components/not-found/not-found.comp
1616
import { CasualCell } from '../../../../shared/components/table/components/casual-cell/casual-cell.component';
1717
import { StatusCell } from '../../../../shared/components/table/status-cell/status-cell.component';
1818
import { TableCellProps } from '../../../../shared/components/table/table.interface';
19+
import { WorkspaceRoleTooltipContent } from '../../../../shared/components/tooltips/workspace-role-tooltip';
1920
import { SpectrumTableLoadingState } from '../../../../shared/utils';
2021
import { LastLoginCell } from './last-login-cell.component';
2122
import { ProjectRoleCell } from './project-role-cell.component';
@@ -116,10 +117,18 @@ export const UsersTable = ({
116117
dataKey: USERS_TABLE_COLUMNS.ROLES,
117118
width: 150,
118119
isSortable: false,
120+
tooltip: <WorkspaceRoleTooltipContent />,
119121
component: (data: TableCellProps) => {
120122
if (overrideRoleColumn) {
121123
return overrideRoleColumn(data);
122124
}
125+
// Organization-level view (no specific workspace selected)
126+
if (isEmpty(resourceId)) {
127+
const isOrgAdminUser = isOrganizationAdmin(data.rowData, organizationId);
128+
if (isOrgAdminUser) {
129+
return <CasualCell {...data} cellData='N/A' />;
130+
}
131+
}
123132
return isProjectUsersTable ? (
124133
<ProjectRoleCell {...data} roles={data.rowData.roles} projectId={resourceId as string} />
125134
) : (

web_ui/src/pages/user-management/users/users-table/workspaces-role-cell.component.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
import { RESOURCE_TYPE, Role } from '@geti/core/src/users/users.interface';
55
import { Workspace } from '@geti/core/src/workspaces/services/workspaces.interface';
6-
import { isEmpty } from 'lodash-es';
6+
import { capitalize, isEmpty } from 'lodash-es';
77

88
import { CasualCell } from '../../../../shared/components/table/components/casual-cell/casual-cell.component';
99
import { TableCellProps } from '../../../../shared/components/table/table.interface';
10+
import { WorkspaceRoleTooltipContent } from '../../../../shared/components/tooltips/workspace-role-tooltip';
1011

1112
interface WorkspacesRoleCellProps extends Omit<TableCellProps, 'cellData'> {
1213
workspaceId: string | undefined;
@@ -16,13 +17,25 @@ interface WorkspacesRoleCellProps extends Omit<TableCellProps, 'cellData'> {
1617

1718
export const WorkspacesRoleCell = ({ cellData, workspaceId, workspaces, ...rest }: WorkspacesRoleCellProps) => {
1819
const workspaceRoles = cellData.filter((role) => role.resourceType === RESOURCE_TYPE.WORKSPACE);
19-
const workspaceRole = workspaceRoles.find((role) => role.resourceId === workspaceId)?.role;
20-
const selectedWorkspaceRole = workspaceRole ? `Workspace ${workspaceRole}` : '';
20+
21+
const selectedWorkspaceRole = capitalize(
22+
workspaceRoles.find((role) => role.resourceId === workspaceId)?.role ?? ''
23+
);
2124
const availableWorkspaces = workspaceRoles
2225
.map((role) => workspaces.find((workspace) => workspace.id === role.resourceId)?.name ?? role.resourceId)
2326
.join(', ');
2427

2528
const rolesWorkspacesCellData = !isEmpty(workspaceId) ? selectedWorkspaceRole : availableWorkspaces;
2629

27-
return <CasualCell {...rest} cellData={rolesWorkspacesCellData} />;
30+
return (
31+
<CasualCell
32+
{...rest}
33+
cellData={rolesWorkspacesCellData}
34+
tooltip={<WorkspaceRoleTooltipContent />}
35+
tooltipProps={{
36+
// Calc is needed to account for paddings
37+
width: 'calc(size-4600 + size-100)',
38+
}}
39+
/>
40+
);
2841
};

0 commit comments

Comments
 (0)