mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 06:59:17 -04:00
* added base UI for categories on overview * update core * cleanup ui * Inspector default view if nothing is selected, explorer takes child components, hidden menu tweak if no items are sm:flex * wip * somewhat functional * scroll * category fixes * clean category bar * added config store + made toolbar available on all explorer screens * clean up overview.tsx * added counts * fix inspector bug * add support for favorites + add book extension support * refactor into smaller components * Some small rust nitpicks * fix camel case location_type * Rust fmt * fix typescript CI --------- Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com> Co-authored-by: nikec <nikec.job@gmail.com> Co-authored-by: Ericson Soares <ericson.ds999@gmail.com>
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { useMemo, useRef } from 'react';
|
|
import { useLibraryQuery } from '@sd/client';
|
|
import { Button, SelectOption } from '@sd/ui';
|
|
import { DummyKey, Key } from './Key';
|
|
|
|
// ideal for going within a select box
|
|
// can use mounted or unmounted keys, just provide different inputs
|
|
export const KeyListSelectOptions = (props: { keys: string[] }) => (
|
|
<>
|
|
{props.keys.map((key) => (
|
|
<SelectOption key={key} value={key}>
|
|
Key {key.substring(0, 8).toUpperCase()}
|
|
</SelectOption>
|
|
))}
|
|
</>
|
|
);
|
|
|
|
export default () => {
|
|
const keys = useLibraryQuery(['keys.list']);
|
|
const mountedUuids = useLibraryQuery(['keys.listMounted']);
|
|
const defaultKey = useLibraryQuery(['keys.getDefault']);
|
|
|
|
const mountingQueue = useRef(new Set<string>());
|
|
|
|
const [mountedKeys, unmountedKeys] = useMemo(
|
|
() => [
|
|
keys.data?.filter((key) => mountedUuids.data?.includes(key.uuid)) ?? [],
|
|
keys.data?.filter((key) => !mountedUuids.data?.includes(key.uuid)) ?? []
|
|
],
|
|
[keys, mountedUuids]
|
|
);
|
|
|
|
if (keys.data?.length === 0) {
|
|
return (
|
|
<Button variant="dotted" className="w-full">
|
|
Mount a new key
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{[...mountedKeys, ...unmountedKeys]?.map((key) => (
|
|
<Key
|
|
key={key.uuid}
|
|
data={{
|
|
id: key.uuid,
|
|
name: `Key ${key.uuid.substring(0, 8).toUpperCase()}`,
|
|
queue: mountingQueue.current,
|
|
mounted: mountedKeys.includes(key),
|
|
default: defaultKey.data === key.uuid,
|
|
memoryOnly: key.memory_only,
|
|
automount: key.automount
|
|
// key stats need including here at some point
|
|
}}
|
|
/>
|
|
))}
|
|
</>
|
|
);
|
|
};
|