Skip to content

Fetch custom roles only after invite member modal is opened

What does this MR do and why?

On the group members page, clicking on Invite members will open the invite members modal:

Group members page Invite members modal
ksnip_20231222-163512 ksnip_20231222-163520

A GraphQL query is run to get the custom roles for the group, so that they can be added to the Select a role dropdown. However, there's 2 issues:

  1. The query is run when the modal is initialized, not when it's shown.

  2. The modal is initialized on every group page.

The two issues combined together means that the GraphQL query is run on every group page, even when the modal is not visible or accessible in the first place:

ksnip_20231222-125553

This MR fixes the first issue so that the query runs only when the modal is visible, preventing it from running on every page. The second issue is much more complex to fix, and is not addressed in this MR.

How to set up and validate locally

  1. Go to a group -> Manage -> Members.
  2. Verify that the getProjectMemberRoles query is not run on page load.
  3. Click on Invite members.
  4. Verify that the query is run.
  5. Go to any other group page. Verify that the query is not run.

Related to #436437 (closed)

Merge request reports