Skip to content

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

Add context menu for the mapique perspective (#2228)

Stanimir2f34a371630b
diff --git a/src/renderer/components/dialogs/NewAudioDialog.tsx b/src/renderer/components/dialogs/NewAudioDialog.tsx
index afee07af5..5d3d6262b 100644
--- a/src/renderer/components/dialogs/NewAudioDialog.tsx
+++ b/src/renderer/components/dialogs/NewAudioDialog.tsx
@@ -30,12 +30,13 @@ import { useTranslation } from 'react-i18next';
interface Props {
open: boolean;
onClose: () => void;
+ title?: string;
}
const CreateAudio = Pro && Pro.UI ? Pro.UI.CreateAudio : false;
function NewAudioDialog(props: Props) {
- const { open, onClose } = props;
+ const { open, onClose, title } = props;
const { t } = useTranslation();
const theme = useTheme();
@@ -76,7 +77,7 @@ function NewAudioDialog(props: Props) {
}}
data-tid="keyboardShortCutsDialog"
>
- {CreateAudio && <CreateAudio onClose={intOnClose} />}
+ {CreateAudio && <CreateAudio onClose={intOnClose} title={title} />}
</DialogContent>
</Dialog>
</TargetPathContextProvider>
diff --git a/src/renderer/components/dialogs/NewFileDialog.tsx b/src/renderer/components/dialogs/NewFileDialog.tsx
index 90088ef72..550c0bb7d 100644
--- a/src/renderer/components/dialogs/NewFileDialog.tsx
+++ b/src/renderer/components/dialogs/NewFileDialog.tsx
@@ -46,6 +46,7 @@ interface Props {
open: boolean;
onClose: (event?: Object, reason?: string) => void;
fileType?: TS.FileType;
+ fileName?: string;
}
function NewFileDialog(props: Props) {
@@ -63,10 +64,11 @@ function NewFileDialog(props: Props) {
const theme = useTheme();
const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
const fileName = useRef<string>(
- (fileType === 'url' ? 'link' : 'note') +
- AppConfig.beginTagContainer +
- formatDateTime4Tag(new Date(), true) +
- AppConfig.endTagContainer,
+ props.fileName ||
+ (fileType === 'url' ? 'link' : 'note') +
+ AppConfig.beginTagContainer +
+ formatDateTime4Tag(new Date(), true) +
+ AppConfig.endTagContainer,
);
const fileContent = useRef<string>('');
diff --git a/src/renderer/components/dialogs/hooks/NewAudioDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/NewAudioDialogContextProvider.tsx
index 4fe4acca5..0e0bef933 100644
--- a/src/renderer/components/dialogs/hooks/NewAudioDialogContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/NewAudioDialogContextProvider.tsx
@@ -20,7 +20,7 @@ import React, { createContext, useMemo, useReducer, useRef } from 'react';
import LoadingLazy from '-/components/LoadingLazy';
type NewAudioDialogContextData = {
- openNewAudioDialog: () => void;
+ openNewAudioDialog: (title?: string) => void;
closeNewAudioDialog: () => void;
};
@@ -41,11 +41,13 @@ export const NewAudioDialogContextProvider = ({
children,
}: NewAudioDialogContextProviderProps) => {
const open = useRef<boolean>(false);
+ const title = useRef<string>(undefined);
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
- function openDialog() {
+ function openDialog(t = undefined) {
open.current = true;
+ title.current = t;
forceUpdate();
}
@@ -71,7 +73,11 @@ export const NewAudioDialogContextProvider = ({
return (
<NewAudioDialogContext.Provider value={context}>
- <NewAudioDialogAsync open={open.current} onClose={closeDialog} />
+ <NewAudioDialogAsync
+ open={open.current}
+ onClose={closeDialog}
+ title={title.current}
+ />
{children}
</NewAudioDialogContext.Provider>
);
diff --git a/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx
index 7089a8637..bbad73524 100644
--- a/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx
@@ -29,7 +29,7 @@ import { TargetPathContextProvider } from '-/components/dialogs/hooks/TargetPath
import { TS } from '-/tagspaces.namespace';
type NewFileDialogContextData = {
- openNewFileDialog: (entryType?: TS.FileType) => void;
+ openNewFileDialog: (entryType?: TS.FileType, fName?: string) => void;
closeNewFileDialog: () => void;
};
@@ -51,6 +51,7 @@ export const NewFileDialogContextProvider = ({
}: NewFileDialogContextProviderProps) => {
const open = useRef<boolean>(false);
const fileType = useRef<TS.FileType>(undefined);
+ const fileName = useRef<string>(undefined);
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
@@ -68,14 +69,17 @@ export const NewFileDialogContextProvider = ({
}
}, []);
- function openDialog(fType = undefined) {
+ function openDialog(fType = undefined, fName = undefined) {
open.current = true;
fileType.current = fType;
+ fileName.current = fName;
forceUpdate();
}
function closeDialog() {
open.current = false;
+ fileType.current = undefined;
+ fileName.current = undefined;
forceUpdate();
}
@@ -105,6 +109,7 @@ export const NewFileDialogContextProvider = ({
}
}}
fileType={fileType.current}
+ fileName={fileName.current}
/>
{children}
</NewFileDialogContext.Provider>
diff --git a/src/renderer/components/menus/DirectoryMenu.tsx b/src/renderer/components/menus/DirectoryMenu.tsx
index b5314c417..ca448e01e 100644
--- a/src/renderer/components/menus/DirectoryMenu.tsx
+++ b/src/renderer/components/menus/DirectoryMenu.tsx
@@ -16,8 +16,8 @@
*
*/
-import React, { useRef } from 'react';
-import { Menu, MenuList } from '@mui/material';
+import React from 'react';
+import { Menu } from '@mui/material';
import { formatDateTime4Tag } from '@tagspaces/tagspaces-common/misc';
import AppConfig from '-/AppConfig';
import {
@@ -63,12 +63,13 @@ interface Props {
open: boolean;
classes?: any;
onClose: (param?: any) => void;
- anchorEl: Element;
+ anchorEl?: Element;
+ items?: React.ReactNode;
directoryPath: string;
openAddRemoveTagsDialog?: () => void;
switchPerspective?: (perspectiveId: string) => void;
perspectiveMode?: boolean;
- openRenameDirectoryDialog: () => void;
+ openRenameDirectoryDialog?: () => void;
openMoveCopyFilesDialog?: () => void;
mouseX?: number;
mouseY?: number;
@@ -107,6 +108,7 @@ function DirectoryMenu(props: Props) {
anchorEl,
mouseX,
mouseY,
+ items,
openAddRemoveTagsDialog,
openMoveCopyFilesDialog,
openRenameDirectoryDialog,
@@ -412,32 +414,34 @@ Do you want to continue?`)
}
}
- const menuItems = getDirectoryMenuItems(
- currentLocation,
- selectedEntries.length,
- perspectiveMode, // lastSelectedEntryPath !== currentDirectoryPath,
- readOnlyMode,
- onClose,
- t,
- openDir,
- reloadDirectory,
- openRenameDirectoryDialog,
- openMoveCopyFilesDialog,
- showDeleteDirectoryDialog,
- showInFileManager,
- createNewFile,
- createNewAudio,
- openCreateDirectoryDialog,
- addExistingFile,
- setFolderThumbnail,
- copySharingLink,
- importMacTags,
- perspectiveSwitch,
- showProperties,
- cameraTakePicture,
- openAddRemoveTagsDialog,
- openInNewWindow,
- );
+ const menuItems = items
+ ? items
+ : getDirectoryMenuItems(
+ currentLocation,
+ selectedEntries.length,
+ perspectiveMode, // lastSelectedEntryPath !== currentDirectoryPath,
+ readOnlyMode,
+ onClose,
+ t,
+ openDir,
+ reloadDirectory,
+ openRenameDirectoryDialog,
+ openMoveCopyFilesDialog,
+ showDeleteDirectoryDialog,
+ showInFileManager,
+ createNewFile,
+ createNewAudio,
+ openCreateDirectoryDialog,
+ addExistingFile,
+ setFolderThumbnail,
+ copySharingLink,
+ importMacTags,
+ perspectiveSwitch,
+ showProperties,
+ cameraTakePicture,
+ openAddRemoveTagsDialog,
+ openInNewWindow,
+ );
return (
<Menu