chore: pr feedbacks
This commit is contained in:
parent
5c67f2e665
commit
507e9a58de
3 changed files with 8 additions and 15 deletions
|
|
@ -42,7 +42,6 @@ export function RestoreForm({ repository, snapshotId, returnPath, basePath }: Re
|
||||||
|
|
||||||
const volumeBasePath = basePath ?? "/";
|
const volumeBasePath = basePath ?? "/";
|
||||||
|
|
||||||
const [waitingForDownload, setWaitingForDownload] = useState(false);
|
|
||||||
const [restoreLocation, setRestoreLocation] = useState<RestoreLocation>("original");
|
const [restoreLocation, setRestoreLocation] = useState<RestoreLocation>("original");
|
||||||
const [customTargetPath, setCustomTargetPath] = useState("");
|
const [customTargetPath, setCustomTargetPath] = useState("");
|
||||||
const [overwriteMode, setOverwriteMode] = useState<OverwriteMode>("always");
|
const [overwriteMode, setOverwriteMode] = useState<OverwriteMode>("always");
|
||||||
|
|
@ -151,8 +150,6 @@ export function RestoreForm({ repository, snapshotId, returnPath, basePath }: Re
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleDownload = useCallback(() => {
|
const handleDownload = useCallback(() => {
|
||||||
setWaitingForDownload(true);
|
|
||||||
|
|
||||||
if (selectedPaths.size > 1) {
|
if (selectedPaths.size > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +174,6 @@ export function RestoreForm({ repository, snapshotId, returnPath, basePath }: Re
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
setWaitingForDownload(false);
|
|
||||||
}, [repository.shortId, snapshotId, selectedPathKind, selectedPaths]);
|
}, [repository.shortId, snapshotId, selectedPathKind, selectedPaths]);
|
||||||
|
|
||||||
const acknowledgeRestoreResult = useCallback(() => {
|
const acknowledgeRestoreResult = useCallback(() => {
|
||||||
|
|
@ -228,7 +224,7 @@ export function RestoreForm({ repository, snapshotId, returnPath, basePath }: Re
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<span className="inline-flex">
|
<span className="inline-flex">
|
||||||
<Button variant="outline" onClick={handleDownload} disabled={!canDownload} loading={waitingForDownload}>
|
<Button variant="outline" onClick={handleDownload} disabled={!canDownload}>
|
||||||
<Download className="h-4 w-4 mr-2" />
|
<Download className="h-4 w-4 mr-2" />
|
||||||
{getDownloadButtonText()}
|
{getDownloadButtonText()}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -563,15 +563,7 @@ const normalizeDumpPath = (pathToDump?: string): string => {
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
const decodedPath = (() => {
|
return normalizeAbsolutePath(trimmedPath);
|
||||||
try {
|
|
||||||
return decodeURIComponent(trimmedPath);
|
|
||||||
} catch {
|
|
||||||
return trimmedPath;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
return normalizeAbsolutePath(decodedPath);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const dump = async (
|
const dump = async (
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@ export const normalizeAbsolutePath = (value?: string): string => {
|
||||||
const trimmed = value?.trim();
|
const trimmed = value?.trim();
|
||||||
if (!trimmed) return "/";
|
if (!trimmed) return "/";
|
||||||
|
|
||||||
const normalizedInput = decodeURIComponent(trimmed).replace(/\\+/g, "/");
|
let normalizedInput: string;
|
||||||
|
try {
|
||||||
|
normalizedInput = decodeURIComponent(trimmed).replace(/\\+/g, "/");
|
||||||
|
} catch {
|
||||||
|
normalizedInput = trimmed.replace(/\\+/g, "/");
|
||||||
|
}
|
||||||
const withLeadingSlash = normalizedInput.startsWith("/") ? normalizedInput : `/${normalizedInput}`;
|
const withLeadingSlash = normalizedInput.startsWith("/") ? normalizedInput : `/${normalizedInput}`;
|
||||||
|
|
||||||
const parts = withLeadingSlash.split("/");
|
const parts = withLeadingSlash.split("/");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue