Add bulk delete to artifacts page (frontend)
What does this MR do and why?
For #33348 (closed)
- This page is behind the
artifacts_management_page
feature flag, and - The bulk delete functionality is behind the
ci_job_artifact_bulk_destroy
feature flag
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
git checkout 33348-artifacts-bulk-delete
echo "Feature.enable(:artifacts_management_page)" | bundle exec rails console
echo "Feature.enable(:ci_job_artifact_bulk_destroy)" | bundle exec rails console
- 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']
- navigate to the project, and in the sidebar select "CI/CD" => "Artifacts"
- click the checkboxes next to jobs and artifacts to select artifacts
- click the "Delete selected" button to open the confirmation modal
- click the "Delete N artifacts" button to confirm
- 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)
- 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
-
bundle exec rspec spec/frontend/fixtures/job_artifacts.rb
to generate the fixture 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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Miranda Fluharty