From 5dd909b779e85e4ca271ed1a7674339c6f2db38b Mon Sep 17 00:00:00 2001
From: Timo Ulich
Date: Thu, 20 Feb 2020 16:31:21 +0100
Subject: Show the group name in autocomplete (#739)
Show the group name in autocomplete
---
keepassxc-browser/_locales/en/messages.json | 8 ++++++++
keepassxc-browser/background/page.js | 5 +++++
keepassxc-browser/content/keepassxc-browser.js | 17 +++++++++++++----
keepassxc-browser/options/options.html | 8 ++++++++
4 files changed, 34 insertions(+), 4 deletions(-)
(limited to 'keepassxc-browser')
diff --git a/keepassxc-browser/_locales/en/messages.json b/keepassxc-browser/_locales/en/messages.json
index 0e4fbb9..798f155 100644
--- a/keepassxc-browser/_locales/en/messages.json
+++ b/keepassxc-browser/_locales/en/messages.json
@@ -607,6 +607,10 @@
"message": "Activate autocomplete for username fields.",
"description": "Activate autocomplete for username fields checkbox text."
},
+ "optionsCheckboxShowGroupNameInAutocomplete": {
+ "message": "Display the group name in autocomplete list when credentials are from different groups.",
+ "description": "Show group name in autocomplete checkbox text."
+ },
"optionsCheckboxAutoSubmit": {
"message": "Auto-submit login forms",
"description": "Auto-submit checkbox text."
@@ -719,6 +723,10 @@
"message": "Show a dropdown list containing available credentials for all username fields on a page.",
"description": "Autocomplete Usernames option help text."
},
+ "optionsShowGroupNameInAutocompleteHelpText": {
+ "message": "When credentials are returned from different groups, the group name will be shown.",
+ "description": "Show group name in autocomplete help text."
+ },
"optionsShowNotificationsHelpText": {
"message": "Show notifications for errors and when user interaction is required.",
"description": "Show notifications option help text."
diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js
index 3d9e4a0..38ec9bc 100755
--- a/keepassxc-browser/background/page.js
+++ b/keepassxc-browser/background/page.js
@@ -2,6 +2,7 @@
const defaultSettings = {
autoCompleteUsernames: true,
+ showGroupNameInAutocomplete: true,
autoFillAndSend: false,
autoFillSingleEntry: false,
autoReconnect: false,
@@ -41,6 +42,10 @@ page.initSettings = async function() {
page.settings.autoCompleteUsernames = defaultSettings.autoCompleteUsernames;
}
+ if (!('showGroupNameInAutocomplete' in page.settings)) {
+ page.settings.showGroupNameInAutocomplete = defaultSettings.showGroupNameInAutocomplete;
+ }
+
if (!('autoFillAndSend' in page.settings)) {
page.settings.autoFillAndSend = defaultSettings.autoFillAndSend;
}
diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js
index 405c03a..329cf49 100755
--- a/keepassxc-browser/content/keepassxc-browser.js
+++ b/keepassxc-browser/content/keepassxc-browser.js
@@ -1121,19 +1121,28 @@ kpxc.preparePageForMultipleCredentials = function(credentials) {
return;
}
- function getLoginText(credential) {
+ function getLoginText(credential, withGroup) {
+ const group = (withGroup && credential.group) ? `[${credential.group}] ` : '';
const visibleLogin = (credential.login.length > 0) ? credential.login : tr('credentialsNoUsername');
+ const text = `${group}${credential.name} (${visibleLogin})`;
if (credential.expired && credential.expired === 'true') {
- return `${visibleLogin} (${credential.name}) [${tr('credentialExpired')}]`;
+ return `${text} [${tr('credentialExpired')}]`;
}
- return `${visibleLogin} (${credential.name})`;
+ return text;
+ }
+
+ function getUniqueGroupCount(credentials) {
+ const groups = credentials.map(c => c.group || '')
+ const uniqueGroups = new Set(groups)
+ return uniqueGroups.size
}
// Add usernames + descriptions to autocomplete-list and popup-list
const usernames = [];
kpxcAutocomplete.elements = [];
+ const showGroupNameInAutocomplete = kpxc.settings.showGroupNameInAutocomplete && (getUniqueGroupCount(credentials) > 1)
for (let i = 0; i < credentials.length; i++) {
- const loginText = getLoginText(credentials[i]);
+ const loginText = getLoginText(credentials[i], showGroupNameInAutocomplete);
usernames.push(loginText);
const item = {
diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html
index 3679347..198d809 100644
--- a/keepassxc-browser/options/options.html
+++ b/keepassxc-browser/options/options.html
@@ -157,6 +157,14 @@
+
+
+
+
+
+
--
cgit v1.2.3