TagSpaces is an offline, open source, document manager with tagging support
added functionality for collecting tags from the current location
Ilian Sapundshiev6d2b3a4dabc0
diff --git a/app/components/menus/TagGroupMenu.js b/app/components/menus/TagGroupMenu.jsindex 6f92a4736..fa7f7e826 100644--- a/app/components/menus/TagGroupMenu.js+++ b/app/components/menus/TagGroupMenu.js@@ -31,6 +31,7 @@ import Menu from '@material-ui/core/Menu';import MenuItem from '@material-ui/core/MenuItem';import { type TagGroup } from '../../reducers/taglibrary';import i18n from '../../services/i18n';+import { Pro } from '../../pro';type Props = {anchorEl: Object,@@ -130,12 +131,12 @@ class TagLibraryMenu extends React.Component<Props> {<MenuItemdata-tid="collectTags"onClick={this.handleCollectTags}- title="This feature is available in the PRO version"+ title={Pro ? '' : i18n.t('core:needProVersion')}><ListItemIcon><CollectTagsIcon /></ListItemIcon>- <ListItemText primary={i18n.t('core:collectTagsFromLocation') + ' PRO'} />+ <ListItemText primary={i18n.t('core:collectTagsFromLocation') + (Pro ? '' : ' PRO')} /></MenuItem></Menu></div>diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex ffdc769ee..d5533ff49 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -239,7 +239,7 @@"documentation": "Documentation","selectFile": "Please select a file first.","geoTaggingNotPossible": "Geo Tagging not possible!",- "needProVersion": "You need the PRO version in order to use this functionality.",+ "needProVersion": "This feature is available in TagSpaces PRO.","sizeInBytes": "bytes","error": "Error","warning": "Warning",@@ -391,5 +391,6 @@"singleClickOpenInternally": "Single click opens file internally","singleClickOpenExternally": "Single click opens file externally","parentDirNotInLocation": "Unable to navigate! Parent folder not in the current location.",+ "collectTagsFromLocation": "Collect Tags From Current Location","-": "-"}diff --git a/app/reducers/tagging-actions.js b/app/reducers/tagging-actions.jsindex 6adb65fe0..753b55f33 100644--- a/app/reducers/tagging-actions.js+++ b/app/reducers/tagging-actions.js@@ -17,10 +17,10 @@* @flow*/+import uuidv1 from 'uuid';import i18n from '../services/i18n';import { actions as AppActions } from './app';-import { actions as TagLibraryActions, type Tag } from './taglibrary';-import uuidv1 from 'uuid';+import { actions as TagLibraryActions, type Tag, type TagGroup } from './taglibrary';import {extractFileExtension,extractFileName,@@ -36,6 +36,7 @@ import {import { formatDateTime4Tag } from '../utils/misc';import AppConfig from '../config';import PlatformIO from '../services/platform-io';+import { Pro } from '../pro';const actions = {addTags: (paths: Array<string>, tags: Array<Tag>) => (@@ -433,6 +434,32 @@ const actions = {) => {// dispatch(actions.createLocation(location));},+ collectTagsFromLocation: (tagGroup: TagGroup) => (+ dispatch: (actions: Object) => void,+ getState: () => Object+ ) => {+ const { locationIndex, settings } = getState();++ if (!Pro || !Pro.Indexer || !Pro.Indexer.collectTagsFromIndex) {+ dispatch(AppActions.showNotification(i18n.t('core:needProVersion'), 'error', true));+ return true;+ }++ if (locationIndex.currentDirectoryIndex.length < 1) {+ dispatch(AppActions.showNotification('Please index location first', 'error', true));+ return true;+ }++ const uniqueTags = Pro.Indexer.collectTagsFromIndex(locationIndex, tagGroup, settings);+ if (uniqueTags.length > 0) {+ const changedTagGroup = {+ ...tagGroup,+ children: uniqueTags,+ modified_date: new Date()+ };+ dispatch(TagLibraryActions.mergeTagGroup(changedTagGroup));+ }+ },};function handleSmartTag(smarttagFunction: string) {