Browse Source

fix(ui): Link to Alert Rules list from command pallet (#32502)

* fix(ui): Link to Alert Rules list from command pallet

Previously, the Alerts link on the command pallet (CMD + K) would go to the Alerts page for Project Settings. This PR fixes this where it will now link to the Alert Rules list.

FIXES WOR-1594

* change navigation config back to previous link, add alert link to source instead

* update title and description to make it clearer that its alert settings and not the alert rules page

* wording

* fix tests
Kelly Carino 3 years ago
parent
commit
1ea47c5bc2

+ 8 - 0
static/app/components/search/sources/apiSource.tsx

@@ -75,6 +75,14 @@ async function createProjectResults(
           resultType: 'settings',
           to: `/settings/${orgId}/projects/${project.slug}/`,
         },
+        {
+          title: t('%s Alerts', project.slug),
+          description: t('List of project alert rules'),
+          model: project,
+          sourceType: 'project',
+          resultType: 'route',
+          to: `/organizations/${orgId}/alerts/rules/?project=${project.id}`,
+        },
       ];
 
       projectResults.unshift({

+ 2 - 2
static/app/views/settings/project/navigationConfiguration.tsx

@@ -33,8 +33,8 @@ export default function getConfiguration({
         },
         {
           path: `${pathPrefix}/alerts/`,
-          title: t('Alerts'),
-          description: t('Manage alert rules for a project'),
+          title: t('Alert Settings'),
+          description: t('Project alert settings'),
         },
         {
           path: `${pathPrefix}/tags/`,

+ 15 - 3
tests/js/spec/components/search/sources/apiSource.spec.jsx

@@ -249,6 +249,18 @@ describe('ApiSource', function () {
           matches: expect.anything(),
           score: expect.anything(),
         }),
+        expect.objectContaining({
+          item: expect.objectContaining({
+            model: expect.objectContaining({
+              slug: 'foo-project',
+            }),
+            sourceType: 'project',
+            resultType: 'route',
+            to: '/organizations/org-slug/alerts/rules/?project=2',
+          }),
+          matches: expect.anything(),
+          score: expect.anything(),
+        }),
         expect.objectContaining({
           item: expect.objectContaining({
             model: expect.objectContaining({
@@ -278,7 +290,7 @@ describe('ApiSource', function () {
 
     // The return values here are because of fuzzy search matching.
     // There are no members that match
-    expect(mock.mock.calls[1][0].results).toHaveLength(5);
+    expect(mock.mock.calls[1][0].results).toHaveLength(6);
   });
 
   it('render function is called with correct results when API requests partially succeed', async function () {
@@ -342,7 +354,7 @@ describe('ApiSource', function () {
 
     // The return values here are because of fuzzy search matching.
     // There are no members that match
-    expect(mock.mock.calls[1][0].results).toHaveLength(5);
+    expect(mock.mock.calls[1][0].results).toHaveLength(6);
     expect(mock.mock.calls[1][0].results[0].item.model.slug).toBe('foo-org');
 
     mock.mockClear();
@@ -351,7 +363,7 @@ describe('ApiSource', function () {
     wrapper.update();
 
     // Still have 4 results, but is re-ordered
-    expect(mock.mock.calls[0][0].results).toHaveLength(5);
+    expect(mock.mock.calls[0][0].results).toHaveLength(6);
     expect(mock.mock.calls[0][0].results[0].item.model.slug).toBe('foo-team');
   });