Skip to content

Commit 4e2a7ad

Browse files
natemoo-regetsantry[bot]scttcper
authored
feat(aci): add monitor config form (#90501)
Adds the basic metric monitor config form to ACI. Also tackles a bit of general UI cleanup and adds more monitor-related hooks. Sorry for the large PR! @ameliahsu graciously split a few smaller branches off from this, so this is a bit of a catch-all PR. --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: Scott Cooper <scttcper@gmail.com>
1 parent 40a702d commit 4e2a7ad

36 files changed

+784
-54
lines changed

static/app/components/workflowEngine/form/control/priorityControl.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default function PriorityControl({
7676
flexibleControlStateSize
7777
size="sm"
7878
suffix="s"
79+
placeholder="0"
7980
// empty string required to keep this as a controlled input
8081
value={thresholds[PriorityLevel.MEDIUM] ?? ''}
8182
onChange={threshold => setMediumThreshold(Number(threshold))}
@@ -96,6 +97,7 @@ export default function PriorityControl({
9697
flexibleControlStateSize
9798
size="sm"
9899
suffix="s"
100+
placeholder="0"
99101
// empty string required to keep this as a controlled input
100102
value={thresholds[PriorityLevel.HIGH] ?? ''}
101103
onChange={threshold => setHighThreshold(Number(threshold))}

static/app/components/workflowEngine/gridCell/actionCell.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ export function ActionCell({actions, disabled}: ActionCellProps) {
3131
</Flex>
3232
);
3333
}
34-
3534
const actionsList = actions
3635
.map(action => ActionMetadata[action]?.name)
3736
.filter(x => x)
3837
.join(', ');
39-
4038
return (
4139
<ActionContainer align="center" gap={space(0.75)}>
4240
<IconContainer>

static/app/components/workflowEngine/gridCell/connectionCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const links: Record<
3232
};
3333

3434
export function ConnectionCell({
35-
ids: items,
35+
ids: items = [],
3636
type,
3737
disabled = false,
3838
className,

static/app/components/workflowEngine/gridCell/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default storyBook('Grid Cell Components', story => {
5050
},
5151
openIssues: 3,
5252
creator: '1',
53-
type: 'trace',
53+
type: 'uptime',
5454
},
5555
{
5656
title: {
@@ -95,7 +95,7 @@ export default storyBook('Grid Cell Components', story => {
9595
},
9696
actions: [ActionType.SLACK, ActionType.DISCORD, ActionType.EMAIL],
9797
creator: 'sentry',
98-
type: 'errors',
98+
type: 'uptime',
9999
timeAgo: null,
100100
linkedItems: {
101101
ids: [],

static/app/components/workflowEngine/gridCell/timeAgoCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import TimeSince from 'sentry/components/timeSince';
22
import {EmptyCell} from 'sentry/components/workflowEngine/gridCell/emptyCell';
33

44
type TimeAgoCellProps = {
5-
date?: Date;
5+
date?: string | Date;
66
};
77

88
export function TimeAgoCell({date}: TimeAgoCellProps) {

static/app/components/workflowEngine/layout/actions.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {createContext, useContext} from 'react';
22

3-
import {ButtonBar} from 'sentry/components/core/button/buttonBar';
3+
import {Flex} from 'sentry/components/container/flex';
44
import {HeaderActions} from 'sentry/components/layouts/thirds';
5+
import {space} from 'sentry/styles/space';
56

67
const ActionContext = createContext<React.ReactNode | undefined>(undefined);
78

@@ -26,9 +27,7 @@ export function ActionsFromContext() {
2627
}
2728
return (
2829
<HeaderActions>
29-
<ButtonBar merged={false} gap={1}>
30-
{actions}
31-
</ButtonBar>
30+
<Flex gap={space(1)}>{actions}</Flex>
3231
</HeaderActions>
3332
);
3433
}

static/app/components/workflowEngine/layout/detail.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function DetailLayout({children, project}: WorkflowEngineDetailLayoutProps) {
2525
const title = useDocumentTitle();
2626
return (
2727
<StyledPage>
28-
<Layout.Header>
28+
<Layout.Header unified>
2929
<Layout.HeaderContent>
3030
<BreadcrumbsFromContext />
3131
<Layout.Title>{title}</Layout.Title>

static/app/components/workflowEngine/layout/edit.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function EditLayout({children, onTitleChange}: WorkflowEngineEditLayoutProps) {
2424
const title = useDocumentTitle();
2525
return (
2626
<Layout.Page>
27-
<StyledHeader>
27+
<Layout.Header unified>
2828
<Layout.HeaderContent>
2929
<BreadcrumbsFromContext />
3030
<Layout.Title>
@@ -37,16 +37,12 @@ function EditLayout({children, onTitleChange}: WorkflowEngineEditLayoutProps) {
3737
</Layout.Title>
3838
</Layout.HeaderContent>
3939
<ActionsFromContext />
40-
</StyledHeader>
40+
</Layout.Header>
4141
<Body>{children}</Body>
4242
</Layout.Page>
4343
);
4444
}
4545

46-
const StyledHeader = styled(Layout.Header)`
47-
background: ${p => p.theme.background};
48-
`;
49-
5046
const Body = styled('div')`
5147
display: flex;
5248
flex-direction: column;

static/app/components/workflowEngine/layout/list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function WorkflowEngineListLayout({children}: WorkflowEngineListLayoutProps) {
1717
const title = useDocumentTitle();
1818
return (
1919
<Layout.Page>
20-
<Layout.Header>
20+
<Layout.Header unified>
2121
<Layout.HeaderContent>
2222
<Layout.Title>{title}</Layout.Title>
2323
</Layout.HeaderContent>

static/app/components/workflowEngine/ui/container.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ export const Container = styled('div')`
77
flex-direction: column;
88
gap: ${space(2)};
99
justify-content: flex-start;
10-
background-color: ${p => p.theme.backgroundSecondary};
10+
background-color: ${p => p.theme.background};
1111
border: 1px solid ${p => p.theme.translucentBorder};
1212
border-radius: ${p => p.theme.borderRadius};
1313
padding: ${space(1.5)};
1414
1515
@media (max-width: ${p => p.theme.breakpoints.large}) {
16-
width: fit-content;
16+
min-width: fit-content;
17+
flex: 1;
1718
}
1819
`;

static/app/components/workflowEngine/ui/footer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {space} from 'sentry/styles/space';
55
export const StickyFooter = styled('div')`
66
position: sticky;
77
margin-top: auto;
8+
margin-bottom: -56px;
89
bottom: 0;
910
right: 0;
1011
width: 100%;

static/app/components/workflowEngine/ui/section.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@ import {space} from 'sentry/styles/space';
66
type SectionProps = {
77
children: React.ReactNode;
88
title: string;
9+
description?: string;
910
};
1011

11-
export default function Section({children, title}: SectionProps) {
12+
export default function Section({children, title, description}: SectionProps) {
1213
return (
1314
<Flex column gap={space(1)}>
1415
<SectionHeading>{title}</SectionHeading>
16+
{description && <SectionDescription>{description}</SectionDescription>}
1517
{children}
1618
</Flex>
1719
);
1820
}
1921

20-
const SectionHeading = styled('h4')`
22+
export const SectionHeading = styled('h4')`
23+
font-size: ${p => p.theme.fontSizeLarge};
24+
font-weight: ${p => p.theme.fontWeightBold};
25+
margin: 0;
26+
`;
27+
28+
export const SectionDescription = styled('p')`
2129
font-size: ${p => p.theme.fontSizeMedium};
30+
font-weight: ${p => p.theme.fontWeightNormal};
31+
color: ${p => p.theme.subText};
2232
margin: 0;
2333
`;

static/app/plugins/components/pluginIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const PLUGIN_ICONS = {
6969
} satisfies Record<string, string>;
7070

7171
export interface PluginIconProps extends React.RefAttributes<HTMLDivElement> {
72-
pluginId: string | keyof typeof PLUGIN_ICONS;
72+
pluginId: keyof typeof PLUGIN_ICONS | (string & {});
7373
/**
7474
* @default 20
7575
*/
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {DataConditionGroup} from 'sentry/types/workflowEngine/dataConditions';
22

3-
interface NewAutomation {
3+
export interface NewAutomation {
44
actionFilters: DataConditionGroup[];
55
detectorIds: string[];
66
name: string;
@@ -10,5 +10,5 @@ interface NewAutomation {
1010

1111
export interface Automation extends Readonly<NewAutomation> {
1212
readonly id: string;
13-
readonly lastTriggered: Date;
13+
readonly lastTriggered: string;
1414
}

static/app/types/workflowEngine/dataConditions.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export interface NewDataCondition {
7373
condition_result?: any;
7474
}
7575

76+
export interface DataCondition extends Readonly<NewDataCondition> {
77+
readonly id: string;
78+
}
79+
7680
export interface DataConditionGroup {
7781
conditions: NewDataCondition[];
7882
id: string;

static/app/types/workflowEngine/detectors.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import type {
44
} from 'sentry/types/workflowEngine/dataConditions';
55

66
export type DetectorType =
7-
| 'metric'
7+
| 'crons'
88
| 'errors'
9+
| 'metric'
910
| 'performance'
10-
| 'trace'
1111
| 'replay'
12+
| 'trace'
1213
| 'uptime';
1314

1415
interface NewDetector {
@@ -24,8 +25,8 @@ interface NewDetector {
2425

2526
export interface Detector extends Readonly<NewDetector> {
2627
readonly createdBy: string;
27-
readonly dateCreated: Date;
28-
readonly dateUpdated: Date;
28+
readonly dateCreated: string;
29+
readonly dateUpdated: string;
2930
readonly id: string;
30-
readonly lastTriggered: Date;
31+
readonly lastTriggered: string;
3132
}

static/app/utils/useParams.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type ParamKeys =
2424
| 'groupId'
2525
| 'id'
2626
| 'installationId'
27+
| 'detectorId'
2728
| 'integrationSlug'
2829
| 'issueId'
2930
| 'memberId'

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ import styled from '@emotion/styled';
44
import {Flex} from 'sentry/components/container/flex';
55
import {Checkbox} from 'sentry/components/core/checkbox';
66
import InteractionStateLayer from 'sentry/components/interactionStateLayer';
7+
import {ProjectList} from 'sentry/components/projectList';
78
import {ActionCell} from 'sentry/components/workflowEngine/gridCell/actionCell';
89
import AutomationTitleCell from 'sentry/components/workflowEngine/gridCell/automationTitleCell';
910
import {ConnectionCell} from 'sentry/components/workflowEngine/gridCell/connectionCell';
1011
import {TimeAgoCell} from 'sentry/components/workflowEngine/gridCell/timeAgoCell';
12+
import ProjectsStore from 'sentry/stores/projectsStore';
1113
import {space} from 'sentry/styles/space';
1214
import type {Automation} from 'sentry/types/workflowEngine/automations';
1315
import useOrganization from 'sentry/utils/useOrganization';
14-
import {useAutomationActions} from 'sentry/views/automations/hooks/utils';
16+
import {
17+
useAutomationActions,
18+
useAutomationProjectIds,
19+
} from 'sentry/views/automations/hooks/utils';
1520
import {makeAutomationDetailsPathname} from 'sentry/views/automations/pathnames';
1621

1722
type AutomationListRowProps = {
@@ -28,6 +33,10 @@ export function AutomationListRow({
2833
const organization = useOrganization();
2934
const actions = useAutomationActions(automation);
3035
const {id, name, disabled, lastTriggered, detectorIds = []} = automation;
36+
const projectIds = useAutomationProjectIds(automation);
37+
const projectSlugs = projectIds.map(
38+
projectId => ProjectsStore.getById(projectId)?.slug
39+
) as string[];
3140
return (
3241
<RowWrapper disabled={disabled}>
3342
<InteractionStateLayer />
@@ -51,6 +60,9 @@ export function AutomationListRow({
5160
<CellWrapper className="action">
5261
<ActionCell actions={actions} disabled={disabled} />
5362
</CellWrapper>
63+
<CellWrapper className="projects">
64+
<ProjectList projectSlugs={projectSlugs} />
65+
</CellWrapper>
5466
<CellWrapper className="connected-monitors">
5567
<ConnectionCell ids={detectorIds} type="detector" disabled={disabled} />
5668
</CellWrapper>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@ function AutomationListTable() {
4343
<HeaderDivider />
4444
<Heading>{t('Actions')}</Heading>
4545
</Flex>
46+
<Flex className="projects">
47+
<HeaderDivider />
48+
<Heading>{t('Projects')}</Heading>
49+
</Flex>
4650
<Flex className="connected-monitors">
4751
<HeaderDivider />
4852
<Heading>{t('Monitors')}</Heading>
4953
</Flex>
5054
</StyledPanelHeader>
5155
<PanelBody>
5256
{isLoading ? <LoadingIndicator /> : null}
53-
5457
{automations.map(automation => (
5558
<AutomationListRow
5659
key={automation.id}

static/app/views/automations/detail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function HistoryAndConnectedMonitors() {
3838

3939
function Details() {
4040
return (
41-
<div>
41+
<Flex column gap={space(3)}>
4242
<Flex column gap={space(1)}>
4343
<SectionHeading>{t('Last Triggered')}</SectionHeading>
4444
<span>
@@ -78,7 +78,7 @@ function Details() {
7878
<KeyValueTableRow keyName={t('Team')} value="Platform" />
7979
</KeyValueTable>
8080
</Flex>
81-
</div>
81+
</Flex>
8282
);
8383
}
8484

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ export function useAutomationsQuery(_options: UseAutomationsQueryOptions = {}) {
1414
retry: false,
1515
});
1616
}
17+
18+
export const makeAutomationQueryKey = (
19+
orgSlug: string,
20+
automationId = ''
21+
): [url: string] => [`/organizations/${orgSlug}/workflows/${automationId}/`];

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {useState} from 'react';
22

33
import type {ActionType} from 'sentry/types/workflowEngine/actions';
44
import type {Automation} from 'sentry/types/workflowEngine/automations';
5+
import {useDetectorQueriesByIds} from 'sentry/views/detectors/hooks';
56

67
export function useAutomationActions(automation: Automation): ActionType[] {
78
return [
@@ -47,3 +48,9 @@ export function useConnectedIds({storageKey, initialIds = []}: UseConnectedIdsPr
4748
}
4849

4950
export const NEW_AUTOMATION_CONNECTED_IDS_KEY = 'new-automation-connected-ids';
51+
export function useAutomationProjectIds(automation: Automation): string[] {
52+
const queries = useDetectorQueriesByIds(automation.detectorIds);
53+
return [
54+
...new Set(queries.map(query => query.data?.projectId).filter(x => x)),
55+
] as string[];
56+
}

static/app/views/automations/list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function AutomationsList() {
3636
function TableHeader() {
3737
return (
3838
<Flex gap={space(2)}>
39-
<ProjectPageFilter />
39+
<ProjectPageFilter size="md" />
4040
<div style={{flexGrow: 1}}>
4141
<SearchBar placeholder={t('Search for events, users, tags, and more')} />
4242
</div>

static/app/views/detectors/components/detectorListRow.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface DetectorListRowProps {
2323
}
2424

2525
export function DetectorListRow({
26-
detector: {workflowIds, id, name, disabled, projectId},
26+
detector: {workflowIds, createdBy, id, projectId, name, disabled, type},
2727
handleSelect,
2828
selected,
2929
}: DetectorListRowProps) {
@@ -51,16 +51,16 @@ export function DetectorListRow({
5151
<StyledGraphCell />
5252
</Flex>
5353
<CellWrapper className="type">
54-
<TypeCell type="errors" />
54+
<TypeCell type={type} />
5555
</CellWrapper>
5656
<CellWrapper className="last-issue">
5757
<StyledIssueCell
5858
group={issues.length > 0 ? issues[0] : undefined}
5959
disabled={disabled}
6060
/>
6161
</CellWrapper>
62-
<CellWrapper className="owner">
63-
<UserCell user="sentry" />
62+
<CellWrapper className="creator">
63+
<UserCell user={createdBy ?? 'sentry'} />
6464
</CellWrapper>
6565
<CellWrapper className="connected-automations">
6666
<ConnectionCell ids={workflowIds} type="workflow" disabled={disabled} />

0 commit comments

Comments
 (0)