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 2021/01/06 22:57:06 UTC
[trafficcontrol] branch master updated: TP: adds the ability to
clone a topology (#5400)
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 60e7f20 TP: adds the ability to clone a topology (#5400)
60e7f20 is described below
commit 60e7f208d8abca7bc8ef9ffce09de978f5878062
Author: Jeremy Mitchell <mi...@users.noreply.github.com>
AuthorDate: Wed Jan 6 15:56:51 2021 -0700
TP: adds the ability to clone a topology (#5400)
* adds the ability to clone a topology
* adds ui test for cloning a topology
* adds changelog.md entry
---
CHANGELOG.md | 1 +
traffic_portal/app/src/app.js | 2 ++
.../form/topology/FormTopologyController.js | 4 +++
.../topology/clone/FormCloneTopologyController.js} | 35 ++++++++++++--------
.../common/modules/form/topology/clone/index.js} | 17 ++--------
.../modules/form/topology/form.topology.tpl.html | 4 +++
.../src/modules/private/topologies/clone/index.js} | 38 +++++++++++++---------
.../test/end_to_end/topologies/pageData.js | 2 ++
.../test/end_to_end/topologies/topologies-spec.js | 12 +++++++
9 files changed, 71 insertions(+), 44 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52bd9f3..9d17e3d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [unreleased]
### Added
- Traffic Portal: [#5394](https://github.com/apache/trafficcontrol/issues/5394) - Converts the tenant table to a tenant tree for usability
+- Traffic Portal: [#5360](https://github.com/apache/trafficcontrol/issues/5360) - Adds the ability to clone a topology
- Traffic Ops: added a feature so that the user can specify `maxRequestHeaderBytes` on a per delivery service basis
- Traffic Router: log warnings when requests to Traffic Monitor return a 503 status code
- [#5344](https://github.com/apache/trafficcontrol/issues/5344) - Add a page that addresses migrating from Traffic Ops API v1 for each endpoint
diff --git a/traffic_portal/app/src/app.js b/traffic_portal/app/src/app.js
index 0bdf95f..a5dd32e 100644
--- a/traffic_portal/app/src/app.js
+++ b/traffic_portal/app/src/app.js
@@ -212,6 +212,7 @@ var trafficPortal = angular.module('trafficPortal', [
require('./modules/private/types').name,
require('./modules/private/topologies').name,
require('./modules/private/topologies/cacheGroups').name,
+ require('./modules/private/topologies/clone').name,
require('./modules/private/topologies/deliveryServices').name,
require('./modules/private/topologies/edit').name,
require('./modules/private/topologies/list').name,
@@ -337,6 +338,7 @@ var trafficPortal = angular.module('trafficPortal', [
require('./common/modules/form/tenant/edit').name,
require('./common/modules/form/tenant/new').name,
require('./common/modules/form/topology').name,
+ require('./common/modules/form/topology/clone').name,
require('./common/modules/form/topology/edit').name,
require('./common/modules/form/topology/new').name,
require('./common/modules/form/type').name,
diff --git a/traffic_portal/app/src/common/modules/form/topology/FormTopologyController.js b/traffic_portal/app/src/common/modules/form/topology/FormTopologyController.js
index fbd423d..a8e77c3 100644
--- a/traffic_portal/app/src/common/modules/form/topology/FormTopologyController.js
+++ b/traffic_portal/app/src/common/modules/form/topology/FormTopologyController.js
@@ -106,6 +106,10 @@ var FormTopologyController = function(topology, cacheGroups, $anchorScroll, $sco
$scope.hasPropertyError = formUtils.hasPropertyError;
+ $scope.clone = function(topology) {
+ locationUtils.navigateToPath('/topologies/clone?name=' + topology.name);
+ };
+
$scope.viewCacheGroups = function() {
$location.path('/topologies/cache-groups');
};
diff --git a/traffic_portal/test/end_to_end/topologies/pageData.js b/traffic_portal/app/src/common/modules/form/topology/clone/FormCloneTopologyController.js
similarity index 50%
copy from traffic_portal/test/end_to_end/topologies/pageData.js
copy to traffic_portal/app/src/common/modules/form/topology/clone/FormCloneTopologyController.js
index 62723d6..039a092 100644
--- a/traffic_portal/test/end_to_end/topologies/pageData.js
+++ b/traffic_portal/app/src/common/modules/form/topology/clone/FormCloneTopologyController.js
@@ -17,18 +17,25 @@
* under the License.
*/
-module.exports = function(){
- this.moreBtn=element(by.name('moreBtn'));
- this.topLink=element(by.name('topLink'));
- this.searchFilter=element(by.id('topologiesTable_filter')).element(by.css('label input'));
- this.name=element(by.name('name'));
- this.description=element(by.id('description'));
- this.addChildCacheGroupBtn=element(by.css('.add-child-cg-btn'));
- this.selectFormSubmitButton=element(by.buttonText('Submit'));
- this.selectAllCB=element(by.id('selectAllCB'));
- this.updateButton=element(by.buttonText('Update'));
- this.createButton=element(by.buttonText('Create'));
- this.viewDeliveryServicesMenuItem=element(by.name('viewDeliveryServicesMenuItem'));
- this.viewCacheGroupsMenuItem=element(by.name('viewCacheGroupsMenuItem'));
- this.viewServersMenuItem=element(by.name('viewServersMenuItem'));
+var FormCloneTopologyController = function(topologies, cacheGroups, $scope, $controller) {
+
+ // extends the FormNewTopologyController to inherit common methods
+ angular.extend(this, $controller('FormNewTopologyController', { topology: topologies[0], cacheGroups: cacheGroups, $scope: $scope }));
+
+ $scope.topologyName = angular.copy($scope.topology.name) + ' clone';
+
+ $scope.settings = {
+ isNew: true,
+ saveLabel: 'Clone'
+ };
+
+ let init = function() {
+ // cloned topology needs a new name
+ $scope.topology.name = '';
+ };
+ init();
+
};
+
+FormCloneTopologyController.$inject = ['topologies', 'cacheGroups', '$scope', '$controller'];
+module.exports = FormCloneTopologyController;
diff --git a/traffic_portal/test/end_to_end/topologies/pageData.js b/traffic_portal/app/src/common/modules/form/topology/clone/index.js
similarity index 50%
copy from traffic_portal/test/end_to_end/topologies/pageData.js
copy to traffic_portal/app/src/common/modules/form/topology/clone/index.js
index 62723d6..43bc315 100644
--- a/traffic_portal/test/end_to_end/topologies/pageData.js
+++ b/traffic_portal/app/src/common/modules/form/topology/clone/index.js
@@ -17,18 +17,5 @@
* under the License.
*/
-module.exports = function(){
- this.moreBtn=element(by.name('moreBtn'));
- this.topLink=element(by.name('topLink'));
- this.searchFilter=element(by.id('topologiesTable_filter')).element(by.css('label input'));
- this.name=element(by.name('name'));
- this.description=element(by.id('description'));
- this.addChildCacheGroupBtn=element(by.css('.add-child-cg-btn'));
- this.selectFormSubmitButton=element(by.buttonText('Submit'));
- this.selectAllCB=element(by.id('selectAllCB'));
- this.updateButton=element(by.buttonText('Update'));
- this.createButton=element(by.buttonText('Create'));
- this.viewDeliveryServicesMenuItem=element(by.name('viewDeliveryServicesMenuItem'));
- this.viewCacheGroupsMenuItem=element(by.name('viewCacheGroupsMenuItem'));
- this.viewServersMenuItem=element(by.name('viewServersMenuItem'));
-};
+module.exports = angular.module('trafficPortal.form.topology.clone', [])
+ .controller('FormCloneTopologyController', require('./FormCloneTopologyController'));
diff --git a/traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html b/traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
index 279b4f7..da35785 100644
--- a/traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
+++ b/traffic_portal/app/src/common/modules/form/topology/form.topology.tpl.html
@@ -31,6 +31,10 @@ under the License.
</button>
<ul class="dropdown-menu-right dropdown-menu" uib-dropdown-menu>
<li role="menuitem">
+ <button type="button" name="cloneToplogyMenuItem" title="Clone Topology" ng-click="clone(topology)">Clone Topology</button>
+ </li>
+ <hr class="divider"/>
+ <li role="menuitem">
<button type="button" name="viewDeliveryServicesMenuItem" title="View Delivery Services" ng-click="viewDeliveryServices()">View Delivery Services</button>
</li>
<li class="divider"></li>
diff --git a/traffic_portal/test/end_to_end/topologies/pageData.js b/traffic_portal/app/src/modules/private/topologies/clone/index.js
similarity index 50%
copy from traffic_portal/test/end_to_end/topologies/pageData.js
copy to traffic_portal/app/src/modules/private/topologies/clone/index.js
index 62723d6..6fcdfa1 100644
--- a/traffic_portal/test/end_to_end/topologies/pageData.js
+++ b/traffic_portal/app/src/modules/private/topologies/clone/index.js
@@ -17,18 +17,26 @@
* under the License.
*/
-module.exports = function(){
- this.moreBtn=element(by.name('moreBtn'));
- this.topLink=element(by.name('topLink'));
- this.searchFilter=element(by.id('topologiesTable_filter')).element(by.css('label input'));
- this.name=element(by.name('name'));
- this.description=element(by.id('description'));
- this.addChildCacheGroupBtn=element(by.css('.add-child-cg-btn'));
- this.selectFormSubmitButton=element(by.buttonText('Submit'));
- this.selectAllCB=element(by.id('selectAllCB'));
- this.updateButton=element(by.buttonText('Update'));
- this.createButton=element(by.buttonText('Create'));
- this.viewDeliveryServicesMenuItem=element(by.name('viewDeliveryServicesMenuItem'));
- this.viewCacheGroupsMenuItem=element(by.name('viewCacheGroupsMenuItem'));
- this.viewServersMenuItem=element(by.name('viewServersMenuItem'));
-};
+module.exports = angular.module('trafficPortal.private.topologies.clone', [])
+ .config(function($stateProvider, $urlRouterProvider) {
+ $stateProvider
+ .state('trafficPortal.private.topologies.clone', {
+ url: '/clone?name',
+ views: {
+ topologiesContent: {
+ templateUrl: 'common/modules/form/topology/form.topology.tpl.html',
+ controller: 'FormCloneTopologyController',
+ resolve: {
+ topologies: function($stateParams, topologyService) {
+ return topologyService.getTopologies({ name: $stateParams.name });
+ },
+ cacheGroups: function(cacheGroupService) {
+ return cacheGroupService.getCacheGroups();
+ }
+ }
+ }
+ }
+ })
+ ;
+ $urlRouterProvider.otherwise('/');
+ });
diff --git a/traffic_portal/test/end_to_end/topologies/pageData.js b/traffic_portal/test/end_to_end/topologies/pageData.js
index 62723d6..385bf57 100644
--- a/traffic_portal/test/end_to_end/topologies/pageData.js
+++ b/traffic_portal/test/end_to_end/topologies/pageData.js
@@ -26,8 +26,10 @@ module.exports = function(){
this.addChildCacheGroupBtn=element(by.css('.add-child-cg-btn'));
this.selectFormSubmitButton=element(by.buttonText('Submit'));
this.selectAllCB=element(by.id('selectAllCB'));
+ this.cloneButton=element(by.buttonText('Clone'));
this.updateButton=element(by.buttonText('Update'));
this.createButton=element(by.buttonText('Create'));
+ this.cloneToplogyMenuItem=element(by.name('cloneToplogyMenuItem'));
this.viewDeliveryServicesMenuItem=element(by.name('viewDeliveryServicesMenuItem'));
this.viewCacheGroupsMenuItem=element(by.name('viewCacheGroupsMenuItem'));
this.viewServersMenuItem=element(by.name('viewServersMenuItem'));
diff --git a/traffic_portal/test/end_to_end/topologies/topologies-spec.js b/traffic_portal/test/end_to_end/topologies/topologies-spec.js
index c2da821..548e47d 100644
--- a/traffic_portal/test/end_to_end/topologies/topologies-spec.js
+++ b/traffic_portal/test/end_to_end/topologies/topologies-spec.js
@@ -108,4 +108,16 @@ describe('Traffic Portal Topologies Test Suite', function() {
pageData.viewServersMenuItem.click();
expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toMatch(commonFunctions.urlPath(browser.baseUrl)+"#!/topologies/servers");
});
+
+ it('should navigate back to the topology and clone the topology', function() {
+ console.log('Cloning topology: ' + myNewTopology.name);
+ pageData.topLink.click();
+ pageData.moreBtn.click();
+ pageData.cloneToplogyMenuItem.click();
+ expect(pageData.cloneButton.isEnabled()).toBe(false);
+ pageData.name.sendKeys(myNewTopology.name + '-clone');
+ expect(pageData.cloneButton.isEnabled()).toBe(true);
+ pageData.cloneButton.click();
+ expect(browser.getCurrentUrl().then(commonFunctions.urlPath)).toEqual(commonFunctions.urlPath(browser.baseUrl)+"#!/topologies");
+ });
});