Skip to content

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

Add-switch-placing-file-name-tags-in-front-of-the-file-name (#2113)

Stanimir69acf275822b
diff --git a/package-lock.json b/package-lock.json
index 165b0cb96..18e779d47 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,10 +19,10 @@
"@mui/lab": "5.0.0-alpha.170",
"@mui/material": "^5.15.19",
"@mui/x-date-pickers": "^5.0.20",
- "@tagspaces/tagspaces-common": "4.3.18",
- "@tagspaces/tagspaces-common-aws3": "4.3.18",
- "@tagspaces/tagspaces-common-cordova": "4.3.18",
- "@tagspaces/tagspaces-indexer": "4.3.18",
+ "@tagspaces/tagspaces-common": "4.3.20",
+ "@tagspaces/tagspaces-common-aws3": "4.3.20",
+ "@tagspaces/tagspaces-common-cordova": "4.3.20",
+ "@tagspaces/tagspaces-indexer": "4.3.20",
"@tagspaces/tagspaces-md": "4.3.19",
"aws-amplify": "^4.3.8",
"aws-sdk": "^2.1036.0",
@@ -13741,9 +13741,9 @@
}
},
"node_modules/@tagspaces/tagspaces-common": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.3.18.tgz",
- "integrity": "sha512-Plw8h2lXzzFL37l8tlH91YaC/5Avh/bVMMrllDQT+0B5yN7xkCxa999G64H7uR22WSo5hIJrnF+3kAuDTFWM7w==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.3.20.tgz",
+ "integrity": "sha512-+2VOdMRq1Wvxx/9jzWyffh0UWYkClVnBlcLmWn/EJOf+T0QKEhsFJy4zU2stK6TD33ThHb8tiE4R8kRIMjIHWw==",
"dependencies": {
"dotenv": "^16.0.2",
"picomatch": "^3.0.1",
@@ -13751,11 +13751,11 @@
}
},
"node_modules/@tagspaces/tagspaces-common-aws3": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-aws3/-/tagspaces-common-aws3-4.3.18.tgz",
- "integrity": "sha512-pjhAkcmRJ0hBvv/EF3y/3nss8eVr+N7yhJ++5tBCrPTch6bWo/JCD6if7OTww1aVnF6AZ54g5E14k/ZMwQUWjw==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-aws3/-/tagspaces-common-aws3-4.3.20.tgz",
+ "integrity": "sha512-guPI1fMN/ue+KQXVOXxoCbneTTluNoWE/EERZcUexWEb5ICbbGeM717LOo9gQdQsDYgcLpl0txSuzVG+/GubgQ==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.3.18",
+ "@tagspaces/tagspaces-common": "^4.3.20",
"aws-sdk": "2.1605.0"
}
},
@@ -13811,11 +13811,11 @@
}
},
"node_modules/@tagspaces/tagspaces-common-cordova": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-cordova/-/tagspaces-common-cordova-4.3.18.tgz",
- "integrity": "sha512-tN4Cdl26xX6reSGK/oun431KUMhRLyqwcVNYBm57KfR2xVuE+bYkNd/tZmBzj050uERs2XJU5+Hz4qPb5Ya4zA==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-cordova/-/tagspaces-common-cordova-4.3.20.tgz",
+ "integrity": "sha512-MiTy0XtjsgvRiTPgKcfEAWL1Sq2c5b8i4eQLVDkd4S8QK0+ODxCpvnkaMXdSUGdiUqEVIDI4Vh7go2mVAlD9DQ==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.3.18"
+ "@tagspaces/tagspaces-common": "^4.3.20"
}
},
"node_modules/@tagspaces/tagspaces-common/node_modules/uuid": {
@@ -13827,11 +13827,11 @@
}
},
"node_modules/@tagspaces/tagspaces-indexer": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.3.18.tgz",
- "integrity": "sha512-rosxOzNIpm9tqApIbRRIYxx0nEGolg21j6nivQ6umnLqzCQKjq8dbvl5eqNrgkV9nn8UnyGl6uGJAHHvS9f+aQ==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-indexer/-/tagspaces-indexer-4.3.20.tgz",
+ "integrity": "sha512-w9kp1F+rv9hCk+8SAnWC4O4d3SuIBFv282ztcxw+mT/KC7MnNzf/g9DsuAqTvquPhJSPHDHpVW8x77zQYRpS1Q==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.3.18"
+ "@tagspaces/tagspaces-common": "^4.3.20"
}
},
"node_modules/@tagspaces/tagspaces-md": {
diff --git a/package.json b/package.json
index b5149ae43..889079800 100644
--- a/package.json
+++ b/package.json
@@ -160,10 +160,10 @@
"@mui/lab": "5.0.0-alpha.170",
"@mui/material": "^5.15.19",
"@mui/x-date-pickers": "^5.0.20",
- "@tagspaces/tagspaces-common": "4.3.18",
- "@tagspaces/tagspaces-common-aws3": "4.3.18",
- "@tagspaces/tagspaces-common-cordova": "4.3.18",
- "@tagspaces/tagspaces-indexer": "4.3.18",
+ "@tagspaces/tagspaces-common": "4.3.20",
+ "@tagspaces/tagspaces-common-aws3": "4.3.20",
+ "@tagspaces/tagspaces-common-cordova": "4.3.20",
+ "@tagspaces/tagspaces-indexer": "4.3.20",
"@tagspaces/tagspaces-md": "4.3.19",
"aws-amplify": "^4.3.8",
"aws-sdk": "^2.1036.0",
diff --git a/release/app/package-lock.json b/release/app/package-lock.json
index cc0bbb7c6..df3e3ba9c 100644
--- a/release/app/package-lock.json
+++ b/release/app/package-lock.json
@@ -12,8 +12,8 @@
"dependencies": {
"@elife/pm2": "3.6.1",
"@tagspaces/extensions": "1.0.118",
- "@tagspaces/tagspaces-common-node": "4.3.18",
- "@tagspaces/tagspaces-ws": "4.3.19",
+ "@tagspaces/tagspaces-common-node": "4.3.20",
+ "@tagspaces/tagspaces-ws": "4.3.20",
"sharp": "0.32.6",
"ws": "8.16.0"
},
@@ -43,9 +43,9 @@
}
},
"node_modules/@tagspaces/tagspaces-common": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.3.18.tgz",
- "integrity": "sha512-Plw8h2lXzzFL37l8tlH91YaC/5Avh/bVMMrllDQT+0B5yN7xkCxa999G64H7uR22WSo5hIJrnF+3kAuDTFWM7w==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.3.20.tgz",
+ "integrity": "sha512-+2VOdMRq1Wvxx/9jzWyffh0UWYkClVnBlcLmWn/EJOf+T0QKEhsFJy4zU2stK6TD33ThHb8tiE4R8kRIMjIHWw==",
"dependencies": {
"dotenv": "^16.0.2",
"picomatch": "^3.0.1",
@@ -53,11 +53,11 @@
}
},
"node_modules/@tagspaces/tagspaces-common-node": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.3.18.tgz",
- "integrity": "sha512-bMCkbs58Os8vIns/370tDVwJSgUwCq+2V5+MWUABK5vL4y+bmcxwjAJMF2QsKAjnpMgTcqPBMu1yVoNus3aD6A==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.3.20.tgz",
+ "integrity": "sha512-VOENbbu/Usg65pHQPSmljCX/8oAzfSPLMOgWpGRK57uUKutkcnCxN9gdcBv3dQRO0KjRi3yk6geuHTzn2i++lA==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.3.18",
+ "@tagspaces/tagspaces-common": "^4.3.20",
"adm-zip": "0.5.10",
"fs-extra": "^10.0.0",
"klaw": "^4.1.0",
@@ -74,22 +74,22 @@
}
},
"node_modules/@tagspaces/tagspaces-workers": {
- "version": "4.3.19",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.3.19.tgz",
- "integrity": "sha512-XnmuD19S03vk1OHIk6ZNTC/rNEpVmXFUDwyhyWOF+bnH5I+b1bmNJudPfNIc5HXdQ9769QSESUoX25EF/iBZtQ==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.3.20.tgz",
+ "integrity": "sha512-slBLjUJ+aYsWCHDAJj3GLaT8giY2DgF5ohzgjWxJYYNaDpp69G0Az7wdz5D4wvyALhspAxlLWRugIqllTYWibw==",
"dependencies": {
- "@tagspaces/tagspaces-common": "^4.3.18",
- "@tagspaces/tagspaces-common-node": "^4.3.18",
+ "@tagspaces/tagspaces-common": "^4.3.20",
+ "@tagspaces/tagspaces-common-node": "^4.3.20",
"@tagspaces/tagspaces-thumbgen-image": "^4.2.3",
"fswin": "^3.24.524"
}
},
"node_modules/@tagspaces/tagspaces-ws": {
- "version": "4.3.19",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.3.19.tgz",
- "integrity": "sha512-oc64g0gJ29nXdG8mG5lEP/AfEXLIZNvWq0hItE6AqJdFznBcw1aT061711iSc8KTeWfZzy63ZC5fCvPN5mdAag==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.3.20.tgz",
+ "integrity": "sha512-b4TJMiKanHxW6L2RNQAh3grD/B9v2G5o3TPiw3ceErlBaLEJTQ+7sAemNN24Jxoh7gNQNiXLvFvvwmhg7QFp1w==",
"dependencies": {
- "@tagspaces/tagspaces-workers": "^4.3.19",
+ "@tagspaces/tagspaces-workers": "^4.3.20",
"find-free-ports": "^3.1.1",
"jsonwebtoken": "^8.5.1",
"ws": "^8.15.1"
@@ -1131,9 +1131,9 @@
}
},
"@tagspaces/tagspaces-common": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.3.18.tgz",
- "integrity": "sha512-Plw8h2lXzzFL37l8tlH91YaC/5Avh/bVMMrllDQT+0B5yN7xkCxa999G64H7uR22WSo5hIJrnF+3kAuDTFWM7w==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common/-/tagspaces-common-4.3.20.tgz",
+ "integrity": "sha512-+2VOdMRq1Wvxx/9jzWyffh0UWYkClVnBlcLmWn/EJOf+T0QKEhsFJy4zU2stK6TD33ThHb8tiE4R8kRIMjIHWw==",
"requires": {
"dotenv": "^16.0.2",
"picomatch": "^3.0.1",
@@ -1141,11 +1141,11 @@
}
},
"@tagspaces/tagspaces-common-node": {
- "version": "4.3.18",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.3.18.tgz",
- "integrity": "sha512-bMCkbs58Os8vIns/370tDVwJSgUwCq+2V5+MWUABK5vL4y+bmcxwjAJMF2QsKAjnpMgTcqPBMu1yVoNus3aD6A==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-common-node/-/tagspaces-common-node-4.3.20.tgz",
+ "integrity": "sha512-VOENbbu/Usg65pHQPSmljCX/8oAzfSPLMOgWpGRK57uUKutkcnCxN9gdcBv3dQRO0KjRi3yk6geuHTzn2i++lA==",
"requires": {
- "@tagspaces/tagspaces-common": "^4.3.18",
+ "@tagspaces/tagspaces-common": "^4.3.20",
"adm-zip": "0.5.10",
"fs-extra": "^10.0.0",
"klaw": "^4.1.0",
@@ -1162,22 +1162,22 @@
}
},
"@tagspaces/tagspaces-workers": {
- "version": "4.3.19",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.3.19.tgz",
- "integrity": "sha512-XnmuD19S03vk1OHIk6ZNTC/rNEpVmXFUDwyhyWOF+bnH5I+b1bmNJudPfNIc5HXdQ9769QSESUoX25EF/iBZtQ==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-workers/-/tagspaces-workers-4.3.20.tgz",
+ "integrity": "sha512-slBLjUJ+aYsWCHDAJj3GLaT8giY2DgF5ohzgjWxJYYNaDpp69G0Az7wdz5D4wvyALhspAxlLWRugIqllTYWibw==",
"requires": {
- "@tagspaces/tagspaces-common": "^4.3.18",
- "@tagspaces/tagspaces-common-node": "^4.3.18",
+ "@tagspaces/tagspaces-common": "^4.3.20",
+ "@tagspaces/tagspaces-common-node": "^4.3.20",
"@tagspaces/tagspaces-thumbgen-image": "^4.2.3",
"fswin": "^3.24.524"
}
},
"@tagspaces/tagspaces-ws": {
- "version": "4.3.19",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.3.19.tgz",
- "integrity": "sha512-oc64g0gJ29nXdG8mG5lEP/AfEXLIZNvWq0hItE6AqJdFznBcw1aT061711iSc8KTeWfZzy63ZC5fCvPN5mdAag==",
+ "version": "4.3.20",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-ws/-/tagspaces-ws-4.3.20.tgz",
+ "integrity": "sha512-b4TJMiKanHxW6L2RNQAh3grD/B9v2G5o3TPiw3ceErlBaLEJTQ+7sAemNN24Jxoh7gNQNiXLvFvvwmhg7QFp1w==",
"requires": {
- "@tagspaces/tagspaces-workers": "^4.3.19",
+ "@tagspaces/tagspaces-workers": "^4.3.20",
"find-free-ports": "^3.1.1",
"jsonwebtoken": "^8.5.1",
"ws": "^8.15.1"
diff --git a/release/app/package.json b/release/app/package.json
index 83eb89a20..625e3b0cc 100644
--- a/release/app/package.json
+++ b/release/app/package.json
@@ -19,8 +19,8 @@
"dependencies": {
"@elife/pm2": "3.6.1",
"@tagspaces/extensions": "1.0.118",
- "@tagspaces/tagspaces-common-node": "4.3.18",
- "@tagspaces/tagspaces-ws": "4.3.19",
+ "@tagspaces/tagspaces-common-node": "4.3.20",
+ "@tagspaces/tagspaces-ws": "4.3.20",
"sharp": "0.32.6",
"ws": "8.16.0"
},
diff --git a/src/renderer/components/dialogs/settings/SettingsGeneral.tsx b/src/renderer/components/dialogs/settings/SettingsGeneral.tsx
index 4a6863a49..477ac9f30 100644
--- a/src/renderer/components/dialogs/settings/SettingsGeneral.tsx
+++ b/src/renderer/components/dialogs/settings/SettingsGeneral.tsx
@@ -36,6 +36,7 @@ import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import AppConfig from '-/AppConfig';
import {
actions as SettingsActions,
+ getFileNameTagPlace,
getPersistTagsInSidecarFile,
//getCurrentLanguage,
getSettings,
@@ -86,6 +87,7 @@ function SettingsGeneral() {
const dispatch: AppDispatch = useDispatch();
const settings = useSelector(getSettings);
const persistTagsInSidecarFile = useSelector(getPersistTagsInSidecarFile);
+ const filenameTagPlacedAtEnd = useSelector(getFileNameTagPlace);
const toggleDefaultTagBackgroundColorPicker = () => {
setDisplayColorPicker(!displayColorPicker);
@@ -270,6 +272,63 @@ function SettingsGeneral() {
</ToggleButtonGroup>
)}
</ListItem>
+ {!persistTagsInSidecarFile && (
+ <ListItem
+ className={classes.listItem}
+ title={t('core:fileNameTagPlaceTitle')}
+ >
+ <ListItemText primary={t('core:fileNameTagSetting')} />
+ <ToggleButtonGroup
+ value={filenameTagPlacedAtEnd}
+ size="small"
+ exclusive
+ >
+ <ToggleButton
+ value={false}
+ data-tid="fileNameBeginningTagTID"
+ onClick={() =>
+ dispatch(SettingsActions.setFileNameTagPlace(false))
+ }
+ >
+ <Tooltip
+ title={
+ <Typography color="inherit">
+ {t('core:fileNameBeginTagPlaceExplanation')}
+ </Typography>
+ }
+ >
+ <div style={{ display: 'flex' }}>
+ {!filenameTagPlacedAtEnd && <CheckIcon />}
+ &nbsp;{t('core:atTheBeginningOfFileName')}&nbsp;&nbsp;
+ <InfoMuiIcon />
+ </div>
+ </Tooltip>
+ </ToggleButton>
+ <ToggleButton
+ value={true}
+ data-tid="fileNameEndTagTID"
+ onClick={() =>
+ dispatch(SettingsActions.setFileNameTagPlace(true))
+ }
+ >
+ <Tooltip
+ title={
+ <Typography color="inherit">
+ {t('core:fileNameEndTagPlaceExplanation')}
+ </Typography>
+ }
+ >
+ <div style={{ display: 'flex' }}>
+ {filenameTagPlacedAtEnd && <CheckIcon />}
+ &nbsp;{t('core:filenameTagPlacedAtEnd')}&nbsp;&nbsp;
+ <InfoMuiIcon />
+ </div>
+ </Tooltip>
+ </ToggleButton>
+ </ToggleButtonGroup>
+ </ListItem>
+ )}
+
<ListItem className={classes.listItem}>
<ListItemText primary={t('core:checkForNewVersionOnStartup')} />
<Switch
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index 2d6386ea1..2300b1b70 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -38,7 +38,7 @@ import {
extractTags,
cleanTrailingDirSeparator,
cleanFrontDirSeparator,
- extractFileExtension,
+ generateFileName,
} from '@tagspaces/tagspaces-common/paths';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
@@ -46,7 +46,6 @@ import { useDispatch, useSelector } from 'react-redux';
import {
cleanMetaData,
executePromisesInBatches,
- generateFileName,
mergeFsEntryMeta,
openDirectoryMessage,
openFileMessage,
@@ -65,6 +64,7 @@ import {
} from '@tagspaces/tagspaces-common/utils-io';
import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
import {
+ getFileNameTagPlace,
getPrefixTagContainer,
getWarningOpeningFilesExternally,
} from '-/reducers/settings';
@@ -283,6 +283,7 @@ export const IOActionsContextProvider = ({
getWarningOpeningFilesExternally,
);
const prefixTagContainer = useSelector(getPrefixTagContainer);
+ const filenameTagPlacedAtEnd = useSelector(getFileNameTagPlace);
useEffect(() => {
if (actions && actions.length > 0) {
@@ -1394,6 +1395,7 @@ export const IOActionsContextProvider = ({
AppConfig.tagDelimiter,
currentLocation?.getDirSeparator(),
prefixTagContainer,
+ filenameTagPlacedAtEnd,
),
);
@@ -2020,7 +2022,11 @@ export const IOActionsContextProvider = ({
getFilesOrder,
pushFileOrder,
};
- }, [warningOpeningFilesExternally, currentDirectoryPath]);
+ }, [
+ warningOpeningFilesExternally,
+ currentDirectoryPath,
+ filenameTagPlacedAtEnd,
+ ]);
return (
<IOActionsContext.Provider value={context}>
diff --git a/src/renderer/hooks/TaggingActionsContextProvider.tsx b/src/renderer/hooks/TaggingActionsContextProvider.tsx
index 8ca161ae6..998c0e8e6 100644
--- a/src/renderer/hooks/TaggingActionsContextProvider.tsx
+++ b/src/renderer/hooks/TaggingActionsContextProvider.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { createContext, useEffect, useMemo } from 'react';
+import React, { createContext, useMemo } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
import mgrs from 'mgrs';
@@ -32,6 +32,7 @@ import { getTagLibrary, setTagLibrary } from '-/services/taglibrary-utils';
import { isGeoTag } from '-/utils/geo';
import {
getAddTagsToLibrary,
+ getFileNameTagPlace,
getGeoTaggingFormat,
getPrefixTagContainer,
getSaveTagInLocation,
@@ -39,11 +40,12 @@ import {
getTagDelimiter,
getTagTextColor,
} from '-/reducers/settings';
-import { generateFileName, parseNewTags } from '-/services/utils-io';
+import { parseNewTags } from '-/services/utils-io';
import {
extractContainingDirectoryPath,
extractFileName,
extractTags,
+ generateFileName,
} from '@tagspaces/tagspaces-common/paths';
import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { useNotificationContext } from '-/hooks/useNotificationContext';
@@ -172,6 +174,7 @@ export const TaggingActionsContextProvider = ({
const prefixTagContainer: boolean = useSelector(getPrefixTagContainer);
//const locations: CommonLocation[] = useSelector(getLocations);
const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);
+ const filenameTagPlacedAtEnd = useSelector(getFileNameTagPlace);
function extractContent(
options: extractOptions = {
@@ -228,6 +231,7 @@ export const TaggingActionsContextProvider = ({
tagDelimiter,
currentLocation?.getDirSeparator(),
prefixTagContainer,
+ filenameTagPlacedAtEnd,
)
);
}
@@ -653,6 +657,7 @@ export const TaggingActionsContextProvider = ({
tagDelimiter,
currentLocation?.getDirSeparator(),
prefixTagContainer,
+ filenameTagPlacedAtEnd,
);
if (newFileName !== fileName) {
await renameFile(
@@ -943,6 +948,7 @@ export const TaggingActionsContextProvider = ({
tagDelimiter,
currentLocation?.getDirSeparator(),
prefixTagContainer,
+ filenameTagPlacedAtEnd,
);
if (path !== newFilePath) {
const success = await renameFile(
@@ -1477,6 +1483,7 @@ export const TaggingActionsContextProvider = ({
addTagsToLibrary,
currentDirectoryEntries,
saveTagInLocation,
+ filenameTagPlacedAtEnd,
]);
return (
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index df9dd57ae..879b11b45 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -822,5 +822,11 @@
"newVersionAvailable": "New version available",
"urlNotSupported": "URL not supported",
"indexing": "Indexing",
+ "fileNameTagSetting": "Place of the tags in the file name",
+ "fileNameTagPlaceTitle": "Choose File name tag place",
+ "atTheBeginningOfFileName": "Beginning",
+ "filenameTagPlacedAtEnd": "End",
+ "fileNameBeginTagPlaceExplanation": "Tags will appears at start of the file name",
+ "fileNameEndTagPlaceExplanation": "Tags will appears at end of the file name",
"-": "-"
}
diff --git a/src/renderer/reducers/settings-default.ts b/src/renderer/reducers/settings-default.ts
index 38830b862..01e30054e 100644
--- a/src/renderer/reducers/settings-default.ts
+++ b/src/renderer/reducers/settings-default.ts
@@ -32,6 +32,10 @@ let checkForUpdates = true;
if (window.ExtCheckForUpdatesOnStartup !== undefined) {
checkForUpdates = window.ExtCheckForUpdatesOnStartup;
}
+let filenameTagPlacedAtEnd = true;
+if (window.ExtFilenameTagPlacedAtEnd !== undefined) {
+ filenameTagPlacedAtEnd = window.ExtFilenameTagPlacedAtEnd;
+}
export default {
//isLoading: false,
@@ -69,6 +73,7 @@ export default {
lastOpenedLocation: '',
useDefaultLocation: false, // TODO for remove
persistTagsInSidecarFile: false, // old name writeMetaToSidecarFile -> persistTagsInSidecarFile
+ filenameTagPlacedAtEnd,
addTagsToLibrary: true,
interfaceLanguage: 'en',
useTrashCan: true,
diff --git a/src/renderer/reducers/settings.ts b/src/renderer/reducers/settings.ts
index dc42a6891..cbd21f050 100644
--- a/src/renderer/reducers/settings.ts
+++ b/src/renderer/reducers/settings.ts
@@ -63,6 +63,7 @@ export const types = {
SET_CALCULATETAGS: 'SETTINGS/SET_CALCULATETAGS',
SET_USETRASHCAN: 'SETTINGS/SET_USETRASHCAN',
SET_PERSISTTAGSINSIDECARFILE: 'SETTINGS/SET_PERSISTTAGSINSIDECARFILE',
+ SET_FILENAMETAGPLACEDATEND: 'SETTINGS/SET_FILENAMETAGPLACEDATEND',
SET_ADDTAGSTOLIBRARY: 'SETTINGS/SET_ADDTAGSTOLIBRARY',
SET_REVISIONS_ENABLED: 'SETTINGS/SET_REVISIONS_ENABLED',
SET_PREFIX_TAG_CONTAINER: 'SETTINGS/SET_PREFIX_TAG_CONTAINER',
@@ -235,6 +236,12 @@ export default (state: any = defaultSettings, action: any) => {
persistTagsInSidecarFile: action.persistTagsInSidecarFile,
};
}
+ case types.SET_FILENAMETAGPLACEDATEND: {
+ return {
+ ...state,
+ filenameTagPlacedAtEnd: action.filenameTagPlacedAtEnd,
+ };
+ }
case types.SET_ADDTAGSTOLIBRARY: {
return { ...state, addTagsToLibrary: action.addTagsToLibrary };
}
@@ -642,6 +649,10 @@ export const actions = {
type: types.SET_PERSISTTAGSINSIDECARFILE,
persistTagsInSidecarFile,
}),
+ setFileNameTagPlace: (filenameTagPlacedAtEnd: boolean) => ({
+ type: types.SET_FILENAMETAGPLACEDATEND,
+ filenameTagPlacedAtEnd,
+ }),
setAddTagsToLibrary: (addTagsToLibrary: boolean) => ({
type: types.SET_ADDTAGSTOLIBRARY,
addTagsToLibrary,
@@ -912,6 +923,8 @@ export const getPersistTagsInSidecarFile = (state: any): boolean =>
AppConfig.useSidecarsForFileTaggingDisableSetting
? AppConfig.useSidecarsForFileTagging
: state.settings.persistTagsInSidecarFile;
+export const getFileNameTagPlace = (state: any): boolean =>
+ state.settings.filenameTagPlacedAtEnd;
export const getUseGenerateThumbnails = (state: any) =>
state.settings.useGenerateThumbnails;
export const getUseTextExtraction = (state: any) =>
diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.ts
index b2839ae2a..2d3639220 100644
--- a/src/renderer/services/utils-io.ts
+++ b/src/renderer/services/utils-io.ts
@@ -306,79 +306,12 @@ export function getFulfilledResults<T>(
return subfolders;
}*/
-export function generateFileName(
- fileName: string,
- tags: string[],
- tagDelimiter: string,
- dirSeparator: string = AppConfig.dirSeparator,
- prefixTagContainer = AppConfig.prefixTagContainer,
-) {
- let tagsString = '';
- // Creating the string will all the tags by more that 0 tags
- if (tags && tags.length > 0) {
- tagsString = AppConfig.beginTagContainer;
- for (let i = 0; i < tags.length; i += 1) {
- if (i === tags.length - 1) {
- tagsString += tags[i].trim();
- } else {
- tagsString += tags[i].trim() + tagDelimiter;
- }
- }
- tagsString = tagsString.trim() + AppConfig.endTagContainer;
- }
-
- const fileExt = extractFileExtension(fileName, dirSeparator);
- // Assembling the new filename with the tags
- let newFileName = '';
- const beginTagContainer = fileName.indexOf(AppConfig.beginTagContainer);
- const endTagContainer = fileName.indexOf(AppConfig.endTagContainer);
- const lastDotPosition = fileName.lastIndexOf('.');
- if (
- beginTagContainer < 0 ||
- endTagContainer < 0 ||
- beginTagContainer >= endTagContainer
- ) {
- // Filename does not contains tags.
- if (lastDotPosition < 0) {
- // File does not have an extension
- newFileName = fileName.trim() + tagsString;
- } else {
- // File has an extension
- newFileName =
- cleanFileName(
- fileName.substring(0, lastDotPosition),
- prefixTagContainer,
- ) +
- (tagsString ? prefixTagContainer + tagsString : '') +
- '.' +
- fileExt;
- }
- } else {
- // File does not have an extension
- newFileName =
- cleanFileName(
- fileName.substring(0, beginTagContainer),
- prefixTagContainer,
- ) +
- (tagsString ? prefixTagContainer + tagsString : '') +
- fileName.substring(endTagContainer + 1, fileName.length).trim();
- }
- if (newFileName.length < 1) {
- throw new Error('Generated filename is invalid');
- }
- // Removing double prefix todo rethink this ?? there is no double prefix
- newFileName = newFileName
- .split(prefixTagContainer + '' + prefixTagContainer)
- .join(prefixTagContainer);
- return newFileName;
-}
-
-function cleanFileName(fileName, prefixTagContainer) {
+/*function cleanFileName(fileName, prefixTagContainer) {
if (prefixTagContainer && fileName.endsWith(prefixTagContainer)) {
return fileName.slice(0, -prefixTagContainer.length);
}
return fileName.trim();
-}
+}*/
export function parseNewTags(tagsInput: string, tagGroup: TS.TagGroup) {
if (tagGroup) {
diff --git a/src/renderer/tagspaces.d.ts b/src/renderer/tagspaces.d.ts
index 46775bc8b..23e291e96 100644
--- a/src/renderer/tagspaces.d.ts
+++ b/src/renderer/tagspaces.d.ts
@@ -57,6 +57,7 @@ declare interface Window {
ExtPrivacyURL?: string;
ExtImprintURL?: string;
ExtCheckForUpdatesOnStartup?: boolean;
+ ExtFilenameTagPlacedAtEnd?: boolean;
ExtRevisionsEnabled?: boolean;
ExtAutoSaveEnabled?: boolean;
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: any;
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.js
index eee90d412..a71215188 100644
--- a/tests/e2e/general.helpers.js
+++ b/tests/e2e/general.helpers.js
@@ -668,55 +668,6 @@ export function getGridFileSelector(fileName) {
return '[data-tid="fsEntryName_' + dataTidFormat(fileName) + '"]';
}
-export function generateFileName(fileName, fileExt, tags, tagDelimiter = ' ') {
- let tagsString = '';
- let beginTagContainer = AppConfig.beginTagContainer;
- let endTagContainer = AppConfig.endTagContainer;
- const prefixTagContainer = AppConfig.prefixTagContainer;
- // Creating the string will all the tags by more that 0 tags
- if (tags && tags.length > 0) {
- tagsString = beginTagContainer;
- for (let i = 0; i < tags.length; i += 1) {
- if (i === tags.length - 1) {
- tagsString += tags[i].trim();
- } else {
- tagsString += tags[i].trim() + tagDelimiter;
- }
- }
- tagsString = tagsString.trim() + endTagContainer;
- }
- // Assembling the new filename with the tags
- let newFileName = '';
- beginTagContainer = fileName.indexOf(beginTagContainer);
- endTagContainer = fileName.indexOf(endTagContainer);
- if (
- beginTagContainer < 0 ||
- endTagContainer < 0 ||
- beginTagContainer >= endTagContainer
- ) {
- // File does not have an extension
- newFileName =
- fileName.trim() +
- (tagsString ? prefixTagContainer + tagsString : '') +
- '.' +
- fileExt;
- } else {
- // File does not have an extension
- newFileName =
- fileName.substring(0, beginTagContainer).trim() +
- (tagsString ? prefixTagContainer + tagsString : '') +
- fileName.substring(endTagContainer + 1, fileName.length).trim();
- }
- if (newFileName.length < 1) {
- throw new Error('Generated filename is invalid');
- }
- // Removing double prefix
- newFileName = newFileName
- .split(prefixTagContainer + '' + prefixTagContainer)
- .join(prefixTagContainer);
- return newFileName;
-}
-
/**
* @deprecated view expectTagsExist
* @param selector
diff --git a/tests/e2e/perspective-grid-right-button.pw.e2e.js b/tests/e2e/perspective-grid-right-button.pw.e2e.js
index 405b20ee1..6cbb7938b 100644
--- a/tests/e2e/perspective-grid-right-button.pw.e2e.js
+++ b/tests/e2e/perspective-grid-right-button.pw.e2e.js
@@ -3,6 +3,7 @@
*/
import { expect, test } from '@playwright/test';
+import { generateFileName } from '@tagspaces/tagspaces-common/paths';
import {
defaultLocationPath,
defaultLocationName,
@@ -11,6 +12,7 @@ import {
createPwMinioLocation,
createPwLocation,
} from './location.helpers';
+import AppConfig from '../../src/renderer/AppConfig';
import { searchEngine } from './search.helpers';
import { openContextEntryMenu, toContainTID } from './test-utils';
import {
@@ -18,7 +20,6 @@ import {
createNewDirectory,
createTxtFile,
expectElementExist,
- generateFileName,
getGridFileSelector,
reloadDirectory,
removeTagFromTagMenu,
@@ -31,13 +32,11 @@ import {
frameLocator,
takeScreenshot,
expectMetaFilesExist,
- getElementScreenshot,
+ setSettings,
} from './general.helpers';
import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';
import { startTestingApp, stopApp, testDataRefresh } from './hook';
import { clearDataStorage } from './welcome.helpers';
-import AppConfig from '../../src/renderer/AppConfig';
-import { dataTidFormat } from '../../src/renderer/services/test';
const testTagName = 'testTag'; // TODO fix camelCase tag name
@@ -286,15 +285,16 @@ test.describe('TST50** - Right button on a file', () => {
test('TST5025 - Add - Remove tags (file menu) [web,electron]', async () => {
// await searchEngine('desktop');
- const fileName = 'sample';
- const fileExt = 'desktop';
+ const fileName = 'sample.desktop';
const tags = [testTagName, testTagName + '2'];
// select file
- await clickOn(getGridFileSelector(fileName + '.' + fileExt));
+ await clickOn(getGridFileSelector(fileName));
await AddRemoveTagsToSelectedFiles('grid', tags, true);
let gridElement = await global.client.waitForSelector(
- getGridFileSelector(generateFileName(fileName, fileExt, tags, ' ')),
+ getGridFileSelector(
+ generateFileName(fileName, tags, AppConfig.tagDelimiter),
+ ),
);
gridElement = await gridElement.$('..');
for (let i = 0; i < tags.length; i++) {
@@ -533,4 +533,42 @@ test.describe('TST50** - Right button on a file', () => {
// const firstFileName = await getGridFileName(0);
// expect(firstFileName).toBe(undefined);
});
+
+ test('TST5049 - Add/remove filename tags Placed at Start [web,electron]', async () => {
+ await setSettings('[data-tid=settingsSetPersistTagsInFileName]', true);
+ await setSettings('[data-tid=fileNameBeginningTagTID]', true);
+
+ const fileName = 'sample.txt';
+ const tags = [testTagName, testTagName + '2'];
+ // select file
+ await clickOn(getGridFileSelector(fileName));
+ await AddRemoveTagsToSelectedFiles('grid', tags, true);
+
+ let gridElement = await global.client.waitForSelector(
+ getGridFileSelector(
+ generateFileName(
+ fileName,
+ tags,
+ AppConfig.tagDelimiter,
+ AppConfig.dirSeparator,
+ AppConfig.prefixTagContainer,
+ false,
+ ),
+ ),
+ );
+ gridElement = await gridElement.$('..');
+ for (let i = 0; i < tags.length; i++) {
+ await expectElementExist('[data-tid=tagContainer_' + tags[i] + ']', true);
+ }
+
+ // remove tags
+ await gridElement.click();
+ await AddRemoveTagsToSelectedFiles('grid', tags, false);
+ for (let i = 0; i < tags.length; i++) {
+ await expectElementExist(
+ '[data-tid=tagContainer_' + tags[i] + ']',
+ false,
+ );
+ }
+ });
});