Skip to content

Commit 167d90a

Browse files
committed
feat(aci): Update connected alerts empty state
1 parent ade9321 commit 167d90a

File tree

4 files changed

+63
-20
lines changed

4 files changed

+63
-20
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import styled from '@emotion/styled';
2+
3+
import {ProjectAvatar} from '@sentry/scraps/avatar';
4+
import {Flex, Stack} from '@sentry/scraps/layout';
5+
import {Text} from '@sentry/scraps/text';
6+
7+
import {tct} from 'sentry/locale';
8+
import type {AvatarProject} from 'sentry/types/project';
9+
10+
interface ConnectedAlertsEmptyStateProps {
11+
project: AvatarProject;
12+
children?: React.ReactNode;
13+
}
14+
15+
export function ConnectedAlertsEmptyState({
16+
project,
17+
children,
18+
}: ConnectedAlertsEmptyStateProps) {
19+
return (
20+
<Stack gap="lg" align="center" maxWidth="300px">
21+
{children && (
22+
<Stack gap="md" align="center">
23+
{children}
24+
</Stack>
25+
)}
26+
<Text variant="muted" align="center" density="comfortable">
27+
{tct(
28+
'Alerts configured for all Issues in the project [project] will also apply to this Monitor.',
29+
{
30+
project: (
31+
<InlineProjectName display="inline-flex" align="center" gap="xs">
32+
<ProjectAvatar project={project} size={16} />
33+
<strong>{project.slug}</strong>
34+
</InlineProjectName>
35+
),
36+
}
37+
)}
38+
</Text>
39+
</Stack>
40+
);
41+
}
42+
43+
const InlineProjectName = styled(Flex)`
44+
vertical-align: bottom;
45+
`;

