Skip to content

Commit 2fc7fe3

Browse files
committed
fix(alerts): Show empty state for projects column when no detectors connected
When an automation has no connected detectors, the projects column showed all projects because useDetectorsQuery({ids: []}) fetched all detectors. Disable the query when detectorIds is empty and show an em-dash empty state instead. Fixes ISWF-2161
1 parent 9c8c155 commit 2fc7fe3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

static/app/views/automations/components/automationListTable/row.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {ProjectList} from 'sentry/components/projectList';
99
import {SimpleTable} from 'sentry/components/tables/simpleTable';
1010
import {ActionCell} from 'sentry/components/workflowEngine/gridCell/actionCell';
1111
import {AutomationTitleCell} from 'sentry/components/workflowEngine/gridCell/automationTitleCell';
12+
import {EmptyCell} from 'sentry/components/workflowEngine/gridCell/emptyCell';
1213
import {TimeAgoCell} from 'sentry/components/workflowEngine/gridCell/timeAgoCell';
1314
import {ProjectsStore} from 'sentry/stores/projectsStore';
1415
import type {Automation} from 'sentry/types/workflowEngine/automations';
@@ -66,7 +67,11 @@ export function AutomationListRow({
6667
<ActionCell actions={actions} disabled={!enabled} />
6768
</SimpleTable.RowCell>
6869
<SimpleTable.RowCell data-column-name="projects">
69-
<ProjectList projectSlugs={projectSlugs} />
70+
{projectSlugs.length > 0 ? (
71+
<ProjectList projectSlugs={projectSlugs} />
72+
) : (
73+
<EmptyCell />
74+
)}
7075
</SimpleTable.RowCell>
7176
<SimpleTable.RowCell data-column-name="connected-monitors">
7277
<AutomationListConnectedDetectors detectorIds={detectorIds} />

static/app/views/automations/hooks/utils.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ export function getAutomationActionsWarning(
5353
}
5454

5555
export function useAutomationProjectIds(automation: Automation): string[] {
56-
const {data: detectors} = useDetectorsQuery({ids: automation.detectorIds});
56+
const {data: detectors} = useDetectorsQuery(
57+
{ids: automation.detectorIds},
58+
{enabled: automation.detectorIds.length > 0}
59+
);
5760
return [
5861
...new Set(detectors?.map(detector => detector.projectId).filter(x => x) ?? []),
5962
] as string[];

0 commit comments

Comments
 (0)