Skip to content

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

TSN513 - Searched for any of the tags in a given tag group (OR search) (#1364)

Stanimir4af0aebb7663
diff --git a/app/components/TagLibrary.tsx b/app/components/TagLibrary.tsx
index 7ff89a613..e3462ef74 100644
--- a/app/components/TagLibrary.tsx
+++ b/app/components/TagLibrary.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { useCallback, useMemo, useState } from 'react';
+import React, { useCallback, useState } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import classNames from 'classnames';
diff --git a/app/components/menus/EntryTagMenu.tsx b/app/components/menus/EntryTagMenu.tsx
index 4189e3b11..ae5b038eb 100644
--- a/app/components/menus/EntryTagMenu.tsx
+++ b/app/components/menus/EntryTagMenu.tsx
@@ -21,7 +21,7 @@ import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import EditIcon from '@material-ui/icons/Edit';
import DeleteIcon from '@material-ui/icons/DeleteForever';
-import ShowEntriesWithTagIcon from '@material-ui/icons/Launch';
+import ShowEntriesWithTagIcon from '@material-ui/icons/SearchOutlined';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import Menu from '@material-ui/core/Menu';
diff --git a/app/components/menus/TagGroupMenu.tsx b/app/components/menus/TagGroupMenu.tsx
index 729012d85..91452acbf 100644
--- a/app/components/menus/TagGroupMenu.tsx
+++ b/app/components/menus/TagGroupMenu.tsx
@@ -24,13 +24,24 @@ import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import DeleteTagGroupIcon from '@material-ui/icons/DeleteForever';
import SortTagGroupIcon from '@material-ui/icons/SortByAlpha';
+import ShowEntriesWithTagIcon from '@material-ui/icons/SearchOutlined';
import TagIcon from '@material-ui/icons/LocalOffer';
+import InfoIcon from '@material-ui/icons/HelpOutlineOutlined';
import CollectTagsIcon from '@material-ui/icons/Voicemail';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
+import { bindActionCreators } from 'redux';
+import { connect } from 'react-redux';
import { TagGroup } from '-/reducers/taglibrary';
import i18n from '-/services/i18n';
import { Pro } from '-/pro';
+import { getMaxSearchResults } from '-/reducers/settings';
+import { actions as AppActions } from '-/reducers/app';
+import { actions as LocationIndexActions } from '-/reducers/location-index';
+import { SearchQuery } from '-/services/search';
+import { Tooltip } from '@material-ui/core';
+import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
+import IconButton from '@material-ui/core/IconButton';
interface Props {
classes?: any;
@@ -46,9 +57,12 @@ interface Props {
sortTagGroup: (tagGroupId: string) => void;
collectTagsFromLocation: (tagGroup: TagGroup) => void;
handleCloseTagGroupMenu: () => void;
+ searchLocationIndex: (searchQuery: SearchQuery) => void;
+ openSearchPanel: () => void;
+ maxSearchResults: number;
}
-const TagLibraryMenu = (props: Props) => {
+const TagGroupMenu = (props: Props) => {
function handleCollectTags() {
props.onClose();
@@ -79,6 +93,17 @@ const TagLibraryMenu = (props: Props) => {
props.handleCloseTagGroupMenu();
}
+ function showFilesWithTags() {
+ if (props.selectedTagGroupEntry) {
+ props.openSearchPanel();
+ props.searchLocationIndex({
+ tagsOR: props.selectedTagGroupEntry.children,
+ maxSearchResults: props.maxSearchResults
+ });
+ }
+ props.handleCloseTagGroupMenu();
+ }
+
return (
<div style={{ overflowY: 'hidden' }}>
<Menu
@@ -119,6 +144,19 @@ const TagLibraryMenu = (props: Props) => {
</ListItemIcon>
<ListItemText primary={i18n.t('core:sortTagGroup')} />
</MenuItem>
+ <MenuItem data-tid="showFilesWithTagsTID" onClick={showFilesWithTags}>
+ <ListItemIcon>
+ <ShowEntriesWithTagIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:showFilesWithTags')} />
+ <ListItemSecondaryAction>
+ <Tooltip title={i18n.t('core:showFilesWithTagsTooltip')}>
+ <IconButton edge="end" aria-label="delete">
+ <InfoIcon />
+ </IconButton>
+ </Tooltip>
+ </ListItemSecondaryAction>
+ </MenuItem>
<MenuItem
data-tid="deleteTagGroup"
onClick={props.showDeleteTagGroupDialog}
@@ -147,4 +185,20 @@ const TagLibraryMenu = (props: Props) => {
);
};
-export default TagLibraryMenu;
+function mapStateToProps(state) {
+ return {
+ maxSearchResults: getMaxSearchResults(state)
+ };
+}
+
+function mapDispatchToProps(dispatch) {
+ return bindActionCreators(
+ {
+ openSearchPanel: AppActions.openSearchPanel,
+ searchLocationIndex: LocationIndexActions.searchLocationIndex
+ },
+ dispatch
+ );
+}
+
+export default connect(mapStateToProps, mapDispatchToProps)(TagGroupMenu);
diff --git a/app/components/menus/TagMenu.tsx b/app/components/menus/TagMenu.tsx
index d446ffb62..2e66cf12b 100644
--- a/app/components/menus/TagMenu.tsx
+++ b/app/components/menus/TagMenu.tsx
@@ -19,7 +19,7 @@
import React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
-import ShowEntriesWithTagIcon from '@material-ui/icons/Launch';
+import ShowEntriesWithTagIcon from '@material-ui/icons/SearchOutlined';
import Edit from '@material-ui/icons/Edit';
import DeleteIcon from '@material-ui/icons/DeleteForever';
import ListItemIcon from '@material-ui/core/ListItemIcon';
@@ -48,7 +48,7 @@ interface Props {
maxSearchResults: number;
}
-const TagLibraryMenu = (props: Props) => {
+const TagMenu = (props: Props) => {
function showFilesWithThisTag() {
if (props.selectedTag) {
props.openSearchPanel();
@@ -119,4 +119,4 @@ function mapDispatchToProps(dispatch) {
);
}
-export default connect(mapStateToProps, mapDispatchToProps)(TagLibraryMenu);
+export default connect(mapStateToProps, mapDispatchToProps)(TagMenu);
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 72199f08e..12eee6246 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -160,6 +160,8 @@
"openNextFileTooltip": "Open next file",
"openNextFile": "Next File",
"showFilesWithThisTag": "Show Files With This Tag",
+ "showFilesWithTags": "Search for tags from this group",
+ "showFilesWithTagsTooltip": "Show files or folders tagged with at least one tag from this tag group",
"editTag": "Edit Tag",
"removeTagTooltip": "Do you really want to remove this tag?",
"removeTag": "Remove Tag",