aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/app/components
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2020-01-03 13:44:12 +0100
committerSonarTech <sonartech@sonarsource.com>2020-01-08 20:46:11 +0100
commit279deef3e8534bba914245ccf10610a459073640 (patch)
tree22cfcf63ecee905641dfd3bc76043c0cfb2843f1 /server/sonar-web/src/main/js/app/components
parent3365182508367bfcc080452d7cf932f9cfbf8c1b (diff)
downloadsonarqube-279deef3e8534bba914245ccf10610a459073640.tar.gz
sonarqube-279deef3e8534bba914245ccf10610a459073640.zip
SONAR-12429 Fix 404 when opening embedded documentation in new tab
Cherry-pick of SC-1304
Diffstat (limited to 'server/sonar-web/src/main/js/app/components')
-rw-r--r--server/sonar-web/src/main/js/app/components/AdminContainer.tsx4
-rw-r--r--server/sonar-web/src/main/js/app/components/ComponentContainerNotFound.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/NotFound.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/PageTracker.tsx3
-rw-r--r--server/sonar-web/src/main/js/app/components/__tests__/PageTracker-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap4
-rw-r--r--server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/PageTracker-test.tsx.snap8
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/Extension.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx4
-rw-r--r--server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap36
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx2
-rw-r--r--server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap2
12 files changed, 25 insertions, 52 deletions
diff --git a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx
index da7f3d83e95..43c2465e9e2 100644
--- a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx
+++ b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import Helmet from 'react-helmet';
+import { Helmet } from 'react-helmet-async';
import { connect } from 'react-redux';
import { translate } from 'sonar-ui-common/helpers/l10n';
import { getSettingsNavigation } from '../../api/nav';
@@ -120,7 +120,7 @@ export class AdminContainer extends React.PureComponent<Props, State> {
return (
<div>
- <Helmet defaultTitle={defaultTitle} titleTemplate={'%s - ' + defaultTitle} />
+ <Helmet defaultTitle={defaultTitle} defer={false} titleTemplate={`%s - ${defaultTitle}`} />
<SettingsNav
extensions={adminPages}
fetchPendingPlugins={this.fetchPendingPlugins}
diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainerNotFound.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainerNotFound.tsx
index 8ebe58c73d7..2c1210593ab 100644
--- a/server/sonar-web/src/main/js/app/components/ComponentContainerNotFound.tsx
+++ b/server/sonar-web/src/main/js/app/components/ComponentContainerNotFound.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import { Helmet } from 'react-helmet';
+import { Helmet } from 'react-helmet-async';
import { Link } from 'react-router';
import { translate } from 'sonar-ui-common/helpers/l10n';
diff --git a/server/sonar-web/src/main/js/app/components/NotFound.tsx b/server/sonar-web/src/main/js/app/components/NotFound.tsx
index 257aec5ec41..5671fd2ef35 100644
--- a/server/sonar-web/src/main/js/app/components/NotFound.tsx
+++ b/server/sonar-web/src/main/js/app/components/NotFound.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import { Helmet } from 'react-helmet';
+import { Helmet } from 'react-helmet-async';
import { Link } from 'react-router';
import { translate } from 'sonar-ui-common/helpers/l10n';
import SimpleContainer from './SimpleContainer';
diff --git a/server/sonar-web/src/main/js/app/components/PageTracker.tsx b/server/sonar-web/src/main/js/app/components/PageTracker.tsx
index cd4b9087ec8..debc7bb9253 100644
--- a/server/sonar-web/src/main/js/app/components/PageTracker.tsx
+++ b/server/sonar-web/src/main/js/app/components/PageTracker.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import Helmet from 'react-helmet';
+import { Helmet } from 'react-helmet-async';
import { connect } from 'react-redux';
import { Location, withRouter } from '../../components/hoc/withRouter';
import { gtm } from '../../helpers/analytics';
@@ -74,6 +74,7 @@ export class PageTracker extends React.Component<Props, State> {
return (
<Helmet
defaultTitle={getInstance()}
+ defer={false}
onChangeClientState={trackingIdGTM || webAnalytics ? this.trackPage : undefined}>
{this.props.children}
</Helmet>
diff --git a/server/sonar-web/src/main/js/app/components/__tests__/PageTracker-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/PageTracker-test.tsx
index e7b69acbe68..ddae1db9a74 100644
--- a/server/sonar-web/src/main/js/app/components/__tests__/PageTracker-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/__tests__/PageTracker-test.tsx
@@ -55,9 +55,7 @@ it('should work for WebAnalytics plugin', () => {
const wrapper = shallowRender({ webAnalytics });
expect(wrapper).toMatchSnapshot();
- expect(wrapper.find('HelmetWrapper').prop('onChangeClientState')).toBe(
- wrapper.instance().trackPage
- );
+ expect(wrapper.find('Helmet').prop('onChangeClientState')).toBe(wrapper.instance().trackPage);
expect(installScript).toBeCalledWith(webAnalytics, 'head');
(getWebAnalyticsPageHandlerFromCache as jest.Mock).mockReturnValueOnce(pageChange);
@@ -72,9 +70,7 @@ it('should work for Google Tag Manager', () => {
const push = jest.spyOn(dataLayer, 'push');
const wrapper = shallowRender({ trackingIdGTM: '123' });
- expect(wrapper.find('HelmetWrapper').prop('onChangeClientState')).toBe(
- wrapper.instance().trackPage
- );
+ expect(wrapper.find('Helmet').prop('onChangeClientState')).toBe(wrapper.instance().trackPage);
expect(gtm).toBeCalled();
expect(dataLayer).toHaveLength(0);
diff --git a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap
index 4763a40ec18..c7a5276bf45 100644
--- a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap
@@ -2,9 +2,9 @@
exports[`should render correctly 1`] = `
<div>
- <HelmetWrapper
+ <Helmet
defaultTitle="layout.settings"
- defer={true}
+ defer={false}
encodeSpecialCharacters={true}
titleTemplate="%s - layout.settings"
/>
diff --git a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/PageTracker-test.tsx.snap b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/PageTracker-test.tsx.snap
index ec84971fa84..b350cdcc21d 100644
--- a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/PageTracker-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/PageTracker-test.tsx.snap
@@ -1,15 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`should not trigger if no analytics system is given 1`] = `
-<HelmetWrapper
- defer={true}
+<Helmet
+ defer={false}
encodeSpecialCharacters={true}
/>
`;
exports[`should work for WebAnalytics plugin 1`] = `
-<HelmetWrapper
- defer={true}
+<Helmet
+ defer={false}
encodeSpecialCharacters={true}
onChangeClientState={[Function]}
/>
diff --git a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx
index 1d244025286..dc1a7cc5c79 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx
+++ b/server/sonar-web/src/main/js/app/components/extensions/Extension.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import Helmet from 'react-helmet';
+import { Helmet } from 'react-helmet-async';
import { InjectedIntlProps, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import { translate } from 'sonar-ui-common/helpers/l10n';
diff --git a/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx b/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx
index 05dfe881f91..fbb67eb0698 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/extensions/__tests__/Extension-test.tsx
@@ -28,6 +28,10 @@ jest.mock('../../../../helpers/extensions', () => ({
getExtensionStart: jest.fn().mockResolvedValue({})
}));
+jest.mock('react-helmet-async', () => ({
+ Helmet: () => null
+}));
+
beforeEach(() => {
jest.clearAllMocks();
});
diff --git a/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap b/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap
index 1dbd93f12a1..06877479c04 100644
--- a/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/extensions/__tests__/__snapshots__/Extension-test.tsx.snap
@@ -41,23 +41,9 @@ exports[`should render React extensions correctly 1`] = `
}
>
<div>
- <HelmetWrapper
- defer={true}
- encodeSpecialCharacters={true}
+ <Helmet
title="Foo"
- >
- <SideEffect(NullComponent)
- defer={true}
- encodeSpecialCharacters={true}
- title="Foo"
- >
- <NullComponent
- defer={true}
- encodeSpecialCharacters={true}
- title="Foo"
- />
- </SideEffect(NullComponent)>
- </HelmetWrapper>
+ />
<div />
</div>
</Extension>
@@ -104,23 +90,9 @@ exports[`should render React extensions correctly 2`] = `
}
>
<div>
- <HelmetWrapper
- defer={true}
- encodeSpecialCharacters={true}
+ <Helmet
title="Foo"
- >
- <SideEffect(NullComponent)
- defer={true}
- encodeSpecialCharacters={true}
- title="Foo"
- >
- <NullComponent
- defer={true}
- encodeSpecialCharacters={true}
- title="Foo"
- />
- </SideEffect(NullComponent)>
- </HelmetWrapper>
+ />
<div
className="extension"
/>
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx
index a719dfab390..dec1d32e10d 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx
+++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavHeader.tsx
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import Helmet from 'react-helmet';
+import { Helmet } from 'react-helmet-async';
import { BranchLike } from '../../../../types/branch-like';
import BranchLikeNavigation from './branch-like/BranchLikeNavigation';
import CurrentBranchLikeMergeInformation from './branch-like/CurrentBranchLikeMergeInformation';
diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap
index 81197bd8cc8..e230965909e 100644
--- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap
+++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavHeader-test.tsx.snap
@@ -2,7 +2,7 @@
exports[`should render correctly 1`] = `
<Fragment>
- <HelmetWrapper
+ <Helmet
defer={true}
encodeSpecialCharacters={true}
title="MyProject"