Skip to content

Add bulk delete to artifacts page (frontend)

Miranda Fluharty requested to merge 33348-artifacts-bulk-delete into master

What does this MR do and why?

For #33348 (closed)

🎏 Feature flags:

This MR adds the following elements to the artifacts page when the user has permission to delete artifacts and when the ci_job_artifact_bulk_destroy feature flag is enabled:

  • a new column to the artifacts table to hold checkboxes
  • a checkbox next to each job that selects all of that job's artifacts when clicked
  • a checkbox next to each artifact (shown when a job is expanded) that selects the artifact when clicked
  • a box at the top of the page with a count of selected artifacts and two buttons:
    • one that clears the selected artifacts
    • one that opens a delete confirmation modal
  • a confirmation modal shown when the delete button is clicked
    • canceling the modal should leave artifacts selected
    • confirming the modal should delete the selected artifacts

Screenshots or screen recordings

Screen_Recording_2023-03-09_at_23.34.10

How to set up and validate locally

  1. git checkout 33348-artifacts-bulk-delete
  2. echo "Feature.enable(:artifacts_management_page)" | bundle exec rails console
  3. echo "Feature.enable(:ci_job_artifact_bulk_destroy)" | bundle exec rails console
  4. find/make a project that generates artifacts
you can use this CI yaml to generate some sample artifacts to manage:
# .gitlab-ci.yml

potato:
  stage: build
  script:
    - echo 'potato' >> potato.txt
  artifacts:
    expose_as: 'potato'
    paths: ['potato.txt']

tomato:
  stage: build
  script:
    - echo 'tomato' >> tomato.txt
  artifacts:
    expose_as: 'tomato'
    paths: ['tomato.txt']

pineapple:
  stage: build
  script:
    - echo 'pineapple' >> pineapple.txt
  artifacts:
    expose_as: 'pineapple'
    paths: ['pineapple.txt']

apple:
  stage: build
  script:
    - echo 'apple' >> apple.txt
  artifacts:
    expose_as: 'apple'
    paths: ['apple.txt']

toblerone:
  stage: build
  script:
    - echo 'toblerone' >> toblerone.txt
  artifacts:
    expose_as: 'toblerone'
    paths: ['toblerone.txt']
  1. navigate to the project, and in the sidebar select "CI/CD" => "Artifacts"
  2. click the checkboxes next to jobs and artifacts to select artifacts
  3. click the "Delete selected" button to open the confirmation modal
  4. click the "Delete N artifacts" button to confirm
  5. if the request was successful, a toast should appear telling you how many artifacts were deleted, and the artifacts that you selected should be removed from the list (jobs with no artifacts will not disappear, but their checkboxes will be disabled)
  6. if the request fails, an alert should appear at the top of the page, and the artifacts that you selected should remain selected

to run tests

  1. bundle exec rspec spec/frontend/fixtures/job_artifacts.rb to generate the fixture
  2. yarn install && yarn jest spec/frontend/artifacts

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Miranda Fluharty

Merge request reports

Loading