Skip to content

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

polish: making confirmation for opening external urls switchable

Ilian Sapundshievd44480de6998
diff --git a/app/components/HelpFeedbackPanel.tsx b/app/components/HelpFeedbackPanel.tsx
index a52bb3602..179e8fe9d 100644
--- a/app/components/HelpFeedbackPanel.tsx
+++ b/app/components/HelpFeedbackPanel.tsx
@@ -50,7 +50,7 @@ import { Pro } from '../pro';
interface Props {
classes?: any;
theme?: any;
- openURLExternally: (url: string) => void;
+ openURLExternally: (url: string, skipConfirmation?: boolean) => void;
openFileNatively: (url: string) => void;
toggleAboutDialog?: () => void;
toggleKeysDialog: () => void;
@@ -96,7 +96,7 @@ const HelpFeedbackPanel = (props: Props) => {
<ListItem
button
onClick={() =>
- openURLExternally(AppConfig.documentationLinks.general)
+ openURLExternally(AppConfig.documentationLinks.general, true)
}
>
<ListItemIcon>
@@ -116,7 +116,9 @@ const HelpFeedbackPanel = (props: Props) => {
</ListItem>
<ListItem
button
- onClick={() => openURLExternally(AppConfig.links.changelogURL)}
+ onClick={() =>
+ openURLExternally(AppConfig.links.changelogURL, true)
+ }
title="Opens the changelog of the app"
>
<ListItemIcon>
@@ -136,7 +138,7 @@ const HelpFeedbackPanel = (props: Props) => {
</ListItem>
<ListItem
button
- onClick={() => openURLExternally(AppConfig.links.webClipper)}
+ onClick={() => openURLExternally(AppConfig.links.webClipper, true)}
>
<ListItemIcon>
<WebClipperIcon />
@@ -274,7 +276,7 @@ const HelpFeedbackPanel = (props: Props) => {
onClick={(event: any) => {
event.preventDefault();
event.stopPropagation();
- openURLExternally(AppConfig.links.productsOverview);
+ openURLExternally(AppConfig.links.productsOverview, true);
}}
>
Get It
diff --git a/app/components/WelcomePanel.tsx b/app/components/WelcomePanel.tsx
index 2ef8fc43b..8c85e5a44 100644
--- a/app/components/WelcomePanel.tsx
+++ b/app/components/WelcomePanel.tsx
@@ -77,7 +77,7 @@ const styles: any = (theme: any) => ({
interface Props {
classes: any;
toggleKeysDialog: () => void;
- openURLExternally: (url: string) => void;
+ openURLExternally: (url: string, skipConfirmation?: boolean) => void;
openFileNatively: (url: string) => void;
toggleAboutDialog: () => void;
isDesktopMode: boolean;
@@ -121,7 +121,7 @@ const WelcomePanel = (props: Props) => {
<ListItem
button
onClick={() =>
- openURLExternally(AppConfig.documentationLinks.general)
+ openURLExternally(AppConfig.documentationLinks.general, true)
}
>
<Button startIcon={<DocumentationIcon />}>Open Documentation</Button>
@@ -133,7 +133,7 @@ const WelcomePanel = (props: Props) => {
</ListItem>
<ListItem
button
- onClick={() => openURLExternally(AppConfig.links.changelogURL)}
+ onClick={() => openURLExternally(AppConfig.links.changelogURL, true)}
>
<Button
startIcon={<ChangeLogIcon />}
@@ -142,15 +142,9 @@ const WelcomePanel = (props: Props) => {
{i18n.t('core:whatsNew')}
</Button>
</ListItem>
- {/* <ListItem button onClick={() => toggleOnboardingDialog()}>
- <ListItemIcon>
- <OnboardingIcon />
- </ListItemIcon>
- <ListItemText primary={i18n.t('core:onboardingWizard')} />
- </ListItem> */}
<ListItem
button
- onClick={() => openURLExternally(AppConfig.links.webClipper)}
+ onClick={() => openURLExternally(AppConfig.links.webClipper, true)}
>
<Button startIcon={<WebClipperIcon />}>
{i18n.t('core:webClipper')}
@@ -184,7 +178,7 @@ const WelcomePanel = (props: Props) => {
<Divider />
<ListItem
button
- onClick={() => openURLExternally(AppConfig.links.emailContact)}
+ onClick={() => openURLExternally(AppConfig.links.emailContact, true)}
>
<Button startIcon={<EmailIcon />}>
{i18n.t('core:emailContact')}
diff --git a/app/components/dialogs/AboutDialog.tsx b/app/components/dialogs/AboutDialog.tsx
index cf713f4f0..4f14915b9 100644
--- a/app/components/dialogs/AboutDialog.tsx
+++ b/app/components/dialogs/AboutDialog.tsx
@@ -35,7 +35,7 @@ import AppConfig from '-/config';
interface Props {
open: boolean;
fullScreen: boolean;
- openURLExternally: (url: string) => void;
+ openURLExternally: (url: string, skipConfirmation?: boolean) => void;
toggleLicenseDialog: () => void;
toggleThirdPartyLibsDialog: () => void;
onClose: () => void;
@@ -56,7 +56,7 @@ const AboutDialog = (props: Props) => {
function checkForUpdates() {
if (updateAvailable) {
- props.openURLExternally(AppConfig.links.downloadURL);
+ props.openURLExternally(AppConfig.links.downloadURL, true);
} else {
getLastVersionPromise()
.then(lastVersion => {
@@ -155,7 +155,7 @@ const AboutDialog = (props: Props) => {
size="small"
color="primary"
onClick={() => {
- props.openURLExternally(AppConfig.links.imprintURL);
+ props.openURLExternally(AppConfig.links.imprintURL, true);
}}
>
Imprint
@@ -164,7 +164,7 @@ const AboutDialog = (props: Props) => {
size="small"
color="primary"
onClick={() => {
- props.openURLExternally(AppConfig.links.privacyURL);
+ props.openURLExternally(AppConfig.links.privacyURL, true);
}}
>
Privacy Policy
@@ -173,7 +173,7 @@ const AboutDialog = (props: Props) => {
size="small"
color="primary"
onClick={() => {
- props.openURLExternally(AppConfig.links.changelogURL);
+ props.openURLExternally(AppConfig.links.changelogURL, true);
}}
>
Changelog
@@ -194,7 +194,7 @@ const AboutDialog = (props: Props) => {
data-tid="checkForUpdates"
title={i18n.t('core:checkForNewVersion')}
onClick={() => {
- props.openURLExternally(AppConfig.links.productsOverview);
+ props.openURLExternally(AppConfig.links.productsOverview, true);
}}
color="primary"
>
diff --git a/app/components/dialogs/OnboardingDialog.tsx b/app/components/dialogs/OnboardingDialog.tsx
index 1ab3d7d84..af9b256ac 100644
--- a/app/components/dialogs/OnboardingDialog.tsx
+++ b/app/components/dialogs/OnboardingDialog.tsx
@@ -58,7 +58,7 @@ interface Props {
// setFirstRun: (isFirstRun: boolean) => void,
setPersistTagsInSidecarFile: (isPersistTagsInSidecar: boolean) => void;
setCurrentTheme: (theme: string) => void;
- openURLExternally: (url: string) => void;
+ openURLExternally: (url: string, skipConfirmation?: boolean) => void;
onClose: () => void;
}
@@ -238,7 +238,7 @@ const OnboardingDialog = (props: Props) => {
<Button
style={{ marginTop: 20 }}
onClick={() => {
- props.openURLExternally(AppConfig.links.webClipper);
+ props.openURLExternally(AppConfig.links.webClipper, true);
}}
variant="contained"
color="primary"
diff --git a/app/components/dialogs/ProTeaserDialog.tsx b/app/components/dialogs/ProTeaserDialog.tsx
index 3d6391d5f..bd43af82d 100644
--- a/app/components/dialogs/ProTeaserDialog.tsx
+++ b/app/components/dialogs/ProTeaserDialog.tsx
@@ -38,7 +38,7 @@ import AppConfig from '-/config';
interface Props {
open: boolean;
fullScreen: boolean;
- openURLExternally: (url: string) => void;
+ openURLExternally: (url: string, skipConfirmation: boolean) => void;
onClose: () => void;
}
@@ -134,7 +134,8 @@ class ProTeaserDialog extends React.Component<Props, State> {
<Button
onClick={() => {
this.props.openURLExternally(
- AppConfig.links.productsOverview
+ AppConfig.links.productsOverview,
+ true
);
}}
variant="contained"
@@ -184,7 +185,8 @@ class ProTeaserDialog extends React.Component<Props, State> {
<Button
onClick={() =>
this.props.openURLExternally(
- AppConfig.links.productProAdvancedSearch
+ AppConfig.links.productProAdvancedSearch,
+ true
)
}
variant="contained"
@@ -225,7 +227,8 @@ class ProTeaserDialog extends React.Component<Props, State> {
<Button
onClick={() =>
this.props.openURLExternally(
- AppConfig.links.productProObjectStore
+ AppConfig.links.productProObjectStore,
+ true
)
}
variant="contained"
@@ -272,7 +275,8 @@ class ProTeaserDialog extends React.Component<Props, State> {
<Button
onClick={() =>
this.props.openURLExternally(
- AppConfig.links.productProFileFolderMeta
+ AppConfig.links.productProFileFolderMeta,
+ true
)
}
variant="contained"
@@ -318,7 +322,8 @@ class ProTeaserDialog extends React.Component<Props, State> {
<Button
onClick={() =>
this.props.openURLExternally(
- AppConfig.links.productProGeoTagging
+ AppConfig.links.productProGeoTagging,
+ true
)
}
variant="contained"
@@ -352,7 +357,8 @@ class ProTeaserDialog extends React.Component<Props, State> {
<Button
onClick={() =>
this.props.openURLExternally(
- AppConfig.links.productProThumbnailsGeneration
+ AppConfig.links.productProThumbnailsGeneration,
+ true
)
}
variant="contained"
@@ -402,7 +408,8 @@ class ProTeaserDialog extends React.Component<Props, State> {
<Button
onClick={() =>
this.props.openURLExternally(
- AppConfig.links.productsOverview
+ AppConfig.links.productsOverview,
+ true
)
}
variant="outlined"
@@ -413,7 +420,10 @@ class ProTeaserDialog extends React.Component<Props, State> {
&nbsp;
<Button
onClick={() =>
- this.props.openURLExternally('mailto:[email protected]')
+ this.props.openURLExternally(
+ AppConfig.links.emailContact,
+ true
+ )
}
variant="outlined"
color="primary"
diff --git a/app/components/menus/LocationManagerMenu.tsx b/app/components/menus/LocationManagerMenu.tsx
index a67ef14f9..51607c604 100644
--- a/app/components/menus/LocationManagerMenu.tsx
+++ b/app/components/menus/LocationManagerMenu.tsx
@@ -30,7 +30,7 @@ interface Props {
open: boolean;
anchorEl: Element;
onClose: () => void;
- openURLExternally: (url: string) => void;
+ openURLExternally: (url: string, skipConfirmation?: boolean) => void;
}
const LocationManagerMenu = (props: Props) => (
@@ -40,7 +40,7 @@ const LocationManagerMenu = (props: Props) => (
data-tid="locationManagerHelp"
onClick={() => {
props.onClose();
- props.openURLExternally(AppConfig.documentationLinks.locations);
+ props.openURLExternally(AppConfig.documentationLinks.locations, true);
}}
>
<ListItemIcon>
diff --git a/app/components/menus/SearchMenu.tsx b/app/components/menus/SearchMenu.tsx
index dfd46c7bd..7a52e15f8 100644
--- a/app/components/menus/SearchMenu.tsx
+++ b/app/components/menus/SearchMenu.tsx
@@ -31,7 +31,7 @@ interface Props {
open: boolean;
anchorEl: Element;
onClose: () => void;
- openURLExternally: (url: string) => void;
+ openURLExternally: (url: string, skipConfirmation?: boolean) => void;
createLocationsIndexes: () => void;
}
@@ -54,7 +54,7 @@ const SearchMenu = (props: Props) => (
data-tid="searchMenuHelp"
onClick={() => {
props.onClose();
- props.openURLExternally(AppConfig.documentationLinks.search);
+ props.openURLExternally(AppConfig.documentationLinks.search, true);
}}
>
<ListItemIcon>
diff --git a/app/components/menus/TagLibraryMenu.tsx b/app/components/menus/TagLibraryMenu.tsx
index 8731d8a7e..70b7013e2 100644
--- a/app/components/menus/TagLibraryMenu.tsx
+++ b/app/components/menus/TagLibraryMenu.tsx
@@ -33,7 +33,7 @@ interface Props {
classes?: any;
anchorEl: Element;
tagGroups: Array<Object>;
- openURLExternally: (path: string) => void;
+ openURLExternally: (path: string, skipConfirmation?: boolean) => void;
open: boolean;
onClose: () => void;
importTagGroups: () => void;
@@ -159,7 +159,10 @@ const TagLibraryMenu = (props: Props) => {
data-tid="taglibraryHelp"
onClick={() => {
props.onClose();
- props.openURLExternally(AppConfig.documentationLinks.taglibrary);
+ props.openURLExternally(
+ AppConfig.documentationLinks.taglibrary,
+ true
+ );
}}
>
<ListItemIcon>
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 19fa9e022..3fc147f86 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -615,8 +615,7 @@ export default (state: any = initialState, action: any) => {
};
} */
case types.CLOSE_ALL_FILES: {
- // eslint-disable-next-line no-restricted-globals
- window.history.pushState('', 'TagSpaces', location.pathname);
+ window.history.pushState('', document.title, window.location.pathname);
return {
...state,
openedFiles: [],
@@ -1464,6 +1463,12 @@ export const actions = {
dispatch: (actions: Object) => void,
getState: () => any
) => {
+ const currentLocation: Location = getLocation(
+ getState(),
+ getState().app.currentLocationId
+ );
+ // const isCloudLocation = currentLocation.type === locationType.TYPE_CLOUD;
+
let entryForOpening: OpenedEntry;
const { openedFiles } = getState().app;
/**
@@ -1510,11 +1515,16 @@ export const actions = {
}
const localePar = getURLParameter(fsEntry.path);
let startPar = '?open=' + encodeURIComponent(fsEntry.path);
+
+ if (currentLocation && currentLocation.uuid) {
+ startPar += '&lid=' + currentLocation.uuid;
+ }
+
if (localePar && localePar.length > 1) {
startPar += '&locale=' + localePar;
}
- // eslint-disable-next-line no-restricted-globals
- window.history.pushState('', 'TagSpaces', location.pathname + startPar);
+
+ window.history.pushState('', document.title, startPar);
dispatch(actions.addToEntryContainer(entryForOpening));
},
@@ -1757,8 +1767,12 @@ export const actions = {
openFileNatively: (selectedFile: string) => () => {
PlatformIO.openFile(selectedFile);
},
- openURLExternally: (url: string, addAppVersion: boolean = false) => () => {
- if (window.confirm('Do you really want to open this url: ' + url + ' ?')) {
+ openURLExternally: (url: string, skipConfirmation: boolean = false) => () => {
+ if (skipConfirmation) {
+ PlatformIO.openUrl(url);
+ } else if (
+ window.confirm('Do you really want to open this url: ' + url + ' ?')
+ ) {
PlatformIO.openUrl(url);
}
},
diff --git a/app/services/electron-menus.ts b/app/services/electron-menus.ts
index 34d9db5fb..2f4a69e8a 100644
--- a/app/services/electron-menus.ts
+++ b/app/services/electron-menus.ts
@@ -302,7 +302,7 @@ export default function buildDesktopMenu(mainPageProps: any) {
{
label: '&' + i18n.t('core:whatsNew'),
click: () => {
- mainPageProps.openURLExternally(AppConfig.links.changelogURL);
+ mainPageProps.openURLExternally(AppConfig.links.changelogURL, true);
}
},
{
@@ -341,13 +341,19 @@ export default function buildDesktopMenu(mainPageProps: any) {
{
label: i18n.t('core:webClipperChrome'),
click: () => {
- mainPageProps.openURLExternally(AppConfig.links.webClipperChrome);
+ mainPageProps.openURLExternally(
+ AppConfig.links.webClipperChrome,
+ true
+ );
}
},
{
label: i18n.t('core:webClipperFirefox'),
click: () => {
- mainPageProps.openURLExternally(AppConfig.links.webClipperFirefox);
+ mainPageProps.openURLExternally(
+ AppConfig.links.webClipperFirefox,
+ true
+ );
}
},
{