From 2a3beacbe08badf6af1a263be099dc68c2a25628 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 9 Jan 2019 11:59:14 -0500 Subject: [PATCH] default match detection setting --- jslib | 2 +- src/_locales/en/messages.json | 7 +++++++ src/popup/settings/options.component.html | 12 ++++++++++++ src/popup/settings/options.component.ts | 22 +++++++++++++++++++++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/jslib b/jslib index 65bd33d860..2e9ce15715 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 65bd33d860f3af71968a15e78491221091c4369e +Subproject commit 2e9ce1571514e2b4ae9ed61a1368b2db03a0ca5d diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 6447a8d0b4..c703756196 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -544,6 +544,13 @@ "disableContextMenuItemDesc": { "message": "Context menu options provide quick access to password generation and logins for the website in your current tab." }, + "defaultUriMatchDetection": { + "message": "Default URI Match Detection", + "description": "Default URI match detection for auto-fill." + }, + "defaultUriMatchDetectionDesc": { + "message": "Choose the default way that URI match detection is handled for logins when performing actions such as auto-fill." + }, "theme": { "message": "Theme" }, diff --git a/src/popup/settings/options.component.html b/src/popup/settings/options.component.html index 7b3c17296d..837b6967d6 100644 --- a/src/popup/settings/options.component.html +++ b/src/popup/settings/options.component.html @@ -24,6 +24,18 @@ {{'warning' | i18n}}: {{'experimentalFeature' | i18n}} +
+
+
+ + +
+
+ +
diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts index 8631792321..c53cc8b7f6 100644 --- a/src/popup/settings/options.component.ts +++ b/src/popup/settings/options.component.ts @@ -5,6 +5,8 @@ import { import { Angulartics2 } from 'angulartics2'; +import { UriMatchType } from 'jslib/enums/uriMatchType'; + import { I18nService } from 'jslib/abstractions/i18n.service'; import { MessagingService } from 'jslib/abstractions/messaging.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; @@ -31,16 +33,26 @@ export class OptionsComponent implements OnInit { disableGa = false; theme: string; themeOptions: any[]; + defaultUriMatch = UriMatchType.Domain; + uriMatchOptions: any[]; constructor(private analytics: Angulartics2, private messagingService: MessagingService, private platformUtilsService: PlatformUtilsService, private storageService: StorageService, private stateService: StateService, private totpService: TotpService, - private i18nService: I18nService) { + i18nService: I18nService) { this.themeOptions = [ { name: i18nService.t('default'), value: null }, { name: i18nService.t('light'), value: 'light' }, { name: i18nService.t('dark'), value: 'dark' }, ]; + this.uriMatchOptions = [ + { name: i18nService.t('baseDomain'), value: UriMatchType.Domain }, + { name: i18nService.t('host'), value: UriMatchType.Host }, + { name: i18nService.t('startsWith'), value: UriMatchType.StartsWith }, + { name: i18nService.t('regEx'), value: UriMatchType.RegularExpression }, + { name: i18nService.t('exact'), value: UriMatchType.Exact }, + { name: i18nService.t('never'), value: UriMatchType.Never }, + ]; } async ngOnInit() { @@ -70,6 +82,9 @@ export class OptionsComponent implements OnInit { this.disableFavicon = await this.storageService.get(ConstantsService.disableFaviconKey); this.theme = await this.storageService.get(ConstantsService.themeKey); + + const defaultUriMatch = await this.storageService.get(ConstantsService.defaultUriMatch); + this.defaultUriMatch = defaultUriMatch == null ? UriMatchType.Domain : defaultUriMatch; } async saveGa() { @@ -135,6 +150,11 @@ export class OptionsComponent implements OnInit { window.setTimeout(() => window.location.reload(), 200); } + async saveDefaultUriMatch() { + await this.storageService.save(ConstantsService.defaultUriMatch, this.defaultUriMatch); + this.analytics.eventTrack.next({ action: 'Set Default URI Match ' + this.defaultUriMatch }); + } + private callAnalytics(name: string, enabled: boolean) { const status = enabled ? 'Enabled' : 'Disabled'; this.analytics.eventTrack.next({ action: `${status} ${name}` });