Skip to content

Commit 641ebe8

Browse files
Add Type column to access table (#2061)
* Add Type column to access table * Remove AccessNameCell --------- Co-authored-by: David Crespo <david-crespo@users.noreply.github.com>
1 parent 1bb8dd3 commit 641ebe8

File tree

7 files changed

+47
-41
lines changed

7 files changed

+47
-41
lines changed

app/components/AccessNameCell.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

app/pages/SiloAccessPage.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from '@oxide/api'
2323
import { Access24Icon } from '@oxide/design-system/icons/react'
2424

25-
import { AccessNameCell } from '~/components/AccessNameCell'
2625
import { HL } from '~/components/HL'
2726
import { RoleBadgeCell } from '~/components/RoleBadgeCell'
2827
import {
@@ -36,6 +35,7 @@ import { Button } from '~/ui/lib/Button'
3635
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
3736
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
3837
import { TableActions, TableEmptyBox } from '~/ui/lib/Table'
38+
import { accessTypeLabel } from '~/util/access'
3939
import { groupBy, isTruthy } from '~/util/array'
4040

4141
const EmptyState = ({ onClick }: { onClick: () => void }) => (
@@ -111,7 +111,11 @@ export function SiloAccessPage() {
111111

112112
const columns = useMemo(
113113
() => [
114-
colHelper.accessor('name', { header: 'Name', cell: AccessNameCell }),
114+
colHelper.accessor('name', { header: 'Name' }),
115+
colHelper.accessor('identityType', {
116+
header: 'Type',
117+
cell: (props) => accessTypeLabel(props.getValue()),
118+
}),
115119
colHelper.accessor('siloRole', {
116120
header: 'Silo role',
117121
cell: RoleBadgeCell,

app/pages/project/access/ProjectAccessPage.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
} from '@oxide/api'
2525
import { Access24Icon } from '@oxide/design-system/icons/react'
2626

27-
import { AccessNameCell } from '~/components/AccessNameCell'
2827
import { HL } from '~/components/HL'
2928
import { RoleBadgeCell } from '~/components/RoleBadgeCell'
3029
import {
@@ -39,6 +38,7 @@ import { Button } from '~/ui/lib/Button'
3938
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
4039
import { PageHeader, PageTitle } from '~/ui/lib/PageHeader'
4140
import { TableActions, TableEmptyBox } from '~/ui/lib/Table'
41+
import { accessTypeLabel } from '~/util/access'
4242
import { groupBy, isTruthy } from '~/util/array'
4343

4444
const EmptyState = ({ onClick }: { onClick: () => void }) => (
@@ -127,7 +127,11 @@ export function ProjectAccessPage() {
127127

128128
const columns = useMemo(
129129
() => [
130-
colHelper.accessor('name', { header: 'Name', cell: AccessNameCell }),
130+
colHelper.accessor('name', { header: 'Name' }),
131+
colHelper.accessor('identityType', {
132+
header: 'Type',
133+
cell: (props) => accessTypeLabel(props.getValue()),
134+
}),
131135
colHelper.accessor('siloRole', {
132136
header: 'Silo role',
133137
cell: RoleBadgeCell,

app/util/access.spec.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
5+
*
6+
* Copyright Oxide Computer Company
7+
*/
8+
import { expect, test } from 'vitest'
9+
10+
import { accessTypeLabel } from './access'
11+
12+
test('accessTypeLabel', () => {
13+
expect(accessTypeLabel('silo_group')).toEqual('Group')
14+
expect(accessTypeLabel('silo_user')).toEqual('User')
15+
})

app/util/access.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
5+
*
6+
* Copyright Oxide Computer Company
7+
*/
8+
import type { IdentityType } from '~/api'
9+
10+
export const accessTypeLabel = (identityType: IdentityType) =>
11+
identityType === 'silo_group' ? 'Group' : 'User'

test/e2e/project-access.e2e.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,26 @@ test('Click through project access page', async ({ page }) => {
1818
const table = page.locator('table')
1919
await expectRowVisible(table, {
2020
Name: 'Hannah Arendt',
21+
Type: 'User',
2122
'Silo role': 'admin',
2223
'Project role': '',
2324
})
2425
await expectRowVisible(table, {
2526
Name: 'Jacob Klein',
27+
Type: 'User',
2628
'Silo role': '',
2729
'Project role': 'collaborator',
2830
})
2931
await expectRowVisible(table, {
3032
// no space because expectRowVisible uses textContent, not accessible name
31-
Name: 'real-estate-devsGroup',
33+
Name: 'real-estate-devs',
34+
Type: 'Group',
3235
'Silo role': 'collaborator',
3336
})
3437
await expectRowVisible(table, {
3538
// no space because expectRowVisible uses textContent, not accessible name
36-
Name: 'kernel-devsGroup',
39+
Name: 'kernel-devs',
40+
Type: 'Group',
3741
'Silo role': '',
3842
'Project role': 'viewer',
3943
})

test/e2e/silo-access.e2e.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ test('Click through silo access page', async ({ page }) => {
2020
await expectVisible(page, ['role=heading[name*="Access & IAM"]'])
2121
await expectRowVisible(table, {
2222
// no space because expectRowVisible uses textContent, not accessible name
23-
Name: 'real-estate-devsGroup',
23+
Name: 'real-estate-devs',
24+
Type: 'Group',
2425
'Silo role': 'collaborator',
2526
})
2627
await expectRowVisible(table, {
2728
Name: 'Hannah Arendt',
29+
Type: 'User',
2830
'Silo role': 'admin',
2931
})
3032
await expectNotVisible(page, [`role=cell[name="${user4.display_name}"]`])

0 commit comments

Comments
 (0)