Browse Source

feat(issue-priority): Add issue.priority as a supported search term in UI (#65192)

<img width="711" alt="image"
src="https://github.com/getsentry/sentry/assets/16563948/4679d96f-13d0-4509-a358-77f8a31abf16">

Backend changes  in https://github.com/getsentry/sentry/pull/65205

Fixes https://github.com/getsentry/sentry/issues/65097
Snigdha Sharma 1 year ago
parent
commit
66c2037ce7

+ 10 - 1
static/app/stores/tagStore.tsx

@@ -1,7 +1,7 @@
 import {createStore} from 'reflux';
 
 import type {Organization, Tag, TagCollection} from 'sentry/types';
-import {IssueCategory, IssueType} from 'sentry/types';
+import {IssueCategory, IssueType, PriorityLevel} from 'sentry/types';
 import {SEMVER_TAGS} from 'sentry/utils/discover/fields';
 import {FieldKey, ISSUE_FIELDS} from 'sentry/utils/fields';
 
@@ -155,6 +155,15 @@ const storeConfig: TagStoreDefinition = {
       },
     };
 
+    if (org.features.includes('issue-priority-ui')) {
+      tagCollection[FieldKey.ISSUE_PRIORITY] = {
+        key: FieldKey.ISSUE_PRIORITY,
+        name: 'Issue Priority',
+        values: [PriorityLevel.HIGH, PriorityLevel.MEDIUM, PriorityLevel.LOW],
+        predefined: true,
+      };
+    }
+
     // Ony include fields that that are part of the ISSUE_FIELDS. This is
     // because we may sometimes have fields that are turned off by removing
     // them from ISSUE_FIELDS

+ 8 - 0
static/app/utils/fields/index.ts

@@ -67,6 +67,7 @@ export enum FieldKey {
   IS = 'is',
   ISSUE = 'issue',
   ISSUE_CATEGORY = 'issue.category',
+  ISSUE_PRIORITY = 'issue.priority',
   ISSUE_TYPE = 'issue.type',
   LAST_SEEN = 'lastSeen',
   LEVEL = 'level',
@@ -750,6 +751,12 @@ const EVENT_FIELD_DEFINITIONS: Record<AllEventFieldKeys, FieldDefinition> = {
     valueType: FieldValueType.STRING,
     keywords: ['error', 'performance'],
   },
+  [FieldKey.ISSUE_PRIORITY]: {
+    desc: t('The priority of the issue'),
+    kind: FieldKind.FIELD,
+    valueType: FieldValueType.STRING,
+    keywords: ['high', 'medium', 'low'],
+  },
   [FieldKey.ISSUE_TYPE]: {
     desc: t('Type of problem the issue represents (i.e. N+1 Query)'),
     kind: FieldKind.FIELD,
@@ -1075,6 +1082,7 @@ export const ISSUE_FIELDS = [
   FieldKey.IS,
   FieldKey.ISSUE,
   FieldKey.ISSUE_CATEGORY,
+  FieldKey.ISSUE_PRIORITY,
   FieldKey.ISSUE_TYPE,
   FieldKey.LAST_SEEN,
   FieldKey.LOCATION,

+ 17 - 12
static/app/views/issueList/searchBar.tsx

@@ -14,6 +14,7 @@ import {SavedSearchType} from 'sentry/types';
 import {getUtcDateString} from 'sentry/utils/dates';
 import {
   DEVICE_CLASS_TAG_VALUES,
+  FieldKey,
   FieldKind,
   getFieldDefinition,
   isDeviceClass,
@@ -23,18 +24,22 @@ import usePageFilters from 'sentry/utils/usePageFilters';
 import type {WithIssueTagsProps} from 'sentry/utils/withIssueTags';
 import withIssueTags from 'sentry/utils/withIssueTags';
 
-const getSupportedTags = (supportedTags: TagCollection) =>
-  Object.fromEntries(
-    Object.keys(supportedTags).map(key => [
-      key,
-      {
-        ...supportedTags[key],
-        kind:
-          getFieldDefinition(key)?.kind ??
-          (supportedTags[key].predefined ? FieldKind.FIELD : FieldKind.TAG),
-      },
-    ])
+const getSupportedTags = (supportedTags: TagCollection, org: Organization) => {
+  const include_priority = org.features.includes('issue-priority-ui');
+  return Object.fromEntries(
+    Object.keys(supportedTags)
+      .map(key => [
+        key,
+        {
+          ...supportedTags[key],
+          kind:
+            getFieldDefinition(key)?.kind ??
+            (supportedTags[key].predefined ? FieldKind.FIELD : FieldKind.TAG),
+        },
+      ])
+      .filter(([key, _]) => (key === FieldKey.ISSUE_PRIORITY ? include_priority : true))
   );
+};
 
 interface Props extends React.ComponentProps<typeof SmartSearchBar>, WithIssueTagsProps {
   organization: Organization;
@@ -148,7 +153,7 @@ function IssueListSearchBar({organization, tags, ...props}: Props) {
       onGetTagValues={getTagValues}
       excludedTags={EXCLUDED_TAGS}
       maxMenuHeight={500}
-      supportedTags={getSupportedTags(tags)}
+      supportedTags={getSupportedTags(tags, organization)}
       defaultSearchGroup={recommendedGroup}
       organization={organization}
       {...props}