Skip to content

Add endpoint for contacts autocomplete

Jarka Košanová requested to merge 350133-contact-autocomplete into master

What does this MR do and why?

It adds contacts as autocomplete source:

  • adds a new route
  • adds an endpoint to the controller + a new method to the AutocompleteService
  • adds new finder for contacts

An existing feature flag is used here, this is not a user facing change. Using the endpoint should probably be under a new feature flag.

How to set up and validate locally

  1. Enable the feature flag
    Feature.enable(:customer_relations)
  2. Visit any group general settings http://127.0.0.1:3000/groups/flightjs/-/edit
  3. Enable the custom relations in Permissions & group features (last item in the section)
  4. Check if you have any existing contacts (http://127.0.0.1:3000/groups/flightjs/-/crm/contacts)
  5. Visit the contacts autocomplete endpoint (project) http://127.0.0.1:3000/flightjs/Flight/-/autocomplete_sources/contacts
  6. You should see a json with contacts (id-email pair)

You can play around and verify that eg.

  • contacts are not returned if a user is not a member of a root group but is a member of a subgroup
  • contacts of a group with the feature disabled are not returned
  • 404 is returned when user does not have permissions to see the contacts (at least reporters can see the contacts)

Database

ContactsFinder queries

Query plans based on group https://gitlab.com/gitlab-org/protect/demos/sandbox (id: 14491403) in order to have some hierarchy to search

Getting group root ancestor

Checking permissions

Getting contacts

  • we don't have any data

group.contacts

SELECT "customer_relations_contacts".* FROM "customer_relations_contacts" 
  WHERE "customer_relations_contacts"."group_id" = 14491403

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #350133 (closed)

Edited by Jarka Košanová

Merge request reports

Loading