Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Add workspaces for location, tag groups and search (#2373)

Stanimird15e9ebec0a2
diff --git a/package-lock.json b/package-lock.json
index 3c1825d6d..898c939a8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -208,7 +208,7 @@
"yarn": "please-use-npm"
},
"optionalDependencies": {
- "@tagspacespro/tagspacespro": "5.0.184"
+ "@tagspacespro/tagspacespro": "5.0.185"
}
},
"node_modules/@adobe/css-tools": {
@@ -19352,9 +19352,9 @@
}
},
"node_modules/@tagspacespro/tagspacespro": {
- "version": "5.0.184",
- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.184/63f7d764c29ee2b5cad547130ebd9becb38d50cf",
- "integrity": "sha512-l5vFGrB+TgErk+DZHeH9W5tJbyDL+6swsLbzU8rc1gCDOy2O0otDe6v3I+sCq3nwQyIDIN9yxSHwXa6Muko4gg==",
+ "version": "5.0.185",
+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.185/8fabb11cb0e7a7c411caa386d17137514949a893",
+ "integrity": "sha512-k2Ww0xjx3qGAHnd8ro+RRJ3OZFJA5JJ3KxdwcyGDfBYpb3L2JMsO1BDhecTISFmBH9jTgoC8Hm0qY6RhINhvWA==",
"license": "Proprietary",
"optional": true
},
diff --git a/package.json b/package.json
index 425696c73..30583110e 100644
--- a/package.json
+++ b/package.json
@@ -246,7 +246,7 @@
"zod-to-json-schema": "^3.24.1"
},
"optionalDependencies": {
- "@tagspacespro/tagspacespro": "5.0.184"
+ "@tagspacespro/tagspacespro": "5.0.185"
},
"devDependencies": {
"@electron/notarize": "^2.5.0",
diff --git a/src/renderer/components/CommonIcons.tsx b/src/renderer/components/CommonIcons.tsx
index 3e1f9f73e..9ab4d4ee8 100644
--- a/src/renderer/components/CommonIcons.tsx
+++ b/src/renderer/components/CommonIcons.tsx
@@ -28,6 +28,8 @@ export const MarkdownFileIcon = (props) => (
<MarkdownRawIcon sx={{ transform: 'scaleX(-1)' }} />
);
+export { default as WorkspacesIcon } from '@mui/icons-material/WorkspacesOutline';
+
export const NavigateToFolderIcon = (props) => <KeyboardReturnIcon />;
export { default as InfoTooltipIcon } from '@mui/icons-material/InfoOutlined';
diff --git a/src/renderer/components/EditSearchQuery.tsx b/src/renderer/components/EditSearchQuery.tsx
index 24e61a2af..8713fe04a 100644
--- a/src/renderer/components/EditSearchQuery.tsx
+++ b/src/renderer/components/EditSearchQuery.tsx
@@ -41,7 +41,9 @@ import TsTextField from '-/components/TsTextField';
import TsToggleButton from '-/components/TsToggleButton';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
import { useSearchQueryContext } from '-/hooks/useSearchQueryContext';
+import { Pro } from '-/pro';
import { isDesktopMode } from '-/reducers/settings';
+import { TS } from '-/tagspaces.namespace';
import { ListItemText, Stack } from '@mui/material';
import Box from '@mui/material/Box';
import FormControl from '@mui/material/FormControl';
@@ -50,10 +52,10 @@ import InputAdornment from '@mui/material/InputAdornment';
import MenuItem from '@mui/material/MenuItem';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import Typography from '@mui/material/Typography';
-import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
+import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { formatFileSize } from '@tagspaces/tagspaces-common/misc';
-import React from 'react';
+import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
@@ -69,6 +71,16 @@ function EditSearchQuery(props: Props) {
useSearchQueryContext();
const { isIndexing } = useLocationIndexContext();
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+ const currentWorkSpace =
+ workSpacesContext && workSpacesContext.getCurrentWorkSpace
+ ? workSpacesContext?.getCurrentWorkSpace()
+ : undefined;
+
const handleFileSizeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { target } = event;
const { value, name } = target;
@@ -263,10 +275,16 @@ function EditSearchQuery(props: Props) {
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
}}
- tooltip={t('searchInAllLocationTooltip')}
+ tooltip={
+ currentWorkSpace
+ ? t('currentWorkspace')
+ : t('searchInAllLocationTooltip')
+ }
value="global"
>
- {t('globalSearch')}
+ {currentWorkSpace
+ ? currentWorkSpace.fullName + ' - ' + currentWorkSpace.shortName
+ : t('globalSearch')}
</TsToggleButton>
</ToggleButtonGroup>
</FormControl>
@@ -575,7 +593,7 @@ function EditSearchQuery(props: Props) {
<TooltipTS title={t('enterTimePeriodTooltip')}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<Box position="relative" display="inline-flex">
- <div>
+ <div style={{ maxWidth: 180 }}>
<FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>
{t('core:enterTagTimePeriodFrom')}
</FormHelperText>
@@ -595,7 +613,7 @@ function EditSearchQuery(props: Props) {
}}
/>
</div>
- <div style={{ marginLeft: 5 }}>
+ <div style={{ marginLeft: 5, maxWidth: 180 }}>
<FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>
{t('core:enterTagTimePeriodTo')}
</FormHelperText>
diff --git a/src/renderer/components/LocationManager.tsx b/src/renderer/components/LocationManager.tsx
index 021b609f0..77e1317da 100644
--- a/src/renderer/components/LocationManager.tsx
+++ b/src/renderer/components/LocationManager.tsx
@@ -25,7 +25,7 @@ import { Pro } from '-/pro';
import { getLocations } from '-/reducers/locations';
import { TS } from '-/tagspaces.namespace';
import { Box, List } from '@mui/material';
-import { useRef, useState } from 'react';
+import { useContext, useEffect, useRef, useState } from 'react';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import { useSelector } from 'react-redux';
@@ -45,6 +45,8 @@ function LocationManager(props: Props) {
const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();
const locations: TS.Location[] = useSelector(getLocations);
+ const [wSpaceLocations, setWSpaceLocations] =
+ useState<TS.Location[]>(locations);
const fileInputRef = useRef<HTMLInputElement>(null);
const [isExportLocationsDialogOpened, setExportLocationsDialogOpened] =
useState<boolean>(false);
@@ -56,6 +58,27 @@ function LocationManager(props: Props) {
const ImportLocationsDialog =
Pro && Pro.UI ? Pro.UI.ImportLocationsDialog : false;
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+
+ const currentWorkSpace =
+ workSpacesContext && workSpacesContext.getCurrentWorkSpace
+ ? workSpacesContext?.getCurrentWorkSpace()
+ : undefined;
+
+ useEffect(() => {
+ if (currentWorkSpace) {
+ setWSpaceLocations(
+ locations.filter((l) => l.workSpaceId === currentWorkSpace.uuid),
+ );
+ } else {
+ setWSpaceLocations(locations);
+ }
+ }, [currentWorkSpace, locations]);
+
function handleFileInputChange(selection: any) {
const target = selection.currentTarget;
const file = target.files[0];
@@ -73,6 +96,16 @@ function LocationManager(props: Props) {
const { reduceHeightBy, show } = props;
const currentLocation = findLocation();
+
+ function getWorkSpace(l) {
+ if (l.workSpaceId) {
+ const wSpace = workSpacesContext.getWorkSpace(l.workSpaceId);
+ if (wSpace) {
+ return wSpace;
+ }
+ }
+ }
+
return (
<Box
style={{
@@ -135,7 +168,7 @@ function LocationManager(props: Props) {
<Droppable droppableId="droppable">
{(provided, snapshot) => (
<div {...provided.droppableProps} ref={provided.innerRef}>
- {locations.map((location, index) => (
+ {wSpaceLocations.map((location, index) => (
<Draggable
key={location.uuid}
draggableId={location.uuid}
@@ -149,6 +182,7 @@ function LocationManager(props: Props) {
>
<LocationView
key={location.uuid}
+ workspace={getWorkSpace(location)}
location={{
isFile: false,
lmdt: 0,
diff --git a/src/renderer/components/LocationView.tsx b/src/renderer/components/LocationView.tsx
index ad086d354..3cd69d1dd 100644
--- a/src/renderer/components/LocationView.tsx
+++ b/src/renderer/components/LocationView.tsx
@@ -35,6 +35,8 @@ import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUp
import { useMenuContext } from '-/components/dialogs/hooks/useMenuContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
+import { useFileUploadContext } from '-/hooks/useFileUploadContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';
@@ -55,11 +57,10 @@ import { useDispatch } from 'react-redux';
import { actions as AppActions, AppDispatch } from '../reducers/app';
import DragItemTypes from './DragItemTypes';
import TargetMoveFileBox from './TargetMoveFileBox';
-import { useFileUploadContext } from '-/hooks/useFileUploadContext';
-import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
interface Props {
location: SubFolder;
+ workspace?: TS.WorkSpace;
hideDrawer?: () => void;
}
@@ -86,7 +87,7 @@ function LocationView(props: Props) {
const theme = useTheme();
const dispatch: AppDispatch = useDispatch();
- const { location, hideDrawer } = props;
+ const { location, hideDrawer, workspace } = props;
const subFolderLocation = findLocation(location.locationID);
const isCloudLocation = subFolderLocation?.type === locationType.TYPE_CLOUD;
@@ -242,6 +243,11 @@ function LocationView(props: Props) {
noWrap
>
<Tooltip title={locationNameTitle}>{location.name}</Tooltip>
+ {workspace && (
+ <Tooltip title={t('core:workspace') + ': ' + workspace.fullName}>
+ {' - ' + workspace.shortName}
+ </Tooltip>
+ )}
</Typography>
</div>
);
diff --git a/src/renderer/components/MobileNavigation.tsx b/src/renderer/components/MobileNavigation.tsx
index 0d2c729cd..7ed6fb43f 100644
--- a/src/renderer/components/MobileNavigation.tsx
+++ b/src/renderer/components/MobileNavigation.tsx
@@ -36,6 +36,7 @@ import {
SettingsIcon,
TagLibraryIcon,
ThemingIcon,
+ WorkspacesIcon,
} from '-/components/CommonIcons';
import CustomLogo from '-/components/CustomLogo';
import HelpFeedbackPanel from '-/components/HelpFeedbackPanel';
@@ -68,6 +69,7 @@ import {
isDesktopMode,
} from '-/reducers/settings';
import { createNewInstance } from '-/services/utils-io';
+import { TS } from '-/tagspaces.namespace';
import ArrowDropDown from '@mui/icons-material/ArrowDropDown';
import { ClickAwayListener, Divider, Popover } from '@mui/material';
import Box from '@mui/material/Box';
@@ -79,7 +81,7 @@ import MenuItem from '@mui/material/MenuItem';
import Paper from '@mui/material/Paper';
import Popper from '@mui/material/Popper';
import { alpha, useTheme } from '@mui/material/styles';
-import React, { useState } from 'react';
+import React, { useContext, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import TsIconButton from './TsIconButton';
@@ -95,7 +97,8 @@ function MobileNavigation(props: Props) {
const theme = useTheme();
const desktopMode = useSelector(isDesktopMode);
const dispatch: AppDispatch = useDispatch();
- const { setSelectedLocation, findLocation } = useCurrentLocationContext();
+ const { setSelectedLocation, currentLocation, locations } =
+ useCurrentLocationContext();
const { currentDirectoryPath } = useDirectoryContentContext();
const { openFileUpload } = useFileUploadContext();
const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();
@@ -114,13 +117,28 @@ function MobileNavigation(props: Props) {
const { hideDrawer, width } = props;
const switchTheme = () => dispatch(SettingsActions.switchTheme());
const [openedCreateMenu, setOpenCreateMenu] = React.useState(false);
- const anchorRef = React.useRef<HTMLDivElement>(null);
- const currentLocation = findLocation();
+ const [openedWorkSpaceMenu, setOpenWorkSpaceMenu] = React.useState(false);
+ const anchorWSpaceRef = React.useRef<HTMLButtonElement>(null);
+ const anchorRef = React.useRef<HTMLButtonElement>(null);
+
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+ const workSpaces: TS.WorkSpace[] = workSpacesContext?.getWorkSpaces() ?? [];
+ /*const foundWorkSpaces: TS.WorkSpace[] = workSpaces.filter((ws) =>
+ locations.some((l) => l.workSpaceId === ws.uuid),
+ );*/
const handleToggle = () => {
setOpenCreateMenu((prevOpen) => !prevOpen);
};
+ const handleToggleWorkSpaces = () => {
+ setOpenWorkSpaceMenu((prevOpen) => !prevOpen);
+ };
+
const handleClose = (event: Event) => {
if (
anchorRef.current &&
@@ -131,6 +149,16 @@ function MobileNavigation(props: Props) {
setOpenCreateMenu(false);
};
+ const handleCloseWSpace = (event: Event) => {
+ if (
+ anchorWSpaceRef.current &&
+ anchorWSpaceRef.current.contains(event.target as HTMLElement)
+ ) {
+ return;
+ }
+ setOpenWorkSpaceMenu(false);
+ };
+
return (
<Box
style={{
@@ -161,7 +189,6 @@ function MobileNavigation(props: Props) {
}}
>
<ButtonGroup
- ref={anchorRef}
aria-label="split button"
style={{
textAlign: 'center',
@@ -170,6 +197,7 @@ function MobileNavigation(props: Props) {
}}
>
<TsButton
+ ref={anchorRef}
aria-controls={
openedCreateMenu ? 'split-button-menu' : undefined
}
@@ -197,6 +225,35 @@ function MobileNavigation(props: Props) {
{/* {t('core:createNew')} */}
</Box>
</TsButton>
+ {workSpaces && workSpaces.length > 0 && (
+ <TsButton
+ ref={anchorWSpaceRef}
+ tooltip={t('currentWorkspace')}
+ aria-controls={
+ openedWorkSpaceMenu ? 'create-wspace-menu' : undefined
+ }
+ aria-expanded={openedWorkSpaceMenu ? 'true' : undefined}
+ aria-haspopup="menu"
+ data-tid="openedWorkSpaceMenuButtonTID"
+ onClick={handleToggleWorkSpaces}
+ endIcon={<ArrowDropDown />}
+ style={{
+ borderRadius: 'unset',
+ }}
+ >
+ <Box
+ style={{
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ overflow: 'hidden',
+ maxWidth: 100,
+ }}
+ >
+ {workSpacesContext.getCurrentWorkSpace()?.shortName ||
+ t('core:allWorkspaces')}
+ </Box>
+ </TsButton>
+ )}
<TsButton
tooltip={t('core:openSharingLink')}
data-tid="openLinkNavigationTID"
@@ -271,7 +328,67 @@ function MobileNavigation(props: Props) {
)}
</Box>
</Box>
-
+ {workSpaces && workSpaces.length > 0 && (
+ <ClickAwayListener onClickAway={handleCloseWSpace}>
+ <Popper
+ anchorEl={anchorWSpaceRef.current}
+ sx={{
+ zIndex: 1,
+ }}
+ open={openedWorkSpaceMenu}
+ role={undefined}
+ transition
+ disablePortal
+ >
+ {({ TransitionProps, placement }) => (
+ <Grow
+ {...TransitionProps}
+ style={{
+ transformOrigin:
+ placement === 'bottom' ? 'center top' : 'center bottom',
+ }}
+ >
+ <Paper>
+ <TsMenuList id="create-file-menu" autoFocusItem>
+ <MenuItem
+ key="allWSpace"
+ data-tid={'wSpaceAllTID'}
+ onClick={() => {
+ workSpacesContext.setCurrentWorkSpaceId(undefined);
+ setOpenWorkSpaceMenu(false);
+ }}
+ >
+ <ListItemIcon>
+ <WorkspacesIcon />
+ </ListItemIcon>
+ <ListItemText primary={t('allWorkspaces')} />
+ </MenuItem>
+ {workSpaces.map((wSpace) => (
+ <MenuItem
+ key={wSpace.uuid}
+ data-tid={'wSpace' + wSpace.shortName + 'TID'}
+ onClick={() => {
+ workSpacesContext.setCurrentWorkSpaceId(
+ wSpace.uuid,
+ );
+ setOpenWorkSpaceMenu(false);
+ }}
+ >
+ <ListItemIcon>
+ <WorkspacesIcon />
+ </ListItemIcon>
+ <ListItemText
+ primary={wSpace.fullName + ' - ' + wSpace.shortName}
+ />
+ </MenuItem>
+ ))}
+ </TsMenuList>
+ </Paper>
+ </Grow>
+ )}
+ </Popper>
+ </ClickAwayListener>
+ )}
<ClickAwayListener onClickAway={handleClose}>
<Popper
sx={{
@@ -292,7 +409,7 @@ function MobileNavigation(props: Props) {
}}
>
<Paper>
- <TsMenuList id="split-button-menu" autoFocusItem>
+ <TsMenuList id="nav-create-menu" autoFocusItem>
<MenuItem
key="navCreateNewTextFile"
data-tid="navCreateNewTextFileTID"
diff --git a/src/renderer/components/SearchAutocomplete.tsx b/src/renderer/components/SearchAutocomplete.tsx
index 42e04b88e..dd773463e 100644
--- a/src/renderer/components/SearchAutocomplete.tsx
+++ b/src/renderer/components/SearchAutocomplete.tsx
@@ -155,6 +155,16 @@ function SearchAutocomplete(props: Props) {
// const mainSearchField = useRef<HTMLInputElement>(null);
const isOpen = useRef<boolean>(true);
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+
+ const currentWorkSpace =
+ workSpacesContext && workSpacesContext.getCurrentWorkSpace
+ ? workSpacesContext?.getCurrentWorkSpace()
+ : undefined;
const firstRender = useFirstRender();
@@ -307,7 +317,7 @@ function SearchAutocomplete(props: Props) {
textQuery: txtQuery,
};
if (searchBoxing === 'global') {
- searchAllLocations(sQuery);
+ searchAllLocations(sQuery, currentWorkSpace);
} else {
searchLocationIndex(sQuery);
}
diff --git a/src/renderer/components/TagGroupTitleDnD.tsx b/src/renderer/components/TagGroupTitleDnD.tsx
index ad123cd55..ba3f4d619 100644
--- a/src/renderer/components/TagGroupTitleDnD.tsx
+++ b/src/renderer/components/TagGroupTitleDnD.tsx
@@ -23,15 +23,18 @@ import {
SmallArrowRightIcon,
} from '-/components/CommonIcons';
import DragItemTypes from '-/components/DragItemTypes';
+import TooltipTS from '-/components/Tooltip';
import TsIconButton from '-/components/TsIconButton';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { Pro } from '-/pro';
import { TS } from '-/tagspaces.namespace';
import { CommonLocation } from '-/utils/CommonLocation';
import { Box } from '@mui/material';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
-import React, { useRef } from 'react';
+import React, { useContext, useRef } from 'react';
import { useDrag, useDrop } from 'react-dnd';
+import { useTranslation } from 'react-i18next';
interface Props {
index: number;
@@ -57,6 +60,12 @@ function TagGroupTitleDnD(props: Props) {
} = props;
const { findLocation } = useCurrentLocationContext();
const tagGroupRef = useRef<HTMLSpanElement>(null);
+ const { t } = useTranslation();
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
const [, drag] = useDrag({
type: DragItemTypes.TAG_GROUP,
@@ -127,6 +136,30 @@ function TagGroupTitleDnD(props: Props) {
const readOnly = tagGroup.readOnly ? 'read-only ' : '';
+ const currentWorkspace = workSpacesContext?.getWorkSpace(
+ tagGroup.workSpaceId,
+ );
+ const taggroupWorkspace = tagGroup.workSpaceId ? (
+ <TooltipTS title={t('core:workspace') + ': ' + currentWorkspace?.fullName}>
+ <span> - {currentWorkspace?.shortName}</span>
+ </TooltipTS>
+ ) : (
+ ''
+ );
+
+ const taggroupTitle = (
+ <TooltipTS
+ title={
+ 'Number of tags in this ' +
+ readOnly +
+ 'tag group: ' +
+ tagGroup.children.length
+ }
+ >
+ {tagGroup.title + getLocationName(tagGroup.locationId)}
+ </TooltipTS>
+ );
+
const tagGroupTitle = (
<Box
data-tid={'tagLibraryTagGroupTitle_' + tagGroup.title}
@@ -135,12 +168,6 @@ function TagGroupTitleDnD(props: Props) {
height: '100%',
borderRadius: AppConfig.defaultCSSRadius,
}}
- title={
- 'Number of tags in this ' +
- readOnly +
- 'tag group: ' +
- tagGroup.children.length
- }
>
<Grid
container
@@ -170,7 +197,8 @@ function TagGroupTitleDnD(props: Props) {
noWrap
onClick={(event: any) => handleTagGroupTitleClick(event, tagGroup)}
>
- {tagGroup.title + getLocationName(tagGroup.locationId)}
+ {taggroupTitle}
+ {taggroupWorkspace}
{!tagGroup.expanded && (
<span
style={{
diff --git a/src/renderer/components/TagLibrary.tsx b/src/renderer/components/TagLibrary.tsx
index 61a929170..90e8ee985 100644
--- a/src/renderer/components/TagLibrary.tsx
+++ b/src/renderer/components/TagLibrary.tsx
@@ -48,11 +48,12 @@ import { TS } from '-/tagspaces.namespace';
import { CommonLocation } from '-/utils/CommonLocation';
import { Box } from '@mui/material';
import Collapse from '@mui/material/Collapse';
-import React, { useCallback, useState } from 'react';
+import React, { useCallback, useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import CustomDragLayer from '-/components/CustomDragLayer';
import { useNotificationContext } from '-/hooks/useNotificationContext';
+import { Pro } from '-/pro';
interface Props {
style?: any;
@@ -72,6 +73,8 @@ function TagLibrary(props: Props) {
const { findLocation } = useCurrentLocationContext();
const { tagGroups } = useEditedTagLibraryContext();
const { openConfirmDialog } = useNotificationContext();
+ const [wSpaceTagGroups, setWSpaceTagGroups] =
+ useState<TS.TagGroup[]>(tagGroups);
const dispatch: AppDispatch = useDispatch();
const tagBackgroundColor = useSelector(getTagColor);
const tagTextColor = useSelector(getTagTextColor);
@@ -98,6 +101,27 @@ function TagLibrary(props: Props) {
const [isEditTagDialogOpened, setIsEditTagDialogOpened] =
useState<boolean>(false);
const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);
+
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+
+ const currentWorkSpace =
+ workSpacesContext && workSpacesContext.getCurrentWorkSpace
+ ? workSpacesContext?.getCurrentWorkSpace()
+ : undefined;
+
+ useEffect(() => {
+ if (currentWorkSpace) {
+ setWSpaceTagGroups(
+ tagGroups.filter((t) => t.workSpaceId === currentWorkSpace.uuid),
+ );
+ } else {
+ setWSpaceTagGroups(tagGroups);
+ }
+ }, [currentWorkSpace, tagGroups]);
/*const firstRender = useFirstRender();
useEffect(() => {
@@ -268,7 +292,7 @@ function TagLibrary(props: Props) {
const { reduceHeightBy } = props;
- const allTags = getAllTags(tagGroups);
+ const allTags = getAllTags(wSpaceTagGroups);
return (
<Box
style={{
@@ -285,12 +309,13 @@ function TagLibrary(props: Props) {
'Your tag library contains ' +
allTags.length +
' tags \ndistributed in ' +
- tagGroups.length +
+ wSpaceTagGroups.length +
' tag groups'
}
menuButton={
// Display the menu button if there are editable tag groups or no tag groups exist (to allow creating new ones)
- (tagGroups.some((tg) => !tg.readOnly) || tagGroups.length === 0) && (
+ (wSpaceTagGroups.some((tg) => !tg.readOnly) ||
+ wSpaceTagGroups.length === 0) && (
<TsIconButton
data-tid="tagLibraryMenu"
onClick={handleTagLibraryMenu}
@@ -384,7 +409,9 @@ function TagLibrary(props: Props) {
{SmartTags(t).map(renderTagGroup)}
</div>
)}
- <div style={{ paddingTop: 0 }}>{tagGroups.map(renderTagGroup)}</div>
+ <div style={{ paddingTop: 0 }}>
+ {wSpaceTagGroups.map(renderTagGroup)}
+ </div>
</div>
</Box>
);
diff --git a/src/renderer/components/TagsSelect.tsx b/src/renderer/components/TagsSelect.tsx
index a13965161..2a9963655 100644
--- a/src/renderer/components/TagsSelect.tsx
+++ b/src/renderer/components/TagsSelect.tsx
@@ -34,10 +34,17 @@ import { Box, InputAdornment } from '@mui/material';
import Autocomplete from '@mui/material/Autocomplete';
import FormHelperText from '@mui/material/FormHelperText';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
-import React, { useReducer, useRef, useState } from 'react';
+import React, {
+ useContext,
+ useEffect,
+ useReducer,
+ useRef,
+ useState,
+} from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';
+import { Pro } from '-/pro';
interface Props {
dataTid?: string;
@@ -57,15 +64,28 @@ function TagsSelect(props: Props) {
const { t } = useTranslation();
const { currentLocation } = useCurrentLocationContext();
const { tagGroups } = useEditedTagLibraryContext();
+
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+
+ const currentWorkSpace =
+ workSpacesContext && workSpacesContext.getCurrentWorkSpace
+ ? workSpacesContext?.getCurrentWorkSpace()
+ : undefined;
+
const desktopMode = useSelector(isDesktopMode);
const isUseOnlyTagsFromTagLibrary = useSelector(useOnlyTagsFromTagLibrary);
const [tagMenuAnchorEl, setTagMenuAnchorEl] = useState<null | HTMLElement>(
null,
);
-
const [selectedTag, setSelectedTag] = useState(undefined);
const tagsError = useRef<boolean>(false);
- const allTags = useRef<Array<TS.Tag>>(getAllTags(tagGroups));
+ const allTags = useRef<Array<TS.Tag>>(
+ getAllTags(tagGroups, currentWorkSpace),
+ );
const defaultBackgroundColor = useSelector(getTagColor);
const defaultTextColor = useSelector(getTagTextColor);
@@ -81,6 +101,11 @@ function TagsSelect(props: Props) {
generateButton,
} = props;
+ useEffect(() => {
+ allTags.current = getAllTags(tagGroups, currentWorkSpace);
+ forceUpdate();
+ }, [currentWorkSpace, tagGroups]);
+
function handleTagChange(
event: Object,
selectedTags: Array<TS.Tag>,
diff --git a/src/renderer/components/TsButton.tsx b/src/renderer/components/TsButton.tsx
index 39c7be140..6e267a11f 100644
--- a/src/renderer/components/TsButton.tsx
+++ b/src/renderer/components/TsButton.tsx
@@ -37,28 +37,32 @@ export type TSButtonProps = ButtonProps & {
startIcon?: React.ReactNode;
};
-function TsButton(props: TSButtonProps) {
- const { children, style, tooltip, loading, startIcon, ...rest } = props;
- const desktopMode = useSelector(isDesktopMode);
- const button = (
- <Button
- loading={loading}
- size={desktopMode ? 'small' : 'medium'}
- {...(startIcon && { startIcon: startIcon })}
- variant="outlined" // text outlined contained
- {...rest}
- style={{
- borderRadius: AppConfig.defaultCSSRadius,
- textTransform: 'none', //'capitalize',
- fontSize: 14,
- fontWeight: 'normal',
- ...style,
- }}
- >
- {children}
- </Button>
- );
- return tooltip ? <TooltipTS title={tooltip}>{button}</TooltipTS> : button;
-}
+//function TsButton(props: TSButtonProps) {
+const TsButton = React.forwardRef<HTMLButtonElement, TSButtonProps>(
+ function TsButton(props, ref) {
+ const { children, style, tooltip, loading, startIcon, ...rest } = props;
+ const desktopMode = useSelector(isDesktopMode);
+ const button = (
+ <Button
+ ref={ref}
+ loading={loading}
+ size={desktopMode ? 'small' : 'medium'}
+ {...(startIcon && { startIcon: startIcon })}
+ variant="outlined" // text outlined contained
+ {...rest}
+ style={{
+ borderRadius: AppConfig.defaultCSSRadius,
+ textTransform: 'none', //'capitalize',
+ fontSize: 14,
+ fontWeight: 'normal',
+ ...style,
+ }}
+ >
+ {children}
+ </Button>
+ );
+ return tooltip ? <TooltipTS title={tooltip}>{button}</TooltipTS> : button;
+ },
+);
export default TsButton;
diff --git a/src/renderer/components/TsSelect.tsx b/src/renderer/components/TsSelect.tsx
index 68f92a604..d8439c263 100644
--- a/src/renderer/components/TsSelect.tsx
+++ b/src/renderer/components/TsSelect.tsx
@@ -26,12 +26,12 @@ import { useSelector } from 'react-redux';
type TSSelectProps = TextFieldProps & {};
function TsSelect(props: TSSelectProps) {
- const { children, label } = props;
+ const { children, label, fullWidth = true } = props;
const theme = useTheme();
const desktopMode = useSelector(isDesktopMode);
return (
- <div>
+ <div style={{ width: fullWidth ? '100%' : 'auto' }}>
<FormHelperText style={{ marginLeft: 5, marginTop: 0 }}>
{label}
</FormHelperText>
@@ -43,6 +43,7 @@ function TsSelect(props: TSSelectProps) {
cursor: 'context-menu',
marginTop: 0,
}}
+ fullWidth={fullWidth}
select
{...props}
label={undefined}
diff --git a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
index 97c129e36..b41ef4c15 100644
--- a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
+++ b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
@@ -69,7 +69,7 @@ import useMediaQuery from '@mui/material/useMediaQuery';
import { locationType } from '@tagspaces/tagspaces-common/misc';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import CryptoJS from 'crypto-js';
-import React, { ChangeEvent, useEffect, useState } from 'react';
+import React, { ChangeEvent, useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import TsToggleButton from '../TsToggleButton';
@@ -87,8 +87,13 @@ function CreateEditLocationDialog(props: Props) {
const { showNotification, openConfirmDialog } = useNotificationContext();
const { createLocationIndex } = useLocationIndexContext();
const { loadLocationDataPromise } = useTagGroupsLocationContext();
- const { addLocation, editLocation, selectedLocation, findLocation } =
- useCurrentLocationContext();
+ const {
+ addLocation,
+ editLocation,
+ selectedLocation,
+ findLocation,
+ locations,
+ } = useCurrentLocationContext();
const isPersistTagsInSidecar = useSelector(getPersistTagsInSidecarFile);
//const locations: Array<CommonLocation> = useSelector(getLocations);
const devMode: boolean = useSelector(isDevMode);
@@ -163,6 +168,9 @@ function CreateEditLocationDialog(props: Props) {
const [isReadOnly, setIsReadOnly] = useState<boolean>(
selectedLocation ? selectedLocation.isReadOnly : false,
);
+ const [workSpaceId, setWorkSpaceId] = useState<string>(
+ selectedLocation ? selectedLocation.workSpaceId || '' : '',
+ );
const [watchForChanges, setWatchForChanges] = useState<boolean>(
selectedLocation ? selectedLocation.watchForChanges : false,
);
@@ -405,6 +413,7 @@ function CreateEditLocationDialog(props: Props) {
if (type === locationType.TYPE_LOCAL) {
loc = {
uuid: selectedLocation ? selectedLocation.uuid : newuuid,
+ workSpaceId,
type,
name,
path,
@@ -424,6 +433,7 @@ function CreateEditLocationDialog(props: Props) {
} else if (type === locationType.TYPE_WEBDAV) {
loc = {
uuid: selectedLocation ? selectedLocation.uuid : newuuid,
+ workSpaceId,
type,
authType,
name,
@@ -446,6 +456,7 @@ function CreateEditLocationDialog(props: Props) {
} else if (type === locationType.TYPE_CLOUD) {
loc = {
uuid: selectedLocation ? selectedLocation.uuid : newuuid,
+ workSpaceId,
type,
name: storeName,
path: storePath,
@@ -581,6 +592,13 @@ function CreateEditLocationDialog(props: Props) {
locationTypeName = t('core:objectStorage');
}
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+ const workSpaces = workSpacesContext?.getWorkSpaces() ?? [];
+
const okButton = (
<TsButton
disabled={disableConfirmButton()}
@@ -628,7 +646,8 @@ function CreateEditLocationDialog(props: Props) {
></TsDialogTitle>
<DialogContent
style={{
- overflow: 'auto',
+ overflowY: 'auto',
+ overflowX: 'hidden',
minHeight: 200,
padding: 8,
}}
@@ -799,6 +818,46 @@ function CreateEditLocationDialog(props: Props) {
</AccordionSummary>
<AccordionDetails>
<FormGroup>
+ <TsSelect
+ label={
+ <>
+ {t('core:workspace')}
+ <ProLabel />
+ </>
+ }
+ disabled={!Pro}
+ style={{ minWidth: 200 }}
+ data-tid="locationWorkspaceTID"
+ value={workSpaceId}
+ onChange={(event: ChangeEvent<HTMLInputElement>) =>
+ setWorkSpaceId(event.target.value)
+ }
+ slotProps={{
+ input: {
+ endAdornment: workSpaceId && (
+ <InputAdornment position="end" sx={{ ml: -12 }}>
+ <TsIconButton
+ aria-label={t('core:deleteWSpace')}
+ onClick={() => setWorkSpaceId('')}
+ data-tid="wSpaceResetTID"
+ >
+ <RemoveIcon />
+ </TsIconButton>
+ </InputAdornment>
+ ),
+ },
+ }}
+ >
+ {workSpaces?.map((wSpace) => (
+ <MenuItem
+ key={wSpace.uuid}
+ value={wSpace.uuid}
+ data-tid={'wSpace' + wSpace.shortName + 'TID'}
+ >
+ {wSpace.shortName + ' - ' + wSpace.fullName}
+ </MenuItem>
+ ))}
+ </TsSelect>
<FormControlLabel
labelPlacement="start"
style={{ justifyContent: 'space-between', marginLeft: 0 }}
@@ -936,11 +995,7 @@ function CreateEditLocationDialog(props: Props) {
: t('core:renameFile')}
</TsButton>
}
- label={
- <Typography variant="caption" display="block" gutterBottom>
- {t('core:fileTaggingSetting')}
- </Typography>
- }
+ label={t('core:fileTaggingSetting')}
/>
) : (
<FormControlLabel
@@ -1021,24 +1076,6 @@ function CreateEditLocationDialog(props: Props) {
}
/>
)}
- <FormControl fullWidth={true}>
- <TsTextField
- name="autoOpenedFilename"
- data-tid="autoOpenedFilenameTID"
- placeholder={
- t('core:forExample') + ': index.md, index.html or readme.md'
- }
- onChange={(event) =>
- setAutoOpenedFilename(event.target.value)
- }
- updateValue={(value) => {
- setAutoOpenedFilename(value);
- }}
- retrieveValue={() => autoOpenedFilename}
- value={autoOpenedFilename}
- label={t('core:autoOpenedFilename')}
- />
- </FormControl>
<>
<FormControlLabel
disabled={!Pro}
@@ -1112,6 +1149,24 @@ function CreateEditLocationDialog(props: Props) {
/>
)}
</>
+ <FormControl fullWidth={true} style={{ marginTop: 10 }}>
+ <TsTextField
+ name="autoOpenedFilename"
+ data-tid="autoOpenedFilenameTID"
+ placeholder={
+ t('core:forExample') + ': index.md, index.html or readme.md'
+ }
+ onChange={(event) =>
+ setAutoOpenedFilename(event.target.value)
+ }
+ updateValue={(value) => {
+ setAutoOpenedFilename(value);
+ }}
+ retrieveValue={() => autoOpenedFilename}
+ value={autoOpenedFilename}
+ label={t('core:autoOpenedFilename')}
+ />
+ </FormControl>
<FormControl fullWidth={true} style={{ marginTop: 10 }}>
<TsTextField
required
diff --git a/src/renderer/components/dialogs/CreateTagGroupDialog.tsx b/src/renderer/components/dialogs/CreateTagGroupDialog.tsx
index 997a3a169..1f0a48bf1 100644
--- a/src/renderer/components/dialogs/CreateTagGroupDialog.tsx
+++ b/src/renderer/components/dialogs/CreateTagGroupDialog.tsx
@@ -17,32 +17,43 @@
*/
import AppConfig from '-/AppConfig';
+import { RemoveIcon } from '-/components/CommonIcons';
import DraggablePaper from '-/components/DraggablePaper';
+import { ProLabel } from '-/components/HelperComponents';
import Tag from '-/components/Tag';
+import TransparentBackground from '-/components/TransparentBackground';
import TsButton from '-/components/TsButton';
+import TsIconButton from '-/components/TsIconButton';
import TsSelect from '-/components/TsSelect';
import TsTextField from '-/components/TsTextField';
+import ColorPickerDialog from '-/components/dialogs/ColorPickerDialog';
import TsDialogActions from '-/components/dialogs/components/TsDialogActions';
+import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { Pro } from '-/pro';
import { getSaveTagInLocation } from '-/reducers/settings';
import { TS } from '-/tagspaces.namespace';
+import { useTheme } from '@mui/material';
import Dialog from '@mui/material/Dialog';
import DialogContent from '@mui/material/DialogContent';
import FormControl from '@mui/material/FormControl';
import FormHelperText from '@mui/material/FormHelperText';
+import InputAdornment from '@mui/material/InputAdornment';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import MenuItem from '@mui/material/MenuItem';
import Paper from '@mui/material/Paper';
-import { useTheme } from '@mui/material';
import useMediaQuery from '@mui/material/useMediaQuery';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
-import React, { ChangeEvent, useReducer, useRef, useState } from 'react';
+import React, {
+ ChangeEvent,
+ useContext,
+ useReducer,
+ useRef,
+ useState,
+} from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
-import TransparentBackground from '../TransparentBackground';
-import ColorPickerDialog from './ColorPickerDialog';
-import TsDialogTitle from './components/TsDialogTitle';
interface Props {
open: boolean;
@@ -56,6 +67,7 @@ const defaultTagGroupLocation = 'TAG_LIBRARY';
function CreateTagGroupDialog(props: Props) {
const { t } = useTranslation();
+ const { open, onClose, createTagGroup } = props;
const { locations } = useCurrentLocationContext();
//const locations = useSelector(getLocations);
const saveTagsInLocation = useSelector(getSaveTagInLocation);
@@ -70,10 +82,16 @@ function CreateTagGroupDialog(props: Props) {
const color = useRef<string>(props.color);
const textcolor = useRef<string>(props.textcolor);
const locationId = useRef<string>(defaultTagGroupLocation);
+ const [workSpaceId, setWorkSpaceId] = useState<string>('');
// eslint-disable-next-line no-unused-vars
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0);
- const { open, onClose, createTagGroup } = props;
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+ const workSpaces = workSpacesContext?.getWorkSpaces() ?? [];
const handleTagGroupTitleChange = (
event: React.ChangeEvent<HTMLInputElement>,
@@ -120,6 +138,7 @@ function CreateTagGroupDialog(props: Props) {
color: color.current,
textcolor: textcolor.current,
locationId: lId,
+ ...(workSpaceId && { workSpaceId }),
children: [],
});
onClose();
@@ -184,7 +203,9 @@ function CreateTagGroupDialog(props: Props) {
onClose={onClose}
actionSlot={okButton}
/>
- <DialogContent style={{ paddingTop: 10, minWidth: 300 }}>
+ <DialogContent
+ style={{ overflowY: 'visible', overflowX: 'hidden', minWidth: 300 }}
+ >
<FormControl fullWidth={true} error={inputError}>
<TsTextField
error={inputError}
@@ -200,7 +221,7 @@ function CreateTagGroupDialog(props: Props) {
)}
</FormControl>
{saveTagsInLocation && (
- <FormControl fullWidth={true} error={inputError}>
+ <ListItem style={{ paddingLeft: 0, paddingRight: 0 }}>
<TsSelect
data-tid="tagGroupLocationTID"
label={t('core:tagGroupLocation')}
@@ -228,8 +249,50 @@ function CreateTagGroupDialog(props: Props) {
</MenuItem>
))}
</TsSelect>
- </FormControl>
+ </ListItem>
)}
+ <ListItem style={{ paddingLeft: 0, paddingRight: 0 }}>
+ <TsSelect
+ disabled={!Pro}
+ data-tid="taggroupWorkspaceTID"
+ value={workSpaceId}
+ fullWidth
+ label={
+ <>
+ {t('core:workspace')}
+ <ProLabel />
+ </>
+ }
+ onChange={(event: ChangeEvent<HTMLInputElement>) =>
+ setWorkSpaceId(event.target.value)
+ }
+ slotProps={{
+ input: {
+ endAdornment: workSpaceId && (
+ <InputAdornment position="end" sx={{ ml: -12 }}>
+ <TsIconButton
+ aria-label={t('core:deleteWSpace')}
+ onClick={() => setWorkSpaceId('')}
+ data-tid="wSpaceResetTID"
+ >
+ <RemoveIcon />
+ </TsIconButton>
+ </InputAdornment>
+ ),
+ },
+ }}
+ >
+ {workSpaces.map((wSpace) => (
+ <MenuItem
+ key={wSpace.uuid}
+ value={wSpace.uuid}
+ data-tid={'wSpace' + wSpace.shortName + 'TID'}
+ >
+ {wSpace.shortName + ' - ' + wSpace.fullName}
+ </MenuItem>
+ ))}
+ </TsSelect>
+ </ListItem>
<ListItem style={{ paddingLeft: 0, paddingRight: 0 }}>
<ListItemText primary={t('core:tagBackgroundColor')} />
<TransparentBackground>
diff --git a/src/renderer/components/dialogs/EditTagGroupDialog.tsx b/src/renderer/components/dialogs/EditTagGroupDialog.tsx
index 044230d81..1f0748c68 100644
--- a/src/renderer/components/dialogs/EditTagGroupDialog.tsx
+++ b/src/renderer/components/dialogs/EditTagGroupDialog.tsx
@@ -16,10 +16,15 @@
*
*/
+import { RemoveIcon } from '-/components/CommonIcons';
+import { ProLabel } from '-/components/HelperComponents';
import Tag from '-/components/Tag';
+import TransparentBackground from '-/components/TransparentBackground';
import TsButton from '-/components/TsButton';
+import TsIconButton from '-/components/TsIconButton';
import TsSelect from '-/components/TsSelect';
import TsTextField from '-/components/TsTextField';
+import ColorPickerDialog from '-/components/dialogs/ColorPickerDialog';
import TsDialogActions from '-/components/dialogs/components/TsDialogActions';
import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
@@ -34,15 +39,14 @@ import Dialog from '@mui/material/Dialog';
import DialogContent from '@mui/material/DialogContent';
import FormControl from '@mui/material/FormControl';
import FormHelperText from '@mui/material/FormHelperText';
+import InputAdornment from '@mui/material/InputAdornment';
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import MenuItem from '@mui/material/MenuItem';
import Switch from '@mui/material/Switch';
-import React, { ChangeEvent, useEffect, useState } from 'react';
+import React, { ChangeEvent, useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
-import TransparentBackground from '../TransparentBackground';
-import ColorPickerDialog from './ColorPickerDialog';
const defaultTagGroupLocation = 'TAG_LIBRARY';
@@ -60,6 +64,9 @@ function EditTagGroupDialog(props: Props) {
const { removeLocationTagGroup } = useTagGroupsLocationContext();
const { t } = useTranslation();
const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);
+ const [workSpaceId, setWorkSpaceId] = useState<string>(
+ selectedTagGroupEntry ? selectedTagGroupEntry.workSpaceId || '' : '',
+ );
const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);
const [displayTextColorPicker, setDisplayTextColorPicker] =
useState<boolean>(false);
@@ -74,6 +81,12 @@ function EditTagGroupDialog(props: Props) {
);
const theme = useTheme();
const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+ const workSpaces = workSpacesContext?.getWorkSpaces() ?? [];
useEffect(() => {
setNewLocationId(undefined);
@@ -135,6 +148,7 @@ function EditTagGroupDialog(props: Props) {
title,
color,
textcolor,
+ ...(workSpaceId && { workSpaceId }),
...(isLocationChanged() && {
locationId:
newLocationId === defaultTagGroupLocation
@@ -169,7 +183,7 @@ function EditTagGroupDialog(props: Props) {
);
const renderContent = (
- <DialogContent style={{ overflow: 'visible' }}>
+ <DialogContent style={{ overflowY: 'visible', overflowX: 'hidden' }}>
<FormControl
fullWidth={true}
error={inputError}
@@ -189,12 +203,10 @@ function EditTagGroupDialog(props: Props) {
)}
</FormControl>
{saveTagInLocation && (
- <FormControl fullWidth={true} error={inputError}>
- <FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>
- {t('core:tagGroupLocation')}
- </FormHelperText>
+ <ListItem style={{ paddingLeft: 0, paddingRight: 0 }}>
<TsSelect
- fullWidth={false}
+ fullWidth
+ label={t('core:tagGroupLocation')}
defaultValue={
selectedTagGroupEntry.locationId || defaultTagGroupLocation
}
@@ -214,8 +226,50 @@ function EditTagGroupDialog(props: Props) {
</MenuItem>
))}
</TsSelect>
- </FormControl>
+ </ListItem>
)}
+ <ListItem style={{ paddingLeft: 0, paddingRight: 0 }}>
+ <TsSelect
+ disabled={!Pro}
+ data-tid="taggroupWorkspaceTID"
+ value={workSpaceId}
+ fullWidth
+ label={
+ <>
+ {t('core:workspace')}
+ <ProLabel />
+ </>
+ }
+ onChange={(event: ChangeEvent<HTMLInputElement>) =>
+ setWorkSpaceId(event.target.value)
+ }
+ slotProps={{
+ input: {
+ endAdornment: workSpaceId && (
+ <InputAdornment position="end" sx={{ ml: -12 }}>
+ <TsIconButton
+ aria-label={t('core:deleteWSpace')}
+ onClick={() => setWorkSpaceId('')}
+ data-tid="wSpaceResetTID"
+ >
+ <RemoveIcon />
+ </TsIconButton>
+ </InputAdornment>
+ ),
+ },
+ }}
+ >
+ {workSpaces.map((wSpace) => (
+ <MenuItem
+ key={wSpace.uuid}
+ value={wSpace.uuid}
+ data-tid={'wSpace' + wSpace.shortName + 'TID'}
+ >
+ {wSpace.shortName + ' - ' + wSpace.fullName}
+ </MenuItem>
+ ))}
+ </TsSelect>
+ </ListItem>
<ListItem style={{ paddingLeft: 0, paddingRight: 0 }}>
<ListItemText primary={t('tagBackgroundColor')} />
<TransparentBackground>
diff --git a/src/renderer/components/dialogs/components/SettingsAdvanced.tsx b/src/renderer/components/dialogs/components/SettingsAdvanced.tsx
index b4c9702d1..5822dd57a 100644
--- a/src/renderer/components/dialogs/components/SettingsAdvanced.tsx
+++ b/src/renderer/components/dialogs/components/SettingsAdvanced.tsx
@@ -50,7 +50,13 @@ import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
import MenuItem from '@mui/material/MenuItem';
import Switch from '@mui/material/Switch';
-import React, { useEffect, useReducer, useRef, useState } from 'react';
+import React, {
+ useContext,
+ useEffect,
+ useReducer,
+ useRef,
+ useState,
+} from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
@@ -67,6 +73,12 @@ function SettingsAdvanced(props: Props) {
const devMode = useSelector(isDevMode);
const [tileServerDialog, setTileServerDialog] = useState<any>(undefined);
const wsAlive = useRef<boolean>(null);
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+ const workSpaces = workSpacesContext?.getWorkSpaces() ?? [];
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
useEffect(() => {
@@ -101,6 +113,12 @@ function SettingsAdvanced(props: Props) {
setTileServerDialog({ ...tileServer, isDefault });
};
+ const editWorkSpacesClick = (event, workSpace?: TS.WorkSpace) => {
+ event.preventDefault();
+ event.stopPropagation();
+ workSpacesContext.openNewWorkspaceDialog(workSpace);
+ };
+
const geoTaggingFormatDisabled = AppConfig.geoTaggingFormat !== undefined;
const setDesktopMode = (desktopMode) =>
@@ -496,7 +514,6 @@ function SettingsAdvanced(props: Props) {
<ListItemText
primary={tileServer.name}
secondary={tileServer.serverURL}
- style={{ maxWidth: 470 }}
/>
<TsIconButton
aria-label={t('core:options')}
@@ -536,6 +553,52 @@ function SettingsAdvanced(props: Props) {
isDefault={tileServerDialog.isDefault}
/>
)}
+ <ListItem>
+ <ListItemText
+ primary={
+ <>
+ {t('core:workspaces')}
+ <ProLabel />
+ </>
+ }
+ />
+ <TsButton
+ disabled={!Pro}
+ onClick={(event) => editWorkSpacesClick(event)}
+ >
+ {t('addWorkspace')}
+ </TsButton>
+ </ListItem>
+ {workSpaces && workSpaces.length > 0 && (
+ <List
+ style={{
+ padding: 5,
+ paddingLeft: 10,
+ backgroundColor: '#d3d3d34a',
+ borderRadius: AppConfig.defaultCSSRadius,
+ }}
+ dense
+ >
+ {workSpaces.map((workSpace, index) => (
+ <ListItem key={workSpace.uuid}>
+ <ListItemText
+ primary={workSpace.fullName + ' - ' + workSpace.shortName}
+ />
+ <TsIconButton
+ aria-label={'Edit workspace'}
+ aria-haspopup="true"
+ edge="end"
+ disabled={!Pro}
+ data-tid={'workSpaceEdit_' + workSpace.shortName}
+ onClick={(event) => editWorkSpacesClick(event, workSpace)}
+ >
+ <EditIcon />
+ </TsIconButton>
+ </ListItem>
+ ))}
+ </List>
+ )}
+
<ListItem>
<ListItemText
primary={
diff --git a/src/renderer/components/menus/LocationManagerMenu.tsx b/src/renderer/components/menus/LocationManagerMenu.tsx
index 8cbbe1b79..98cf1731f 100644
--- a/src/renderer/components/menus/LocationManagerMenu.tsx
+++ b/src/renderer/components/menus/LocationManagerMenu.tsx
@@ -40,9 +40,10 @@ import ListItemText from '@mui/material/ListItemText';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import Links from 'assets/links';
-import { useState } from 'react';
+import { useContext, useState } from 'react';
import { useTranslation } from 'react-i18next';
import SidePanelTitle from '../SidePanelTitle';
+import { TS } from '-/tagspaces.namespace';
interface Props {
exportLocations: () => void;
@@ -56,9 +57,20 @@ function LocationManagerMenu(props: Props) {
const { createLocationsIndexes } = useLocationIndexContext();
const { closeAllLocations } = useCurrentLocationContext();
- const { openLinkDialog } = useLinkDialogContext();
+ //const { openLinkDialog } = useLinkDialogContext();
const [locationManagerMenuAnchorEl, setLocationManagerMenuAnchorEl] =
useState<null | HTMLElement>(null);
+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext
+ ? useContext<TS.WorkSpacesContextData>(
+ Pro.contextProviders.WorkSpacesContext,
+ )
+ : undefined;
+
+ const currentWorkSpace =
+ workSpacesContext && workSpacesContext.getCurrentWorkSpace
+ ? workSpacesContext?.getCurrentWorkSpace()
+ : undefined;
+
const menuItems = [];
if (!AppConfig.locationsReadOnly) {
menuItems.push(
@@ -152,7 +164,7 @@ function LocationManagerMenu(props: Props) {
data-tid="updateAllLocationIndexes"
onClick={() => {
setLocationManagerMenuAnchorEl(null);
- createLocationsIndexes();
+ createLocationsIndexes(true, currentWorkSpace);
}}
>
<ListItemIcon>
diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsx
index 12c9aae70..9dbe3f23c 100644
--- a/src/renderer/containers/Root.tsx
+++ b/src/renderer/containers/Root.tsx
@@ -15,154 +15,173 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
-
-import React, { useEffect, useState } from 'react';
-import { Provider } from 'react-redux';
-import { PersistGate } from 'redux-persist/integration/react';
-import { Store } from 'redux';
import AppConfig from '-/AppConfig';
-import { actions as AppActions } from '../reducers/app';
+import { FileUploadDialogContextProvider } from '-/components/dialogs/hooks/FileUploadDialogContextProvider';
import App from '-/containers/App';
+import DialogsRoot from '-/containers/DialogsRoot';
import MainPage from '-/containers/MainPage';
import TsAuth from '-/containers/TsAuth';
-import i18nInit from '-/services/i18nInit';
-import { OpenedEntryContextProvider } from '-/hooks/OpenedEntryContextProvider';
-import { DirectoryContentContextProvider } from '-/hooks/DirectoryContentContextProvider';
+import { BrowserHistoryContextProvider } from '-/hooks/BrowserHistoryContextProvider';
+import { ChatContextProvider } from '-/hooks/ChatProvider';
import { CurrentLocationContextProvider } from '-/hooks/CurrentLocationContextProvider';
-import { NotificationContextProvider } from '-/hooks/NotificationContextProvider';
-import { IOActionsContextProvider } from '-/hooks/IOActionsContextProvider';
-import { TaggingActionsContextProvider } from '-/hooks/TaggingActionsContextProvider';
-import { LocationIndexContextProvider } from '-/hooks/LocationIndexContextProvider';
-import { SelectedEntryContextProvider } from '-/hooks/SelectedEntryContextProvider';
-import { FSWatcherContextProvider } from '-/hooks/FSWatcherContextProvider';
-import { PlatformFacadeContextProvider } from '-/hooks/PlatformFacadeContextProvider';
+import { DirectoryContentContextProvider } from '-/hooks/DirectoryContentContextProvider';
import { EditedEntryContextProvider } from '-/hooks/EditedEntryContextProvider';
-import { HTML5Backend } from 'react-dnd-html5-backend';
-import { DndProvider } from 'react-dnd';
import { EditedEntryMetaContextProvider } from '-/hooks/EditedEntryMetaContextProvider';
-import { TagGroupsLocationContextProvider } from '-/hooks/TagGroupsLocationContextProvider';
import { EditedTagLibraryContextProvider } from '-/hooks/EditedTagLibraryContextProvider';
-import { PerspectiveActionsContextProvider } from '-/hooks/PerspectiveActionsContextProvider';
-import { Pro } from '-/pro';
+import { EntryPropsTabsContextProvider } from '-/hooks/EntryPropsTabsContextProvider';
import { ExtensionsContextProvider } from '-/hooks/ExtensionsContextProvider';
+import { FSWatcherContextProvider } from '-/hooks/FSWatcherContextProvider';
+import { FileUploadContextProvider } from '-/hooks/FileUploadContextProvider';
+import { HistoryContextProvider } from '-/hooks/HistoryContextProvider';
+import { IOActionsContextProvider } from '-/hooks/IOActionsContextProvider';
+import { LocationIndexContextProvider } from '-/hooks/LocationIndexContextProvider';
+import { NotificationContextProvider } from '-/hooks/NotificationContextProvider';
+import { OpenedEntryContextProvider } from '-/hooks/OpenedEntryContextProvider';
import { PanelsContextProvider } from '-/hooks/PanelsContextProvider';
-import { UserContextProvider } from '-/hooks/UserContextProvider';
+import { PerspectiveActionsContextProvider } from '-/hooks/PerspectiveActionsContextProvider';
+import { PlatformFacadeContextProvider } from '-/hooks/PlatformFacadeContextProvider';
import { SavedSearchesContextProvider } from '-/hooks/SavedSearchesContextProvider';
-import DialogsRoot from '-/containers/DialogsRoot';
-import { BrowserHistoryContextProvider } from '-/hooks/BrowserHistoryContextProvider';
-import { ChatContextProvider } from '-/hooks/ChatProvider';
-import { FileUploadDialogContextProvider } from '-/components/dialogs/hooks/FileUploadDialogContextProvider';
-import { EntryPropsTabsContextProvider } from '-/hooks/EntryPropsTabsContextProvider';
import { SearchQueryContextProvider } from '-/hooks/SearchQueryContextProvider';
-import { HistoryContextProvider } from '-/hooks/HistoryContextProvider';
-import { FileUploadContextProvider } from '-/hooks/FileUploadContextProvider';
+import { SelectedEntryContextProvider } from '-/hooks/SelectedEntryContextProvider';
+import { TagGroupsLocationContextProvider } from '-/hooks/TagGroupsLocationContextProvider';
+import { TaggingActionsContextProvider } from '-/hooks/TaggingActionsContextProvider';
+import { UserContextProvider } from '-/hooks/UserContextProvider';
+import { Pro } from '-/pro';
+import i18nInit from '-/services/i18nInit';
+import React, { useEffect, useMemo, useState } from 'react';
+import { DndProvider } from 'react-dnd';
+import { HTML5Backend } from 'react-dnd-html5-backend';
+import { Provider as ReduxProvider } from 'react-redux';
+import { Store } from 'redux';
+import { PersistGate } from 'redux-persist/integration/react';
+import { actions as AppActions } from '../reducers/app';
type RootType = {
store: Store<{}>;
- persistor: {};
+ persistor: any;
};
+/**
+ * Compose an array of providers (components that accept children) around children.
+ */
+function composeProviders(
+ providers: React.ComponentType<{ children?: React.ReactNode }>[],
+ children: React.ReactNode,
+) {
+ return providers.reduceRight<React.ReactNode>((acc, Provider) => {
+ return <Provider>{acc}</Provider>;
+ }, children);
+}
+
+/* Few small wrappers where provider needs props */
+const DndWrapper: React.FC<{ children?: React.ReactNode }> = ({ children }) => (
+ <DndProvider backend={HTML5Backend}>{children}</DndProvider>
+);
+
+/* The stack of Pro-only feature providers (WorkSpaces removed from here). */
+const ProFeatureStack: React.FC = () => (
+ <Pro.contextProviders.BookmarksContextProvider>
+ <Pro.contextProviders.KanBanImportDialogContextProvider>
+ <Pro.contextProviders.ThumbDialogContextProvider>
+ <Pro.contextProviders.BgndDialogContextProvider>
+ <Pro.contextProviders.AiTemplatesContextProvider>
+ <Pro.contextProviders.FileTemplatesContextProvider>
+ <Pro.contextProviders.WorkSpacesContextProvider>
+ <ChatContextProvider>
+ <DialogsRoot>
+ <MainPage />
+ </DialogsRoot>
+ </ChatContextProvider>
+ </Pro.contextProviders.WorkSpacesContextProvider>
+ </Pro.contextProviders.FileTemplatesContextProvider>
+ </Pro.contextProviders.AiTemplatesContextProvider>
+ </Pro.contextProviders.BgndDialogContextProvider>
+ </Pro.contextProviders.ThumbDialogContextProvider>
+ </Pro.contextProviders.KanBanImportDialogContextProvider>
+ </Pro.contextProviders.BookmarksContextProvider>
+);
+
+/* Non-pro fallback content */
+const NonProInner: React.FC = () => (
+ <ChatContextProvider>
+ <DialogsRoot>
+ <MainPage />
+ </DialogsRoot>
+ </ChatContextProvider>
+);
+
+/* Providers that are shared and can be composed programmatically */
+const SHARED_PROVIDERS = [
+ NotificationContextProvider,
+ CurrentLocationContextProvider,
+ EditedEntryContextProvider,
+ EditedEntryMetaContextProvider,
+ PerspectiveActionsContextProvider,
+ SelectedEntryContextProvider,
+ DirectoryContentContextProvider,
+ FSWatcherContextProvider,
+ PlatformFacadeContextProvider,
+ LocationIndexContextProvider,
+ IOActionsContextProvider,
+ EntryPropsTabsContextProvider,
+ OpenedEntryContextProvider,
+ TagGroupsLocationContextProvider,
+ EditedTagLibraryContextProvider,
+ TaggingActionsContextProvider,
+ DndWrapper, // wrapper that passes backend prop
+ ExtensionsContextProvider,
+ PanelsContextProvider,
+ UserContextProvider,
+ SavedSearchesContextProvider,
+ SearchQueryContextProvider,
+ BrowserHistoryContextProvider,
+ FileUploadContextProvider,
+ FileUploadDialogContextProvider,
+ HistoryContextProvider,
+] as React.ComponentType<any>[];
+
export default function Root({ store, persistor }: RootType) {
const [initialized, setInitialized] = useState(false);
useEffect(() => {
- // @ts-ignore
- const language: string = store.getState().settings.interfaceLanguage;
- i18nInit(language).then(() => setInitialized(true));
+ // Safe read of language setting; fall back to 'en' if anything is missing
+ try {
+ const language: string =
+ (store.getState() as any).settings?.interfaceLanguage ?? 'en';
+ i18nInit(language)
+ .then(() => setInitialized(true))
+ .catch(() => setInitialized(true));
+ } catch (err) {
+ // if anything goes wrong, still allow app to render
+ setInitialized(true);
+ }
+ // we intentionally run this once on mount
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
+ /**
+ * IMPORTANT: this hook must run on every render — even while `initialized` is false —
+ * otherwise hook order will change between renders and React will throw.
+ *
+ * If `Pro` can change at runtime, include it in deps: [Pro] (but usually it's static).
+ */
+ const appInner = useMemo(() => {
+ const inner = Pro ? <ProFeatureStack /> : <NonProInner />;
+ return composeProviders(SHARED_PROVIDERS, inner);
+ }, []); // keep empty if Pro is static; add [Pro] if Pro can change during runtime
+
if (!initialized) {
return <span />;
}
- let appContent = (
- <App>
- <NotificationContextProvider>
- <CurrentLocationContextProvider>
- <EditedEntryContextProvider>
- <EditedEntryMetaContextProvider>
- <PerspectiveActionsContextProvider>
- <SelectedEntryContextProvider>
- <DirectoryContentContextProvider>
- <FSWatcherContextProvider>
- <PlatformFacadeContextProvider>
- <LocationIndexContextProvider>
- <IOActionsContextProvider>
- <EntryPropsTabsContextProvider>
- <OpenedEntryContextProvider>
- <TagGroupsLocationContextProvider>
- <EditedTagLibraryContextProvider>
- <TaggingActionsContextProvider>
- <DndProvider backend={HTML5Backend}>
- <ExtensionsContextProvider>
- <PanelsContextProvider>
- <UserContextProvider>
- <SavedSearchesContextProvider>
- <SearchQueryContextProvider>
- <BrowserHistoryContextProvider>
- <FileUploadContextProvider>
- <FileUploadDialogContextProvider>
- <HistoryContextProvider>
- {Pro ? (
- <Pro.contextProviders.BookmarksContextProvider>
- <Pro.contextProviders.KanBanImportDialogContextProvider>
- <Pro.contextProviders.ThumbDialogContextProvider>
- <Pro.contextProviders.BgndDialogContextProvider>
- <Pro.contextProviders.AiTemplatesContextProvider>
- <Pro.contextProviders.FileTemplatesContextProvider>
- <ChatContextProvider>
- <DialogsRoot>
- <MainPage />
- </DialogsRoot>
- </ChatContextProvider>
- </Pro.contextProviders.FileTemplatesContextProvider>
- </Pro.contextProviders.AiTemplatesContextProvider>
- </Pro.contextProviders.BgndDialogContextProvider>
- </Pro.contextProviders.ThumbDialogContextProvider>
- </Pro.contextProviders.KanBanImportDialogContextProvider>
- </Pro.contextProviders.BookmarksContextProvider>
- ) : (
- <ChatContextProvider>
- <DialogsRoot>
- <MainPage />
- </DialogsRoot>
- </ChatContextProvider>
- )}
- </HistoryContextProvider>
- </FileUploadDialogContextProvider>
- </FileUploadContextProvider>
- </BrowserHistoryContextProvider>
- </SearchQueryContextProvider>
- </SavedSearchesContextProvider>
- </UserContextProvider>
- </PanelsContextProvider>
- </ExtensionsContextProvider>
- </DndProvider>
- </TaggingActionsContextProvider>
- </EditedTagLibraryContextProvider>
- </TagGroupsLocationContextProvider>
- </OpenedEntryContextProvider>
- </EntryPropsTabsContextProvider>
- </IOActionsContextProvider>
- </LocationIndexContextProvider>
- </PlatformFacadeContextProvider>
- </FSWatcherContextProvider>
- </DirectoryContentContextProvider>
- </SelectedEntryContextProvider>
- </PerspectiveActionsContextProvider>
- </EditedEntryMetaContextProvider>
- </EditedEntryContextProvider>
- </CurrentLocationContextProvider>
- </NotificationContextProvider>
- </App>
- );
+ let appContent = <App>{appInner}</App>;
if (AppConfig.isWeb) {
appContent = <TsAuth>{appContent}</TsAuth>;
}
return (
- <Provider
+ <ReduxProvider
// @ts-ignore
store={store}
>
@@ -188,6 +207,6 @@ export default function Root({ store, persistor }: RootType) {
>
{appContent}
</PersistGate>
- </Provider>
+ </ReduxProvider>
);
}
diff --git a/src/renderer/hooks/CurrentLocationContextProvider.tsx b/src/renderer/hooks/CurrentLocationContextProvider.tsx
index 09a7fe1f9..a4c29dc09 100644
--- a/src/renderer/hooks/CurrentLocationContextProvider.tsx
+++ b/src/renderer/hooks/CurrentLocationContextProvider.tsx
@@ -153,7 +153,6 @@ export const CurrentLocationContextProvider = ({
setLocationDirectoryContextMenuAnchorEl,
] = useState<null | HTMLElement>(null);
const broadcast = new BroadcastChannel('ts-sync-channel');
- // Generate a unique ID for the tab
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
diff --git a/src/renderer/hooks/LocationIndexContextProvider.tsx b/src/renderer/hooks/LocationIndexContextProvider.tsx
index 932cce994..302cc4c1e 100644
--- a/src/renderer/hooks/LocationIndexContextProvider.tsx
+++ b/src/renderer/hooks/LocationIndexContextProvider.tsx
@@ -60,10 +60,16 @@ type LocationIndexContextData = {
location: CommonLocation,
force?: boolean,
) => Promise<boolean>;
- createLocationsIndexes: (extractText?: boolean) => Promise<boolean>;
+ createLocationsIndexes: (
+ extractText?: boolean,
+ workSpace?: TS.WorkSpace,
+ ) => Promise<boolean>;
clearDirectoryIndex: (persist?: boolean) => void;
searchLocationIndex: (searchQuery: TS.SearchQuery) => void;
- searchAllLocations: (searchQuery: TS.SearchQuery) => void;
+ searchAllLocations: (
+ searchQuery: TS.SearchQuery,
+ workSpace?: TS.WorkSpace,
+ ) => void;
setIndex: (i: TS.FileSystemEntry[], location?: CommonLocation) => void;
//indexUpdateSidecarTags: (path: string, tags: Array<TS.Tag>) => void;
reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;
@@ -562,9 +568,15 @@ export const LocationIndexContextProvider = ({
});
}
- async function createLocationsIndexes(extractText = true): Promise<boolean> {
+ async function createLocationsIndexes(
+ extractText = true,
+ workSpace: TS.WorkSpace = undefined,
+ ): Promise<boolean> {
walkingRef.current = true;
- for (let location of locations) {
+ const searchingLocation = workSpace
+ ? locations.filter((l) => l.workSpaceId === workSpace.uuid)
+ : locations;
+ for (let location of searchingLocation) {
try {
if (!location.disableIndexing) {
const locationPath = await getLocationPath(location);
@@ -758,7 +770,10 @@ export const LocationIndexContextProvider = ({
}, 50);
}
- function searchAllLocations(searchQuery: TS.SearchQuery) {
+ function searchAllLocations(
+ searchQuery: TS.SearchQuery,
+ workSpace: TS.WorkSpace = undefined,
+ ) {
console.time('globalSearch');
setSearchResults([]);
showNotification(t('core:searching'), 'default', false, 'TIDSearching');
@@ -767,8 +782,10 @@ export const LocationIndexContextProvider = ({
//let searchResultCount = 0;
let searchResults = [];
let maxSearchResultReached = false;
-
- const result = locations.reduce(
+ const searchingLocation = workSpace
+ ? locations.filter((l) => l.workSpaceId === workSpace.uuid)
+ : locations;
+ const result = searchingLocation.reduce(
(accumulatorPromise, location) =>
accumulatorPromise.then(async () => {
// cancel search if max search result count reached
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index e0a0e6fe2..c00a19eac 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -1032,7 +1032,16 @@
"ptsWhySection2": "Upgrade to Pro and supercharge TagSpaces with advanced search, unique perspectives for effortless organization, and powerful geo-tagging. Discover how these features can transform your workflow in the slides ahead.",
"ptsKanbanTitle": "Kanban Perspective in TagSpaces Pro",
"ptsKanban": "This perspective turns any folder into a fully functional Kanban board. Subfolders become columns, and the files inside them are displayed as cards that can be easily moved between columns using drag and drop. Entire columns can also be rearranged in the same way. Plus, with the built-in Trello import, you can bring exported Trello boards directly into your workspace.",
-
"pts": "",
+ "workspaces": "Workspaces",
+ "workspace": "Workspace",
+ "currentWorkspace": "Current Workspace",
+ "allWorkspaces": "All",
+ "addWorkspace": "Add Workspace",
+ "fullName": "Full name",
+ "shortName": "Short name",
+ "shortNameRequired": "Short name required",
+ "shortNameMaxLength": "Short name should be max. 5 characters",
+ "fullNameRequired": "Full name required",
"-": "-"
}
diff --git a/src/renderer/services/taglibrary-utils.ts b/src/renderer/services/taglibrary-utils.ts
index 1543757cb..b5aacd9ed 100644
--- a/src/renderer/services/taglibrary-utils.ts
+++ b/src/renderer/services/taglibrary-utils.ts
@@ -35,10 +35,18 @@ export function setTagLibrary(tagGroups: TS.TagGroup[]) {
}
}
-export function getAllTags(tagGroups?: Array<TS.TagGroup>) {
+export function getAllTags(
+ tagGroups?: Array<TS.TagGroup>,
+ currentWorkSpace?: TS.WorkSpace,
+) {
if (tagGroups === undefined) {
tagGroups = getTagLibrary();
}
+ if (currentWorkSpace) {
+ tagGroups = tagGroups.filter(
+ (t) => t.workSpaceId === currentWorkSpace.uuid,
+ );
+ }
const uniqueTags: TS.Tag[] = [];
tagGroups.forEach((tagGroup) => {
tagGroup?.children.forEach((tag) => {
diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.ts
index 75a173d9c..4e798fad7 100644
--- a/src/renderer/services/utils-io.ts
+++ b/src/renderer/services/utils-io.ts
@@ -1251,6 +1251,7 @@ export function toTsLocation(location: CommonLocation): TS.S3Location {
uuid: location.uuid || getUuid(),
name: location.name,
type: location.type,
+ ...(location.workSpaceId && { workSpaceId: location.workSpaceId }),
...(location.authType && { authType: location.authType }),
...(location.username && { username: location.username }),
...(location.password && { password: location.password }),
diff --git a/src/renderer/tagspaces.d.ts b/src/renderer/tagspaces.d.ts
index 0e30fb1bf..0b2a7c182 100644
--- a/src/renderer/tagspaces.d.ts
+++ b/src/renderer/tagspaces.d.ts
@@ -88,6 +88,7 @@ declare interface Window {
ExtTagsFromImagePrompt?: string;
ExtFileTemplates?: Array<any>;
ExtDefaultFileTemplate?: any;
+ ExtWorkSpaces?: Array<any>;
ExtAuthor?: string;
}
diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.ts
index 490fca37d..ece9c0efa 100644
--- a/src/renderer/tagspaces.namespace.d.ts
+++ b/src/renderer/tagspaces.namespace.d.ts
@@ -20,10 +20,16 @@ import { ScopeType } from '-/components/SearchOptions';
import AWS from 'aws-sdk';
export namespace TS {
+ interface WorkSpace {
+ uuid: string;
+ shortName: string;
+ fullName: string;
+ }
interface Location {
uuid: string;
newuuid?: string;
name: string;
+ workSpaceId?: string;
type: string; // 0 - local; 1 - S3; 2 - amplify; 3 - webdav
authType?: string; // none,password,digest,token
username?: string;
@@ -169,6 +175,7 @@ export namespace TS {
uuid: Uuid;
title: string;
locationId?: Uuid;
+ workSpaceId?: string;
expanded?: boolean;
description?: string;
categoryId?: string;
@@ -342,6 +349,16 @@ export namespace TS {
delTemplate: (id: string) => void;
};
+ type WorkSpacesContextData = {
+ getWorkSpace: (id: string) => WorkSpace | undefined;
+ setWorkSpace: (wSpace: WorkSpace) => void;
+ delWorkSpace: (id: string) => void;
+ getWorkSpaces: () => WorkSpace[];
+ setCurrentWorkSpaceId: (wSpaceId: string) => void;
+ getCurrentWorkSpace: () => TS.WorkSpace;
+ openNewWorkspaceDialog: (workSpace?: TS.WorkSpace) => void;
+ };
+
interface EditedEntryPath {
action: EditedEntryAction;
path: string;
diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.ts
index c682eb4b4..d28e313d2 100644
--- a/src/renderer/utils/CommonLocation.ts
+++ b/src/renderer/utils/CommonLocation.ts
@@ -24,6 +24,7 @@ export class CommonLocation implements TS.Location {
uuid: string;
newuuid?: string;
name: string;
+ workSpaceId?: string;
type: string; // 0 - local; 1 - S3; 2 - amplify; 3 - webdav
authType?: string; // none,password,digest,token
username?: string;
@@ -60,6 +61,7 @@ export class CommonLocation implements TS.Location {
constructor(location: TS.Location) {
this.uuid = location.uuid;
+ this.workSpaceId = location.workSpaceId;
this.newuuid = location.newuuid;
this.name = location.name;
this.type = location.type; // 0 - local; 1 - S3; 2 - amplify; 3 - webdav