mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat: show organization name in workspaces table (#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
This commit is contained in:
@ -54,7 +54,7 @@ export const AvatarData: FC<AvatarDataProps> = ({
|
||||
css={{
|
||||
fontSize: 13,
|
||||
color: theme.palette.text.secondary,
|
||||
lineHeight: "150%",
|
||||
lineHeight: 1.5,
|
||||
maxWidth: 540,
|
||||
}}
|
||||
>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { expect, within } from "@storybook/test";
|
||||
import {
|
||||
type Workspace,
|
||||
type WorkspaceStatus,
|
||||
@ -265,3 +266,30 @@ export const InvalidPageNumber: Story = {
|
||||
page: 1000,
|
||||
},
|
||||
};
|
||||
|
||||
export const ShowOrganizations: Story = {
|
||||
args: {
|
||||
workspaces: [
|
||||
{
|
||||
...MockWorkspace,
|
||||
organization_name: "Limbus Co.",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
parameters: {
|
||||
showOrganizations: true,
|
||||
},
|
||||
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const accessibleTableCell = await canvas.findByRole("cell", {
|
||||
// Need whitespace classes because different parts of the element
|
||||
// are going in different spans, and Storybook doesn't consolidate
|
||||
// these
|
||||
name: /org\s?(?:anization)?\s?:\s?Limbus Co\./i,
|
||||
});
|
||||
|
||||
expect(accessibleTableCell).toBeDefined();
|
||||
},
|
||||
};
|
||||
|
@ -9,6 +9,7 @@ import TableCell from "@mui/material/TableCell";
|
||||
import TableContainer from "@mui/material/TableContainer";
|
||||
import TableHead from "@mui/material/TableHead";
|
||||
import TableRow from "@mui/material/TableRow";
|
||||
import { visuallyHidden } from "@mui/utils";
|
||||
import type { Template, Workspace } from "api/typesGenerated";
|
||||
import { ExternalAvatar } from "components/Avatar/Avatar";
|
||||
import { AvatarData } from "components/AvatarData/AvatarData";
|
||||
@ -20,6 +21,7 @@ import {
|
||||
TableRowSkeleton,
|
||||
} from "components/TableLoader/TableLoader";
|
||||
import { useClickableTableRow } from "hooks/useClickableTableRow";
|
||||
import { useDashboard } from "modules/dashboard/useDashboard";
|
||||
import { WorkspaceDormantBadge } from "modules/workspaces/WorkspaceDormantBadge/WorkspaceDormantBadge";
|
||||
import { WorkspaceOutdatedTooltip } from "modules/workspaces/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
|
||||
import { WorkspaceStatusBadge } from "modules/workspaces/WorkspaceStatusBadge/WorkspaceStatusBadge";
|
||||
@ -52,6 +54,7 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
|
||||
canCreateTemplate,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const dashboard = useDashboard();
|
||||
|
||||
return (
|
||||
<TableContainer>
|
||||
@ -172,7 +175,12 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
|
||||
)}
|
||||
</Stack>
|
||||
}
|
||||
subtitle={workspace.owner_name}
|
||||
subtitle={
|
||||
<div>
|
||||
<span css={{ ...visuallyHidden }}>User: </span>
|
||||
{workspace.owner_name}
|
||||
</div>
|
||||
}
|
||||
avatar={
|
||||
<ExternalAvatar
|
||||
src={workspace.template_icon}
|
||||
@ -189,7 +197,20 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
{getDisplayWorkspaceTemplateName(workspace)}
|
||||
<div>{getDisplayWorkspaceTemplateName(workspace)}</div>
|
||||
|
||||
{dashboard.showOrganizations && (
|
||||
<div
|
||||
css={{
|
||||
fontSize: 13,
|
||||
color: theme.palette.text.secondary,
|
||||
lineHeight: 1.5,
|
||||
}}
|
||||
>
|
||||
<span css={{ ...visuallyHidden }}>Organization: </span>
|
||||
{workspace.organization_name}
|
||||
</div>
|
||||
)}
|
||||
</TableCell>
|
||||
|
||||
<TableCell>
|
||||
|
Reference in New Issue
Block a user