aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorGuillaume Peoc'h <guillaume.peoch@sonarsource.com>2022-05-24 14:23:09 +0200
committersonartech <sonartech@sonarsource.com>2022-05-24 20:10:14 +0000
commit28852b57ef5d80596d8e98bee00a6e6a0d0c611b (patch)
treed607bb66754f00627bdc6401a0f7f241569014b6 /server
parentb66ff887e1ad3a81ef438a3832818e61c03eebd7 (diff)
downloadsonarqube-28852b57ef5d80596d8e98bee00a6e6a0d0c611b.tar.gz
sonarqube-28852b57ef5d80596d8e98bee00a6e6a0d0c611b.zip
SONAR-16426 Remove SonarCloud code (frontend)
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx6
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/components/App.tsx10
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx8
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/components/PermissionCell.tsx7
-rw-r--r--server/sonar-web/src/main/js/apps/permissions/__tests__/utils-test.ts35
-rw-r--r--server/sonar-web/src/main/js/apps/permissions/utils.ts14
-rw-r--r--server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx3
-rw-r--r--server/sonar-web/src/main/js/components/docs/DocLink.tsx24
-rw-r--r--server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx8
-rw-r--r--server/sonar-web/src/main/js/components/docs/__tests__/DocLink-test.tsx46
-rw-r--r--server/sonar-web/src/main/js/components/docs/__tests__/DocTooltipLink-test.tsx2
-rw-r--r--server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocLink-test.tsx.snap36
-rw-r--r--server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocTooltipLink-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/helpers/__tests__/__snapshots__/markdown-test.ts.snap28
-rw-r--r--server/sonar-web/src/main/js/helpers/__tests__/markdown-test.ts7
-rw-r--r--server/sonar-web/src/main/js/helpers/markdown.js13
-rw-r--r--server/sonar-web/src/main/js/helpers/system.ts5
18 files changed, 21 insertions, 235 deletions
diff --git a/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.tsx
index 7758e327c69..afacff7897a 100644
--- a/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.tsx
+++ b/server/sonar-web/src/main/js/app/components/__tests__/GlobalFooter-test.tsx
@@ -23,8 +23,6 @@ import { mockAppState } from '../../../helpers/testMocks';
import { EditionKey } from '../../../types/editions';
import { GlobalFooter, GlobalFooterProps } from '../GlobalFooter';
-jest.mock('../../../helpers/system', () => ({ isSonarCloud: jest.fn() }));
-
it('should render the only logged in information', () => {
expect(getWrapper()).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx
index d257d1e82d1..6cad88399d1 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx
@@ -21,7 +21,6 @@ import * as React from 'react';
import HomePageSelect from '../../../components/controls/HomePageSelect';
import PageShortcutsTooltip from '../../../components/ui/PageShortcutsTooltip';
import { translate } from '../../../helpers/l10n';
-import { isSonarCloud } from '../../../helpers/system';
import { Paging } from '../../../types/types';
import IssuesCounter from './IssuesCounter';
import TotalEffort from './TotalEffort';
@@ -49,10 +48,7 @@ export default function PageActions(props: PageActionsProps) {
</div>
{canSetHome && (
- <HomePageSelect
- className="huge-spacer-left"
- currentPage={isSonarCloud() ? { type: 'MY_ISSUES' } : { type: 'ISSUES' }}
- />
+ <HomePageSelect className="huge-spacer-left" currentPage={{ type: 'ISSUES' }} />
)}
</div>
);
diff --git a/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx b/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx
index ef134d4fd88..7cf60e0d92e 100644
--- a/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/maintenance/components/App.tsx
@@ -27,7 +27,7 @@ import { Button } from '../../../components/controls/buttons';
import DateFromNow from '../../../components/intl/DateFromNow';
import TimeFormatter from '../../../components/intl/TimeFormatter';
import { translate } from '../../../helpers/l10n';
-import { getBaseUrl, isSonarCloud } from '../../../helpers/system';
+import { getBaseUrl } from '../../../helpers/system';
import { getReturnUrl } from '../../../helpers/urls';
import '../styles.css';
@@ -145,11 +145,9 @@ export default class App extends React.PureComponent<Props, State> {
<h1 className="maintenance-title text-danger">
<InstanceMessage message={translate('maintenance.is_offline')} />
</h1>
- {!isSonarCloud() && (
- <p className="maintenance-text">
- {translate('maintenance.sonarqube_is_offline.text')}
- </p>
- )}
+ <p className="maintenance-text">
+ {translate('maintenance.sonarqube_is_offline.text')}
+ </p>
<p className="maintenance-text text-center">
<a href={getBaseUrl() + '/'}>{translate('maintenance.try_again')}</a>
</p>
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx
index e9e3c018fce..505ed021c24 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/App-test.tsx
@@ -19,13 +19,10 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { isSonarCloud } from '../../../../helpers/system';
import { mockAppState } from '../../../../helpers/testMocks';
import BranchOverview from '../../branches/BranchOverview';
import { App } from '../App';
-jest.mock('../../../../helpers/system', () => ({ isSonarCloud: jest.fn() }));
-
const component = {
key: 'foo',
analysisDate: '2016-01-01',
@@ -35,11 +32,6 @@ const component = {
version: '0.0.1'
};
-beforeEach(() => {
- (isSonarCloud as jest.Mock<any>).mockClear();
- (isSonarCloud as jest.Mock<any>).mockReturnValue(false);
-});
-
it('should render BranchOverview', () => {
expect(
getWrapper()
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionCell.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionCell.tsx
index fbf33ad3dad..8c80d57dc49 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionCell.tsx
+++ b/server/sonar-web/src/main/js/apps/permission-templates/components/PermissionCell.tsx
@@ -20,7 +20,6 @@
import * as React from 'react';
import HelpTooltip from '../../../components/controls/HelpTooltip';
import { translate } from '../../../helpers/l10n';
-import { isSonarCloud } from '../../../helpers/system';
interface Props {
permission: {
@@ -41,11 +40,7 @@ export default function PermissionCell({ permission: p }: Props) {
{translate('permission_templates.project_creators')}
<HelpTooltip
className="little-spacer-left"
- overlay={translate(
- isSonarCloud()
- ? 'permission_templates.project_creators.explanation.sonarcloud'
- : 'permission_templates.project_creators.explanation'
- )}
+ overlay={translate('permission_templates.project_creators.explanation')}
/>
</li>
)}
diff --git a/server/sonar-web/src/main/js/apps/permissions/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/permissions/__tests__/utils-test.ts
index 72e28f5ac38..c322579fe2d 100644
--- a/server/sonar-web/src/main/js/apps/permissions/__tests__/utils-test.ts
+++ b/server/sonar-web/src/main/js/apps/permissions/__tests__/utils-test.ts
@@ -17,19 +17,14 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { isSonarCloud } from '../../../helpers/system';
import { convertToPermissionDefinitions } from '../utils';
-jest.mock('../../../helpers/system', () => ({ isSonarCloud: jest.fn() }));
-
jest.mock('../../../helpers/l10nBundle', () => ({
getMessages: jest.fn().mockReturnValue({})
}));
describe('convertToPermissionDefinitions', () => {
it('should convert and translate a permission definition', () => {
- (isSonarCloud as jest.Mock).mockImplementation(() => false);
-
const data = convertToPermissionDefinitions(['admin'], 'global_permissions');
const expected = [
{
@@ -41,34 +36,4 @@ describe('convertToPermissionDefinitions', () => {
expect(data).toEqual(expected);
});
-
- it('should convert and translate a permission definition for SonarCloud', () => {
- (isSonarCloud as jest.Mock).mockImplementation(() => true);
-
- const data = convertToPermissionDefinitions(['admin'], 'global_permissions');
- const expected = [
- {
- description: 'global_permissions.admin.desc.sonarcloud',
- key: 'admin',
- name: 'global_permissions.admin.sonarcloud'
- }
- ];
-
- expect(data).toEqual(expected);
- });
-
- it('should fallback to basic message when SonarCloud version does not exist', () => {
- (isSonarCloud as jest.Mock).mockImplementation(() => true);
-
- const data = convertToPermissionDefinitions(['admin'], 'global_permissions');
- const expected = [
- {
- description: 'global_permissions.admin.desc.sonarcloud',
- key: 'admin',
- name: 'global_permissions.admin.sonarcloud'
- }
- ];
-
- expect(data).toEqual(expected);
- });
});
diff --git a/server/sonar-web/src/main/js/apps/permissions/utils.ts b/server/sonar-web/src/main/js/apps/permissions/utils.ts
index 6bd1494c907..2fe4d741417 100644
--- a/server/sonar-web/src/main/js/apps/permissions/utils.ts
+++ b/server/sonar-web/src/main/js/apps/permissions/utils.ts
@@ -17,8 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { hasMessage, translate } from '../../helpers/l10n';
-import { isSonarCloud } from '../../helpers/system';
+import { translate } from '../../helpers/l10n';
import { Dict, PermissionDefinition, PermissionDefinitionGroup } from '../../types/types';
export const PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE = [
@@ -50,15 +49,8 @@ export const PERMISSIONS_ORDER_BY_QUALIFIER: Dict<string[]> = {
};
function convertToPermissionDefinition(permission: string, l10nPrefix: string) {
- const getMessage = (messageKey: string) => {
- const cloudMessageKey = `${messageKey}.sonarcloud`;
- return isSonarCloud() && hasMessage(cloudMessageKey)
- ? translate(cloudMessageKey)
- : translate(messageKey);
- };
-
- const name = getMessage(`${l10nPrefix}.${permission}`);
- const description = getMessage(`${l10nPrefix}.${permission}.desc`);
+ const name = translate(`${l10nPrefix}.${permission}`);
+ const description = translate(`${l10nPrefix}.${permission}.desc`);
return {
key: permission,
diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx
index f260ef4f5c8..fb55e6dee3b 100644
--- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx
+++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Header-test.tsx
@@ -23,8 +23,7 @@ import { click } from '../../../helpers/testUtils';
import Header, { Props } from '../Header';
jest.mock('../../../helpers/system', () => ({
- getReactDomContainerSelector: jest.fn(() => '#content'),
- isSonarCloud: jest.fn().mockReturnValue(false)
+ getReactDomContainerSelector: jest.fn(() => '#content')
}));
it('renders', () => {
diff --git a/server/sonar-web/src/main/js/components/docs/DocLink.tsx b/server/sonar-web/src/main/js/components/docs/DocLink.tsx
index 77e6cbd833c..1e1c556665a 100644
--- a/server/sonar-web/src/main/js/components/docs/DocLink.tsx
+++ b/server/sonar-web/src/main/js/components/docs/DocLink.tsx
@@ -21,7 +21,6 @@ import * as React from 'react';
import { Link } from 'react-router';
import withAppStateContext from '../../app/components/app-state/withAppStateContext';
import DetachIcon from '../../components/icons/DetachIcon';
-import { isSonarCloud } from '../../helpers/system';
import { AppState } from '../../types/appstate';
interface OwnProps {
@@ -33,7 +32,6 @@ interface OwnProps {
type Props = OwnProps & React.AnchorHTMLAttributes<HTMLAnchorElement>;
-const SONARCLOUD_LINK = '/#sonarcloud#/';
const SONARQUBE_LINK = '/#sonarqube#/';
const SONARQUBE_ADMIN_LINK = '/#sonarqube-admin#/';
@@ -56,9 +54,7 @@ export class DocLink extends React.PureComponent<Props> {
}
if (href && href.startsWith('/')) {
- if (href.startsWith(SONARCLOUD_LINK)) {
- return <SonarCloudLink url={href}>{children}</SonarCloudLink>;
- } else if (href.startsWith(SONARQUBE_LINK)) {
+ if (href.startsWith(SONARQUBE_LINK)) {
return <SonarQubeLink url={href}>{children}</SonarQubeLink>;
} else if (href.startsWith(SONARQUBE_ADMIN_LINK)) {
return (
@@ -91,28 +87,12 @@ export class DocLink extends React.PureComponent<Props> {
export default withAppStateContext(DocLink);
-interface SonarCloudLinkProps {
- children: React.ReactNode;
- url: string;
-}
-
-function SonarCloudLink({ children, url }: SonarCloudLinkProps) {
- if (!isSonarCloud()) {
- return <>{children}</>;
- }
- const to = `/${url.substr(SONARCLOUD_LINK.length)}`;
- return <Link to={to}>{children}</Link>;
-}
-
interface SonarQubeLinkProps {
children: React.ReactNode;
url: string;
}
function SonarQubeLink({ children, url }: SonarQubeLinkProps) {
- if (isSonarCloud()) {
- return <>{children}</>;
- }
const to = `/${url.substr(SONARQUBE_LINK.length)}`;
return (
<Link target="_blank" to={to}>
@@ -128,7 +108,7 @@ interface SonarQubeAdminLinkProps {
}
function SonarQubeAdminLink({ canAdmin, children, url }: SonarQubeAdminLinkProps) {
- if (isSonarCloud() || !canAdmin) {
+ if (!canAdmin) {
return <>{children}</>;
}
const to = `/${url.substr(SONARQUBE_ADMIN_LINK.length)}`;
diff --git a/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx b/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx
index e53e5dcf458..eb29f9be7aa 100644
--- a/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx
+++ b/server/sonar-web/src/main/js/components/docs/DocTooltipLink.tsx
@@ -29,8 +29,6 @@ interface OwnProps {
type Props = OwnProps & React.AnchorHTMLAttributes<HTMLAnchorElement>;
-const SONARCLOUD_LINK = '/#sonarcloud#/';
-
export default function DocTooltipLink({ children, customProps, href, ...other }: Props) {
if (customProps) {
forEach(customProps, (value, key) => {
@@ -41,11 +39,7 @@ export default function DocTooltipLink({ children, customProps, href, ...other }
}
if (href && href.startsWith('/')) {
- if (href.startsWith(SONARCLOUD_LINK)) {
- href = `/${href.substr(SONARCLOUD_LINK.length)}`;
- } else {
- href = `/documentation/${href.substr(1)}`;
- }
+ href = `/documentation/${href.substr(1)}`;
return (
<Link rel="noopener noreferrer" target="_blank" to={href} {...other}>
diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/DocLink-test.tsx b/server/sonar-web/src/main/js/components/docs/__tests__/DocLink-test.tsx
index 86e613815e0..fbc71124d70 100644
--- a/server/sonar-web/src/main/js/components/docs/__tests__/DocLink-test.tsx
+++ b/server/sonar-web/src/main/js/components/docs/__tests__/DocLink-test.tsx
@@ -19,14 +19,9 @@
*/
import { shallow } from 'enzyme';
import * as React from 'react';
-import { isSonarCloud } from '../../../helpers/system';
import { mockAppState } from '../../../helpers/testMocks';
import { DocLink } from '../DocLink';
-jest.mock('../../../helpers/system', () => ({
- isSonarCloud: jest.fn(() => false)
-}));
-
it('should render simple link', () => {
expect(
shallow(
@@ -47,27 +42,6 @@ it('should render documentation link', () => {
).toMatchSnapshot();
});
-it('should render sonarcloud link on sonarcloud', () => {
- (isSonarCloud as jest.Mock).mockImplementationOnce(() => true);
- const wrapper = shallow(
- <DocLink appState={mockAppState({ canAdmin: false })} href="/#sonarcloud#/foo/bar">
- link text
- </DocLink>
- );
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.find('SonarCloudLink').dive()).toMatchSnapshot();
-});
-
-it('should not render sonarcloud link on sonarcloud', () => {
- (isSonarCloud as jest.Mock).mockImplementationOnce(() => false);
- const wrapper = shallow(
- <DocLink appState={mockAppState({ canAdmin: false })} href="/#sonarcloud#/foo/bar">
- link text
- </DocLink>
- );
- expect(wrapper.find('SonarCloudLink').dive()).toMatchSnapshot();
-});
-
it('should render sonarqube link on sonarqube', () => {
const wrapper = shallow(
<DocLink appState={mockAppState({ canAdmin: false })} href="/#sonarqube#/foo/bar">
@@ -78,16 +52,6 @@ it('should render sonarqube link on sonarqube', () => {
expect(wrapper.find('SonarQubeLink').dive()).toMatchSnapshot();
});
-it('should not render sonarqube link on sonarcloud', () => {
- (isSonarCloud as jest.Mock).mockImplementationOnce(() => true);
- const wrapper = shallow(
- <DocLink appState={mockAppState({ canAdmin: false })} href="/#sonarqube#/foo/bar">
- link text
- </DocLink>
- );
- expect(wrapper.find('SonarQubeLink').dive()).toMatchSnapshot();
-});
-
it('should render sonarqube admin link on sonarqube for admin', () => {
const wrapper = shallow(
<DocLink appState={mockAppState({ canAdmin: true })} href="/#sonarqube-admin#/foo/bar">
@@ -107,16 +71,6 @@ it('should not render sonarqube admin link on sonarqube for non-admin', () => {
expect(wrapper.find('SonarQubeAdminLink').dive()).toMatchSnapshot();
});
-it('should not render sonarqube admin link on sonarcloud', () => {
- (isSonarCloud as jest.Mock).mockImplementationOnce(() => true);
- const wrapper = shallow(
- <DocLink appState={mockAppState({ canAdmin: true })} href="/#sonarqube-admin#/foo/bar">
- link text
- </DocLink>
- );
- expect(wrapper.find('SonarQubeAdminLink').dive()).toMatchSnapshot();
-});
-
it('should render documentation anchor', () => {
expect(
shallow(
diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/DocTooltipLink-test.tsx b/server/sonar-web/src/main/js/components/docs/__tests__/DocTooltipLink-test.tsx
index 6a6dd117779..632d4d31af6 100644
--- a/server/sonar-web/src/main/js/components/docs/__tests__/DocTooltipLink-test.tsx
+++ b/server/sonar-web/src/main/js/components/docs/__tests__/DocTooltipLink-test.tsx
@@ -31,6 +31,6 @@ it('should render internal link', () => {
it('should render links with custom props', () => {
expect(
- shallow(<DocTooltipLink customProps={{ bar: 'baz' }} href="/#sonarcloud#/foo/#bar#" />)
+ shallow(<DocTooltipLink customProps={{ bar: 'baz' }} href="/foo/#bar#" />)
).toMatchSnapshot();
});
diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocLink-test.tsx.snap b/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocLink-test.tsx.snap
index 3b3db3ba938..a9918c0b752 100644
--- a/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocLink-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocLink-test.tsx.snap
@@ -1,29 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`should not render sonarcloud link on sonarcloud 1`] = `
-<Fragment>
- link text
-</Fragment>
-`;
-
-exports[`should not render sonarqube admin link on sonarcloud 1`] = `
-<Fragment>
- link text
-</Fragment>
-`;
-
exports[`should not render sonarqube admin link on sonarqube for non-admin 1`] = `
<Fragment>
link text
</Fragment>
`;
-exports[`should not render sonarqube link on sonarcloud 1`] = `
-<Fragment>
- link text
-</Fragment>
-`;
-
exports[`should render documentation anchor 1`] = `
<a
href="#"
@@ -59,24 +41,6 @@ exports[`should render simple link 1`] = `
</Fragment>
`;
-exports[`should render sonarcloud link on sonarcloud 1`] = `
-<SonarCloudLink
- url="/#sonarcloud#/foo/bar"
->
- link text
-</SonarCloudLink>
-`;
-
-exports[`should render sonarcloud link on sonarcloud 2`] = `
-<Link
- onlyActiveOnIndex={false}
- style={Object {}}
- to="/foo/bar"
->
- link text
-</Link>
-`;
-
exports[`should render sonarqube admin link on sonarqube for admin 1`] = `
<SonarQubeAdminLink
canAdmin={true}
diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocTooltipLink-test.tsx.snap b/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocTooltipLink-test.tsx.snap
index be9b357e261..4d7250e364e 100644
--- a/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocTooltipLink-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/docs/__tests__/__snapshots__/DocTooltipLink-test.tsx.snap
@@ -16,7 +16,7 @@ exports[`should render links with custom props 1`] = `
rel="noopener noreferrer"
style={Object {}}
target="_blank"
- to="/foo/baz"
+ to="/documentation/foo/baz"
/>
`;
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/__snapshots__/markdown-test.ts.snap b/server/sonar-web/src/main/js/helpers/__tests__/__snapshots__/markdown-test.ts.snap
index 74dd4b87a03..cdc1f9a74e0 100644
--- a/server/sonar-web/src/main/js/helpers/__tests__/__snapshots__/markdown-test.ts.snap
+++ b/server/sonar-web/src/main/js/helpers/__tests__/__snapshots__/markdown-test.ts.snap
@@ -28,34 +28,6 @@ Duis sagittis semper sapien nec tempor. Nullam vehicula nisi vitae nisi interdum
"
`;
-exports[`should cut sonarqube/sonarcloud/static content 2`] = `
-"
-This text has inline text for SonarCloud. Donec sed nulla magna.
-
-
-
-This is text for SonarCloud, multi-line. In hac habitasse platea dictumst. Duis sagittis semper sapien nec tempor. Nullam vehicula nisi vitae nisi interdum aliquam. Mauris volutpat nunc non fermentum rhoncus. Aenean laoreet, orci vitae tempor bibendum,
-metus nisl euismod neque, vitae euismod nibh nisl eu velit. Vivamus luctus suscipit elit vel semper.
-
-
-
-
-
-* In hac habitasse
-* Duis sagittis semper sapien nec tempor
-
-* This is a bullet point for SonarCloud
-* Platea dictumst
-
-Duis sagittis semper sapien nec tempor. Nullam vehicula nisi vitae nisi interdum aliquam.
-
-| Parameter Name | Description |
-| --------------------- | ------------------ |
-| sonar.pullrequest.github.repository | SLUG of the GitHub Repo |
-
-"
-`;
-
exports[`should not break when conditional tags are misused 1`] = `
"Random SC text
Break
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/markdown-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/markdown-test.ts
index 9915c17fe52..b4201f41bb6 100644
--- a/server/sonar-web/src/main/js/helpers/__tests__/markdown-test.ts
+++ b/server/sonar-web/src/main/js/helpers/__tests__/markdown-test.ts
@@ -19,11 +19,9 @@
*/
/* eslint-disable no-console */
import { filterContent, getFrontMatter, separateFrontMatter } from '../markdown';
-import { isSonarCloud } from '../system';
jest.mock('../system', () => ({
- getInstance: () => 'SonarQube',
- isSonarCloud: jest.fn().mockReturnValue(false)
+ getInstance: () => 'SonarQube'
}));
it('returns parsed frontmatter of one item', () => {
@@ -158,9 +156,6 @@ Duis sagittis semper sapien nec tempor. Nullam vehicula nisi vitae nisi interdum
`;
expect(filterContent(content)).toMatchSnapshot();
-
- (isSonarCloud as jest.Mock).mockReturnValueOnce(true);
- expect(filterContent(content)).toMatchSnapshot();
});
it('should not break when conditional tags are misused', () => {
diff --git a/server/sonar-web/src/main/js/helpers/markdown.js b/server/sonar-web/src/main/js/helpers/markdown.js
index 075e10230e9..6701d972642 100644
--- a/server/sonar-web/src/main/js/helpers/markdown.js
+++ b/server/sonar-web/src/main/js/helpers/markdown.js
@@ -33,9 +33,8 @@ function separateFrontMatter(content) {
const frontmatter = parseFrontMatter(lines.slice(position.firstLine + 1, position.lastLine));
const content = lines.slice(position.lastLine + 1).join('\n');
return { frontmatter, content };
- } else {
- return { frontmatter: {}, content };
}
+ return { frontmatter: {}, content };
}
function getFrontMatterPosition(lines) {
@@ -57,8 +56,8 @@ function getFrontMatterPosition(lines) {
function parseFrontMatter(lines) {
const data = {};
- for (let i = 0; i < lines.length; i++) {
- const tokens = lines[i].split(':').map(x => x.trim());
+ for (const element of lines) {
+ const tokens = element.split(':').map(x => x.trim());
if (tokens.length === 2) {
data[tokens[0]] = tokens[1];
}
@@ -72,12 +71,10 @@ function parseFrontMatter(lines) {
*/
function filterContent(content) {
const regexBase = '<!-- \\/?(sonarqube|sonarcloud|static) -->';
- const { isSonarCloud, getInstance } = require('./system');
+ const { getInstance } = require('./system');
const contentWithInstance = content.replace(/{instance}/gi, getInstance());
const contentWithoutStatic = cutConditionalContent(contentWithInstance, 'static');
- const filteredContent = isSonarCloud()
- ? cutConditionalContent(contentWithoutStatic, 'sonarqube')
- : cutConditionalContent(contentWithoutStatic, 'sonarcloud');
+ const filteredContent = cutConditionalContent(contentWithoutStatic, 'sonarcloud');
return filteredContent
.replace(new RegExp(`^${regexBase}(\n|\r|\r\n|$)`, 'gm'), '') // First, remove single-line ones, including ending carriage-returns.
.replace(new RegExp(`${regexBase}`, 'g'), ''); // Now remove all remaining ones.
diff --git a/server/sonar-web/src/main/js/helpers/system.ts b/server/sonar-web/src/main/js/helpers/system.ts
index 9a78a7c03e1..54da1b6b7d5 100644
--- a/server/sonar-web/src/main/js/helpers/system.ts
+++ b/server/sonar-web/src/main/js/helpers/system.ts
@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { InstanceType } from '../types/system';
import { getEnhancedWindow } from './browser';
export function getBaseUrl() {
@@ -36,10 +35,6 @@ export function isOfficial() {
return getEnhancedWindow().official;
}
-export function isSonarCloud() {
- return getInstance() === InstanceType.SonarCloud;
-}
-
export function getReactDomContainerSelector() {
return '#content';
}