Browse Source

ref(metrics): Remove 'search-query-builder-metrics' flag (#78329)

Priscila Oliveira 5 months ago
parent
commit
6842146e0b

+ 3 - 61
static/app/components/metrics/metricSearchBar.spec.tsx

@@ -14,11 +14,6 @@ describe('metricSearchBar', function () {
       url: '/organizations/org-slug/metrics/tags/',
       body: [],
     });
-    MockApiClient.addMockResponse({
-      method: 'POST',
-      url: '/organizations/org-slug/recent-searches/',
-      body: [],
-    });
     MockApiClient.addMockResponse({
       method: 'GET',
       url: '/organizations/org-slug/recent-searches/',
@@ -36,57 +31,10 @@ describe('metricSearchBar', function () {
     });
   });
 
-  describe('using SmartSearchBar', function () {
-    it('does not allow illegal filters', async function () {
-      render(
-        <MetricSearchBar onChange={onChange} mri="d:transactions/duration@millisecond" />
-      );
-      await screen.findByPlaceholderText('Filter by tags');
-      await userEvent.type(screen.getByPlaceholderText('Filter by tags'), 'potato:db');
-      expect(screen.getByTestId('search-autocomplete-item')).toHaveTextContent(
-        "The field potato isn't supported here."
-      );
-      await userEvent.keyboard('{enter}');
-      expect(onChange).not.toHaveBeenCalled();
-    });
-    it('does not allow insights filters when not using an insights mri', async function () {
-      render(
-        <MetricSearchBar onChange={onChange} mri="d:transactions/duration@millisecond" />
-      );
-      await screen.findByPlaceholderText('Filter by tags');
-      await userEvent.type(
-        screen.getByPlaceholderText('Filter by tags'),
-        'span.module:db'
-      );
-      expect(screen.getByTestId('search-autocomplete-item')).toHaveTextContent(
-        "The field span.module isn't supported here."
-      );
-      await userEvent.keyboard('{enter}');
-      expect(onChange).not.toHaveBeenCalled();
-    });
-    it('allows insights specific filters when using an insights mri', async function () {
-      render(
-        <MetricSearchBar onChange={onChange} mri="d:spans/exclusive_time@millisecond" />
-      );
-      await screen.findByPlaceholderText('Filter by tags');
-      await userEvent.type(
-        screen.getByPlaceholderText('Filter by tags'),
-        'span.module:db'
-      );
-      expect(screen.queryByTestId('search-autocomplete-item')).not.toBeInTheDocument();
-      await userEvent.keyboard('{enter}');
-      expect(onChange).toHaveBeenCalledWith('span.module:"db"');
-    });
-  });
-
   describe('using SearchQueryBuilder', function () {
-    const organization = {features: ['search-query-builder-metrics']};
     it('does not allow illegal filters', async function () {
       render(
-        <MetricSearchBar onChange={onChange} mri="d:transactions/duration@millisecond" />,
-        {
-          organization,
-        }
+        <MetricSearchBar onChange={onChange} mri="d:transactions/duration@millisecond" />
       );
       await screen.findByPlaceholderText('Filter by tags');
       await userEvent.type(screen.getByPlaceholderText('Filter by tags'), 'potato:db');
@@ -96,10 +44,7 @@ describe('metricSearchBar', function () {
     });
     it('does not allow insights filters when not using an insights mri', async function () {
       render(
-        <MetricSearchBar onChange={onChange} mri="d:transactions/duration@millisecond" />,
-        {
-          organization,
-        }
+        <MetricSearchBar onChange={onChange} mri="d:transactions/duration@millisecond" />
       );
       await screen.findByPlaceholderText('Filter by tags');
       await userEvent.type(
@@ -112,10 +57,7 @@ describe('metricSearchBar', function () {
     });
     it('allows insights specific filters when using an insights mri', async function () {
       render(
-        <MetricSearchBar onChange={onChange} mri="d:spans/exclusive_time@millisecond" />,
-        {
-          organization,
-        }
+        <MetricSearchBar onChange={onChange} mri="d:spans/exclusive_time@millisecond" />
       );
       await screen.findByPlaceholderText('Filter by tags');
       await userEvent.type(

+ 3 - 36
static/app/components/metrics/metricSearchBar.tsx

@@ -1,6 +1,5 @@
 import {useCallback, useMemo} from 'react';
 import {css, type SerializedStyles} from '@emotion/react';
-import {useId} from '@react-aria/utils';
 
 import {QueryFieldGroup} from 'sentry/components/metrics/queryFieldGroup';
 import {
@@ -8,14 +7,10 @@ import {
   type SearchQueryBuilderProps,
 } from 'sentry/components/searchQueryBuilder';
 import type {SmartSearchBarProps} from 'sentry/components/smartSearchBar';
-import SmartSearchBar from 'sentry/components/smartSearchBar';
 import {t} from 'sentry/locale';
 import {SavedSearchType, type TagCollection} from 'sentry/types/group';
 import type {MRI} from 'sentry/types/metrics';
-import {
-  hasMetricsNewInputs,
-  hasMetricsNewSearchQueryBuilder,
-} from 'sentry/utils/metrics/features';
+import {hasMetricsNewInputs} from 'sentry/utils/metrics/features';
 import {getUseCaseFromMRI} from 'sentry/utils/metrics/mri';
 import type {MetricTag} from 'sentry/utils/metrics/types';
 import {useMetricsTags} from 'sentry/utils/metrics/useMetricsTags';
@@ -64,14 +59,12 @@ export function MetricSearchBar({
   onChange,
   query,
   projectIds,
-  id: idProp,
   ...props
 }: MetricSearchBarProps) {
   const organization = useOrganization();
   const api = useApi();
   const {selection} = usePageFilters();
   const selectedProjects = useSelectedProjects();
-  const id = useId(idProp);
   const projectIdNumbers = useMemo(
     () => projectIds?.map(projectId => parseInt(projectId, 10)),
     [projectIds]
@@ -172,37 +165,11 @@ export function MetricSearchBar({
     css: wideSearchBarCss(disabled),
   };
 
-  const smartSearchProps: Partial<SmartSearchBarProps> & {css: SerializedStyles} = {
-    id,
-    disabled,
-    maxMenuHeight: 220,
-    organization,
-    onGetTagValues: getTagValues,
-    // don't highlight tags while loading as we don't know yet if they are supported
-    highlightUnsupportedTags: !isPending,
-    onClose: handleChange,
-    onSearch: handleChange,
-    placeholder: t('Filter by tags'),
-    query,
-    savedSearchType: SavedSearchType.METRIC,
-    css: wideSearchBarCss(disabled),
-    ...props,
-    ...searchConfig,
-  };
-
   if (hasMetricsNewInputs(organization)) {
-    if (hasMetricsNewSearchQueryBuilder(organization)) {
-      return <QueryFieldGroup.SearchQueryBuilder {...searchQueryBuilderProps} />;
-    }
-
-    return <QueryFieldGroup.SmartSearchBar {...smartSearchProps} />;
-  }
-
-  if (hasMetricsNewSearchQueryBuilder(organization)) {
-    return <SearchQueryBuilder {...searchQueryBuilderProps} />;
+    return <QueryFieldGroup.SearchQueryBuilder {...searchQueryBuilderProps} />;
   }
 
-  return <SmartSearchBar {...smartSearchProps} />;
+  return <SearchQueryBuilder {...searchQueryBuilderProps} />;
 }
 
 function wideSearchBarCss(disabled?: boolean) {

+ 0 - 4
static/app/utils/metrics/features.tsx

@@ -18,10 +18,6 @@ export function hasMetricsNewInputs(organization: Organization) {
   return organization.features.includes('metrics-new-inputs');
 }
 
-export function hasMetricsNewSearchQueryBuilder(organization: Organization) {
-  return organization.features.includes('search-query-builder-metrics');
-}
-
 /**
  * Returns the forceMetricsLayer query param for the alert
  * wrapped in an object so it can be spread into existing query params

+ 5 - 0
static/app/views/alerts/rules/metric/ruleForm.spec.tsx

@@ -100,6 +100,11 @@ describe('Incident Rules Form', () => {
       url: '/organizations/org-slug/metrics/tags/',
       body: [],
     });
+    MockApiClient.addMockResponse({
+      method: 'GET',
+      url: '/organizations/org-slug/recent-searches/',
+      body: [],
+    });
   });
 
   afterEach(() => {

+ 6 - 0
static/app/views/metrics/queries.spec.tsx

@@ -63,6 +63,12 @@ function renderMockRequests({orgSlug, projectId}: {orgSlug: string; projectId: s
     method: 'GET',
     body: [],
   });
+
+  MockApiClient.addMockResponse({
+    method: 'GET',
+    url: `/organizations/${orgSlug}/recent-searches/`,
+    body: [],
+  });
 }
 
 describe('Queries', function () {