2026-07-09 13:54:05 +03:00
|
|
|
import React from 'react';
|
|
|
|
|
import { WorktreeSectionContent } from '@/components/sections/openchamber/WorktreeSectionContent';
|
|
|
|
|
import { ProjectActionsSection } from '@/components/sections/projects/ProjectActionsSection';
|
|
|
|
|
import { ProjectIdentityFields } from '@/components/sections/projects/ProjectIdentityFields';
|
|
|
|
|
import {
|
|
|
|
|
useProjectIdentityForm,
|
|
|
|
|
type ProjectIdentitySaveData,
|
|
|
|
|
} from '@/components/sections/projects/useProjectIdentityForm';
|
|
|
|
|
import { useProjectIdentityAutoSave } from '@/components/sections/projects/useProjectIdentityAutoSave';
|
|
|
|
|
import type { ProjectEntry } from '@/lib/api/types';
|
|
|
|
|
|
|
|
|
|
type ProjectSettingsPanelProps = {
|
|
|
|
|
project: ProjectEntry | null;
|
|
|
|
|
onIdentitySave: (data: ProjectIdentitySaveData) => void | Promise<void>;
|
2026-07-28 12:04:39 +03:00
|
|
|
/**
|
|
|
|
|
* The project-edit dialog hides the worktree section — worktrees have
|
|
|
|
|
* their own full-page surface (project menu → Manage worktrees). Settings
|
|
|
|
|
* keeps the full panel.
|
|
|
|
|
*/
|
|
|
|
|
showWorktrees?: boolean;
|
2026-07-09 13:54:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const ProjectSettingsPanel: React.FC<ProjectSettingsPanelProps> = ({
|
|
|
|
|
project,
|
|
|
|
|
onIdentitySave,
|
2026-07-28 12:04:39 +03:00
|
|
|
showWorktrees = true,
|
2026-07-09 13:54:05 +03:00
|
|
|
}) => {
|
|
|
|
|
const form = useProjectIdentityForm(project);
|
|
|
|
|
|
|
|
|
|
const projectRef = React.useMemo(() => {
|
|
|
|
|
if (!project) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return { id: project.id, path: project.path };
|
|
|
|
|
}, [project]);
|
|
|
|
|
|
|
|
|
|
const handleIdentitySave = React.useCallback(async (data: ProjectIdentitySaveData) => {
|
|
|
|
|
await onIdentitySave(data);
|
|
|
|
|
}, [onIdentitySave]);
|
|
|
|
|
|
|
|
|
|
useProjectIdentityAutoSave(form, handleIdentitySave);
|
|
|
|
|
|
|
|
|
|
if (!project || !projectRef) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-0">
|
|
|
|
|
<ProjectIdentityFields form={form} />
|
|
|
|
|
<ProjectActionsSection projectRef={projectRef} />
|
2026-07-28 12:04:39 +03:00
|
|
|
{showWorktrees ? <WorktreeSectionContent projectRef={projectRef} /> : null}
|
2026-07-09 13:54:05 +03:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|