You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/02/03 20:49:35 UTC

[GitHub] [trafficcontrol] rimashah25 opened a new pull request #5495: Ability to change the name of a topology

rimashah25 opened a new pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495


   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [ ] This PR fixes #5361 <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   - Traffic Ops
   - Traffic Portal
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   
   Two ways to test the PR
   Method 1:
   Using curl API: api/3.0/topologies/edit?name=<existing_topology_name> and a json request body (like below), change the name field to a new name (for eg: test):
   
   ```
   {
   	"name":"test",
   	"description":"west topology-test",
   	"nodes":[{
   		"cachegroup":"test",
   		"parent":{"name":"","type":""},
   		"secParent":{"name":"","type":""},
   		"parents":[]
   	}]
   }
   ```
   
   Method 2:
   Using TP, edit an existing topology. The name field shouldn't be disabled and a user can edit the name and then click on update button.
   
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   - master (1df853c8)
   - 4.0.0
   - 4.0.1 (RC1)
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   
   - master (82314b1)
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [x] This PR includes tests
   - [x] I have explained why documentation is unnecessary
   - [x] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [x] This PR includes any and all required license headers
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   ## Additional Information
   <!-- If you would like to include any additional information on the PR for
   potential reviewers please put it here.
   
   Some examples of this would be:
   
   - Before and after screenshots/gifs of the Traffic Portal if it is affected
   - Links to other dependent Pull Requests
   - References to relevant context (e.g. new/updates to dependent libraries,
   mailing list records, blueprints)
   
   Feel free to leave this section blank (or, preferably, delete it entirely).
   -->
   No structure changes have occurred to require changing the documentation.
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570514487



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -394,8 +394,10 @@ func (topology TOTopology) GetKeys() (map[string]interface{}, bool) {
 
 // SetKeys is a requirement of the api.Updater interface and is called by
 // api.UpdateHandler().
+// SetKeys function will no longer makes the name key immutable by setting it to
+// query param. On 2/3/21, the requirement was added to change the topology name.
 func (topology *TOTopology) SetKeys(keys map[string]interface{}) {
-	topology.Name, _ = keys["name"].(string)
+	//topology.Name, _ = keys["name"].(string)

Review comment:
       You can remove the commented out line.

##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -572,10 +574,11 @@ func (topology *TOTopology) addParents() (error, error, int) {
 	return nil, nil, http.StatusOK
 }
 
-func (topology *TOTopology) setDescription() (error, error, int) {
-	rows, err := topology.ReqInfo.Tx.Query(updateQuery(), topology.Description, topology.Name)
+func (topology *TOTopology) setNameDescription() (error, error, int) {

Review comment:
       I think we should just change the name of this function to `setTopologyDetails` or something on those lines. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570576736



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -394,8 +394,10 @@ func (topology TOTopology) GetKeys() (map[string]interface{}, bool) {
 
 // SetKeys is a requirement of the api.Updater interface and is called by
 // api.UpdateHandler().
+// SetKeys function will no longer makes the name key immutable by setting it to
+// query param. On 2/3/21, the requirement was added to change the topology name.
 func (topology *TOTopology) SetKeys(keys map[string]interface{}) {
-	topology.Name, _ = keys["name"].(string)
+	//topology.Name, _ = keys["name"].(string)

Review comment:
       Good catch.. I updated the Validate()

##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -572,10 +574,11 @@ func (topology *TOTopology) addParents() (error, error, int) {
 	return nil, nil, http.StatusOK
 }
 
-func (topology *TOTopology) setDescription() (error, error, int) {
-	rows, err := topology.ReqInfo.Tx.Query(updateQuery(), topology.Description, topology.Name)
+func (topology *TOTopology) setNameDescription() (error, error, int) {

Review comment:
       Good idea!

##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       nope, the first save is for create button and second save is for update button.

##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       We can't since the `query param` in the url link will have old param. So, we need to go back to /topologies, and then click on a topology, to update the `query param` to new name.

##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -781,13 +785,13 @@ WHERE tcp.child IN
 func updateQuery() string {
 	query := `
 UPDATE topology t SET
-description = $1
-WHERE t.name = $2
+name = $1,
+description = $2
+WHERE t.name = $3
 RETURNING t.name, t.description, t.last_updated
 `
 	return query
 }
-

Review comment:
       oh ok.. i'll add it.

##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       Anytime.

##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       I am not sure if that would work but I can try.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570637208



##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       I am not sure if that would work but I can try.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570533495



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -394,8 +394,10 @@ func (topology TOTopology) GetKeys() (map[string]interface{}, bool) {
 
 // SetKeys is a requirement of the api.Updater interface and is called by
 // api.UpdateHandler().
+// SetKeys function will no longer makes the name key immutable by setting it to
+// query param. On 2/3/21, the requirement was added to change the topology name.
 func (topology *TOTopology) SetKeys(keys map[string]interface{}) {
-	topology.Name, _ = keys["name"].(string)
+	//topology.Name, _ = keys["name"].(string)

Review comment:
       So, I'm not positive, but I _think_ the `Validation()` method might be doing validation based on the _requested_ name, rather than the _current_ name, which would be bad. Can you double-check if that's happening or not?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rawlinp merged pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rawlinp merged pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570636499



##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       Anytime.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570634246



##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       I'm not much of a javascripter, but is it possible to use the `result.data.response.name` to navigate back to the original page?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570633095



##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       Ah, I see, they use the same function name -- that's confusing. Thank you for clarifying.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570514487



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -394,8 +394,10 @@ func (topology TOTopology) GetKeys() (map[string]interface{}, bool) {
 
 // SetKeys is a requirement of the api.Updater interface and is called by
 // api.UpdateHandler().
+// SetKeys function will no longer makes the name key immutable by setting it to
+// query param. On 2/3/21, the requirement was added to change the topology name.
 func (topology *TOTopology) SetKeys(keys map[string]interface{}) {
-	topology.Name, _ = keys["name"].(string)
+	//topology.Name, _ = keys["name"].(string)

Review comment:
       You can remove the commented out line.

##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -572,10 +574,11 @@ func (topology *TOTopology) addParents() (error, error, int) {
 	return nil, nil, http.StatusOK
 }
 
-func (topology *TOTopology) setDescription() (error, error, int) {
-	rows, err := topology.ReqInfo.Tx.Query(updateQuery(), topology.Description, topology.Name)
+func (topology *TOTopology) setNameDescription() (error, error, int) {

Review comment:
       I think we should just change the name of this function to `setTopologyDetails` or something on those lines. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r571093341



##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       Updated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570533495



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -394,8 +394,10 @@ func (topology TOTopology) GetKeys() (map[string]interface{}, bool) {
 
 // SetKeys is a requirement of the api.Updater interface and is called by
 // api.UpdateHandler().
+// SetKeys function will no longer makes the name key immutable by setting it to
+// query param. On 2/3/21, the requirement was added to change the topology name.
 func (topology *TOTopology) SetKeys(keys map[string]interface{}) {
-	topology.Name, _ = keys["name"].(string)
+	//topology.Name, _ = keys["name"].(string)

Review comment:
       So, I'm not positive, but I _think_ the `Validation()` method might be doing validation based on the _requested_ name, rather than the _current_ name, which would be bad. Can you double-check if that's happening or not?

##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       Shouldn't this call to `save` have all 4 params?

##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       Why navigate to `/topologies`? Don't we want to stay on the same page?

##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -781,13 +785,13 @@ WHERE tcp.child IN
 func updateQuery() string {
 	query := `
 UPDATE topology t SET
-description = $1
-WHERE t.name = $2
+name = $1,
+description = $2
+WHERE t.name = $3
 RETURNING t.name, t.description, t.last_updated
 `
 	return query
 }
-

Review comment:
       gofmt will probably complain about this line missing

##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       Ah, I see, they use the same function name -- that's confusing. Thank you for clarifying.

##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       I'm not much of a javascripter, but is it possible to use the `result.data.response.name` to navigate back to the original page?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570630069



##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       We can't since the `query param` in the url link will have old param. So, we need to go back to /topologies, and then click on a topology, to update the `query param` to new name.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570576736



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -394,8 +394,10 @@ func (topology TOTopology) GetKeys() (map[string]interface{}, bool) {
 
 // SetKeys is a requirement of the api.Updater interface and is called by
 // api.UpdateHandler().
+// SetKeys function will no longer makes the name key immutable by setting it to
+// query param. On 2/3/21, the requirement was added to change the topology name.
 func (topology *TOTopology) SetKeys(keys map[string]interface{}) {
-	topology.Name, _ = keys["name"].(string)
+	//topology.Name, _ = keys["name"].(string)

Review comment:
       Good catch.. I updated the Validate()




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570629229



##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       nope, the first save is for create button and second save is for update button.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570630276



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -781,13 +785,13 @@ WHERE tcp.child IN
 func updateQuery() string {
 	query := `
 UPDATE topology t SET
-description = $1
-WHERE t.name = $2
+name = $1,
+description = $2
+WHERE t.name = $3
 RETURNING t.name, t.description, t.last_updated
 `
 	return query
 }
-

Review comment:
       oh ok.. i'll add it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rimashah25 commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570576911



##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -572,10 +574,11 @@ func (topology *TOTopology) addParents() (error, error, int) {
 	return nil, nil, http.StatusOK
 }
 
-func (topology *TOTopology) setDescription() (error, error, int) {
-	rows, err := topology.ReqInfo.Tx.Query(updateQuery(), topology.Description, topology.Name)
+func (topology *TOTopology) setNameDescription() (error, error, int) {

Review comment:
       Good idea!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5495: Ability to change the name of a topology

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #5495:
URL: https://github.com/apache/trafficcontrol/pull/5495#discussion_r570623666



##########
File path: traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
##########
@@ -87,7 +87,8 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-danger" ng-show="!settings.isNew" ng-click="confirmDelete(topology)">Delete</button>
-                <button type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>
+                <button ng-if="settings.isNew" type="button" class="btn btn-success" ng-disabled="topologyForm.$pristine || topologyForm.$invalid" ng-click="save(topology.name, topology.description, topologyTree)">{{settings.saveLabel}}</button>

Review comment:
       Shouldn't this call to `save` have all 4 params?

##########
File path: traffic_portal/app/src/common/modules/form/topology/edit/FormEditTopologyController.js
##########
@@ -37,11 +37,12 @@ var FormEditTopologyController = function(topologies, cacheGroups, $scope, $cont
 		saveLabel: 'Update'
 	};
 
-	$scope.save = function(name, description, topologyTree) {
-		let normalizedTopology = topologyUtils.getNormalizedTopology(name, description, topologyTree);
-		topologyService.updateTopology(normalizedTopology).
+	$scope.save = function(currentName, newName, description, topologyTree) {
+		let normalizedTopology = topologyUtils.getNormalizedTopology(newName, description, topologyTree);
+		topologyService.updateTopology(normalizedTopology, currentName).
 			then(function(result) {
-				messageModel.setMessages(result.data.alerts, false);
+				messageModel.setMessages(result.data.alerts, true);
+				locationUtils.navigateToPath('/topologies');

Review comment:
       Why navigate to `/topologies`? Don't we want to stay on the same page?

##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -781,13 +785,13 @@ WHERE tcp.child IN
 func updateQuery() string {
 	query := `
 UPDATE topology t SET
-description = $1
-WHERE t.name = $2
+name = $1,
+description = $2
+WHERE t.name = $3
 RETURNING t.name, t.description, t.last_updated
 `
 	return query
 }
-

Review comment:
       gofmt will probably complain about this line missing




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org