From f17516585b4a09b68e8165f3a186d9550c945259 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 20 Jul 2016 14:08:42 +0200 Subject: [PATCH] open permission template after its creation --- .../permission-templates/components/Header.js | 17 ++++++++++++++--- .../permission-templates/views/CreateView.js | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js b/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js index b22b9387f3e..97590dc0ce3 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/components/Header.js @@ -28,6 +28,10 @@ export default class Header extends React.Component { refresh: CallbackType }; + static contextTypes = { + router: React.PropTypes.object + }; + componentWillMount () { this.handleCreateClick = this.handleCreateClick.bind(this); } @@ -35,9 +39,16 @@ export default class Header extends React.Component { handleCreateClick (e) { e.preventDefault(); - new CreateView({ - refresh: this.props.refresh - }).render(); + new CreateView() + .on('done', r => { + this.props.refresh().then(() => { + this.context.router.push({ + pathname: '/', + query: { id: r.permissionTemplate.id } + }) + }); + }) + .render(); } render () { diff --git a/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js b/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js index 516373a0aa9..bd6ad52409f 100644 --- a/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js +++ b/server/sonar-web/src/main/js/apps/permission-templates/views/CreateView.js @@ -34,8 +34,8 @@ export default FormView.extend({ // do not show global error 400: null } - }).done(function () { - that.options.refresh(); + }).done(function (r) { + that.trigger('done', r); that.destroy(); }).fail(function (jqXHR) { that.enableForm(); -- 2.39.5