-
Notifications
You must be signed in to change notification settings - Fork 896
feat: show organization name in workspaces table #14547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
bfdfd38
936c21e
1d5ecdb
c4a06e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}, | ||
Comment on lines
+284
to
+294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wanted to make sure that I understand the limitations around decorators: they're basically assumed to always be static values, right? There's no easy way to make a decorator re-render with a new value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. each "decorator" undergoes a small transformation to get turned into a component by storybook. there's no way to force a rerender from the outside, just like any other component. being a component tho, they can call hooks and have state, which is kind of non-obvious. |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,7 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({ | |
)} | ||
</Stack> | ||
} | ||
subtitle={workspace.owner_name} | ||
subtitle={`user:${workspace.owner_name}`} | ||
avatar={ | ||
<ExternalAvatar | ||
src={workspace.template_icon} | ||
|
@@ -189,7 +192,29 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({ | |
</TableCell> | ||
|
||
<TableCell> | ||
{getDisplayWorkspaceTemplateName(workspace)} | ||
<span css={{ display: "block" }}> | ||
{getDisplayWorkspaceTemplateName(workspace)} | ||
</span> | ||
|
||
{dashboard.showOrganizations && ( | ||
<span | ||
css={{ | ||
display: "block", | ||
fontSize: 13, | ||
color: theme.palette.text.secondary, | ||
lineHeight: 1.5, | ||
}} | ||
> | ||
{/* | ||
Only using shorthand version of "organizations" for aesthetics, | ||
but because screen readers don't care about aesthetics, we can | ||
always display the full text to them | ||
*/} | ||
org | ||
<span css={{ ...visuallyHidden }}>anization</span>: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are screen readers going to handle this split well though? my gut feeling is they say "org anization" with some awful disconnected pronounciation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried it with the built-in Mac screen reader, but (1) I think I was just assuming that any elements that are semantically inline elements wouldn't affect pronunciation, and (2) the Mac screen reader isn't even the most popular reader by a long shot Let me change this just to be on the safe side |
||
{workspace.organization_name} | ||
</span> | ||
)} | ||
</TableCell> | ||
|
||
<TableCell> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah the wonderful subtleties of css. so annoying that this actually means something different. 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSS is so silly sometimes