Skip to content

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

feat: added open file or folder in new window

Ilian Sapundshievcaab1ec6db0e
diff --git a/app/components/CommonIcons.tsx b/app/components/CommonIcons.tsx
index 7f55abb4f..840583910 100644
--- a/app/components/CommonIcons.tsx
+++ b/app/components/CommonIcons.tsx
@@ -59,3 +59,11 @@ export { default as OpenLinkIcon } from '@mui/icons-material/Link';
export { default as KeyShortcutsIcon } from '@mui/icons-material/Keyboard';
export { default as CancelIcon } from '@mui/icons-material/Cancel';
+
+export { default as OpenNewWindowIcon } from '@mui/icons-material/OpenInBrowser';
+
+export { default as ReloadIcon } from '@mui/icons-material/Refresh';
+
+export { default as DeleteIcon } from '@mui/icons-material/DeleteForever';
+
+export { default as LinkIcon } from '@mui/icons-material/Link';
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index 8f55efff7..10a80f4b3 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -40,22 +40,22 @@ import SaveIcon from '@mui/icons-material/Save';
import CloseIcon from '@mui/icons-material/Close';
import FullScreenIcon from '@mui/icons-material/ZoomOutMap';
import OpenNativelyIcon from '@mui/icons-material/Launch';
-import OpenNewWindowIcon from '@mui/icons-material/OpenInBrowser';
import PrevDocumentIcon from '@mui/icons-material/KeyboardArrowUp';
import NextDocumentIcon from '@mui/icons-material/KeyboardArrowDown';
import FileDownloadIcon from '@mui/icons-material/AssignmentReturned';
import DetailsIcon from '@mui/icons-material/Info';
import ExpandIcon from '@mui/icons-material/SettingsEthernet';
-import DeleteIcon from '@mui/icons-material/Delete';
-import ShareIcon from '@mui/icons-material/Share';
import withStyles from '@mui/styles/withStyles';
-import RefreshIcon from '@mui/icons-material/Refresh';
import Box from '@mui/material/Box';
import ButtonGroup from '@mui/material/ButtonGroup';
import {
ParentFolderIcon,
NavigateToFolderIcon,
- CancelIcon
+ OpenNewWindowIcon,
+ CancelIcon,
+ ReloadIcon,
+ DeleteIcon,
+ LinkIcon
} from '-/components/CommonIcons';
import HistoryIcon from '@mui/icons-material/History';
import { Split } from 'ts-react-splitter';
@@ -1098,7 +1098,7 @@ function EntryContainer(props: Props) {
onClick={() => shareFile(`file:///${openedFile.path}`)}
size="large"
>
- <ShareIcon />
+ <LinkIcon />
</IconButton>
</Tooltip>
)}
@@ -1128,7 +1128,7 @@ function EntryContainer(props: Props) {
onClick={reloadDocument}
size="large"
>
- <RefreshIcon />
+ <ReloadIcon />
</IconButton>
</Tooltip>
{!isReadOnlyMode && (
@@ -1223,7 +1223,7 @@ function EntryContainer(props: Props) {
onClick={reloadDocument}
size="large"
>
- <RefreshIcon />
+ <ReloadIcon />
</IconButton>
</Tooltip>
{isDesktopMode && (
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index f21982af9..190affa2a 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -35,7 +35,6 @@ import Typography from '@mui/material/Typography';
import TextField from '@mui/material/TextField';
import Button from '@mui/material/Button';
import InputAdornment from '@mui/material/InputAdornment';
-import ShareIcon from '@mui/icons-material/Link';
import QRCodeIcon from '@mui/icons-material/QrCode';
import Tooltip from '-/components/Tooltip';
import LocationIcon from '@mui/icons-material/WorkOutline';
@@ -105,6 +104,7 @@ import { actions as LocationActions } from '-/reducers/locations';
import { actions as AppActions } from '-/reducers/app';
import useFirstRender from '-/utils/useFirstRender';
import LinkGeneratorDialog from '-/components/dialogs/LinkGeneratorDialog';
+import { LinkIcon } from '-/components/CommonIcons';
const ThumbnailChooserDialog =
Pro && Pro.UI ? Pro.UI.ThumbnailChooserDialog : false;
@@ -1089,9 +1089,7 @@ function EntryProperties(props: Props) {
readOnly: true,
startAdornment: (
<InputAdornment position="start">
- <ShareIcon
- style={{ color: theme.palette.text.secondary }}
- />
+ <LinkIcon style={{ color: theme.palette.text.secondary }} />
</InputAdornment>
),
endAdornment: (
diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsx
index 0a30501eb..6e1f805a1 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -30,7 +30,7 @@ import {
normalizePath,
generateSharingLink
} from '@tagspaces/tagspaces-common/paths';
-import { Pro } from '../../pro';
+import { Pro } from '-/pro';
import i18n from '-/services/i18n';
import PlatformIO from '-/services/platform-facade';
import {
@@ -119,20 +119,20 @@ function DirectoryMenu(props: Props) {
showNotification
} = props;
+ function generateFolderLink() {
+ const entryFromIndex = selectedEntries[0]['locationID'];
+ const locationID = entryFromIndex
+ ? selectedEntries[0]['locationID']
+ : currentLocation.uuid;
+ const entryPath = selectedEntries[0].path;
+ const tmpLoc = locations.find(location => location.uuid === locationID);
+ const relativePath = getRelativeEntryPath(tmpLoc, entryPath);
+ return generateSharingLink(locationID, undefined, relativePath);
+ }
+
function copySharingLink() {
- if (selectedEntries.length === 1) {
- const entryFromIndex = selectedEntries[0]['locationID'];
- const locationID = entryFromIndex
- ? selectedEntries[0]['locationID']
- : currentLocation.uuid;
- const entryPath = selectedEntries[0].path;
- const tmpLoc = locations.find(location => location.uuid === locationID);
- const relativePath = getRelativeEntryPath(tmpLoc, entryPath);
- const sharingLink = generateSharingLink(
- locationID,
- undefined,
- relativePath
- );
+ if (selectedEntries && selectedEntries.length === 1) {
+ const sharingLink = generateFolderLink();
navigator.clipboard
.writeText(sharingLink)
.then(() => {
@@ -249,6 +249,16 @@ function DirectoryMenu(props: Props) {
props.openDirectory(props.directoryPath);
}
+ function openInNewWindow() {
+ // onClose();
+ if (selectedEntries && selectedEntries.length === 1) {
+ const sharingLink = generateFolderLink();
+ PlatformIO.createNewInstance(
+ window.location.href.split('?')[0] + '?' + sharingLink.split('?')[1]
+ );
+ }
+ }
+
function addExistingFile() {
fileUploadContainerRef.current.onFileUpload();
}
@@ -432,7 +442,8 @@ Do you want to continue?`)
switchPerspective,
showProperties,
cameraTakePicture,
- props.openAddRemoveTagsDialog
+ props.openAddRemoveTagsDialog,
+ openInNewWindow
);
return (
diff --git a/app/components/menus/FileMenu.tsx b/app/components/menus/FileMenu.tsx
index bb1a0e8e3..8d821d740 100644
--- a/app/components/menus/FileMenu.tsx
+++ b/app/components/menus/FileMenu.tsx
@@ -32,9 +32,7 @@ import MoveToTopIcon from '@mui/icons-material/VerticalAlignTop';
import MoveToBottomIcon from '@mui/icons-material/VerticalAlignBottom';
import DuplicateFile from '@mui/icons-material/PostAdd';
import ImageIcon from '@mui/icons-material/Image';
-import ShareIcon from '@mui/icons-material/Link';
import RenameFile from '@mui/icons-material/FormatTextdirectionLToR';
-import DeleteForever from '@mui/icons-material/DeleteForever';
import { formatDateTime4Tag } from '@tagspaces/tagspaces-common/misc';
import AppConfig from '-/AppConfig';
import {
@@ -66,7 +64,11 @@ import {
getSettings,
isDevMode
} from '-/reducers/settings';
-// import AddIcon from '@mui/icons-material/Add';
+import {
+ OpenNewWindowIcon,
+ DeleteIcon,
+ LinkIcon
+} from '-/components/CommonIcons';
interface Props {
anchorEl: Element;
@@ -114,17 +116,21 @@ function FileMenu(props: Props) {
locations
} = props;
+ function generateFileLink() {
+ const entryFromIndex = selectedEntries[0].locationID;
+ const locationID = entryFromIndex
+ ? selectedEntries[0].locationID
+ : currentLocation.uuid;
+ const entryPath = selectedEntries[0].path;
+ const tmpLoc = locations.find(location => location.uuid === locationID);
+ const relativePath = getRelativeEntryPath(tmpLoc, entryPath);
+ return generateSharingLink(locationID, relativePath);
+ }
+
function copySharingLink() {
onClose();
- if (selectedEntries.length === 1) {
- const entryFromIndex = selectedEntries[0].locationID;
- const locationID = entryFromIndex
- ? selectedEntries[0].locationID
- : currentLocation.uuid;
- const entryPath = selectedEntries[0].path;
- const tmpLoc = locations.find(location => location.uuid === locationID);
- const relativePath = getRelativeEntryPath(tmpLoc, entryPath);
- const sharingLink = generateSharingLink(locationID, relativePath);
+ if (selectedEntries && selectedEntries.length === 1) {
+ const sharingLink = generateFileLink();
navigator.clipboard
.writeText(sharingLink)
.then(() => {
@@ -287,6 +293,17 @@ function FileMenu(props: Props) {
);
}
}
+
+ function openInNewWindow() {
+ onClose();
+ if (selectedEntries && selectedEntries.length === 1) {
+ const sharingLink = generateFileLink();
+ PlatformIO.createNewInstance(
+ window.location.href.split('?')[0] + '?' + sharingLink.split('?')[1]
+ );
+ }
+ }
+
const menuItems = [];
const pathLowerCase = selectedFilePath.toLowerCase();
@@ -307,6 +324,18 @@ function FileMenu(props: Props) {
<ListItemText primary={i18n.t('core:openFile')} />
</MenuItem>
);
+ menuItems.push(
+ <MenuItem
+ key="fileMenuOpenFileNewWindow"
+ data-tid="fileMenuOpenFileNewWindow"
+ onClick={openInNewWindow}
+ >
+ <ListItemIcon>
+ <OpenNewWindowIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:openInWindow')} />
+ </MenuItem>
+ );
menuItems.push(
<MenuItem
key="fileMenuOpenParentFolderInternally"
@@ -354,7 +383,6 @@ function FileMenu(props: Props) {
);
menuItems.push(<Divider key="fmDivider" />);
}
-
if (!isReadOnlyMode) {
menuItems.push(
<MenuItem
@@ -402,6 +430,7 @@ function FileMenu(props: Props) {
</MenuItem>
);
}
+ menuItems.push(<Divider key="fmDivider3" />);
menuItems.push(
<MenuItem
key="fileMenuRenameFile"
@@ -438,6 +467,19 @@ function FileMenu(props: Props) {
<ListItemText primary={i18n.t('core:moveCopyFile')} />
</MenuItem>
);
+ menuItems.push(
+ <MenuItem
+ key="fileMenuDeleteFile"
+ data-tid="fileMenuDeleteFile"
+ onClick={showDeleteFileDialog}
+ >
+ <ListItemIcon>
+ <DeleteIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:deleteEntry')} />
+ </MenuItem>
+ );
+ menuItems.push(<Divider key="fmDivider2" />);
if (Pro && selectedEntries.length < 2) {
menuItems.push(
<MenuItem
@@ -466,18 +508,6 @@ function FileMenu(props: Props) {
);
}
}
- menuItems.push(
- <MenuItem
- key="fileMenuDeleteFile"
- data-tid="fileMenuDeleteFile"
- onClick={showDeleteFileDialog}
- >
- <ListItemIcon>
- <DeleteForever />
- </ListItemIcon>
- <ListItemText primary={i18n.t('core:deleteEntry')} />
- </MenuItem>
- );
}
if (selectedEntries.length === 1) {
@@ -488,7 +518,7 @@ function FileMenu(props: Props) {
onClick={copySharingLink}
>
<ListItemIcon>
- <ShareIcon />
+ <LinkIcon />
</ListItemIcon>
<ListItemText primary={i18n.t('core:copySharingLink')} />
</MenuItem>
diff --git a/app/perspectives/common/DirectoryMenuItems.tsx b/app/perspectives/common/DirectoryMenuItems.tsx
index 7ce4b48ad..4f6a25985 100644
--- a/app/perspectives/common/DirectoryMenuItems.tsx
+++ b/app/perspectives/common/DirectoryMenuItems.tsx
@@ -4,9 +4,7 @@ import OpenFolderIcon from '@mui/icons-material/SubdirectoryArrowLeft';
import MoveCopy from '@mui/icons-material/FileCopy';
import ListItemText from '@mui/material/ListItemText';
import i18n from '-/services/i18n';
-import AutoRenew from '@mui/icons-material/Autorenew';
import RenameFolderIcon from '@mui/icons-material/FormatTextdirectionLToR';
-import DeleteForeverIcon from '@mui/icons-material/DeleteForever';
import PlatformIO from '-/services/platform-facade';
import AppConfig from '-/AppConfig';
import OpenFolderNativelyIcon from '@mui/icons-material/Launch';
@@ -17,11 +15,16 @@ import NewFolderIcon from '@mui/icons-material/CreateNewFolder';
import AddExistingFileIcon from '@mui/icons-material/ExitToApp';
import { Pro } from '-/pro';
import ImageIcon from '@mui/icons-material/Image';
-import ShareIcon from '@mui/icons-material/Link';
import ImportTagsIcon from '@mui/icons-material/FindInPage';
import { BetaLabel, ProLabel } from '-/components/HelperComponents';
import { AvailablePerspectives } from '-/perspectives';
import PropertiesIcon from '@mui/icons-material/Info';
+import {
+ ReloadIcon,
+ OpenNewWindowIcon,
+ DeleteIcon,
+ LinkIcon
+} from '-/components/CommonIcons';
import React from 'react';
import { TS } from '-/tagspaces.namespace';
@@ -46,7 +49,8 @@ export function getDirectoryMenuItems(
switchPerspective?: (perspectiveId: string) => void,
showProperties?: () => void,
cameraTakePicture?: () => void,
- showAddRemoveTagsDialog?: () => void
+ showAddRemoveTagsDialog?: () => void,
+ openInNewWindow?: () => void
) {
const menuItems = [];
if (selectedEntriesLength < 2) {
@@ -68,6 +72,23 @@ export function getDirectoryMenuItems(
</MenuItem>
);
}
+ if (openInNewWindow) {
+ menuItems.push(
+ <MenuItem
+ key="openInNewWindow"
+ data-tid="openInNewWindow"
+ onClick={() => {
+ onClose();
+ openInNewWindow();
+ }}
+ >
+ <ListItemIcon>
+ <OpenNewWindowIcon />
+ </ListItemIcon>
+ <ListItemText primary={i18n.t('core:openInWindow')} />
+ </MenuItem>
+ );
+ }
} else if (reloadDirectory) {
menuItems.push(
<MenuItem
@@ -79,7 +100,7 @@ export function getDirectoryMenuItems(
}}
>
<ListItemIcon>
- <AutoRenew />
+ <ReloadIcon />
</ListItemIcon>
<ListItemText primary={i18n.t('core:reloadDirectory')} />
</MenuItem>
@@ -138,7 +159,7 @@ export function getDirectoryMenuItems(
}}
>
<ListItemIcon>
- <DeleteForeverIcon />
+ <DeleteIcon />
</ListItemIcon>
<ListItemText primary={i18n.t('core:deleteDirectory')} />
</MenuItem>
@@ -259,7 +280,7 @@ export function getDirectoryMenuItems(
}}
>
<ListItemIcon>
- <ShareIcon />
+ <LinkIcon />
</ListItemIcon>
<ListItemText primary={i18n.t('core:copySharingLink')} />
</MenuItem>