Skip to content

chore: update workspaces top bar to display org name #14596

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 17 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix: ensure that mock query cache key and component key are properly …
…synced for storybook
  • Loading branch information
Parkreiner committed Sep 13, 2024
commit 775486f31f89112756c73ee7dd9c7777c3e88bb3
2 changes: 1 addition & 1 deletion site/src/api/queries/workspaceQuota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const getWorkspaceQuotaQueryKey = (
organizationName: string,
username: string,
) => {
return [organizationName, username, "workspaceQuota"];
return ["workspaceQuota", organizationName, username];
};

export const workspaceQuota = (organizationName: string, username: string) => {
Expand Down
31 changes: 27 additions & 4 deletions site/src/pages/WorkspacePage/WorkspaceTopbar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react";
import { expect, screen, userEvent, waitFor, within } from "@storybook/test";
import { getWorkspaceQuotaQueryKey } from "api/queries/workspaceQuota";
import type { Workspace, WorkspaceQuota } from "api/typesGenerated";
import { addHours, addMinutes } from "date-fns";
import {
MockOrganization,
Expand All @@ -12,9 +13,12 @@ import {
import { withDashboardProvider } from "testHelpers/storybook";
import { WorkspaceTopbar } from "./WorkspaceTopbar";

// We want a workspace without a deadline to not pollute the screenshot
const baseWorkspace = {
// We want a workspace without a deadline to not pollute the screenshot. Also
// want to make sure that the workspace is synced to our other mock values
const baseWorkspace: Workspace = {
...MockWorkspace,
organization_name: MockOrganization.name,
organization_id: MockOrganization.id,
latest_build: {
...MockWorkspace.latest_build,
deadline: undefined,
Expand Down Expand Up @@ -263,8 +267,9 @@ export const WithFarAwayDeadlineRequiredByTemplate: Story = {
},
};

export const WithQuota: Story = {
export const WithQuotaNoOrgs: Story = {
parameters: {
showOrganizations: false,
queries: [
{
key: getWorkspaceQuotaQueryKey(
Expand All @@ -274,7 +279,25 @@ export const WithQuota: Story = {
data: {
credits_consumed: 2,
budget: 40,
},
} satisfies WorkspaceQuota,
},
],
},
};

export const WithQuotaWithOrgs: Story = {
parameters: {
showOrganizations: true,
queries: [
{
key: getWorkspaceQuotaQueryKey(
MockOrganization.name,
MockUser.username,
),
data: {
credits_consumed: 2,
budget: 40,
} satisfies WorkspaceQuota,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/WorkspacePage/WorkspaceTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const WorkspaceTopbar: FC<WorkspaceProps> = ({
(org) => org.id === workspace.organization_id,
);

const orgDisplayName = activeOrg?.display_name ?? workspace.organization_name;
const orgDisplayName = activeOrg?.display_name || workspace.organization_name;

const isImmutable =
workspace.latest_build.status === "deleted" ||
Expand Down
Loading