mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
* feat: add custom restore target directory Adds the ability to restore snapshots to a custom directory instead of only the original path. Closes #12. Changes: - Add target parameter to restore API endpoint - Add directory picker UI in file browser restore dialog - Add target input field in snapshot restore form - Create reusable PathSelector component Note: Run `bun run gen:api-client` after merging to regenerate types. * refactor: path selector design * refactor: unify restore snapshot dialogs * refactor: restore snapshot as a page * chore: fix liniting issues * chore(create-notification): remove un-used prop --------- Co-authored-by: Deepseek1 <Deepseek1@users.noreply.github.com>
40 lines
959 B
TypeScript
40 lines
959 B
TypeScript
import { useState } from "react";
|
|
import { DirectoryBrowser } from "./directory-browser";
|
|
import { Button } from "./ui/button";
|
|
|
|
type Props = {
|
|
value: string;
|
|
onChange: (path: string) => void;
|
|
label?: string;
|
|
};
|
|
|
|
export const PathSelector = ({ value, onChange }: Props) => {
|
|
const [showBrowser, setShowBrowser] = useState(false);
|
|
|
|
if (showBrowser) {
|
|
return (
|
|
<div className="space-y-2">
|
|
<DirectoryBrowser
|
|
onSelectPath={(path) => {
|
|
onChange(path);
|
|
setShowBrowser(false);
|
|
}}
|
|
selectedPath={value}
|
|
/>
|
|
<Button type="button" variant="ghost" size="sm" onClick={() => setShowBrowser(false)}>
|
|
Cancel
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<div className="flex-1 text-sm font-mono bg-muted px-3 py-2 rounded-md border">{value}</div>
|
|
<Button type="button" variant="outline" onClick={() => setShowBrowser(true)} size="sm">
|
|
Change
|
|
</Button>
|
|
</div>
|
|
);
|
|
};
|