TagSpaces is an offline, open source, document manager with tagging support
feat: added a filter for locations on the top of the location manager
Ilian Sapundshievfdfaf41c4d33
diff --git a/capacitor/ios/App/App.xcodeproj/project.pbxproj b/capacitor/ios/App/App.xcodeproj/project.pbxprojindex 263869651..a5a44081b 100644--- a/capacitor/ios/App/App.xcodeproj/project.pbxproj+++ b/capacitor/ios/App/App.xcodeproj/project.pbxproj@@ -319,7 +319,7 @@CODE_SIGN_ENTITLEMENTS = App/App.entitlements;CODE_SIGN_IDENTITY = "Apple Development";CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 10318;+ CURRENT_PROJECT_VERSION = 10328;DEVELOPMENT_TEAM = DLK22E2679;INFOPLIST_FILE = App/Info.plist;IPHONEOS_DEPLOYMENT_TARGET = 15.0;@@ -327,7 +327,7 @@"$(inherited)","@executable_path/Frameworks",);- MARKETING_VERSION = 6.13.5;+ MARKETING_VERSION = 6.13.9;OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";PRODUCT_BUNDLE_IDENTIFIER = org.tagspaces.mobileapp;PRODUCT_NAME = TagSpaces;@@ -345,7 +345,7 @@CODE_SIGN_ENTITLEMENTS = App/App.entitlements;CODE_SIGN_IDENTITY = "Apple Development";CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 10318;+ CURRENT_PROJECT_VERSION = 10328;DEVELOPMENT_TEAM = DLK22E2679;INFOPLIST_FILE = App/Info.plist;IPHONEOS_DEPLOYMENT_TARGET = 15.0;@@ -353,7 +353,7 @@"$(inherited)","@executable_path/Frameworks",);- MARKETING_VERSION = 6.13.5;+ MARKETING_VERSION = 6.13.9;PRODUCT_BUNDLE_IDENTIFIER = org.tagspaces.mobileapp;PRODUCT_NAME = TagSpaces;PROVISIONING_PROFILE_SPECIFIER = "";diff --git a/src/renderer/components/CommonIcons.tsx b/src/renderer/components/CommonIcons.tsxindex 37bdc467c..f99a1454f 100644--- a/src/renderer/components/CommonIcons.tsx+++ b/src/renderer/components/CommonIcons.tsx@@ -139,6 +139,8 @@ export { default as ArchiveIcon } from '@mui/icons-material/ArchiveOutlined';export { default as SearchIcon } from '@mui/icons-material/Search';+export { default as FilterIcon } from '@mui/icons-material/FilterListOutlined';+export { default as CloseIcon } from '@mui/icons-material/CancelOutlined';export { default as CancelIcon } from '@mui/icons-material/Cancel';diff --git a/src/renderer/components/LocationManager.tsx b/src/renderer/components/LocationManager.tsxindex aea5f5c39..34a18e460 100644--- a/src/renderer/components/LocationManager.tsx+++ b/src/renderer/components/LocationManager.tsx@@ -16,10 +16,13 @@**/+import { CloseIcon } from '-/components/CommonIcons';import LocationView from '-/components/LocationView';import TsButton from '-/components/TsButton';-import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';+import TsIconButton from '-/components/TsIconButton';+import TsTextField from '-/components/TsTextField';import { SettingsTab } from '-/components/dialogs/SettingsDialog';+import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';import { useSettingsDialogContext } from '-/components/dialogs/hooks/useSettingsDialogContext';import LocationContextMenu from '-/components/menus/LocationContextMenu';import LocationManagerMenu from '-/components/menus/LocationManagerMenu';@@ -27,7 +30,7 @@ import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { Pro } from '-/pro';import { getLocations } from '-/reducers/locations';import { TS } from '-/tagspaces.namespace';-import { Box, List, Typography } from '@mui/material';+import { Box, InputAdornment, List, Typography } from '@mui/material';import { useContext, useEffect, useRef, useState } from 'react';import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';import { useTranslation } from 'react-i18next';@@ -52,6 +55,8 @@ function LocationManager(props: Props) {const locations: TS.Location[] = useSelector(getLocations);const [wSpaceLocations, setWSpaceLocations] =useState<TS.Location[]>(locations);+ const [showFilter, setShowFilter] = useState<boolean>(false);+ const [filterQuery, setFilterQuery] = useState<string>('');const fileInputRef = useRef<HTMLInputElement>(null);const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext@@ -108,6 +113,29 @@ function LocationManager(props: Props) {return undefined;}+ function toggleFilter() {+ setShowFilter((prev) => {+ if (prev) {+ setFilterQuery('');+ }+ return !prev;+ });+ }++ const query = filterQuery.trim().toLowerCase();+ const filteredLocations =+ showFilter && query+ ? wSpaceLocations.filter((l) => {+ const wSpace = getWorkSpace(l);+ return (+ (l.name && l.name.toLowerCase().includes(query)) ||+ (wSpace?.shortName &&+ wSpace.shortName.toLowerCase().includes(query)) ||+ (wSpace?.fullName && wSpace.fullName.toLowerCase().includes(query))+ );+ })+ : wSpaceLocations;+return (<Boxsx={{@@ -133,82 +161,144 @@ function LocationManager(props: Props) {setSelectedLocation(undefined);openCreateEditLocationDialog();}}+ toggleFilter={toggleFilter}+ filterActive={showFilter}/>{locationDirectoryContextMenuAnchorEl && <LocationContextMenu />}- <List- data-tid="locationList"+ <Boxsx={{- height: 'calc(100% - ' + reduceHeightBy + 'px)',- width: '100%',- borderRadius: '5px',- paddingTop: 0,- marginTop: 0,- overflowY: 'auto',+ height: `calc(100% - ${reduceHeightBy}px)`,+ display: 'flex',+ flexDirection: 'column',}}>- {wSpaceLocations.length === 0 && (- <Box- data-tid="locationsEmptyState"+ {showFilter && (+ <TsTextField+ autoFocus+ data-tid="locationManagerFilterInputTID"+ value={filterQuery}+ updateValue={(value) => setFilterQuery(value)}+ retrieveValue={() => filterQuery}+ onChange={(event) => setFilterQuery(event.target.value)}+ placeholder={t('core:filterLocationsPlaceholder')}sx={{- padding: '16px',- textAlign: 'center',- color: 'text.secondary',+ marginBottom: '5px',+ '& .MuiInputBase-root': {+ paddingRight: '4px',+ },+ '& .MuiInputBase-input': {+ padding: '5px 8px',+ fontSize: '0.85rem',+ },}}- >- <Typography variant="body2" sx={{ marginBottom: '12px' }}>- {t('peri:noLocationsYet')}- </Typography>- <TsButton- variant="contained"- data-tid="createFirstLocationTID"- onClick={() => {- setSelectedLocation(undefined);- openCreateEditLocationDialog();+ slotProps={{+ input: {+ endAdornment: filterQuery ? (+ <InputAdornment position="end">+ <TsIconButton+ size="small"+ data-tid="locationManagerFilterClearTID"+ onClick={() => setFilterQuery('')}+ >+ <CloseIcon fontSize="small" />+ </TsIconButton>+ </InputAdornment>+ ) : undefined,+ },+ }}+ />+ )}+ <List+ data-tid="locationList"+ sx={{+ flex: 1,+ minHeight: 0,+ width: '100%',+ borderRadius: '5px',+ paddingTop: 0,+ marginTop: 0,+ overflowY: 'auto',+ }}+ >+ {wSpaceLocations.length === 0 && (+ <Box+ data-tid="locationsEmptyState"+ sx={{+ padding: '16px',+ textAlign: 'center',+ color: 'text.secondary',}}>- {t('peri:createYourFirstLocation')}- </TsButton>- </Box>- )}- <DragDropContext onDragEnd={onDragEnd}>- <Droppable droppableId="droppable">- {(provided, snapshot) => (- <div {...provided.droppableProps} ref={provided.innerRef}>- {wSpaceLocations.map((location, index) => (- <Draggable- key={location.uuid}- draggableId={location.uuid}- index={index}- >- {(prov, snap) => (- <div- ref={prov.innerRef}- {...prov.draggableProps}- {...prov.dragHandleProps}- >- <LocationView- key={location.uuid + index}- workspace={getWorkSpace(location)}- location={{- isFile: false,- lmdt: 0,- name: location.name,- path: location.path,- size: 0,- locationID: location.uuid,- children: [],- }}- />- </div>- )}- </Draggable>- ))}- {provided.placeholder}- </div>- )}- </Droppable>- </DragDropContext>- </List>+ <Typography variant="body2" sx={{ marginBottom: '12px' }}>+ {t('peri:noLocationsYet')}+ </Typography>+ <TsButton+ variant="contained"+ data-tid="createFirstLocationTID"+ onClick={() => {+ setSelectedLocation(undefined);+ openCreateEditLocationDialog();+ }}+ >+ {t('peri:createYourFirstLocation')}+ </TsButton>+ </Box>+ )}+ {wSpaceLocations.length > 0 && filteredLocations.length === 0 && (+ <Box+ data-tid="locationsFilterNoMatch"+ sx={{+ padding: '16px',+ textAlign: 'center',+ color: 'text.secondary',+ }}+ >+ <Typography variant="body2">+ {t('core:noMatchesFound')}+ </Typography>+ </Box>+ )}+ <DragDropContext onDragEnd={onDragEnd}>+ <Droppable droppableId="droppable">+ {(provided, snapshot) => (+ <div {...provided.droppableProps} ref={provided.innerRef}>+ {filteredLocations.map((location, index) => (+ <Draggable+ key={location.uuid}+ draggableId={location.uuid}+ index={index}+ isDragDisabled={Boolean(query)}+ >+ {(prov, snap) => (+ <div+ ref={prov.innerRef}+ {...prov.draggableProps}+ {...prov.dragHandleProps}+ >+ <LocationView+ key={location.uuid + index}+ workspace={getWorkSpace(location)}+ location={{+ isFile: false,+ lmdt: 0,+ name: location.name,+ path: location.path,+ size: 0,+ locationID: location.uuid,+ children: [],+ }}+ />+ </div>+ )}+ </Draggable>+ ))}+ {provided.placeholder}+ </div>+ )}+ </Droppable>+ </DragDropContext>+ </List>+ </Box><inputstyle={{ display: 'none' }}ref={fileInputRef}diff --git a/src/renderer/components/SidePanelTitle.tsx b/src/renderer/components/SidePanelTitle.tsxindex fe6029931..475e98390 100644--- a/src/renderer/components/SidePanelTitle.tsx+++ b/src/renderer/components/SidePanelTitle.tsx@@ -25,14 +25,16 @@ export type TSButtonProps = ButtonProps & {title: string;tooltip?: string;menuButton?: React.ReactNode;+ titleAdornment?: React.ReactNode;};function SidePanelTitle(props: TSButtonProps) {- const { title, tooltip, menuButton, ...rest } = props;+ const { title, tooltip, menuButton, titleAdornment, ...rest } = props;return (<divstyle={{display: 'flex',+ alignItems: 'center',paddingRight: 5, //AppConfig.defaultSpaceBetweenButtons,}}>@@ -42,7 +44,7 @@ function SidePanelTitle(props: TSButtonProps) {sx={{textTransform: 'uppercase',fontSize: '0.9rem',- flex: 1,+ flex: titleAdornment ? 'none' : 1,paddingLeft: '7px',paddingTop: '12px',}}@@ -50,6 +52,8 @@ function SidePanelTitle(props: TSButtonProps) {{title}</Typography></TsTooltip>+ {titleAdornment}+ {titleAdornment && <div style={{ flex: 1 }} />}{menuButton && menuButton}</div>);diff --git a/src/renderer/components/menus/LocationManagerMenu.tsx b/src/renderer/components/menus/LocationManagerMenu.tsxindex 508a0ad50..fe62c5a02 100644--- a/src/renderer/components/menus/LocationManagerMenu.tsx+++ b/src/renderer/components/menus/LocationManagerMenu.tsx@@ -20,6 +20,7 @@ import AppConfig from '-/AppConfig';import {CloseIcon,ExportIcon,+ FilterIcon,HelpIcon,ImportIcon,LocalLocationIcon,@@ -31,6 +32,7 @@ import TsMenuList from '-/components/TsMenuList';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';import { Pro } from '-/pro';+import { isDesktopMode } from '-/reducers/settings';import { openURLExternally } from '-/services/utils-io';import { TS } from '-/tagspaces.namespace';import { Divider } from '@mui/material';@@ -41,17 +43,27 @@ import MenuItem from '@mui/material/MenuItem';import Links from 'assets/links';import { useContext, useState } from 'react';import { useTranslation } from 'react-i18next';+import { useSelector } from 'react-redux';import SidePanelTitle from '../SidePanelTitle';interface Props {exportLocations: () => void;importLocations: () => void;showCreateLocationDialog: () => void;+ toggleFilter: () => void;+ filterActive: boolean;}function LocationManagerMenu(props: Props) {- const { exportLocations, importLocations, showCreateLocationDialog } = props;+ const {+ exportLocations,+ importLocations,+ showCreateLocationDialog,+ toggleFilter,+ filterActive,+ } = props;const { t } = useTranslation();+ const desktopMode = useSelector(isDesktopMode);const { createLocationsIndexes } = useLocationIndexContext();const { closeAllLocations } = useCurrentLocationContext();@@ -176,6 +188,33 @@ function LocationManagerMenu(props: Props) {<><SidePanelTitletitle={t('core:locationManager')}+ titleAdornment={+ desktopMode ? (+ <TsIconButton+ size="small"+ data-tid="locationManagerFilterTID"+ tooltip={t('core:filterLocations')}+ onClick={toggleFilter}+ sx={{+ marginTop: '8px',+ marginLeft: '6px',+ width: 18,+ height: 18,+ padding: '2px',+ borderRadius: '4px',+ border: '1px dashed',+ borderColor: filterActive ? 'text.primary' : 'text.disabled',+ color: filterActive ? 'text.primary' : 'text.disabled',+ '&:hover': {+ borderColor: 'text.primary',+ color: 'text.primary',+ },+ }}+ >+ <FilterIcon sx={{ fontSize: 13 }} />+ </TsIconButton>+ ) : null+ }menuButton={<TsIconButtondata-tid="locationManagerMenu"diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.jsonindex 10c1f5b7c..5e6fc365d 100644--- a/src/renderer/locales/en/core.json+++ b/src/renderer/locales/en/core.json@@ -1077,6 +1077,9 @@"filesPerMonth": "Files per month","confirmResetFileTypes": "Are you sure you want to reset all custom file type settings to default?","filterByFileExtension": "Filter by extension...",+ "filterLocations": "Filter locations",+ "filterLocationsPlaceholder": "Filter by location or workspace name...",+ "noMatchesFound": "No matches found","movingFileNotPossible": "Moving file not possible","importingFilesFailedNoFolderOpen": "Importing files failed, because no folder is opened in TagSpaces!","locationIdAlreadyExists": "Location with this ID already exists",