static/app/views/detectors/components/details/common/automations.spec.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ describe('DetectorDetailsAutomations', () => {
2424
const automation1 = AutomationFixture({id: '1', name: 'Alert 1'});
2525
const issueStreamDetector = IssueStreamDetectorFixture({id: '4'});
2626

27+
const project = ProjectFixture({id: '1'});
28+
2729
beforeEach(() => {
2830
jest.clearAllMocks();
2931
MockApiClient.clearMockResponses();
32+
ProjectsStore.loadInitialData([project]);
3033

3134
MockApiClient.addMockResponse({
3235
url: '/organizations/org-slug/detectors/',
@@ -297,8 +300,7 @@ describe('DetectorDetailsAutomations', () => {
297300
projectId: '1',
298301
workflowIds: [automation1.id],
299302
});
300-
301-
act(() => ProjectsStore.loadInitialData([projectWithoutAlertsWrite]));
303+
ProjectsStore.loadInitialData([projectWithoutAlertsWrite]);
302304

303305
MockApiClient.addMockResponse({
304306
url: '/organizations/org-slug/workflows/',

static/app/views/detectors/components/details/common/automations.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {useAutomationsQuery} from 'sentry/views/automations/hooks';
3030
import {getAutomationActions} from 'sentry/views/automations/hooks/utils';
3131
import {makeAutomationCreatePathname} from 'sentry/views/automations/pathnames';
3232
import {ConnectAutomationsDrawer} from 'sentry/views/detectors/components/connectAutomationsDrawer';
33+
import {ConnectedAlertsEmptyState} from 'sentry/views/detectors/components/connectedAutomationsEmptyState';
3334
import {useUpdateDetector} from 'sentry/views/detectors/hooks';
3435
import {useCanEditDetectorWorkflowConnections} from 'sentry/views/detectors/utils/useCanEditDetector';
3536
import {useIssueStreamDetectorsForProject} from 'sentry/views/detectors/utils/useIssueStreamDetectorsForProject';
@@ -222,6 +223,7 @@ export function DetectorDetailsAutomations({detector}: Props) {
222223
const queryClient = useQueryClient();
223224
const {openDrawer, closeDrawer, isDrawerOpen} = useDrawer();
224225
const {mutate: updateDetector} = useUpdateDetector();
226+
const project = useProjectFromId({project_id: detector.projectId});
225227
const canEditWorkflowConnections = useCanEditDetectorWorkflowConnections({
226228
projectId: detector.projectId,
227229
});
@@ -304,8 +306,8 @@ export function DetectorDetailsAutomations({detector}: Props) {
304306
detectorId={detector.id}
305307
projectId={detector.projectId}
306308
emptyMessage={
307-
<Stack gap="xl" align="center">
308-
<Stack gap="sm" align="center">
309+
project ? (
310+
<ConnectedAlertsEmptyState project={project}>
309311
<Button
310312
size="sm"
311313
onClick={toggleDrawer}
@@ -326,8 +328,10 @@ export function DetectorDetailsAutomations({detector}: Props) {
326328
>
327329
{t('Create a New Alert')}
328330
</LinkButton>
329-
</Stack>
330-
</Stack>
331+
</ConnectedAlertsEmptyState>
332+
) : (
333+
t('No alerts connected')
334+
)
331335
}
332336
/>
333337
</ErrorBoundary>

static/app/views/detectors/components/forms/automateSection.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import {useCallback, useContext, useRef} from 'react';
22
import styled from '@emotion/styled';
33

44
import {Button} from '@sentry/scraps/button';
5-
import {Flex, Stack} from '@sentry/scraps/layout';
6-
import {Text} from '@sentry/scraps/text';
5+
import {Flex} from '@sentry/scraps/layout';
76

87
import {FormContext} from 'sentry/components/forms/formContext';
98
import {useDrawer} from 'sentry/components/globalDrawer';
109
import {useFormField} from 'sentry/components/workflowEngine/form/useFormField';
1110
import {Container} from 'sentry/components/workflowEngine/ui/container';
1211
import {FormSection} from 'sentry/components/workflowEngine/ui/formSection';
1312
import {IconAdd, IconEdit} from 'sentry/icons';
14-
import {t, tct} from 'sentry/locale';
13+
import {t} from 'sentry/locale';
1514
import {AutomationBuilderDrawerForm} from 'sentry/views/automations/components/automationBuilderDrawerForm';
1615
import {ConnectAutomationsDrawer} from 'sentry/views/detectors/components/connectAutomationsDrawer';
1716
import {ConnectedAutomationsList} from 'sentry/views/detectors/components/connectedAutomationList';
17+
import {ConnectedAlertsEmptyState} from 'sentry/views/detectors/components/connectedAutomationsEmptyState';
1818
import {useDetectorFormContext} from 'sentry/views/detectors/components/forms/context';
1919

2020
export function AutomateSection({step}: {step?: number}) {
@@ -110,7 +110,7 @@ export function AutomateSection({step}: {step?: number}) {
110110
cursor={undefined}
111111
onCursor={() => {}}
112112
emptyMessage={
113-
<Stack gap="md" align="center" maxWidth="300px">
113+
<ConnectedAlertsEmptyState project={project}>
114114
<Button
115115
ref={ref}
116116
size="sm"
@@ -119,18 +119,10 @@ export function AutomateSection({step}: {step?: number}) {
119119
>
120120
{t('Connect Existing Alerts')}
121121
</Button>
122-
<Button size="sm" icon={<IconAdd />} onClick={openCreateDrawer}>
122+
<Button size="sm" onClick={openCreateDrawer}>
123123
{t('Create New Alert')}
124124
</Button>
125-
<Text variant="muted" align="center">
126-
{tct(
127-
'Alerts configured for all Issues in [projectName] will also apply to this Monitor.',
128-
{
129-
projectName: <strong>{project.slug}</strong>,
130-
}
131-
)}
132-
</Text>
133-
</Stack>
125+
</ConnectedAlertsEmptyState>
134126
}
135127
/>
136128
</FormSection>

0 commit comments

Comments
 (0)