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:
[email protected]