added a warning about extension association

This commit is contained in:
antelle 2021-04-24 19:31:39 +02:00
parent 72d0f76acc
commit 3722477eea
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
2 changed files with 26 additions and 0 deletions

View File

@ -652,6 +652,9 @@
"setBrowserExtensionNotSupported": "Not supported",
"setBrowserExtensionHelp": "How to install?",
"setBrowserExtensionInstall": "Install the extension",
"setBrowserExtensionKPXCWarnHeader": "{} will stop working",
"setBrowserExtensionKPXCWarnBody1": "Unfortunately it's not possible to connect one extension to several apps. If you connect the extension to KeeWeb, we'll overwrite its app association, which means that integration with {} will stop working. Even if you uncheck this checkbox, the association with {} won't be restored. To make it work again, configure browser integration in {} settings.",
"setBrowserExtensionKPXCWarnBody2": "Configure the extension to use KeeWeb?",
"setDevicesTitle": "Devices",
"setDevicesEnableUsb": "Enable interaction with USB devices",

View File

@ -3,12 +3,14 @@ import template from 'templates/settings/settings-browser.hbs';
import { Features } from 'util/features';
import { Links } from 'const/links';
import { AppSettingsModel } from 'models/app-settings-model';
import { RuntimeDataModel } from 'models/runtime-data-model';
import { Locale } from 'util/locale';
import {
BrowserExtensionConnector,
SupportedBrowsers,
SupportedExtensions
} from 'comp/extension/browser-extension-connector';
import { Alerts } from 'comp/ui/alerts';
class SettingsBrowserView extends View {
template = template;
@ -64,6 +66,27 @@ class SettingsBrowserView extends View {
const browser = e.target.dataset.browser;
const extension = e.target.dataset.extension;
if (enabled && extension === 'KPXC' && !RuntimeDataModel.kpxcExtensionWarningShown) {
e.target.checked = false;
Alerts.yesno({
icon: 'exclamation-triangle',
header: Locale.setBrowserExtensionKPXCWarnHeader.replace('{}', 'KeePassXC'),
body:
Locale.setBrowserExtensionKPXCWarnBody1.replace(/{}/g, 'KeePassXC') +
'\n' +
Locale.setBrowserExtensionKPXCWarnBody2,
success: () => {
RuntimeDataModel.kpxcExtensionWarningShown = true;
this.enableForBrowser(enabled, browser, extension);
}
});
} else {
this.enableForBrowser(enabled, browser, extension);
}
}
enableForBrowser(enabled, browser, extension) {
const setting = `extensionEnabled${extension}${browser}`;
if (setting) {
AppSettingsModel[setting] = enabled;