TagSpaces is an offline, open source, document manager with tagging support
feat: initial implementation for opening new app instances
Ilian Sapundshievbdcceda2f43b
diff --git a/app/components/CustomLogo.tsx b/app/components/CustomLogo.tsxindex 876b1f072..cb48f972f 100644--- a/app/components/CustomLogo.tsx+++ b/app/components/CustomLogo.tsx@@ -24,6 +24,7 @@ import withStyles from '@mui/styles/withStyles';import Badge from '@mui/material/Badge';import Tooltip from '@mui/material/Tooltip';import AppConfig from '@tagspaces/tagspaces-platforms/AppConfig';+import PlatformIO from '-/services/platform-facade';import { Pro } from '../pro';import TextLogoIcon from '../assets/images/text-logo.svg';import WebLogoIcon from '../assets/images/text-logo-web.svg';@@ -62,22 +63,23 @@ if (AppConfig.customLogo) {function CustomLogo(props: Props) {return (- <Tooltip title={i18n.t('core:aboutTitle')}>- <AppVersionBadge badgeContent={'v' + versionMeta.version} color="primary">+ <AppVersionBadge badgeContent={'v' + versionMeta.version} color="primary">+ <Tooltip title={i18n.t('core:openNewInstance')}><IconButton- onClick={props.toggleAboutDialog}+ onClick={() => PlatformIO.createNewInstance()}style={{ padding: 0, paddingLeft: 5, height: 50 }}- data-tid="aboutTagSpaces"+ data-tid="createNewInstance"><imgstyle={{width: 40- // color: props.theme.palette.text.primary}}src={LogoIcon}alt="TagSpaces Logo"/></IconButton>+ </Tooltip>+ <Tooltip title={i18n.t('core:aboutTitle')}><IconButtonstyle={{ height: 50, padding: 0, marginBottom: 15 }}data-tid="aboutTagSpaces"@@ -89,8 +91,8 @@ function CustomLogo(props: Props) {alt="TagSpaces"/></IconButton>- </AppVersionBadge>- </Tooltip>+ </Tooltip>+ </AppVersionBadge>);}diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex b691e5f8a..b17f5e4a1 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -641,6 +641,10 @@ function EntryContainer(props: Props) {};const openInNewWindow = () => {+ PlatformIO.createNewInstance(window.location.href);+ };++ const openInNewWindow2 = () => {const locale = '&locale=' + i18n.language;const filePath = openedFile.url ? openedFile.url : openedFile.path;const fileExt = extractFileExtension(@@ -674,11 +678,7 @@ function EntryContainer(props: Props) {const fileName = extractFileName(openedFile.url ? openedFile.url : openedFile.path);- const newWindow = window.open(- fileOpenerURL,- '_blank'- // 'menubar=0,location=0,toolbar=0,resizable=1,status=1,scrollbars=1'- );+ const newWindow = window.open(fileOpenerURL, '_blank');newWindow.document.title = fileName;};@@ -748,9 +748,9 @@ function EntryContainer(props: Props) {<OpenNewWindowIcon /></IconButton></Tooltip>- <Tooltip title={i18n.t('core:openFileInWindow')}>+ <Tooltip title={i18n.t('core:openInWindow')}><IconButton- aria-label={i18n.t('core:openFileInWindow')}+ aria-label={i18n.t('core:openInWindow')}onClick={openInNewWindow}size="large">@@ -928,6 +928,15 @@ function EntryContainer(props: Props) {<OpenNewWindowIcon /></IconButton></Tooltip>+ <Tooltip title={i18n.t('core:openInWindow')}>+ <IconButton+ aria-label={i18n.t('core:openInWindow')}+ onClick={openInNewWindow}+ size="large"+ >+ <OpenNewWindowIcon />+ </IconButton>+ </Tooltip>{!(PlatformIO.haveObjectStoreSupport() ||PlatformIO.haveWebDavSupport() ||diff --git a/app/components/LoadingLazy.tsx b/app/components/LoadingLazy.tsxindex 520982cab..e86a7b6de 100644--- a/app/components/LoadingLazy.tsx+++ b/app/components/LoadingLazy.tsx@@ -25,10 +25,10 @@ function LoadingLazy() {return (<divstyle={{- width: 1,- height: 1,+ width: 0,+ height: 0,backgroundColor: 'transparent',- padding: 10+ padding: 0}}>...diff --git a/app/components/StoredSearches.tsx b/app/components/StoredSearches.tsxindex 0a0202078..5ade3e2e1 100644--- a/app/components/StoredSearches.tsx+++ b/app/components/StoredSearches.tsx@@ -367,7 +367,7 @@ function StoredSearches(props: Props) {</Grid><Grid container direction="row">{props.storedSearchesVisible && noSearchesFound && (- <Grid item xs={12} style={{ display: 'flex', padding: 10 }}>+ <Grid item xs={12} style={{ textAlign: 'center' }}><Typography variant="caption">{i18n.t('noSavedSearches')}</Typography>diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 47731a505..1f7984109 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -90,7 +90,7 @@"showSearch": "Show Search","deleteDocument": "Delete Document","openFileExternally": "Open File Externally",- "openFileInWindow": "Open File In New Window",+ "openInWindow": "Open in new window","showUnixHiddenFiles": "Show files/directories with a dot(.) in front of the name (e.g. Unix, Linux, OS X hidden files)","checkForNewVersionOnStartup": "Check for new version on startup","reorderTags": "Enable changing the tag order with drag and drop",diff --git a/app/main.dev.ts b/app/main.dev.tsindex 8c20f2348..ea03f649d 100644--- a/app/main.dev.ts+++ b/app/main.dev.ts@@ -308,7 +308,7 @@ function reloadApp() {}}-function createNewWindowInstance(startupParameter?) {+function createNewWindowInstance(url?) {const mainWindowState = windowStateKeeper({defaultWidth: 1280,defaultHeight: 800@@ -329,7 +329,11 @@ function createNewWindowInstance(startupParameter?) {mainWindowInstance.setMenuBarVisibility(false);mainWindowInstance.setAutoHideMenuBar(true);- mainWindowInstance.loadURL(mainHTML); // + startupParameter && startupParameter+ if (url) {+ mainWindowInstance.loadURL(url);+ } else {+ mainWindowInstance.loadURL(mainHTML);+ }}function buildTrayMenu() {@@ -569,6 +573,10 @@ app.on('ready', async () => {}});+ ipcMain.on('create-new-window', (e, url) => {+ createNewWindowInstance(url);+ });+ipcMain.on('focus-window', () => {if (mainWindow) {mainWindow.focus();diff --git a/app/services/platform-facade.ts b/app/services/platform-facade.tsindex ce8001b4a..1afd4c67e 100644--- a/app/services/platform-facade.ts+++ b/app/services/platform-facade.ts@@ -109,6 +109,17 @@ export default class PlatformFacade {static showMainWindow = (): void => platformShowMainWindow();+ static createNewInstance = (url?: string): void => {+ if (AppConfig.isElectron) {+ } else {+ if (url) {+ window.open(url, '_blank');+ } else {+ window.open('index.html', '_blank');+ }+ }+ };+static quitApp = (): void => platformQuitApp();static watchDirectory = (dirPath: string, listener): void =>