Files
spacedrive/interface/app/$libraryId/Explorer/FilePath/EraseDialog.tsx
T
9c0aec8167 [ENG-300] Explorer multi-select (#1197)
* grid

* Improved multi-select, grid list & view offset. Added gap option & app frame.

* List view multi-select

* Include multi-select in overview, fix page ref type

* Add gap to options panel

* Fix drag

* Update categories z-index

* going pretty well

* fix a couple bugs

* fix another bug :)

* minor improvements

* Separate grid activeItem

* extra comments

* um akshully don't ref during render

* show thumbnails yay

* cleanup

* Clean up

* Fix ranges

* here it is

* fix cols drag

* don't enforce selecto context

* explorer view selectable

* Update index.tsx

* Context menu support for multi-select (#1187)

* here it is

* stopPropagation

* cut copy multiple

---------

Co-authored-by: nikec <nikec.job@gmail.com>

* explorer view selectable

* Update index.tsx

* items Map

* fix renamable

* Update inspector

* Hide tag assign if empty

* fix merge

* cleanup

* fix un-rendered drag select

* fix double click quick preview

* update thumbnail

* mostly handle multiple select in keybindings

* fix ts

* remove another todo

* move useItemAs hooks to @sd/client

* fix thumb controls

* multi-select double click

* cleaner?

* smaller gap

---------

Co-authored-by: Jamie Pine <ijamespine@me.com>
Co-authored-by: Brendan Allan <brendonovich@outlook.com>
Co-authored-by: Jamie Pine <32987599+jamiepine@users.noreply.github.com>
Co-authored-by: Utku <74243531+utkubakir@users.noreply.github.com>
Co-authored-by: Ericson "Fogo" Soares <ericson.ds999@gmail.com>
2023-08-15 08:23:41 +00:00

68 lines
1.6 KiB
TypeScript

import { useState } from 'react';
import { FilePath, useLibraryMutation } from '@sd/client';
import { Dialog, Slider, UseDialogProps, useDialog } from '@sd/ui';
import { useZodForm, z } from '@sd/ui/src/forms';
interface Props extends UseDialogProps {
locationId: number;
filePaths: FilePath[];
}
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={form.handleSubmit((data) =>
eraseFile.mutateAsync({
location_id: props.locationId,
file_path_ids: props.filePaths.map((p) => p.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>
);
};