Skip to content

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

Merged
merged 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/src/components/AvatarData/AvatarData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const AvatarData: FC<AvatarDataProps> = ({
css={{
fontSize: 13,
color: theme.palette.text.secondary,
lineHeight: "150%",
lineHeight: 1.5,
Copy link
Member

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. 🙃

Copy link
Member Author

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

maxWidth: 540,
}}
>
Expand Down
28 changes: 28 additions & 0 deletions site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx
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,
Expand Down Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The 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.

};
25 changes: 23 additions & 2 deletions site/src/pages/WorkspacesPage/WorkspacesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -52,6 +54,7 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
canCreateTemplate,
}) => {
const theme = useTheme();
const dashboard = useDashboard();

return (
<TableContainer>
Expand Down Expand Up @@ -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}
Expand All @@ -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>
Expand Down
Loading