Files
spacedrive/interface/app/$libraryId/settings/library/general.tsx
Vítor Vasconcellos 0d3805339e [ENG-591] - Fix some funky behaviors (#827)
* 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
2023-05-20 03:11:10 +00:00

97 lines
2.5 KiB
TypeScript

import { useBridgeMutation, useLibraryContext } from '@sd/client';
import { Button, Input, dialogManager } from '@sd/ui';
import { useZodForm, z } from '@sd/ui/src/forms';
import { useDebouncedFormWatch } from '~/hooks';
import { Heading } from '../Layout';
import Setting from '../Setting';
import DeleteLibraryDialog from '../node/libraries/DeleteDialog';
const schema = z.object({
id: z.string(),
name: z.string().min(1),
description: z.string()
});
export const Component = () => {
const { library } = useLibraryContext();
const editLibrary = useBridgeMutation('library.edit');
const form = useZodForm({
schema,
defaultValues: { id: library!.uuid, ...library?.config }
});
useDebouncedFormWatch(form, (value) =>
editLibrary.mutate({
id: library.uuid,
name: value.name ?? null,
description: value.description ?? null
})
);
return (
<>
<Heading
title="Library Settings"
description="General settings related to the currently active library."
/>
<input type="hidden" {...form.register('id')} />
<div className="flex flex-row space-x-5 pb-3">
<div className="flex grow flex-col">
<span className="mb-1 text-sm font-medium">Name</span>
<Input
size="md"
{...form.register('name', { required: true })}
defaultValue="My Default Library"
/>
</div>
<div className="flex grow flex-col">
<span className="mb-1 text-sm font-medium">Description</span>
<Input size="md" {...form.register('description')} placeholder="" />
</div>
</div>
{/* <Setting
mini
title="Encrypt Library"
description="Enable encryption for this library, this will only encrypt the Spacedrive database, not the files themselves."
>
<div className="ml-3 flex items-center">
<Switch checked={false} />
</div>
</Setting> */}
{/* <Setting mini title="Export Library" description="Export this library to a file.">
<div className="mt-2">
<Button size="sm" variant="gray">
Export
</Button>
</div>
</Setting> */}
<Setting
mini
title="Delete Library"
description="This is permanent, your files will not be deleted, only the Spacedrive library."
>
<div className="mt-2">
<Button
size="sm"
variant="colored"
className="border-red-500 bg-red-500"
onClick={() => {
dialogManager.create((dp) => (
<DeleteLibraryDialog {...dp} libraryUuid={library.uuid} />
));
}}
>
Delete
</Button>
</div>
</Setting>
</>
);
};