mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-20 14:38:58 -04:00
* support for late key manager setup and remove password from onboarding * mobile * delete master-password.tsx * remove secure temp keystore * remove more km_config artifacts * fix builds * Fix most of the UI, there still some minor bugs * Workaround portalled closing Popovers * Restore search in core/src/api/mod.rs * Fix Password eye icon closing Popover on click * Fix keymanager setup submit button spinner not centered - Fix keymanager setup missing logic for disabling form - Adjust keymanager tab roundness to match app style * Restore .gitignore * Restore .prettierignore * fixerino tests --------- Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com> Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com>
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { useQueryClient } from '@tanstack/react-query';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { LibraryConfigWrapped, useBridgeMutation, usePlausibleEvent } from '@sd/client';
|
|
import { Dialog, UseDialogProps, forms, useDialog } from '@sd/ui';
|
|
|
|
const { Input, z, useZodForm } = forms;
|
|
|
|
const schema = z.object({
|
|
name: z.string().min(1)
|
|
});
|
|
export default (props: UseDialogProps) => {
|
|
const dialog = useDialog(props);
|
|
const navigate = useNavigate();
|
|
const queryClient = useQueryClient();
|
|
const submitPlausibleEvent = usePlausibleEvent();
|
|
|
|
const createLibrary = useBridgeMutation('library.create', {
|
|
onSuccess: (library) => {
|
|
queryClient.setQueryData(
|
|
['library.list'],
|
|
(libraries: LibraryConfigWrapped[] | undefined) => [...(libraries || []), library]
|
|
);
|
|
|
|
submitPlausibleEvent({
|
|
event: {
|
|
type: 'libraryCreate'
|
|
}
|
|
});
|
|
|
|
navigate(`/${library.uuid}/overview`);
|
|
},
|
|
onError: (err) => console.log(err)
|
|
});
|
|
|
|
const form = useZodForm({
|
|
schema: schema
|
|
});
|
|
|
|
const onSubmit = form.handleSubmit(async (data) => {
|
|
await createLibrary.mutateAsync({
|
|
name: data.name
|
|
});
|
|
});
|
|
|
|
return (
|
|
<Dialog
|
|
form={form}
|
|
onSubmit={onSubmit}
|
|
dialog={dialog}
|
|
submitDisabled={!form.formState.isValid}
|
|
title="Create New Library"
|
|
description="Libraries are a secure, on-device database. Your files remain where they are, the Library catalogs them and stores all Spacedrive related data."
|
|
ctaLabel={form.formState.isSubmitting ? 'Creating library...' : 'Create library'}
|
|
>
|
|
<div className="mt-5 space-y-4">
|
|
<Input
|
|
{...form.register('name')}
|
|
label="Library name"
|
|
placeholder={'e.g. "James\' Library"'}
|
|
size="md"
|
|
/>
|
|
</div>
|
|
</Dialog>
|
|
);
|
|
};
|