From e611094dfc396179a680c0c41cfe7bfe57dcb89c Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Wed, 18 Jan 2017 17:58:40 -0200 Subject: [#828] Adds tooltips for encrypt and sign labels We added a tooltip on the "encrypted" and "signed" label to inform the user what these flags mean. And we did some refactoring. With @tayanefernandes --- web-ui/app/js/mail_view/ui/mail_view.js | 95 ++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 44 deletions(-) (limited to 'web-ui/app/js/mail_view/ui/mail_view.js') diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index 4c9dce30..4315226c 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -96,72 +96,79 @@ define( }; this.checkEncrypted = function(mail) { - if(_.isEmpty(mail.security_casing.locks)) { - return { - cssClass: 'security-status__label--not-encrypted', - label: 'not-encrypted' - }; - } - - var statusClass = ['security-status__label--encrypted']; + var statusClass = ['security-status__label']; var statusLabel; + var tooltip; - var hasAnyEncryptionInfo = _.any(mail.security_casing.locks, function (lock) { - return lock.state === 'valid'; - }); - - if(hasAnyEncryptionInfo) { - statusLabel = 'encrypted'; + if(_.isEmpty(mail.security_casing.locks)) { + statusClass.push('--not-encrypted'); + statusLabel = 'not-encrypted'; + tooltip = 'This message is not encrypted.'; } else { - statusClass.push('--with-error'); - statusLabel = 'encryption-error'; + statusClass.push('--encrypted'); + + var hasAnyEncryptionInfo = _.any(mail.security_casing.locks, function (lock) { + return lock.state === 'valid'; + }); + + if(hasAnyEncryptionInfo) { + statusLabel = 'encrypted'; + tooltip = 'This message was encrypted.'; + } else { + statusClass.push('--with-error'); + statusLabel = 'encryption-error'; + tooltip = 'This message had an encryption error.'; + } } return { cssClass: statusClass.join(''), - label: statusLabel + label: statusLabel, + tooltipText: tooltip }; }; this.checkSigned = function(mail) { - var statusNotSigned = { - cssClass: 'security-status__label--not-signed', - label: 'not-signed' - }; - - if(_.isEmpty(mail.security_casing.imprints)) { - return statusNotSigned; - } + var statusClass = ['security-status__label']; + var statusLabel = []; + var tooltip; var hasNoSignatureInformation = _.any(mail.security_casing.imprints, function (imprint) { return imprint.state === 'no_signature_information'; }); - if(hasNoSignatureInformation) { - return statusNotSigned; - } - - var statusClass = ['security-status__label--signed']; - var statusLabel = ['signed']; - - if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_revoked'; })) { - statusClass.push('--revoked'); - statusLabel.push('signature-revoked'); - } + if(_.isEmpty(mail.security_casing.imprints) || hasNoSignatureInformation) { + statusClass.push('--not-signed'); + statusLabel.push('not-signed'); + tooltip = 'The sender could not be verified.'; + } else { + statusClass.push('--signed'); + statusLabel.push('signed'); + tooltip = 'You are communicating with the real sender.'; + + if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_revoked'; })) { + statusClass.push('--revoked'); + statusLabel.push('signature-revoked'); + tooltip = 'The sender could not be verified.'; + } - if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_expired'; })) { - statusClass.push('--expired'); - statusLabel.push('signature-expired'); - } + if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_expired'; })) { + statusClass.push('--expired'); + statusLabel.push('signature-expired'); + tooltip = 'The sender could not be verified.'; + } - if(this.isNotTrusted(mail)) { - statusClass.push('--not-trusted'); - statusLabel.push('signature-not-trusted'); + if(this.isNotTrusted(mail)) { + statusClass.push('--not-trusted'); + statusLabel.push('signature-not-trusted'); + tooltip = 'The sender could not be verified.'; + } } return { cssClass: statusClass.join(''), - label: statusLabel.join(' ') + label: statusLabel.join(' '), + tooltipText: tooltip }; }; -- cgit v1.2.3 From f9bda79686c5a4f65bc1c98bc5a1936faf1bc8e0 Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Wed, 18 Jan 2017 19:01:05 -0200 Subject: [#828] Replaced plain text to translation properties with @tayanefernandes --- web-ui/app/js/mail_view/ui/mail_view.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'web-ui/app/js/mail_view/ui/mail_view.js') diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index 4315226c..86605b37 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -103,7 +103,7 @@ define( if(_.isEmpty(mail.security_casing.locks)) { statusClass.push('--not-encrypted'); statusLabel = 'not-encrypted'; - tooltip = 'This message is not encrypted.'; + tooltip = 'not-encrypted-label-tooltip'; } else { statusClass.push('--encrypted'); @@ -113,11 +113,11 @@ define( if(hasAnyEncryptionInfo) { statusLabel = 'encrypted'; - tooltip = 'This message was encrypted.'; + tooltip = 'encrypted-label-tooltip'; } else { statusClass.push('--with-error'); statusLabel = 'encryption-error'; - tooltip = 'This message had an encryption error.'; + tooltip = 'encryption-error-label-tooltip'; } } @@ -140,28 +140,28 @@ define( if(_.isEmpty(mail.security_casing.imprints) || hasNoSignatureInformation) { statusClass.push('--not-signed'); statusLabel.push('not-signed'); - tooltip = 'The sender could not be verified.'; + tooltip = 'not-signed-label-tooltip'; } else { statusClass.push('--signed'); statusLabel.push('signed'); - tooltip = 'You are communicating with the real sender.'; + tooltip = 'signed-label-tooltip'; if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_revoked'; })) { statusClass.push('--revoked'); statusLabel.push('signature-revoked'); - tooltip = 'The sender could not be verified.'; + tooltip = 'not-signed-label-tooltip'; } if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_expired'; })) { statusClass.push('--expired'); statusLabel.push('signature-expired'); - tooltip = 'The sender could not be verified.'; + tooltip = 'not-signed-label-tooltip'; } if(this.isNotTrusted(mail)) { statusClass.push('--not-trusted'); statusLabel.push('signature-not-trusted'); - tooltip = 'The sender could not be verified.'; + tooltip = 'not-signed-label-tooltip'; } } -- cgit v1.2.3 From a05b42935725a032196157a9200fb4f7019ae132 Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Thu, 19 Jan 2017 15:47:32 -0200 Subject: [#828] Refactoring checkEncrypted and checkSigned functions with @tayanefernandes --- web-ui/app/js/mail_view/ui/mail_view.js | 128 ++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 57 deletions(-) (limited to 'web-ui/app/js/mail_view/ui/mail_view.js') diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index 86605b37..029707c1 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -96,80 +96,94 @@ define( }; this.checkEncrypted = function(mail) { - var statusClass = ['security-status__label']; - var statusLabel; - var tooltip; + var ENCRYPTED_FLAG = { + cssClass: 'security-status__label--encrypted', + label: 'encrypted', + tooltipText: 'encrypted-label-tooltip' + }; + + var ENCRYPTED_WITH_ERROR_FLAG = { + cssClass: 'security-status__label--encrypted--with-error', + label: 'encryption-error', + tooltipText: 'encryption-error-label-tooltip' + }; + + var NOT_ENCRYPTED_FLAG = { + cssClass: 'security-status__label--not-encrypted', + label: 'not-encrypted', + tooltipText: 'not-encrypted-label-tooltip' + }; if(_.isEmpty(mail.security_casing.locks)) { - statusClass.push('--not-encrypted'); - statusLabel = 'not-encrypted'; - tooltip = 'not-encrypted-label-tooltip'; - } else { - statusClass.push('--encrypted'); - - var hasAnyEncryptionInfo = _.any(mail.security_casing.locks, function (lock) { - return lock.state === 'valid'; - }); - - if(hasAnyEncryptionInfo) { - statusLabel = 'encrypted'; - tooltip = 'encrypted-label-tooltip'; - } else { - statusClass.push('--with-error'); - statusLabel = 'encryption-error'; - tooltip = 'encryption-error-label-tooltip'; - } + return NOT_ENCRYPTED_FLAG; } - return { - cssClass: statusClass.join(''), - label: statusLabel, - tooltipText: tooltip - }; + if(this.hasAnyEncryptionInfo(mail)) { + return ENCRYPTED_FLAG; + } + + return ENCRYPTED_WITH_ERROR_FLAG; + }; + + this.hasAnyEncryptionInfo = function(mail) { + return _.any(mail.security_casing.locks, function (lock) { + return lock.state === 'valid'; + }); }; this.checkSigned = function(mail) { - var statusClass = ['security-status__label']; - var statusLabel = []; - var tooltip; + + var SIGNED_FLAG = { + cssClass: 'security-status__label--signed', + label: 'signed', + tooltipText: 'signed-label-tooltip' + }; + + var SIGNED_REVOKED_FLAG = { + cssClass: 'security-status__label--signed--revoked', + label: 'signature-revoked', + tooltipText: 'not-signed-label-tooltip' + }; + + var SIGNED_EXPIRED_FLAG = { + cssClass: 'security-status__label--signed--expired', + label: 'signature-expired', + tooltipText: 'not-signed-label-tooltip' + }; + + var SIGNED_NOT_TRUSTED_FLAG = { + cssClass: 'security-status__label--signed--not-trusted', + label: 'signature-not-trusted', + tooltipText: 'not-signed-label-tooltip' + }; + + var NOT_SIGNED_FLAG = { + cssClass: 'security-status__label--not-signed', + label: 'not-signed', + tooltipText: 'not-signed-label-tooltip' + }; var hasNoSignatureInformation = _.any(mail.security_casing.imprints, function (imprint) { return imprint.state === 'no_signature_information'; }); if(_.isEmpty(mail.security_casing.imprints) || hasNoSignatureInformation) { - statusClass.push('--not-signed'); - statusLabel.push('not-signed'); - tooltip = 'not-signed-label-tooltip'; - } else { - statusClass.push('--signed'); - statusLabel.push('signed'); - tooltip = 'signed-label-tooltip'; - - if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_revoked'; })) { - statusClass.push('--revoked'); - statusLabel.push('signature-revoked'); - tooltip = 'not-signed-label-tooltip'; - } + return NOT_SIGNED_FLAG; + } - if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_expired'; })) { - statusClass.push('--expired'); - statusLabel.push('signature-expired'); - tooltip = 'not-signed-label-tooltip'; - } + if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_revoked'; })) { + return SIGNED_REVOKED_FLAG; + } - if(this.isNotTrusted(mail)) { - statusClass.push('--not-trusted'); - statusLabel.push('signature-not-trusted'); - tooltip = 'not-signed-label-tooltip'; - } + if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_expired'; })) { + return SIGNED_EXPIRED_FLAG; } - return { - cssClass: statusClass.join(''), - label: statusLabel.join(' '), - tooltipText: tooltip - }; + if(this.isNotTrusted(mail)) { + return SIGNED_NOT_TRUSTED_FLAG; + } + + return SIGNED_FLAG; }; this.isNotTrusted = function(mail){ -- cgit v1.2.3