aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-docs/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-docs/src/components')
-rw-r--r--server/sonar-docs/src/components/PluginMetaData.tsx175
-rw-r--r--server/sonar-docs/src/components/PluginVersionMetaData.tsx118
-rw-r--r--server/sonar-docs/src/components/UpdateCenterMetaDataInjector.tsx132
-rw-r--r--server/sonar-docs/src/components/__tests__/PluginMetaData-test.tsx81
-rw-r--r--server/sonar-docs/src/components/__tests__/PluginVersionMetaData-test.tsx77
-rw-r--r--server/sonar-docs/src/components/__tests__/UpdateCenterMetaDataInjector-test.tsx55
-rw-r--r--server/sonar-docs/src/components/__tests__/__snapshots__/PluginMetaData-test.tsx.snap11
-rw-r--r--server/sonar-docs/src/components/__tests__/__snapshots__/PluginVersionMetaData-test.tsx.snap93
-rw-r--r--server/sonar-docs/src/components/__tests__/__snapshots__/UpdateCenterMetaDataInjector-test.tsx.snap39
-rw-r--r--server/sonar-docs/src/components/utils.tsx16
10 files changed, 226 insertions, 571 deletions
diff --git a/server/sonar-docs/src/components/PluginMetaData.tsx b/server/sonar-docs/src/components/PluginMetaData.tsx
deleted file mode 100644
index b62678c26c8..00000000000
--- a/server/sonar-docs/src/components/PluginMetaData.tsx
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import * as React from 'react';
-import { createPortal } from 'react-dom';
-import { Dict, PluginMetaDataInfo } from '../@types/types';
-import PluginVersionMetaData from './PluginVersionMetaData';
-import { getPluginMetaData } from './utils';
-
-interface Props {
- location: Pick<Location, 'pathname'>;
-}
-
-interface State {
- data: Dict<PluginMetaDataInfo>;
- wrappers: Dict<HTMLDivElement>;
-}
-
-export default class PluginMetaData extends React.Component<Props, State> {
- state: State = {
- data: {},
- wrappers: {}
- };
-
- componentDidMount() {
- this.searchForCommentNodes();
- }
-
- componentDidUpdate({ location }: Props) {
- if (location.pathname !== this.props.location.pathname) {
- this.clearWrapperNodes();
- this.searchForCommentNodes();
- }
- }
-
- clearWrapperNodes = () => {
- const { wrappers } = this.state;
-
- Object.keys(wrappers).forEach(key => {
- const node = wrappers[key];
- const { parentNode } = node;
- if (parentNode) {
- parentNode.removeChild(node);
- }
-
- delete wrappers[key];
- });
-
- this.setState({ data: {}, wrappers: {} });
- };
-
- fetchAndRender = () => {
- const { wrappers } = this.state;
-
- Object.keys(wrappers).forEach(key => {
- getPluginMetaData(key).then(
- (payload: PluginMetaDataInfo) => {
- this.setState(({ data }) => ({ data: { ...data, [key]: payload } }));
- },
- () => {}
- );
- });
- };
-
- searchForCommentNodes = () => {
- const pageContainer = document.querySelector('.page-container');
-
- if (pageContainer) {
- // The following uses an older syntax for createNodeIterator() in order
- // to support IE11
- // - IE doesn't support the new { acceptNode: (node: Node) => number }
- // format for the 3rd parameter, and instead expects to get it passed
- // the function directly. Modern browsers support both paradigms as a
- // fallback, so we fallback to the old one.
- // - IE11 requires the 4th argument.
- // @ts-ignore: tsc requires an additional comment at the function call.
- const iterator = document.createNodeIterator(
- pageContainer,
- NodeFilter.SHOW_COMMENT,
- // @ts-ignore: IE11 doesn't support the { acceptNode: () => number } format.
- (_: Node) => NodeFilter.FILTER_ACCEPT,
- // @ts-ignore: IE11 requires the 4th argument.
- false
- );
-
- let node;
- const wrappers: Dict<HTMLDivElement> = {};
- while ((node = iterator.nextNode())) {
- if (node.nodeValue && /update_center\s*:/.test(node.nodeValue)) {
- let [, key] = node.nodeValue.split(':');
- key = key.trim();
-
- const wrapper = document.createElement('div');
- wrapper.className = 'plugin-meta-data-wrapper';
- wrappers[key] = wrapper;
-
- node.parentNode!.insertBefore(wrapper, node);
- }
- }
- this.setState({ wrappers }, this.fetchAndRender);
- }
- };
-
- renderMetaData = ({
- isSonarSourceCommercial,
- issueTrackerURL,
- license,
- organization,
- versions
- }: PluginMetaDataInfo) => {
- let vendor;
- if (organization) {
- vendor = organization.name;
- if (organization.url) {
- vendor = (
- <a href={organization.url} rel="noopener noreferrer" target="_blank">
- {vendor}
- </a>
- );
- }
- }
- return (
- <div className="plugin-meta-data">
- <div className="plugin-meta-data-header">
- {vendor && <span className="plugin-meta-data-vendor">By {vendor}</span>}
- {license && <span className="plugin-meta-data-license">{license}</span>}
- {issueTrackerURL && (
- <span className="plugin-meta-data-issue-tracker">
- <a href={issueTrackerURL} rel="noopener noreferrer" target="_blank">
- Issue Tracker
- </a>
- </span>
- )}
- {isSonarSourceCommercial && (
- <span className="plugin-meta-data-supported">Supported by SonarSource</span>
- )}
- </div>
- {versions && versions.length > 0 && <PluginVersionMetaData versions={versions} />}
- </div>
- );
- };
-
- render() {
- const { data, wrappers } = this.state;
- const keys = Object.keys(data);
-
- if (keys.length === 0) {
- return null;
- }
-
- return keys.map(key => {
- if (wrappers[key] !== undefined && data[key] !== undefined) {
- return createPortal(this.renderMetaData(data[key]), wrappers[key]);
- } else {
- return null;
- }
- });
- }
-}
diff --git a/server/sonar-docs/src/components/PluginVersionMetaData.tsx b/server/sonar-docs/src/components/PluginVersionMetaData.tsx
deleted file mode 100644
index 8d17ffe5e4f..00000000000
--- a/server/sonar-docs/src/components/PluginVersionMetaData.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import classNames from 'classnames';
-import * as React from 'react';
-import { PluginVersionInfo } from '../@types/types';
-
-interface Props {
- versions: PluginVersionInfo[];
-}
-
-interface State {
- collapsed: boolean;
-}
-
-export default class PluginVersionMetaData extends React.Component<Props, State> {
- state: State = {
- collapsed: true
- };
-
- handleClick = (event: React.SyntheticEvent<HTMLButtonElement>) => {
- event.preventDefault();
- event.currentTarget.blur();
- this.setState(({ collapsed }) => ({ collapsed: !collapsed }));
- };
-
- renderVersion = ({
- archived,
- changeLogUrl,
- compatibility,
- date,
- description,
- downloadURL,
- version
- }: PluginVersionInfo) => {
- return (
- <div
- className={classNames('plugin-meta-data-version', {
- 'plugin-meta-data-version-archived': archived
- })}
- key={version}>
- <div className="plugin-meta-data-version-version">{version}</div>
-
- <div className="plugin-meta-data-version-release-info">
- {date && <time className="plugin-meta-data-version-release-date">{date}</time>}
-
- {compatibility && (
- <span className="plugin-meta-data-version-compatibility">{compatibility}</span>
- )}
- </div>
-
- {description && (
- <div className="plugin-meta-data-version-release-description">{description}</div>
- )}
-
- {(downloadURL || changeLogUrl) && (
- <div className="plugin-meta-data-version-release-links">
- {downloadURL && (
- <span className="plugin-meta-data-version-download">
- <a href={downloadURL} rel="noopener noreferrer" target="_blank">
- Download
- </a>
- </span>
- )}
-
- {changeLogUrl && (
- <span className="plugin-meta-data-version-release-notes">
- <a href={changeLogUrl} rel="noopener noreferrer" target="_blank">
- Release notes
- </a>
- </span>
- )}
- </div>
- )}
- </div>
- );
- };
-
- render() {
- const { versions } = this.props;
- const { collapsed } = this.state;
-
- const archivedVersions = versions.filter(version => version.archived);
- const currentVersions = versions.filter(version => !version.archived);
- return (
- <div className="plugin-meta-data-versions">
- {archivedVersions.length > 0 && (
- <button
- className="plugin-meta-data-versions-show-more"
- onClick={this.handleClick}
- type="button">
- {collapsed ? 'Show more versions' : 'Show fewer version'}
- </button>
- )}
-
- {currentVersions.map(version => this.renderVersion(version))}
-
- {!collapsed && archivedVersions.map(version => this.renderVersion(version))}
- </div>
- );
- }
-}
diff --git a/server/sonar-docs/src/components/UpdateCenterMetaDataInjector.tsx b/server/sonar-docs/src/components/UpdateCenterMetaDataInjector.tsx
new file mode 100644
index 00000000000..2593983a4f7
--- /dev/null
+++ b/server/sonar-docs/src/components/UpdateCenterMetaDataInjector.tsx
@@ -0,0 +1,132 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import * as React from 'react';
+import { createPortal } from 'react-dom';
+import MetaData from 'sonar-ui-common/components/ui/update-center/MetaData';
+import { Dict } from '../@types/types';
+
+interface Props {
+ location: Pick<Location, 'pathname'>;
+}
+
+interface State {
+ wrappers: Dict<HTMLDivElement>;
+}
+
+export default class UpdateCenterMetaDataInjector extends React.Component<Props, State> {
+ state: State = {
+ wrappers: {}
+ };
+
+ componentDidMount() {
+ this.searchForMetaData();
+ }
+
+ componentDidUpdate({ location }: Props) {
+ if (location.pathname !== this.props.location.pathname) {
+ this.clearMetaData();
+ this.searchForMetaData();
+ }
+ }
+
+ componentWillUnmount() {
+ this.clearMetaData();
+ }
+
+ clearMetaData = () => {
+ const { wrappers } = this.state;
+
+ Object.keys(wrappers).forEach(key => {
+ const node = wrappers[key];
+ const { parentNode } = node;
+ if (parentNode) {
+ parentNode.removeChild(node);
+ }
+
+ delete wrappers[key];
+ });
+
+ this.setState({ wrappers: {} });
+ };
+
+ searchForMetaData = () => {
+ const pageContainer = document.querySelector('.page-container');
+
+ if (!pageContainer) {
+ return;
+ }
+
+ // The following uses an older syntax for createNodeIterator() in order
+ // to support IE11
+ // - IE doesn't support the new { acceptNode: (node: Node) => number }
+ // format for the 3rd parameter, and instead expects to get it passed
+ // the function directly. Modern browsers support both paradigms as a
+ // fallback, so we fallback to the old one.
+ // - IE11 requires the 4th argument.
+ // @ts-ignore: tsc requires an additional comment at the function call.
+ const iterator = document.createNodeIterator(
+ pageContainer,
+ NodeFilter.SHOW_COMMENT,
+ // @ts-ignore: IE11 doesn't support the { acceptNode: () => number } format.
+ (_: Node) => NodeFilter.FILTER_ACCEPT,
+ // @ts-ignore: IE11 requires the 4th argument.
+ false
+ );
+
+ const wrappers: Dict<HTMLDivElement> = {};
+ let node = iterator.nextNode();
+
+ while (node) {
+ if (node.nodeValue && node.parentNode && /update_center\s*:/.test(node.nodeValue)) {
+ let [, key] = node.nodeValue.split(':');
+ key = key.trim();
+
+ const wrapper = document.createElement('div');
+ wrappers[key] = wrapper;
+ node.parentNode.insertBefore(wrapper, node);
+ }
+
+ node = iterator.nextNode();
+ }
+
+ this.setState({ wrappers });
+ };
+
+ render() {
+ const { wrappers } = this.state;
+ const keys = Object.keys(wrappers);
+
+ if (keys.length === 0) {
+ return null;
+ }
+
+ return (
+ <div>
+ {keys.map(key => {
+ if (wrappers[key]) {
+ return createPortal(<MetaData updateCenterKey={key} />, wrappers[key]);
+ } else {
+ return null;
+ }
+ })}
+ </div>
+ );
+ }
+}
diff --git a/server/sonar-docs/src/components/__tests__/PluginMetaData-test.tsx b/server/sonar-docs/src/components/__tests__/PluginMetaData-test.tsx
deleted file mode 100644
index 4039f1e389e..00000000000
--- a/server/sonar-docs/src/components/__tests__/PluginMetaData-test.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { mount } from 'enzyme';
-import * as React from 'react';
-import PluginMetaData from '../PluginMetaData';
-import { getPluginMetaData } from '../utils';
-
-jest.mock('../utils', () => ({
- getPluginMetaData: jest.fn().mockResolvedValue({
- name: 'SonarJava',
- key: 'java',
- isSonarSourceCommercial: true,
- organization: {
- name: 'SonarSource',
- url: 'http://www.sonarsource.com/'
- },
- category: 'Languages',
- license: 'SonarSource',
- issueTrackerURL: 'https://jira.sonarsource.com/browse/SONARJAVA',
- sourcesURL: 'https://github.com/SonarSource/sonar-java',
- versions: [
- {
- version: '4.2',
- compatibilityRange: { minimum: '6.0', maximum: '6.6' },
- archived: false,
- downloadURL: 'https://example.com/sonar-java-plugin-5.13.0.18197.jar'
- },
- {
- version: '3.2',
- date: '2015-04-30',
- compatibilityRange: { maximum: '6.0' },
- archived: true,
- changeLogUrl: 'https://example.com/sonar-java-plugin/release',
- downloadURL: 'https://example.com/sonar-java-plugin-3.2.jar'
- }
- ]
- })
-}));
-
-beforeAll(() => {
- (global as any).document.body.innerHTML = `
-<div class="page-container">
- <p>Lorem ipsum</p>
- <!-- update_center:java -->
- <p>Dolor sit amet</p>
- <!-- update_center : python -->
- <p>Foo Bar</p>
- <!--update_center : abap-->
-</div>
-`;
-});
-
-it('should render correctly', async () => {
- const wrapper = shallowRender();
- await new Promise(setImmediate);
- expect(wrapper).toMatchSnapshot();
- expect(getPluginMetaData).toBeCalledWith('java');
- expect(getPluginMetaData).toBeCalledWith('python');
- expect(getPluginMetaData).toBeCalledWith('abap');
-});
-
-function shallowRender(props: Partial<PluginMetaData['props']> = {}) {
- return mount(<PluginMetaData location={{ pathname: 'foo' }} {...props} />);
-}
diff --git a/server/sonar-docs/src/components/__tests__/PluginVersionMetaData-test.tsx b/server/sonar-docs/src/components/__tests__/PluginVersionMetaData-test.tsx
deleted file mode 100644
index 3845b3a3e23..00000000000
--- a/server/sonar-docs/src/components/__tests__/PluginVersionMetaData-test.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import { shallow } from 'enzyme';
-import * as React from 'react';
-import PluginVersionMetaData from '../PluginVersionMetaData';
-
-it('should render correctly', () => {
- const wrapper = shallowRender();
- expect(wrapper).toMatchSnapshot();
-});
-
-it('should correctly show all versions', () => {
- const wrapper = shallowRender();
- expect(wrapper.find('.plugin-meta-data-version').length).toBe(2);
- wrapper.instance().setState({ collapsed: false });
- expect(wrapper.find('.plugin-meta-data-version').length).toBe(5);
-});
-
-function shallowRender(props: Partial<PluginVersionMetaData['props']> = {}) {
- return shallow(
- <PluginVersionMetaData
- versions={[
- {
- version: '5.13',
- date: '2019-05-31',
- compatibility: '6.7',
- archived: false,
- downloadURL: 'https://example.com/sonar-java-plugin-5.13.0.18197.jar',
- changeLogUrl: 'https://example.com/sonar-java-plugin/release'
- },
- {
- version: '4.2',
- archived: false,
- downloadURL: 'https://example.com/sonar-java-plugin-5.13.0.18197.jar'
- },
- {
- version: '3.2',
- date: '2015-04-30',
- compatibility: '6.0 to 7.1',
- archived: true,
- changeLogUrl: 'https://example.com/sonar-java-plugin/release',
- downloadURL: 'https://example.com/sonar-java-plugin-3.2.jar'
- },
- {
- version: '3.1',
- description: 'Lorem ipsum dolor sit amet',
- archived: true,
- changeLogUrl: 'https://example.com/sonar-java-plugin/release',
- downloadURL: 'https://example.com/sonar-java-plugin-3.1.jar'
- },
- {
- version: '2.1',
- archived: true,
- downloadURL: 'https://example.com/sonar-java-plugin-2.1.jar'
- }
- ]}
- {...props}
- />
- );
-}
diff --git a/server/sonar-docs/src/components/__tests__/UpdateCenterMetaDataInjector-test.tsx b/server/sonar-docs/src/components/__tests__/UpdateCenterMetaDataInjector-test.tsx
new file mode 100644
index 00000000000..b12ea7e0e74
--- /dev/null
+++ b/server/sonar-docs/src/components/__tests__/UpdateCenterMetaDataInjector-test.tsx
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { shallow } from 'enzyme';
+import * as React from 'react';
+import UpdateCenterMetaDataInjector from '../UpdateCenterMetaDataInjector';
+
+it('should render correctly', () => {
+ (global as any).document.body.innerHTML = `
+<div class="page-container">
+ <p>Lorem ipsum</p>
+ <!-- update_center:java -->
+ <p>Dolor sit amet</p>
+ <!-- update_center : python -->
+ <p>Foo Bar</p>
+ <!--update_center : abap-->
+</div>
+`;
+
+ const wrapper = shallowRender();
+ expect(wrapper).toMatchSnapshot();
+
+ (global as any).document.body.innerHTML = `
+<div class="page-container">
+ <p>Lorem ipsum</p>
+ <!-- update_center:csharp -->
+ <p>Foo Bar</p>
+</div>
+`;
+
+ wrapper.setProps({ location: { pathname: 'foo2' } });
+ expect(wrapper).toMatchSnapshot();
+});
+
+function shallowRender(props: Partial<UpdateCenterMetaDataInjector['props']> = {}) {
+ return shallow<UpdateCenterMetaDataInjector>(
+ <UpdateCenterMetaDataInjector location={{ pathname: 'foo' }} {...props} />
+ );
+}
diff --git a/server/sonar-docs/src/components/__tests__/__snapshots__/PluginMetaData-test.tsx.snap b/server/sonar-docs/src/components/__tests__/__snapshots__/PluginMetaData-test.tsx.snap
deleted file mode 100644
index e98eab29c96..00000000000
--- a/server/sonar-docs/src/components/__tests__/__snapshots__/PluginMetaData-test.tsx.snap
+++ /dev/null
@@ -1,11 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<PluginMetaData
- location={
- Object {
- "pathname": "foo",
- }
- }
-/>
-`;
diff --git a/server/sonar-docs/src/components/__tests__/__snapshots__/PluginVersionMetaData-test.tsx.snap b/server/sonar-docs/src/components/__tests__/__snapshots__/PluginVersionMetaData-test.tsx.snap
deleted file mode 100644
index e8c0a1238f8..00000000000
--- a/server/sonar-docs/src/components/__tests__/__snapshots__/PluginVersionMetaData-test.tsx.snap
+++ /dev/null
@@ -1,93 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly 1`] = `
-<div
- className="plugin-meta-data-versions"
->
- <button
- className="plugin-meta-data-versions-show-more"
- onClick={[Function]}
- type="button"
- >
- Show more versions
- </button>
- <div
- className="plugin-meta-data-version"
- key="5.13"
- >
- <div
- className="plugin-meta-data-version-version"
- >
- 5.13
- </div>
- <div
- className="plugin-meta-data-version-release-info"
- >
- <time
- className="plugin-meta-data-version-release-date"
- >
- 2019-05-31
- </time>
- <span
- className="plugin-meta-data-version-compatibility"
- >
- 6.7
- </span>
- </div>
- <div
- className="plugin-meta-data-version-release-links"
- >
- <span
- className="plugin-meta-data-version-download"
- >
- <a
- href="https://example.com/sonar-java-plugin-5.13.0.18197.jar"
- rel="noopener noreferrer"
- target="_blank"
- >
- Download
- </a>
- </span>
- <span
- className="plugin-meta-data-version-release-notes"
- >
- <a
- href="https://example.com/sonar-java-plugin/release"
- rel="noopener noreferrer"
- target="_blank"
- >
- Release notes
- </a>
- </span>
- </div>
- </div>
- <div
- className="plugin-meta-data-version"
- key="4.2"
- >
- <div
- className="plugin-meta-data-version-version"
- >
- 4.2
- </div>
- <div
- className="plugin-meta-data-version-release-info"
- />
- <div
- className="plugin-meta-data-version-release-links"
- >
- <span
- className="plugin-meta-data-version-download"
- >
- <a
- href="https://example.com/sonar-java-plugin-5.13.0.18197.jar"
- rel="noopener noreferrer"
- target="_blank"
- >
- Download
- </a>
- </span>
- </div>
- </div>
-</div>
-`;
diff --git a/server/sonar-docs/src/components/__tests__/__snapshots__/UpdateCenterMetaDataInjector-test.tsx.snap b/server/sonar-docs/src/components/__tests__/__snapshots__/UpdateCenterMetaDataInjector-test.tsx.snap
new file mode 100644
index 00000000000..7682b8ca34b
--- /dev/null
+++ b/server/sonar-docs/src/components/__tests__/__snapshots__/UpdateCenterMetaDataInjector-test.tsx.snap
@@ -0,0 +1,39 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<div>
+ <Portal
+ containerInfo={<div />}
+ >
+ <MetaData
+ updateCenterKey="java"
+ />
+ </Portal>
+ <Portal
+ containerInfo={<div />}
+ >
+ <MetaData
+ updateCenterKey="python"
+ />
+ </Portal>
+ <Portal
+ containerInfo={<div />}
+ >
+ <MetaData
+ updateCenterKey="abap"
+ />
+ </Portal>
+</div>
+`;
+
+exports[`should render correctly 2`] = `
+<div>
+ <Portal
+ containerInfo={<div />}
+ >
+ <MetaData
+ updateCenterKey="csharp"
+ />
+ </Portal>
+</div>
+`;
diff --git a/server/sonar-docs/src/components/utils.tsx b/server/sonar-docs/src/components/utils.tsx
index 86ce88c2f84..ac3114e4d7d 100644
--- a/server/sonar-docs/src/components/utils.tsx
+++ b/server/sonar-docs/src/components/utils.tsx
@@ -19,7 +19,6 @@
*/
import { sortBy } from 'lodash';
import { MarkdownRemark } from '../@types/graphql-types';
-import { PluginMetaDataInfo } from '../@types/types';
const WORDS = 6;
@@ -127,18 +126,3 @@ export function highlightMarks(str: string, marks: Array<{ from: number; to: num
export function isDefined<T>(x: T | undefined | null): x is T {
return x !== undefined && x !== null;
}
-
-export function getPluginMetaData(key: string): Promise<PluginMetaDataInfo> {
- return (
- window
- .fetch(`https://update.sonarsource.org/${key}.json`)
- .then((response: Response) => {
- if (response.status >= 200 && response.status < 300) {
- return response.json();
- }
- return Promise.reject(response);
- })
- /* eslint-disable no-console */
- .catch(console.error)
- );
-}