Skip to content

Commit

Permalink
feat(web): add mxplan chip for dkim
Browse files Browse the repository at this point in the history
    ref: MANAGER-14918

Signed-off-by: Antony MARION <[email protected]>
  • Loading branch information
Antony MARION authored and ghyenne committed Nov 18, 2024
1 parent 6b4ac70 commit 4939db8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
export const DKIM_STATUS = {
ACTIVE: 'active',
ENABLED: 'enabled',
DISABLED: 'disabled',
DISABLED_NO_SET: 'error',
ERROR: 'error',
IN_PROGRESS: 'inProgress',
TO_CONFIGURE: 'toConfigure',
MODIFYING: 'modifying',
};

export const DKIM_STATUS_TEXT = {
Expand All @@ -21,6 +24,15 @@ export const DKIM_STATUS_CLASS = {
[DKIM_STATUS.ERROR]: 'oui-badge_error',
};

export const DKIM_STATUS_CLASS_MXPLAN = {
[DKIM_STATUS.ENABLED]: 'oui-badge_success',
[DKIM_STATUS.DISABLED]: 'oui-badge_warning',
[DKIM_STATUS.DISABLED_NO_SET]: 'oui-badge_error',
[DKIM_STATUS.TO_CONFIGURE]: 'oui-badge_error',
[DKIM_STATUS.MODIFYING]: 'oui-badge_info',
[DKIM_STATUS.ERROR]: 'oui-badge_error',
};

export default {
DKIM_STATUS,
DKIM_STATUS_TEXT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import angular from 'angular';
import set from 'lodash/set';

import { DKIM_STATUS, DKIM_STATUS_CLASS } from './emailpro-domain.constants';
import {
DKIM_STATUS,
DKIM_STATUS_CLASS,
DKIM_STATUS_CLASS_MXPLAN,
} from './emailpro-domain.constants';

export default /* @ngInject */ (
$scope,
Expand All @@ -17,6 +21,7 @@ export default /* @ngInject */ (
$scope.stateOk = EmailPro.stateOk;
$scope.DKIM_STATUS = DKIM_STATUS;
$scope.DKIM_STATUS_CLASS = DKIM_STATUS_CLASS;
$scope.DKIM_STATUS_CLASS_MXPLAN = DKIM_STATUS_CLASS_MXPLAN;

const init = function init() {
$scope.loading = false;
Expand Down Expand Up @@ -138,6 +143,27 @@ export default /* @ngInject */ (
}
}

$scope.getDkimColouredChipClass = function getDkimColouredChipClass(
exchange,
domain,
) {
return exchange.isMXPlan
? DKIM_STATUS_CLASS_MXPLAN[$scope.getDkimForMxPlan(domain)]
: DKIM_STATUS_CLASS[domain.dkimDiag.state];
};

$scope.getDkimForMxPlan = function getDkimForMxPlan(domain) {
if (domain.dkim.status !== DKIM_STATUS.DISABLED) {
return domain.dkim.status;
}
const otherStatusThanSet =
domain.dkim.selectors.filter((selector) => selector.status !== 'set')
.length > 0;
return otherStatusThanSet
? DKIM_STATUS.DISABLED_NO_SET
: DKIM_STATUS.DISABLED;
};

$scope.getDomains = function getDomains(count, offset) {
$scope.loading = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@

<!-- dkim -->
<button
data-ng-if="getDkimColouredChipClass(exchange, domain)"
class="oui-badge"
data-ng-class="DKIM_STATUS_CLASS[domain.dkimDiag.state]"
data-ng-class="getDkimColouredChipClass(exchange, domain)"
data-ng-click="setAction('emailpro/domain/dkim-autoconfig/emailpro-domain-dkim-autoconfig', {
domain,
domain
})"
data-ng-if="!exchange.isMXPlan"
data-translate="emailpro_tab_domain_diagnostic_dkim"
></button>
<!-- end dkim -->
Expand Down

0 comments on commit 4939db8

Please sign in to comment.