Make the job-level delete button on the artifacts management page work

What does this MR do and why?

For #33348 (closed)

🎏 This feature is behind the artifacts_management_page and ci_job_artifact_bulk_destroy feature flags.

When the artifacts management page was built, the Delete button next to the job was disabled because we the delete mutation could only delete one artifact at a time. The user would have to expand the job row and click the Delete button for each artifact. Now that we have a mutation that deletes more than one artifact at a time, and we're using it for the bulk delete functionality, we can also enable the job-level button and use the mutation to delete all the artifacts for a job when it is clicked.

The first commit is mainly refactoring: moving the multi-artifact delete modal to its own component and moving the multi-artifact delete mutation to the job_artifacts_table component so we can use these bits for both of the delete methods (via job-level delete button and via checkbox selection). The second commit contains the "real" changes: wiring up the job-level delete button to trigger the modal on that job's artifacts while avoiding interfering with the existing checkbox selection system (and adding tests for what it should do).

Screenshots or screen recordings

before after
delete buttons for jobs are disabled 🚫 the user has to expand the job and delete the artifacts one by one the delete button for a job deletes that job's artifacts 🗑
Screenshot_2023-04-11_at_23.40.35 Screen_Recording_2023-04-11_at_23.51.44

How to set up and validate locally

  1. echo "Feature.enable(:artifacts_management_page)" | bundle exec rails console to show the artifacts page (and the link to it in the sidebar)
  2. echo "Feature.enable(:ci_job_artifact_bulk_destroy)" | bundle exec rails console to enable more than one artifact to be deleted at once
  3. git checkout make-job-level-delete-button-work-on-artifacts-page
  4. find/make/import a project with a pipeline with a job that generates artifacts
you can use this CI yaml to generate some sample artifacts:
# .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. run a pipeline for that project - for this you'll need to set up a local runner for GDK or enable runners in gitpod
  2. navigate to the project, and in the sidebar select CI/CD => Artifacts
  3. click the delete button next to a job - a modal should appear to confirm that you want to delete N artifacts (as many as the job has)
  4. click the confirm button in the modal - a toast should appear to tell you that the artifacts were successfully deleted
  5. this should not interfere with the process of selecting and deleting artifacts via the checkboxes and the box at the top of the page

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