summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mail_view/ui/mail_view.js
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/app/js/mail_view/ui/mail_view.js')
-rw-r--r--web-ui/app/js/mail_view/ui/mail_view.js99
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){