Skip to content

Commit 6350456

Browse files
Remove UI-based subproject management (#3649)
CDash currently supports managing subprojects via the UI, as well as Project.xml uploads. This PR removes the manual UI-based subproject management features. Going forward, the only way to define subprojects and their dependencies is via uploading a Project.xml.
1 parent eb03cb3 commit 6350456

File tree

6 files changed

+2
-248
lines changed

6 files changed

+2
-248
lines changed

app/cdash/public/api/v1/subproject.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -142,53 +142,11 @@ function rest_delete(): void
142142
$Group->Delete();
143143
return;
144144
}
145-
146-
$subprojectid = get_subprojectid();
147-
if ($subprojectid === false) {
148-
return;
149-
}
150-
151-
if (isset($_GET['dependencyid'])) {
152-
// Remove dependency from subproject.
153-
$SubProject = new SubProject();
154-
$SubProject->SetId($subprojectid);
155-
$SubProject->RemoveDependency(intval($_GET['dependencyid']));
156-
} else {
157-
// Delete subproject.
158-
$SubProject = new SubProject();
159-
$SubProject->SetId($subprojectid);
160-
$SubProject->Delete();
161-
}
162145
}
163146

164147
/** Handle POST requests */
165148
function rest_post($projectid): void
166149
{
167-
if (isset($_POST['newsubproject'])) {
168-
// Create a new subproject
169-
$SubProject = new SubProject();
170-
$SubProject->SetProjectId($projectid);
171-
172-
$newSubProject =
173-
htmlspecialchars($_POST['newsubproject']);
174-
$SubProject->SetName($newSubProject);
175-
176-
if (isset($_POST['group'])) {
177-
$SubProject->SetGroup(
178-
htmlspecialchars($_POST['group']));
179-
}
180-
181-
$SubProject->Save();
182-
183-
// Respond with a JSON representation of this new subproject
184-
$response = [];
185-
$response['id'] = $SubProject->GetId();
186-
$response['name'] = $SubProject->GetName();
187-
$response['group'] = $SubProject->GetGroupId();
188-
echo json_encode(cast_data_for_JSON($response));
189-
return;
190-
}
191-
192150
if (isset($_POST['newgroup'])) {
193151
// Create a new group
194152
$Group = new SubProjectGroup();
@@ -253,13 +211,6 @@ function rest_put($projectid): void
253211
$SubProject = new SubProject();
254212
$SubProject->SetId($subprojectid);
255213

256-
if (isset($_GET['dependencyid'])) {
257-
// Add dependency to existing subproject.
258-
$dependencyid = intval($_GET['dependencyid']);
259-
$SubProject->AddDependency($dependencyid);
260-
return;
261-
}
262-
263214
if (isset($_GET['groupname'])) {
264215
// Change which group a subproject belongs to.
265216
$groupName = $_GET['groupname'];

phpstan-baseline.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14004,13 +14004,13 @@ parameters:
1400414004
-
1400514005
rawMessage: 'Parameter #1 $string of function htmlspecialchars expects string, mixed given.'
1400614006
identifier: argument.type
14007-
count: 3
14007+
count: 1
1400814008
path: app/cdash/public/api/v1/subproject.php
1400914009

1401014010
-
1401114011
rawMessage: 'Parameter #1 $value of function intval expects array|bool|float|GMP|int|resource|SimpleXMLElement|string|null, mixed given.'
1401214012
identifier: argument.type
14013-
count: 6
14013+
count: 4
1401414014
path: app/cdash/public/api/v1/subproject.php
1401514015

1401614016
-

resources/js/angular/controllers/manageSubProject.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,6 @@ export function ManageSubProjectController($scope, $http, apiLoader) {
4040
};
4141
};
4242

43-
$scope.createSubProject = function(newSubProject, groupName) {
44-
var parameters = {
45-
projectid: $scope.cdash.projectid,
46-
newsubproject: newSubProject,
47-
group: groupName
48-
};
49-
$http.post('api/v1/subproject.php', parameters)
50-
.then(function success(s) {
51-
var subproj = s.data;
52-
if (subproj.error) {
53-
$scope.cdash.error = subproj.error;
54-
}
55-
else {
56-
$("#subproject_created").show();
57-
$("#subproject_created").delay(3000).fadeOut(400);
58-
59-
// Add this new subproject to our scope.
60-
$scope.cdash.subprojects.push(subproj);
61-
}
62-
});
63-
};
64-
6543
$scope.createGroup = function(newGroup, threshold, isDefault) {
6644
var parameters = {
6745
projectid: $scope.cdash.projectid,

resources/js/angular/controllers/subproject.js

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -29,90 +29,6 @@ export function SubProjectController($scope, $rootScope, $http) {
2929
}
3030
};
3131

32-
$scope.deleteSubProject = function(id) {
33-
var parameters = {
34-
projectid: $scope.details.projectid,
35-
subprojectid: id
36-
};
37-
38-
$http({
39-
url: 'api/v1/subproject.php',
40-
method: 'DELETE',
41-
params: parameters
42-
}).then(function success() {
43-
// Find the index of the subproject to remove.
44-
var index = -1;
45-
for(var i = 0, len = $scope.cdash.subprojects.length; i < len; i++) {
46-
if ($scope.cdash.subprojects[i].id === id) {
47-
index = i;
48-
break;
49-
}
50-
}
51-
if (index > -1) {
52-
// Remove the subproject from our scope.
53-
$scope.cdash.subprojects.splice(index, 1);
54-
}
55-
});
56-
};
57-
58-
$scope.addDependency = function(dependency, subprojectId) {
59-
var parameters = {
60-
projectid: $scope.details.projectid,
61-
subprojectid: subprojectId,
62-
dependencyid: dependency.id
63-
};
64-
65-
$http({
66-
url: 'api/v1/subproject.php',
67-
method: 'PUT',
68-
params: parameters
69-
}).then(function success() {
70-
// Find the index of the dependency we just added.
71-
var index = -1;
72-
for(var i = 0, len = $scope.details.available_dependencies.length; i < len; i++) {
73-
if ($scope.details.available_dependencies[i].id === dependency.id) {
74-
index = i;
75-
break;
76-
}
77-
}
78-
if (index > -1) {
79-
// Remove this subproject from our list of available dependencies.
80-
var added = $scope.details.available_dependencies.splice(index, 1);
81-
// And add it to our list of dependencies.
82-
$scope.details.dependencies.push(added[0]);
83-
}
84-
});
85-
};
86-
87-
$scope.removeDependency = function(dependencyId, subprojectId) {
88-
var parameters = {
89-
projectid: $scope.details.projectid,
90-
subprojectid: subprojectId,
91-
dependencyid: dependencyId
92-
};
93-
94-
$http({
95-
url: 'api/v1/subproject.php',
96-
method: 'DELETE',
97-
params: parameters
98-
}).then(function success() {
99-
// Find the index of the dependency to remove.
100-
var index = -1;
101-
for(var i = 0, len = $scope.details.dependencies.length; i < len; i++) {
102-
if ($scope.details.dependencies[i].id === dependencyId) {
103-
index = i;
104-
break;
105-
}
106-
}
107-
if (index > -1) {
108-
// Remove this subproject from our list of dependencies.
109-
var removed = $scope.details.dependencies.splice(index, 1);
110-
// And add it to our list of potential dependencies.
111-
$scope.details.available_dependencies.push(removed[0]);
112-
}
113-
});
114-
};
115-
11632
$scope.changeGroup = function() {
11733
var parameters = {
11834
projectid: $scope.details.projectid,

resources/js/angular/views/manageSubProject.html

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<li role="presentation" class="active">
1717
<a class="cdash-link" href="#current" aria-controls="current" role="tab" data-toggle="tab">Current SubProjects</a>
1818
</li>
19-
<li role="presentation">
20-
<a class="cdash-link" href="#add" aria-controls="add" role="tab" data-toggle="tab">Add a SubProject</a>
21-
</li>
2219
<li role="presentation">
2320
<a class="cdash-link" href="#groups" aria-controls="groups" role="tab" data-toggle="tab" data-test="subproject-groups">SubProject Groups</a>
2421
</li>
@@ -49,9 +46,6 @@
4946
<div class="col-md-4">
5047
<!-- The subproject's name & an icon to fetch more info -->
5148
<span ng-click="loadData(subproject.id); showDetails = !showDetails" ng-class="showDetails ? 'glyphicon glyphicon-chevron-down' : 'glyphicon glyphicon-chevron-right'"></span> {{subproject.name}}
52-
53-
<!-- Link to delete this subproject -->
54-
<span ng-show="showDetails" ng-click="deleteSubProject(subproject.id)" class="glyphicon glyphicon-trash"></span>
5549
</div>
5650
</div>
5751

@@ -67,16 +61,6 @@
6761
<img id="group_changed_{{details.subprojectid}}" src="img/check.gif" style="display: none; height:16px; width:16px; margin-top:9px;" />
6862
</div>
6963
</div>
70-
71-
<!-- Form to add new dependencies to this subproject -->
72-
<div class="col-md-3 col-md-offset-5 form-group">
73-
<label for="dependency_selection_{{details.subprojectid}}">Add dependency: </label>
74-
<select class="dependency_selector form-control" name="dependency_selection_{{details.subprojectid}}" ng-model="dependencySelection" ng-options="avail as avail.name for avail in details.available_dependencies | orderBy:'name'">
75-
<option value="">Choose...</option>
76-
</select>
77-
<button class="btn btn-default" ng-click="addDependency(dependencySelection, details.subprojectid)" ng-disabled="! dependencySelection">Add</button>
78-
</div>
79-
8064
</div>
8165

8266
<!-- List the dependencies for this subproject -->
@@ -88,9 +72,7 @@
8872

8973
<div class="row repeat-item" ng-repeat="dep in details.dependencies | orderBy:'name'">
9074
<div class="col-md-5" data-cy="current-dependency">
91-
<!-- Remove a dependency from a subproject -->
9275
- {{dep.name}}
93-
<span ng-click="removeDependency(dep.id, details.subprojectid)" class="glyphicon glyphicon-trash"></span>
9476
</div>
9577
</div>
9678

@@ -102,24 +84,6 @@
10284
</div>
10385
</div> <!-- "current" pane -->
10486

105-
<div role="tabpanel" class="tab-pane container" id="add">
106-
<div class="col-md-9 text-center">
107-
<strong>Add a SubProject</strong>
108-
</div>
109-
<div class="col-md-9 form-horizontal">
110-
<label for="newsubproject">New SubProject</label>
111-
<input name="newsubproject" type="text" class="form-control" ng-model="newsubproject">
112-
<div ng-if="cdash.groups.length > 0">
113-
<label for="newGroupSelection">Group</label>
114-
<select name="newGroupSelection" ng-model="dd" ng-options="group as group.name for group in cdash.groups | orderBy:'name'" class="form-control">
115-
</select>
116-
</div>
117-
118-
<button class="btn btn-default" ng-click="createSubProject(newsubproject, dd.name)">Add SubProject</button>
119-
<img id="subproject_created" src="img/check.gif" style="display: none; height:16px; width:16px; margin-top:9px;" />
120-
</div>
121-
</div> <!-- "add" pane -->
122-
12387
<div role="tabpanel" class="tab-pane container" id="groups">
12488

12589
<!-- form to create a new group -->

tests/cypress/e2e/manage-sub-project.cy.js

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@ describe('manageSubProject', () => {
66
});
77

88

9-
it('can add a subproject', () => {
10-
cy.login();
11-
cy.visit('manageSubProject.php?projectid=8');
12-
13-
cy.get('a').contains('Add a SubProject').click();
14-
cy.get('input[name="newsubproject"]').type('aNewSubProject');
15-
cy.get('button').contains('Add SubProject').click();
16-
17-
cy.reload();
18-
cy.get('#current').should('contain', 'aNewSubProject');
19-
});
20-
21-
229
// TODO: (sbelsk) add test to check that no subprojects under the
2310
// same parent project can be created with duplicate names
2411

@@ -37,27 +24,6 @@ describe('manageSubProject', () => {
3724
});
3825

3926

40-
it('can add and remove a dependency', () => {
41-
cy.login();
42-
cy.visit('manageSubProject.php?projectid=8');
43-
44-
// get the first subproject & expand its details
45-
cy.get('[data-cy="subproject-item"]').first().as('subproject');
46-
cy.get('@subproject').find('span.glyphicon-chevron-right').click();
47-
48-
// select a new dependency and add it to our subproject
49-
cy.get('@subproject').find('select.dependency_selector').select('Aristos');
50-
cy.get('@subproject').find('button').contains('Add').click();
51-
52-
cy.get('@subproject').find('div[data-cy="current-dependency"]').contains('- Aristos').as('new_dependency');
53-
cy.get('@new_dependency').should('be.visible');
54-
55-
// find the trash icon and click it
56-
cy.get('@new_dependency').find('span.glyphicon-trash').click();
57-
cy.get('@subproject').find('div[data-cy="current-dependency"]').contains('- Aristos').should('not.exist');
58-
});
59-
60-
6127
it('can create subproject groups', () => {
6228
cy.login();
6329
cy.visit('manageSubProject.php?projectid=8');
@@ -168,25 +134,4 @@ describe('manageSubProject', () => {
168134
cy.get('a').contains('SubProject Groups').click();
169135
cy.get('table[data-cy="existing-subproject-groups"]').should('not.exist');
170136
});
171-
172-
173-
it('can delete a subproject', () => {
174-
cy.login();
175-
cy.visit('manageSubProject.php?projectid=8');
176-
177-
// select the subproject we added from the list & expand its details
178-
cy.get('[data-cy="subproject-item"]').contains('aNewSubProject').as('subproject');
179-
cy.get('@subproject').find('span.glyphicon-chevron-right').click();
180-
181-
// locate the deletion icon for this subproject & click it
182-
cy.get('@subproject').find('span.glyphicon-trash').click();
183-
184-
// make sure that 'aNewSubProject' doesn't appear on the page anymore
185-
cy.get('[data-cy="subproject-item"]').contains('aNewSubProject').should('not.exist');
186-
187-
// reload the page to make sure it's really gone from the database too
188-
cy.reload();
189-
cy.get('[data-cy="subproject-item"]').contains('aNewSubProject').should('not.exist');
190-
});
191-
192137
});

0 commit comments

Comments
 (0)