You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2023/01/19 18:35:22 UTC
[trafficcontrol] branch master updated: Traffic Portal configuration option for Delivery Service active flags (#7296)
This is an automated email from the ASF dual-hosted git repository.
zrhoffman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 51ab760c0f Traffic Portal configuration option for Delivery Service active flags (#7296)
51ab760c0f is described below
commit 51ab760c0f60a24f070942f6211b1f1016ff3b75
Author: ocket8888 <oc...@apache.org>
AuthorDate: Thu Jan 19 11:35:15 2023 -0700
Traffic Portal configuration option for Delivery Service active flags (#7296)
* Add typings to the PropertiesModel
* Hide the new DS Active state behind a new configuration option
* Set up DS forms to not lie to users
* Add CHANGELOG entry
---
CHANGELOG.md | 1 +
.../app/src/common/models/PropertiesModel.js | 26 ++++++++++++++++------
.../FormDeliveryServiceController.js | 10 +++++++--
.../form.deliveryService.DNS.tpl.html | 4 ++--
.../form.deliveryService.HTTP.tpl.html | 4 ++--
.../form.deliveryService.Steering.tpl.html | 4 ++--
.../form.deliveryService.anyMap.tpl.html | 5 +++--
.../app/src/traffic_portal_properties.json | 3 ++-
8 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 49d4ba5d9e..b4d3bb296e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7176](https://github.com/apache/trafficcontrol/pull/7176) *ATC Build system* Support building ATC for the `aarch64` CPU architecture
- [#7113](https://github.com/apache/trafficcontrol/pull/7113) *Traffic Portal* Minimize the Server Server Capability part of the *Traffic Servers* section of the Snapshot Diff
- [#7273](https://github.com/apache/trafficcontrol/pull/7273) *Traffic Ops* Adds SSL-KEY-EXPIRATION:READ permission to operations, portal, read-only, federation and steering roles
+- [#7296](https://github.com/apache/trafficcontrol/pull/7296) *Traffic Portal* New configuration option in `traffic_portal_properties.json` at `deliveryServices.exposeInactive` controls exposing APIv5 DS Active State options in the TP UI.
### Changed
- [#7224](https://github.com/apache/trafficcontrol/pull/7224) *Traffic Ops* Required Capabilities are now a part of the `DeliveryService` structure.
diff --git a/traffic_portal/app/src/common/models/PropertiesModel.js b/traffic_portal/app/src/common/models/PropertiesModel.js
index b1326cacab..5cf57d30f0 100644
--- a/traffic_portal/app/src/common/models/PropertiesModel.js
+++ b/traffic_portal/app/src/common/models/PropertiesModel.js
@@ -15,12 +15,24 @@
*/
-var PropertiesModel = function() {
-
- this.properties = {};
- this.loaded = false;
-
- this.setProperties = function(properties) {
+/**
+ * PropertiesModel models the "properties" (i.e. configuration) of Traffic
+ * Portal.
+ */
+class PropertiesModel {
+
+ /**
+ * @type {Partial<typeof import("../../traffic_portal_properties.json").properties>}
+ */
+ properties = {};
+ loaded = false;
+
+ /**
+ * Loads in properties if not already done.
+ *
+ * @param {Partial<typeof import("../../traffic_portal_properties.json").properties>} properties
+ */
+ setProperties(properties) {
if (this.loaded) return;
this.properties = properties;
this.loaded = true;
@@ -29,4 +41,4 @@ var PropertiesModel = function() {
};
PropertiesModel.$inject = [];
-module.exports = PropertiesModel;
\ No newline at end of file
+module.exports = PropertiesModel;
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
index ade2f757d1..b5cbb005d1 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
@@ -47,6 +47,8 @@ var FormDeliveryServiceController = function(deliveryService, dsCurrent, origin,
*/
let cachedTLSVersions = null;
+ $scope.exposeInactive = !!(propertiesModel.properties.deliveryServices?.exposeInactive);
+
$scope.showSensitive = false;
const knownVersions = new Set(["1.0", "1.1", "1.2", "1.3"]);
@@ -232,11 +234,11 @@ var FormDeliveryServiceController = function(deliveryService, dsCurrent, origin,
$scope.topologies = topologies;
- $scope.showChartsButton = propertiesModel.properties.deliveryServices.charts.customLink.show;
+ $scope.showChartsButton = !!(propertiesModel.properties.deliveryServices?.charts?.customLink?.show);
$scope.openCharts = ds => deliveryServiceUtils.openCharts(ds);
- $scope.dsRequestsEnabled = propertiesModel.properties.dsRequests.enabled;
+ $scope.dsRequestsEnabled = !!(propertiesModel.properties.dsRequests?.enabled);
/**
* Gods have mercy.
@@ -476,6 +478,10 @@ var FormDeliveryServiceController = function(deliveryService, dsCurrent, origin,
// ... the right way to do this is with an interceptor, but nobody
// wants to put in that kinda work on a legacy product.
}
+
+ if (!$scope.exposeInactive && deliveryService.active === "INACTIVE") {
+ deliveryService.active = "PRIMED";
+ }
};
FormDeliveryServiceController.$inject = ["deliveryService", "dsCurrent", "origin", "topologies", "type", "types", "$scope", "formUtils", "tenantUtils", "deliveryServiceUtils", "deliveryServiceService", "cdnService", "profileService", "tenantService", "propertiesModel", "userModel", "serviceCategoryService"];
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html
index 3e39e47a81..54d77850d1 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html
@@ -126,8 +126,8 @@ under the License.
<select id="active" name="active" class="form-control" ng-model="deliveryService.active" required>
<option disabled hidden value="">Select...</option>
<option value="ACTIVE">Active</option>
- <option value="PRIMED">Primed</option>
- <option value="INACTIVE">Inactive</option>
+ <option value="PRIMED">{{exposeInactive ? 'Primed' : 'Inactive'}}</option>
+ <option ng-if="exposeInactive" value="INACTIVE">Inactive</option>
</select>
<small class="input-error" ng-show="hasPropertyError(generalConfig.active, 'required')">Required</small>
<aside class="current-value" ng-if="settings.isRequest" ng-show="deliveryService.active != dsCurrent.active">
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
index 3a99048d3b..f884b5c5c8 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
@@ -126,8 +126,8 @@ under the License.
<select id="active" name="active" class="form-control" ng-model="deliveryService.active" required>
<option disabled hidden value="">Select...</option>
<option value="ACTIVE">Active</option>
- <option value="PRIMED">Primed</option>
- <option value="INACTIVE">Inactive</option>
+ <option value="PRIMED">{{exposeInactive ? 'Primed' : 'Inactive'}}</option>
+ <option ng-if="exposeInactive" value="INACTIVE">Inactive</option>
</select>
<small class="input-error" ng-show="hasPropertyError(generalConfig.active, 'required')">Required</small>
<aside class="current-value" ng-if="settings.isRequest" ng-show="deliveryService.active != dsCurrent.active">
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.Steering.tpl.html b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.Steering.tpl.html
index ebdd30bb9f..1a660eb4ed 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.Steering.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.Steering.tpl.html
@@ -121,8 +121,8 @@ under the License.
<select id="active" name="active" class="form-control" ng-model="deliveryService.active" required>
<option disabled hidden value="">Select...</option>
<option value="ACTIVE">Active</option>
- <option value="PRIMED">Primed</option>
- <option value="INACTIVE">Inactive</option>
+ <option value="PRIMED">{{exposeInactive ? 'Primed' : 'Inactive'}}</option>
+ <option ng-if="exposeInactive" value="INACTIVE">Inactive</option>
</select>
<small class="input-error" ng-show="hasPropertyError(generalConfig.active, 'required')">Required</small>
<aside class="current-value" ng-if="settings.isRequest" ng-show="deliveryService.active != dsCurrent.active">
diff --git a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.anyMap.tpl.html b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.anyMap.tpl.html
index 1deb3451ea..e913de6d9d 100644
--- a/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.anyMap.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.anyMap.tpl.html
@@ -112,8 +112,9 @@ under the License.
<div class="col-md-10 col-sm-10 col-xs-12">
<select id="active" name="active" class="form-control" ng-model="deliveryService.active" required>
<option disabled hidden value="">Select...</option>
- <option value="PRIMED">Active</option>
- <option value="INACTIVE">Inactive</option>
+ <option value="ACTIVE">Active</option>
+ <option value="PRIMED">{{exposeInactive ? 'Primed' : 'Inactive'}}</option>
+ <option ng-if="exposeInactive" value="INACTIVE">Inactive</option>
</select>
<small class="input-error" ng-show="hasPropertyError(generalConfig.active, 'required')">Required</small>
<aside class="current-value" ng-if="settings.isRequest" ng-show="deliveryService.active != dsCurrent.active">
diff --git a/traffic_portal/app/src/traffic_portal_properties.json b/traffic_portal/app/src/traffic_portal_properties.json
index 8c04196d65..8dd1e71388 100644
--- a/traffic_portal/app/src/traffic_portal_properties.json
+++ b/traffic_portal/app/src/traffic_portal_properties.json
@@ -190,7 +190,8 @@
"show": false,
"baseUrl": "https://trafficstats.domain.com/dashboard/script/traffic_ops_deliveryservice.js?which="
}
- }
+ },
+ "exposeInactive": false
},
"dsRequests": {
"_comments": "Should all delivery service changes go through the delivery service request/review process? You can also provide a override role name (i.e. admin) that will allow users with the given role to circumvent the delivery service request process.",