Skip to content

Add ability to search issues by crm contact

Lee Tickett requested to merge 2256-search-issues-by-crm-contact into master

What does this MR do and why?

Related to #225690

If you're new to customer relations/crm- take a quick glance at the docs for some background https://docs.gitlab.com/ee/user/crm/#customer-relations-management-crm

This MR adds crm contact filtering to the issue finder, in turn allowing querying by manipulating the querystring (e.g. we don't have a pretty UI/search filter bar widget thingy).

We also add a button to the crm contacts list to navigate directly to all group issues for that contact.

Screenshots or screen recordings

issue_search_by_crm_contact

How to set up and validate locally

From rails console:
1. Enable feature flag:
Feature.enable(:customer_relations)
From GraphiQL (http://gdk.test:3000/-/graphql-explorer):
2. Pick a an issue (I used http://gdk.test:3000/flightjs/Flight/-/issues/30)
3. Create a few contacts for the group the issue belongs to:
mutation {
  customerRelationsContactCreate(input:
    {
      groupId: "gid://gitlab/Group/26"
      firstName: "Lee"
      lastName: "Tickett"
      email: "example@gitlab.com"
    }) {
    contact {
      id
      firstName
      lastName
    }
    errors
  }
}
4. Attempt to add/remove those contacts from your issue (via graphql... or now via `/add_contacts` quick action):
mutation {
  issueSetCrmContacts(input:
    {
      projectPath: "flightjs/Flight"
      iid: "30"
      operationMode: REPLACE
	crmContactIds: [
        "gid://gitlab/CustomerRelations::Contact/14",
        "gid://gitlab/CustomerRelations::Contact/12"
      ]
    }) {
    issue {
     id
      customerRelationsContacts {
        nodes {
          id
          firstName
          lastName
        }
      }
    }
    errors
  }
}
5. Visit the group contacts list http://gdk.test:3000/groups/flightjs/-/crm/contacts
6. Click the issues button for a contact and ensure the correct issues are returned

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 Lee Tickett

Merge request reports