Browse Source

feat(sort): Add better priority sort to saved search and dashboards (#50379)

Add better priority to the dashboards and saved search features.

<img width="784" alt="Screenshot 2023-06-05 at 5 07 05 PM"
src="https://github.com/getsentry/sentry/assets/29959063/3a3add67-911d-44ed-9de0-ebf2af710a54">
<img width="622" alt="Screenshot 2023-06-05 at 5 19 09 PM"
src="https://github.com/getsentry/sentry/assets/29959063/7bbe54f2-5da1-4962-acee-194ada971be8">
Colleen O'Rourke 1 year ago
parent
commit
4e15eceb19

+ 16 - 3
static/app/components/modals/savedSearchModal/createSavedSearchModal.tsx

@@ -26,8 +26,21 @@ const DEFAULT_SORT_OPTIONS = [
   IssueSortOptions.USER,
 ];
 
-function validateSortOption({sort}: {sort?: string}) {
-  if (DEFAULT_SORT_OPTIONS.find(option => option === sort)) {
+function validateSortOption({
+  sort,
+  organization,
+}: {
+  organization: Organization;
+  sort?: string;
+}) {
+  const hasBetterPrioritySort = organization.features.includes(
+    'issue-list-better-priority-sort'
+  );
+  const sortOptions = [...DEFAULT_SORT_OPTIONS];
+  if (hasBetterPrioritySort) {
+    sortOptions.push(IssueSortOptions.BETTER_PRIORITY);
+  }
+  if (sortOptions.find(option => option === sort)) {
     return sort as string;
   }
 
@@ -49,7 +62,7 @@ export function CreateSavedSearchModal({
   const initialData = {
     name: '',
     query,
-    sort: validateSortOption({sort}),
+    sort: validateSortOption({sort, organization}),
     visibility: SavedSearchVisibility.OWNER,
   };
 

+ 9 - 1
static/app/components/modals/savedSearchModal/savedSearchModalContent.tsx

@@ -27,7 +27,15 @@ const SELECT_FIELD_VISIBILITY_OPTIONS = [
 export function SavedSearchModalContent({organization}: SavedSearchModalContentProps) {
   const canChangeVisibility = organization.access.includes('org:write');
 
-  const selectFieldSortOptions = DEFAULT_SORT_OPTIONS.map(sortOption => ({
+  const hasBetterPrioritySort = organization.features.includes(
+    'issue-list-better-priority-sort'
+  );
+  const sortOptions = [...DEFAULT_SORT_OPTIONS];
+  if (hasBetterPrioritySort) {
+    sortOptions.push(IssueSortOptions.BETTER_PRIORITY);
+  }
+
+  const selectFieldSortOptions = sortOptions.map(sortOption => ({
     value: sortOption,
     label: getSortLabel(sortOption),
   }));

+ 7 - 1
static/app/views/dashboards/datasetConfig/issues.tsx

@@ -72,8 +72,14 @@ function disableSortOptions(_widgetQuery: WidgetQuery) {
   };
 }
 
-function getTableSortOptions(_organization: Organization, _widgetQuery: WidgetQuery) {
+function getTableSortOptions(organization: Organization, _widgetQuery: WidgetQuery) {
+  const hasBetterPrioritySort = organization.features.includes(
+    'issue-list-better-priority-sort'
+  );
   const sortOptions = [...ISSUE_WIDGET_SORT_OPTIONS];
+  if (hasBetterPrioritySort) {
+    sortOptions.push(IssueSortOptions.BETTER_PRIORITY);
+  }
   return sortOptions.map(sortOption => ({
     label: getSortLabel(sortOption),
     value: sortOption,