TagSpaces is an offline, open source, document manager with tagging support
fix: open external links in electron, add confirmation
Ilian Sapundshievdbb6310d8e94
diff --git a/app/components/dialogs/AboutDialog.tsx b/app/components/dialogs/AboutDialog.tsxindex c627809bb..ea884da06 100644--- a/app/components/dialogs/AboutDialog.tsx+++ b/app/components/dialogs/AboutDialog.tsx@@ -28,7 +28,6 @@ import semver from 'semver';import LogoIcon from '-/assets/images/icon100x100.svg';import i18n from '-/services/i18n';import versionMeta from '-/version.json';-import PlatformIO from '-/services/platform-io';import { Pro } from '-/pro';import { getLastVersionPromise } from '-/reducers/settings';import AppConfig from '-/config';@@ -36,6 +35,7 @@ import AppConfig from '-/config';interface Props {open: boolean;fullScreen: boolean;+ openURLExternally: (url: string) => void;toggleLicenseDialog: () => void;toggleThirdPartyLibsDialog: () => void;onClose: () => void;@@ -56,7 +56,7 @@ const AboutDialog = (props: Props) => {function checkForUpdates() {if (updateAvailable) {- PlatformIO.openUrl(AppConfig.links.downloadURL);+ props.openURLExternally(AppConfig.links.downloadURL);} else {getLastVersionPromise().then(lastVersion => {@@ -122,15 +122,19 @@ const AboutDialog = (props: Props) => {navigator.appVersion}>- Version: {versionMeta.version} / BuildID: {buildID}+ Version:+ {versionMeta.version} BuildID:+ {buildID}</Typography><br /><Typography id="aboutContent" variant="body1">- <strong>{productName}</strong> is made possible by the- TagSpaces(github.com/tagspaces) open source project and other{' '}+ <strong>{productName}</strong>+ is made possible by the TagSpaces(github.com/tagspaces) open source+ project and other<Buttonsize="small"color="primary"+ style={{ marginLeft: 10 }}onClick={props.toggleThirdPartyLibsDialog}>open source software@@ -155,7 +159,7 @@ const AboutDialog = (props: Props) => {size="small"color="primary"onClick={() => {- PlatformIO.openUrl(AppConfig.links.imprintURL);+ props.openURLExternally(AppConfig.links.imprintURL);}}>Imprint@@ -164,7 +168,7 @@ const AboutDialog = (props: Props) => {size="small"color="primary"onClick={() => {- PlatformIO.openUrl(AppConfig.links.privacyURL);+ props.openURLExternally(AppConfig.links.privacyURL);}}>Privacy Policy@@ -173,7 +177,7 @@ const AboutDialog = (props: Props) => {size="small"color="primary"onClick={() => {- PlatformIO.openUrl(AppConfig.links.changelogURL);+ props.openURLExternally(AppConfig.links.changelogURL);}}>Changelog@@ -194,7 +198,7 @@ const AboutDialog = (props: Props) => {data-tid="checkForUpdates"title={i18n.t('core:checkForNewVersion')}onClick={() => {- PlatformIO.openUrl(AppConfig.links.productsOverview);+ props.openURLExternally(AppConfig.links.productsOverview);}}color="primary">diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsxindex 832712eb3..c0fe56c0f 100644--- a/app/containers/MainPage.tsx+++ b/app/containers/MainPage.tsx@@ -175,7 +175,7 @@ interface Props {setLastSelectedEntry: (path: string) => void; // needed by electron-menusopenFile: (path: string) => void; // needed by electron-menusopenFileNatively: (url: string) => void; // needed by electron-menus- openURLExternally: (url: string) => void; // needed by electron-menus+ openURLExternally: (url: string) => void;getNextFile: () => void; // needed by electron-menusgetPrevFile: () => void; // needed by electron-menusopenLocationManagerPanel: () => void;@@ -615,6 +615,7 @@ class MainPage extends Component<Props, State> {toggleSelectDirectoryDialog,toggleEditTagDialog,setFirstRun,+ openURLExternally,directoryPath} = this.props;const { FILE } = NativeTypes;@@ -627,6 +628,7 @@ class MainPage extends Component<Props, State> {{isAboutDialogOpened && (<AboutDialogAsyncopen={isAboutDialogOpened}+ openURLExternally={openURLExternally}toggleLicenseDialog={toggleLicenseDialog}toggleThirdPartyLibsDialog={toggleThirdPartyLibsDialog}onClose={toggleAboutDialog}diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 91659a468..b5a390f96 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -1329,7 +1329,9 @@ export const actions = {PlatformIO.openFile(selectedFile);},openURLExternally: (url: string, addAppVersion: boolean = false) => () => {- PlatformIO.openUrl(url);+ if (window.confirm('Do you really want to open this url: ' + url + ' ?')) {+ PlatformIO.openUrl(url);+ }},saveFile: () => () =>// dispatch: (actions: Object) => void,diff --git a/app/services/electron-io.ts b/app/services/electron-io.tsindex 0bdeb9102..8970799dc 100644--- a/app/services/electron-io.ts+++ b/app/services/electron-io.ts@@ -828,7 +828,7 @@ export default class ElectronIO {openUrl = (url: string): void => {console.log(url);- this.electron.shell.openExternalSync(url);+ this.electron.shell.openExternal(url);};selectFileDialog = (): Promise<any> => {