fix: allow workspace creation from workspaces page

- Replace awkward first-workspace-guessing logic with inline project/repo selector
- New WorkspaceCreateInline component with cascading dropdowns:
  - Select project → loads repositories for that project
  - Select repository → enter workspace name + branch
  - Submit creates workspace via top-level POST /workspaces/
- Add createWorkspaceTopLevel() API client for flat endpoint
- Works even with zero existing workspaces (shows create button in empty state)
- Add CSS grid layout for inline create form
- TypeScript + eslint clean
This commit is contained in:
2026-06-01 17:32:35 +02:00
parent 88a973dc68
commit ab1843b1c3
12 changed files with 870 additions and 561 deletions
+25 -22
View File
@@ -2,50 +2,53 @@ import { apiClient } from "./client";
import type { Project, ProjectWithRepos } from "../types";
export type ProjectCreateInput = {
name: string;
description?: string | null;
name: string;
description?: string | null;
};
export type ProjectUpdateInput = {
name?: string | null;
description?: string | null;
name?: string | null;
description?: string | null;
};
export type SetDefaultSSHKeyInput = {
ssh_key_id: string;
ssh_key_id: string;
};
export const listProjects = async (): Promise<ProjectWithRepos[]> => {
const response = await apiClient.get<ProjectWithRepos[]>("/projects");
return response.data;
const response = await apiClient.get<ProjectWithRepos[]>("/projects");
return response.data;
};
export const createProject = async (
input: ProjectCreateInput
input: ProjectCreateInput,
): Promise<Project> => {
const response = await apiClient.post<Project>("/projects", input);
return response.data;
const response = await apiClient.post<Project>("/projects", input);
return response.data;
};
export const updateProject = async (
projectId: string,
input: ProjectUpdateInput
projectId: string,
input: ProjectUpdateInput,
): Promise<Project> => {
const response = await apiClient.patch<Project>(`/projects/${projectId}`, input);
return response.data;
const response = await apiClient.patch<Project>(
`/projects/${projectId}`,
input,
);
return response.data;
};
export const deleteProject = async (projectId: string): Promise<void> => {
await apiClient.delete(`/projects/${projectId}`);
await apiClient.delete(`/projects/${projectId}`);
};
export const setDefaultSSHKey = async (
projectId: string,
input: SetDefaultSSHKeyInput
projectId: string,
input: SetDefaultSSHKeyInput,
): Promise<Project> => {
const response = await apiClient.patch<Project>(
`/projects/${projectId}/default-ssh-key`,
input
);
return response.data;
const response = await apiClient.patch<Project>(
`/projects/${projectId}/default-ssh-key`,
input,
);
return response.data;
};
+7
View File
@@ -39,6 +39,13 @@ export async function createWorkspace(
return response.data;
}
export async function createWorkspaceTopLevel(
data: CreateWorkspaceRequest & { repo_id: string },
): Promise<Workspace> {
const response = await apiClient.post<Workspace>("/workspaces/", data);
return response.data;
}
export async function getWorkspace(
projectId: string,
repoId: string,