mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-22 15:40:07 -04:00
* add generic dialog for keys settings * revert artifact failed key viewing attempt * move `Select` key list component * rename dialog * remove unused imports and add new select option for *all* keys * add WIP but broken key viewer dialog * cleanup code and fix key viewer dialog * add clipboard icon and copy functionality * generalise the `AlertDialog` and refactor `BackupRestoreDialog` to use it * use new alert dialog in place of JS/tauri alerts * use generic alerts everywhere and bring generic alert props/default state * make `SelectOptionKeyList` generic for mounted/unmounted keys (with the use of `map` for the latter) * add clipboard to generic alert dialog + clean up * fix accent colour button for backup restoration * remove unneeded props from components * add slider+automount button * tweak password gen function * add password autogeneration * clippy * tweak password generation * use `crypto-random-string` and drop rust password generation * add default TEMPORARY keymanager pass/secret key to library creation screen * make key automounting functional * clean up key viewer * change dialog name * remove slider as that wasn't even being used? * make requested changes and hide key viewer if no keys are in the key manager * prevent automount and library sync from being enabled simultaneously * include `memoryOnly` in key * mark keys as memoryOnly
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import { useLibraryMutation } from '@sd/client';
|
|
import { Button, Dialog } from '@sd/ui';
|
|
import { save } from '@tauri-apps/api/dialog';
|
|
import { useState } from 'react';
|
|
|
|
import { GenericAlertDialogProps } from './AlertDialog';
|
|
|
|
interface DecryptDialogProps {
|
|
open: boolean;
|
|
setOpen: (isShowing: boolean) => void;
|
|
location_id: number | null;
|
|
object_id: number | null;
|
|
setAlertDialogData: (data: GenericAlertDialogProps) => void;
|
|
}
|
|
|
|
export const DecryptFileDialog = (props: DecryptDialogProps) => {
|
|
const { location_id, object_id } = props;
|
|
const decryptFile = useLibraryMutation('files.decryptFiles');
|
|
const [outputPath, setOutputpath] = useState('');
|
|
|
|
return (
|
|
<>
|
|
<Dialog
|
|
open={props.open}
|
|
setOpen={props.setOpen}
|
|
title="Decrypt a file"
|
|
description="Leave the output file blank for the default."
|
|
loading={decryptFile.isLoading}
|
|
ctaLabel="Decrypt"
|
|
ctaAction={() => {
|
|
const output = outputPath !== '' ? outputPath : null;
|
|
props.setOpen(false);
|
|
|
|
location_id &&
|
|
object_id &&
|
|
decryptFile.mutate(
|
|
{
|
|
location_id,
|
|
object_id,
|
|
output_path: output
|
|
},
|
|
{
|
|
onSuccess: () => {
|
|
props.setAlertDialogData({
|
|
open: true,
|
|
title: 'Info',
|
|
value:
|
|
'The decryption job has started successfully. You may track the progress in the job overview panel.',
|
|
inputBox: false,
|
|
description: ''
|
|
});
|
|
},
|
|
onError: () => {
|
|
props.setAlertDialogData({
|
|
open: true,
|
|
title: 'Error',
|
|
value: 'The decryption job failed to start.',
|
|
inputBox: false,
|
|
description: ''
|
|
});
|
|
}
|
|
}
|
|
);
|
|
}}
|
|
>
|
|
<div className="grid w-full grid-cols-2 gap-4 mt-4 mb-3">
|
|
<div className="flex flex-col">
|
|
<span className="text-xs font-bold">Output file</span>
|
|
|
|
<Button
|
|
size="sm"
|
|
variant={outputPath !== '' ? 'accent' : 'gray'}
|
|
className="h-[23px] text-xs leading-3 mt-2"
|
|
type="button"
|
|
onClick={() => {
|
|
// if we allow the user to encrypt multiple files simultaneously, this should become a directory instead
|
|
// not platform-safe, probably will break on web but `platform` doesn't have a save dialog option
|
|
save()?.then((result) => {
|
|
if (result) setOutputpath(result as string);
|
|
});
|
|
}}
|
|
>
|
|
Select
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</Dialog>
|
|
</>
|
|
);
|
|
};
|