Skip to content

Add feature flag for global snippet search

What does this MR do and why?

Adds a feature flag for global snippet searches. The flag is enabled by default so that self-managed can continue as usual. On Gitlab.com, we will disable the feature flag.

API

  • Feature flag is enabled: Global level Snippet searches are available.
  • Feature flag is disabled: Global level Snippet searches are not available, and give a 403 response with 403 Forbidden - Global Search is disabled for this scope

UI

To get to global snippet search: go to /dashboard/snippets, click on the search bar, enter a term and press enter.

  • Feature flag enabled: Snippet tab and search is available
  • Feature flag disabled: Redirects to /search with an alert

FYI: snippet search UI is broken: the counts for all scopes are set to the snippet count and if you click on another scope, it remains on snippets:

Screen_Recording_2023-06-15_at_14.48.05

How to set up and validate locally

  1. Enable the feature flag: Feature.enable(:global_search_snippet_titles_tab)
  2. Make an API call with the scope snippet_titles without a group/project: E.g. http://127.0.0.1:3000/api/v4/search?scope=snippet_titles&search=test
    1. The request should succeed
  3. Disable the feature flag: Feature.disable(:global_search_snippet_titles_tab)
  4. Make an API call with the scope snippet_titles without a group/project: E.g. http://127.0.0.1:3000/api/v4/search?scope=snippet_titles&search=test
    1. The request should fail with an error "403 Forbidden - Global Search is disabled for this scope"

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 #415251 (closed)

Edited by Madelein van Niekerk

Merge request reports

Loading