TagSpaces is an offline, open source, document manager with tagging support
Upload from local location to s3 with dnd do not work (#2101)
Stanimir82d83113ac75
diff --git a/src/renderer/components/EntryProperties.tsx b/src/renderer/components/EntryProperties.tsxindex 1185740f5..b4c3a621d 100644--- a/src/renderer/components/EntryProperties.tsx+++ b/src/renderer/components/EntryProperties.tsx@@ -97,8 +97,6 @@ import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useNotificationContext } from '-/hooks/useNotificationContext';-import { useFSWatcherContext } from '-/hooks/useFSWatcherContext';-import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';import { generateClipboardLink } from '-/utils/dom';const PREFIX = 'EntryProperties';diff --git a/src/renderer/components/FileUploadContainer.tsx b/src/renderer/components/FileUploadContainer.tsxindex a8a774dc8..2f34d3800 100644--- a/src/renderer/components/FileUploadContainer.tsx+++ b/src/renderer/components/FileUploadContainer.tsx@@ -22,6 +22,7 @@ import { TS } from '-/tagspaces.namespace';import { actions as AppActions, AppDispatch } from '-/reducers/app';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';+import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';interface Props {id: string;@@ -37,6 +38,7 @@ const FileUploadContainer = forwardRef((props: Props, ref: Ref<FileUploadContainerRef>) => {const dispatch: AppDispatch = useDispatch();const { id, directoryPath } = props;+ const { openFileUploadDialog } = useFileUploadDialogContext();const { uploadFilesAPI } = useIOActionsContext();const { setReflectMetaActions } = useEditedEntryMetaContext();@@ -88,7 +90,7 @@ const FileUploadContainer = forwardRef(// console.log("Selected File: "+JSON.stringify(selection.currentTarget.files[0]));// const file = selection.currentTarget.files[0];dispatch(AppActions.resetProgress());- dispatch(AppActions.toggleUploadDialog());+ openFileUploadDialog();uploadFilesAPI(Array.from(selection.currentTarget.files),directoryPath,diff --git a/src/renderer/components/FolderContainer.tsx b/src/renderer/components/FolderContainer.tsxindex b0acc8b0e..0ce066798 100644--- a/src/renderer/components/FolderContainer.tsx+++ b/src/renderer/components/FolderContainer.tsx@@ -49,6 +49,7 @@ import { useTranslation } from 'react-i18next';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import RenderPerspective from '-/components/RenderPerspective';import { adjustKeyBinding } from '-/components/dialogs/KeyboardDialog';+import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';interface Props {toggleDrawer?: () => void;@@ -63,8 +64,8 @@ function FolderContainer(props: Props) {props;const { t } = useTranslation();- const dispatch: AppDispatch = useDispatch();const theme = useTheme();+ const { openFileUploadDialog } = useFileUploadDialogContext();const {setSearchQuery,currentDirectoryEntries,@@ -289,7 +290,7 @@ function FolderContainer(props: Props) {id="progressButton"title={t('core:progress')}data-tid="uploadProgress"- onClick={() => dispatch(AppActions.toggleUploadDialog())}+ onClick={() => openFileUploadDialog()}style={{position: 'relative',padding: '8px 12px 6px 8px',diff --git a/src/renderer/components/LocationView.tsx b/src/renderer/components/LocationView.tsxindex 65bf8d95c..470cc4bf5 100644--- a/src/renderer/components/LocationView.tsx+++ b/src/renderer/components/LocationView.tsx@@ -43,6 +43,7 @@ import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { CommonLocation } from '-/utils/CommonLocation';+import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';interface Props {location: CommonLocation;@@ -55,6 +56,7 @@ function LocationView(props: Props) {const { t } = useTranslation();const { moveFiles, uploadFiles } = useIOActionsContext();+ const { openFileUploadDialog } = useFileUploadDialogContext();const {openLocation,currentLocation,@@ -137,14 +139,14 @@ function LocationView(props: Props) {showNotification(t('core:dndDisabledReadOnlyMode'), 'error', true);return;}- if (!AppConfig.isWin && !path.startsWith('/')) {+ /*if (!AppConfig.isWin && !path.startsWith('/')) {showNotification(t('Moving file not possible'), 'error', true);return;}if (AppConfig.isWin && !path.substr(1).startsWith(':')) {showNotification(t('Moving file not possible'), 'error', true);return;- }+ }*/const targetLocation = item.targetLocation;let targetPath = targetLocation ? targetLocation.path : undefined;if (targetPath === undefined) {@@ -154,16 +156,25 @@ function LocationView(props: Props) {if (targetPath !== undefined && targetLocation !== undefined) {// TODO handle monitor -> isOver and change folder iconconsole.log('Dropped files: ' + path);- if (targetLocation.type === locationType.TYPE_CLOUD) {+ if (targetLocation.type !== currentLocation.type) {+ //locationType.TYPE_CLOUD) {dispatch(AppActions.resetProgress());- dispatch(AppActions.toggleUploadDialog());- return uploadFiles(arrPath, targetPath, onUploadProgress).catch(- (error) => {- console.log('uploadFiles', error);- },- );+ openFileUploadDialog(targetPath);+ return uploadFiles(+ arrPath,+ targetPath,+ onUploadProgress,+ true,+ false,+ targetLocation.uuid,+ ).catch((error) => {+ console.log('uploadFiles', error);+ });} else if (targetLocation.type === locationType.TYPE_LOCAL) {moveFiles(arrPath, targetPath, targetLocation.uuid);+ } else {+ showNotification(t('Moving file not possible'), 'error', true);+ return;}setSelectedEntries([]);}diff --git a/src/renderer/components/TargetFileBox.tsx b/src/renderer/components/TargetFileBox.tsxindex c33da4d40..45f3eec81 100644--- a/src/renderer/components/TargetFileBox.tsx+++ b/src/renderer/components/TargetFileBox.tsx@@ -30,6 +30,7 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useNotificationContext } from '-/hooks/useNotificationContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';+import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';type DragItem = { files: File[]; items: DataTransferItemList };type DragProps = { isActive: boolean; handlerId: Identifier | null };@@ -43,7 +44,9 @@ interface Props {function TargetFileBox(props: Props) {const { t } = useTranslation();const dispatch: AppDispatch = useDispatch();- const { currentLocation, readOnlyMode } = useCurrentLocationContext();+ const { openFileUploadDialog } = useFileUploadDialogContext();+ const { currentLocation, readOnlyMode, findLocalLocation } =+ useCurrentLocationContext();const { uploadFilesAPI } = useIOActionsContext();const { showNotification } = useNotificationContext();const { setReflectMetaActions } = useEditedEntryMetaContext();@@ -75,13 +78,15 @@ function TargetFileBox(props: Props) {);}dispatch(AppActions.resetProgress());- dispatch(AppActions.toggleUploadDialog());+ openFileUploadDialog();return uploadFilesAPI(files,currentDirectoryPath,onUploadProgress,true,false,+ undefined,+ findLocalLocation().uuid,).then((fsEntries: Array<TS.FileSystemEntry>) => {const actions: TS.EditMetaAction[] = fsEntries.map((entry) => ({diff --git a/src/renderer/components/dialogs/FileUploadDialog.tsx b/src/renderer/components/dialogs/FileUploadDialog.tsxindex 59e890c19..37b1cdeb2 100644--- a/src/renderer/components/dialogs/FileUploadDialog.tsx+++ b/src/renderer/components/dialogs/FileUploadDialog.tsx@@ -46,6 +46,7 @@ import { uploadAbort } from '-/services/utils-io';interface Props {open: boolean;title: string;+ targetPath?: string;onClose: () => void;}@@ -58,7 +59,7 @@ function FileUploadDialog(props: Props) {const { currentLocation } = useCurrentLocationContext();const progress = useSelector(getProgress);- const targetPath = React.useRef<string>(getTargetPath());+ const targetPath = React.useRef<string>(getTargetPath()); // todo ContextProvideruseEffect(() => {if (AppConfig.isElectron) {@@ -100,6 +101,9 @@ function FileUploadDialog(props: Props) {let haveProgress = false;function getTargetPath() {+ if (props.targetPath) {+ return props.targetPath;+ }const pathProgress = progress.find((fileProgress) => fileProgress.path);if (pathProgress) {return pathProgress.path;@@ -108,6 +112,9 @@ function FileUploadDialog(props: Props) {}function getTargetURL() {+ if (props.targetPath) {+ return props.targetPath;+ }if (currentLocation) {if (currentLocation.endpointURL) {return (@@ -243,7 +250,7 @@ function FileUploadDialog(props: Props) {data-tid="uploadCloseAndClearTID"onClick={() => {onClose();- dispatch(AppActions.clearUploadDialog());+ //dispatch(AppActions.clearUploadDialog());}}color="primary">diff --git a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsxindex bef4746e1..065ce1047 100644--- a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx+++ b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx@@ -28,6 +28,7 @@ import { useIOActionsContext } from '-/hooks/useIOActionsContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { getDirProperties } from '-/services/utils-io';+import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';interface Props {open: boolean;@@ -43,6 +44,7 @@ function MoveCopyFilesDialog(props: Props) {const { currentDirectoryPath } = useDirectoryContentContext();const { copyFiles, copyDirs, moveFiles, moveDirs } = useIOActionsContext();const { selectedEntries } = useSelectedEntriesContext();+ const { openFileUploadDialog } = useFileUploadDialogContext();const [targetPath, setTargetPath] = useState(currentDirectoryPath ? currentDirectoryPath : '',@@ -147,7 +149,7 @@ function MoveCopyFilesDialog(props: Props) {function handleCopyFiles() {dispatch(AppActions.resetProgress());- dispatch(AppActions.toggleUploadDialog('copyEntriesTitle'));+ openFileUploadDialog(undefined, 'copyEntriesTitle');if (selectedFiles.length > 0) {copyFiles(selectedFiles, targetPath, onUploadProgress);setTargetPath('');@@ -179,7 +181,7 @@ function MoveCopyFilesDialog(props: Props) {}if (selectedDirs.length > 0) {dispatch(AppActions.resetProgress());- dispatch(AppActions.toggleUploadDialog('moveEntriesTitle'));+ openFileUploadDialog(undefined, 'moveEntriesTitle');moveDirs(getEntriesCount(selectedDirs),targetPath,diff --git a/src/renderer/components/dialogs/components/CreateDirectory.tsx b/src/renderer/components/dialogs/components/CreateDirectory.tsxindex dee0c4a16..1d2ddabba 100644--- a/src/renderer/components/dialogs/components/CreateDirectory.tsx+++ b/src/renderer/components/dialogs/components/CreateDirectory.tsx@@ -38,6 +38,7 @@ import { useNotificationContext } from '-/hooks/useNotificationContext';import { Pro } from '-/pro';import { BetaLabel, ProLabel } from '-/components/HelperComponents';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';+import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';const PREFIX = 'CreateDirectory';@@ -63,6 +64,7 @@ function CreateDirectory(props: Props) {const { currentLocation } = useCurrentLocationContext();const { downloadFile } = useIOActionsContext();const { showNotification } = useNotificationContext();+ const { openFileUploadDialog } = useFileUploadDialogContext();const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);const dispatch: AppDispatch = useDispatch();@@ -122,7 +124,7 @@ function CreateDirectory(props: Props) {}if (currentLocation?.haveObjectStoreSupport() || AppConfig.isElectron) {dispatch(AppActions.resetProgress());- dispatch(AppActions.toggleUploadDialog());+ openFileUploadDialog();downloadFile(fileUrl.current,targetDirectoryPath + '/' + decodeURIComponent(fileName),diff --git a/src/renderer/components/dialogs/hooks/FileUploadDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/FileUploadDialogContextProvider.tsxnew file mode 100644index 000000000..b9f1df239--- /dev/null+++ b/src/renderer/components/dialogs/hooks/FileUploadDialogContextProvider.tsx@@ -0,0 +1,79 @@+/**+ * 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, { createContext, useMemo, useReducer, useRef } from 'react';+import FileUploadDialog from '-/components/dialogs/FileUploadDialog';++type FileUploadDialogContextData = {+ openFileUploadDialog: (targetPath?: string, dialogTitle?: string) => void;+ closeFileUploadDialog: () => void;+};++export const FileUploadDialogContext =+ createContext<FileUploadDialogContextData>({+ openFileUploadDialog: undefined,+ closeFileUploadDialog: undefined,+ });++export type FileUploadDialogContextProviderProps = {+ children: React.ReactNode;+};++export const FileUploadDialogContextProvider = ({+ children,+}: FileUploadDialogContextProviderProps) => {+ const open = useRef<boolean>(false);+ const targetPath = useRef<string>(undefined);+ const dialogTitle = useRef<string>('importDialogTitle');++ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ function openDialog(tPath?: string, dTitle?: string) {+ open.current = true;+ targetPath.current = tPath;+ if (dTitle) {+ dialogTitle.current = dTitle;+ }+ forceUpdate();+ }++ function closeDialog() {+ open.current = false;+ targetPath.current = undefined;+ dialogTitle.current = 'importDialogTitle';+ forceUpdate();+ }+ const context = useMemo(() => {+ return {+ openFileUploadDialog: openDialog,+ closeFileUploadDialog: closeDialog,+ };+ }, []);++ return (+ <FileUploadDialogContext.Provider value={context}>+ {children}+ <FileUploadDialog+ open={open.current}+ onClose={() => closeDialog()}+ title={dialogTitle.current}+ targetPath={targetPath.current}+ />+ </FileUploadDialogContext.Provider>+ );+};diff --git a/src/renderer/components/dialogs/hooks/useFileUploadDialogContext.tsx b/src/renderer/components/dialogs/hooks/useFileUploadDialogContext.tsxnew file mode 100644index 000000000..3500bfdbd--- /dev/null+++ b/src/renderer/components/dialogs/hooks/useFileUploadDialogContext.tsx@@ -0,0 +1,6 @@+import { useContext } from 'react';++import { FileUploadDialogContext } from '-/components/dialogs/hooks/FileUploadDialogContextProvider';++export const useFileUploadDialogContext = () =>+ useContext(FileUploadDialogContext);diff --git a/src/renderer/components/dialogs/settings/SettingsExtensions.tsx b/src/renderer/components/dialogs/settings/SettingsExtensions.tsxindex 9c409563b..8c1861912 100644--- a/src/renderer/components/dialogs/settings/SettingsExtensions.tsx+++ b/src/renderer/components/dialogs/settings/SettingsExtensions.tsx@@ -48,11 +48,13 @@ import {unZip,} from '-/services/utils-io';import AppConfig from '-/AppConfig';+import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';function SettingsExtensions() {const { t } = useTranslation();const { currentLocation } = useCurrentLocationContext();const { uploadFilesAPI } = useIOActionsContext();+ const { openFileUploadDialog } = useFileUploadDialogContext();const fileInputRef = useRef<HTMLInputElement>(null);const [removeExtDialogOpened, setRemoveExtDialogOpened] =useState<TS.Extension>(undefined);@@ -69,7 +71,7 @@ function SettingsExtensions() {const files: File[] = Array.from(selection.currentTarget.files);getUserDataDir().then((dataDir) => {dispatch(AppActions.resetProgress());- dispatch(AppActions.toggleUploadDialog());+ openFileUploadDialog();const destinationPath = dataDir + AppConfig.dirSeparator + 'tsplugins';uploadFilesAPI(files, destinationPath, onUploadProgress, false).then((fsEntries: Array<TS.FileSystemEntry>) => {diff --git a/src/renderer/containers/DialogsRoot.tsx b/src/renderer/containers/DialogsRoot.tsxnew file mode 100644index 000000000..0ca8c31e3--- /dev/null+++ b/src/renderer/containers/DialogsRoot.tsx@@ -0,0 +1,34 @@+/**+ * 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 from 'react';+import { FileUploadDialogContextProvider } from '-/components/dialogs/hooks/FileUploadDialogContextProvider';++export type DialogsRootProps = {+ children: React.ReactNode;+};++function DialogsRoot({ children }: DialogsRootProps) {+ return (+ <FileUploadDialogContextProvider>+ {children}+ </FileUploadDialogContextProvider>+ );+}++export default DialogsRoot;diff --git a/src/renderer/containers/MainPage.tsx b/src/renderer/containers/MainPage.tsxindex cf8484774..fbd509edc 100644--- a/src/renderer/containers/MainPage.tsx+++ b/src/renderer/containers/MainPage.tsx@@ -54,7 +54,6 @@ import {isHelpFeedbackPanelOpened,isEditTagDialogOpened,isCreateDirectoryOpened,- isUploadDialogOpened,isNewEntryDialogOpened,isNewFileDialogOpened,isSettingsDialogOpened,@@ -71,7 +70,6 @@ import {import TargetFileBox from '../components/TargetFileBox';import LoadingLazy from '../components/LoadingLazy';import CustomDragLayer from '-/components/CustomDragLayer';-import FileUploadDialog from '-/components/dialogs/FileUploadDialog';import ProgressDialog from '-/components/dialogs/ProgressDialog';import useEventListener from '-/utils/useEventListener';import ConfirmDialog from '-/components/dialogs/ConfirmDialog';@@ -146,11 +144,11 @@ interface Props {isLicenseDialogOpened: boolean;isThirdPartyLibsDialogOpened: boolean;isOnboardingDialogOpened: boolean;- isUploadProgressDialogOpened: string | undefined;+ //isUploadProgressDialogOpened: string | undefined;isTruncatedConfirmDialogOpened: boolean;isProgressDialogOpened: boolean;isProTeaserVisible: boolean;- toggleUploadDialog: () => void;+ //toggleUploadDialog: () => void;toggleOpenLinkDialog: () => void;toggleProgressDialog: () => void;resetProgress: () => void;@@ -478,7 +476,7 @@ function MainPage(props: Props) {toggleNewEntryDialog,toggleNewFileDialog,toggleNewAudioDialog,- toggleUploadDialog,+ //toggleUploadDialog,toggleProgressDialog,toggleEditTagDialog,toggleOpenLinkDialog,@@ -628,13 +626,13 @@ function MainPage(props: Props) {onClose={toggleProTeaser}/>)}- {props.isUploadProgressDialogOpened !== undefined && (+ {/*{props.isUploadProgressDialogOpened !== undefined && (<FileUploadDialogopen={true}onClose={toggleUploadDialog}title={props.isUploadProgressDialogOpened}/>- )}+ )}*/}{props.isTruncatedConfirmDialogOpened && (<IsTruncatedConfirmDialogopen={true}@@ -809,7 +807,7 @@ function mapStateToProps(state) {isOnboardingDialogOpened: isOnboardingDialogOpened(state),isLicenseDialogOpened: isLicenseDialogOpened(state),isThirdPartyLibsDialogOpened: isThirdPartyLibsDialogOpened(state),- isUploadProgressDialogOpened: isUploadDialogOpened(state),+ //isUploadProgressDialogOpened: isUploadDialogOpened(state),isTruncatedConfirmDialogOpened: isTruncatedConfirmDialogOpened(state),isOpenLinkDialogOpened: isOpenLinkDialogOpened(state),isProTeaserVisible: isProTeaserVisible(state),@@ -832,7 +830,7 @@ function mapDispatchToProps(dispatch) {return bindActionCreators({toggleCreateDirectoryDialog: AppActions.toggleCreateDirectoryDialog,- toggleUploadDialog: AppActions.toggleUploadDialog,+ //toggleUploadDialog: AppActions.toggleUploadDialog,toggleProgressDialog: AppActions.toggleProgressDialog,resetProgress: AppActions.resetProgress,toggleEditTagDialog: AppActions.toggleEditTagDialog,@@ -896,8 +894,8 @@ const areEqual = (prevProp, nextProp) =>prevProp.isTruncatedConfirmDialogOpened &&nextProp.isThirdPartyLibsDialogOpened ===prevProp.isThirdPartyLibsDialogOpened &&- nextProp.isUploadProgressDialogOpened ===- prevProp.isUploadProgressDialogOpened &&+ /*nextProp.isUploadProgressDialogOpened ===+ prevProp.isUploadProgressDialogOpened &&*/nextProp.isImportKanBanDialogOpened === prevProp.isImportKanBanDialogOpened &&nextProp.mainSplitSize === prevProp.mainSplitSize;diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsxindex 6984f953d..0a42deed0 100644--- a/src/renderer/containers/Root.tsx+++ b/src/renderer/containers/Root.tsx@@ -45,6 +45,7 @@ import { EditedTagLibraryContextProvider } from '-/hooks/EditedTagLibraryContextimport { EditedKanBanMetaContextProvider } from '-/hooks/EditedKanBanMetaContextProvider';import { PerspectiveActionsContextProvider } from '-/hooks/PerspectiveActionsContextProvider';import { Pro } from '-/pro';+import DialogsRoot from '-/containers/DialogsRoot';type RootType = {store: Store<{}>;@@ -83,15 +84,17 @@ export default function Root({ store, persistor }: RootType) {<TagGroupsLocationContextProvider><TaggingActionsContextProvider><DndProvider backend={HTML5Backend}>- {Pro ? (- <Pro.contextProviders.BookmarksContextProvider>- <Pro.contextProviders.HistoryContextProvider>- <MainPage />- </Pro.contextProviders.HistoryContextProvider>- </Pro.contextProviders.BookmarksContextProvider>- ) : (- <MainPage />- )}+ <DialogsRoot>+ {Pro ? (+ <Pro.contextProviders.BookmarksContextProvider>+ <Pro.contextProviders.HistoryContextProvider>+ <MainPage />+ </Pro.contextProviders.HistoryContextProvider>+ </Pro.contextProviders.BookmarksContextProvider>+ ) : (+ <MainPage />+ )}+ </DialogsRoot></DndProvider></TaggingActionsContextProvider></TagGroupsLocationContextProvider>diff --git a/src/renderer/hooks/CurrentLocationContextProvider.tsx b/src/renderer/hooks/CurrentLocationContextProvider.tsxindex d377cc9fc..fa90f04aa 100644--- a/src/renderer/hooks/CurrentLocationContextProvider.tsx+++ b/src/renderer/hooks/CurrentLocationContextProvider.tsx@@ -50,6 +50,7 @@ type CurrentLocationContextData = {persistTagsInSidecarFile: boolean;getLocationPath: (location: CommonLocation) => Promise<string>;findLocation: (locationID: string) => CommonLocation;+ findLocalLocation: () => CommonLocation;changeLocation: (location: CommonLocation, skipInitDirList?: boolean) => void;editLocation: (location: CommonLocation, openAfterEdit?: boolean) => void;addLocation: (@@ -85,6 +86,7 @@ export const CurrentLocationContext = createContext<CurrentLocationContextData>(persistTagsInSidecarFile: true,getLocationPath: undefined,findLocation: undefined,+ findLocalLocation: undefined,changeLocation: () => {},editLocation: () => {},addLocation: () => {},@@ -203,6 +205,14 @@ export const CurrentLocationContextProvider = ({return currentLocation.current;}+ function findLocalLocation(): CommonLocation {+ const loc = locations.find((l) => l.type === locationType.TYPE_LOCAL);+ if (loc) {+ return loc;+ }+ return undefined;+ }+function setDefaultLocations() {if (!initLocations.current) {initLocations.current = true;@@ -392,6 +402,7 @@ export const CurrentLocationContextProvider = ({persistTagsInSidecarFile,getLocationPath,findLocation,+ findLocalLocation,changeLocation,addLocation,addLocations,diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsxindex 241e91e3b..27f45ec09 100644--- a/src/renderer/hooks/IOActionsContextProvider.tsx+++ b/src/renderer/hooks/IOActionsContextProvider.tsx@@ -116,6 +116,8 @@ type IOActionsContextData = {onUploadProgress?: (progress: Progress, abort, fileName?) => void,uploadMeta?: boolean,open?: boolean,+ targetLocationId?: string,+ sourceLocationId?: string,) => Promise<TS.FileSystemEntry[]>;uploadFiles: (paths: Array<string>,@@ -123,6 +125,8 @@ type IOActionsContextData = {onUploadProgress?: (progress: Progress, abort, fileName?) => void,uploadMeta?: boolean,open?: boolean,+ targetLocationId?: string,+ sourceLocationId?: string,) => Promise<TS.FileSystemEntry[]>;renameDirectory: (directoryPath: string,@@ -814,6 +818,8 @@ export const IOActionsContextProvider = ({* @param uploadMeta - try to upload meta and thumbs if available* reader.onload not work for multiple files https://stackoverflow.com/questions/56178918/react-upload-multiple-files-using-window-filereader* @param open+ * @param targetLocationId+ * @param sourceLocationId*/function uploadFilesAPI(files: Array<any>,@@ -821,6 +827,8 @@ export const IOActionsContextProvider = ({onUploadProgress?: (progress: Progress, abort, fileName?) => void,uploadMeta = true,open = true,+ targetLocationId: string = undefined,+ sourceLocationId: string = undefined,): Promise<TS.FileSystemEntry[]> {if (AppConfig.isElectron || AppConfig.isCordovaiOS) {const arrFiles = [];@@ -833,6 +841,8 @@ export const IOActionsContextProvider = ({onUploadProgress,uploadMeta,open,+ targetLocationId,+ sourceLocationId,);}@@ -957,6 +967,7 @@ export const IOActionsContextProvider = ({fileContent: any,onUploadProgress?: (progress: Progress, response: any) => void,reflect: boolean = true,+ locationID: string = undefined,) {return currentLocation.getPropertiesPromise(filePath)@@ -971,7 +982,7 @@ export const IOActionsContextProvider = ({} else {// dispatch(AppActions.setProgress(filePath, progress));return saveBinaryFilePromise(- { path: filePath },+ { path: filePath, locationID: locationID },fileContent,true,onUploadProgress,@@ -1018,6 +1029,8 @@ export const IOActionsContextProvider = ({* @param onUploadProgress* @param uploadMeta* @param open -> open files after upload+ * @param targetLocationId+ * @param sourceLocationId*/function uploadFiles(paths: Array<string>,@@ -1025,6 +1038,8 @@ export const IOActionsContextProvider = ({onUploadProgress?: (progress: Progress, response: any) => void,uploadMeta = true,open = true,+ targetLocationId: string = undefined,+ sourceLocationId: string = undefined,): Promise<TS.FileSystemEntry[]> {return new Promise((resolve, reject) => {const uploadJobs = [];@@ -1035,12 +1050,12 @@ export const IOActionsContextProvider = ({extractFileName(path, AppConfig.dirSeparator),); // with "/" dir separator cannot extractFileName on Win// fix for Win- if (+ /*if (currentLocation.haveObjectStoreSupport() &&(target.startsWith('\\') || target.startsWith('/'))) {target = target.substr(1);- }+ }*/uploadJobs.push([path, target, 'file']);if (uploadMeta) {// copy meta@@ -1072,9 +1087,8 @@ export const IOActionsContextProvider = ({// TODO try to replace this with <input type="file"if (AppConfig.isElectron) {- // for AWS location getFileContentPromise cannot load with io-objectore- return currentLocation- .getLocalFileContentPromise(job[0])+ return findLocation(sourceLocationId)+ .getFileContentPromise(job[0], 'arraybuffer').then((fileContent) =>uploadFile(filePath,@@ -1082,6 +1096,7 @@ export const IOActionsContextProvider = ({fileContent,onUploadProgress,false,+ targetLocationId,),).catch((err) => {@@ -1103,6 +1118,7 @@ export const IOActionsContextProvider = ({fileContent,onUploadProgress,false,+ targetLocationId,);}return undefined;diff --git a/src/renderer/hooks/PlatformFacadeContextProvider.tsx b/src/renderer/hooks/PlatformFacadeContextProvider.tsxindex ecd648e3f..904c44790 100644--- a/src/renderer/hooks/PlatformFacadeContextProvider.tsx+++ b/src/renderer/hooks/PlatformFacadeContextProvider.tsx@@ -652,18 +652,20 @@ export const PlatformFacadeContextProvider = ({reflect: boolean | TS.ActionSource = true,): Promise<TS.FileSystemEntry> {ignoreByWatcher(param.path);- return getLocation(param)+ const location = getLocation(param);+ return location.saveBinaryFilePromise(param, content, overwrite, onUploadProgress)- .then((fsEntry) => {+ .then((fsEntry: TS.FileSystemEntry) => {+ const entry = { ...fsEntry, locationID: location.uuid };if (reflect) {reflectAddEntry(- fsEntry,+ entry,false,typeof reflect === 'boolean' ? 'local' : reflect,);}deignoreByWatcher(param.path);- return fsEntry;+ return entry;});}diff --git a/src/renderer/reducers/app.ts b/src/renderer/reducers/app.tsindex 4781c3b43..9a910abff 100644--- a/src/renderer/reducers/app.ts+++ b/src/renderer/reducers/app.ts@@ -88,10 +88,10 @@ export const types = {TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG:'APP/TOGGLE_DELETE_MULTIPLE_ENTRIES_DIALOG',TOGGLE_IMPORT_KANBAN_DIALOG: 'APP/TOGGLE_IMPORT_KANBAN_DIALOG',- TOGGLE_UPLOAD_DIALOG: 'APP/TOGGLE_UPLOAD_DIALOG',+ //TOGGLE_UPLOAD_DIALOG: 'APP/TOGGLE_UPLOAD_DIALOG',TOGGLE_TRUNCATED_DIALOG: 'APP/TOGGLE_TRUNCATED_DIALOG',//SET_CURRENT_DIRECTORY_DIRS: 'APP/SET_CURRENT_DIRECTORY_DIRS',- CLEAR_UPLOAD_DIALOG: 'APP/CLEAR_UPLOAD_DIALOG',+ //CLEAR_UPLOAD_DIALOG: 'APP/CLEAR_UPLOAD_DIALOG',TOGGLE_PROGRESS_DIALOG: 'APP/TOGGLE_PROGRESS_DIALOG',OPEN_LOCATIONMANAGER_PANEL: 'APP/OPEN_LOCATIONMANAGER_PANEL',OPEN_TAGLIBRARY_PANEL: 'APP/OPEN_TAGLIBRARY_PANEL',@@ -397,7 +397,7 @@ export default (state: any = initialState, action: any) => {state.createDirectoryDialogOpened !== null ? null : action.props,};}- case types.TOGGLE_UPLOAD_DIALOG: {+ /*case types.TOGGLE_UPLOAD_DIALOG: {// if (PlatformIO.haveObjectStoreSupport()) {// upload dialog have objectStore support onlyreturn {@@ -408,7 +408,7 @@ export default (state: any = initialState, action: any) => {};//}// return state;- }+ }*/case types.TOGGLE_TRUNCATED_DIALOG: {return {...state,@@ -427,7 +427,7 @@ export default (state: any = initialState, action: any) => {}return state;}*/- case types.CLEAR_UPLOAD_DIALOG: {+ /*case types.CLEAR_UPLOAD_DIALOG: {// if (PlatformIO.haveObjectStoreSupport()) {// upload dialog have objectStore support onlyreturn {@@ -437,7 +437,7 @@ export default (state: any = initialState, action: any) => {};// }// return state;- }+ }*/case types.TOGGLE_PROGRESS_DIALOG: {return {...state,@@ -818,10 +818,10 @@ export const actions = {toggleImportKanBanDialog: () => ({type: types.TOGGLE_IMPORT_KANBAN_DIALOG,}),- toggleUploadDialog: (title = '') => ({+ /*toggleUploadDialog: (title = '') => ({type: types.TOGGLE_UPLOAD_DIALOG,title,- }),+ }),*/toggleTruncatedConfirmDialog: () => ({type: types.TOGGLE_TRUNCATED_DIALOG,}),@@ -829,9 +829,9 @@ export const actions = {type: types.SET_CURRENT_DIRECTORY_DIRS,dirs}),*/- clearUploadDialog: () => ({+ /*clearUploadDialog: () => ({type: types.CLEAR_UPLOAD_DIALOG,- }),+ }),*/toggleProgressDialog: () => ({type: types.TOGGLE_PROGRESS_DIALOG,}),@@ -1013,8 +1013,8 @@ export const isDeleteMultipleEntriesDialogOpened = (state: any) =>state.app.deleteMultipleEntriesDialogOpened;export const isImportKanBanDialogOpened = (state: any) =>state.app.importKanBanDialogOpened;-export const isUploadDialogOpened = (state: any) =>- state.app.uploadDialogOpened;+/*export const isUploadDialogOpened = (state: any) =>+ state.app.uploadDialogOpened;*/export const isTruncatedConfirmDialogOpened = (state: any) =>state.app.isTruncatedConfirmDialogOpened;export const isOpenLinkDialogOpened = (state: any) =>diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.tsindex 4dabfb87d..fbdd132f8 100644--- a/src/renderer/utils/CommonLocation.ts+++ b/src/renderer/utils/CommonLocation.ts@@ -706,7 +706,7 @@ export class CommonLocation implements TS.Location {}};- getLocalFileContentPromise = (+ /*getLocalFileContentPromise = (filePath: string,type?: string,): Promise<any> => {@@ -715,7 +715,7 @@ export class CommonLocation implements TS.Location {filePath,type,);- };+ };*/loadTextFilePromise = (param: any, isPreview?: boolean): Promise<string> => {let filePath = this.getPath(param);