#1458 OptionsPage - AutoSubmit WIP

This commit is contained in:
Grzegorz Zając 2023-12-11 15:41:03 +01:00
parent 4862dc8577
commit 298d732beb
7 changed files with 31 additions and 9 deletions

View File

@ -67,6 +67,7 @@
31 - removeDevice - wrong deviceID or deviceName
36 - handleSafariReset
38 - storageValidationReload
45 - domainModalFormSubmit
// PARTIALS
*23 - openShortcutEdit [redundant]

View File

@ -43,6 +43,8 @@
"successDeviceDisconnectedMessage": "Device disconnected",
"successSafariResetTitle": "Success",
"successSafariResetMessage": "Browser Extension configuration removed",
"successDomainExcludedTitle": "Success",
"successDomainExcludedMessage": "Domain added to excluded list",
"infoNativeNotificationsTitle": "2FAS Notifications",
"infoNativeNotificationsMessage": "From now on, you'll be receiving system notifications instead of 2FAS custom ones. If you'd like to change this, go to the ",
"infoEnabledNativeNotifications": "extension's settings",

View File

@ -122,6 +122,10 @@ const config = {
SafariReset: {
Title: browser.i18n.getMessage('successSafariResetTitle') || t.successSafariResetTitle,
Message: browser.i18n.getMessage('successSafariResetMessage') || t.successSafariResetMessage
},
DomainExcluded: {
Title: browser.i18n.getMessage('successDomainExcludedTitle') || t.successDomainExcludedTitle,
Message: browser.i18n.getMessage('successDomainExcludedMessage') || t.successDomainExcludedMessage
}
},
Info: {

View File

@ -21,6 +21,9 @@
const S = require('../../selectors');
const generateDomainsList = require('./generateDomainsList');
const { loadFromLocalStorage, saveToLocalStorage } = require('../../localStorage');
const TwoFasNotification = require('../../notification');
const config = require('../../config');
const storeLog = require('../../partials/storeLog');
const isValidUrl = urlString => {
const urlPattern = new RegExp('^(https?:\\/\\/)?' +
@ -40,6 +43,11 @@ const domainModalFormSubmit = e => {
const domain = data.get('domain').trim();
const validation = document.querySelector(S.optionsPage.domainModal.validation);
if (!domain || domain.length === 0) {
validation.innerText = 'Domain is required'; // @TODO: i18n
return false;
}
if (!isValidUrl(domain)) {
validation.innerText = 'Domain is not correct'; // @TODO: i18n
return false;
@ -68,17 +76,13 @@ const domainModalFormSubmit = e => {
domainModal.classList.add('hidden');
generateDomainsList(res.autoSubmitExcludedDomains);
TwoFasNotification.show(config.Texts.Success.DomainExcluded);
}
})
.catch(err => {
// @TODO: check err
console.log(err);
.catch(async err => {
await storeLog('error', 45, err, 'domainModalFormSubmit');
return TwoFasNotification.show(config.Texts.Error.UndefinedError, null, true);
});
/*
@TODO:
ShowPush
*/
};
module.exports = domainModalFormSubmit;

View File

@ -21,7 +21,10 @@ const S = require('../../selectors');
const showDomainModal = () => {
const modalEl = document.querySelector(S.optionsPage.domainModal.element);
const validation = document.querySelector(S.optionsPage.domainModal.validation);
modalEl.classList.remove('hidden');
validation.innerText = '';
};
module.exports = showDomainModal;

View File

@ -190,4 +190,12 @@
line-height: 18px;
}
}
&-validation {
color: $theme-color;
font-size: 12px !important;
font-weight: 700 !important;
height: 18px !important;
margin-top: 5px !important;
}
}

View File

@ -40,7 +40,7 @@
name="domain"
placeholder="Type in domain to exclude..."
/>
<p class="js-twofas-domain-modal-validation"></p>
<p class="twofas-domain-modal-validation js-twofas-domain-modal-validation"></p>
<div class="twofas-domain-modal-body-buttons">
<button type="submit" data-i18n="add" class="btn btn-clear">Add</button>