Skip to content

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

TSN375: add menu to search and location manager (#1051)

mladensapf5f37024400b
diff --git a/app/components/LocationManager.js b/app/components/LocationManager.js
index 06fa54a22..93b9a83a1 100644
--- a/app/components/LocationManager.js
+++ b/app/components/LocationManager.js
@@ -48,6 +48,7 @@ import ArrowUpwardIcon from '@material-ui/icons/ArrowUpward';
import OpenFolderNativelyIcon from '@material-ui/icons/Launch';
import styles from './SidePanels.css';
import DirectoryMenu from './menus/DirectoryMenu';
+import LocationManagerMenu from './menus/LocationManagerMenu';
import EditLocationDialog from './dialogs/EditLocationDialog';
import CreateLocationDialog from './dialogs/CreateLocationDialog';
import ConfirmDialog from './dialogs/ConfirmDialog';
@@ -80,6 +81,7 @@ type Props = {
currentLocationId: string,
isReadOnlyMode: boolean,
hideDrawer?: () => void,
+ openURLExternally: (path: string) => void,
loadDirectoryContent: (path: string) => void,
openLocation: (location: Location) => void,
openFileNatively: (path: string) => void,
@@ -117,7 +119,9 @@ type State = {
isSelectDirectoryDialogOpened?: boolean,
isCreateDirectoryDialogOpened?: boolean,
createLocationDialogKey: string,
- isCreateDirectoryDialogOpened?: boolean,
+ isCreateDirectoryDialogOpened?: boolean,
+ locationManagerMenuOpened: boolean,
+ locationManagerMenuAnchorEl: Object | null,
dirs?: Object
};
@@ -142,7 +146,9 @@ class LocationManager extends React.Component<Props, State> {
isEditLocationDialogOpened: false,
isDeleteLocationDialogOpened: false,
isCreateDirectoryDialogOpened: false,
- isSelectDirectoryDialogOpened: false,
+ isSelectDirectoryDialogOpened: false,
+ locationManagerMenuOpened: false,
+ locationManagerMenuAnchorEl: null,
createLocationDialogKey: uuidv1(),
editLocationDialogKey: uuidv1(),
dirs: {}
@@ -364,7 +370,6 @@ class LocationManager extends React.Component<Props, State> {
}
};
-
showEditLocationDialog = () => {
this.handleRequestCloseContextMenus();
this.setState({ isEditLocationDialogOpened: true });
@@ -650,6 +655,17 @@ class LocationManager extends React.Component<Props, State> {
{table}
</div>
);
+ };
+
+ handleLocationManagerMenu = (event: Object) => {
+ this.setState({
+ locationManagerMenuOpened: true,
+ locationManagerMenuAnchorEl: event.currentTarget
+ });
+ };
+
+ handleCloseLocationManagerMenu = () => {
+ this.setState({ locationManagerMenuOpened: false});
};
render() {
@@ -661,7 +677,19 @@ class LocationManager extends React.Component<Props, State> {
<Typography className={classNames(classes.panelTitle, classes.header)} type="subtitle1">
{i18n.t('core:locationManager')}
</Typography>
+ <IconButton
+ data-tid="locationManagerMenu"
+ onClick={this.handleLocationManagerMenu}
+ >
+ <MoreVertIcon />
+ </IconButton>
</div>
+ <LocationManagerMenu
+ anchorEl={this.state.locationManagerMenuAnchorEl}
+ open={this.state.locationManagerMenuOpened}
+ onClose={this.handleCloseLocationManagerMenu}
+ openURLExternally={this.props.openURLExternally}
+ />
{!isLocationsReadOnly && (
<div style={{ width: '100%', textAlign: 'center', marginBottom: 10 }}>
<Button
@@ -853,7 +881,8 @@ function mapDispatchToProps(dispatch) {
openFileNatively: AppActions.openFileNatively,
openFile: AppActions.openFile,
showNotification: AppActions.showNotification,
- moveFiles: IOActions.moveFiles
+ moveFiles: IOActions.moveFiles,
+ openURLExternally: AppActions.openURLExternally,
}, dispatch);
}
diff --git a/app/components/Search.js b/app/components/Search.js
index eb071e450..06c6bd574 100644
--- a/app/components/Search.js
+++ b/app/components/Search.js
@@ -48,6 +48,7 @@ import InputAdornment from '@material-ui/core/InputAdornment';
import IconButton from '@material-ui/core/IconButton';
import Select from '@material-ui/core/Select';
import FormControl from '@material-ui/core/FormControl';
+import MoreVertIcon from '@material-ui/icons/MoreVert';
import TagsSelect from './TagsSelect';
import CustomLogo from './CustomLogo';
import { actions as AppActions, getDirectoryPath } from '../reducers/app';
@@ -57,6 +58,7 @@ import styles from './SidePanels.css';
import i18n from '../services/i18n';
import { FileTypeGroups, type SearchQuery } from '../services/search';
import { Pro } from '../pro';
+import SearchMenu from './menus/SearchMenu';
import type { Tag } from '../reducers/taglibrary';
import ocl from '../utils/openlocationcode';
import {
@@ -98,7 +100,9 @@ type State = {
tagPlaceLat: number | null,
tagPlaceLong: number | null,
tagPlaceRadius: number,
- fileSize: string
+ fileSize: string,
+ searchMenuOpened: boolean,
+ searchMenuAnchorEl: Object | null
};
class Search extends React.Component<Props, State> {
@@ -119,7 +123,9 @@ class Search extends React.Component<Props, State> {
tagPlaceLat: null,
tagPlaceLong: null,
tagPlaceRadius: 0,
- fileSize: ''
+ fileSize: '',
+ searchMenuOpened: false,
+ searchMenuAnchorEl: null
};
handleInputChange = event => {
@@ -262,15 +268,27 @@ class Search extends React.Component<Props, State> {
};
console.log('Search object: ' + JSON.stringify(searchQuery));
this.props.searchLocationIndex(searchQuery);
+ };
+
+ handleSearchMenu = (event: Object) => {
+ this.setState({
+ searchMenuOpened: true,
+ searchMenuAnchorEl: event.currentTarget
+ });
+ };
+
+ handleCloseSearchMenu = () => {
+ this.setState({ searchMenuOpened: false});
};
render() {
const { classes, indexing, indexedEntriesCount } = this.props;
+
return (
<div className={classes.panel} style={this.props.style}>
<CustomLogo />
<div className={classes.toolbar}>
- <Typography className={classNames(classes.panelTitle, classes.header)} style={{ flex: 'none' }}>
+ <Typography className={classNames(classes.panelTitle, classes.header)}>
{i18n.t('searchTitle')}
</Typography>
<Typography variant="caption" className={classes.header} style={{ alignSelf: 'flex-end', paddingLeft: 5, display: 'block' }}>
@@ -282,7 +300,19 @@ class Search extends React.Component<Props, State> {
>
<HelpIcon />
</IconButton> */}
+ <IconButton
+ data-tid="searchMenu"
+ onClick={this.handleSearchMenu}
+ >
+ <MoreVertIcon />
+ </IconButton>
</div>
+ <SearchMenu
+ anchorEl={this.state.searchMenuAnchorEl}
+ open={this.state.searchMenuOpened}
+ onClose={this.handleCloseSearchMenu}
+ openURLExternally={this.props.openURLExternally}
+ />
<div className={classes.searchArea}>
<FormControl
className={classes.formControl}
@@ -610,7 +640,8 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return bindActionCreators({
searchLocationIndex: LocationIndexActions.searchLocationIndex,
- loadDirectoryContent: AppActions.loadDirectoryContent
+ loadDirectoryContent: AppActions.loadDirectoryContent,
+ openURLExternally: AppActions.openURLExternally,
}, dispatch);
}
diff --git a/app/components/TagLibrary.js b/app/components/TagLibrary.js
index 9aaf4f87d..30c5e443d 100644
--- a/app/components/TagLibrary.js
+++ b/app/components/TagLibrary.js
@@ -89,8 +89,8 @@ type Props = {
};
type State = {
- importExportMenuAnchorEl: Object | null,
- importExportMenuOpened: boolean,
+ tagLibraryMenuAnchorEl: Object | null,
+ tagLibraryMenuOpened: boolean,
tagGroupMenuAnchorEl: Object | null,
tagGroupMenuOpened: boolean,
tagMenuAnchorEl: Object,
@@ -112,8 +112,8 @@ class TagLibrary extends React.Component<Props, State> {
tagGroupMenuOpened: false,
tagMenuAnchorEl: null,
tagMenuOpened: false,
- importExportMenuAnchorEl: null,
- importExportMenuOpened: false,
+ tagLibraryMenuAnchorEl: null,
+ tagLibraryMenuOpened: false,
selectedTagGroupEntry: null,
selectedTagEntry: null,
selectedTag: null,
@@ -159,8 +159,8 @@ class TagLibrary extends React.Component<Props, State> {
handleTagLibraryMenu = (event: Object) => {
this.setState({
- importExportMenuOpened: true,
- importExportMenuAnchorEl: event.currentTarget
+ tagLibraryMenuOpened: true,
+ tagLibraryMenuAnchorEl: event.currentTarget
});
};
@@ -207,7 +207,7 @@ class TagLibrary extends React.Component<Props, State> {
};
handleCloseImportExportMenu = () => {
- this.setState({ importExportMenuOpened: false });
+ this.setState({ tagLibraryMenuOpened: false });
};
renderTagGroup = (tagGroup) => {
@@ -364,8 +364,8 @@ class TagLibrary extends React.Component<Props, State> {
collectTagsFromLocation={this.props.collectTagsFromLocation}
/>
<TagLibraryMenu
- anchorEl={this.state.importExportMenuAnchorEl}
- open={this.state.importExportMenuOpened}
+ anchorEl={this.state.tagLibraryMenuAnchorEl}
+ open={this.state.tagLibraryMenuOpened}
onClose={this.handleCloseImportExportMenu}
tagGroups={tagGroups}
importTagGroups={this.props.importTagGroups}
diff --git a/app/components/menus/LocationManagerMenu.js b/app/components/menus/LocationManagerMenu.js
new file mode 100644
index 000000000..d93aec2c4
--- /dev/null
+++ b/app/components/menus/LocationManagerMenu.js
@@ -0,0 +1,63 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * @flow
+ */
+
+import React from 'react';
+import ListItemText from '@material-ui/core/ListItemText';
+import ListItemIcon from '@material-ui/core/ListItemIcon';
+import Menu from '@material-ui/core/Menu';
+import MenuItem from '@material-ui/core/MenuItem';
+import HelpIcon from '@material-ui/icons/Help';
+import i18n from '../../services/i18n';
+import AppConfig from '../../config';
+
+type Props = {
+ classes: Object,
+ open: boolean,
+ anchorEl: Object,
+ onClose: () => void,
+ openURLExternally: (url: string) => void,
+};
+
+const LocationManagerMenu = (props: Props) => {
+
+ return (
+ <div style={{ overflowY: 'hidden !important' }}>
+ <Menu
+ anchorEl={props.anchorEl}
+ open={props.open}
+ onClose={props.onClose}
+ >
+ <MenuItem
+ data-tid="locationManagerMenu"
+ onClick={() => {
+ props.onClose();
+ props.openURLExternally(AppConfig.documentationLinks.locations)
+ }}
+ >
+ <ListItemIcon>
+ <HelpIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:help')} />
+ </MenuItem>
+ </Menu>
+ </div>
+ );
+};
+
+export default LocationManagerMenu;
\ No newline at end of file
diff --git a/app/components/menus/SearchMenu.js b/app/components/menus/SearchMenu.js
new file mode 100644
index 000000000..d2bea092c
--- /dev/null
+++ b/app/components/menus/SearchMenu.js
@@ -0,0 +1,63 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * @flow
+ */
+
+import React from 'react';
+import ListItemText from '@material-ui/core/ListItemText';
+import ListItemIcon from '@material-ui/core/ListItemIcon';
+import Menu from '@material-ui/core/Menu';
+import MenuItem from '@material-ui/core/MenuItem';
+import HelpIcon from '@material-ui/icons/Help';
+import i18n from '../../services/i18n';
+import AppConfig from '../../config';
+
+type Props = {
+ classes: Object,
+ open: boolean,
+ anchorEl: Object,
+ onClose: () => void,
+ openURLExternally: (url: string) => void,
+};
+
+const SearchMenu = (props: Props) => {
+
+ return (
+ <div style={{ overflowY: 'hidden !important' }}>
+ <Menu
+ anchorEl={props.anchorEl}
+ open={props.open}
+ onClose={props.onClose}
+ >
+ <MenuItem
+ data-tid="searchMenuHelp"
+ onClick={() => {
+ props.onClose();
+ props.openURLExternally(AppConfig.documentationLinks.search)
+ }}
+ >
+ <ListItemIcon>
+ <HelpIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:help')} />
+ </MenuItem>
+ </Menu>
+ </div>
+ );
+};
+
+export default SearchMenu;
diff --git a/app/components/menus/TagLibraryMenu.js b/app/components/menus/TagLibraryMenu.js
index 580ef9691..d1bac59a1 100644
--- a/app/components/menus/TagLibraryMenu.js
+++ b/app/components/menus/TagLibraryMenu.js
@@ -162,7 +162,7 @@ const TagLibraryMenu = (props: Props) => {
<ListItemText primary={i18n.t('core:exportTagGroupsButton')} />
</MenuItem>
<MenuItem
- data-tid="tablibraryHelp"
+ data-tid="taglibraryHelp"
onClick={() => {
props.onClose();
props.openURLExternally(AppConfig.documentationLinks.taglibrary)