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