Skip to content

Improved CRM contacts autocomplete service to include state and set

What does this MR do and why?

Related to #375457 and #375467.

Currently, the contacts autocomplete endpoint returns all contacts (regardless of their state and ability to add/remove them). The data contains a limited field set that does not allow sufficient local filtering.

This MR adds the contact state and "whether it is already attached to the issue" to the results, allowing us to filter in the frontend. This will allow us to only show:

  • active contacts which aren't already attached (when using the add quick action)
  • currently attached contacts (when using the remove quick action)

Screenshots or screen recordings

Not really anything to show here, all changes are related to backend 🙂

How to set up and validate locally

  1. Enable CRM feature on a root group
  2. Make sure some CRM contacts are available otherwise create some
  3. Set some contacts as inactive (edit them and use the Active checkbox to change their state)
  4. Go to an issue
  5. Use the /add_contacts quick action to add one or more contacts to that issue
  6. Open another tab and use the autocomplete_sources endpoint to check the returned data.
    • The URL looks something like this: http://127.0.0.1:3000/<project_path>/-/autocomplete_sources/contacts?type=Issue&type_id=<issue_id> (e.g. http://127.0.0.1:3000/flightjs/Flight/-/autocomplete_sources/contacts?type=Issue&type_id=40)
    • Change project_path accordingly and type_id to the ID of the issue
  7. Make sure that the returned data includes the state field (also its value should reflect that active or inactive state of the contact) and the set field for the CRM contacts that have been added to the issue

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