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 3562e8f511 TP Fix issue where user is unable to submit changes to DS 
if they had Geo Limit Countries (#7505)
3562e8f511 is described below

commit 3562e8f51107b2c569eb012ebf2e6a1eda7826d0
Author: Steve Hamrick <[email protected]>
AuthorDate: Wed May 10 16:54:33 2023 -0600

    TP Fix issue where user is unable to submit changes to DS if they had Geo 
Limit Countries (#7505)
    
    * Fix unable to update DS with geo limit country changes
    
    * Changelog
    
    * Fix issue with change requests
    
    * Load fields for all DS action forms
---
 CHANGELOG.md                                       |  1 +
 .../FormDeliveryServiceController.js               | 26 ++++++++++++++++++++++
 .../edit/FormEditDeliveryServiceController.js      |  1 +
 .../form.deliveryService.DNS.tpl.html              | 12 +++++-----
 .../form.deliveryService.HTTP.tpl.html             | 10 ++++-----
 .../form.deliveryService.Steering.tpl.html         | 12 +++++-----
 .../new/FormNewDeliveryServiceController.js        |  1 +
 7 files changed, 46 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 98433ed19e..beb1ac775c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -53,6 +53,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#7469](https://github.com/apache/trafficcontrol/pull/7469) *Traffic Ops* 
Changed logic to not report empty or missing cookies into TO error.log.
 
 ### Fixed
+- [#7505](https://github.com/apache/trafficcontrol/pull/7505) *Traffic Portal* 
Fix an issue where a Delivery Service with Geo Limit Countries Set was unable 
to be updated.
 - [#7441](https://github.com/apache/trafficcontrol/pull/7441) *Traffic Ops* 
Fixed the invalidation jobs endpoint to respect CDN locks.
 - [#7413](https://github.com/apache/trafficcontrol/issues/7413) *Traffic Ops* 
Fixes service_category apis to respond with RFC3339 date/time Format
 - [#7414](https://github.com/apache/trafficcontrol/pull/7414) * Traffic 
Portal* Fixed DSR difference for DS required capability.
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 be24049365..452de62102 100644
--- 
a/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
+++ 
b/traffic_portal/app/src/common/modules/form/deliveryService/FormDeliveryServiceController.js
@@ -97,6 +97,27 @@ var FormDeliveryServiceController = 
function(deliveryService, dsCurrent, origin,
        }
        $scope.toggleTLSRestrict = toggleTLSRestrict;
 
+       $scope.hasGeoLimitCountries = function(ds) {
+               return ds && ds.geoLimit === 1 || ds.geoLimit === 2;
+       }
+
+       $scope.loadGeoLimitCountriesRaw = function (ds) {
+               if($scope.hasGeoLimitCountries(ds)) {
+                       ds.geoLimitCountriesRaw = (ds.geoLimitCountries ?? 
[]).join(",");
+               } else {
+                       ds.geoLimitCountriesRaw = "";
+               }
+       }
+
+       $scope.loadGeoLimitCountries = function (ds) {
+               if($scope.hasGeoLimitCountries(ds)) {
+                       ds.geoLimitCountries = 
ds.geoLimitCountriesRaw.split(",");
+               } else {
+                       ds.geoLimitCountriesRaw = "";
+                       ds.geoLimitCountries = [];
+               }
+       }
+
        /**
         * Removes a TLS version at the given index.
         * @param {number} index
@@ -483,6 +504,11 @@ var FormDeliveryServiceController = 
function(deliveryService, dsCurrent, origin,
        }
        $scope.tlsVersionHasPropertyError = tlsVersionHasPropertyError;
 
+       this.$onInit = function() {
+               $scope.loadGeoLimitCountriesRaw(this.deliveryService);
+               $scope.loadGeoLimitCountriesRaw(this.dsCurrent);
+       }
+
        /**
         * Checks if a TLS Version has any error.
         *
diff --git 
a/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js
 
b/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js
index 87ecae043d..03f8da9bfb 100644
--- 
a/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js
+++ 
b/traffic_portal/app/src/common/modules/form/deliveryService/edit/FormEditDeliveryServiceController.js
@@ -266,6 +266,7 @@ var FormEditDeliveryServiceController = 
function(deliveryService, origin, topolo
         */
        $scope.save = async function(deliveryService) {
                deliveryService.requiredCapabilities = 
Object.entries($scope.selectedCapabilities).filter(sc => (sc[1])).map(sc => 
sc[0])
+               $scope.loadGeoLimitCountries(deliveryService);
 
                if (
                        deliveryService.sslKeyVersion !== null &&
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 76ce0c9d34..0aeb7bc9ea 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
@@ -1018,18 +1018,18 @@ under the License.
                             </aside>
                         </div>
                     </div>
-                    <div class="form-group" ng-class="{'has-error': 
hasError(routingConfig.geoLimitCountries), 'has-feedback': 
hasError(routingConfig.geoLimitCountries)}" ng-show="deliveryService.geoLimit 
=== 1 || deliveryService.geoLimit === 2">
-                        <label class="has-tooltip control-label col-md-2 
col-sm-2 col-xs-12" for="geoLimitCountries">Geo Limit Countries<div 
class="helptooltip">
+                    <div class="form-group" ng-class="{'has-error': 
hasError(routingConfig.geoLimitCountriesRaw), 'has-feedback': 
hasError(routingConfig.geoLimitCountriesRaw)}" 
ng-show="hasGeoLimitCountries(deliveryService)">
+                        <label class="has-tooltip control-label col-md-2 
col-sm-2 col-xs-12" for="geoLimitCountriesRaw">Geo Limit Countries<div 
class="helptooltip">
                             <div class="helptext">How (if at all) is this 
service to be limited by geography. Example Country Codes: <abbr 
title="Canada">CA</abbr>, <abbr title="India">IN</abbr>, <abbr title="Puerto 
Rico">PR</abbr>.</div>
                         </div>
                         </label>
                         <div class="col-md-10 col-sm-10 col-xs-12">
-                            <input id="geoLimitCountries" 
name="geoLimitCountries" type="text" class="form-control" 
ng-model="deliveryService.geoLimitCountries" maxlength="255" 
pattern="[A-Z]+(,[A-Z]+)*">
-                            <small class="input-error" 
ng-show="hasPropertyError(routingConfig.geoLimitCountries, 'maxlength')">Too 
Long</small>
-                            <aside class="current-value" 
ng-if="settings.isRequest" ng-show="deliveryService.geoLimitCountries != 
dsCurrent.geoLimitCountries">
+                            <input id="geoLimitCountriesRaw" 
name="geoLimitCountriesRaw" type="text" class="form-control" 
ng-model="deliveryService.geoLimitCountriesRaw" maxlength="255" 
pattern="[A-Z]+(,[A-Z]+)*">
+                            <small class="input-error" 
ng-show="hasPropertyError(routingConfig.geoLimitCountriesRaw, 'maxlength')">Too 
Long</small>
+                            <aside class="current-value" 
ng-if="settings.isRequest" ng-show="deliveryService.geoLimitCountriesRaw != 
dsCurrent.geoLimitCountriesRaw">
                                 <h3 ng-if="open()">Current Value</h3>
                                 <h3 ng-if="!open()">Previous Value</h3>
-                                <pre>{{::dsCurrent.geoLimitCountries}}</pre>
+                                <pre>{{::dsCurrent.geoLimitCountriesRaw}}</pre>
                             </aside>
                         </div>
                     </div>
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 a1b06577e1..56609873d3 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
@@ -1117,15 +1117,15 @@ under the License.
                             </aside>
                         </div>
                     </div>
-                    <div class="form-group" ng-class="{'has-error': 
hasError(routingConfig.geoLimitCountries), 'has-feedback': 
hasError(routingConfig.geoLimitCountries)}" ng-show="deliveryService.geoLimit 
=== 1 || deliveryService.geoLimit === 2">
-                        <label class="has-tooltip control-label col-md-2 
col-sm-2 col-xs-12" for="geoLimitCountries">Geo Limit Countries<div 
class="helptooltip">
+                    <div class="form-group" ng-class="{'has-error': 
hasError(routingConfig.geoLimitCountriesRaw), 'has-feedback': 
hasError(routingConfig.geoLimitCountriesRaw)}" 
ng-show="hasGeoLimitCountries(deliveryService)">
+                        <label class="has-tooltip control-label col-md-2 
col-sm-2 col-xs-12" for="geoLimitCountriesRaw">Geo Limit Countries<div 
class="helptooltip">
                             <div class="helptext">How (if at all) is this 
service to be limited by geography. Example Country Codes: <abbr 
title="Canada">CA</abbr>, <abbr title="India">IN</abbr>, <abbr title="Puerto 
Rico">PR</abbr>.</div>
                         </div>
                         </label>
                         <div class="col-md-10 col-sm-10 col-xs-12">
-                            <input id="geoLimitCountries" 
name="geoLimitCountries" type="text" class="form-control" 
ng-model="deliveryService.geoLimitCountries" maxlength="255" 
pattern="[A-Z]+(,[A-Z]+)*">
-                            <small class="input-error" 
ng-show="hasPropertyError(routingConfig.geoLimitCountries, 'maxlength')">Too 
Long</small>
-                            <aside class="current-value" 
ng-if="settings.isRequest" ng-show="deliveryService.geoLimitCountries != 
dsCurrent.geoLimitCountries">
+                            <input id="geoLimitCountriesRaw" 
name="geoLimitCountriesRaw" type="text" class="form-control" 
ng-model="deliveryService.geoLimitCountriesRaw" maxlength="255" 
pattern="[A-Z]+(,[A-Z]+)*">
+                            <small class="input-error" 
ng-show="hasPropertyError(routingConfig.geoLimitCountriesRaw, 'maxlength')">Too 
Long</small>
+                            <aside class="current-value" 
ng-if="settings.isRequest" ng-show="deliveryService.geoLimitCountriesRaw != 
dsCurrent.geoLimitCountriesRaw">
                                 <h3 ng-if="open()">Current Value</h3>
                                 <h3 ng-if="!open()">Previous Value</h3>
                                 <pre>{{::dsCurrent.geoLimitCountries}}</pre>
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 04635e7ae3..8c98aad1e6 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
@@ -411,18 +411,18 @@ under the License.
                             </aside>
                         </div>
                     </div>
-                    <div class="form-group" ng-class="{'has-error': 
hasError(routingConfig.geoLimitCountries), 'has-feedback': 
hasError(routingConfig.geoLimitCountries)}" ng-show="deliveryService.geoLimit 
=== 1 || deliveryService.geoLimit === 2">
-                        <label class="has-tooltip control-label col-md-2 
col-sm-2 col-xs-12" for="geoLimitCountries">Geo Limit Countries<div 
class="helptooltip">
+                    <div class="form-group" ng-class="{'has-error': 
hasError(routingConfig.geoLimitCountriesRaw), 'has-feedback': 
hasError(routingConfig.geoLimitCountriesRaw)}" 
ng-show="hasGeoLimitCountries(deliveryService)">
+                        <label class="has-tooltip control-label col-md-2 
col-sm-2 col-xs-12" for="geoLimitCountriesRaw">Geo Limit Countries<div 
class="helptooltip">
                             <div class="helptext">How (if at all) is this 
service to be limited by geography. Example Country Codes: <abbr 
title="Canada">CA</abbr>, <abbr title="India">IN</abbr>, <abbr title="Puerto 
Rico">PR</abbr>.</div>
                         </div>
                         </label>
                         <div class="col-md-10 col-sm-10 col-xs-12">
-                            <input id="geoLimitCountries" 
name="geoLimitCountries" type="text" class="form-control" 
ng-model="deliveryService.geoLimitCountries" maxlength="255" 
pattern="[A-Z]+(,[A-Z]+)*">
-                            <small class="input-error" 
ng-show="hasPropertyError(routingConfig.geoLimitCountries, 'maxlength')">Too 
Long</small>
-                            <aside class="current-value" 
ng-if="settings.isRequest" ng-show="deliveryService.geoLimitCountries != 
dsCurrent.geoLimitCountries">
+                            <input id="geoLimitCountriesRaw" 
name="geoLimitCountriesRaw" type="text" class="form-control" 
ng-model="deliveryService.geoLimitCountriesRaw" maxlength="255" 
pattern="[A-Z]+(,[A-Z]+)*">
+                            <small class="input-error" 
ng-show="hasPropertyError(routingConfig.geoLimitCountriesRaw, 'maxlength')">Too 
Long</small>
+                            <aside class="current-value" 
ng-if="settings.isRequest" ng-show="deliveryService.geoLimitCountriesRaw != 
dsCurrent.geoLimitCountriesRaw">
                                 <h3 ng-if="open()">Current Value</h3>
                                 <h3 ng-if="!open()">Previous Value</h3>
-                                <pre>{{::dsCurrent.geoLimitCountries}}</pre>
+                                <pre>{{::dsCurrent.geoLimitCountriesRaw}}</pre>
                             </aside>
                         </div>
                     </div>
diff --git 
a/traffic_portal/app/src/common/modules/form/deliveryService/new/FormNewDeliveryServiceController.js
 
b/traffic_portal/app/src/common/modules/form/deliveryService/new/FormNewDeliveryServiceController.js
index 6eab528e87..5a13395cbf 100644
--- 
a/traffic_portal/app/src/common/modules/form/deliveryService/new/FormNewDeliveryServiceController.js
+++ 
b/traffic_portal/app/src/common/modules/form/deliveryService/new/FormNewDeliveryServiceController.js
@@ -156,6 +156,7 @@ var FormNewDeliveryServiceController = 
function(deliveryService, origin, topolog
         */
        $scope.save = async function(deliveryService) {
                deliveryService.requiredCapabilities = 
Object.entries($scope.selectedCapabilities).filter(sc => (sc[1])).map(sc => 
sc[0])
+               $scope.loadGeoLimitCountries(deliveryService);
 
                if (!$scope.restrictTLS) {
                        deliveryService.tlsVersions = null;

Reply via email to