TagSpaces is an offline, open source, document manager with tagging support
add skipSelection to CreateDirectoryDialog and use it on create directory in Copy Move dialog (#2336)
Stanimir6d09ec4a3807
diff --git a/src/renderer/components/DirectoryListView.tsx b/src/renderer/components/DirectoryListView.tsxindex c0a25e059..9afde82f0 100644--- a/src/renderer/components/DirectoryListView.tsx+++ b/src/renderer/components/DirectoryListView.tsx@@ -183,10 +183,14 @@ const DirectoryListView: React.FC<Props> = ({style={{ marginLeft: 5, marginTop: 10, marginBottom: 10 }}data-tid="newSubdirectoryTID"onClick={() => {- openCreateDirectoryDialog(chosenDirectory.current, (newDirPath) => {- listDirectory(chosenDirectory.current);- setTargetDir(newDirPath);- });+ openCreateDirectoryDialog(+ chosenDirectory.current,+ (newDirPath) => {+ listDirectory(chosenDirectory.current);+ setTargetDir(newDirPath);+ },+ true,+ );//reflect: false,}}>diff --git a/src/renderer/components/dialogs/CreateDirectoryDialog.tsx b/src/renderer/components/dialogs/CreateDirectoryDialog.tsxindex 889d0b394..da941515b 100644--- a/src/renderer/components/dialogs/CreateDirectoryDialog.tsx+++ b/src/renderer/components/dialogs/CreateDirectoryDialog.tsx@@ -55,13 +55,14 @@ interface Props {open: boolean;onClose: () => void;selectedDirectoryPath?: string;+ skipSelection?: boolean;callback?: (newDirPath: string) => void;}function CreateDirectoryDialog(props: Props) {const { t } = useTranslation();const { createDirectory, setBackgroundColorChange } = useIOActionsContext();- const { findLocation } = useCurrentLocationContext();+ const { currentLocation } = useCurrentLocationContext();const { currentDirectoryPath, getAllPropertiesPromise } =useDirectoryContentContext();const { showNotification } = useNotificationContext();@@ -73,8 +74,7 @@ function CreateDirectoryDialog(props: Props) {const [name, setName] = useState('');const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);- const { open, onClose, selectedDirectoryPath } = props;- const currentLocation = findLocation();+ const { open, onClose, selectedDirectoryPath, skipSelection } = props;const defaultBackgrounds = ['transparent',@@ -129,7 +129,13 @@ function CreateDirectoryDialog(props: Props) {);currentLocation.checkDirExist(dirPath).then((exist) => {if (!exist) {- createDirectory(dirPath).then(() => {+ createDirectory(+ dirPath,+ currentLocation.uuid,+ true,+ true,+ skipSelection,+ ).then(() => {if (props.callback) {props.callback(dirPath);}diff --git a/src/renderer/components/dialogs/hooks/CreateDirectoryDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/CreateDirectoryDialogContextProvider.tsxindex 56a42ceae..fc8da6576 100644--- a/src/renderer/components/dialogs/hooks/CreateDirectoryDialogContextProvider.tsx+++ b/src/renderer/components/dialogs/hooks/CreateDirectoryDialogContextProvider.tsx@@ -30,6 +30,7 @@ type CreateDirectoryDialogContextData = {openCreateDirectoryDialog: (selectedDirectoryPath?: string,callback?: (newDirPath: string) => void,+ skipSelection?: boolean,) => void;closeCreateDirectoryDialog: () => void;};@@ -56,6 +57,7 @@ export const CreateDirectoryDialogContextProvider = ({}: CreateDirectoryDialogContextProviderProps) => {const open = useRef<boolean>(false);const selectedDirectoryPath = useRef<string>(undefined);+ const skipSelection = useRef<boolean>(false);const callbackFn = useRef<(newDirPath: string) => void>(undefined);const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);@@ -81,9 +83,11 @@ export const CreateDirectoryDialogContextProvider = ({function openDialog(directoryPath: string,callback: (newDirPath: string) => void,+ skipSel: boolean = false,) {open.current = true;selectedDirectoryPath.current = directoryPath;+ skipSelection.current = skipSel;callbackFn.current = callback;forceUpdate();}@@ -114,6 +118,7 @@ export const CreateDirectoryDialogContextProvider = ({open={open.current}onClose={closeDialog}selectedDirectoryPath={selectedDirectoryPath.current}+ skipSelection={skipSelection.current}callback={callbackFn.current}/>{children}diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsxindex 28e637e2d..c6a108e97 100644--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx@@ -475,7 +475,8 @@ export const DirectoryContentContextProvider = ({if (currentDirectoryEntries.current.some((entry) => entry.path === action.entry.path,- )+ ) &&+ !action.skipSelection) {selected.push(action.entry);updated = true;diff --git a/src/renderer/hooks/EditedEntryContextProvider.tsx b/src/renderer/hooks/EditedEntryContextProvider.tsxindex 53b8098ba..6d5be5b16 100644--- a/src/renderer/hooks/EditedEntryContextProvider.tsx+++ b/src/renderer/hooks/EditedEntryContextProvider.tsx@@ -33,6 +33,7 @@ type EditedEntryContextData = {entry: TS.FileSystemEntry,open?: boolean,source?: TS.ActionSource,+ skipSelection?: boolean,) => void;};@@ -107,11 +108,13 @@ export const EditedEntryContextProvider = ({* @param entry* @param open* @param actionSource+ * @param skipSelection*/function reflectAddEntry(entry: TS.FileSystemEntry,open = true,actionSource: TS.ActionSource = 'local',+ skipSelection: boolean = false,) {if (!entry.tags || entry.tags.length === 0) {entry.tags = extractTagsAsObjects(entry.name, AppConfig.tagDelimiter);@@ -121,6 +124,7 @@ export const EditedEntryContextProvider = ({entry: entry,open: open,...(typeof actionSource !== 'boolean' && { source: actionSource }),+ ...(skipSelection !== undefined && { skipSelection: skipSelection }),};actions.current = [currentAction];forceUpdate();diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsxindex b845318af..fbbb1dd6d 100644--- a/src/renderer/hooks/IOActionsContextProvider.tsx+++ b/src/renderer/hooks/IOActionsContextProvider.tsx@@ -79,7 +79,13 @@ import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';type IOActionsContextData = {- createDirectory: (directoryPath: string) => Promise<boolean>;+ createDirectory: (+ directoryPath: string,+ locationID?: string,+ reflect?: boolean,+ open?: boolean,+ skipSelection?: boolean,+ ) => Promise<boolean>;deleteEntries: (...entries: TS.FileSystemEntry[]) => Promise<boolean>;deleteDirectory: (directoryPath: string) => Promise<boolean>;deleteFile: (filePath: string, uuid: string) => Promise<boolean>;@@ -350,8 +356,20 @@ export const IOActionsContextProvider = ({}}, [actions]);*/- function createDirectory(directoryPath: string) {- return createDirectoryPromise(directoryPath)+ function createDirectory(+ directoryPath: string,+ locationID?: string,+ reflect: boolean = true,+ open: boolean = true,+ skipSelection: boolean = false,+ ) {+ return createDirectoryPromise(+ directoryPath,+ locationID,+ reflect,+ open,+ skipSelection,+ ).then((result) => {if (result !== undefined && result.dirPath !== undefined) {// eslint-disable-next-line no-param-reassigndiff --git a/src/renderer/hooks/PlatformFacadeContextProvider.tsx b/src/renderer/hooks/PlatformFacadeContextProvider.tsxindex 354060672..84358987a 100644--- a/src/renderer/hooks/PlatformFacadeContextProvider.tsx+++ b/src/renderer/hooks/PlatformFacadeContextProvider.tsx@@ -53,6 +53,8 @@ type PlatformFacadeContextData = {path: string,locationID?: string,reflect?: boolean,+ open?: boolean,+ skipSelection?: boolean,) => Promise<any>;copyFilePromise: (sourceFilePath: string,@@ -190,13 +192,20 @@ export const PlatformFacadeContextProvider = ({path: string,locationID?: string,reflect: boolean = true,+ open: boolean = true,+ skipSelection: boolean = false,): Promise<any> {ignoreByWatcher(path);const currentLocation = getLocation({ locationID });return currentLocation.createDirectoryPromise(path).then((result) => {if (result !== undefined && reflect) {// do not reflect if directory not created- reflectAddEntry(currentLocation.toFsEntry(path, false));+ reflectAddEntry(+ currentLocation.toFsEntry(path, false),+ open,+ 'local',+ skipSelection,+ );}deignoreByWatcher(path);return result;diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.tsindex 6b1328eeb..829d6938d 100644--- a/src/renderer/tagspaces.namespace.d.ts+++ b/src/renderer/tagspaces.namespace.d.ts@@ -126,6 +126,7 @@ export namespace TS {oldEntryPath?: string;open?: boolean;source?: ActionSource;+ skipSelection?: boolean;}interface EditMetaAction {