mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 15:07:54 -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
58 lines
1.6 KiB
TypeScript
58 lines
1.6 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 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 });
|
|
|
|
return (
|
|
<Dialog
|
|
form={form}
|
|
onSubmit={(data) => createLibrary.mutateAsync({ name: data.name })}
|
|
dialog={useDialog(props)}
|
|
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>
|
|
);
|
|
};
|