diff --git a/app/cdash/public/api/v1/subproject.php b/app/cdash/public/api/v1/subproject.php index b81605d829..a6b10afa51 100644 --- a/app/cdash/public/api/v1/subproject.php +++ b/app/cdash/public/api/v1/subproject.php @@ -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(); @@ -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']; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2cc79a95ee..3db7406bdc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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 - diff --git a/resources/js/angular/controllers/manageSubProject.js b/resources/js/angular/controllers/manageSubProject.js index 762162e15a..a9d1c31ec1 100644 --- a/resources/js/angular/controllers/manageSubProject.js +++ b/resources/js/angular/controllers/manageSubProject.js @@ -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, diff --git a/resources/js/angular/controllers/subproject.js b/resources/js/angular/controllers/subproject.js index ab0816003f..e5d8d238e7 100644 --- a/resources/js/angular/controllers/subproject.js +++ b/resources/js/angular/controllers/subproject.js @@ -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, diff --git a/resources/js/angular/views/manageSubProject.html b/resources/js/angular/views/manageSubProject.html index 9875e5583e..a248e7c2de 100644 --- a/resources/js/angular/views/manageSubProject.html +++ b/resources/js/angular/views/manageSubProject.html @@ -16,9 +16,6 @@ -
  • - Add a SubProject -
  • SubProject Groups
  • @@ -49,9 +46,6 @@
    {{subproject.name}} - - -
    @@ -67,16 +61,6 @@ - - -
    - - - -
    - @@ -88,9 +72,7 @@
    - - {{dep.name}} -
    @@ -102,24 +84,6 @@ -
    -
    - Add a SubProject -
    -
    - - -
    - - -
    - - - -
    -
    -
    diff --git a/tests/cypress/e2e/manage-sub-project.cy.js b/tests/cypress/e2e/manage-sub-project.cy.js index ecdbad855b..797b2a25e1 100644 --- a/tests/cypress/e2e/manage-sub-project.cy.js +++ b/tests/cypress/e2e/manage-sub-project.cy.js @@ -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 @@ -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'); @@ -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'); - }); - });