Files
spacedrive/interface/app/$libraryId/Layout/Sidebar/LibrariesDropdown.tsx
T
27f077ea0b [ENG-1269] Search options (#1561)
* search options start

* small progress

* more

* bunch of stuff

* semi functioning filters

* cleanup setup api

* progress

* remove filters

* hooked up to query epic moment

* fix

* move db stuff to specific modules

* in/notIn for some fields

* generate ts

* big gains

* working filter options for locations, tags and kind

* working search query

* perfect fixed filters

* saved searches lol

* merge error

* saved searches via api

* better routing

* [ENG-1338] Fix fresh Spacedrive install failing to start due to attempting to query a nonexistent Library (#1649)

Fix Spacedrive failing to start due to attempting to query a nonexistent Library
 - Rename useShoudRedirect to useRedirectToNewLocations
 - Improve behaviour for the immedite redirection after adding a new location

* Show hidden files false by default (#1652)

bool

* fix remove filter in list

* tweaks

* fix nav buttons

* unify MediaData search handling

* cleanup saved search writing

* Add left top bar portals for tags and search + fixed media view on tags

* added search to filter dropdown

* render cycle improvements

* hotfix

* wip

* Refactor with Brendan, but this is a WIP and the search query no longer works

Co-authored-by: Brendan Allan <Brendonovich@users.noreply.github.com>

* progress

* fix location/$id page

* fix tags too

Co-authored-by: Brendan Allan <Brendonovich@users.noreply.github.com>

* 3rd refactor lol

epic style

* half-done with enum-ification of SearchFilterArgs

* broken fixed filters but working inNotIn filters

* search name + extension kinda working

* hidden filter

* fixed filters working??

* deferred search value

* extensions works

* filtered search items mostly working

* tweaks

* stacked approach working for non-search filters

* move to Explorer/Search

* actually use filterArgs in queries

things actually work properly now

* added new icons from Mint

* goof

* cleanup types, filters and mutation logic

* actually use search value

* remove overview from sidebar

* don't shrink LibrariesDropdown ga

* remove overview from sidebar and default to /network

---------

Co-authored-by: Brendan Allan <brendonovich@outlook.com>
Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com>
Co-authored-by: Brendan Allan <Brendonovich@users.noreply.github.com>
2023-11-17 06:58:44 +00:00

67 lines
2.1 KiB
TypeScript

import { Gear, Lock, Plus } from '@phosphor-icons/react';
import clsx from 'clsx';
import { useClientContext } from '@sd/client';
import { dialogManager, Dropdown, DropdownMenu } from '@sd/ui';
import CreateDialog from '../../settings/node/libraries/CreateDialog';
export default () => {
const { library, libraries, currentLibraryId } = useClientContext();
return (
<DropdownMenu.Root
trigger={
<Dropdown.Button
variant="gray"
className={clsx(
`w-full text-sidebar-ink`,
// these classname overrides are messy
// but they work
`!border-sidebar-line/50 !bg-sidebar-box ring-offset-sidebar active:!border-sidebar-line active:!bg-sidebar-button ui-open:!border-sidebar-line ui-open:!bg-sidebar-button`,
(library === null || libraries.isLoading) && '!text-sidebar-inkFaint'
)}
>
<span className="truncate">
{libraries.isLoading ? 'Loading...' : library ? library.config.name : ' '}
</span>
</Dropdown.Button>
}
// we override the sidebar dropdown item's hover styles
// because the dark style clashes with the sidebar
className="mt-1 shadow-none data-[side=bottom]:slide-in-from-top-2 dark:divide-menu-selected/30 dark:border-sidebar-line dark:bg-sidebar-box"
alignToTrigger
>
{libraries.data?.map((lib) => (
<DropdownMenu.Item
to={`/${lib.uuid}`}
key={lib.uuid}
selected={lib.uuid === currentLibraryId}
>
<p className="truncate">{lib.config.name}</p>
</DropdownMenu.Item>
))}
<DropdownMenu.Separator className="mx-0" />
<DropdownMenu.Item
label="New Library"
icon={Plus}
iconProps={{ weight: 'bold', size: 16 }}
onClick={() => dialogManager.create((dp) => <CreateDialog {...dp} />)}
className="font-medium"
/>
<DropdownMenu.Item
label="Manage Library"
icon={Gear}
iconProps={{ weight: 'bold', size: 16 }}
to="settings/library/general"
className="font-medium"
/>
<DropdownMenu.Item
label="Lock"
icon={Lock}
iconProps={{ weight: 'bold', size: 16 }}
onClick={() => alert('TODO: Not implemented yet!')}
className="font-medium"
/>
</DropdownMenu.Root>
);
};