Skip to content
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

NickAkhmetov/HMP-503-HOTFIX Fix workspace launch form lock #3341

Merged
merged 8 commits into from
Nov 21, 2023
2 changes: 2 additions & 0 deletions CHANGELOG-workspace-launch-form-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix bug with workspace creation locking after unsuccessful submit.
- Fix errors launching workspace when another workspace is running.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function useCreateWorkspaceForm({ defaultName }: UseCreateWorkspaceTypes) {
handleSubmit,
control,
reset,
formState: { errors, isSubmitting, isSubmitted },
formState: { errors, isSubmitting, isSubmitSuccessful },
} = useForm({
defaultValues: {
'workspace-name': defaultName ?? '',
Expand All @@ -68,7 +68,7 @@ function useCreateWorkspaceForm({ defaultName }: UseCreateWorkspaceTypes) {
}

async function onSubmit({ templateKeys, uuids, workspaceName }: CreateTemplateNotebooksTypes) {
if (isSubmitting || isSubmitted) return;
if (isSubmitting || isSubmitSuccessful) return;
await createTemplateNotebooks({ templateKeys, uuids, workspaceName });
reset();
handleClose();
Expand All @@ -82,7 +82,7 @@ function useCreateWorkspaceForm({ defaultName }: UseCreateWorkspaceTypes) {
control,
errors,
onSubmit,
isSubmitting: isSubmitting || isSubmitted,
isSubmitting: isSubmitting || isSubmitSuccessful,
};
}

Expand Down
2 changes: 1 addition & 1 deletion context/app/static/js/components/workspaces/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface Workspace {
disk_space: number;
datetime_created: string;
workspace_details: WorkspaceDetails;
path: string;
}

interface WorkspaceJobDetail {
Expand Down Expand Up @@ -69,6 +68,7 @@ export interface WorkspaceJobWithDisplayStatus extends Omit<WorkspaceJob, 'statu

export interface MergedWorkspace extends Workspace {
jobs: WorkspaceJob[];
path: string;
}

interface WorkspaceAPIFailure {
Expand Down
3 changes: 2 additions & 1 deletion context/app/static/js/components/workspaces/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ async function locationIfJobRunning({
}

function getWorkspaceStartLink(workspace: Workspace, templatePath?: string) {
return `/workspaces/start/${workspace.id}?notebook_path=${encodeURIComponent(templatePath ?? workspace.path)}`;
const path = getNotebookPath(workspace);
return `/workspaces/start/${workspace.id}?notebook_path=${encodeURIComponent(templatePath ?? path)}`;
}

function getWorkspaceLink(workspace: Workspace) {
Expand Down
Loading