Fix workspace codebase form not allowing empty saves and not auto-updating
- Allow saving empty values to clear repo URL or local folder from an existing workspace - submitLocalWorkspace/submitRepoWorkspace now handle empty input as a "clear" operation - Save button is only disabled for empty input when there's no existing workspace to clear - removeWorkspace.onSuccess now resets form state (matching create/update handlers) Co-Authored-By: Paperclip <noreply@paperclip.ing> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -223,7 +223,13 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
|
|||||||
|
|
||||||
const removeWorkspace = useMutation({
|
const removeWorkspace = useMutation({
|
||||||
mutationFn: (workspaceId: string) => projectsApi.removeWorkspace(project.id, workspaceId),
|
mutationFn: (workspaceId: string) => projectsApi.removeWorkspace(project.id, workspaceId),
|
||||||
onSuccess: invalidateProject,
|
onSuccess: () => {
|
||||||
|
setWorkspaceCwd("");
|
||||||
|
setWorkspaceRepoUrl("");
|
||||||
|
setWorkspaceMode(null);
|
||||||
|
setWorkspaceError(null);
|
||||||
|
invalidateProject();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const updateWorkspace = useMutation({
|
const updateWorkspace = useMutation({
|
||||||
mutationFn: ({ workspaceId, data }: { workspaceId: string; data: Record<string, unknown> }) =>
|
mutationFn: ({ workspaceId, data }: { workspaceId: string; data: Record<string, unknown> }) =>
|
||||||
@@ -322,6 +328,11 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
|
|||||||
|
|
||||||
const submitLocalWorkspace = () => {
|
const submitLocalWorkspace = () => {
|
||||||
const cwd = workspaceCwd.trim();
|
const cwd = workspaceCwd.trim();
|
||||||
|
if (!cwd) {
|
||||||
|
setWorkspaceError(null);
|
||||||
|
persistCodebase({ cwd: null });
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isAbsolutePath(cwd)) {
|
if (!isAbsolutePath(cwd)) {
|
||||||
setWorkspaceError("Local folder must be a full absolute path.");
|
setWorkspaceError("Local folder must be a full absolute path.");
|
||||||
return;
|
return;
|
||||||
@@ -332,6 +343,11 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
|
|||||||
|
|
||||||
const submitRepoWorkspace = () => {
|
const submitRepoWorkspace = () => {
|
||||||
const repoUrl = workspaceRepoUrl.trim();
|
const repoUrl = workspaceRepoUrl.trim();
|
||||||
|
if (!repoUrl) {
|
||||||
|
setWorkspaceError(null);
|
||||||
|
persistCodebase({ repoUrl: null });
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isGitHubRepoUrl(repoUrl)) {
|
if (!isGitHubRepoUrl(repoUrl)) {
|
||||||
setWorkspaceError("Repo must use a valid GitHub repo URL.");
|
setWorkspaceError("Repo must use a valid GitHub repo URL.");
|
||||||
return;
|
return;
|
||||||
@@ -678,7 +694,7 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
size="xs"
|
size="xs"
|
||||||
className="h-6 px-2"
|
className="h-6 px-2"
|
||||||
disabled={!workspaceCwd.trim() || createWorkspace.isPending || updateWorkspace.isPending}
|
disabled={(!workspaceCwd.trim() && !primaryCodebaseWorkspace) || createWorkspace.isPending || updateWorkspace.isPending}
|
||||||
onClick={submitLocalWorkspace}
|
onClick={submitLocalWorkspace}
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
@@ -711,7 +727,7 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
size="xs"
|
size="xs"
|
||||||
className="h-6 px-2"
|
className="h-6 px-2"
|
||||||
disabled={!workspaceRepoUrl.trim() || createWorkspace.isPending || updateWorkspace.isPending}
|
disabled={(!workspaceRepoUrl.trim() && !primaryCodebaseWorkspace) || createWorkspace.isPending || updateWorkspace.isPending}
|
||||||
onClick={submitRepoWorkspace}
|
onClick={submitRepoWorkspace}
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
|
|||||||
Reference in New Issue
Block a user