|
@@ -3,6 +3,7 @@ import type {Organization} from 'sentry/types/organization';
|
|
|
import type {Project} from 'sentry/types/project';
|
|
|
import {metric} from 'sentry/utils/analytics';
|
|
|
import type EventView from 'sentry/utils/discover/eventView';
|
|
|
+import {decodeScalar} from 'sentry/utils/queryString';
|
|
|
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
|
|
|
import {
|
|
|
createDefaultRule,
|
|
@@ -49,8 +50,15 @@ function MetricRulesCreate(props: Props) {
|
|
|
router.push(normalizeUrl(target));
|
|
|
}
|
|
|
|
|
|
- const {project, eventView, wizardTemplate, sessionId, userTeamIds, ...otherProps} =
|
|
|
- props;
|
|
|
+ const {
|
|
|
+ project,
|
|
|
+ eventView,
|
|
|
+ wizardTemplate,
|
|
|
+ sessionId,
|
|
|
+ userTeamIds,
|
|
|
+ location,
|
|
|
+ ...otherProps
|
|
|
+ } = props;
|
|
|
const defaultRule = eventView
|
|
|
? createRuleFromEventView(eventView)
|
|
|
: wizardTemplate
|
|
@@ -60,15 +68,17 @@ function MetricRulesCreate(props: Props) {
|
|
|
const projectTeamIds = new Set(project.teams.map(({id}) => id));
|
|
|
const defaultOwnerId = userTeamIds.find(id => projectTeamIds.has(id)) ?? null;
|
|
|
defaultRule.owner = defaultOwnerId && `team:${defaultOwnerId}`;
|
|
|
+ const environment = decodeScalar(location?.query?.environment) ?? null;
|
|
|
|
|
|
return (
|
|
|
<RuleForm
|
|
|
onSubmitSuccess={handleSubmitSuccess}
|
|
|
- rule={{...defaultRule, projects: [project.slug]}}
|
|
|
+ rule={{...defaultRule, environment, projects: [project.slug]}}
|
|
|
sessionId={sessionId}
|
|
|
project={project}
|
|
|
userTeamIds={userTeamIds}
|
|
|
eventView={eventView}
|
|
|
+ location={location}
|
|
|
{...otherProps}
|
|
|
/>
|
|
|
);
|