aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main
diff options
context:
space:
mode:
authorStas Vilchik <stas.vilchik@sonarsource.com>2018-08-24 10:54:41 +0200
committerSonarTech <sonartech@sonarsource.com>2018-08-27 20:21:57 +0200
commit54e30b249b4b8dab16aff328a4ca64f0fa37263c (patch)
tree1deaca04b19cd8cacb57b4e6fdfb9b3c6e13d5fe /server/sonar-web/src/main
parent76c379bdbe1ddc932a6bc80eeb9e3ead5e8107dd (diff)
downloadsonarqube-54e30b249b4b8dab16aff328a4ca64f0fa37263c.tar.gz
sonarqube-54e30b249b4b8dab16aff328a4ca64f0fa37263c.zip
SONAR-10952 Use link rel=preconnect to speed up gravatar fetching
Diffstat (limited to 'server/sonar-web/src/main')
-rw-r--r--server/sonar-web/src/main/js/app/components/App.tsx22
1 files changed, 19 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/js/app/components/App.tsx b/server/sonar-web/src/main/js/app/components/App.tsx
index 23211fbae33..22cd429689a 100644
--- a/server/sonar-web/src/main/js/app/components/App.tsx
+++ b/server/sonar-web/src/main/js/app/components/App.tsx
@@ -26,13 +26,15 @@ import { fetchLanguages } from '../../store/rootActions';
import { fetchMyOrganizations } from '../../apps/account/organizations/actions';
import { getInstance, isSonarCloud } from '../../helpers/system';
import { lazyLoad } from '../../components/lazyLoad';
-import { getCurrentUser, getAppState } from '../../store/rootReducer';
+import { getCurrentUser, getAppState, getGlobalSettingValue } from '../../store/rootReducer';
const PageTracker = lazyLoad(() => import('./PageTracker'));
interface StateProps {
appState: AppState | undefined;
currentUser: CurrentUser | undefined;
+ enableGravatar: boolean;
+ gravatarServerUrl: string;
}
interface DispatchProps {
@@ -79,10 +81,22 @@ class App extends React.PureComponent<Props> {
this.mounted = false;
}
+ renderPreconnectLink = () => {
+ const parser = document.createElement('a');
+ parser.href = this.props.gravatarServerUrl;
+ if (parser.hostname !== window.location.hostname) {
+ return <link href={parser.origin} rel="preconnect" />;
+ } else {
+ return null;
+ }
+ };
+
render() {
return (
<>
- <Helmet defaultTitle={getInstance()} />
+ <Helmet defaultTitle={getInstance()}>
+ {this.props.enableGravatar && this.renderPreconnectLink()}
+ </Helmet>
{isSonarCloud() && <PageTracker />}
{this.props.children}
</>
@@ -92,7 +106,9 @@ class App extends React.PureComponent<Props> {
const mapStateToProps = (state: any): StateProps => ({
appState: getAppState(state),
- currentUser: getCurrentUser(state)
+ currentUser: getCurrentUser(state),
+ enableGravatar: (getGlobalSettingValue(state, 'sonar.lf.enableGravatar') || {}).value === 'true',
+ gravatarServerUrl: (getGlobalSettingValue(state, 'sonar.lf.gravatarServerUrl') || {}).value || ''
});
const mapDispatchToProps = ({