Skip to content

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

Shortcut key doesn't work (#1378)

Stanimir507ede585b5b
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index d7ca1647c..53f4fa982 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -205,7 +205,7 @@ interface Props {
) => void;
// reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => void;
updateThumbnailUrl: (path: string, thumbUrl: string) => void;
- setLastSelectedEntry: (path: string) => void;
+ // setLastSelectedEntry: (path: string) => void;
setSelectedEntries: (selectedEntries: Array<Object>) => void;
currentDirectoryPath: string | null;
isDesktopMode: boolean;
@@ -1313,7 +1313,7 @@ function mapActionCreatorsToProps(dispatch) {
// editTagForEntry: TaggingActions.editTagForEntry,
updateOpenedFile: AppActions.updateOpenedFile,
updateThumbnailUrl: AppActions.updateThumbnailUrl,
- setLastSelectedEntry: AppActions.setLastSelectedEntry,
+ // setLastSelectedEntry: AppActions.setLastSelectedEntry,
setSelectedEntries: AppActions.setSelectedEntries
},
dispatch
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index 4978638e5..51579bf3e 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -33,7 +33,7 @@ import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
import DefaultPerspectiveIcon from '@material-ui/icons/GridOn';
import GalleryPerspectiveIcon from '@material-ui/icons/Camera';
import MapiquePerspectiveIcon from '@material-ui/icons/Map';
-import KanBanPerspectiveIcon from '@material-ui/icons/Dashboard';
+// import KanBanPerspectiveIcon from '@material-ui/icons/Dashboard';
import LocationMenu from './menus/LocationMenu';
import DirectoryMenu from './menus/DirectoryMenu';
import i18n from '../services/i18n';
@@ -61,6 +61,7 @@ import LoadingLazy from '../components/LoadingLazy';
import { Pro } from '../pro';
import { enhanceOpenedEntry, FileSystemEntry } from '-/services/utils-io';
import AppConfig from '-/config';
+import RenameEntryDialog from '-/components/dialogs/RenameEntryDialog';
const GridPerspective = React.lazy(() =>
import(
@@ -221,7 +222,8 @@ interface Props {
reflectCreateEntry: (path: string, isFile: boolean) => void;
loadDirectoryContent: (path: string) => void;
loadParentDirectoryContent: () => void;
- setLastSelectedEntry: (entryPath: string | null) => void;
+ setSelectedEntries: (selectedEntries: Array<Object>) => void;
+ // setLastSelectedEntry: (entryPath: string | null) => void;
isReadOnlyMode: boolean;
isDesktopMode: boolean;
showNotification: (content: string) => void;
@@ -243,6 +245,10 @@ const FolderContainer = (props: Props) => {
setDirectoryContextMenuAnchorEl
] = useState<null | HTMLElement>(null);
+ const [isRenameEntryDialogOpened, setIsRenameEntryDialogOpened] = useState<
+ boolean
+ >(false);
+
useEffect(() => {
if (props.openedFiles.length > 0) {
const openedFile = props.openedFiles[0];
@@ -305,6 +311,7 @@ const FolderContainer = (props: Props) => {
}
const openDirectoryMenu = (event: React.MouseEvent<HTMLButtonElement>) => {
+ props.setSelectedEntries([]);
setDirectoryContextMenuAnchorEl(event.currentTarget);
};
@@ -367,12 +374,13 @@ const FolderContainer = (props: Props) => {
directoryContent={props.directoryContent}
loadDirectoryContent={props.loadDirectoryContent}
openFsEntry={props.openFsEntry}
+ openRenameEntryDialog={() => setIsRenameEntryDialogOpened(true)}
loadParentDirectoryContent={props.loadParentDirectoryContent}
renameFile={props.renameFile}
openDirectory={props.openDirectory}
showInFileManager={props.showInFileManager}
currentDirectoryPath={props.currentDirectoryPath}
- setLastSelectedEntry={props.setLastSelectedEntry}
+ // setLastSelectedEntry={props.setLastSelectedEntry}
addTags={props.addTags}
editTagForEntry={props.editTagForEntry}
removeTags={props.removeTags}
@@ -387,12 +395,13 @@ const FolderContainer = (props: Props) => {
directoryContent={props.directoryContent}
loadDirectoryContent={props.loadDirectoryContent}
openFsEntry={props.openFsEntry}
+ openRenameEntryDialog={() => setIsRenameEntryDialogOpened(true)}
loadParentDirectoryContent={props.loadParentDirectoryContent}
renameFile={props.renameFile}
openDirectory={props.openDirectory}
showInFileManager={props.showInFileManager}
currentDirectoryPath={props.currentDirectoryPath}
- setLastSelectedEntry={props.setLastSelectedEntry}
+ // setLastSelectedEntry={props.setLastSelectedEntry}
addTags={props.addTags}
editTagForEntry={props.editTagForEntry}
removeTags={props.removeTags}
@@ -518,6 +527,9 @@ const FolderContainer = (props: Props) => {
anchorEl={directoryContextMenuAnchorEl}
directoryPath={currentDirectoryPath}
loadDirectoryContent={props.loadDirectoryContent}
+ openRenameDirectoryDialog={() =>
+ setIsRenameEntryDialogOpened(true)
+ }
openDirectory={props.openDirectory}
reflectCreateEntry={props.reflectCreateEntry}
openFsEntry={props.openFsEntry}
@@ -534,6 +546,13 @@ const FolderContainer = (props: Props) => {
style={{ height: props.windowHeight }}
>
{renderPerspective()}
+ {isRenameEntryDialogOpened && (
+ <RenameEntryDialog
+ open={isRenameEntryDialogOpened}
+ currentDirectoryPath={props.currentDirectoryPath}
+ onClose={() => setIsRenameEntryDialogOpened(false)}
+ />
+ )}
</div>
</div>
{Pro && props.isDesktopMode && !showWelcomePanel && (
@@ -617,7 +636,7 @@ function mapActionCreatorsToProps(dispatch) {
reflectCreateEntry: AppActions.reflectCreateEntry,
loadDirectoryContent: AppActions.loadDirectoryContent,
loadParentDirectoryContent: AppActions.loadParentDirectoryContent,
- setLastSelectedEntry: AppActions.setLastSelectedEntry,
+ setSelectedEntries: AppActions.setSelectedEntries,
showNotification: AppActions.showNotification,
openSearchPanel: AppActions.openSearchPanel,
setCurrentDirectoryPerspective: AppActions.setCurrentDirectoryPerspective,
diff --git a/app/components/dialogs/RenameDirectoryDialog.tsx b/app/components/dialogs/RenameDirectoryDialog.tsx
deleted file mode 100644
index 58b714513..000000000
--- a/app/components/dialogs/RenameDirectoryDialog.tsx
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * 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/>.
- *
- */
-
-import React, { useReducer, useRef, useState } from 'react';
-import { bindActionCreators } from 'redux';
-import { connect } from 'react-redux';
-import Button from '@material-ui/core/Button';
-import TextField from '@material-ui/core/TextField';
-import DialogActions from '@material-ui/core/DialogActions';
-import DialogContent from '@material-ui/core/DialogContent';
-import DialogTitle from '@material-ui/core/DialogTitle';
-import FormControl from '@material-ui/core/FormControl';
-import FormHelperText from '@material-ui/core/FormHelperText';
-import Dialog from '@material-ui/core/Dialog';
-import i18n from '-/services/i18n';
-import { extractDirectoryName } from '-/utils/paths';
-import { actions as AppActions } from '-/reducers/app';
-import PlatformIO from '-/services/platform-io';
-
-interface Props {
- open: boolean;
- selectedDirectoryPath: string;
- onClose: () => void;
- renameDirectory: (directoryPath: string, newDirectoryName: string) => void;
-}
-
-const RenameDirectoryDialog = (props: Props) => {
- const [inputError, setInputError] = useState<boolean>(false);
- const disableConfirmButton = useRef<boolean>(true);
- const name = useRef<string>(
- props.selectedDirectoryPath
- ? extractDirectoryName(
- props.selectedDirectoryPath,
- PlatformIO.getDirSeparator()
- )
- : ''
- );
-
- // eslint-disable-next-line no-unused-vars
- const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
-
- const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- name.current = event.target.value;
- handleValidation();
- };
-
- const handleValidation = () => {
- // const nameRegex = this.state.name.match('^[A-Z][-a-zA-Z]+$');
- if (name.current.length > 0) {
- if (inputError) {
- setInputError(false);
- } else {
- // rerender
- forceUpdate();
- }
- disableConfirmButton.current = false;
- } else {
- if (!inputError) {
- setInputError(true);
- } else {
- // rerender
- forceUpdate();
- }
- disableConfirmButton.current = true;
- }
- };
-
- const onConfirm = () => {
- if (!disableConfirmButton.current) {
- props.renameDirectory(props.selectedDirectoryPath, name.current);
- props.onClose();
- }
- };
-
- const { open, onClose } = props;
-
- return (
- <Dialog
- open={open}
- onClose={onClose}
- keepMounted
- scroll="paper"
- onKeyDown={event => {
- if (event.key === 'Enter' || event.keyCode === 13) {
- event.preventDefault();
- event.stopPropagation();
- onConfirm();
- } else if (event.key === 'Escape') {
- onClose();
- }
- }}
- >
- <DialogTitle>{i18n.t('core:renameDirectory')}</DialogTitle>
- <DialogContent>
- <FormControl fullWidth={true} error={inputError}>
- <TextField
- fullWidth={true}
- autoFocus
- required
- error={inputError}
- margin="dense"
- name="name"
- label={i18n.t('core:renameDirectoryTitleName')}
- onChange={handleInputChange}
- defaultValue={name.current}
- data-tid="renameDirectoryDialogInput"
- />
- <FormHelperText>{i18n.t('core:directoryNameHelp')}</FormHelperText>
- </FormControl>
- </DialogContent>
- <DialogActions>
- <Button
- data-tid="closeRenameDirectoryDialog"
- onClick={props.onClose}
- color="primary"
- >
- {i18n.t('core:cancel')}
- </Button>
- <Button
- disabled={disableConfirmButton.current}
- onClick={onConfirm}
- data-tid="confirmRenameDirectory"
- color="primary"
- >
- {i18n.t('core:ok')}
- </Button>
- </DialogActions>
- </Dialog>
- );
-};
-
-function mapActionCreatorsToProps(dispatch) {
- return bindActionCreators(
- {
- renameDirectory: AppActions.renameDirectory
- },
- dispatch
- );
-}
-
-export default connect(null, mapActionCreatorsToProps)(RenameDirectoryDialog);
diff --git a/app/components/dialogs/RenameEntryDialog.tsx b/app/components/dialogs/RenameEntryDialog.tsx
new file mode 100644
index 000000000..cb1a6c13b
--- /dev/null
+++ b/app/components/dialogs/RenameEntryDialog.tsx
@@ -0,0 +1,244 @@
+/**
+ * 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/>.
+ *
+ */
+
+import React, { useReducer, useRef, useState } from 'react';
+import { bindActionCreators } from 'redux';
+import { connect } from 'react-redux';
+import Button from '@material-ui/core/Button';
+import TextField from '@material-ui/core/TextField';
+import DialogActions from '@material-ui/core/DialogActions';
+import DialogContent from '@material-ui/core/DialogContent';
+import DialogTitle from '@material-ui/core/DialogTitle';
+import FormControl from '@material-ui/core/FormControl';
+import FormHelperText from '@material-ui/core/FormHelperText';
+import Dialog from '@material-ui/core/Dialog';
+import i18n from '-/services/i18n';
+import {
+ extractContainingDirectoryPath,
+ extractDirectoryName,
+ extractFileName
+} from '-/utils/paths';
+import { actions as AppActions, getLastSelectedEntry } from '-/reducers/app';
+import PlatformIO from '-/services/platform-io';
+import AppConfig from '-/config';
+
+interface Props {
+ open: boolean;
+ currentDirectoryPath?: string;
+ lastSelectedEntry: any;
+ onClose: () => void;
+ renameFile: (source: string, target: string) => void;
+ renameDirectory: (directoryPath: string, newDirectoryName: string) => void;
+}
+
+const RenameEntryDialog = (props: Props) => {
+ const [inputError, setInputError] = useState<boolean>(false);
+ const disableConfirmButton = useRef<boolean>(true);
+
+ let defaultName = '';
+ let originPath;
+ let isFile;
+ if (props.lastSelectedEntry) {
+ ({ isFile } = props.lastSelectedEntry);
+ if (isFile) {
+ defaultName = extractFileName(
+ props.lastSelectedEntry.path,
+ PlatformIO.getDirSeparator()
+ );
+ } else {
+ defaultName = extractDirectoryName(
+ props.lastSelectedEntry.path,
+ PlatformIO.getDirSeparator()
+ );
+ }
+ originPath = props.lastSelectedEntry.path;
+ } else if (props.currentDirectoryPath) {
+ isFile = false;
+ defaultName = extractDirectoryName(
+ props.currentDirectoryPath,
+ PlatformIO.getDirSeparator()
+ );
+ originPath = props.currentDirectoryPath;
+ } else {
+ return (
+ <Dialog open={props.open} onClose={props.onClose}>
+ <DialogTitle>{i18n.t('core:noSelectedEntryError')}</DialogTitle>
+ </Dialog>
+ );
+ }
+ const name = useRef<string>(defaultName);
+
+ // eslint-disable-next-line no-unused-vars
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
+
+ const onInputFocus = event => {
+ // https://github.com/mui-org/material-ui/issues/1594
+ // const timer = setTimeout(() => {
+ if (name.current) {
+ event.preventDefault();
+ const { target } = event;
+ target.focus();
+ // inputElement.focus();
+ // if (defaultName) {
+ const indexOfBracket = name.current.indexOf(AppConfig.beginTagContainer);
+ const indexOfDot = name.current.lastIndexOf('.');
+ let endRange = name.current.length;
+ if (indexOfBracket > 0) {
+ endRange = indexOfBracket;
+ } else if (indexOfDot > 0) {
+ endRange = indexOfDot;
+ }
+ target.setSelectionRange(0, endRange);
+ // }
+ }
+ // }, 100);
+
+ // return () => clearTimeout(timer);
+ };
+
+ const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ name.current = event.target.value;
+ handleValidation();
+ };
+
+ const handleValidation = () => {
+ const initValid = disableConfirmButton.current;
+ if (name.current.length > 0) {
+ const rg1 = /^[^#\\/:*?"<>|]+$/; // forbidden characters # \ / : * ? " < > |
+ if (isFile) {
+ // https://stackoverflow.com/a/11101624/2285631
+ const rg2 = /^\./; // cannot start with dot (.)
+ const rg3 = /^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i; // forbidden file names
+ disableConfirmButton.current = !(
+ rg1.test(name.current) &&
+ !rg2.test(name.current) &&
+ !rg3.test(name.current)
+ );
+ } else disableConfirmButton.current = !rg1.test(name.current);
+ setInputError(disableConfirmButton.current);
+ } else {
+ disableConfirmButton.current = true;
+ }
+ if (initValid !== disableConfirmButton.current) {
+ setInputError(disableConfirmButton.current);
+ forceUpdate();
+ }
+ };
+
+ const onConfirm = () => {
+ if (!disableConfirmButton.current) {
+ if (isFile) {
+ const fileDirectory = extractContainingDirectoryPath(
+ props.lastSelectedEntry.path,
+ PlatformIO.getDirSeparator()
+ );
+ const newFilePath =
+ fileDirectory + PlatformIO.getDirSeparator() + name.current;
+ props.renameFile(originPath, newFilePath);
+ } else {
+ props.renameDirectory(originPath, name.current);
+ }
+ props.onClose();
+ }
+ };
+
+ const { open, onClose } = props;
+
+ return (
+ <Dialog
+ open={open}
+ onClose={onClose}
+ keepMounted
+ scroll="paper"
+ onKeyDown={event => {
+ if (event.key === 'Enter' || event.keyCode === 13) {
+ event.preventDefault();
+ event.stopPropagation();
+ onConfirm();
+ } else if (event.key === 'Escape') {
+ onClose();
+ }
+ }}
+ >
+ <DialogTitle>
+ {i18n.t('core:' + (isFile ? 'renameFileTitle' : 'renameDirectory'))}
+ </DialogTitle>
+ <DialogContent>
+ <FormControl fullWidth={true} error={inputError}>
+ <TextField
+ autoFocus
+ required
+ error={inputError}
+ margin="dense"
+ name="entryName"
+ label={i18n.t(
+ 'core:' +
+ (isFile ? 'renameNewFileName' : 'renameDirectoryTitleName')
+ )}
+ onChange={handleInputChange}
+ onFocus={onInputFocus}
+ defaultValue={name.current}
+ fullWidth={true}
+ data-tid="renameEntryDialogInput"
+ />
+ <FormHelperText>
+ {i18n.t('core:' + (isFile ? 'fileNameHelp' : 'directoryNameHelp'))}
+ </FormHelperText>
+ </FormControl>
+ </DialogContent>
+ <DialogActions>
+ <Button
+ data-tid="closeRenameEntryDialog"
+ onClick={props.onClose}
+ color="primary"
+ >
+ {i18n.t('core:cancel')}
+ </Button>
+ <Button
+ disabled={disableConfirmButton.current}
+ onClick={onConfirm}
+ data-tid="confirmRenameEntry"
+ color="primary"
+ >
+ {i18n.t('core:ok')}
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+};
+
+function mapStateToProps(state) {
+ return {
+ lastSelectedEntry: getLastSelectedEntry(state)
+ };
+}
+
+function mapActionCreatorsToProps(dispatch) {
+ return bindActionCreators(
+ {
+ renameFile: AppActions.renameFile,
+ renameDirectory: AppActions.renameDirectory
+ },
+ dispatch
+ );
+}
+
+export default connect(
+ mapStateToProps,
+ mapActionCreatorsToProps
+)(RenameEntryDialog);
diff --git a/app/components/dialogs/RenameFileDialog.tsx b/app/components/dialogs/RenameFileDialog.tsx
deleted file mode 100644
index 590b8801e..000000000
--- a/app/components/dialogs/RenameFileDialog.tsx
+++ /dev/null
@@ -1,235 +0,0 @@
-/**
- * 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/>.
- *
- */
-
-import React, { useEffect, useRef, useState } from 'react';
-import { bindActionCreators } from 'redux';
-import { connect } from 'react-redux';
-import Button from '@material-ui/core/Button';
-import TextField from '@material-ui/core/TextField';
-import Dialog from '@material-ui/core/Dialog';
-import DialogActions from '@material-ui/core/DialogActions';
-import DialogContent from '@material-ui/core/DialogContent';
-import DialogTitle from '@material-ui/core/DialogTitle';
-import { withStyles } from '@material-ui/core/styles';
-import FormControl from '@material-ui/core/FormControl';
-import FormHelperText from '@material-ui/core/FormHelperText';
-import AppConfig from '-/config';
-import i18n from '-/services/i18n';
-import { extractFileName, extractContainingDirectoryPath } from '-/utils/paths';
-import { actions as AppActions } from '-/reducers/app';
-import PlatformIO from '-/services/platform-io';
-
-interface Props {
- open: boolean;
- selectedFilePath: string;
- classes: any;
- renameFile: (source: string, target: string) => void;
- onClose: (clearSelection?: boolean) => void;
-}
-
-const styles = theme => ({
- root: {
- width: 550,
- height: '100%',
- marginBottom: 30,
- background: theme.palette.background.paper
- }
-});
-
-const RenameFileDialog = (props: Props) => {
- const [inputError, setInputError] = useState(false);
- // const [disableConfirmButton, setDisableConfirmButton] = useState(true);
- const fileNameInput = useRef<HTMLInputElement>(null);
- let fileName = extractFileName(
- props.selectedFilePath,
- PlatformIO.getDirSeparator()
- );
-
- useEffect(() => {
- // https://github.com/mui-org/material-ui/issues/1594
- const timer = setTimeout(() => {
- if (fileNameInput && fileNameInput.current) {
- fileNameInput.current.focus();
- if (fileName) {
- const indexOfBracket = fileName.indexOf(AppConfig.beginTagContainer);
- const indexOfDot = fileName.lastIndexOf('.');
- let endRange = fileName.length;
- if (indexOfBracket > 0) {
- endRange = indexOfBracket;
- } else if (indexOfDot > 0) {
- endRange = indexOfDot;
- }
- fileNameInput.current.setSelectionRange(0, endRange);
- }
- }
- }, 100);
-
- return () => clearTimeout(timer);
- }, [props.selectedFilePath]);
- /**
- * todo rewrite this to functional componet
- * its have problem with e2e test dialog is displayed without fileName -> its set here in state later
- * @param nextProps
- */
- /* componentWillReceiveProps = (nextProps: any) => {
- if (nextProps.open) {
- const fileName = extractFileName(
- nextProps.selectedFilePath,
- PlatformIO.getDirSeparator()
- );
- this.setState({ fileName }, () => {
- this.fileName.focus();
- if (fileName) {
- const indexOfBracket = fileName.indexOf(AppConfig.beginTagContainer);
- const indexOfDot = fileName.lastIndexOf('.');
- let endRange = fileName.length;
- if (indexOfBracket > 0) {
- endRange = indexOfBracket;
- } else if (indexOfDot > 0) {
- endRange = indexOfDot;
- }
- this.fileName.setSelectionRange(0, endRange);
- }
- return {
- fileName
- };
- });
- }
- }; */
-
- const handleRenameFile = (event: React.ChangeEvent<HTMLInputElement>) => {
- const { target } = event;
- const { value, name } = target;
-
- if (name === 'fileName') {
- fileName = value;
- handleValidation();
- // this.setState({ fileName: value }, this.handleValidation);
- }
- };
-
- const handleValidation = () => {
- if (fileName.length > 0) {
- setInputError(false);
- // this.setState({ inputError: false, disableConfirmButton: false });
- } else {
- setInputError(true);
- // this.setState({ inputError: true, disableConfirmButton: true });
- }
- };
-
- const onConfirm = () => {
- if (!inputError) {
- const fileDirectory = extractContainingDirectoryPath(
- props.selectedFilePath,
- PlatformIO.getDirSeparator()
- );
- const newFilePath =
- fileDirectory + PlatformIO.getDirSeparator() + fileName;
- props.renameFile(props.selectedFilePath, newFilePath);
- props.onClose(true);
- // this.setState({ inputError: false, disableConfirmButton: true });
- } else {
- handleValidation();
- }
- };
-
- const renderTitle = () => (
- <DialogTitle>{i18n.t('core:renameFileTitle')}</DialogTitle>
- );
-
- const renderContent = () => (
- <DialogContent className={props.classes.root}>
- <FormControl
- data-tid="renameFileDialog"
- fullWidth={true}
- error={inputError}
- >
- <TextField
- error={inputError}
- margin="dense"
- name="fileName"
- autoFocus
- inputRef={fileNameInput}
- label={i18n.t('core:renameNewFileName')}
- onChange={handleRenameFile}
- defaultValue={fileName}
- data-tid="renameFileDialogInput"
- fullWidth={true}
- />
- {inputError && <FormHelperText>Empty File Name</FormHelperText>}
- </FormControl>
- </DialogContent>
- );
-
- const renderActions = () => (
- <DialogActions>
- <Button
- data-tid="closeRenameFileDialog"
- onClick={() => props.onClose()}
- color="primary"
- >
- {i18n.t('core:cancel')}
- </Button>
- <Button
- disabled={inputError}
- onClick={onConfirm}
- data-tid="confirmRenameFileDialog"
- color="primary"
- >
- {i18n.t('core:ok')}
- </Button>
- </DialogActions>
- );
-
- const { onClose, open } = props;
- return (
- <Dialog
- open={open}
- keepMounted
- onClose={onClose}
- onKeyDown={event => {
- if (event.key === 'Enter' || event.keyCode === 13) {
- event.preventDefault();
- event.stopPropagation();
- onConfirm();
- } else if (event.key === 'Escape') {
- onClose();
- }
- }}
- >
- {renderTitle()}
- {renderContent()}
- {renderActions()}
- </Dialog>
- );
-};
-
-function mapActionCreatorsToProps(dispatch) {
- return bindActionCreators(
- {
- renameFile: AppActions.renameFile
- },
- dispatch
- );
-}
-
-export default connect(
- null,
- mapActionCreatorsToProps
-)(withStyles(styles)(RenameFileDialog));
diff --git a/app/components/dialogs/settings/SettingsKeyBindings.tsx b/app/components/dialogs/settings/SettingsKeyBindings.tsx
index af7316279..874ee59a0 100644
--- a/app/components/dialogs/settings/SettingsKeyBindings.tsx
+++ b/app/components/dialogs/settings/SettingsKeyBindings.tsx
@@ -108,7 +108,13 @@ function mapStateToProps(state) {
}
function mapActionCreatorsToProps(dispatch) {
- return bindActionCreators(SettingsActions, dispatch);
+ return bindActionCreators(
+ {
+ setKeyBinding: SettingsActions.setKeyBinding,
+ setGlobalKeyBinding: SettingsActions.setGlobalKeyBinding
+ },
+ dispatch
+ );
}
export default connect(
diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsx
index 8b9317ac1..e48b67ad1 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -43,7 +43,7 @@ import SettingsIcon from '@material-ui/icons/Settings';
import { Progress } from 'aws-sdk/clients/s3';
import { Pro } from '../../pro';
import CreateDirectoryDialog from '../dialogs/CreateDirectoryDialog';
-import RenameDirectoryDialog from '../dialogs/RenameDirectoryDialog';
+// import RenameDirectoryDialog from '../dialogs/RenameDirectoryDialog';
import AppConfig from '-/config';
import i18n from '-/services/i18n';
import { normalizePath } from '-/utils/paths';
@@ -99,6 +99,7 @@ interface Props {
updateIndex: boolean
) => void;
toggleDeleteMultipleEntriesDialog: () => void;
+ openRenameDirectoryDialog: () => void;
selectedEntries: Array<any>;
setSelectedEntries: (selectedEntries: Array<Object>) => void;
mouseX?: number;
@@ -113,10 +114,10 @@ const DirectoryMenu = (props: Props) => {
isCreateDirectoryDialogOpened,
setIsCreateDirectoryDialogOpened
] = useState(false);
- const [
+ /* const [
isRenameDirectoryDialogOpened,
setIsRenameDirectoryDialogOpened
- ] = useState(false);
+ ] = useState(false); */
function reloadDirectory() {
props.onClose();
@@ -177,7 +178,8 @@ const DirectoryMenu = (props: Props) => {
function showRenameDirectoryDialog() {
props.onClose();
- setIsRenameDirectoryDialogOpened(true);
+ props.openRenameDirectoryDialog();
+ // setIsRenameDirectoryDialogOpened(true);
}
function showCreateDirectoryDialog() {
@@ -326,14 +328,14 @@ Do you want to continue?`)
return (
<div style={{ overflowY: 'hidden' }}>
- {isRenameDirectoryDialogOpened && (
+ {/* {isRenameDirectoryDialogOpened && (
<RenameDirectoryDialog
key={'renameDir' + props.directoryPath}
open={isRenameDirectoryDialogOpened}
onClose={() => setIsRenameDirectoryDialogOpened(false)}
selectedDirectoryPath={props.directoryPath}
/>
- )}
+ )} */}
{isCreateDirectoryDialogOpened && ( // TODO move dialogs in MainContainer and don't include the Menu HTML always
<CreateDirectoryDialog
key={'createDir' + props.directoryPath}
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index c000bee6d..ceaef7373 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -186,7 +186,7 @@ interface Props {
toggleThirdPartyLibsDialog: () => void; // neede by electron-menus
toggleAboutDialog: () => void; // needed by electron-menus
toggleOnboardingDialog: () => void; // needed by electron-menus
- setLastSelectedEntry: (path: string) => void; // needed by electron-menus
+ // setLastSelectedEntry: (path: string) => void; // needed by electron-menus
setSelectedEntries: (selectedEntries: Array<Object>) => void; // needed by electron-menus
openFsEntry: (fsEntry: FileSystemEntry) => void; // needed by electron-menus
openFileNatively: (url: string) => void; // needed by electron-menus
@@ -908,7 +908,7 @@ function mapDispatchToProps(dispatch) {
toggleAboutDialog: AppActions.toggleAboutDialog,
toggleOnboardingDialog: AppActions.toggleOnboardingDialog,
toggleOpenLinkDialog: AppActions.toggleOpenLinkDialog,
- setLastSelectedEntry: AppActions.setLastSelectedEntry,
+ // setLastSelectedEntry: AppActions.setLastSelectedEntry,
setSelectedEntries: AppActions.setSelectedEntries,
setGeneratingThumbnails: AppActions.setGeneratingThumbnails,
openFsEntry: AppActions.openFsEntry,
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index 6a78a53b7..994608c77 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -37,7 +37,6 @@ import EntryTagMenu from '-/components/menus/EntryTagMenu';
import i18n from '-/services/i18n';
import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';
import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';
-import RenameFileDialog from '-/components/dialogs/RenameFileDialog';
import TargetMoveFileBox from '-/components/TargetMoveFileBox';
import FileSourceDnd from '-/components/FileSourceDnd';
import AppConfig from '-/config';
@@ -67,20 +66,21 @@ interface Props {
theme: any;
desktopMode: boolean;
currentDirectoryPath: string;
- lastSelectedEntryPath: string | null;
+ lastSelectedEntry: any;
selectedEntries: Array<any>;
supportedFileTypes: Array<any>;
isReadOnlyMode: boolean;
- openFsEntry: (fsEntry: FileSystemEntry) => void;
+ openFsEntry: (fsEntry?: FileSystemEntry) => void;
openNextFile: () => any;
openPrevFile: () => any;
+ openRenameEntryDialog: () => void;
loadDirectoryContent: (path: string) => void;
openDirectory: (path: string) => void;
showInFileManager: (path: string) => void;
- openFileNatively: (path: string) => void;
+ openFileNatively: (path?: string) => void;
openURLExternally: (path: string) => void;
loadParentDirectoryContent: () => void;
- setLastSelectedEntry: (entryPath: string | null) => void;
+ // setLastSelectedEntry: (entryPath: string | null) => void;
setSelectedEntries: (selectedEntries: Array<Object>) => void;
addTags: () => void;
removeTags: (paths: Array<string>, tags: Array<Tag>) => void;
@@ -104,7 +104,8 @@ const GridPerspective = (props: Props) => {
const mouseX = useRef<number>(undefined);
const mouseY = useRef<number>(undefined);
const allFilesSelected = useRef<boolean>(false);
- const selectedEntryPath = useRef<string>('');
+ // const selectedEntry = useRef<FileSystemEntry>(undefined);
+ const selectedEntryPath = useRef<string>(undefined);
const selectedTag = useRef<Tag | null>(null);
const [
fileContextMenuAnchorEl,
@@ -166,9 +167,9 @@ const GridPerspective = (props: Props) => {
isAddRemoveTagsDialogOpened,
setIsAddRemoveTagsDialogOpened
] = useState<boolean>(false);
- const [isFileRenameDialogOpened, setIsFileRenameDialogOpened] = useState<
+ /* const [isRenameEntryDialogOpened, setIsRenameEntryDialogOpened] = useState<
boolean
- >(false);
+ >(false); */
const [isGridSettingsDialogOpened, setIsGridSettingsDialogOpened] = useState<
boolean
>(false);
@@ -273,15 +274,18 @@ const GridPerspective = (props: Props) => {
const {
selectedEntries,
directoryContent,
- lastSelectedEntryPath,
- setLastSelectedEntry,
+ lastSelectedEntry,
+ // setLastSelectedEntry,
setSelectedEntries
} = props;
const selectHelperKey = AppConfig.isMacLike ? event.metaKey : event.ctrlKey;
if (event.shiftKey) {
- let lastSelectedIndex = directoryContent.findIndex(
- entry => entry.path === lastSelectedEntryPath
- );
+ let lastSelectedIndex;
+ if (lastSelectedEntry) {
+ lastSelectedIndex = directoryContent.findIndex(
+ entry => entry.path === lastSelectedEntry.path
+ );
+ }
const currentSelectedIndex = directoryContent.findIndex(
entry => entry.path === fsEntry.path
);
@@ -297,13 +301,13 @@ const GridPerspective = (props: Props) => {
currentSelectedIndex + 1
);
} else if (currentSelectedIndex < lastSelectedIndex) {
- entriesToSelect = directoryContent.slice(
- currentSelectedIndex,
- lastSelectedIndex + 1
- );
+ entriesToSelect = directoryContent
+ .slice(currentSelectedIndex, lastSelectedIndex + 1)
+ .reverse();
} else if (currentSelectedIndex === lastSelectedIndex) {
entriesToSelect = [fsEntry];
- setLastSelectedEntry(fsEntry.path);
+ // setLastSelectedEntry(fsEntry.path);
+ // selectedEntry.current = fsEntry;
}
setSelectedEntries(entriesToSelect);
@@ -316,11 +320,13 @@ const GridPerspective = (props: Props) => {
selectedEntries.filter(entry => entry.path !== fsEntry.path)
); // deselect selected entry
} else {
+ // selectedEntry.current = fsEntry;
setSelectedEntries([...selectedEntries, fsEntry]);
}
} else {
setSelectedEntries([fsEntry]);
- setLastSelectedEntry(fsEntry.path);
+ // setLastSelectedEntry(fsEntry.path);
+ // selectedEntry.current = fsEntry;
if (fsEntry.isFile) {
if (singleClickAction === 'openInternal') {
props.openFsEntry(fsEntry);
@@ -335,7 +341,9 @@ const GridPerspective = (props: Props) => {
const clearSelection = () => {
props.setSelectedEntries([]);
allFilesSelected.current = false;
- props.setLastSelectedEntry(null);
+ // props.setLastSelectedEntry(null);
+ // selectedEntry.current = undefined;
+ selectedEntryPath.current = undefined;
};
const toggleSelectAllFiles = () => {
@@ -451,7 +459,7 @@ const GridPerspective = (props: Props) => {
]);
}
setFileContextMenuAnchorEl(event.currentTarget);
- selectedEntryPath.current = fsEntry.path;
+ // selectedEntry.current = fsEntry;
}
} else {
if (props.selectedEntries.length === 0 || !folderOperationsEnabled()) {
@@ -463,7 +471,7 @@ const GridPerspective = (props: Props) => {
fsEntry
]);
}
- selectedEntryPath.current = fsEntry.path;
+ // selectedEntry.current = fsEntry;
setDirContextMenuAnchorEl(event.currentTarget);
}
};
@@ -633,10 +641,20 @@ const GridPerspective = (props: Props) => {
if (props.selectedEntries.length > 0) {
props.setSelectedEntries([]);
}
- selectedEntryPath.current = props.currentDirectoryPath;
+ // selectedEntryPath.current = props.currentDirectoryPath;
setDirContextMenuAnchorEl(e.currentTarget);
};
+ const getSelEntryPath = () => {
+ /* if (selectedEntryPath.current) {
+ return selectedEntryPath.current;
+ } */
+ if (props.lastSelectedEntry) {
+ return props.lastSelectedEntry.path;
+ }
+ return props.currentDirectoryPath;
+ };
+
const keyBindingHandlers = {
nextDocument: () => props.openNextFile(),
prevDocument: () => props.openPrevFile(),
@@ -647,45 +665,56 @@ const GridPerspective = (props: Props) => {
}
},
addRemoveTags: () => {
- if (props.selectedEntries && props.selectedEntries.length > 0) {
+ // if (props.selectedEntries && props.selectedEntries.length > 0) {
+ if (getSelEntryPath()) {
openAddRemoveTagsDialog();
}
},
renameFile: () => {
- if (
+ /* if (
props.selectedEntries &&
props.selectedEntries.length === 1 &&
props.selectedEntries[0].isFile
- ) {
- selectedEntryPath.current = props.selectedEntries[0].path;
- setIsFileRenameDialogOpened(true);
- }
+ ) { */
+ // selectedEntryPath.current = props.selectedEntries[0].path;
+ // if (selectedEntry.current) {
+ // if (selectedEntry.current.isFile) {
+ props.openRenameEntryDialog();
},
openEntry: e => {
e.preventDefault();
- const { lastSelectedEntryPath } = props;
- if (lastSelectedEntryPath) {
- const lastSelectedEntryFile = props.directoryContent.find(
- fsEntry => fsEntry.isFile && fsEntry.path === lastSelectedEntryPath
- );
- if (lastSelectedEntryFile) {
- props.openFsEntry(lastSelectedEntryFile);
+ // const { lastSelectedEntry } = props;
+ /* const lastSelectedEntryFile = props.directoryContent.find(
+ fsEntry => fsEntry.isFile && fsEntry.path === selectedEntryPath.current // lastSelectedEntryPath
+ ); */
+ props.openFsEntry();
+
+ /* if (lastSelectedEntry) {
+ if (lastSelectedEntry.isFile) {
+ props.openFsEntry(lastSelectedEntry);
} else {
- props.loadDirectoryContent(lastSelectedEntryPath);
+ props.loadDirectoryContent(lastSelectedEntry.path); // lastSelectedEntryPath);
}
- }
+ } */
},
openFileExternally: () => {
- if (props.lastSelectedEntryPath) {
- props.openFileNatively(props.lastSelectedEntryPath);
- }
+ props.openFileNatively();
+ // if (props.lastSelectedEntryPath) {
+ /* const { lastSelectedEntry } = props;
+ if (lastSelectedEntry) {
+ if (lastSelectedEntry.isFile) {
+ props.openFileNatively(lastSelectedEntry.path);
+ }
+ } */
}
};
const { classes, selectedEntries, loadParentDirectoryContent, theme } = props;
const selectedFilePaths = selectedEntries
- .filter(fsEntry => fsEntry.isFile)
- .map(fsentry => fsentry.path);
+ ? selectedEntries
+ .filter(fsEntry => fsEntry.isFile)
+ .map(fsentry => fsentry.path)
+ : [];
const sortedDirectories = sortedDirContentMemoized.filter(
entry => !entry.isFile
);
@@ -710,13 +739,6 @@ const GridPerspective = (props: Props) => {
'px)'
}}
>
- {/* <style>
- {`
- #gridCellTags:hover, #gridCellDescription:hover {
- opacity: 1
- }
- `}
- </style> */}
<MainToolbar
classes={classes}
layoutType={layoutType}
@@ -736,7 +758,11 @@ const GridPerspective = (props: Props) => {
handleOptionsMenu={handleOptionsMenu}
isDesktopMode={props.isDesktopMode}
/>
- <GlobalHotKeys keyMap={keyMap} handlers={keyBindingHandlers}>
+ <GlobalHotKeys
+ keyMap={keyMap}
+ handlers={keyBindingHandlers}
+ allowChanges={true}
+ >
<GridPagination
gridPageLimit={gridPageLimit}
className={
@@ -786,13 +812,6 @@ const GridPerspective = (props: Props) => {
selectedFiles={selectedFilePaths}
/>
)}
- {isFileRenameDialogOpened && (
- <RenameFileDialog
- open={isFileRenameDialogOpened}
- onClose={() => setIsFileRenameDialogOpened(false)}
- selectedFilePath={selectedEntryPath.current}
- />
- )}
{Boolean(fileContextMenuAnchorEl) && (
<FileMenu
@@ -800,7 +819,7 @@ const GridPerspective = (props: Props) => {
open={Boolean(fileContextMenuAnchorEl)}
onClose={() => setFileContextMenuAnchorEl(null)}
openDeleteFileDialog={openDeleteFileDialog}
- openRenameFileDialog={() => setIsFileRenameDialogOpened(true)}
+ openRenameFileDialog={props.openRenameEntryDialog}
openMoveCopyFilesDialog={openMoveCopyFilesDialog}
openAddRemoveTagsDialog={openAddRemoveTagsDialog}
openFsEntry={props.openFsEntry}
@@ -809,7 +828,7 @@ const GridPerspective = (props: Props) => {
showInFileManager={props.showInFileManager}
showNotification={props.showNotification}
isReadOnlyMode={props.isReadOnlyMode}
- selectedFilePath={selectedEntryPath.current}
+ selectedFilePath={getSelEntryPath()}
selectedEntries={props.selectedEntries}
/>
)}
@@ -818,14 +837,13 @@ const GridPerspective = (props: Props) => {
open={Boolean(dirContextMenuAnchorEl)}
onClose={() => setDirContextMenuAnchorEl(null)}
anchorEl={dirContextMenuAnchorEl}
- directoryPath={selectedEntryPath.current}
+ directoryPath={getSelEntryPath()}
loadDirectoryContent={props.loadDirectoryContent}
+ openRenameDirectoryDialog={props.openRenameEntryDialog}
openDirectory={props.openDirectory}
openFsEntry={props.openFsEntry}
isReadOnlyMode={props.isReadOnlyMode}
- perspectiveMode={
- selectedEntryPath.current !== props.currentDirectoryPath
- }
+ perspectiveMode={getSelEntryPath() !== props.currentDirectoryPath}
mouseX={mouseX.current}
mouseY={mouseY.current}
/>
@@ -835,7 +853,7 @@ const GridPerspective = (props: Props) => {
open={Boolean(tagContextMenuAnchorEl)}
onClose={() => setTagContextMenuAnchorEl(null)}
selectedTag={selectedTag.current}
- currentEntryPath={selectedEntryPath.current}
+ currentEntryPath={selectedEntryPath.current} // getSelEntryPath()}
removeTags={props.removeTags}
isReadOnlyMode={props.isReadOnlyMode}
/>
@@ -894,7 +912,7 @@ function mapStateToProps(state) {
return {
supportedFileTypes: getSupportedFileTypes(state),
isReadOnlyMode: isReadOnlyMode(state),
- lastSelectedEntryPath: getLastSelectedEntry(state),
+ lastSelectedEntry: getLastSelectedEntry(state),
desktopMode: getDesktopMode(state),
selectedEntries: getSelectedEntries(state),
keyBindings: getKeyBindingObject(state),
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index af0e69e18..675568528 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -217,7 +217,7 @@ export const initialState = {
thirdPartyLibsDialogOpened: false,
settingsDialogOpened: false,
createDirectoryDialogOpened: false,
- lastSelectedEntry: null,
+ // lastSelectedEntry: null,
selectedEntries: [],
isEntryInFullWidth: false,
isGeneratingThumbs: false,
@@ -296,13 +296,9 @@ export default (state: any = initialState, action: any) => {
currentLocationId: action.locationId
};
}
- case types.SET_LAST_SELECTED_ENTRY: {
- /* console.time('SET_LAST_SELECTED_ENTRY'); // Measure set last selected entry
- const result = { ...state, lastSelectedEntry: action.entryPath };
- console.timeEnd('SET_LAST_SELECTED_ENTRY');
- return result; */
+ /* case types.SET_LAST_SELECTED_ENTRY: {
return { ...state, lastSelectedEntry: action.entryPath };
- }
+ } */
case types.SET_SELECTED_ENTRIES: {
return { ...state, selectedEntries: action.selectedEntries };
}
@@ -1046,10 +1042,10 @@ export const actions = {
type: types.SET_GENERATING_THUMBNAILS,
isGeneratingThumbs
}),
- setLastSelectedEntry: (entryPath: string | null) => ({
+ /* setLastSelectedEntry: (entryPath: string | null) => ({
type: types.SET_LAST_SELECTED_ENTRY,
entryPath
- }),
+ }), */
setCurrentDirectoryColor: (color: string) => ({
type: types.SET_CURRENDIRECTORYCOLOR,
color
@@ -1243,6 +1239,7 @@ export const actions = {
getAllPropertiesPromise(filePath)
.then((fsEntry: FileSystemEntry) => {
dispatch(actions.openFsEntry(fsEntry)); // TODO return fsEntry from saveFilePromise and simplify
+ dispatch(actions.setSelectedEntries([fsEntry]));
return true;
})
.catch(error =>
@@ -1253,7 +1250,6 @@ export const actions = {
error
)
);
- // TODO select file // dispatch(actions.setLastSelectedEntry(filePath));
return true;
})
.catch(err => {
@@ -1300,7 +1296,7 @@ export const actions = {
dispatch(actions.reflectCreateEntry(filePath, true));
dispatch(actions.openFsEntry(fsEntry)); // TODO return fsEntry from saveFilePromise and simplify
- dispatch(actions.setLastSelectedEntry(filePath));
+ dispatch(actions.setSelectedEntries([fsEntry]));
dispatch(
actions.showNotification(
`File '${fileNameAndExt}' created.`,
@@ -1541,10 +1537,21 @@ export const actions = {
});
}
},
- openFsEntry: (fsEntry: FileSystemEntry) => (
+ openFsEntry: (fsEntry?: FileSystemEntry) => (
dispatch: (actions: Object) => void,
getState: () => any
) => {
+ if (fsEntry === undefined) {
+ // eslint-disable-next-line no-param-reassign
+ fsEntry = getLastSelectedEntry(getState());
+ if (fsEntry === undefined) {
+ return;
+ }
+ if (!fsEntry.isFile) {
+ dispatch(actions.loadDirectoryContent(fsEntry.path));
+ return;
+ }
+ }
let entryForOpening: OpenedEntry;
const { openedFiles } = getState().app;
/**
@@ -1609,14 +1616,15 @@ export const actions = {
dispatch: (actions: Object) => void,
getState: () => any
) => {
+ const lastSelectedEntry = getLastSelectedEntry(getState());
const nextFile = getNextFile(
path,
- getState().app.lastSelectedEntry,
+ lastSelectedEntry ? lastSelectedEntry.path : undefined,
getState().app.currentDirectoryEntries
);
if (nextFile !== undefined) {
dispatch(actions.openFsEntry(nextFile));
- dispatch(actions.setLastSelectedEntry(nextFile.path));
+ // dispatch(actions.setLastSelectedEntry(nextFile.path));
dispatch(actions.setSelectedEntries([nextFile]));
return nextFile;
}
@@ -1625,14 +1633,15 @@ export const actions = {
dispatch: (actions: Object) => void,
getState: () => any
) => {
+ const lastSelectedEntry = getLastSelectedEntry(getState());
const prevFile = getPrevFile(
path,
- getState().app.lastSelectedEntry,
+ lastSelectedEntry ? lastSelectedEntry.path : undefined,
getState().app.currentDirectoryEntries
);
if (prevFile !== undefined) {
dispatch(actions.openFsEntry(prevFile));
- dispatch(actions.setLastSelectedEntry(prevFile.path));
+ // dispatch(actions.setLastSelectedEntry(prevFile.path));
dispatch(actions.setSelectedEntries([prevFile]));
}
},
@@ -1836,8 +1845,24 @@ export const actions = {
);
throw error;
}),
- openFileNatively: (selectedFile: string) => () => {
- PlatformIO.openFile(selectedFile);
+ openFileNatively: (selectedFile?: string) => (
+ dispatch: (actions: Object) => void,
+ getState: () => any
+ ) => {
+ if (selectedFile === undefined) {
+ // eslint-disable-next-line no-param-reassign
+ const fsEntry = getLastSelectedEntry(getState());
+ if (fsEntry === undefined) {
+ return;
+ }
+ if (fsEntry.isFile) {
+ PlatformIO.openFile(fsEntry.path);
+ } else {
+ PlatformIO.openDirectory(fsEntry.path);
+ }
+ } else {
+ PlatformIO.openFile(selectedFile);
+ }
},
openLink: (url: string) => (
dispatch: (actions: Object) => void,
@@ -2041,9 +2066,16 @@ export const getCurrentLocationPath = (state: any) => {
export const isUpdateAvailable = (state: any) => state.app.isUpdateAvailable;
export const isUpdateInProgress = (state: any) => state.app.isUpdateInProgress;
export const isOnline = (state: any) => state.app.isOnline;
-export const getLastSelectedEntry = (state: any) => state.app.lastSelectedEntry;
+export const getLastSelectedEntry = (state: any) => {
+ const { selectedEntries } = state.app;
+ if (selectedEntries && selectedEntries.length > 0) {
+ return selectedEntries[selectedEntries.length - 1];
+ }
+ return undefined;
+};
export const getSelectedTag = (state: any) => state.app.tag;
-export const getSelectedEntries = (state: any) => state.app.selectedEntries;
+export const getSelectedEntries = (state: any) =>
+ state.app.selectedEntries ? state.app.selectedEntries : [];
export const isGeneratingThumbs = (state: any) => state.app.isGeneratingThumbs;
export const isReadOnlyMode = (state: any) => state.app.isReadOnlyMode;
export const isOnboardingDialogOpened = (state: any) =>
diff --git a/package.json b/package.json
index bc0b8cbf9..d434fcc05 100644
--- a/package.json
+++ b/package.json
@@ -163,7 +163,7 @@
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"chalk": "^2.4.1",
- "chromedriver": "^88.0.0",
+ "chromedriver": "^89.0.0",
"concat-licenses": "^2.0.1",
"concurrently": "^4.1.0",
"cross-env": "^5.2.0",
diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.js
index 21b0b5009..5ca287bdd 100644
--- a/tests/e2e/location.helpers.js
+++ b/tests/e2e/location.helpers.js
@@ -150,13 +150,13 @@ export async function renameFileFromMenu(newFileName, selector = selectorFile) {
await openContextEntryMenu(selector, 'fileMenuRenameFile');
// await global.client.pause(500);
const renameFileDialogInput = await global.client.$(
- '[data-tid=renameFileDialogInput] input'
+ '[data-tid=renameEntryDialogInput] input'
);
await renameFileDialogInput.waitForDisplayed({ timeout: 5000 });
fileName = await renameFileDialogInput.getValue();
- await setInputKeys('renameFileDialogInput', newFileName);
- await clickOn('[data-tid=confirmRenameFileDialog]');
+ await setInputKeys('renameEntryDialogInput', newFileName);
+ await clickOn('[data-tid=confirmRenameEntry]');
await waitForNotification();
return fileName;
}
@@ -175,7 +175,7 @@ export async function getFirstFileName() {
let fileName;
await openContextEntryMenu(selectorFile, 'fileMenuRenameFile');
const renameFileDialogInput = await global.client.$(
- '[data-tid=renameFileDialogInput] input'
+ '[data-tid=renameEntryDialogInput] input'
);
await renameFileDialogInput.waitForDisplayed({ timeout: 5000 });
fileName = await renameFileDialogInput.getValue();
diff --git a/tests/e2e/perspective-grid-right-button.e2e.js b/tests/e2e/perspective-grid-right-button.e2e.js
index 5cf331820..6d66eb209 100644
--- a/tests/e2e/perspective-grid-right-button.e2e.js
+++ b/tests/e2e/perspective-grid-right-button.e2e.js
@@ -335,11 +335,8 @@ describe('TST50** - Right button on a file', () => {
perspectiveGridTable + firstFolder,
'renameDirectory'
);
- const oldDirName = await setInputKeys(
- 'renameDirectoryDialogInput',
- newDirName
- );
- await clickOn('[data-tid=confirmRenameDirectory]');
+ const oldDirName = await setInputKeys('renameEntryDialogInput', newDirName);
+ await clickOn('[data-tid=confirmRenameEntry]');
await waitForNotification();
//turn dir name back
@@ -347,11 +344,8 @@ describe('TST50** - Right button on a file', () => {
perspectiveGridTable + firstFolder,
'renameDirectory'
);
- const renamedDir = await setInputKeys(
- 'renameDirectoryDialogInput',
- oldDirName
- );
- await clickOn('[data-tid=confirmRenameDirectory]');
+ const renamedDir = await setInputKeys('renameEntryDialogInput', oldDirName);
+ await clickOn('[data-tid=confirmRenameEntry]');
await waitForNotification();
expect(renamedDir).toBe(newDirName);
});
diff --git a/tests/e2e/test-utils.js b/tests/e2e/test-utils.js
index 2fd2e0194..1966c1fbc 100644
--- a/tests/e2e/test-utils.js
+++ b/tests/e2e/test-utils.js
@@ -81,7 +81,7 @@ export async function renameFolder() {
await clickOn('[data-tid=folderContainerOpenDirMenu]');
await clickOn('[data-tid=renameDirectory]');
// set new dir name
- await setInputKeys('renameDirectoryDialogInput', newDirectoryName);
- await clickOn('[data-tid=confirmRenameDirectory]');
+ await setInputKeys('renameEntryDialogInput', newDirectoryName);
+ await clickOn('[data-tid=confirmRenameEntry]');
return newDirectoryName;
}
diff --git a/yarn.lock b/yarn.lock
index b9764ae2f..2ff63bad6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6178,10 +6178,10 @@ chrome-trace-event@^1.0.2:
dependencies:
tslib "^1.9.0"
-chromedriver@^88.0.0:
- version "88.0.0"
- resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-88.0.0.tgz#6833fffd516db23c811eeafa1ee1069b5a12fd2f"
- integrity sha512-EE8rXh7mikxk3VWKjUsz0KCUX8d3HkQ4HgMNJhWrWjzju12dKPPVHO9MY+YaAI5ryXrXGNf0Y4HcNKgW36P/CA==
+chromedriver@^89.0.0:
+ version "89.0.0"
+ resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-89.0.0.tgz#a6f27aa306400651a20dc04976fe5b2c4e65d61a"
+ integrity sha512-+DVYp3+m6tZUYTMl9fEgCZIDk9YBTcHws82nIV1JYwusu51zRITA0oeNzuPyFhuK7ageFnnKCDviH2BL5I4M0w==
dependencies:
"@testim/chrome-version" "^1.0.7"
axios "^0.21.1"