Skip to content

Commit

Permalink
fix(ui): Fix redirect after creating/editing Metric Alert rules (#16342)
Browse files Browse the repository at this point in the history
Also makes sure that the index redirects to combined alert listing view.
  • Loading branch information
billyvg authored and Nisanthan Nanthakumar committed Jan 9, 2020
1 parent 35a3b82 commit 1bf55bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

0 comments on commit 1bf55bf

Please sign in to comment.