Use the GraphQL pipelines list on the new merge request page

What does this MR do and why?

This MR moves the Pipelines tab of the new merge request page to GraphQL. It is the first of three MRs that remove the mr_pipelines_graphql feature flag.

Only Projects::MergeRequestsController pushes the flag. The new merge request page uses Projects::MergeRequests::CreationsController, so it never got the flag and always used the legacy REST table. The GraphQL merge request wrapper, pipelines_table_wrapper.vue, cannot replace that table here, because there is no merge request to query yet.

The page now renders commit_pipelines_list.vue for the source branch head commit. This is the same GraphQL list as the commit Pipelines tab. The page already has the data it needs, data-project-full-path and data-commit-sha on #commit-pipeline-table-view, so the MR has no controller change. mountPipelines picks the list with MergeRequestTabs#isNewMergeRequest, the flag that the class already uses for the new merge request page.

After this MR, the flag is the only way to reach the REST table. The next MR removes the flag, and with it the last REST consumer.

Behaviour change

The REST action listed the branch pipelines of every commit in the new merge request. The page now lists the pipelines of the head commit only.

The list reports its count with the update-pipelines-count event. The listener, initPipelineCountListener, updates the .js-pipelines-mr-count badge, and the new merge request page had no such badge. Without one, the listener throws Cannot set properties of null (setting 'textContent'). The badge on this page now has the class, so it shows the same count as the list.

Mounting

Both Pipelines tab apps, on the new and on the existing merge request page, now mount with initVueApp and tear down with unmountVueApp:

  • initVueApp replaces its element, so each app mounts on a child of #commit-pipeline-table-view. The count listener stays on that element.
  • unmountVueApp also works on Vue 3. There, $destroy() does nothing on an app root.
  • The existing merge request page keeps its lazy load, through defineAsyncComponent.

Screenshots or screen recordings

Each scenario has two branch pipelines. The source branch fix has two commits that are not on master. In each scenario, the spec opens the Pipelines tab, switches to Commits, and opens Pipelines again, so the screenshot shows the app after a remount.

Scenario Before (b52bae9d) After (a47d5533)
New merge request, both pipelines on the head commit 2 rows, Pipelines 2 2 rows, Pipelines 2
New merge request, one pipeline on the head commit and one on the older commit 2 rows, Pipelines 2 1 row, Pipelines 1
Existing merge request, both pipelines on the head commit 2 rows, Pipelines 2 2 rows, Pipelines 2

The other tabs are the same in every case: Commits 2 and Changes 2, plus Overview and Reports on the existing merge request.

New merge request, both pipelines on the head commit

Before (b52bae9d) After (a47d5533)
before_new_mr_head_head_light after_new_mr_head_head_light
before_new_mr_head_head_dark after_new_mr_head_head_dark

New merge request, pipelines on the head commit and the older commit

Before (b52bae9d) After (a47d5533)
before_new_mr_head_older_light after_new_mr_head_older_light
before_new_mr_head_older_dark after_new_mr_head_older_dark

Existing merge request, both pipelines on the head commit

Before (b52bae9d) After (a47d5533)
before_existing_mr_light after_existing_mr_light
before_existing_mr_dark after_existing_mr_dark
How the screenshots were taken
  • Ran a temporary local feature spec in GDK. The spec was not committed.
  • Before: merge base b52bae9d. After: MR head a47d5533.
  • User path for a new merge request:
    1. Go to Code > Merge requests > New merge request, with fix as the source branch and master as the target branch.
    2. Select Pipelines, then Commits, then Pipelines again.
  • User path for an existing merge request: open the merge request from fix into master, then select Pipelines, Commits and Pipelines again.
  • The spec printed the number of table rows, the number of tables and every tab label for each scenario. The tables above use those values.
  • Full page, light and dark mode.

How to set up and validate locally

  1. Push a branch with two commits that are not on the default branch, and a pipeline on each commit.
  2. Start a new merge request from that branch.
  3. Select the Pipelines tab. The table lists the pipeline of the head commit, and the tab badge shows 1.
  4. Select Commits, then Pipelines again. The table renders once.
  5. Create the merge request, and open its Pipelines tab. The table renders as before.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Local verification
  • spec/frontend/merge_request_tabs_spec.js passes in the Vue 2 lane and with VUE_VERSION=3. Its destroyPipelines examples now check that the tab calls unmountVueApp.
  • These feature specs pass locally in GDK:
    • user_selects_branches_for_new_mr_spec.rb:158. It now has pipelines on two commits, and checks that only the head pipeline is listed and that the badge reads Pipelines 1. Without the badge class, it fails on the console error above.
    • user_creates_mr_spec.rb:118, the limited count on the tab badge.
    • user_creates_mr_spec.rb:125, which switches to the Pipelines tab.
    • user_sees_merge_request_pipelines_spec.rb, 16 examples, with the flag on and off.
    • user_sees_pipelines_from_forked_project_spec.rb, with the flag on and off. With the flag off, this is the legacy table through defineAsyncComponent.

References

Edited by Miguel Rincon

Merge request reports

Loading
Loading