From 2bef1021e3278f1998ab18511ddda31162410f34 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 9 Sep 2024 14:40:14 +0000 Subject: [PATCH 1/3] fix: prefer organization display name for workspaces table --- site/src/pages/WorkspacesPage/WorkspacesTable.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx index 8998d0d6ac314..cff9873274a55 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx @@ -115,6 +115,10 @@ export const WorkspacesTable: FC = ({ const checked = checkedWorkspaces.some( (w) => w.id === workspace.id, ); + const activeOrg = dashboard.organizations.find( + (o) => o.id === workspace.organization_id, + ); + return ( = ({ }} > Organization: - {workspace.organization_name} + {activeOrg?.display_name || workspace.organization_name} )} From 4cdef42d19e7da2f7d8ec7e20ce4d1d77b18adc6 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 9 Sep 2024 15:20:02 +0000 Subject: [PATCH 2/3] fix: update story to account for organization name changes --- site/src/@types/storybook.d.ts | 2 ++ .../WorkspacesPageView.stories.tsx | 23 +++++++++++-------- site/src/testHelpers/storybook.tsx | 5 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/site/src/@types/storybook.d.ts b/site/src/@types/storybook.d.ts index 4d5aefb75a29c..bd59ec1a93c6b 100644 --- a/site/src/@types/storybook.d.ts +++ b/site/src/@types/storybook.d.ts @@ -3,6 +3,7 @@ import type { DeploymentValues, Experiments, FeatureName, + Organization, SerpentOption, User, } from "api/typesGenerated"; @@ -17,6 +18,7 @@ declare module "@storybook/react" { features?: FeatureName[]; experiments?: Experiments; showOrganizations?: boolean; + organizations?: Organization[]; queries?: { key: QueryKey; data: unknown }[]; webSocket?: WebSocketEvent[]; user?: User; diff --git a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx index 503c76b24d0e1..c38a1bc0756fa 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx @@ -15,6 +15,7 @@ import uniqueId from "lodash/uniqueId"; import type { ComponentProps } from "react"; import { MockBuildInfo, + MockOrganization, MockPendingProvisionerJob, MockTemplate, MockUser, @@ -269,25 +270,27 @@ export const InvalidPageNumber: Story = { export const ShowOrganizations: Story = { args: { - workspaces: [ - { - ...MockWorkspace, - organization_name: "Limbus Co.", - }, - ], + workspaces: [{ ...MockWorkspace, organization_name: "limbus-co" }], }, parameters: { showOrganizations: true, + organizations: [ + { + ...MockOrganization, + name: "limbus-co", + display_name: "Limbus Company, LLC", + }, + ], }, 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, + // The organization label is always visually hidden, but the test + // makes sure that there's a screen reader hook to give the table + // cell more structured output + name: /organization: Limbus Co\., LLC/i, }); expect(accessibleTableCell).toBeDefined(); diff --git a/site/src/testHelpers/storybook.tsx b/site/src/testHelpers/storybook.tsx index 1789d096629a8..9550af025e6f7 100644 --- a/site/src/testHelpers/storybook.tsx +++ b/site/src/testHelpers/storybook.tsx @@ -24,6 +24,7 @@ export const withDashboardProvider = ( features = [], experiments = [], showOrganizations = false, + organizations = [MockDefaultOrganization], } = parameters; const entitlements: Entitlements = { @@ -44,9 +45,9 @@ export const withDashboardProvider = ( value={{ entitlements, experiments, - appearance: MockAppearanceConfig, - organizations: [MockDefaultOrganization], + organizations, showOrganizations, + appearance: MockAppearanceConfig, }} > From a9ff9a038efb6329820d5041edf64400584ed0db Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 9 Sep 2024 15:25:13 +0000 Subject: [PATCH 3/3] fix: resolve typo in regex search for test --- site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx index c38a1bc0756fa..02f34d0189691 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx @@ -290,7 +290,7 @@ export const ShowOrganizations: Story = { // The organization label is always visually hidden, but the test // makes sure that there's a screen reader hook to give the table // cell more structured output - name: /organization: Limbus Co\., LLC/i, + name: /organization: Limbus Company, LLC/i, }); expect(accessibleTableCell).toBeDefined();