Skip to content

Commit

Permalink
fix(dedicated.firewall): disable toggle button
Browse files Browse the repository at this point in the history
ref: UXCT-512

disable toggle button if mitigation is on PERMANENT or FORCED status

Signed-off-by: Stephanie Moallic <[email protected]>
  • Loading branch information
Stephanie Moallic committed Dec 1, 2023
1 parent c01d697 commit 5e8a8dd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ export default /* @ngInject */ function IpFirewallService(
);
};

this.getMitigation = function getMitigation(ipBlock, ip) {
const url = [
'/ip',
window.encodeURIComponent(ipBlock),
'mitigation',
ip,
].join('/');
return $http.get(url, { serviceType: 'apiv6' }).then(
(result) => result.data,
(http) => $q.reject(http.data),
);
};

this.getFirewallRuleConstants = function getFirewallRuleConstants() {
return self.getIpModels().then((ipModels) => ({
actions: ipModels['ip.FirewallActionEnum'].enum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default /* @ngInject */ function IpFirewallCtrl(
self.successMessage = null;
self.denyMessage = null;
self.firewallStatus = null;
self.disabledToggle = false;

function paginate(pageSize, offset) {
self.rulesTable = self.rules.list.results.slice(
Expand Down Expand Up @@ -149,6 +150,16 @@ export default /* @ngInject */ function IpFirewallCtrl(
loadRules(self.FIREWALL_MAX_RULES, 0);
}

function getMitigationDetail() {
IpFirewall.getMitigation(self.selectedBlock, self.selectedIp).then(
(mitigation) => {
if (mitigation.permanent || mitigation.auto) {
self.disabledToggle = true;
}
},
);
}

function getFirewallDetail() {
IpFirewall.getFirewallDetails(self.selectedBlock, self.selectedIp).then(
(firewallDetails) => {
Expand All @@ -161,6 +172,8 @@ export default /* @ngInject */ function IpFirewallCtrl(
firewall: firewallDetails.enabled ? 'ACTIVATED' : 'DEACTIVATED',
};
self.firewallStatus = firewallDetails.enabled;

getMitigationDetail();
paginate(self.pageSize, self.offset);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@
data-model="IpFirewallCtrl.firewallToggle.status"
data-name="firewallStatus"
data-on-change="setAction('ip/firewall/toggle/ip-ip-firewall-toggle', {ipBlock: IpFirewallCtrl.ipBlock, ip: IpFirewallCtrl.firewallToggle, tracking: IpFirewallCtrl.tracking['update-firewall-status']})"
></oui-switch>
data-ng-if="!IpFirewallCtrl.disabledToggle"
>
</oui-switch>
<oui-switch
data-model="IpFirewallCtrl.firewallToggle.status"
data-name="firewallStatus"
data-ng-if="IpFirewallCtrl.disabledToggle"
data-oui-tooltip-placement="left"
data-oui-tooltip="{{:: 'ip_table_manage_firewall_disable_tooltip' | translate }}"
disabled
>
</oui-switch>
</div>
</div>
<div
Expand Down

0 comments on commit 5e8a8dd

Please sign in to comment.