aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-01-10 17:25:05 +0100
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-01-25 15:16:50 +0100
commitaddc88f96fb4b873d66ea32df433e98be741d7c7 (patch)
tree277a2e78dcf28d9a7f7ba70d385a95d2224b21b6 /server/sonar-web/src/main/js
parenta2749f6e52fbb1b46263383f0f4cf39ce5d4c418 (diff)
downloadsonarqube-addc88f96fb4b873d66ea32df433e98be741d7c7.tar.gz
sonarqube-addc88f96fb4b873d66ea32df433e98be741d7c7.zip
Create a getHostUrl function in the urls helper
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js15
-rw-r--r--server/sonar-web/src/main/js/helpers/urls.ts4
2 files changed, 11 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js
index 51d5195fc4b..885ec7e2754 100644
--- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js
+++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js
@@ -29,6 +29,7 @@ import Msvc from './commands/Msvc';
import ClangGCC from './commands/ClangGCC';
import Other from './commands/Other';
import { translate } from '../../../helpers/l10n';
+import { getHostUrl } from '../../../helpers/urls';
/*::
type Props = {|
@@ -63,8 +64,6 @@ export default class AnalysisStep extends React.PureComponent {
this.props.onReset();
};
- getHost = () => window.location.origin + window.baseUrl;
-
renderForm = () => {
return (
<div className="boxed-group-inner">
@@ -111,7 +110,7 @@ export default class AnalysisStep extends React.PureComponent {
renderCommandForMaven = () => (
<JavaMaven
- host={this.getHost()}
+ host={getHostUrl()}
organization={this.props.organization}
token={this.props.token}
/>
@@ -119,7 +118,7 @@ export default class AnalysisStep extends React.PureComponent {
renderCommandForGradle = () => (
<JavaGradle
- host={this.getHost()}
+ host={getHostUrl()}
organization={this.props.organization}
token={this.props.token}
/>
@@ -128,7 +127,7 @@ export default class AnalysisStep extends React.PureComponent {
renderCommandForDotNet = () => {
return (
<DotNet
- host={this.getHost()}
+ host={getHostUrl()}
organization={this.props.organization}
// $FlowFixMe
projectKey={this.state.result.projectKey}
@@ -140,7 +139,7 @@ export default class AnalysisStep extends React.PureComponent {
renderCommandForMSVC = () => {
return (
<Msvc
- host={this.getHost()}
+ host={getHostUrl()}
organization={this.props.organization}
// $FlowFixMe
projectKey={this.state.result.projectKey}
@@ -151,7 +150,7 @@ export default class AnalysisStep extends React.PureComponent {
renderCommandForClangGCC = () => (
<ClangGCC
- host={this.getHost()}
+ host={getHostUrl()}
organization={this.props.organization}
// $FlowFixMe
os={this.state.result.os}
@@ -163,7 +162,7 @@ export default class AnalysisStep extends React.PureComponent {
renderCommandForOther = () => (
<Other
- host={this.getHost()}
+ host={getHostUrl()}
organization={this.props.organization}
// $FlowFixMe
os={this.state.result.os}
diff --git a/server/sonar-web/src/main/js/helpers/urls.ts b/server/sonar-web/src/main/js/helpers/urls.ts
index be7d4b660dc..51666283ff8 100644
--- a/server/sonar-web/src/main/js/helpers/urls.ts
+++ b/server/sonar-web/src/main/js/helpers/urls.ts
@@ -36,6 +36,10 @@ export function getBaseUrl(): string {
return (window as any).baseUrl;
}
+export function getHostUrl(): string {
+ return window.location.origin + getBaseUrl();
+}
+
export function getPathUrlAsString(path: Location): string {
return `${getBaseUrl()}${path.pathname}?${stringify(omitBy(path.query, isNil))}`;
}