diff --git a/src/sentry_plugins/clubhouse/plugin.py b/src/sentry_plugins/clubhouse/plugin.py index 16be2979..f6d1706e 100644 --- a/src/sentry_plugins/clubhouse/plugin.py +++ b/src/sentry_plugins/clubhouse/plugin.py @@ -55,6 +55,13 @@ def get_configure_plugin_fields(self, request, project, **kwargs): 'type': 'text', 'placeholder': 'e.g. 639281', 'help': 'Enter your project\'s numerical ID.' + }, + { + 'name': 'global_search', + 'label': 'Global Search', + 'type': 'bool', + 'required': False, + 'help': 'When linking Sentry issues, search across all Clubhouse projects.' } ] @@ -128,6 +135,7 @@ def view_autocomplete(self, request, group, **kwargs): if field != 'issue_id' or not query: return Response({'issue_id': []}) + search_globally = self.get_option('global_search', group.project) project = self.get_option('project', group.project) client = self.get_client(group.project) @@ -135,9 +143,11 @@ def view_autocomplete(self, request, group, **kwargs): # TODO: Something about the search API won't allow an explicit number search. # Should it switch the search mechanism from search_stories(text) to get_story(id)? try: - response = client.search_stories( - query=(u'project:%s %s' % (project, query)).encode('utf-8'), - ) + if not search_globally: + # Modify the query string to include the project scope + query = u'project:%s %s' % (project, query) + + response = client.search_stories(query=query.encode('utf-8')) except Exception as e: return self.handle_api_error(e)