Skip to content

Fix: fix Workspace storybook and remove unnecessary fetching from xService #1682

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 5 commits into from
May 24, 2022
Merged
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
Next Next commit
Remove breadcrumb from workspaceXService
  • Loading branch information
presleyp committed May 23, 2022
commit abe0eb3ace4e7a61d5d2a2a1eb9ee912a3228a3b
62 changes: 0 additions & 62 deletions site/src/xServices/workspace/workspaceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ const Language = {
export interface WorkspaceContext {
workspace?: TypesGen.Workspace
template?: TypesGen.Template
organization?: TypesGen.Organization
build?: TypesGen.WorkspaceBuild
resources?: TypesGen.WorkspaceResource[]
getWorkspaceError?: Error | unknown
getTemplateError?: Error | unknown
getOrganizationError?: Error | unknown
// error creating a new WorkspaceBuild
buildError?: Error | unknown
// these are separate from getX errors because they don't make the page unusable
Expand Down Expand Up @@ -59,9 +56,6 @@ export const workspaceMachine = createMachine(
getTemplate: {
data: TypesGen.Template
}
getOrganization: {
data: TypesGen.Organization
}
startWorkspace: {
data: TypesGen.WorkspaceBuild
}
Expand Down Expand Up @@ -130,43 +124,6 @@ export const workspaceMachine = createMachine(
},
},
},
breadcrumb: {
initial: "gettingTemplate",
states: {
gettingTemplate: {
invoke: {
src: "getTemplate",
id: "getTemplate",
onDone: {
target: "gettingOrganization",
actions: ["assignTemplate", "clearGetTemplateError"],
},
onError: {
target: "error",
actions: "assignGetTemplateError",
},
},
tags: "loading",
},
gettingOrganization: {
invoke: {
src: "getOrganization",
id: "getOrganization",
onDone: {
target: "ready",
actions: ["assignOrganization", "clearGetOrganizationError"],
},
onError: {
target: "error",
actions: "assignGetOrganizationError",
},
},
tags: "loading",
},
error: {},
ready: {},
},
},
build: {
initial: "idle",
states: {
Expand Down Expand Up @@ -309,7 +266,6 @@ export const workspaceMachine = createMachine(
assign({
workspace: undefined,
template: undefined,
organization: undefined,
build: undefined,
}),
assignWorkspace: assign({
Expand All @@ -322,17 +278,6 @@ export const workspaceMachine = createMachine(
assignTemplate: assign({
template: (_, event) => event.data,
}),
assignGetTemplateError: assign({
getTemplateError: (_, event) => event.data,
}),
clearGetTemplateError: (context) => assign({ ...context, getTemplateError: undefined }),
assignOrganization: assign({
organization: (_, event) => event.data,
}),
assignGetOrganizationError: assign({
getOrganizationError: (_, event) => event.data,
}),
clearGetOrganizationError: (context) => assign({ ...context, getOrganizationError: undefined }),
assignBuild: (_, event) =>
assign({
build: event.data,
Expand Down Expand Up @@ -438,13 +383,6 @@ export const workspaceMachine = createMachine(
throw Error("Cannot get template without workspace")
}
},
getOrganization: async (context) => {
if (context.template) {
return await API.getOrganization(context.template.organization_id)
} else {
throw Error("Cannot get organization without template")
}
},
startWorkspace: async (context) => {
if (context.workspace) {
return await API.startWorkspace(context.workspace.id, context.template?.active_version_id)
Expand Down