Skip to content

Commit 539614d

Browse files
authored
fix(ui): Don't show project picker for alert wizard v3 (#33634)
* fix(ui): Don't show project picker for alert wizard v3 * add whitespace
1 parent b554f6f commit 539614d

File tree

6 files changed

+45
-23
lines changed

6 files changed

+45
-23
lines changed

static/app/components/createAlertButton.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function IncompatibleQueryAlert({
7272
const {hasProjectError, hasEnvironmentError, hasEventTypeError, hasYAxisError} =
7373
incompatibleQuery;
7474

75-
const totalErrors = Object.values(incompatibleQuery).filter(val => val === true).length;
75+
const totalErrors = Object.values(incompatibleQuery).filter(val => val).length;
7676

7777
const eventTypeError = eventView.clone();
7878
eventTypeError.query += ' event.type:error';
@@ -360,7 +360,11 @@ const CreateAlertButton = withRouter(
360360
: `/organizations/${organization.slug}/alerts/${providedProj}`;
361361
const alertsArgs = [
362362
`${referrer ? `referrer=${referrer}` : ''}`,
363-
`${hasAlertWizardV3 && providedProj ? `project=${providedProj}` : ''}`,
363+
`${
364+
hasAlertWizardV3 && providedProj && providedProj !== ':projectId'
365+
? `project=${providedProj}`
366+
: ''
367+
}`,
364368
].filter(item => item !== '');
365369

366370
return `${alertsBaseUrl}/wizard/${alertsArgs.length ? '?' : ''}${alertsArgs.join(

static/app/views/alerts/incidentRules/ruleNameOwnerForm.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default function RuleNameOwnerForm({disabled, project, hasAlertWizardV3}:
3535
const renderTeamSelect = () => (
3636
<StyledFormField
3737
hasAlertWizardV3={hasAlertWizardV3}
38+
extraMargin
3839
name="owner"
3940
label={hasAlertWizardV3 ? null : t('Team')}
4041
help={hasAlertWizardV3 ? null : t('The team that can edit this alert.')}
@@ -102,7 +103,10 @@ const StyledTextField = styled(TextField)<{hasAlertWizardV3: boolean}>`
102103
`}
103104
`;
104105

105-
const StyledFormField = styled(FormField)<{hasAlertWizardV3: boolean}>`
106+
const StyledFormField = styled(FormField)<{
107+
hasAlertWizardV3: boolean;
108+
extraMargin?: boolean;
109+
}>`
106110
${p =>
107111
p.hasAlertWizardV3 &&
108112
`
@@ -113,6 +117,6 @@ const StyledFormField = styled(FormField)<{hasAlertWizardV3: boolean}>`
113117
width: 100%;
114118
}
115119
116-
margin-bottom: ${space(1)};
120+
margin-bottom: ${p.extraMargin ? '60px' : space(1)};
117121
`}
118122
`;

static/app/views/alerts/issueRuleEditor/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ class IssueRuleEditor extends AsyncView<Props, State> {
612612
return (
613613
<StyledField
614614
hasAlertWizardV3={hasAlertWizardV3}
615+
extraMargin
615616
label={hasAlertWizardV3 ? null : t('Team')}
616617
help={hasAlertWizardV3 ? null : t('The team that can edit this alert.')}
617618
disabled={!hasAccess || !canEdit}
@@ -1145,7 +1146,7 @@ const SettingsContainer = styled('div')`
11451146
gap: ${space(1)};
11461147
`;
11471148

1148-
const StyledField = styled(Field)<{hasAlertWizardV3?: boolean}>`
1149+
const StyledField = styled(Field)<{extraMargin?: boolean; hasAlertWizardV3?: boolean}>`
11491150
:last-child {
11501151
padding-bottom: ${space(2)};
11511152
}
@@ -1161,7 +1162,7 @@ const StyledField = styled(Field)<{hasAlertWizardV3?: boolean}>`
11611162
width: 100%;
11621163
}
11631164
1164-
margin-bottom: ${space(1)};
1165+
margin-bottom: ${p.extraMargin ? '60px' : space(1)};
11651166
`}
11661167
`;
11671168

static/app/views/alerts/list/header.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import {Organization} from 'sentry/types';
1616
type Props = {
1717
activeTab: 'stream' | 'rules';
1818
organization: Organization;
19+
projectSlugs: string[];
1920
router: InjectedRouter;
2021
};
2122

22-
const AlertHeader = ({router, organization, activeTab}: Props) => {
23+
const AlertHeader = ({router, organization, activeTab, projectSlugs}: Props) => {
2324
/**
2425
* Incidents list is currently at the organization level, but the link needs to
2526
* go down to a specific project scope.
@@ -50,6 +51,7 @@ const AlertHeader = ({router, organization, activeTab}: Props) => {
5051
priority="primary"
5152
referrer="alert_stream"
5253
showPermissionGuide
54+
projectSlug={projectSlugs.length === 1 ? projectSlugs[0] : undefined}
5355
>
5456
{t('Create Alert')}
5557
</CreateAlertButton>

static/app/views/alerts/list/index.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Component, Fragment} from 'react';
22
import {RouteComponentProps} from 'react-router';
33
import styled from '@emotion/styled';
4-
import flatten from 'lodash/flatten';
54

65
import {promptsCheck, promptsUpdate} from 'sentry/actionCreators/prompts';
76
import Feature from 'sentry/components/acl/feature';
@@ -123,6 +122,12 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
123122
this.setState({hasAlertRule, firstVisitShown, loading: false});
124123
}
125124

125+
get projectsFromIncidents() {
126+
const {incidentList} = this.state;
127+
128+
return [...new Set(incidentList?.map(({projects}) => projects).flat())];
129+
}
130+
126131
handleChangeSearch = (title: string) => {
127132
const {router, location} = this.props;
128133
const {cursor: _cursor, page: _page, ...currentQuery} = location.query;
@@ -199,13 +204,8 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
199204
organization,
200205
} = this.props;
201206

202-
const allProjectsFromIncidents = new Set(
203-
flatten(incidentList?.map(({projects}) => projects))
204-
);
205207
const checkingForAlertRules =
206-
incidentList && incidentList.length === 0 && hasAlertRule === undefined
207-
? true
208-
: false;
208+
incidentList?.length === 0 && hasAlertRule === undefined;
209209
const showLoadingIndicator = loading || checkingForAlertRules;
210210

211211
return (
@@ -231,7 +231,7 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
231231
t('Team'),
232232
]}
233233
>
234-
<Projects orgId={orgId} slugs={Array.from(allProjectsFromIncidents)}>
234+
<Projects orgId={orgId} slugs={this.projectsFromIncidents}>
235235
{({initiallyLoaded, projects}) =>
236236
incidentList.map(incident => (
237237
<AlertListRow
@@ -263,7 +263,12 @@ class IncidentsList extends AsyncComponent<Props, State & AsyncComponent['state'
263263
showDateSelector={false}
264264
hideGlobalHeader
265265
>
266-
<AlertHeader organization={organization} router={router} activeTab="stream" />
266+
<AlertHeader
267+
organization={organization}
268+
router={router}
269+
activeTab="stream"
270+
projectSlugs={this.projectsFromIncidents}
271+
/>
267272
<Layout.Body>
268273
<Layout.Main fullWidth>
269274
{!this.tryRenderOnboarding() && (

static/app/views/alerts/rules/index.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Component} from 'react';
22
import {RouteComponentProps} from 'react-router';
33
import styled from '@emotion/styled';
4-
import flatten from 'lodash/flatten';
54

65
import {addErrorMessage} from 'sentry/actionCreators/indicator';
76
import AsyncComponent from 'sentry/components/asyncComponent';
@@ -59,6 +58,12 @@ class AlertRulesList extends AsyncComponent<Props, State & AsyncComponent['state
5958
];
6059
}
6160

61+
get projectsFromIncidents() {
62+
const {ruleList = []} = this.state;
63+
64+
return [...new Set(ruleList?.map(({projects}) => projects).flat())];
65+
}
66+
6267
handleChangeFilter = (_sectionId: string, activeFilters: Set<string>) => {
6368
const {router, location} = this.props;
6469
const {cursor: _cursor, page: _page, ...currentQuery} = location.query;
@@ -115,10 +120,6 @@ class AlertRulesList extends AsyncComponent<Props, State & AsyncComponent['state
115120
const {loading, ruleList = [], ruleListPageLinks} = this.state;
116121
const {query} = location;
117122

118-
const allProjectsFromIncidents = new Set(
119-
flatten(ruleList?.map(({projects}) => projects))
120-
);
121-
122123
const sort: {
123124
asc: boolean;
124125
field: 'date_added' | 'name' | ['incident_status', 'date_triggered'];
@@ -215,7 +216,7 @@ class AlertRulesList extends AsyncComponent<Props, State & AsyncComponent['state
215216
isEmpty={ruleList?.length === 0}
216217
emptyMessage={t('No alert rules found for the current query.')}
217218
>
218-
<Projects orgId={orgId} slugs={Array.from(allProjectsFromIncidents)}>
219+
<Projects orgId={orgId} slugs={this.projectsFromIncidents}>
219220
{({initiallyLoaded, projects}) =>
220221
ruleList.map(rule => (
221222
<RuleListRow
@@ -268,7 +269,12 @@ class AlertRulesList extends AsyncComponent<Props, State & AsyncComponent['state
268269
showEnvironmentSelector={false}
269270
hideGlobalHeader
270271
>
271-
<AlertHeader organization={organization} router={router} activeTab="rules" />
272+
<AlertHeader
273+
organization={organization}
274+
router={router}
275+
activeTab="rules"
276+
projectSlugs={this.projectsFromIncidents}
277+
/>
272278
{this.renderList()}
273279
</PageFiltersContainer>
274280
</SentryDocumentTitle>

0 commit comments

Comments
 (0)