mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 23:18:06 -04:00
* tabs w/ multiple router instances * fix router switching * keybinds * manual history tracking * eslint * remove scroll restoration * fix tab removal * route title + tab create delay * typescript * put tab list up top * Remove import + show close button only if tabs length more than 1 * lint * unify blur across whole top bar * add to keybindings page, tauri drag region, and tooltip * fix blur * more drag regions * merge moment --------- Co-authored-by: ameer2468 <33054370+ameer2468@users.noreply.github.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { useBridgeQuery, useLibraryQuery } from '@sd/client';
|
|
import { NodeIdParamsSchema } from '~/app/route-schemas';
|
|
import { Icon } from '~/components';
|
|
import { useRouteTitle, useZodRouteParams } from '~/hooks';
|
|
|
|
import Explorer from '../Explorer';
|
|
import { ExplorerContextProvider } from '../Explorer/Context';
|
|
import { createDefaultExplorerSettings } from '../Explorer/store';
|
|
import { DefaultTopBarOptions } from '../Explorer/TopBarOptions';
|
|
import { useExplorer, useExplorerSettings } from '../Explorer/useExplorer';
|
|
import { TopBarPortal } from '../TopBar/Portal';
|
|
|
|
export const Component = () => {
|
|
const { id: nodeId } = useZodRouteParams(NodeIdParamsSchema);
|
|
|
|
const query = useLibraryQuery(['nodes.listLocations', nodeId]);
|
|
|
|
const nodeState = useBridgeQuery(['nodeState']);
|
|
|
|
const title = useRouteTitle(nodeState.data?.name || 'Node');
|
|
|
|
const explorerSettings = useExplorerSettings({
|
|
settings: useMemo(
|
|
() =>
|
|
createDefaultExplorerSettings<never>({
|
|
order: null
|
|
}),
|
|
[]
|
|
)
|
|
});
|
|
|
|
const explorer = useExplorer({
|
|
items: query.data || null,
|
|
parent: nodeState.data
|
|
? {
|
|
type: 'Node',
|
|
node: nodeState.data
|
|
}
|
|
: undefined,
|
|
settings: explorerSettings,
|
|
showPathBar: false,
|
|
layouts: { media: false }
|
|
});
|
|
|
|
return (
|
|
<ExplorerContextProvider explorer={explorer}>
|
|
<TopBarPortal
|
|
left={
|
|
<div className="flex items-center gap-2">
|
|
<Icon name="Laptop" size={24} className="mt-[-1px]" />
|
|
<span className="truncate text-sm font-medium">{title}</span>
|
|
</div>
|
|
}
|
|
right={<DefaultTopBarOptions />}
|
|
/>
|
|
|
|
<Explorer />
|
|
</ExplorerContextProvider>
|
|
);
|
|
};
|