mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 06:59:17 -04:00
* WIP * Some minor fixes for light theme - Fix `useIsDark` not reading the initial theme value (only reacting to theme changes) - Fix `Inspector` always showing a dark image when no item was selected - Fix `Thumb` video extension using black text on light theme * Improve form error messages - Fix `addLocationDialog` not registering the path input - Remove `@hookform/error-message` * Fix Dialog not respecting max-width - Fix ErrorMessage animation jumping * A lot of misc fixes - Implement an `useExplorerItemData` (cleaner fix for thumbnail flicker) - Fix broken image showing for `Thumb` due a rece condition when props are updated - Implement an `ExternalObject` component that hacks an alternative for `onLoad` and `onError` events for <object> - Fix `Overview` broken layout when `Inspector` is open and window is small - Improve `IndexerRuleEditor` UX in `AddLocationDialog` - Improve the way `IndexerRuleEditor` handles rules deletion - Fix `IndexerRuleEditor` closing the the new rule form even when the rule creation fails - Add an editable prop to `IndexerRuleEditor` to disable all editable functions - Fix `getIcon` fallbacking to Document instead of the dark version of an icon if it exists - Add some missing colors to white theme * Format * Fix Backup restore key dialog not resetting after error * Feedback * Format * Normalize imports * Fix ColorPicker export * Fix Thumb video ext not showing in MediaView with show square thumbnails - Fix AddLocationDialog Error resetting when changing IndexRules
68 lines
1.5 KiB
TypeScript
68 lines
1.5 KiB
TypeScript
import { useState } from 'react';
|
|
import { useLibraryMutation } from '@sd/client';
|
|
import { Dialog, Slider, UseDialogProps, useDialog } from '@sd/ui';
|
|
import { useZodForm, z } from '@sd/ui/src/forms';
|
|
|
|
interface Props extends UseDialogProps {
|
|
location_id: number;
|
|
path_id: number;
|
|
}
|
|
|
|
const schema = z.object({
|
|
passes: z.number()
|
|
});
|
|
|
|
export default (props: Props) => {
|
|
const eraseFile = useLibraryMutation('files.eraseFiles');
|
|
|
|
const form = useZodForm({
|
|
schema,
|
|
defaultValues: {
|
|
passes: 4
|
|
}
|
|
});
|
|
|
|
const [passes, setPasses] = useState([4]);
|
|
|
|
return (
|
|
<Dialog
|
|
form={form}
|
|
onSubmit={(data) =>
|
|
eraseFile.mutateAsync({
|
|
location_id: props.location_id,
|
|
path_id: props.path_id,
|
|
passes: data.passes.toString()
|
|
})
|
|
}
|
|
dialog={useDialog(props)}
|
|
title="Erase a file"
|
|
description="Configure your erasure settings."
|
|
loading={eraseFile.isLoading}
|
|
ctaLabel="Erase"
|
|
>
|
|
<div className="mt-2 flex flex-col">
|
|
<span className="text-xs font-bold"># of passes</span>
|
|
|
|
<div className="flex flex-row space-x-2">
|
|
<div className="relative mt-2 flex grow">
|
|
<Slider
|
|
value={passes}
|
|
max={16}
|
|
min={1}
|
|
step={1}
|
|
defaultValue={[4]}
|
|
onValueChange={(val) => {
|
|
setPasses(val);
|
|
form.setValue('passes', val[0] ?? 1);
|
|
}}
|
|
/>
|
|
</div>
|
|
<span className="mt-2.5 text-sm font-medium">{passes}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<p>TODO: checkbox for "erase all matching files" (only if a file is selected)</p>
|
|
</Dialog>
|
|
);
|
|
};
|