-
Notifications
You must be signed in to change notification settings - Fork 948
fix(site): exclude workspace schedule settings for prebuilt workspaces #18826
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 all commits
95ca5f7
207c80f
450b3e1
0bde254
73f5476
f306854
d5e45bb
0120c5b
ad475cf
02c0ff5
1260e49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { getAuthorizationKey } from "api/queries/authCheck"; | ||
import { templateByNameKey } from "api/queries/templates"; | ||
import { workspaceByOwnerAndNameKey } from "api/queries/workspaces"; | ||
import type { Workspace } from "api/typesGenerated"; | ||
import { | ||
reactRouterNestedAncestors, | ||
reactRouterParameters, | ||
} from "storybook-addon-remix-react-router"; | ||
import { | ||
MockPrebuiltWorkspace, | ||
MockTemplate, | ||
MockUserOwner, | ||
MockWorkspace, | ||
} from "testHelpers/entities"; | ||
import { withAuthProvider, withDashboardProvider } from "testHelpers/storybook"; | ||
import { WorkspaceSettingsLayout } from "../WorkspaceSettingsLayout"; | ||
import WorkspaceSchedulePage from "./WorkspaceSchedulePage"; | ||
|
||
const meta = { | ||
title: "pages/WorkspaceSchedulePage", | ||
component: WorkspaceSchedulePage, | ||
decorators: [withAuthProvider, withDashboardProvider], | ||
parameters: { | ||
layout: "fullscreen", | ||
user: MockUserOwner, | ||
}, | ||
} satisfies Meta<typeof WorkspaceSchedulePage>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof WorkspaceSchedulePage>; | ||
|
||
export const RegularWorkspace: Story = { | ||
parameters: { | ||
reactRouter: workspaceRouterParameters(MockWorkspace), | ||
queries: workspaceQueries(MockWorkspace), | ||
}, | ||
}; | ||
|
||
export const PrebuiltWorkspace: Story = { | ||
parameters: { | ||
reactRouter: workspaceRouterParameters(MockPrebuiltWorkspace), | ||
queries: workspaceQueries(MockPrebuiltWorkspace), | ||
}, | ||
}; | ||
|
||
function workspaceRouterParameters(workspace: Workspace) { | ||
return reactRouterParameters({ | ||
location: { | ||
pathParams: { | ||
username: `@${workspace.owner_name}`, | ||
workspace: workspace.name, | ||
}, | ||
}, | ||
routing: reactRouterNestedAncestors( | ||
{ | ||
path: "/:username/:workspace/settings/schedule", | ||
}, | ||
<WorkspaceSettingsLayout />, | ||
), | ||
}); | ||
} | ||
|
||
function workspaceQueries(workspace: Workspace) { | ||
return [ | ||
{ | ||
key: workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name), | ||
data: workspace, | ||
}, | ||
{ | ||
key: getAuthorizationKey({ | ||
checks: { | ||
updateWorkspace: { | ||
object: { | ||
resource_type: "workspace", | ||
resource_id: MockWorkspace.id, | ||
owner_id: MockWorkspace.owner_id, | ||
}, | ||
action: "update", | ||
}, | ||
}, | ||
}), | ||
data: { updateWorkspace: true }, | ||
}, | ||
{ | ||
key: templateByNameKey( | ||
MockWorkspace.organization_id, | ||
MockWorkspace.template_name, | ||
), | ||
data: MockTemplate, | ||
}, | ||
]; | ||
} |
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.
I'd suggest adding a story here to showcase the new behaviour.
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.
Good catch!
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.
Addressed in 73f5476