Skip to content

Commit a5862f3

Browse files
ameliahsuandrewshie-sentry
authored andcommitted
feat(aci): add edit monitors drawer and link monitor creation page (#91761)
**"Create New Monitor"** now links to the monitor creation page **"Edit Monitors"** now opens a new drawer to connect/disconnect monitors <img width="1219" alt="Screenshot 2025-05-15 at 11 44 11 AM" src="https://github.com/user-attachments/assets/050c6956-e4d2-4362-a8c0-014e921614e9" /> doesn't look like much without mock data <img width="1486" alt="Screenshot 2025-05-15 at 11 42 48 AM" src="https://github.com/user-attachments/assets/38a409c0-cbd0-40b8-aaaa-901b553fa7e4" /> **designs with mock data:** <img width="410" alt="Screenshot 2025-05-15 at 11 47 17 AM" src="https://github.com/user-attachments/assets/06929b99-fd6e-44cc-a8b5-20a9891354ce" />
1 parent 2e00f0e commit a5862f3

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

static/app/views/automations/components/automationForm.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,33 @@ import {flattie} from 'flattie';
44

55
import {Flex} from 'sentry/components/container/flex';
66
import {Button} from 'sentry/components/core/button';
7+
import {LinkButton} from 'sentry/components/core/button/linkButton';
78
import SelectField from 'sentry/components/forms/fields/selectField';
89
import Form from 'sentry/components/forms/form';
910
import FormModel from 'sentry/components/forms/model';
11+
import useDrawer from 'sentry/components/globalDrawer';
12+
import {DrawerBody, DrawerHeader} from 'sentry/components/globalDrawer/components';
1013
import {useDocumentTitle} from 'sentry/components/sentryDocumentTitle';
1114
import {DebugForm} from 'sentry/components/workflowEngine/form/debug';
1215
import {Card} from 'sentry/components/workflowEngine/ui/card';
1316
import {IconAdd, IconEdit} from 'sentry/icons';
1417
import {t} from 'sentry/locale';
1518
import {space} from 'sentry/styles/space';
1619
import type {Detector} from 'sentry/types/workflowEngine/detectors';
20+
import useOrganization from 'sentry/utils/useOrganization';
1721
import AutomationBuilder from 'sentry/views/automations/components/automationBuilder';
1822
import {
1923
AutomationBuilderContext,
2024
initialAutomationBuilderState,
2125
useAutomationBuilderReducer,
2226
} from 'sentry/views/automations/components/automationBuilderContext';
2327
import ConnectedMonitorsList from 'sentry/views/automations/components/connectedMonitorsList';
28+
import EditConnectedMonitors from 'sentry/views/automations/components/editConnectedMonitors';
2429
import {
2530
NEW_AUTOMATION_CONNECTED_IDS_KEY,
2631
useConnectedIds,
2732
} from 'sentry/views/automations/hooks/utils';
33+
import {makeMonitorBasePathname} from 'sentry/views/detectors/pathnames';
2834

2935
const FREQUENCY_OPTIONS = [
3036
{value: '5', label: t('5 minutes')},
@@ -39,6 +45,7 @@ const FREQUENCY_OPTIONS = [
3945
];
4046

4147
export default function AutomationForm() {
48+
const organization = useOrganization();
4249
const title = useDocumentTitle();
4350
const {state, actions} = useAutomationBuilderReducer();
4451
const [model] = useState(() => new FormModel());
@@ -48,11 +55,34 @@ export default function AutomationForm() {
4855
}, [title, model]);
4956

5057
const monitors: Detector[] = []; // TODO: Fetch monitors from API
58+
const storageKey = NEW_AUTOMATION_CONNECTED_IDS_KEY; // TODO: use automation id for storage key when editing an existing automation
5159
const {connectedIds, toggleConnected} = useConnectedIds({
52-
storageKey: NEW_AUTOMATION_CONNECTED_IDS_KEY,
60+
storageKey,
5361
});
5462
const connectedMonitors = monitors.filter(monitor => connectedIds.has(monitor.id));
5563

64+
const {openDrawer: openEditMonitorsDrawer, isDrawerOpen: isEditMonitorsDrawerOpen} =
65+
useDrawer();
66+
67+
const showEditMonitorsDrawer = () => {
68+
if (!isEditMonitorsDrawerOpen) {
69+
openEditMonitorsDrawer(
70+
() => (
71+
<div>
72+
<DrawerHeader />
73+
<DrawerBody>
74+
<EditConnectedMonitors storageKey={storageKey} />
75+
</DrawerBody>
76+
</div>
77+
),
78+
{
79+
ariaLabel: 'Edit Monitors Drawer',
80+
drawerKey: 'edit-monitors-drawer',
81+
}
82+
);
83+
}
84+
};
85+
5686
return (
5787
<Form
5888
hideFooter
@@ -69,8 +99,15 @@ export default function AutomationForm() {
6999
toggleConnected={toggleConnected}
70100
/>
71101
<ButtonWrapper justify="space-between">
72-
<Button icon={<IconAdd />}>{t('Create New Monitor')}</Button>
73-
<Button icon={<IconEdit />}>{t('Edit Monitors')}</Button>
102+
<LinkButton
103+
icon={<IconAdd />}
104+
to={`${makeMonitorBasePathname(organization.slug)}new/`}
105+
>
106+
{t('Create New Monitor')}
107+
</LinkButton>
108+
<Button icon={<IconEdit />} onClick={showEditMonitorsDrawer}>
109+
{t('Edit Monitors')}
110+
</Button>
74111
</ButtonWrapper>
75112
</Card>
76113
<Card>

0 commit comments

Comments
 (0)