Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions app/cdash/public/api/v1/subproject.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,53 +142,11 @@ function rest_delete(): void
$Group->Delete();
return;
}

$subprojectid = get_subprojectid();
if ($subprojectid === false) {
return;
}

if (isset($_GET['dependencyid'])) {
// Remove dependency from subproject.
$SubProject = new SubProject();
$SubProject->SetId($subprojectid);
$SubProject->RemoveDependency(intval($_GET['dependencyid']));
} else {
// Delete subproject.
$SubProject = new SubProject();
$SubProject->SetId($subprojectid);
$SubProject->Delete();
}
}

/** Handle POST requests */
function rest_post($projectid): void
{
if (isset($_POST['newsubproject'])) {
// Create a new subproject
$SubProject = new SubProject();
$SubProject->SetProjectId($projectid);

$newSubProject =
htmlspecialchars($_POST['newsubproject']);
$SubProject->SetName($newSubProject);

if (isset($_POST['group'])) {
$SubProject->SetGroup(
htmlspecialchars($_POST['group']));
}

$SubProject->Save();

// Respond with a JSON representation of this new subproject
$response = [];
$response['id'] = $SubProject->GetId();
$response['name'] = $SubProject->GetName();
$response['group'] = $SubProject->GetGroupId();
echo json_encode(cast_data_for_JSON($response));
return;
}

if (isset($_POST['newgroup'])) {
// Create a new group
$Group = new SubProjectGroup();
Expand Down Expand Up @@ -253,13 +211,6 @@ function rest_put($projectid): void
$SubProject = new SubProject();
$SubProject->SetId($subprojectid);

if (isset($_GET['dependencyid'])) {
// Add dependency to existing subproject.
$dependencyid = intval($_GET['dependencyid']);
$SubProject->AddDependency($dependencyid);
return;
}

if (isset($_GET['groupname'])) {
// Change which group a subproject belongs to.
$groupName = $_GET['groupname'];
Expand Down
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14100,13 +14100,13 @@ parameters:
-
rawMessage: 'Parameter #1 $string of function htmlspecialchars expects string, mixed given.'
identifier: argument.type
count: 3
count: 1
path: app/cdash/public/api/v1/subproject.php

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

-
Expand Down
22 changes: 0 additions & 22 deletions resources/js/angular/controllers/manageSubProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,6 @@ export function ManageSubProjectController($scope, $http, apiLoader) {
};
};

$scope.createSubProject = function(newSubProject, groupName) {
var parameters = {
projectid: $scope.cdash.projectid,
newsubproject: newSubProject,
group: groupName
};
$http.post('api/v1/subproject.php', parameters)
.then(function success(s) {
var subproj = s.data;
if (subproj.error) {
$scope.cdash.error = subproj.error;
}
else {
$("#subproject_created").show();
$("#subproject_created").delay(3000).fadeOut(400);

// Add this new subproject to our scope.
$scope.cdash.subprojects.push(subproj);
}
});
};

$scope.createGroup = function(newGroup, threshold, isDefault) {
var parameters = {
projectid: $scope.cdash.projectid,
Expand Down
84 changes: 0 additions & 84 deletions resources/js/angular/controllers/subproject.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,90 +29,6 @@ export function SubProjectController($scope, $rootScope, $http) {
}
};

$scope.deleteSubProject = function(id) {
var parameters = {
projectid: $scope.details.projectid,
subprojectid: id
};

$http({
url: 'api/v1/subproject.php',
method: 'DELETE',
params: parameters
}).then(function success() {
// Find the index of the subproject to remove.
var index = -1;
for(var i = 0, len = $scope.cdash.subprojects.length; i < len; i++) {
if ($scope.cdash.subprojects[i].id === id) {
index = i;
break;
}
}
if (index > -1) {
// Remove the subproject from our scope.
$scope.cdash.subprojects.splice(index, 1);
}
});
};

$scope.addDependency = function(dependency, subprojectId) {
var parameters = {
projectid: $scope.details.projectid,
subprojectid: subprojectId,
dependencyid: dependency.id
};

$http({
url: 'api/v1/subproject.php',
method: 'PUT',
params: parameters
}).then(function success() {
// Find the index of the dependency we just added.
var index = -1;
for(var i = 0, len = $scope.details.available_dependencies.length; i < len; i++) {
if ($scope.details.available_dependencies[i].id === dependency.id) {
index = i;
break;
}
}
if (index > -1) {
// Remove this subproject from our list of available dependencies.
var added = $scope.details.available_dependencies.splice(index, 1);
// And add it to our list of dependencies.
$scope.details.dependencies.push(added[0]);
}
});
};

$scope.removeDependency = function(dependencyId, subprojectId) {
var parameters = {
projectid: $scope.details.projectid,
subprojectid: subprojectId,
dependencyid: dependencyId
};

$http({
url: 'api/v1/subproject.php',
method: 'DELETE',
params: parameters
}).then(function success() {
// Find the index of the dependency to remove.
var index = -1;
for(var i = 0, len = $scope.details.dependencies.length; i < len; i++) {
if ($scope.details.dependencies[i].id === dependencyId) {
index = i;
break;
}
}
if (index > -1) {
// Remove this subproject from our list of dependencies.
var removed = $scope.details.dependencies.splice(index, 1);
// And add it to our list of potential dependencies.
$scope.details.available_dependencies.push(removed[0]);
}
});
};

$scope.changeGroup = function() {
var parameters = {
projectid: $scope.details.projectid,
Expand Down
36 changes: 0 additions & 36 deletions resources/js/angular/views/manageSubProject.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<li role="presentation" class="active">
<a class="cdash-link" href="#current" aria-controls="current" role="tab" data-toggle="tab">Current SubProjects</a>
</li>
<li role="presentation">
<a class="cdash-link" href="#add" aria-controls="add" role="tab" data-toggle="tab">Add a SubProject</a>
</li>
<li role="presentation">
<a class="cdash-link" href="#groups" aria-controls="groups" role="tab" data-toggle="tab" data-test="subproject-groups">SubProject Groups</a>
</li>
Expand Down Expand Up @@ -49,9 +46,6 @@
<div class="col-md-4">
<!-- The subproject's name & an icon to fetch more info -->
<span ng-click="loadData(subproject.id); showDetails = !showDetails" ng-class="showDetails ? 'glyphicon glyphicon-chevron-down' : 'glyphicon glyphicon-chevron-right'"></span> {{subproject.name}}

<!-- Link to delete this subproject -->
<span ng-show="showDetails" ng-click="deleteSubProject(subproject.id)" class="glyphicon glyphicon-trash"></span>
</div>
</div>

Expand All @@ -67,16 +61,6 @@
<img id="group_changed_{{details.subprojectid}}" src="img/check.gif" style="display: none; height:16px; width:16px; margin-top:9px;" />
</div>
</div>

<!-- Form to add new dependencies to this subproject -->
<div class="col-md-3 col-md-offset-5 form-group">
<label for="dependency_selection_{{details.subprojectid}}">Add dependency: </label>
<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'">
<option value="">Choose...</option>
</select>
<button class="btn btn-default" ng-click="addDependency(dependencySelection, details.subprojectid)" ng-disabled="! dependencySelection">Add</button>
</div>

</div>

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

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

Expand All @@ -102,24 +84,6 @@
</div>
</div> <!-- "current" pane -->

<div role="tabpanel" class="tab-pane container" id="add">
<div class="col-md-9 text-center">
<strong>Add a SubProject</strong>
</div>
<div class="col-md-9 form-horizontal">
<label for="newsubproject">New SubProject</label>
<input name="newsubproject" type="text" class="form-control" ng-model="newsubproject">
<div ng-if="cdash.groups.length > 0">
<label for="newGroupSelection">Group</label>
<select name="newGroupSelection" ng-model="dd" ng-options="group as group.name for group in cdash.groups | orderBy:'name'" class="form-control">
</select>
</div>

<button class="btn btn-default" ng-click="createSubProject(newsubproject, dd.name)">Add SubProject</button>
<img id="subproject_created" src="img/check.gif" style="display: none; height:16px; width:16px; margin-top:9px;" />
</div>
</div> <!-- "add" pane -->

<div role="tabpanel" class="tab-pane container" id="groups">

<!-- form to create a new group -->
Expand Down
55 changes: 0 additions & 55 deletions tests/cypress/e2e/manage-sub-project.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ describe('manageSubProject', () => {
});


it('can add a subproject', () => {
cy.login();
cy.visit('manageSubProject.php?projectid=8');

cy.get('a').contains('Add a SubProject').click();
cy.get('input[name="newsubproject"]').type('aNewSubProject');
cy.get('button').contains('Add SubProject').click();

cy.reload();
cy.get('#current').should('contain', 'aNewSubProject');
});


// TODO: (sbelsk) add test to check that no subprojects under the
// same parent project can be created with duplicate names

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


it('can add and remove a dependency', () => {
cy.login();
cy.visit('manageSubProject.php?projectid=8');

// get the first subproject & expand its details
cy.get('[data-cy="subproject-item"]').first().as('subproject');
cy.get('@subproject').find('span.glyphicon-chevron-right').click();

// select a new dependency and add it to our subproject
cy.get('@subproject').find('select.dependency_selector').select('Aristos');
cy.get('@subproject').find('button').contains('Add').click();

cy.get('@subproject').find('div[data-cy="current-dependency"]').contains('- Aristos').as('new_dependency');
cy.get('@new_dependency').should('be.visible');

// find the trash icon and click it
cy.get('@new_dependency').find('span.glyphicon-trash').click();
cy.get('@subproject').find('div[data-cy="current-dependency"]').contains('- Aristos').should('not.exist');
});


it('can create subproject groups', () => {
cy.login();
cy.visit('manageSubProject.php?projectid=8');
Expand Down Expand Up @@ -168,25 +134,4 @@ describe('manageSubProject', () => {
cy.get('a').contains('SubProject Groups').click();
cy.get('table[data-cy="existing-subproject-groups"]').should('not.exist');
});


it('can delete a subproject', () => {
cy.login();
cy.visit('manageSubProject.php?projectid=8');

// select the subproject we added from the list & expand its details
cy.get('[data-cy="subproject-item"]').contains('aNewSubProject').as('subproject');
cy.get('@subproject').find('span.glyphicon-chevron-right').click();

// locate the deletion icon for this subproject & click it
cy.get('@subproject').find('span.glyphicon-trash').click();

// make sure that 'aNewSubProject' doesn't appear on the page anymore
cy.get('[data-cy="subproject-item"]').contains('aNewSubProject').should('not.exist');

// reload the page to make sure it's really gone from the database too
cy.reload();
cy.get('[data-cy="subproject-item"]').contains('aNewSubProject').should('not.exist');
});

});