aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-10-03 15:46:17 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-10-04 12:02:16 +0200
commita816f8904d4a9474308845537a85ff64f71156b7 (patch)
treee354fca54345420a582ba34ec75b6a4a8e377679
parente6fc6203ef5bc20ad583c1f6bb06169b38b9cec9 (diff)
downloadsonarqube-a816f8904d4a9474308845537a85ff64f71156b7.tar.gz
sonarqube-a816f8904d4a9474308845537a85ff64f71156b7.zip
SONAR-9446 Redirect to previous page after server start/migration
-rw-r--r--server/sonar-web/src/main/js/app/components/MigrationContainer.js13
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/init.js4
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/main-view.js8
5 files changed, 26 insertions, 15 deletions
diff --git a/server/sonar-web/src/main/js/app/components/MigrationContainer.js b/server/sonar-web/src/main/js/app/components/MigrationContainer.js
index ef24c09e991..04055272af3 100644
--- a/server/sonar-web/src/main/js/app/components/MigrationContainer.js
+++ b/server/sonar-web/src/main/js/app/components/MigrationContainer.js
@@ -27,20 +27,23 @@ class MigrationContainer extends React.PureComponent {
/*::
props: {
children?: React.Element<*>,
- router: { push: (path: string) => void }
+ router: { push: ({ pathname: string, query?: { return_to: string } }) => void }
};
*/
- state = {
- loading: true
- };
+ state = { loading: true };
componentDidMount() {
getSystemStatus().then(r => {
if (r.status === 'UP') {
this.setState({ loading: false });
} else {
- this.props.router.push('/maintenance');
+ this.props.router.push({
+ pathname: '/maintenance',
+ query: {
+ return_to: window.location.pathname + window.location.search + window.location.hash
+ }
+ });
}
});
}
diff --git a/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx b/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx
index 923d805efd7..58f06438b41 100644
--- a/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/maintenance/components/MaintenanceAppContainer.tsx
@@ -20,9 +20,13 @@
import * as React from 'react';
import init from '../init';
-export default class MaintenanceAppContainer extends React.PureComponent {
+interface Props {
+ location: { query: { return_to: string } };
+}
+
+export default class MaintenanceAppContainer extends React.PureComponent<Props> {
componentDidMount() {
- init(this.refs.container, false);
+ init(this.refs.container, false, this.props.location.query['return_to']);
}
render() {
diff --git a/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx b/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx
index 398ebb69fd6..eeb57f47fe4 100644
--- a/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/maintenance/components/SetupAppContainer.tsx
@@ -20,9 +20,13 @@
import * as React from 'react';
import init from '../init';
-export default class SetupAppContainer extends React.PureComponent {
+interface Props {
+ location: { query: { return_to: string } };
+}
+
+export default class SetupAppContainer extends React.PureComponent<Props> {
componentDidMount() {
- init(this.refs.container, true);
+ init(this.refs.container, true, this.props.location.query['return_to']);
}
render() {
diff --git a/server/sonar-web/src/main/js/apps/maintenance/init.js b/server/sonar-web/src/main/js/apps/maintenance/init.js
index 3d86d8fc881..e71347b423b 100644
--- a/server/sonar-web/src/main/js/apps/maintenance/init.js
+++ b/server/sonar-web/src/main/js/apps/maintenance/init.js
@@ -32,6 +32,6 @@ App.on('start', options => {
mainView.render().refresh();
});
-export default function(el, setup) {
- App.start({ el, setup });
+export default function(el, setup, returnTo) {
+ App.start({ el, setup, returnTo });
}
diff --git a/server/sonar-web/src/main/js/apps/maintenance/main-view.js b/server/sonar-web/src/main/js/apps/maintenance/main-view.js
index 68b234721bf..26ed8f944ba 100644
--- a/server/sonar-web/src/main/js/apps/maintenance/main-view.js
+++ b/server/sonar-web/src/main/js/apps/maintenance/main-view.js
@@ -51,10 +51,10 @@ export default Marionette.ItemView.extend({
this.stopPolling();
}
if (this.model.get('status') === 'UP' && this.wasStarting) {
- this.goHome();
+ this.loadPreviousPage();
}
if (this.model.get('state') === 'MIGRATION_SUCCEEDED') {
- this.goHome();
+ this.loadPreviousPage();
}
});
},
@@ -80,9 +80,9 @@ export default Marionette.ItemView.extend({
);
},
- goHome() {
+ loadPreviousPage() {
setInterval(() => {
- window.location = window.baseUrl + '/';
+ window.location = window.baseUrl + (this.options.returnTo || '/');
}, 2500);
},