TagSpaces is an offline, open source, document manager with tagging support
disabling file droping in readonly mode
Ilian Sapundshiev93d60158b6ee
diff --git a/app/components/LocationManager.js b/app/components/LocationManager.jsindex 6369a22c9..e9c6c9725 100644--- a/app/components/LocationManager.js+++ b/app/components/LocationManager.js@@ -58,7 +58,7 @@ import {locationType,type Location} from '../reducers/locations';-import { actions as AppActions, getCurrentLocationId } from '../reducers/app';+import { actions as AppActions, getCurrentLocationId, isReadOnlyMode } from '../reducers/app';import { actions as LocationIndexActions } from '../reducers/location-index';import { getPerspectives } from '../reducers/settings';import i18n from '../services/i18n';@@ -74,6 +74,7 @@ type Props = {locations: Array<Location>,perspectives: Array<Object>,currentLocationId: string,+ isReadOnlyMode: boolean,loadDirectoryContent: (path: string) => void,openLocation: (location: Location) => void,openFileNatively: (path: string) => void,@@ -500,6 +501,14 @@ class LocationManager extends React.Component<Props, State> {* @param monitor*/handleFileMoveDrop = (item, monitor) => {+ if (this.props.isReadOnlyMode) {+ this.props.showNotification(+ i18n.t('core:dndDisabledReadOnlyMode'),+ 'error',+ true+ );+ return;+ }if (monitor) { // TODO handle monitor -> isOver and change folder iconconst { path } = monitor.getItem();console.log('Dropped files: ' + path);@@ -777,7 +786,8 @@ function mapStateToProps(state) {return {locations: getLocations(state),currentLocationId: getCurrentLocationId(state),- perspectives: getPerspectives(state)+ perspectives: getPerspectives(state),+ isReadOnlyMode: isReadOnlyMode(state)};}@@ -794,6 +804,7 @@ function mapDispatchToProps(dispatch) {showInFileManager: AppActions.showInFileManager,openFileNatively: AppActions.openFileNatively,openFile: AppActions.openFile,+ showNotification: AppActions.showNotification,moveFiles: IOActions.moveFiles}, dispatch);}diff --git a/app/containers/MainPage.js b/app/containers/MainPage.jsindex 8f0f2a10d..d3458c8e7 100644--- a/app/containers/MainPage.js+++ b/app/containers/MainPage.js@@ -55,7 +55,8 @@ import {// isFileDragged,isEntryInFullWidth,isUpdateAvailable,- getDirectoryPath+ getDirectoryPath,+ isReadOnlyMode} from '../reducers/app';import { actions as LocationIndexActions, isIndexing } from '../reducers/location-index';import { buffer } from '../utils/misc';@@ -126,6 +127,7 @@ type Props = {lastPublishedVersion: string,isUpdateAvailable: boolean,isFirstRun: boolean,+ isReadOnlyMode: boolean,setFirstRun: (isFirstRun: boolean) => void,setEntryFullWidth: (isFullWidth: boolean) => void,hideNotifications: () => void,@@ -154,7 +156,7 @@ type Props = {setLeftVerticalSplitSize: (splitSize: number) => void,setMainVerticalSplitSize: (splitSize: string) => void,directoryPath?: string,- showNotification?: (+ showNotification: (text: string,notificationType: string,autohide: boolean@@ -298,6 +300,14 @@ class MainPage extends Component<Props, State> {}handleFileDrop = (item, monitor) => {+ if (this.props.isReadOnlyMode) {+ this.props.showNotification(+ i18n.t('core:dndDisabledReadOnlyMode'),+ 'error',+ true+ );+ return;+ }if (monitor) {const { files } = monitor.getItem();console.log('Dropped files: ' + JSON.stringify(files));@@ -575,6 +585,7 @@ function mapStateToProps(state) {return {isIndexing: isIndexing(state),isFirstRun: isFirstRun(state),+ isReadOnlyMode: isReadOnlyMode(state),isGeneratingThumbs: isGeneratingThumbs(state),isFileOpened: isFileOpened(state),// isFileDragged: isFileDragged(state),diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex a6c7a8aa9..69c45cb2f 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -397,5 +397,6 @@"noneOfTheseTags": "None of these tags","collectTagsFromLocation": "Collect Tags From Current Location","searchCurrentFolderWithSubFolders": "Search in folder with sub folders",+ "dndDisabledReadOnlyMode": "Importing files is disabled because the location is in read-only mode.","-": "-"}diff --git a/app/perspectives/grid-perspective/src/index.js b/app/perspectives/grid-perspective/src/index.jsindex b08e677df..34c5c29e6 100644--- a/app/perspectives/grid-perspective/src/index.js+++ b/app/perspectives/grid-perspective/src/index.js@@ -125,7 +125,12 @@ type Props = {editTagForEntry: () => void,perspectiveCommand: Object,directoryContent: Array<FileSystemEntry>,- moveFiles: (files: Array<string>, destination: string) => void+ moveFiles: (files: Array<string>, destination: string) => void,+ showNotification: (+ text: string,+ notificationType: string,+ autohide: boolean+ ) => void};type State = {@@ -552,6 +557,14 @@ class GridPerspective extends React.Component<Props, State> {};handleFileMoveDrop = (item, monitor) => {+ if (this.props.isReadOnlyMode) {+ this.props.showNotification(+ i18n.t('core:dndDisabledReadOnlyMode'),+ 'error',+ true+ );+ return;+ }if (monitor) {const { path } = monitor.getItem();console.log('Dropped files: ' + path);@@ -1238,6 +1251,7 @@ function mapActionCreatorsToProps(dispatch) {return bindActionCreators({moveFiles: IOActions.moveFiles,setSelectedEntries: AppActions.setSelectedEntries,+ showNotification: AppActions.showNotification,addTags: TaggingActions.addTags}, dispatch);}