Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Fix redirect after creating/editing Metric Alert rules #16342

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sentry/static/sentry/app/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ function routes() {
/>

<Route path="issue-rules/" component={null}>
<IndexRedirect to="/settings/:orgId/projects/:projectId/alerts-v2/" />
<Route
path="new/"
name="New Alert Rule"
Expand All @@ -306,6 +307,7 @@ function routes() {
</Route>

<Route path="metric-rules/" component={null}>
<IndexRedirect to="/settings/:orgId/projects/:projectId/alerts-v2/" />
<Route
name="New Incident Rule"
path="new/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IncidentRulesCreate extends React.Component<Props> {
handleSubmitSuccess = () => {
const {params, routes, router, location} = this.props;

router.push(recreateRoute('metric-rules/', {params, routes, location, stepBack: -1}));
router.push(recreateRoute('', {params, routes, location, stepBack: -1}));
};

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {addErrorMessage} from 'app/actionCreators/indicator';
import {t} from 'app/locale';
import AsyncView from 'app/views/asyncView';
import RuleForm from 'app/views/settings/incidentRules/ruleForm';
import recreateRoute from 'app/utils/recreateRoute';
import withOrganization from 'app/utils/withOrganization';

type RouteParams = {
Expand Down Expand Up @@ -43,6 +44,12 @@ class IncidentRulesDetails extends AsyncView<Props, State> {
];
}

handleSubmitSuccess = () => {
const {params, routes, router, location} = this.props;

router.push(recreateRoute('', {params, routes, location, stepBack: -2}));
};

// XXX(billy): This is temporary, ideally we want actions fetched with triggers?
onRequestSuccess = async ({data}) => {
const {orgId, incidentRuleId} = this.props.params;
Expand Down Expand Up @@ -91,6 +98,7 @@ class IncidentRulesDetails extends AsyncView<Props, State> {
{...this.props}
incidentRuleId={incidentRuleId}
rule={this.getActions(rule, this.state.actions)}
onSubmitSuccess={this.handleSubmitSuccess}
/>
);
}
Expand Down