From 334d4b7065f34673cc3e857b634aca51570fe47c Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Fri, 20 Mar 2020 14:48:15 +0100 Subject: [PATCH] SONAR-12945 Display latest release's information for scanners in documentation --- server/sonar-docs/README.md | 23 +- server/sonar-docs/src/@types/types.d.ts | 25 -- .../src/components/PluginMetaData.tsx | 175 ----------- .../src/components/PluginVersionMetaData.tsx | 118 ------- .../UpdateCenterMetaDataInjector.tsx | 132 ++++++++ .../__tests__/PluginMetaData-test.tsx | 81 ----- .../__tests__/PluginVersionMetaData-test.tsx | 77 ----- .../UpdateCenterMetaDataInjector-test.tsx | 55 ++++ .../PluginMetaData-test.tsx.snap | 11 - .../PluginVersionMetaData-test.tsx.snap | 93 ------ ...UpdateCenterMetaDataInjector-test.tsx.snap | 39 +++ server/sonar-docs/src/components/utils.tsx | 16 - server/sonar-docs/src/layouts/index.tsx | 4 +- server/sonar-docs/src/layouts/layout.css | 83 ----- .../analysis/scan/sonarscanner-for-ant.md | 9 +- .../scan/sonarscanner-for-azure-devops.md | 8 +- .../analysis/scan/sonarscanner-for-gradle.md | 9 +- .../analysis/scan/sonarscanner-for-jenkins.md | 7 +- .../analysis/scan/sonarscanner-for-maven.md | 8 +- .../analysis/scan/sonarscanner-for-msbuild.md | 13 +- .../src/pages/analysis/scan/sonarscanner.md | 14 +- server/sonar-web/package.json | 3 + .../src/main/js/@types/rehype-raw.d.ts | 23 ++ .../src/main/js/@types/rehype-react.d.ts | 23 ++ .../src/main/js/@types/remark-rehype.d.ts | 23 ++ .../js/components/docs/DocMarkdownBlock.tsx | 21 +- .../docs/__tests__/DocMarkdownBlock-test.tsx | 29 +- .../DocMarkdownBlock-test.tsx.snap | 157 +++++----- server/sonar-web/yarn.lock | 296 +++++++++++++----- 29 files changed, 668 insertions(+), 907 deletions(-) delete mode 100644 server/sonar-docs/src/components/PluginMetaData.tsx delete mode 100644 server/sonar-docs/src/components/PluginVersionMetaData.tsx create mode 100644 server/sonar-docs/src/components/UpdateCenterMetaDataInjector.tsx delete mode 100644 server/sonar-docs/src/components/__tests__/PluginMetaData-test.tsx delete mode 100644 server/sonar-docs/src/components/__tests__/PluginVersionMetaData-test.tsx create mode 100644 server/sonar-docs/src/components/__tests__/UpdateCenterMetaDataInjector-test.tsx delete mode 100644 server/sonar-docs/src/components/__tests__/__snapshots__/PluginMetaData-test.tsx.snap delete mode 100644 server/sonar-docs/src/components/__tests__/__snapshots__/PluginVersionMetaData-test.tsx.snap create mode 100644 server/sonar-docs/src/components/__tests__/__snapshots__/UpdateCenterMetaDataInjector-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/@types/rehype-raw.d.ts create mode 100644 server/sonar-web/src/main/js/@types/rehype-react.d.ts create mode 100644 server/sonar-web/src/main/js/@types/remark-rehype.d.ts diff --git a/server/sonar-docs/README.md b/server/sonar-docs/README.md index ca57d22fbda..f0f21aff683 100644 --- a/server/sonar-docs/README.md +++ b/server/sonar-docs/README.md @@ -301,20 +301,35 @@ Note that an iframe is **not** a self-closing tag. This means that the following ``` -#### Dynamic Plugin Version Info +#### Dynamic Plugin/Scanner Version Info -_Note: at this time, this is only supported for the static documentation, and will be stripped from the embedded documentation._ +You can dynamically include a plugin/scanner version block to any page, using the following special tag: -You can dynamically include a plugin version block to any page, using the following special tag: +For static documentation, use: ```html - + +``` + +For embedded documentation, use: +```html + ``` For example, for Sonar Java, use: ```html +or + +``` + +For gradle's scanner, use: + +```html + +or + ``` You can include multiple boxes per page, if needed. diff --git a/server/sonar-docs/src/@types/types.d.ts b/server/sonar-docs/src/@types/types.d.ts index b27e9f9f029..a46e8fbe0ec 100644 --- a/server/sonar-docs/src/@types/types.d.ts +++ b/server/sonar-docs/src/@types/types.d.ts @@ -37,31 +37,6 @@ export interface DocsNavigationExternalLink { url: string; } -export type PluginMetaDataInfo = { - category?: string; - isSonarSourceCommercial: boolean; - issueTrackerURL?: string; - key?: string; - license?: string; - name: string; - organization?: { - name: string; - url?: string; - }; - sourcesURL?: string; - versions?: PluginVersionInfo[]; -}; - -export type PluginVersionInfo = { - archived?: boolean; - changeLogUrl?: string; - compatibility?: string; - date?: string; - description?: string; - downloadURL?: string; - version: string; -}; - export interface SearchResult { exactMatch?: boolean; highlights: { [field: string]: [number, number][] }; 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; -} - -interface State { - data: Dict; - wrappers: Dict; -} - -export default class PluginMetaData extends React.Component { - 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 = {}; - 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 = ( - - {vendor} - - ); - } - } - return ( -
-
- {vendor && By {vendor}} - {license && {license}} - {issueTrackerURL && ( - - - Issue Tracker - - - )} - {isSonarSourceCommercial && ( - Supported by SonarSource - )} -
- {versions && versions.length > 0 && } -
- ); - }; - - 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 { - state: State = { - collapsed: true - }; - - handleClick = (event: React.SyntheticEvent) => { - event.preventDefault(); - event.currentTarget.blur(); - this.setState(({ collapsed }) => ({ collapsed: !collapsed })); - }; - - renderVersion = ({ - archived, - changeLogUrl, - compatibility, - date, - description, - downloadURL, - version - }: PluginVersionInfo) => { - return ( -
-
{version}
- -
- {date && } - - {compatibility && ( - {compatibility} - )} -
- - {description && ( -
{description}
- )} - - {(downloadURL || changeLogUrl) && ( -
- {downloadURL && ( - - - Download - - - )} - - {changeLogUrl && ( - - - Release notes - - - )} -
- )} -
- ); - }; - - render() { - const { versions } = this.props; - const { collapsed } = this.state; - - const archivedVersions = versions.filter(version => version.archived); - const currentVersions = versions.filter(version => !version.archived); - return ( -
- {archivedVersions.length > 0 && ( - - )} - - {currentVersions.map(version => this.renderVersion(version))} - - {!collapsed && archivedVersions.map(version => this.renderVersion(version))} -
- ); - } -} 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; +} + +interface State { + wrappers: Dict; +} + +export default class UpdateCenterMetaDataInjector extends React.Component { + 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 = {}; + 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 ( +
+ {keys.map(key => { + if (wrappers[key]) { + return createPortal(, wrappers[key]); + } else { + return null; + } + })} +
+ ); + } +} 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 = ` -
-

Lorem ipsum

- -

Dolor sit amet

- -

Foo Bar

- -
-`; -}); - -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 = {}) { - return mount(); -} 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 = {}) { - return shallow( - - ); -} 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 = ` +
+

Lorem ipsum

+ +

Dolor sit amet

+ +

Foo Bar

+ +
+`; + + const wrapper = shallowRender(); + expect(wrapper).toMatchSnapshot(); + + (global as any).document.body.innerHTML = ` +
+

Lorem ipsum

+ +

Foo Bar

+
+`; + + wrapper.setProps({ location: { pathname: 'foo2' } }); + expect(wrapper).toMatchSnapshot(); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} 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`] = ` - -`; 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`] = ` -
- -
-
- 5.13 -
-
- - - 6.7 - -
- -
-
-
- 4.2 -
-
- -
-
-`; 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`] = ` +
+ } + > + + + } + > + + + } + > + + +
+`; + +exports[`should render correctly 2`] = ` +
+ } + > + + +
+`; 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(x: T | undefined | null): x is T { return x !== undefined && x !== null; } - -export function getPluginMetaData(key: string): Promise { - 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) - ); -} diff --git a/server/sonar-docs/src/layouts/index.tsx b/server/sonar-docs/src/layouts/index.tsx index 2af5049d2be..5d1ef762124 100644 --- a/server/sonar-docs/src/layouts/index.tsx +++ b/server/sonar-docs/src/layouts/index.tsx @@ -23,8 +23,8 @@ import { MarkdownRemark, MarkdownRemarkConnection } from '../@types/graphql-type import Footer from '../components/Footer'; import HeaderListProvider from '../components/HeaderListProvider'; import HeadingsLink from '../components/HeadingsLink'; -import PluginMetaData from '../components/PluginMetaData'; import Sidebar from '../components/Sidebar'; +import UpdateCenterMetaDataInjector from '../components/UpdateCenterMetaDataInjector'; import './layout.css'; const version = process.env.GATSBY_DOCS_VERSION || '1.0'; @@ -95,7 +95,7 @@ export default function Layout({ children, location }: Props) {
{children}