Skip to content

Commit c249174

Browse files
authored
feat: show organization name in workspaces table (coder#14547)
* chore: add organization label to workspace template column * chore: add test for presence of showOrganizations context value * fix: organize imports * fix: expose table row subtitles only to screen readers
1 parent c1bb5ab commit c249174

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

site/src/components/AvatarData/AvatarData.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const AvatarData: FC<AvatarDataProps> = ({
5454
css={{
5555
fontSize: 13,
5656
color: theme.palette.text.secondary,
57-
lineHeight: "150%",
57+
lineHeight: 1.5,
5858
maxWidth: 540,
5959
}}
6060
>

site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Meta, StoryObj } from "@storybook/react";
2+
import { expect, within } from "@storybook/test";
23
import {
34
type Workspace,
45
type WorkspaceStatus,
@@ -265,3 +266,30 @@ export const InvalidPageNumber: Story = {
265266
page: 1000,
266267
},
267268
};
269+
270+
export const ShowOrganizations: Story = {
271+
args: {
272+
workspaces: [
273+
{
274+
...MockWorkspace,
275+
organization_name: "Limbus Co.",
276+
},
277+
],
278+
},
279+
280+
parameters: {
281+
showOrganizations: true,
282+
},
283+
284+
play: async ({ canvasElement }) => {
285+
const canvas = within(canvasElement);
286+
const accessibleTableCell = await canvas.findByRole("cell", {
287+
// Need whitespace classes because different parts of the element
288+
// are going in different spans, and Storybook doesn't consolidate
289+
// these
290+
name: /org\s?(?:anization)?\s?:\s?Limbus Co\./i,
291+
});
292+
293+
expect(accessibleTableCell).toBeDefined();
294+
},
295+
};

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import TableCell from "@mui/material/TableCell";
99
import TableContainer from "@mui/material/TableContainer";
1010
import TableHead from "@mui/material/TableHead";
1111
import TableRow from "@mui/material/TableRow";
12+
import { visuallyHidden } from "@mui/utils";
1213
import type { Template, Workspace } from "api/typesGenerated";
1314
import { ExternalAvatar } from "components/Avatar/Avatar";
1415
import { AvatarData } from "components/AvatarData/AvatarData";
@@ -20,6 +21,7 @@ import {
2021
TableRowSkeleton,
2122
} from "components/TableLoader/TableLoader";
2223
import { useClickableTableRow } from "hooks/useClickableTableRow";
24+
import { useDashboard } from "modules/dashboard/useDashboard";
2325
import { WorkspaceDormantBadge } from "modules/workspaces/WorkspaceDormantBadge/WorkspaceDormantBadge";
2426
import { WorkspaceOutdatedTooltip } from "modules/workspaces/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
2527
import { WorkspaceStatusBadge } from "modules/workspaces/WorkspaceStatusBadge/WorkspaceStatusBadge";
@@ -52,6 +54,7 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
5254
canCreateTemplate,
5355
}) => {
5456
const theme = useTheme();
57+
const dashboard = useDashboard();
5558

5659
return (
5760
<TableContainer>
@@ -172,7 +175,12 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
172175
)}
173176
</Stack>
174177
}
175-
subtitle={workspace.owner_name}
178+
subtitle={
179+
<div>
180+
<span css={{ ...visuallyHidden }}>User: </span>
181+
{workspace.owner_name}
182+
</div>
183+
}
176184
avatar={
177185
<ExternalAvatar
178186
src={workspace.template_icon}
@@ -189,7 +197,20 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
189197
</TableCell>
190198

191199
<TableCell>
192-
{getDisplayWorkspaceTemplateName(workspace)}
200+
<div>{getDisplayWorkspaceTemplateName(workspace)}</div>
201+
202+
{dashboard.showOrganizations && (
203+
<div
204+
css={{
205+
fontSize: 13,
206+
color: theme.palette.text.secondary,
207+
lineHeight: 1.5,
208+
}}
209+
>
210+
<span css={{ ...visuallyHidden }}>Organization: </span>
211+
{workspace.organization_name}
212+
</div>
213+
)}
193214
</TableCell>
194215

195216
<TableCell>

0 commit comments

Comments
 (0)