diff options
author | thaissiqueira <thais.siqueira@thoughtworks.com> | 2017-01-20 11:13:41 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-20 11:13:41 -0200 |
commit | 1eeb5389781d2db1cc025c731dc3505a83248f61 (patch) | |
tree | f16bbab08196145423b510599b442d8f53fa1cdc /web-ui/app/js | |
parent | 468bc98a3b1e0c92bffefa24c199b52f9f15b5dd (diff) | |
parent | f611ab80133efdea8cf1e303636c1a850b5d52d0 (diff) |
Merge pull request #912 from pixelated/tooltip-labels
[#828] Adds tooltips for encrypt and sign labels
Diffstat (limited to 'web-ui/app/js')
-rw-r--r-- | web-ui/app/js/mail_view/ui/mail_view.js | 99 |
1 files changed, 60 insertions, 39 deletions
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..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,73 +96,94 @@ define( }; this.checkEncrypted = function(mail) { + 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)) { - return { - cssClass: 'security-status__label--not-encrypted', - label: 'not-encrypted' - }; + return NOT_ENCRYPTED_FLAG; } - var statusClass = ['security-status__label--encrypted']; - var statusLabel; + if(this.hasAnyEncryptionInfo(mail)) { + return ENCRYPTED_FLAG; + } + + return ENCRYPTED_WITH_ERROR_FLAG; + }; - var hasAnyEncryptionInfo = _.any(mail.security_casing.locks, function (lock) { + this.hasAnyEncryptionInfo = function(mail) { + return _.any(mail.security_casing.locks, function (lock) { return lock.state === 'valid'; }); + }; - if(hasAnyEncryptionInfo) { - statusLabel = 'encrypted'; - } else { - statusClass.push('--with-error'); - statusLabel = 'encryption-error'; - } + this.checkSigned = function(mail) { - return { - cssClass: statusClass.join(''), - label: statusLabel + var SIGNED_FLAG = { + cssClass: 'security-status__label--signed', + label: 'signed', + tooltipText: 'signed-label-tooltip' }; - }; - this.checkSigned = function(mail) { - var statusNotSigned = { - cssClass: 'security-status__label--not-signed', - label: 'not-signed' + var SIGNED_REVOKED_FLAG = { + cssClass: 'security-status__label--signed--revoked', + label: 'signature-revoked', + tooltipText: 'not-signed-label-tooltip' }; - if(_.isEmpty(mail.security_casing.imprints)) { - return statusNotSigned; - } + 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(hasNoSignatureInformation) { - return statusNotSigned; + if(_.isEmpty(mail.security_casing.imprints) || hasNoSignatureInformation) { + return NOT_SIGNED_FLAG; } - 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'); + return SIGNED_REVOKED_FLAG; } if(_.any(mail.security_casing.imprints, function(imprint) { return imprint.state === 'from_expired'; })) { - statusClass.push('--expired'); - statusLabel.push('signature-expired'); + return SIGNED_EXPIRED_FLAG; } if(this.isNotTrusted(mail)) { - statusClass.push('--not-trusted'); - statusLabel.push('signature-not-trusted'); + return SIGNED_NOT_TRUSTED_FLAG; } - return { - cssClass: statusClass.join(''), - label: statusLabel.join(' ') - }; + return SIGNED_FLAG; }; this.isNotTrusted = function(mail){ |