Skip to content

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

ui-search-improvements (#1513)

Stanimir40b8e237a9c4
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index a3f1044d4..e87059008 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -41,7 +41,7 @@ import MapiquePerspectiveIcon from '@material-ui/icons/Map';
import LocationMenu from './menus/LocationMenu';
import i18n from '../services/i18n';
import { getMaxSearchResults, getDesktopMode } from '-/reducers/settings';
-import { getLocations } from '-/reducers/locations';
+// import { getLocations } from '-/reducers/locations';
import {
actions as AppActions,
getDirectoryContent,
@@ -232,7 +232,7 @@ interface Props {
maxSearchResults: number;
currentDirectoryPerspective: string;
currentLocationPath: string;
- locations: Array<Location>;
+ // locations: Array<Location>;
openedFiles: Array<OpenedEntry>;
updateCurrentDirEntry: (path: string, entry: Object) => void;
setCurrentDirectoryColor: (color: string) => void;
@@ -503,7 +503,7 @@ const FolderContainer = (props: Props) => {
anchorEl={anchorSearch}
onClose={() => setAnchorSearch(null)}
anchorOrigin={{
- vertical: 'bottom',
+ vertical: 'top',
horizontal: 'right'
}}
style={{
@@ -629,7 +629,7 @@ function mapStateToProps(state) {
currentDirectoryPerspective: getCurrentDirectoryPerspective(state),
searchResultCount: getSearchResultCount(state),
currentLocationPath: getCurrentLocationPath(state),
- locations: getLocations(state),
+ // locations: getLocations(state),
maxSearchResults: getMaxSearchResults(state),
isDesktopMode: getDesktopMode(state),
isReadOnlyMode: isReadOnlyMode(state),
diff --git a/app/components/SearchInline.tsx b/app/components/SearchInline.tsx
index 30839747d..a44a4c6e5 100644
--- a/app/components/SearchInline.tsx
+++ b/app/components/SearchInline.tsx
@@ -20,8 +20,9 @@ import React, { useEffect, useReducer, useRef, useState } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { withStyles, Theme, createStyles } from '@material-ui/core/styles';
-import ClearSearchIcon from '@material-ui/icons/Clear';
+import ClearSearchIcon from '@material-ui/icons/CancelOutlined';
import Button from '@material-ui/core/Button';
+import Tooltip from '@material-ui/core/Tooltip';
import IconButton from '@material-ui/core/IconButton';
import InputAdornment from '@material-ui/core/InputAdornment';
import TextField from '@material-ui/core/TextField';
@@ -156,6 +157,30 @@ const SearchInline = (props: Props) => {
mainSearchField.current.value = textQuery.current;
// forceUpdate();
}
+ if (props.searchQuery.searchBoxing) {
+ searchBoxing.current = props.searchQuery.searchBoxing;
+ }
+ if (props.searchQuery.fileTypes) {
+ fileTypes.current = props.searchQuery.fileTypes;
+ }
+ if (props.searchQuery.searchType) {
+ searchType.current = props.searchQuery.searchType;
+ }
+ if (props.searchQuery.lastModified) {
+ lastModified.current = props.searchQuery.lastModified;
+ }
+ if (props.searchQuery.tagTimePeriodFrom) {
+ tagTimePeriodFrom.current = props.searchQuery.tagTimePeriodFrom;
+ }
+ if (props.searchQuery.tagTimePeriodTo) {
+ tagTimePeriodTo.current = props.searchQuery.tagTimePeriodTo;
+ }
+ if (props.searchQuery.forceIndexing) {
+ forceIndexing.current = props.searchQuery.forceIndexing;
+ }
+ if (props.searchQuery.fileSize) {
+ fileSize.current = props.searchQuery.fileSize;
+ }
}, [props.searchQuery]);
/* const mergeWithExtractedTags = (tags: Array<TS.Tag>, identifier: string) => {
@@ -340,14 +365,16 @@ const SearchInline = (props: Props) => {
InputProps={{
endAdornment: (
<InputAdornment position="end">
- <IconButton
- id="clearSearchID"
- onClick={clearSearch}
- size="small"
- edge="end"
- >
- <ClearSearchIcon />
- </IconButton>
+ <Tooltip title={i18n.t('clearSearch')}>
+ <IconButton
+ id="clearSearchID"
+ onClick={clearSearch}
+ size="small"
+ edge="end"
+ >
+ <ClearSearchIcon />
+ </IconButton>
+ </Tooltip>
</InputAdornment>
)
}}
diff --git a/app/components/SearchPopover.tsx b/app/components/SearchPopover.tsx
index 76de2f2f1..41efaddd3 100644
--- a/app/components/SearchPopover.tsx
+++ b/app/components/SearchPopover.tsx
@@ -44,6 +44,7 @@ import InputLabel from '@material-ui/core/InputLabel';
import InputAdornment from '@material-ui/core/InputAdornment';
import IconButton from '@material-ui/core/IconButton';
import CloseIcon from '@material-ui/icons/Close';
+import CancelSearchIcon from '@material-ui/icons/CancelOutlined';
import Select from '@material-ui/core/Select';
import FormControl from '@material-ui/core/FormControl';
import MoreVertIcon from '@material-ui/icons/MoreVert';
@@ -208,13 +209,17 @@ const SearchPopover = (props: Props) => {
if (name === 'fileTypes') {
const types = JSON.parse(value);
fileTypes.current = types;
- if (searchBoxing.current !== 'global') {
- props.searchLocationIndex({
- ...props.searchQuery,
- fileTypes: types,
- showUnixHiddenEntries: props.showUnixHiddenEntries
- });
- }
+ const searchQuery = {
+ ...props.searchQuery,
+ searchBoxing: searchBoxing.current,
+ fileTypes: types,
+ showUnixHiddenEntries: props.showUnixHiddenEntries
+ };
+ /*if (searchBoxing.current !== 'global') {
+ props.searchLocationIndex(searchQuery);
+ } else {*/
+ props.setSearchQuery(searchQuery);
+ //}
}
};
@@ -224,13 +229,18 @@ const SearchPopover = (props: Props) => {
if (name === 'fileSize') {
fileSize.current = value;
- if (searchBoxing.current !== 'global') {
- props.searchLocationIndex({
- ...props.searchQuery,
- fileSize: value,
- showUnixHiddenEntries: props.showUnixHiddenEntries
- });
- }
+ const searchQuery = {
+ ...props.searchQuery,
+ searchBoxing: searchBoxing.current,
+ fileSize: value,
+ showUnixHiddenEntries: props.showUnixHiddenEntries
+ };
+
+ /*if (searchBoxing.current !== 'global') {
+ props.searchLocationIndex(searchQuery);
+ } else {*/
+ props.setSearchQuery(searchQuery);
+ //}
}
};
@@ -242,13 +252,17 @@ const SearchPopover = (props: Props) => {
if (name === 'lastModified') {
lastModified.current = value;
- if (searchBoxing.current !== 'global') {
- props.searchLocationIndex({
- ...props.searchQuery,
- lastModified: value,
- showUnixHiddenEntries: props.showUnixHiddenEntries
- });
- }
+ const searchQuery = {
+ ...props.searchQuery,
+ searchBoxing: searchBoxing.current,
+ lastModified: value,
+ showUnixHiddenEntries: props.showUnixHiddenEntries
+ };
+ /*if (searchBoxing.current !== 'global') {
+ props.searchLocationIndex(searchQuery);
+ } else {*/
+ props.setSearchQuery(searchQuery);
+ // }
}
};
@@ -338,13 +352,14 @@ const SearchPopover = (props: Props) => {
searchQuery = { ...props.searchQuery, tagsOR: value };
}
}
- props.searchLocationIndex({
+ props.setSearchQuery({
...searchQuery,
showUnixHiddenEntries: props.showUnixHiddenEntries
});
- // if (searchBoxing !== 'global') { // TODO disable automatic search in global mode
- //
- // }
+ /*props.searchLocationIndex({
+ ...searchQuery,
+ showUnixHiddenEntries: props.showUnixHiddenEntries
+ });*/
};
function haveSearchFilters(searchQuery) {
@@ -602,6 +617,7 @@ const SearchPopover = (props: Props) => {
} else {
searchLocationIndex(searchQuery);
}
+ props.onClose();
};
const handleSearchMenu = (event: any) => {
@@ -631,14 +647,14 @@ const SearchPopover = (props: Props) => {
<Typography
variant="caption"
className={classes.header}
- style={{ flex: 1 }}
+ style={{ flex: 1, margin: 'auto' }}
>
{indexStatus}
</Typography>
<IconButton
style={{ marginLeft: 'auto' }}
- data-tid="searchMenu"
- onClick={clearSearch}
+ data-tid="closeSearchTID"
+ onClick={props.onClose}
>
<CloseIcon />
</IconButton>
@@ -734,6 +750,34 @@ const SearchPopover = (props: Props) => {
</ToggleButton>
</ToggleButtonGroup>
</FormControl>
+ <FormControl className={classes.formControl} disabled={indexing}>
+ <ButtonGroup style={{ justifyContent: 'center' }}>
+ <Button
+ disabled={indexing}
+ id="searchButton"
+ // variant="outlined"
+ color="primary"
+ onClick={executeSearch}
+ style={{ flex: 1 }}
+ size="small"
+ >
+ {indexing
+ ? 'Search disabled while indexing'
+ : i18n.t('searchTitle')}
+ </Button>
+ <Tooltip title={i18n.t('clearSearch')}>
+ <Button
+ variant="outlined"
+ color="secondary"
+ size="small"
+ onClick={clearSearch}
+ id="resetSearchButton"
+ >
+ <CancelSearchIcon />
+ </Button>
+ </Tooltip>
+ </ButtonGroup>
+ </FormControl>
<FormControl className={classes.formControl} disabled={indexing}>
<TagsSelect
placeholderText={i18n.t('core:selectTags')}
@@ -1044,7 +1088,7 @@ const SearchPopover = (props: Props) => {
<Button
variant="outlined"
color="secondary"
- size="medium"
+ size="small"
style={{ flex: 1 }}
onClick={() => saveSearch()}
>
@@ -1054,7 +1098,7 @@ const SearchPopover = (props: Props) => {
<Button
variant="outlined"
color="secondary"
- size="medium"
+ size="small"
style={{ flex: 1 }}
onClick={() => saveSearch(false)}
>
@@ -1063,16 +1107,6 @@ const SearchPopover = (props: Props) => {
)}
</>
)}
- <Button
- variant="outlined"
- color="secondary"
- size="medium"
- style={{ flex: 1 }}
- onClick={clearSearch}
- id="resetSearchButton"
- >
- {i18n.t('resetBtn')}
- </Button>
</ButtonGroup>
</FormControl>
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 875a3e92e..c2d807e97 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -218,6 +218,7 @@
"settings": "Settings",
"fileExists": "Target file '{{fileName}}' already exists.",
"searchTitle": "Search",
+ "clearSearch": "Clear Search",
"resetBtn": "Reset",
"services": "Services",
"quit": "Quit",
diff --git a/app/main.dev.ts b/app/main.dev.ts
index c400e2bd3..e028dea90 100644
--- a/app/main.dev.ts
+++ b/app/main.dev.ts
@@ -361,7 +361,6 @@ function createSplashWorker() {
frame: false,
webPreferences: {
nodeIntegration: true,
- enableRemoteModule: false,
contextIsolation: false
}
});
@@ -426,7 +425,6 @@ async function createAppWindow() {
spellcheck: true,
nodeIntegration: true,
webviewTag: true,
- enableRemoteModule: false,
contextIsolation: false
}
});
diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.ts
index 2f7303afa..f19638b87 100644
--- a/app/reducers/location-index.ts
+++ b/app/reducers/location-index.ts
@@ -16,7 +16,7 @@
*
*/
-import { getLocation, getLocations } from './locations';
+import { getLocation, getLocationByPath, getLocations } from './locations';
import { createDirectoryIndex } from '-/services/utils-io';
import { Pro } from '../pro';
import {
@@ -288,11 +288,19 @@ export const actions = {
getState: () => any
) => {
const state = getState();
- const currentLocation: TS.Location = getLocation(
+ let currentLocation: TS.Location = getLocation(
state,
state.app.currentLocationId
);
window.walkCanceled = false;
+ if (!currentLocation) {
+ if (searchQuery.currentDirectory) {
+ currentLocation = getLocationByPath(
+ state,
+ searchQuery.currentDirectory
+ );
+ }
+ }
if (!currentLocation) {
dispatch(
AppActions.showNotification(
@@ -303,6 +311,7 @@ export const actions = {
);
return;
}
+
const isCloudLocation = currentLocation.type === locationType.TYPE_CLOUD;
dispatch(
AppActions.showNotification(
diff --git a/app/reducers/locations.ts b/app/reducers/locations.ts
index 6f3ca4ee8..4a7a09508 100644
--- a/app/reducers/locations.ts
+++ b/app/reducers/locations.ts
@@ -256,6 +256,11 @@ export const getLocation = (
locationId: string
): TS.Location | null =>
state.locations.find(location => location.uuid === locationId);
+export const getLocationByPath = (
+ state: any,
+ path: string
+): TS.Location | null =>
+ state.locations.find(location => location.path === path);
export const getDefaultLocationId = (state: any): string | undefined => {
let defaultLocationID;
state.locations.map(location => {
diff --git a/package.json b/package.json
index 38669fb33..8f7dac685 100644
--- a/package.json
+++ b/package.json
@@ -180,7 +180,7 @@
"current-git-branch": "^1.1.0",
"detect-port": "^1.3.0",
"devtron": "^1.4.0",
- "electron": "13.2.2",
+ "electron": "15.1.2",
"electron-builder": "^22.10.5",
"electron-devtools-installer": "^3.2.0",
"enzyme": "^2.8.2",
diff --git a/yarn.lock b/yarn.lock
index 466c29aa4..f8bf43a09 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3498,10 +3498,10 @@
ajv "^6.12.0"
ajv-keywords "^3.4.1"
-"@electron/get@^1.0.1":
- version "1.12.4"
- resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.12.4.tgz#a5971113fc1bf8fa12a8789dc20152a7359f06ab"
- integrity sha512-6nr9DbJPUR9Xujw6zD3y+rS95TyItEVM0NVjt1EehY2vUWfIgPiIPVHxCvaTS0xr2B+DRxovYVKbuOWqC35kjg==
+"@electron/get@^1.13.0":
+ version "1.13.0"
+ resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.13.0.tgz#95c6bcaff4f9a505ea46792424f451efea89228c"
+ integrity sha512-+SjZhRuRo+STTO1Fdhzqnv9D2ZhjxXP6egsJ9kiO8dtP68cDx7dFCwWi64dlMQV7sWcfW1OYCW4wviEBzmRsfQ==
dependencies:
debug "^4.1.1"
env-paths "^2.2.0"
@@ -8079,12 +8079,12 @@ electron-window-state@^5.0.3:
jsonfile "^4.0.0"
mkdirp "^0.5.1"
- version "13.2.2"
- resolved "https://registry.yarnpkg.com/electron/-/electron-13.2.2.tgz#332d91891d0db4f9a1d22d4d0bc3b500e59dc051"
- integrity sha512-thGq2YaZqQWK1HexRghxdb26a8hA7ZSebukUSHlnHrY9+Sx9rW7e3uEHbibk/seRXVoXO76HndjKdHyObP9/Kw==
+ version "15.1.2"
+ resolved "https://registry.yarnpkg.com/electron/-/electron-15.1.2.tgz#be1e362ab7307e38155709b0862e6a87f5e748b3"
+ integrity sha512-cU5x1ZvhwcTtzClJrsxqbvCocs40uhuXcdXbXFMpe6XnbnjruTbwrB2V0OxN01pStDrYihnfKo2yhfEvhO3zmw==
dependencies:
- "@electron/get" "^1.0.1"
+ "@electron/get" "^1.13.0"
"@types/node" "^14.6.2"
extract-zip "^1.0.3"
@@ -16043,7 +16043,7 @@ reselect@^4.0.0:
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==
-resize-observer-polyfill@^1.5.1:
+resize-observer-polyfill@^1.5.0, resize-observer-polyfill@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==