mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-19 21:18:20 +02:00
feat(projets): client API + store re-racinés par projet
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
0291831479
commit
5e7461096b
5 files changed
+134
-32
No files matched your search
@@ -61,7 +61,7 @@ export function FilesView() {
|
||||
}
|
||||
|
||||
function WorkspaceTree({ nodes, depth }: { nodes: FileNode[]; depth: number }) {
|
||||
const { openPreview, previewPath, removeFile } = useStore();
|
||||
const { openPreview, previewPath, removeFile, currentProject } = useStore();
|
||||
const confirmDelete = (node: FileNode) => {
|
||||
const msg =
|
||||
node.type === "dir"
|
||||
@@ -93,7 +93,7 @@ function WorkspaceTree({ nodes, depth }: { nodes: FileNode[]; depth: number }) {
|
||||
</button>
|
||||
{node.type === "file" && (
|
||||
<button
|
||||
onClick={() => downloadFile(node.path)}
|
||||
onClick={() => downloadFile(node.path, currentProject())}
|
||||
className="flex items-center gap-1 border-2 border-line bg-base px-2 py-1 text-[11px] text-accent"
|
||||
title={`Télécharger ${node.name}`}
|
||||
>
|
||||
|
||||
@@ -117,7 +117,7 @@ export function LeftPanel() {
|
||||
}
|
||||
|
||||
function FileTree({ nodes, depth }: { nodes: FileNode[]; depth: number }) {
|
||||
const { openPreview, previewPath, removeFile } = useStore();
|
||||
const { openPreview, previewPath, removeFile, currentProject } = useStore();
|
||||
const confirmDelete = (n: FileNode) => {
|
||||
const msg =
|
||||
n.type === "dir"
|
||||
@@ -156,7 +156,7 @@ function FileTree({ nodes, depth }: { nodes: FileNode[]; depth: number }) {
|
||||
<button
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
downloadFile(n.path);
|
||||
downloadFile(n.path, currentProject());
|
||||
}}
|
||||
className="hidden flex-none text-muted-2 hover:text-accent group-hover:block"
|
||||
title={`Télécharger ${n.name}`}
|
||||
|
||||
@@ -98,7 +98,7 @@ export function PreviewPanel() {
|
||||
{previewPath && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => downloadFile(previewPath)}
|
||||
onClick={() => downloadFile(previewPath, useStore.getState().currentProject())}
|
||||
className="flex h-8 items-center gap-1.5 border-[3px] border-line bg-card px-2.5 text-[12px] text-accent"
|
||||
title={`Télécharger ${previewPath}`}
|
||||
>
|
||||
@@ -202,21 +202,24 @@ export function PreviewPanel() {
|
||||
/** Onglet Git : historique des commits, diff colorisé, retour arrière. */
|
||||
function GitPanel() {
|
||||
const refreshFiles = useStore((s) => s.refreshFiles);
|
||||
const currentProject = useStore((s) => s.currentProject);
|
||||
const project = currentProject();
|
||||
const [commits, setCommits] = useState<GitCommit[]>([]);
|
||||
const [selected, setSelected] = useState<string | null>(null);
|
||||
const [diff, setDiff] = useState("");
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const load = () => getGitLog().then(setCommits).catch(() => {});
|
||||
const load = () => getGitLog(project).then(setCommits).catch(() => {});
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, []);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [project]);
|
||||
|
||||
const openDiff = async (hash: string) => {
|
||||
setSelected(hash);
|
||||
setDiff("Chargement…");
|
||||
setDiff((await getGitDiff(hash)) || "(diff vide)");
|
||||
setDiff((await getGitDiff(hash, project)) || "(diff vide)");
|
||||
};
|
||||
|
||||
const doRevert = async (hash: string) => {
|
||||
@@ -225,7 +228,7 @@ function GitPanel() {
|
||||
setBusy(hash);
|
||||
setError(null);
|
||||
try {
|
||||
await revertCommit(hash);
|
||||
await revertCommit(hash, project);
|
||||
await load();
|
||||
await refreshFiles();
|
||||
if (selected === hash) setSelected(null);
|
||||
|
||||
Reference in new issue
Block a user