diff options
Diffstat (limited to 'server/sonar-ui-common/components/ui')
67 files changed, 0 insertions, 4768 deletions
diff --git a/server/sonar-ui-common/components/ui/Alert.tsx b/server/sonar-ui-common/components/ui/Alert.tsx deleted file mode 100644 index 376d6e5fec6..00000000000 --- a/server/sonar-ui-common/components/ui/Alert.tsx +++ /dev/null @@ -1,159 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import { translate } from '../../helpers/l10n'; -import AlertErrorIcon from '../icons/AlertErrorIcon'; -import AlertSuccessIcon from '../icons/AlertSuccessIcon'; -import AlertWarnIcon from '../icons/AlertWarnIcon'; -import InfoIcon from '../icons/InfoIcon'; -import { css, styled, Theme, themeColor, ThemedProps, themeSize, useTheme } from '../theme'; -import DeferredSpinner from './DeferredSpinner'; - -type AlertDisplay = 'banner' | 'inline' | 'block'; -type AlertVariant = 'error' | 'warning' | 'success' | 'info' | 'loading'; - -export interface AlertProps { - display?: AlertDisplay; - variant: AlertVariant; -} - -interface AlertVariantInformation { - icon: JSX.Element; - color: string; - borderColor: string; - backGroundColor: string; -} - -const StyledAlertIcon = styled.div<{ isBanner: boolean; variantInfo: AlertVariantInformation }>` - flex: 0 0 auto; - display: flex; - justify-content: center; - align-items: center; - width: calc(${({ isBanner }) => (isBanner ? 2 : 4)} * ${themeSize('gridSize')}); - border-right: ${({ isBanner }) => (!isBanner ? '1px solid' : 'none')}; - border-color: ${({ variantInfo }) => variantInfo.borderColor}; -`; - -const StyledAlertContent = styled.div` - flex: 1 1 auto; - overflow: auto; - text-align: left; - padding: ${themeSize('gridSize')} calc(2 * ${themeSize('gridSize')}); -`; - -const alertInnerIsBannerMixin = ({ theme }: ThemedProps) => css` - min-width: ${theme.sizes.minPageWidth}; - max-width: ${theme.sizes.maxPageWidth}; - margin-left: auto; - margin-right: auto; - padding-left: ${theme.sizes.pagePadding}; - padding-right: ${theme.sizes.pagePadding}; - box-sizing: border-box; -`; - -const StyledAlertInner = styled.div<{ isBanner: boolean }>` - display: flex; - align-items: stretch; - ${({ isBanner }) => (isBanner ? alertInnerIsBannerMixin : null)} -`; - -const StyledAlert = styled.div<{ isInline: boolean; variantInfo: AlertVariantInformation }>` - border: 1px solid; - border-radius: 2px; - margin-bottom: ${themeSize('gridSize')}; - border-color: ${({ variantInfo }) => variantInfo.borderColor}; - background-color: ${({ variantInfo }) => variantInfo.backGroundColor}; - color: ${({ variantInfo }) => variantInfo.color}; - display: ${({ isInline }) => (isInline ? 'inline-block' : 'block')}; - - :empty { - display: none; - } - - a, - .button-link { - border-color: ${themeColor('darkBlue')}; - } -`; - -function getAlertVariantInfo({ colors }: Theme, variant: AlertVariant): AlertVariantInformation { - const variantList: T.Dict<AlertVariantInformation> = { - error: { - icon: <AlertErrorIcon fill={colors.alertIconError} />, - color: colors.alertTextError, - borderColor: colors.alertBorderError, - backGroundColor: colors.alertBackgroundError, - }, - warning: { - icon: <AlertWarnIcon fill={colors.alertIconWarning} />, - color: colors.alertTextWarning, - borderColor: colors.alertBorderWarning, - backGroundColor: colors.alertBackgroundWarning, - }, - success: { - icon: <AlertSuccessIcon fill={colors.alertIconSuccess} />, - color: colors.alertTextSuccess, - borderColor: colors.alertBorderSuccess, - backGroundColor: colors.alertBackgroundSuccess, - }, - info: { - icon: <InfoIcon fill={colors.alertIconInfo} />, - color: colors.alertTextInfo, - borderColor: colors.alertBorderInfo, - backGroundColor: colors.alertBackgroundInfo, - }, - loading: { - icon: <DeferredSpinner timeout={0} />, - color: colors.alertTextInfo, - borderColor: colors.alertBorderInfo, - backGroundColor: colors.alertBackgroundInfo, - }, - }; - - return variantList[variant]; -} - -export function Alert(props: AlertProps & React.HTMLAttributes<HTMLDivElement>) { - const theme = useTheme(); - const { className, display, variant, ...domProps } = props; - const isInline = display === 'inline'; - const isBanner = display === 'banner'; - const variantInfo = getAlertVariantInfo(theme, variant); - - return ( - <StyledAlert - className={classNames('alert', className)} - isInline={isInline} - role="alert" - variantInfo={variantInfo} - {...domProps}> - <StyledAlertInner isBanner={isBanner}> - <StyledAlertIcon - aria-label={translate('alert.tooltip', variant)} - isBanner={isBanner} - variantInfo={variantInfo}> - {variantInfo.icon} - </StyledAlertIcon> - <StyledAlertContent className="alert-content">{props.children}</StyledAlertContent> - </StyledAlertInner> - </StyledAlert> - ); -} diff --git a/server/sonar-ui-common/components/ui/AutoEllipsis.tsx b/server/sonar-ui-common/components/ui/AutoEllipsis.tsx deleted file mode 100644 index ee2ed0ae7da..00000000000 --- a/server/sonar-ui-common/components/ui/AutoEllipsis.tsx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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'; - -type EllipsisPredicate = ( - node: HTMLElement, - props: Omit<AutoEllipsisProps, 'customShouldEllipsis'> -) => boolean; - -interface AutoEllipsisProps { - customShouldEllipsis?: EllipsisPredicate; - maxHeight?: number; - maxWidth?: number; - useParent?: boolean; -} - -interface Props extends AutoEllipsisProps { - children: React.ReactElement; -} - -/* - * This component allows to automatically add the .text-ellipsis class on it's children if this one - * might overflow the max width/height passed as props. - * If one of maxHeight or maxWidth is not specified, they will be ignored in the conditions to add the ellipsis class. - * If useParent is true, then the parent size will be used instead of the undefined maxHeight/maxWidth - */ -export default function AutoEllipsis(props: Props) { - const { children, ...autoEllipsisProps } = props; - const [autoEllispis, ref] = useAutoEllipsis(autoEllipsisProps); - - return React.cloneElement(children, { - className: classNames(children.props.className, { 'text-ellipsis': autoEllispis }), - ref, - }); -} - -export function useAutoEllipsis(props: AutoEllipsisProps): [boolean, (node: HTMLElement) => void] { - const [autoEllipsis, setAutoEllipsis] = React.useState(false); - - // useCallback instead of useRef to be able to compute if the flag is needed as soon as the ref is attached - // useRef doesn't accept a callback to notify us that the current ref value was attached, - // see https://reactjs.org/docs/hooks-faq.html#how-can-i-measure-a-dom-node for more info on this. - const ref = React.useCallback( - (node: HTMLElement) => { - if (!autoEllipsis && node) { - const shouldEllipsis = props.customShouldEllipsis ?? defaultShouldEllipsis; - setAutoEllipsis(shouldEllipsis(node, props)); - } - }, - // We don't want to apply this effect when ellipsis state change, only this effect can change it - // eslint-disable-next-line react-hooks/exhaustive-deps - [props.customShouldEllipsis, props.maxHeight, props.maxWidth, props.useParent] - ); - - return [autoEllipsis, ref]; -} - -export const defaultShouldEllipsis: EllipsisPredicate = ( - node, - { useParent = true, maxWidth, maxHeight } -) => { - if (node.parentElement && useParent) { - maxWidth = maxWidth ?? node.parentElement.clientWidth; - maxHeight = maxHeight ?? node.parentElement.clientHeight; - } - return ( - (maxWidth !== undefined && node.clientWidth > maxWidth) || - (maxHeight !== undefined && node.clientHeight > maxHeight) - ); -}; diff --git a/server/sonar-ui-common/components/ui/ContextNavBar.css b/server/sonar-ui-common/components/ui/ContextNavBar.css deleted file mode 100644 index 2c3865a835d..00000000000 --- a/server/sonar-ui-common/components/ui/ContextNavBar.css +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.navbar-context, -.navbar-context .navbar-inner { - background-color: #fff; - z-index: var(--contextbarZIndex); -} - -.navbar-context .navbar-inner { - padding-top: var(--gridSize); - border-bottom: 1px solid var(--barBorderColor); -} - -.navbar-context .navbar-inner-with-notif { - border-bottom: none; -} - -.navbar-context-justified { - display: flex; - justify-content: space-between; -} - -/* use `min-width: 0` to cut breadcrumb links (to end with "...") */ -/* https://stackoverflow.com/questions/38223879/white-space-nowrap-breaks-flexbox-layout */ -.navbar-context-header { - display: flex; - align-items: center; - min-width: 0; - height: calc(4 * var(--gridSize)); - font-size: var(--bigFontSize); -} - -/* disallow icons and slash separators to shrink */ -.navbar-context-header > *:not(.navbar-context-header-breadcrumb-link) { - flex-shrink: 0; -} - -.navbar-context-header-breadcrumb-link { - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.navbar-context-header .slash-separator { - margin-left: var(--gridSize); - margin-right: var(--gridSize); - font-size: 24px; -} - -.navbar-context-header .slash-separator::after { - color: rgba(68, 68, 68, 0.2); -} - -/* set `min-width: 0` to allow flexbox item to shrink */ -/* https://stackoverflow.com/questions/38223879/white-space-nowrap-breaks-flexbox-layout */ -.navbar-context-meta { - display: flex; - align-items: center; - height: calc(4 * var(--gridSize)); - padding-left: 20px; - color: var(--secondFontColor); - font-size: var(--smallFontSize); - text-align: right; -} - -.navbar-context-meta-secondary { - position: absolute; - top: 34px; - right: 0; - padding: 0 20px; - white-space: nowrap; -} - -.navbar-context-description { - display: inline-block; - line-height: var(--controlHeight); - margin-left: var(--gridSize); - padding-top: 4px; - color: var(--secondFontColor); - font-size: var(--smallFontSize); -} diff --git a/server/sonar-ui-common/components/ui/ContextNavBar.tsx b/server/sonar-ui-common/components/ui/ContextNavBar.tsx deleted file mode 100644 index 07a75d15ae5..00000000000 --- a/server/sonar-ui-common/components/ui/ContextNavBar.tsx +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import './ContextNavBar.css'; -import NavBar from './NavBar'; - -interface Props { - className?: string; - height: number; - [attr: string]: any; -} - -export default function ContextNavBar({ className, ...other }: Props) { - return <NavBar className={classNames('navbar-context', className)} {...other} />; -} diff --git a/server/sonar-ui-common/components/ui/DeferredSpinner.css b/server/sonar-ui-common/components/ui/DeferredSpinner.css deleted file mode 100644 index 22569c0c6b6..00000000000 --- a/server/sonar-ui-common/components/ui/DeferredSpinner.css +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.deferred-spinner { - position: relative; - vertical-align: middle; - width: 16px; - height: 16px; - border: 2px solid var(--blue); - border-radius: 50%; - animation: spin 0.75s infinite linear; -} - -.deferred-spinner:before, -.deferred-spinner:after { - left: -2px; - top: -2px; - display: none; - position: absolute; - content: ''; - width: inherit; - height: inherit; - border: inherit; - border-radius: inherit; -} - -.deferred-spinner, -.deferred-spinner:before, -.deferred-spinner:after { - display: inline-block; - box-sizing: border-box; - border-color: transparent; - border-top-color: var(--blue); - animation-duration: 1.2s; -} - -.deferred-spinner:before { - transform: rotate(120deg); -} - -.deferred-spinner:after { - transform: rotate(240deg); -} - -.deferred-spinner-placeholder { - position: relative; - display: inline-block; - vertical-align: middle; - width: 16px; - height: 16px; - visibility: hidden; -} - -@keyframes spin { - from { - transform: rotate(0deg); - } - - to { - transform: rotate(360deg); - } -} diff --git a/server/sonar-ui-common/components/ui/DeferredSpinner.tsx b/server/sonar-ui-common/components/ui/DeferredSpinner.tsx deleted file mode 100644 index 7021917c0bc..00000000000 --- a/server/sonar-ui-common/components/ui/DeferredSpinner.tsx +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import './DeferredSpinner.css'; - -interface Props { - children?: React.ReactNode; - className?: string; - customSpinner?: JSX.Element; - loading?: boolean; - placeholder?: boolean; - timeout?: number; -} - -interface State { - showSpinner: boolean; -} - -const DEFAULT_TIMEOUT = 100; - -export default class DeferredSpinner extends React.PureComponent<Props, State> { - timer?: number; - - state: State = { showSpinner: false }; - - componentDidMount() { - if (this.props.loading == null || this.props.loading === true) { - this.startTimer(); - } - } - - componentDidUpdate(prevProps: Props) { - if (prevProps.loading === false && this.props.loading === true) { - this.stopTimer(); - this.startTimer(); - } - if (prevProps.loading === true && this.props.loading === false) { - this.stopTimer(); - this.setState({ showSpinner: false }); - } - } - - componentWillUnmount() { - this.stopTimer(); - } - - startTimer = () => { - this.timer = window.setTimeout( - () => this.setState({ showSpinner: true }), - this.props.timeout || DEFAULT_TIMEOUT - ); - }; - - stopTimer = () => { - window.clearTimeout(this.timer); - }; - - render() { - if (this.state.showSpinner) { - return ( - this.props.customSpinner || ( - <i className={classNames('deferred-spinner', this.props.className)} /> - ) - ); - } - return ( - this.props.children || - (this.props.placeholder ? ( - <i className={classNames('deferred-spinner-placeholder', this.props.className)} /> - ) : null) - ); - } -} diff --git a/server/sonar-ui-common/components/ui/DuplicationsRating.css b/server/sonar-ui-common/components/ui/DuplicationsRating.css deleted file mode 100644 index 82f4024bca3..00000000000 --- a/server/sonar-ui-common/components/ui/DuplicationsRating.css +++ /dev/null @@ -1,171 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.duplications-rating { - position: relative; - display: inline-flex; - vertical-align: top; - justify-content: center; - align-items: center; - width: var(--controlHeight); - height: var(--controlHeight); - border: 3px solid var(--orange); - border-radius: var(--controlHeight); - box-sizing: border-box; -} - -.duplications-rating-small { - width: 16px; - height: 16px; - border-width: 2px; -} - -.duplications-rating-big { - width: 40px; - height: 40px; - border-width: 3px; -} - -.duplications-rating-huge { - width: 60px; - height: 60px; - border-width: 4px; - border-radius: 30px; -} - -.duplications-rating-muted { - border-color: #bdbdbd !important; -} - -.duplications-rating-muted:after { - background-color: #bdbdbd !important; -} - -.duplications-rating:after { - border-radius: var(--controlHeight); - content: ''; -} - -.duplications-rating-A { - border-color: var(--green); -} - -.duplications-rating-A:after { - display: none; -} - -.duplications-rating-B { - border-color: var(--lightGreen); -} - -.duplications-rating-B:after { - width: 6px; - height: 6px; - background-color: var(--lightGreen); -} - -.duplications-rating-small.duplications-rating-B:after { - width: 2px; - height: 2px; -} - -.duplications-rating-big.duplications-rating-B:after { - width: var(--smallFontSize); - height: var(--smallFontSize); -} - -.duplications-rating-huge.duplications-rating-B:after { - width: 18px; - height: 18px; -} - -.duplications-rating-C { - border-color: var(--yellow); -} - -.duplications-rating-C:after { - width: 8px; - height: 8px; - background-color: var(--yellow); -} - -.duplications-rating-small.duplications-rating-C:after { - width: 6px; - height: 6px; -} - -.duplications-rating-big.duplications-rating-C:after { - width: 16px; - height: 16px; -} - -.duplications-rating-huge.duplications-rating-C:after { - width: var(--controlHeight); - height: var(--controlHeight); -} - -.duplications-rating-D { - border-color: var(--orange); -} - -.duplications-rating-D:after { - width: var(--smallFontSize); - height: var(--smallFontSize); - background-color: var(--orange); -} - -.duplications-rating-small.duplications-rating-D:after { - width: 8px; - height: 8px; -} - -.duplications-rating-big.duplications-rating-D:after { - width: var(--controlHeight); - height: var(--controlHeight); -} - -.duplications-rating-huge.duplications-rating-D:after { - width: 36px; - height: 36px; -} - -.duplications-rating-E { - border-color: var(--red); -} - -.duplications-rating-E:after { - width: 14px; - height: 14px; - background-color: var(--red); -} - -.duplications-rating-small.duplications-rating-E:after { - width: 10px; - height: 10px; -} - -.duplications-rating-big.duplications-rating-E:after { - width: 28px; - height: 28px; -} - -.duplications-rating-huge.duplications-rating-E:after { - width: 42px; - height: 42px; -} diff --git a/server/sonar-ui-common/components/ui/DuplicationsRating.tsx b/server/sonar-ui-common/components/ui/DuplicationsRating.tsx deleted file mode 100644 index 9289f587960..00000000000 --- a/server/sonar-ui-common/components/ui/DuplicationsRating.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import { inRange } from 'lodash'; -import * as React from 'react'; -import './DuplicationsRating.css'; - -interface Props { - muted?: boolean; - size?: 'small' | 'normal' | 'big' | 'huge'; - value: number | null | undefined; -} - -export default function DuplicationsRating({ muted = false, size = 'normal', value }: Props) { - const className = classNames('duplications-rating', { - 'duplications-rating-small': size === 'small', - 'duplications-rating-big': size === 'big', - 'duplications-rating-huge': size === 'huge', - 'duplications-rating-muted': muted || value == null || isNaN(value), - 'duplications-rating-A': inRange(value || 0, 0, 3), - 'duplications-rating-B': inRange(value || 0, 3, 5), - 'duplications-rating-C': inRange(value || 0, 5, 10), - 'duplications-rating-D': inRange(value || 0, 10, 20), - 'duplications-rating-E': (value || 0) >= 20, - }); - - return <div className={className} />; -} diff --git a/server/sonar-ui-common/components/ui/FilesCounter.tsx b/server/sonar-ui-common/components/ui/FilesCounter.tsx deleted file mode 100644 index 60b96c223fa..00000000000 --- a/server/sonar-ui-common/components/ui/FilesCounter.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { translate } from '../../helpers/l10n'; -import { formatMeasure } from '../../helpers/measures'; - -interface Props { - className?: string; - current?: number; - total: number; -} - -export default function FilesCounter({ className, current, total }: Props) { - return ( - <span className={className}> - <strong> - {current !== undefined && ( - <span> - {formatMeasure(current, 'INT')} - {' / '} - </span> - )} - {formatMeasure(total, 'INT')} - </strong>{' '} - {translate('component_measures.files')} - </span> - ); -} diff --git a/server/sonar-ui-common/components/ui/GenericAvatar.tsx b/server/sonar-ui-common/components/ui/GenericAvatar.tsx deleted file mode 100644 index 1d9aab2aa9f..00000000000 --- a/server/sonar-ui-common/components/ui/GenericAvatar.tsx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import { getTextColor, stringToColor } from '../../helpers/colors'; - -interface Props { - className?: string; - name: string; - round?: boolean; - size: number; -} - -export default function GenericAvatar({ className, name, round, size }: Props) { - const color = stringToColor(name); - - let text = ''; - const words = name.split(/\s+/).filter((word) => word.length > 0); - if (words.length >= 2) { - text = words[0][0] + words[1][0]; - } else if (name.length > 0) { - text = name[0]; - } - - return ( - <div - className={classNames(className, 'rounded')} - style={{ - backgroundColor: color, - borderRadius: round ? '50%' : undefined, - color: getTextColor(color), - display: 'inline-block', - fontSize: Math.min(size / 2, 14), - fontWeight: 'normal', - height: size, - lineHeight: `${size}px`, - textAlign: 'center', - verticalAlign: 'top', - width: size, - }}> - {text.toUpperCase()} - </div> - ); -} diff --git a/server/sonar-ui-common/components/ui/Level.css b/server/sonar-ui-common/components/ui/Level.css deleted file mode 100644 index a4d722f01ce..00000000000 --- a/server/sonar-ui-common/components/ui/Level.css +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.level { - display: inline-block; - width: auto; - min-width: 80px; - padding-left: 9px; - padding-right: 9px; - height: var(--controlHeight); - line-height: var(--controlHeight); - border-radius: var(--controlHeight); - box-sizing: border-box; - color: #fff; - letter-spacing: 0.02em; - font-size: var(--baseFontSize); - font-weight: 400; - text-align: center; - text-shadow: 0 0 1px rgba(0, 0, 0, 0.35); -} - -.level-small { - width: auto; - min-width: 64px; - padding-left: 9px; - padding-right: 9px; - margin-top: -1px; - margin-bottom: -1px; - height: var(--smallControlHeight); - line-height: var(--smallControlHeight); - font-size: var(--smallFontSize); -} - -.level-muted { - background-color: #bdbdbd !important; -} - -a > .level { - margin-bottom: -1px; - border-bottom: 1px solid; - transition: all 0.2s ease; -} - -a > .level:hover { - opacity: 0.8; -} - -.level-OK { - background-color: var(--green); -} - -.level-WARN { - background-color: var(--orange); -} - -.level-ERROR { - background-color: var(--red); -} - -.level-NONE { - background-color: var(--gray71); -} - -.level-NOT_COMPUTED { - background-color: var(--gray40); -} diff --git a/server/sonar-ui-common/components/ui/Level.tsx b/server/sonar-ui-common/components/ui/Level.tsx deleted file mode 100644 index 8d2284df17e..00000000000 --- a/server/sonar-ui-common/components/ui/Level.tsx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import { formatMeasure } from '../../helpers/measures'; -import './Level.css'; - -export interface LevelProps { - 'aria-label'?: string; - 'aria-labelledby'?: string; - className?: string; - level: string; - small?: boolean; - muted?: boolean; -} - -export default function Level(props: LevelProps) { - const formatted = formatMeasure(props.level, 'LEVEL'); - const className = classNames(props.className, 'level', 'level-' + props.level, { - 'level-small': props.small, - 'level-muted': props.muted, - }); - - return ( - <span - aria-label={props['aria-label']} - aria-labelledby={props['aria-labelledby']} - className={className}> - {formatted} - </span> - ); -} diff --git a/server/sonar-ui-common/components/ui/MandatoryFieldMarker.tsx b/server/sonar-ui-common/components/ui/MandatoryFieldMarker.tsx deleted file mode 100644 index bedf016d2a6..00000000000 --- a/server/sonar-ui-common/components/ui/MandatoryFieldMarker.tsx +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import { translate } from '../../helpers/l10n'; - -export interface MandatoryFieldMarkerProps { - className?: string; -} - -export default function MandatoryFieldMarker({ className }: MandatoryFieldMarkerProps) { - return ( - <em - aria-label={translate('field_required')} - className={classNames('mandatory little-spacer-left', className)}> - * - </em> - ); -} diff --git a/server/sonar-ui-common/components/ui/MandatoryFieldsExplanation.tsx b/server/sonar-ui-common/components/ui/MandatoryFieldsExplanation.tsx deleted file mode 100644 index 67ef7370bca..00000000000 --- a/server/sonar-ui-common/components/ui/MandatoryFieldsExplanation.tsx +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import { FormattedMessage } from 'react-intl'; -import { translate } from '../../helpers/l10n'; - -export interface MandatoryFieldsExplanationProps { - className?: string; -} - -export default function MandatoryFieldsExplanation({ className }: MandatoryFieldsExplanationProps) { - return ( - <div aria-hidden={true} className={classNames('text-muted', className)}> - <FormattedMessage - id="fields_marked_with_x_required" - defaultMessage={translate('fields_marked_with_x_required')} - values={{ star: <em className="mandatory">*</em> }} - /> - </div> - ); -} diff --git a/server/sonar-ui-common/components/ui/NavBar.css b/server/sonar-ui-common/components/ui/NavBar.css deleted file mode 100644 index c9e5757121d..00000000000 --- a/server/sonar-ui-common/components/ui/NavBar.css +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.navbar, -[class^='navbar-'], -[class*=' navbar-'] { - box-sizing: border-box; -} - -.navbar { -} - -.navbar-inner { - position: fixed; - left: 0; - right: 0; -} - -.navbar-inner > div { - position: relative; - min-width: var(--minPageWidth); - padding-left: var(--pagePadding); - padding-right: var(--pagePadding); -} - -.navbar-limited { - max-width: var(--maxPageWidth); - margin-left: auto; - margin-right: auto; -} - -.ReactModal__Body--open .navbar-inner { - padding-right: var(--sbw); -} diff --git a/server/sonar-ui-common/components/ui/NavBar.tsx b/server/sonar-ui-common/components/ui/NavBar.tsx deleted file mode 100644 index 5f6de14ffaa..00000000000 --- a/server/sonar-ui-common/components/ui/NavBar.tsx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import { throttle } from 'lodash'; -import * as React from 'react'; -import './NavBar.css'; - -export interface NavBarProps { - children?: React.ReactNode; - className?: string; - height: number; - limited?: boolean; - top?: number; - notif?: React.ReactNode; -} - -interface State { - left: number; -} - -export default class NavBar extends React.PureComponent< - NavBarProps & React.HTMLProps<HTMLDivElement>, - State -> { - throttledFollowHorizontalScroll: () => void; - - constructor(props: NavBarProps) { - super(props); - this.state = { left: 0 }; - this.throttledFollowHorizontalScroll = throttle(this.followHorizontalScroll, 10); - } - - componentDidMount() { - document.addEventListener('scroll', this.throttledFollowHorizontalScroll); - } - - componentWillUnmount() { - document.removeEventListener('scroll', this.throttledFollowHorizontalScroll); - } - - followHorizontalScroll = () => { - if (document.documentElement) { - this.setState({ left: -document.documentElement.scrollLeft }); - } - }; - - render() { - const { children, className, height, limited = true, top, notif, ...other } = this.props; - return ( - <nav {...other} className={classNames('navbar', className)} style={{ height, top }}> - <div - className={classNames('navbar-inner', { 'navbar-inner-with-notif': notif != null })} - style={{ height, left: this.state.left }}> - <div className={classNames('clearfix', { 'navbar-limited': limited })}>{children}</div> - {notif} - </div> - </nav> - ); - } -} diff --git a/server/sonar-ui-common/components/ui/NavBarTabs.css b/server/sonar-ui-common/components/ui/NavBarTabs.css deleted file mode 100644 index f43e1389f07..00000000000 --- a/server/sonar-ui-common/components/ui/NavBarTabs.css +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.navbar-tabs { - display: flex; - align-items: center; - clear: left; - height: var(--controlHeight); - margin-top: var(--gridSize); -} - -.navbar-tabs > li + li { - margin-left: 20px; -} - -.navbar-tabs > li > a { - display: block; - height: var(--controlHeight); - line-height: 16px; - padding-top: 2px; - border-bottom: 3px solid transparent; - box-sizing: border-box; - color: var(--baseFontColor); - transition: none; -} - -.navbar-tabs > li > a.active, -.navbar-tabs > li > a:hover, -.navbar-tabs > li > a:focus { - border-bottom-color: var(--blue); -} diff --git a/server/sonar-ui-common/components/ui/NavBarTabs.tsx b/server/sonar-ui-common/components/ui/NavBarTabs.tsx deleted file mode 100644 index 0cc09e5abc6..00000000000 --- a/server/sonar-ui-common/components/ui/NavBarTabs.tsx +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import './NavBarTabs.css'; - -interface Props { - children?: any; - className?: string; - [attr: string]: any; -} - -export default function NavBarTabs({ children, className, ...other }: Props) { - return ( - <ul {...other} className={classNames('navbar-tabs', className)}> - {children} - </ul> - ); -} diff --git a/server/sonar-ui-common/components/ui/NewsBox.css b/server/sonar-ui-common/components/ui/NewsBox.css deleted file mode 100644 index 1adae9f9102..00000000000 --- a/server/sonar-ui-common/components/ui/NewsBox.css +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.news-box { - border: 1px solid var(--alertBorderInfo); - border-radius: 2px; - background-color: var(--veryLightBlue); - padding: var(--gridSize); -} - -.news-box-header { - display: flex; - align-items: center; - justify-content: space-between; -} diff --git a/server/sonar-ui-common/components/ui/NewsBox.tsx b/server/sonar-ui-common/components/ui/NewsBox.tsx deleted file mode 100644 index 27626765848..00000000000 --- a/server/sonar-ui-common/components/ui/NewsBox.tsx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import { translate } from '../../helpers/l10n'; -import { ClearButton } from '../controls/buttons'; -import './NewsBox.css'; - -export interface Props { - children: React.ReactNode; - className?: string; - onClose: () => void; - title: string; -} - -export default function NewsBox({ children, className, onClose, title }: Props) { - return ( - <div className={classNames('news-box', className)} role="alert"> - <div className="news-box-header"> - <div className="display-flex-center"> - <span className="badge badge-info spacer-right">{translate('new')}</span> - <strong>{title}</strong> - </div> - <ClearButton - className="button-tiny" - iconProps={{ size: 12, thin: true }} - onClick={onClose} - /> - </div> - <div className="big-spacer-top note">{children}</div> - </div> - ); -} diff --git a/server/sonar-ui-common/components/ui/PageActions.tsx b/server/sonar-ui-common/components/ui/PageActions.tsx deleted file mode 100644 index 8c2e4106b16..00000000000 --- a/server/sonar-ui-common/components/ui/PageActions.tsx +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { translate } from '../../helpers/l10n'; -import FilesCounter from './FilesCounter'; - -export interface Props { - current?: number; - showShortcuts?: boolean; - total?: number; -} - -export default function PageActions(props: Props) { - const { current, showShortcuts, total = 0 } = props; - - return ( - <div className="page-actions display-flex-center"> - {showShortcuts && ( - <span className="note nowrap"> - <span className="big-spacer-right"> - <span className="shortcut-button little-spacer-right">↑</span> - <span className="shortcut-button little-spacer-right">↓</span> - {translate('component_measures.to_select_files')} - </span> - - <span> - <span className="shortcut-button little-spacer-right">←</span> - <span className="shortcut-button little-spacer-right">→</span> - {translate('component_measures.to_navigate')} - </span> - </span> - )} - {total > 0 && ( - <div className="nowrap"> - <FilesCounter className="big-spacer-left" current={current} total={total} /> - </div> - )} - </div> - ); -} diff --git a/server/sonar-ui-common/components/ui/Rating.css b/server/sonar-ui-common/components/ui/Rating.css deleted file mode 100644 index 8bd2dda1a3d..00000000000 --- a/server/sonar-ui-common/components/ui/Rating.css +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.rating { - display: inline-block; - width: var(--controlHeight); - height: var(--controlHeight); - line-height: var(--controlHeight); - border-radius: var(--controlHeight); - box-sizing: border-box; - color: #fff; - font-size: var(--bigFontSize); - font-weight: 400; - text-align: center; - text-shadow: 0 0 1px rgba(0, 0, 0, 0.35); -} - -.rating-muted { - background-color: #bdbdbd !important; - color: #fff !important; - text-shadow: 0 0 1px rgba(0, 0, 0, 0.35) !important; -} - -a > .rating { - margin-bottom: -1px; - border-bottom: 1px solid; - transition: all 0.2s ease; -} - -a > .rating:hover { - opacity: 0.8; -} - -.rating-A { - line-height: 23px; - background-color: var(--green); -} - -a > .rating-A { - border-bottom-color: var(--green); -} - -.rating-B { - background-color: var(--lightGreen); -} - -a .rating-B { - border-bottom-color: var(--lightGreen); -} - -.rating-C { - background-color: var(--yellow); -} - -a .rating-C { - border-bottom-color: var(--yellow); -} - -.rating-D { - background-color: var(--orange); -} - -a .rating-D { - border-bottom-color: var(--orange); -} - -.rating-E { - background-color: var(--red); -} - -a .rating-E { - border-bottom-color: var(--red); -} - -.rating-small { - width: 18px; - height: 18px; - line-height: 18px; - margin-top: -1px; - margin-bottom: -1px; - font-size: var(--smallFontSize); -} diff --git a/server/sonar-ui-common/components/ui/Rating.tsx b/server/sonar-ui-common/components/ui/Rating.tsx deleted file mode 100644 index 91c661ffc97..00000000000 --- a/server/sonar-ui-common/components/ui/Rating.tsx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import * as React from 'react'; -import { translate, translateWithParameters } from '../../helpers/l10n'; -import { formatMeasure } from '../../helpers/measures'; -import './Rating.css'; - -interface Props extends React.AriaAttributes { - className?: string; - muted?: boolean; - small?: boolean; - value: string | number | undefined; -} - -export default function Rating({ - className, - muted = false, - small = false, - value, - ...ariaAttrs -}: Props) { - if (value === undefined) { - return ( - <span aria-label={translate('metric.no_rating')} {...ariaAttrs}> - – - </span> - ); - } - const formatted = formatMeasure(value, 'RATING'); - return ( - <span - aria-label={translateWithParameters('metric.has_rating_X', formatted)} - className={classNames( - 'rating', - `rating-${formatted}`, - { 'rating-small': small, 'rating-muted': muted }, - className - )} - {...ariaAttrs}> - {formatted} - </span> - ); -} diff --git a/server/sonar-ui-common/components/ui/SizeRating.css b/server/sonar-ui-common/components/ui/SizeRating.css deleted file mode 100644 index 4403c162271..00000000000 --- a/server/sonar-ui-common/components/ui/SizeRating.css +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.size-rating { - display: inline-block; - vertical-align: top; - width: var(--controlHeight); - height: var(--controlHeight); - line-height: var(--controlHeight); - border-radius: var(--controlHeight); - background-color: var(--blue); - color: #fff; - font-size: var(--smallFontSize); - text-align: center; - text-shadow: 0 0 1px rgba(0, 0, 0, 0.35); -} - -.size-rating-small { - width: 18px; - height: 18px; - line-height: 18px; - margin-top: -1px; - margin-bottom: -1px; - font-size: 10px; -} - -.size-rating-muted { - background-color: #bdbdbd; -} diff --git a/server/sonar-ui-common/components/ui/SizeRating.tsx b/server/sonar-ui-common/components/ui/SizeRating.tsx deleted file mode 100644 index 190c5a3205a..00000000000 --- a/server/sonar-ui-common/components/ui/SizeRating.tsx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import { inRange } from 'lodash'; -import * as React from 'react'; -import './SizeRating.css'; - -export interface Props { - muted?: boolean; - small?: boolean; - value: number | null | undefined; -} - -export default function SizeRating({ small = false, muted = false, value }: Props) { - if (value == null) { - return <div className="size-rating size-rating-muted"> </div>; - } - - let letter; - if (inRange(value, 0, 1000)) { - letter = 'XS'; - } else if (inRange(value, 1000, 10000)) { - letter = 'S'; - } else if (inRange(value, 10000, 100000)) { - letter = 'M'; - } else if (inRange(value, 100000, 500000)) { - letter = 'L'; - } else if (value >= 500000) { - letter = 'XL'; - } - - const className = classNames('size-rating', { - 'size-rating-small': small, - 'size-rating-muted': muted, - }); - - return ( - <div aria-hidden="true" className={className}> - {letter} - </div> - ); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/Alert-test.tsx b/server/sonar-ui-common/components/ui/__tests__/Alert-test.tsx deleted file mode 100644 index baed94e98bc..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/Alert-test.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { Alert, AlertProps } from '../Alert'; - -it('should render properly', () => { - expect(shallowRender({ variant: 'error' })).toMatchSnapshot(); -}); - -it('verification of all variants of alert', () => { - const variants: AlertProps['variant'][] = ['error', 'warning', 'success', 'info', 'loading']; - variants.forEach((variant) => { - const wrapper = shallowRender({ variant }); - expect(wrapper.prop('variantInfo')).toMatchSnapshot(); - }); -}); - -it('should render inline alert', () => { - expect(shallowRender({ display: 'inline' }).find('Styled(div)[isInline=true]').exists()).toBe( - true - ); -}); - -it('should render banner alert', () => { - expect(shallowRender({ display: 'banner' }).find('Styled(div)[isBanner=true]').exists()).toBe( - true - ); -}); - -it('should render banner alert with correct css', () => { - expect(shallowRender({ display: 'banner' }).render()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<AlertProps>) { - return shallow( - <Alert className="alert-test" id="error-message" variant="error" {...props}> - This is an error! - </Alert> - ); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/AutoEllipsis-test.tsx b/server/sonar-ui-common/components/ui/__tests__/AutoEllipsis-test.tsx deleted file mode 100644 index 5d3411078cf..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/AutoEllipsis-test.tsx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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, shallow } from 'enzyme'; -import * as React from 'react'; -import AutoEllipsis, { defaultShouldEllipsis } from '../AutoEllipsis'; - -it('should render', () => { - const wrapper = shallow( - <AutoEllipsis maxWidth={5} useParent={false}> - <span className="medium">my test text</span> - </AutoEllipsis> - ); - - expect(wrapper).toMatchSnapshot(); -}); - -it('should render with text-ellipsis class', () => { - const wrapper = mount( - <AutoEllipsis customShouldEllipsis={() => true} maxWidth={5} useParent={false}> - <span className="medium">my test text</span> - </AutoEllipsis> - ); - - expect(wrapper.find('span').hasClass('medium')).toBe(true); - expect(wrapper.find('span').hasClass('text-ellipsis')).toBe(true); -}); - -const node5 = { clientWidth: 5, clientHeight: 5 } as any; -const node10 = { clientWidth: 10, clientHeight: 10 } as any; -const nodeParentSmaller = { ...node10, parentElement: node5 }; -const nodeParentBigger = { ...node5, parentElement: node10 }; - -it('should correctly compute the auto-ellipsis', () => { - expect(defaultShouldEllipsis(node10, { maxWidth: 5, useParent: false })).toBe(true); - expect(defaultShouldEllipsis(node10, { maxHeight: 5, useParent: false })).toBe(true); - expect(defaultShouldEllipsis(node10, { maxWidth: 5, maxHeight: 5, useParent: false })).toBe(true); - expect(defaultShouldEllipsis(node10, { maxWidth: 5, maxHeight: 10, useParent: false })).toBe( - true - ); - expect(defaultShouldEllipsis(node10, { maxWidth: 10, maxHeight: 5, useParent: false })).toBe( - true - ); - expect(defaultShouldEllipsis(node10, { maxWidth: 10, useParent: false })).toBe(false); - expect(defaultShouldEllipsis(node10, { maxHeight: 10, useParent: false })).toBe(false); - - expect(defaultShouldEllipsis(nodeParentSmaller, { maxWidth: 10, useParent: false })).toBe(false); - expect(defaultShouldEllipsis(nodeParentSmaller, { maxHeight: 10, useParent: false })).toBe(false); -}); - -it('should correctly compute the auto-ellipsis with a parent node', () => { - expect(defaultShouldEllipsis(nodeParentSmaller, {})).toBe(true); - expect(defaultShouldEllipsis(nodeParentSmaller, { maxWidth: 10 })).toBe(true); - expect(defaultShouldEllipsis(nodeParentSmaller, { maxHeight: 10 })).toBe(true); - expect(defaultShouldEllipsis(nodeParentSmaller, { maxWidth: 10, maxHeight: 10 })).toBe(false); - expect(defaultShouldEllipsis(nodeParentBigger, {})).toBe(false); - expect(defaultShouldEllipsis(nodeParentBigger, { maxWidth: 2 })).toBe(true); - expect(defaultShouldEllipsis(nodeParentBigger, { maxHeight: 2 })).toBe(true); -}); diff --git a/server/sonar-ui-common/components/ui/__tests__/DeferredSpinner-test.tsx b/server/sonar-ui-common/components/ui/__tests__/DeferredSpinner-test.tsx deleted file mode 100644 index 8a7bc268499..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/DeferredSpinner-test.tsx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 DeferredSpinner from '../DeferredSpinner'; - -jest.useFakeTimers(); - -it('renders spinner after timeout', () => { - const spinner = mount(<DeferredSpinner />); - expect(spinner).toMatchSnapshot(); - jest.runAllTimers(); - spinner.update(); - expect(spinner).toMatchSnapshot(); -}); - -it('add custom className', () => { - const spinner = mount(<DeferredSpinner className="foo" />); - jest.runAllTimers(); - spinner.update(); - expect(spinner).toMatchSnapshot(); -}); - -it('renders children before timeout', () => { - const spinner = mount( - <DeferredSpinner> - <div>foo</div> - </DeferredSpinner> - ); - expect(spinner).toMatchSnapshot(); - jest.runAllTimers(); - spinner.update(); - expect(spinner).toMatchSnapshot(); -}); - -it('is controlled by loading prop', () => { - const spinner = mount( - <DeferredSpinner loading={false}> - <div>foo</div> - </DeferredSpinner> - ); - expect(spinner).toMatchSnapshot(); - spinner.setProps({ loading: true }); - expect(spinner).toMatchSnapshot(); - jest.runAllTimers(); - spinner.update(); - expect(spinner).toMatchSnapshot(); - spinner.setProps({ loading: false }); - spinner.update(); - expect(spinner).toMatchSnapshot(); -}); - -it('renders a placeholder while waiting', () => { - const spinner = mount(<DeferredSpinner placeholder={true} />); - expect(spinner).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/ui/__tests__/FilesCounter-test.tsx b/server/sonar-ui-common/components/ui/__tests__/FilesCounter-test.tsx deleted file mode 100644 index 2f020368cdb..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/FilesCounter-test.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 FilesCounter from '../FilesCounter'; - -it('should display x files on y total', () => { - expect(shallow(<FilesCounter current={12} total={123455} />)).toMatchSnapshot(); -}); - -it('should display only total of files', () => { - expect(shallow(<FilesCounter current={undefined} total={123455} />)).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/ui/__tests__/GenericAvatar-test.tsx b/server/sonar-ui-common/components/ui/__tests__/GenericAvatar-test.tsx deleted file mode 100644 index d244490dcd9..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/GenericAvatar-test.tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 GenericAvatar from '../GenericAvatar'; - -it('should render properly', () => { - expect(shallow(<GenericAvatar name="foo" size={40} />)).toMatchSnapshot(); - expect(shallow(<GenericAvatar name="foo" size={40} round={true} />)).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/ui/__tests__/Level-test.tsx b/server/sonar-ui-common/components/ui/__tests__/Level-test.tsx deleted file mode 100644 index 8f52a420665..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/Level-test.tsx +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 Level, { LevelProps } from '../Level'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default ok'); - expect(shallowRender({ level: 'ERROR' })).toMatchSnapshot('default error'); - expect(shallowRender({ muted: true, small: true })).toMatchSnapshot('muted and small'); - expect(shallowRender({ 'aria-label': 'ARIA Label' })).toMatchSnapshot('with aria-label'); - expect(shallowRender({ 'aria-labelledby': 'element-id' })).toMatchSnapshot( - 'with aria-labelledby' - ); -}); - -function shallowRender(props: Partial<LevelProps> = {}) { - return shallow(<Level className="foo" level="OK" {...props} />); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/MandatoryFieldMarker-test.tsx b/server/sonar-ui-common/components/ui/__tests__/MandatoryFieldMarker-test.tsx deleted file mode 100644 index 8cd043086c2..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/MandatoryFieldMarker-test.tsx +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 MandatoryFieldMarker, { MandatoryFieldMarkerProps } from '../MandatoryFieldMarker'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ className: 'foo-bar' })).toMatchSnapshot('with className'); -}); - -function shallowRender(props: Partial<MandatoryFieldMarkerProps> = {}) { - return shallow<MandatoryFieldMarkerProps>(<MandatoryFieldMarker {...props} />); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/MandatoryFieldsExplanation-test.tsx b/server/sonar-ui-common/components/ui/__tests__/MandatoryFieldsExplanation-test.tsx deleted file mode 100644 index 5104f1cfbad..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/MandatoryFieldsExplanation-test.tsx +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 MandatoryFieldsExplanation, { - MandatoryFieldsExplanationProps, -} from '../MandatoryFieldsExplanation'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ className: 'foo-bar' })).toMatchSnapshot('with className'); -}); - -function shallowRender(props: Partial<MandatoryFieldsExplanationProps> = {}) { - return shallow<MandatoryFieldsExplanationProps>(<MandatoryFieldsExplanation {...props} />); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/NavBar-test.tsx b/server/sonar-ui-common/components/ui/__tests__/NavBar-test.tsx deleted file mode 100644 index 1db05af50e0..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/NavBar-test.tsx +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 NavBar, { NavBarProps } from '../NavBar'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); -}); - -it('should render correctly with notif and not limited', () => { - const wrapper = shallowRender({ limited: false, notif: <div className="my-notifs" /> }); - expect(wrapper).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<NavBarProps> = {}) { - return shallow( - <NavBar height={42} {...props}> - <div className="my-navbar-content" /> - </NavBar> - ); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/NewsBox-test.tsx b/server/sonar-ui-common/components/ui/__tests__/NewsBox-test.tsx deleted file mode 100644 index 8b46a49efbc..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/NewsBox-test.tsx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { click } from '../../../helpers/testUtils'; -import NewsBox, { Props } from '../NewsBox'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should call onClose', () => { - const onClose = jest.fn(); - const wrapper = shallowRender({ onClose }); - - click(wrapper.find('ClearButton')); - expect(onClose).toBeCalled(); -}); - -function shallowRender(props: Partial<Props> = {}) { - return shallow( - <NewsBox onClose={jest.fn()} title="title" {...props}> - <div>description</div> - </NewsBox> - ); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/PageActions-test.tsx b/server/sonar-ui-common/components/ui/__tests__/PageActions-test.tsx deleted file mode 100644 index 46594418d3a..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/PageActions-test.tsx +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 PageActions, { Props } from '../PageActions'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ total: 10 })).toMatchSnapshot(); - expect(shallowRender({ current: 12, showShortcuts: false, total: 120 })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<Props> = {}) { - return shallow(<PageActions showShortcuts={true} {...props} />); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/Rating-test.tsx b/server/sonar-ui-common/components/ui/__tests__/Rating-test.tsx deleted file mode 100644 index f8f1540adfc..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/Rating-test.tsx +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 Rating from '../Rating'; - -it('renders numeric value', () => { - expect(shallow(<Rating value={2} />)).toMatchSnapshot(); -}); - -it('renders string value', () => { - expect(shallow(<Rating value="2.0" muted={true} small={true} />)).toMatchSnapshot(); -}); - -it('renders undefined value', () => { - expect(shallow(<Rating value={undefined} muted={true} small={true} />)).toMatchSnapshot(); -}); - -it('renders with a custom aria-label', () => { - expect(shallow(<Rating aria-label="custom" aria-hidden={false} value="2.0" />)).toMatchSnapshot(); - expect( - shallow(<Rating aria-label="custom" aria-hidden={false} value={undefined} />) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/ui/__tests__/SizeRating-test.tsx b/server/sonar-ui-common/components/ui/__tests__/SizeRating-test.tsx deleted file mode 100644 index 7c3b8e3b005..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/SizeRating-test.tsx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 SizeRating, { Props } from '../SizeRating'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ muted: true, small: true, value: 1000 })).toMatchSnapshot(); - expect(shallowRender({ value: 10000 })).toMatchSnapshot(); - expect(shallowRender({ value: 100000 })).toMatchSnapshot(); - expect(shallowRender({ value: 500000 })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<Props> = {}) { - return shallow(<SizeRating value={100} {...props} />); -} diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Alert-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Alert-test.tsx.snap deleted file mode 100644 index 893212cc564..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Alert-test.tsx.snap +++ /dev/null @@ -1,207 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render banner alert with correct css 1`] = ` -.emotion-3 { - border: 1px solid; - border-radius: 2px; - margin-bottom: 8px; - border-color: #f4b1b0; - background-color: #f2dede; - color: #862422; - display: block; -} - -.emotion-3:empty { - display: none; -} - -.emotion-3 a, -.emotion-3 .button-link { - border-color: #236a97; -} - -.emotion-2 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: stretch; - -webkit-box-align: stretch; - -ms-flex-align: stretch; - align-items: stretch; - min-width: 1080px; - max-width: 1320px; - margin-left: auto; - margin-right: auto; - padding-left: 20px; - padding-right: 20px; - box-sizing: border-box; -} - -.emotion-0 { - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: center; - -webkit-justify-content: center; - -ms-flex-pack: center; - justify-content: center; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - width: calc(2 * 8px); - border-right: none; - border-color: #f4b1b0; -} - -.emotion-1 { - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - overflow: auto; - text-align: left; - padding: 8px calc(2 * 8px); -} - -<div - class="alert alert-test emotion-3" - id="error-message" - role="alert" -> - <div - class="emotion-2" - > - <div - aria-label="alert.tooltip.error" - class="emotion-0" - > - <svg - height="16" - space="preserve" - style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421" - version="1.1" - viewBox="0 0 16 16" - width="16" - xlink="http://www.w3.org/1999/xlink" - > - <path - d="M11.402 10.018q0-0.232-0.17-0.402l-1.616-1.616 1.616-1.616q0.17-0.17 0.17-0.402 0-0.241-0.17-0.411l-0.804-0.804q-0.17-0.17-0.411-0.17-0.232 0-0.402 0.17l-1.616 1.616-1.616-1.616q-0.17-0.17-0.402-0.17-0.241 0-0.411 0.17l-0.804 0.804q-0.17 0.17-0.17 0.411 0 0.232 0.17 0.402l1.616 1.616-1.616 1.616q-0.17 0.17-0.17 0.402 0 0.241 0.17 0.411l0.804 0.804q0.17 0.17 0.411 0.17 0.232 0 0.402-0.17l1.616-1.616 1.616 1.616q0.17 0.17 0.402 0.17 0.241 0 0.411-0.17l0.804-0.804q0.17-0.17 0.17-0.411zM14.857 8q0 1.866-0.92 3.442t-2.496 2.496-3.442 0.92-3.442-0.92-2.496-2.496-0.92-3.442 0.92-3.442 2.496-2.496 3.442-0.92 3.442 0.92 2.496 2.496 0.92 3.442z" - style="fill:#a4030f" - /> - </svg> - </div> - <div - class="alert-content emotion-1" - > - This is an error! - </div> - </div> -</div> -`; - -exports[`should render properly 1`] = ` -<Styled(div) - className="alert alert-test" - id="error-message" - isInline={false} - role="alert" - variantInfo={ - Object { - "backGroundColor": "#f2dede", - "borderColor": "#f4b1b0", - "color": "#862422", - "icon": <AlertErrorIcon - fill="#a4030f" - />, - } - } -> - <Styled(div) - isBanner={false} - > - <Styled(div) - aria-label="alert.tooltip.error" - isBanner={false} - variantInfo={ - Object { - "backGroundColor": "#f2dede", - "borderColor": "#f4b1b0", - "color": "#862422", - "icon": <AlertErrorIcon - fill="#a4030f" - />, - } - } - > - <AlertErrorIcon - fill="#a4030f" - /> - </Styled(div)> - <Styled(div) - className="alert-content" - > - This is an error! - </Styled(div)> - </Styled(div)> -</Styled(div)> -`; - -exports[`verification of all variants of alert 1`] = ` -Object { - "backGroundColor": "#f2dede", - "borderColor": "#f4b1b0", - "color": "#862422", - "icon": <AlertErrorIcon - fill="#a4030f" - />, -} -`; - -exports[`verification of all variants of alert 2`] = ` -Object { - "backGroundColor": "#fcf8e3", - "borderColor": "#faebcc", - "color": "#6f4f17", - "icon": <AlertWarnIcon - fill="#db781a" - />, -} -`; - -exports[`verification of all variants of alert 3`] = ` -Object { - "backGroundColor": "#dff0d8", - "borderColor": "#d6e9c6", - "color": "#215821", - "icon": <AlertSuccessIcon - fill="#6d9867" - />, -} -`; - -exports[`verification of all variants of alert 4`] = ` -Object { - "backGroundColor": "#d9edf7", - "borderColor": "#b1dff3", - "color": "#0e516f", - "icon": <InfoIcon - fill="#0271b9" - />, -} -`; - -exports[`verification of all variants of alert 5`] = ` -Object { - "backGroundColor": "#d9edf7", - "borderColor": "#b1dff3", - "color": "#0e516f", - "icon": <DeferredSpinner - timeout={0} - />, -} -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/AutoEllipsis-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/AutoEllipsis-test.tsx.snap deleted file mode 100644 index 84212d45e27..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/AutoEllipsis-test.tsx.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render 1`] = ` -<span - className="medium" -> - my test text -</span> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/DeferredSpinner-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/DeferredSpinner-test.tsx.snap deleted file mode 100644 index 6822674e7d2..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/DeferredSpinner-test.tsx.snap +++ /dev/null @@ -1,87 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`add custom className 1`] = ` -<DeferredSpinner - className="foo" -> - <i - className="deferred-spinner foo" - /> -</DeferredSpinner> -`; - -exports[`is controlled by loading prop 1`] = ` -<DeferredSpinner - loading={false} -> - <div> - foo - </div> -</DeferredSpinner> -`; - -exports[`is controlled by loading prop 2`] = ` -<DeferredSpinner - loading={true} -> - <div> - foo - </div> -</DeferredSpinner> -`; - -exports[`is controlled by loading prop 3`] = ` -<DeferredSpinner - loading={true} -> - <i - className="deferred-spinner" - /> -</DeferredSpinner> -`; - -exports[`is controlled by loading prop 4`] = ` -<DeferredSpinner - loading={false} -> - <div> - foo - </div> -</DeferredSpinner> -`; - -exports[`renders a placeholder while waiting 1`] = ` -<DeferredSpinner - placeholder={true} -> - <i - className="deferred-spinner-placeholder" - /> -</DeferredSpinner> -`; - -exports[`renders children before timeout 1`] = ` -<DeferredSpinner> - <div> - foo - </div> -</DeferredSpinner> -`; - -exports[`renders children before timeout 2`] = ` -<DeferredSpinner> - <i - className="deferred-spinner" - /> -</DeferredSpinner> -`; - -exports[`renders spinner after timeout 1`] = `<DeferredSpinner />`; - -exports[`renders spinner after timeout 2`] = ` -<DeferredSpinner> - <i - className="deferred-spinner" - /> -</DeferredSpinner> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/FilesCounter-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/FilesCounter-test.tsx.snap deleted file mode 100644 index bb01a6121da..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/FilesCounter-test.tsx.snap +++ /dev/null @@ -1,25 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should display only total of files 1`] = ` -<span> - <strong> - 123,455 - </strong> - - component_measures.files -</span> -`; - -exports[`should display x files on y total 1`] = ` -<span> - <strong> - <span> - 12 - / - </span> - 123,455 - </strong> - - component_measures.files -</span> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/GenericAvatar-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/GenericAvatar-test.tsx.snap deleted file mode 100644 index 9c2bb0fa7fd..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/GenericAvatar-test.tsx.snap +++ /dev/null @@ -1,47 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render properly 1`] = ` -<div - className="rounded" - style={ - Object { - "backgroundColor": "#c68c01", - "borderRadius": undefined, - "color": "#fff", - "display": "inline-block", - "fontSize": 14, - "fontWeight": "normal", - "height": 40, - "lineHeight": "40px", - "textAlign": "center", - "verticalAlign": "top", - "width": 40, - } - } -> - F -</div> -`; - -exports[`should render properly 2`] = ` -<div - className="rounded" - style={ - Object { - "backgroundColor": "#c68c01", - "borderRadius": "50%", - "color": "#fff", - "display": "inline-block", - "fontSize": 14, - "fontWeight": "normal", - "height": 40, - "lineHeight": "40px", - "textAlign": "center", - "verticalAlign": "top", - "width": 40, - } - } -> - F -</div> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Level-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Level-test.tsx.snap deleted file mode 100644 index 089171fcc17..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Level-test.tsx.snap +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default error 1`] = ` -<span - className="foo level level-ERROR" -> - ERROR -</span> -`; - -exports[`should render correctly: default ok 1`] = ` -<span - className="foo level level-OK" -> - OK -</span> -`; - -exports[`should render correctly: muted and small 1`] = ` -<span - className="foo level level-OK level-small level-muted" -> - OK -</span> -`; - -exports[`should render correctly: with aria-label 1`] = ` -<span - aria-label="ARIA Label" - className="foo level level-OK" -> - OK -</span> -`; - -exports[`should render correctly: with aria-labelledby 1`] = ` -<span - aria-labelledby="element-id" - className="foo level level-OK" -> - OK -</span> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/MandatoryFieldMarker-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/MandatoryFieldMarker-test.tsx.snap deleted file mode 100644 index 1adb77718dd..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/MandatoryFieldMarker-test.tsx.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -<em - aria-label="field_required" - className="mandatory little-spacer-left" -> - * -</em> -`; - -exports[`should render correctly: with className 1`] = ` -<em - aria-label="field_required" - className="mandatory little-spacer-left foo-bar" -> - * -</em> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/MandatoryFieldsExplanation-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/MandatoryFieldsExplanation-test.tsx.snap deleted file mode 100644 index ca469b7e71c..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/MandatoryFieldsExplanation-test.tsx.snap +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -<div - aria-hidden={true} - className="text-muted" -> - <FormattedMessage - defaultMessage="fields_marked_with_x_required" - id="fields_marked_with_x_required" - values={ - Object { - "star": <em - className="mandatory" - > - * - </em>, - } - } - /> -</div> -`; - -exports[`should render correctly: with className 1`] = ` -<div - aria-hidden={true} - className="text-muted foo-bar" -> - <FormattedMessage - defaultMessage="fields_marked_with_x_required" - id="fields_marked_with_x_required" - values={ - Object { - "star": <em - className="mandatory" - > - * - </em>, - } - } - /> -</div> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/NavBar-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/NavBar-test.tsx.snap deleted file mode 100644 index a039d0ebb24..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/NavBar-test.tsx.snap +++ /dev/null @@ -1,64 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<nav - className="navbar" - style={ - Object { - "height": 42, - "top": undefined, - } - } -> - <div - className="navbar-inner" - style={ - Object { - "height": 42, - "left": 0, - } - } - > - <div - className="clearfix navbar-limited" - > - <div - className="my-navbar-content" - /> - </div> - </div> -</nav> -`; - -exports[`should render correctly with notif and not limited 1`] = ` -<nav - className="navbar" - style={ - Object { - "height": 42, - "top": undefined, - } - } -> - <div - className="navbar-inner navbar-inner-with-notif" - style={ - Object { - "height": 42, - "left": 0, - } - } - > - <div - className="clearfix" - > - <div - className="my-navbar-content" - /> - </div> - <div - className="my-notifs" - /> - </div> -</nav> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/NewsBox-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/NewsBox-test.tsx.snap deleted file mode 100644 index 91e58894fbf..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/NewsBox-test.tsx.snap +++ /dev/null @@ -1,42 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - className="news-box" - role="alert" -> - <div - className="news-box-header" - > - <div - className="display-flex-center" - > - <span - className="badge badge-info spacer-right" - > - new - </span> - <strong> - title - </strong> - </div> - <ClearButton - className="button-tiny" - iconProps={ - Object { - "size": 12, - "thin": true, - } - } - onClick={[MockFunction]} - /> - </div> - <div - className="big-spacer-top note" - > - <div> - description - </div> - </div> -</div> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/PageActions-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/PageActions-test.tsx.snap deleted file mode 100644 index bb220fbacaf..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/PageActions-test.tsx.snap +++ /dev/null @@ -1,103 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - className="page-actions display-flex-center" -> - <span - className="note nowrap" - > - <span - className="big-spacer-right" - > - <span - className="shortcut-button little-spacer-right" - > - ↑ - </span> - <span - className="shortcut-button little-spacer-right" - > - ↓ - </span> - component_measures.to_select_files - </span> - <span> - <span - className="shortcut-button little-spacer-right" - > - ← - </span> - <span - className="shortcut-button little-spacer-right" - > - → - </span> - component_measures.to_navigate - </span> - </span> -</div> -`; - -exports[`should render correctly 2`] = ` -<div - className="page-actions display-flex-center" -> - <span - className="note nowrap" - > - <span - className="big-spacer-right" - > - <span - className="shortcut-button little-spacer-right" - > - ↑ - </span> - <span - className="shortcut-button little-spacer-right" - > - ↓ - </span> - component_measures.to_select_files - </span> - <span> - <span - className="shortcut-button little-spacer-right" - > - ← - </span> - <span - className="shortcut-button little-spacer-right" - > - → - </span> - component_measures.to_navigate - </span> - </span> - <div - className="nowrap" - > - <FilesCounter - className="big-spacer-left" - total={10} - /> - </div> -</div> -`; - -exports[`should render correctly 3`] = ` -<div - className="page-actions display-flex-center" -> - <div - className="nowrap" - > - <FilesCounter - className="big-spacer-left" - current={12} - total={120} - /> - </div> -</div> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Rating-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Rating-test.tsx.snap deleted file mode 100644 index 9455ce98965..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/Rating-test.tsx.snap +++ /dev/null @@ -1,46 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders numeric value 1`] = ` -<span - aria-label="metric.has_rating_X.B" - className="rating rating-B" -> - B -</span> -`; - -exports[`renders string value 1`] = ` -<span - aria-label="metric.has_rating_X.B" - className="rating rating-B rating-small rating-muted" -> - B -</span> -`; - -exports[`renders undefined value 1`] = ` -<span - aria-label="metric.no_rating" -> - – -</span> -`; - -exports[`renders with a custom aria-label 1`] = ` -<span - aria-hidden={false} - aria-label="custom" - className="rating rating-B" -> - B -</span> -`; - -exports[`renders with a custom aria-label 2`] = ` -<span - aria-hidden={false} - aria-label="custom" -> - – -</span> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/SizeRating-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/SizeRating-test.tsx.snap deleted file mode 100644 index a35517cc685..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/SizeRating-test.tsx.snap +++ /dev/null @@ -1,46 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - aria-hidden="true" - className="size-rating" -> - XS -</div> -`; - -exports[`should render correctly 2`] = ` -<div - aria-hidden="true" - className="size-rating size-rating-small size-rating-muted" -> - S -</div> -`; - -exports[`should render correctly 3`] = ` -<div - aria-hidden="true" - className="size-rating" -> - M -</div> -`; - -exports[`should render correctly 4`] = ` -<div - aria-hidden="true" - className="size-rating" -> - L -</div> -`; - -exports[`should render correctly 5`] = ` -<div - aria-hidden="true" - className="size-rating" -> - XL -</div> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/popups-test.tsx.snap b/server/sonar-ui-common/components/ui/__tests__/__snapshots__/popups-test.tsx.snap deleted file mode 100644 index 87b7811eb17..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/__snapshots__/popups-test.tsx.snap +++ /dev/null @@ -1,79 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Popup should render Popup 1`] = ` -<ClickEventBoundary> - <div - className="popup is-left-top foo" - style={ - Object { - "left": -5, - } - } - > - <PopupArrow - style={ - Object { - "top": -5, - } - } - /> - </div> -</ClickEventBoundary> -`; - -exports[`Popup should render PopupArrow 1`] = ` -<div - className="popup-arrow" - style={ - Object { - "left": -5, - } - } -/> -`; - -exports[`PortalPopup should render correctly with overlay 1`] = ` -<Fragment> - <div - id="popup-trigger" - /> - <PortalWrapper> - <WithTheme(ScreenPositionFixer) - ready={true} - > - <Component /> - </WithTheme(ScreenPositionFixer)> - </PortalWrapper> -</Fragment> -`; - -exports[`PortalPopup should render correctly with overlay 2`] = ` -<Popup - arrowStyle={ - Object { - "marginLeft": 0, - } - } - placement="bottom" - style={ - Object { - "height": 10, - "left": 0, - "top": 0, - "width": 10, - } - } -> - <span - id="overlay" - /> -</Popup> -`; - -exports[`PortalPopup should render correctly without overlay 1`] = ` -<Fragment> - <div - id="popup-trigger" - /> -</Fragment> -`; diff --git a/server/sonar-ui-common/components/ui/__tests__/popups-test.tsx b/server/sonar-ui-common/components/ui/__tests__/popups-test.tsx deleted file mode 100644 index c014d824b6f..00000000000 --- a/server/sonar-ui-common/components/ui/__tests__/popups-test.tsx +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { findDOMNode } from 'react-dom'; -import ScreenPositionFixer from '../../controls/ScreenPositionFixer'; -import { Popup, PopupArrow, PopupPlacement, PortalPopup } from '../popups'; - -jest.mock('react-dom', () => ({ - ...jest.requireActual('react-dom'), - findDOMNode: jest.fn().mockReturnValue(undefined), -})); - -describe('Popup', () => { - it('should render Popup', () => { - expect( - shallow( - <Popup - arrowStyle={{ top: -5 }} - className="foo" - placement={PopupPlacement.LeftTop} - style={{ left: -5 }} - /> - ) - ).toMatchSnapshot(); - }); - - it('should render PopupArrow', () => { - expect(shallow(<PopupArrow style={{ left: -5 }} />)).toMatchSnapshot(); - }); -}); - -describe('PortalPopup', () => { - it('should render correctly without overlay', () => { - expect(shallowRender({ overlay: undefined })).toMatchSnapshot(); - }); - - it('should render correctly with overlay', () => { - const wrapper = shallowRender(); - wrapper.setState({ left: 0, top: 0, width: 10, height: 10 }); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find(ScreenPositionFixer).dive().dive().dive()).toMatchSnapshot(); - }); - - it('should correctly compute the popup positioning', () => { - const fakeDomNode = document.createElement('div'); - fakeDomNode.getBoundingClientRect = jest - .fn() - .mockReturnValue({ left: 10, top: 10, width: 10, height: 10 }); - (findDOMNode as jest.Mock).mockReturnValue(fakeDomNode); - const wrapper = shallowRender(); - const getPlacementSpy = jest.spyOn(wrapper.instance(), 'getPlacement'); - - wrapper.instance().popupNode = { - current: { - getBoundingClientRect: jest.fn().mockReturnValue({ width: 8, height: 8 }), - } as any, - }; - - wrapper.instance().positionPopup(); - expect(wrapper.state()).toEqual(expect.objectContaining({ left: 11, top: 20 })); - - getPlacementSpy.mockReturnValue(PopupPlacement.BottomLeft); - wrapper.instance().positionPopup(); - expect(wrapper.state()).toEqual(expect.objectContaining({ left: 10, top: 20 })); - - getPlacementSpy.mockReturnValue(PopupPlacement.BottomRight); - wrapper.instance().positionPopup(); - expect(wrapper.state()).toEqual(expect.objectContaining({ left: 12, top: 20 })); - - getPlacementSpy.mockReturnValue(PopupPlacement.LeftTop); - wrapper.instance().positionPopup(); - expect(wrapper.state()).toEqual(expect.objectContaining({ left: 2, top: 10 })); - - getPlacementSpy.mockReturnValue(PopupPlacement.RightBottom); - wrapper.instance().positionPopup(); - expect(wrapper.state()).toEqual(expect.objectContaining({ left: 20, top: 12 })); - - getPlacementSpy.mockReturnValue(PopupPlacement.RightTop); - wrapper.instance().positionPopup(); - expect(wrapper.state()).toEqual(expect.objectContaining({ left: 20, top: 10 })); - - getPlacementSpy.mockReturnValue(PopupPlacement.TopLeft); - wrapper.instance().positionPopup(); - expect(wrapper.state()).toEqual(expect.objectContaining({ left: 10, top: 2 })); - }); - - it('should correctly compute the popup arrow positioning', () => { - const wrapper = shallowRender({ arrowOffset: -2 }); - - expect( - wrapper.instance().adjustArrowPosition(PopupPlacement.BottomLeft, { leftFix: 10, topFix: 10 }) - ).toEqual({ marginLeft: -12 }); - - expect( - wrapper - .instance() - .adjustArrowPosition(PopupPlacement.RightBottom, { leftFix: 10, topFix: 10 }) - ).toEqual({ marginTop: -12 }); - }); - - function shallowRender(props: Partial<PortalPopup['props']> = {}) { - return shallow<PortalPopup>( - <PortalPopup overlay={<span id="overlay" />} {...props}> - <div id="popup-trigger" /> - </PortalPopup> - ); - } -}); diff --git a/server/sonar-ui-common/components/ui/popups.css b/server/sonar-ui-common/components/ui/popups.css deleted file mode 100644 index f7bb71b188c..00000000000 --- a/server/sonar-ui-common/components/ui/popups.css +++ /dev/null @@ -1,288 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.popup { - position: absolute; - z-index: var(--popupZIndex); - margin-top: -16px; - margin-left: 8px; - padding: var(--gridSize); - border: 1px solid var(--barBorderColor); - border-radius: 3px; - box-sizing: border-box; - background-color: #ffffff; - box-shadow: var(--defaultShadow); - cursor: default; -} - -.popup.no-padding { - padding: 0; -} - -/* #region .popup-arrow */ -.popup-arrow, -.popup-arrow:after { - position: absolute; - display: block; - width: 0; - height: 0; - border: 6px solid transparent; -} - -.popup-arrow { - top: 15px; - left: -6px; - border-left-width: 0; - border-right-color: var(--barBorderColor); -} - -.popup-arrow:after { - content: ' '; - left: 1px; - bottom: -6px; - border-left-width: 0; - border-right-color: #ffffff; -} -/* #endregion */ - -/* #region .popup.is-bottom */ -.popup.is-bottom { - top: 100%; - left: 0; - margin: 0; - margin-left: 50%; - transform: translate(-50%, 6px); -} - -.popup.is-bottom .popup-arrow { - top: -6px; - left: calc(50% - 6px); - border-left-width: 6px; - border-top-width: 0; - border-right-color: transparent; - border-bottom-color: var(--barBorderColor); -} - -.popup.is-bottom .popup-arrow.is-left { - left: 8px; -} - -.popup.is-bottom .popup-arrow:after { - left: -6px; - bottom: -7px; - border-left-width: 6px; - border-top-width: 0; - border-right-color: transparent; - border-bottom-color: #ffffff; -} -/* #endregion */ - -/* #region .popup.is-bottom-right */ -.popup.is-bottom-right { - top: 100%; - right: 0; - margin: 0; - - /* TODO Update like .is-bottom-left, currently it's */ - transform: translateY(6px); -} - -.popup.is-bottom-right .popup-arrow { - top: -6px; - left: auto; - right: 8px; - border-left-width: 6px; - border-top-width: 0; - border-right-color: transparent; - border-bottom-color: var(--barBorderColor); -} - -.popup.is-bottom-right .popup-arrow:after { - left: -6px; - bottom: -7px; - border-left-width: 6px; - border-top-width: 0; - border-right-color: transparent; - border-bottom-color: #ffffff; -} -/* #endregion */ - -/* #region .popup.is-bottom-left */ -.popup.is-bottom-left { - top: 100%; - left: 0; - margin: 0; - transform: translate(-8px, 6px); -} - -.popup.is-bottom-left .popup-arrow { - top: -6px; - right: auto; - left: 8px; - border-left-width: 6px; - border-top-width: 0; - border-right-color: transparent; - border-bottom-color: var(--barBorderColor); -} - -.popup.is-bottom-left .popup-arrow:after { - left: -6px; - bottom: -7px; - border-left-width: 6px; - border-top-width: 0; - border-right-color: transparent; - border-bottom-color: #ffffff; -} -/* #endregion */ - -/* #region .popup.is-left-top */ -.popup.is-left-top { - top: -4px; - right: 100%; - margin: 0; - transform: translateX(-6px); -} - -.popup.is-left-top .popup-arrow { - right: -6px; - left: auto; - top: 8px; - border-right-width: 0; - border-left-width: 6px; - border-left-color: var(--barBorderColor); - border-right-color: transparent; -} - -.popup.is-left-top .popup-arrow:after { - top: -6px; - left: -7px; - border-right-width: 0; - border-left-width: 6px; - border-left-color: #ffffff; - border-right-color: transparent; -} -/* #endregion */ - -/* #region .popup.is-right-top */ -.popup.is-right-top { - top: -4px; - left: 100%; - margin: 0; - transform: translateX(6px); -} - -.popup.is-right-top .popup-arrow { - left: -6px; - right: auto; - top: 8px; - border-left-width: 0; - border-right-width: 6px; - border-right-color: var(--barBorderColor); - border-left-color: transparent; -} - -.popup.is-right-top .popup-arrow:after { - top: -6px; - right: -7px; - border-left-width: 0; - border-right-width: 6px; - border-right-color: #ffffff; - border-left-color: transparent; -} -/* #endregion */ - -/* #region .popup.is-right-bottom */ -.popup.is-right-bottom { - bottom: 4px; - left: 100%; - margin: 0; - transform: translateX(6px); -} - -.popup.is-right-bottom .popup-arrow { - left: -6px; - right: auto; - top: calc(100% - 15px); - border-left-width: 0; - border-right-width: 6px; - border-right-color: var(--barBorderColor); - border-left-color: transparent; -} - -.popup.is-right-bottom .popup-arrow:after { - top: -6px; - right: -7px; - border-left-width: 0; - border-right-width: 6px; - border-right-color: #ffffff; - border-left-color: transparent; -} -/* #endregion */ - -/* #region .popup.is-top-left */ -.popup.is-top-left { - bottom: calc(100% + 8px); - left: 0; - margin: 0; - transform: translateX(-8px); -} - -.popup.is-top-left .popup-arrow { - bottom: -6px; - top: auto; - left: 8px; - border-color: var(--barBorderColor) transparent transparent; - border-width: 6px 6px 0 6px; -} - -.popup.is-top-left .popup-arrow:after { - left: -6px; - top: -7px; - border-width: 6px 6px 0 6px; - border-color: #fff transparent transparent; -} -/* #endregion */ - -/* #region .popup & .menu or .multi-select */ -.popup:not(.no-padding) > .menu, -.popup:not(.no-padding) > .multi-select { - margin: calc(-1 * var(--gridSize)); -} -/* #endregion */ - -/* #region .popup-portal override css placement */ -.popup-portal .popup.is-bottom { - top: unset; - left: unset; - transform: unset; - margin: 0; -} - -.popup-portal .popup.is-bottom-left, -.popup-portal .popup.is-bottom-right, -.popup-portal .popup.is-top-left, -.popup-portal .popup.is-left-top, -.popup-portal .popup.is-right-top, -.popup-portal .popup.is-right-bottom { - top: unset; - right: unset; - bottom: unset; - left: unset; -} -/* #endregion */ diff --git a/server/sonar-ui-common/components/ui/popups.tsx b/server/sonar-ui-common/components/ui/popups.tsx deleted file mode 100644 index 01bb28f658f..00000000000 --- a/server/sonar-ui-common/components/ui/popups.tsx +++ /dev/null @@ -1,288 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 classNames from 'classnames'; -import { throttle } from 'lodash'; -import * as React from 'react'; -import { createPortal, findDOMNode } from 'react-dom'; -import ClickEventBoundary from '../controls/ClickEventBoundary'; -import ScreenPositionFixer from '../controls/ScreenPositionFixer'; -import './popups.css'; - -/** - * Positioning rules: - * - Bottom = below the block, horizontally centered - * - BottomLeft = below the block, horizontally left-aligned - * - BottomRight = below the block, horizontally right-aligned - * - LeftTop = on the left-side of the block, vertically top-aligned - * - RightTop = on the right-side of the block, vertically top-aligned - * - RightBottom = on the right-side of the block, vetically bottom-aligned - * - TopLeft = above the block, horizontally left-aligned - */ -export enum PopupPlacement { - Bottom = 'bottom', - BottomLeft = 'bottom-left', - BottomRight = 'bottom-right', - LeftTop = 'left-top', - RightTop = 'right-top', - RightBottom = 'right-bottom', - TopLeft = 'top-left', -} - -interface PopupProps { - arrowStyle?: React.CSSProperties; - children?: React.ReactNode; - className?: string; - noPadding?: boolean; - placement?: PopupPlacement; - style?: React.CSSProperties; -} - -function PopupBase(props: PopupProps, ref: React.Ref<HTMLDivElement>) { - const { placement = PopupPlacement.Bottom } = props; - return ( - <ClickEventBoundary> - <div - className={classNames( - 'popup', - `is-${placement}`, - { 'no-padding': props.noPadding }, - props.className - )} - ref={ref || React.createRef()} - style={props.style}> - {props.children} - <PopupArrow style={props.arrowStyle} /> - </div> - </ClickEventBoundary> - ); -} - -const PopupWithRef = React.forwardRef(PopupBase); -PopupWithRef.displayName = 'Popup'; - -export const Popup = PopupWithRef; - -interface PopupArrowProps { - style?: React.CSSProperties; -} - -export function PopupArrow(props: PopupArrowProps) { - return <div className="popup-arrow" style={props.style} />; -} - -interface PortalPopupProps extends Omit<PopupProps, 'arrowStyle' | 'style'> { - arrowOffset?: number; - children: React.ReactNode; - overlay: React.ReactNode; -} - -interface Measurements { - height: number; - left: number; - top: number; - width: number; -} - -type State = Partial<Measurements>; - -function isMeasured(state: State): state is Measurements { - return state.height !== undefined; -} - -export class PortalPopup extends React.Component<PortalPopupProps, State> { - mounted = false; - popupNode = React.createRef<HTMLDivElement>(); - throttledPositionTooltip: () => void; - - constructor(props: PortalPopupProps) { - super(props); - this.state = {}; - this.throttledPositionTooltip = throttle(this.positionPopup, 10); - } - - componentDidMount() { - this.mounted = true; - this.positionPopup(); - this.addEventListeners(); - } - - componentDidUpdate(prevProps: PortalPopupProps) { - if (this.props.placement !== prevProps.placement || this.props.overlay !== prevProps.overlay) { - this.positionPopup(); - } - } - - componentWillUnmount() { - this.mounted = false; - this.removeEventListeners(); - } - - addEventListeners = () => { - window.addEventListener('resize', this.throttledPositionTooltip); - window.addEventListener('scroll', this.throttledPositionTooltip); - }; - - removeEventListeners = () => { - window.removeEventListener('resize', this.throttledPositionTooltip); - window.removeEventListener('scroll', this.throttledPositionTooltip); - }; - - getPlacement = (): PopupPlacement => { - return this.props.placement || PopupPlacement.Bottom; - }; - - adjustArrowPosition = ( - placement: PopupPlacement, - { leftFix, topFix }: { leftFix: number; topFix: number } - ) => { - const { arrowOffset = 0 } = this.props; - switch (placement) { - case PopupPlacement.Bottom: - case PopupPlacement.BottomLeft: - case PopupPlacement.BottomRight: - case PopupPlacement.TopLeft: - return { marginLeft: -leftFix + arrowOffset }; - default: - return { marginTop: -topFix + arrowOffset }; - } - }; - - positionPopup = () => { - // `findDOMNode(this)` will search for the DOM node for the current component - // first it will find a React.Fragment (see `render`), - // so it will get the DOM node of the first child, i.e. DOM node of `this.props.children` - // docs: https://reactjs.org/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components - - // eslint-disable-next-line react/no-find-dom-node - const toggleNode = findDOMNode(this); - - if (toggleNode && toggleNode instanceof Element && this.popupNode.current) { - const toggleRect = toggleNode.getBoundingClientRect(); - const { width, height } = this.popupNode.current.getBoundingClientRect(); - let left = 0; - let top = 0; - - switch (this.getPlacement()) { - case PopupPlacement.Bottom: - left = toggleRect.left + toggleRect.width / 2 - width / 2; - top = toggleRect.top + toggleRect.height; - break; - case PopupPlacement.BottomLeft: - left = toggleRect.left; - top = toggleRect.top + toggleRect.height; - break; - case PopupPlacement.BottomRight: - left = toggleRect.left + toggleRect.width - width; - top = toggleRect.top + toggleRect.height; - break; - case PopupPlacement.LeftTop: - left = toggleRect.left - width; - top = toggleRect.top; - break; - case PopupPlacement.RightTop: - left = toggleRect.left + toggleRect.width; - top = toggleRect.top; - break; - case PopupPlacement.RightBottom: - left = toggleRect.left + toggleRect.width; - top = toggleRect.top + toggleRect.height - height; - break; - case PopupPlacement.TopLeft: - left = toggleRect.left; - top = toggleRect.top - height; - break; - } - - // save width and height (and later set in `render`) to avoid resizing the popup element, - // when it's placed close to the window edge - this.setState({ - left: window.pageXOffset + left, - top: window.pageYOffset + top, - width, - height, - }); - } - }; - - renderActual = ({ leftFix = 0, topFix = 0 }) => { - const { className, overlay, noPadding } = this.props; - const placement = this.getPlacement(); - let arrowStyle; - let style; - if (isMeasured(this.state)) { - style = { - left: this.state.left + leftFix, - top: this.state.top + topFix, - width: this.state.width, - height: this.state.height, - }; - arrowStyle = this.adjustArrowPosition(placement, { leftFix, topFix }); - } - - return ( - <Popup - arrowStyle={arrowStyle} - className={className} - noPadding={noPadding} - placement={placement} - ref={this.popupNode} - style={style}> - {overlay} - </Popup> - ); - }; - - render() { - return ( - <> - {this.props.children} - {this.props.overlay && ( - <PortalWrapper> - <ScreenPositionFixer ready={isMeasured(this.state)}> - {this.renderActual} - </ScreenPositionFixer> - </PortalWrapper> - )} - </> - ); - } -} - -class PortalWrapper extends React.Component { - el: HTMLElement; - - constructor(props: {}) { - super(props); - this.el = document.createElement('div'); - this.el.classList.add('popup-portal'); - } - - componentDidMount() { - document.body.appendChild(this.el); - } - - componentWillUnmount() { - document.body.removeChild(this.el); - } - - render() { - return createPortal(this.props.children, this.el); - } -} diff --git a/server/sonar-ui-common/components/ui/update-center/MetaData.css b/server/sonar-ui-common/components/ui/update-center/MetaData.css deleted file mode 100644 index 6bc5a632fb1..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/MetaData.css +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -.update-center-meta-data { - margin: 16px 0; - padding: 16px 16px 8px 16px; - background: #f9f9fb; - border: 1px solid #e6e6e6; - border-radius: 3px; -} - -.update-center-meta-data a svg { - margin-right: 8px; -} - -.update-center-meta-data-header { - border-bottom: 1px solid #cfd3d7; - padding-bottom: 16px; -} - -.update-center-meta-data-header, -.update-center-meta-data-version-release-info, -.update-center-meta-data-version-links { - display: flex; -} - -.update-center-meta-data-header > * + *, -.update-center-meta-data-version-release-info > * + * { - margin-left: 16px; -} - -.update-center-meta-data-header > * + * { - padding-left: 16px; - border-left: 1px solid #cfd3d7; -} - -.update-center-meta-data-versions { - margin-top: 16px; -} - -.update-center-meta-data-versions-show-more { - font-size: 14px; - float: right; - color: #51575a; - border-color: #7b8184; - border-width: 0 0 1px 0; - padding-left: 0; - padding-right: 0; - background: transparent; - cursor: pointer; -} - -.update-center-meta-data-versions-show-more:hover { - color: #2d3032; - border-color: #2d3032; -} - -.update-center-meta-data-version { - margin-bottom: 16px; -} - -.update-center-meta-data-version + .update-center-meta-data-version { - padding-top: 8px; - border-top: 1px dashed #cfd3d7; -} - -.update-center-meta-data-version-version { - font-weight: bold; - font-size: 18px; -} - -.update-center-meta-data-version-release-info { - margin-top: 8px; - font-style: italic; -} - -.update-center-meta-data-version-release-description { - margin-top: 8px; -} - -.update-center-meta-data-version-download > a, -.update-center-meta-data-version-release-notes > a { - display: inline-block; - margin: 8px 16px 0 0; -} diff --git a/server/sonar-ui-common/components/ui/update-center/MetaData.tsx b/server/sonar-ui-common/components/ui/update-center/MetaData.tsx deleted file mode 100644 index 017527abcde..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/MetaData.tsx +++ /dev/null @@ -1,122 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 './MetaData.css'; -import MetaDataVersions from './MetaDataVersions'; -import { MetaDataInformation } from './update-center-metadata'; -import { isSuccessStatus } from '../../../helpers/request'; - -interface Props { - updateCenterKey?: string; -} - -interface State { - data?: MetaDataInformation; -} - -export default class MetaData extends React.Component<Props, State> { - mounted = false; - state: State = {}; - - componentDidMount() { - this.mounted = true; - this.fetchData(); - } - - componentDidUpdate(prevProps: Props) { - if (prevProps.updateCenterKey !== this.props.updateCenterKey) { - this.fetchData(); - } - } - - componentWillUnmount() { - this.mounted = false; - } - - fetchData() { - const { updateCenterKey } = this.props; - - if (updateCenterKey) { - window - .fetch(`https://update.sonarsource.org/${updateCenterKey}.json`) - .then((response: Response) => { - if (isSuccessStatus(response.status)) { - return response.json(); - } else { - return Promise.reject(response); - } - }) - .then((data) => { - if (this.mounted) { - this.setState({ data }); - } - }) - .catch(() => { - if (this.mounted) { - this.setState({ data: undefined }); - } - }); - } else { - this.setState({ data: undefined }); - } - } - - render() { - const { data } = this.state; - - if (!data) { - return null; - } - - const { isSonarSourceCommercial, issueTrackerURL, license, organization, versions } = data; - - 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="update-center-meta-data"> - <div className="update-center-meta-data-header"> - {vendor && <span className="update-center-meta-data-vendor">By {vendor}</span>} - {license && <span className="update-center-meta-data-license">{license}</span>} - {issueTrackerURL && ( - <span className="update-center-meta-data-issue-tracker"> - <a href={issueTrackerURL} rel="noopener noreferrer" target="_blank"> - Issue Tracker - </a> - </span> - )} - {isSonarSourceCommercial && ( - <span className="update-center-meta-data-supported">Supported by SonarSource</span> - )} - </div> - {versions && versions.length > 0 && <MetaDataVersions versions={versions} />} - </div> - ); - } -} diff --git a/server/sonar-ui-common/components/ui/update-center/MetaDataVersion.tsx b/server/sonar-ui-common/components/ui/update-center/MetaDataVersion.tsx deleted file mode 100644 index d91a1bd3bc6..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/MetaDataVersion.tsx +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { AdvancedDownloadUrl, MetaDataVersionInformation } from './update-center-metadata'; - -export interface MetaDataVersionProps { - versionInformation: MetaDataVersionInformation; -} - -export default function MetaDataVersion(props: MetaDataVersionProps) { - const { - versionInformation: { - archived, - changeLogUrl, - compatibility, - date, - description, - downloadURL, - version, - }, - } = props; - - const fallbackLabel = 'Download'; - - const advancedDownloadUrls = isAdvancedDownloadUrlArray(downloadURL) - ? downloadURL.map((url) => ({ ...url, label: url.label || fallbackLabel })) - : [{ label: fallbackLabel, url: downloadURL }]; - - return ( - <div - className={classNames('update-center-meta-data-version', { - 'update-center-meta-data-version-archived': archived, - })}> - <div className="update-center-meta-data-version-version">{version}</div> - - <div className="update-center-meta-data-version-release-info"> - {date && <time className="update-center-meta-data-version-release-date">{date}</time>} - - {compatibility && ( - <span className="update-center-meta-data-version-compatibility">{compatibility}</span> - )} - </div> - - {description && ( - <div className="update-center-meta-data-version-release-description">{description}</div> - )} - - {(advancedDownloadUrls.length > 0 || changeLogUrl) && ( - <div className="update-center-meta-data-version-release-links"> - {advancedDownloadUrls.length > 0 && - advancedDownloadUrls.map( - (advancedDownloadUrl, i) => - advancedDownloadUrl.url && ( - // eslint-disable-next-line react/no-array-index-key - <span className="update-center-meta-data-version-download" key={i}> - <a href={advancedDownloadUrl.url} rel="noopener noreferrer" target="_blank"> - {advancedDownloadUrl.label} - </a> - </span> - ) - )} - - {changeLogUrl && ( - <span className="update-center-meta-data-version-release-notes"> - <a href={changeLogUrl} rel="noopener noreferrer" target="_blank"> - Release notes - </a> - </span> - )} - </div> - )} - </div> - ); -} - -function isAdvancedDownloadUrlArray( - downloadUrl: string | AdvancedDownloadUrl[] | undefined -): downloadUrl is AdvancedDownloadUrl[] { - return !!downloadUrl && typeof downloadUrl !== 'string'; -} diff --git a/server/sonar-ui-common/components/ui/update-center/MetaDataVersions.tsx b/server/sonar-ui-common/components/ui/update-center/MetaDataVersions.tsx deleted file mode 100644 index f51e11e730a..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/MetaDataVersions.tsx +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 MetaDataVersion from './MetaDataVersion'; -import { MetaDataVersionInformation } from './update-center-metadata'; - -interface Props { - versions: MetaDataVersionInformation[]; -} - -interface State { - collapsed: boolean; -} - -export default class MetaDataVersions extends React.Component<Props, State> { - state: State = { - collapsed: true, - }; - - componentDidUpdate(prevProps: Props) { - if (prevProps.versions !== this.props.versions) { - this.setState({ collapsed: true }); - } - } - - handleClick = (event: React.SyntheticEvent<HTMLButtonElement>) => { - event.preventDefault(); - event.currentTarget.blur(); - this.setState(({ collapsed }) => ({ collapsed: !collapsed })); - }; - - 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="update-center-meta-data-versions"> - {archivedVersions.length > 0 && ( - <button - className="update-center-meta-data-versions-show-more" - onClick={this.handleClick} - type="button"> - {collapsed ? 'Show more versions' : 'Show fewer versions'} - </button> - )} - - {currentVersions.map((versionInformation) => ( - <MetaDataVersion - key={versionInformation.version} - versionInformation={versionInformation} - /> - ))} - - {!collapsed && - archivedVersions.map((archivedVersionInformation) => ( - <MetaDataVersion - key={archivedVersionInformation.version} - versionInformation={archivedVersionInformation} - /> - ))} - </div> - ); - } -} diff --git a/server/sonar-ui-common/components/ui/update-center/__tests__/MetaData-test.tsx b/server/sonar-ui-common/components/ui/update-center/__tests__/MetaData-test.tsx deleted file mode 100644 index 85c6ce0ac71..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/__tests__/MetaData-test.tsx +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { waitAndUpdate } from '../../../../helpers/testUtils'; -import MetaData from '../MetaData'; -import { mockMetaDataInformation } from '../mocks/update-center-metadata'; -import { MetaDataInformation } from '../update-center-metadata'; -import { HttpStatus } from '../../../../helpers/request'; - -beforeAll(() => { - window.fetch = jest.fn(); -}); - -beforeEach(() => { - jest.resetAllMocks(); -}); - -it('should render correctly', async () => { - const metaDataInfo = mockMetaDataInformation(); - mockFetchReturnValue(metaDataInfo); - - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); -}); - -it('should render correctly with organization', async () => { - const metaDataInfo = mockMetaDataInformation({ - organization: { name: 'test-org', url: 'test-org-url' }, - }); - mockFetchReturnValue(metaDataInfo); - - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); -}); - -it('should not render anything if call for metadata fails', async () => { - const metaDataInfo = mockMetaDataInformation(); - mockFetchReturnValue(metaDataInfo, HttpStatus.NotFound); - - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper.type()).toBeNull(); -}); - -it('should fetch metadata again if the update center key if modified', async () => { - const metaDataInfo = mockMetaDataInformation(); - mockFetchReturnValue(metaDataInfo); - - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - - expect(window.fetch).toHaveBeenCalledTimes(1); - - mockFetchReturnValue(metaDataInfo); - wrapper.setProps({ updateCenterKey: 'abap' }); - - expect(window.fetch).toHaveBeenCalledTimes(2); -}); - -function shallowRender(props?: Partial<MetaData['props']>) { - return shallow<MetaData>(<MetaData updateCenterKey="apex" {...props} />); -} - -function mockFetchReturnValue(metaDataInfo: MetaDataInformation, status = HttpStatus.Ok) { - (window.fetch as jest.Mock).mockResolvedValueOnce({ status, json: () => metaDataInfo }); -} diff --git a/server/sonar-ui-common/components/ui/update-center/__tests__/MetaDataVersion-test.tsx b/server/sonar-ui-common/components/ui/update-center/__tests__/MetaDataVersion-test.tsx deleted file mode 100644 index f1e5b947224..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/__tests__/MetaDataVersion-test.tsx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 MetaDataVersion, { MetaDataVersionProps } from '../MetaDataVersion'; -import { mockMetaDataVersionInformation } from '../mocks/update-center-metadata'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect( - shallowRender({ - versionInformation: mockMetaDataVersionInformation({ - downloadURL: [{ label: 'macos 64 bits', url: '' }], - }), - }) - ).toMatchSnapshot('with advanced downloadUrl'); - expect( - shallowRender({ - versionInformation: { version: '2.0' }, - }) - ).toMatchSnapshot('with very few info'); -}); - -function shallowRender(props?: Partial<MetaDataVersionProps>) { - return shallow( - <MetaDataVersion versionInformation={mockMetaDataVersionInformation()} {...props} /> - ); -} diff --git a/server/sonar-ui-common/components/ui/update-center/__tests__/MetaDataVersions-test.tsx b/server/sonar-ui-common/components/ui/update-center/__tests__/MetaDataVersions-test.tsx deleted file mode 100644 index 0648c0fd59d..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/__tests__/MetaDataVersions-test.tsx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { click } from '../../../../helpers/testUtils'; -import MetaDataVersion from '../MetaDataVersion'; -import MetaDataVersions from '../MetaDataVersions'; -import { mockMetaDataVersionInformation } from '../mocks/update-center-metadata'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); -}); - -it('should properly handle show more / show less', () => { - const wrapper = shallowRender(); - expect(wrapper.find(MetaDataVersion).length).toBe(1); - - click(wrapper.find('.update-center-meta-data-versions-show-more')); - expect(wrapper.find(MetaDataVersion).length).toBe(3); -}); - -function shallowRender(props?: Partial<MetaDataVersions['props']>) { - return shallow<MetaDataVersions>( - <MetaDataVersions - versions={[ - mockMetaDataVersionInformation({ version: '3.0' }), - mockMetaDataVersionInformation({ version: '2.0', archived: true }), - mockMetaDataVersionInformation({ version: '1.0', archived: true }), - ]} - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaData-test.tsx.snap b/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaData-test.tsx.snap deleted file mode 100644 index 89e8d74a6d1..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaData-test.tsx.snap +++ /dev/null @@ -1,133 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - className="update-center-meta-data" -> - <div - className="update-center-meta-data-header" - > - <span - className="update-center-meta-data-vendor" - > - By - <a - href="http://www.sonarsource.com/" - rel="noopener noreferrer" - target="_blank" - > - SonarSource - </a> - </span> - <span - className="update-center-meta-data-license" - > - SonarSource - </span> - <span - className="update-center-meta-data-issue-tracker" - > - <a - href="https://jira.sonarsource.com/browse/SONARJAVA" - rel="noopener noreferrer" - target="_blank" - > - Issue Tracker - </a> - </span> - <span - className="update-center-meta-data-supported" - > - Supported by SonarSource - </span> - </div> - <MetaDataVersions - versions={ - Array [ - Object { - "archived": false, - "changeLogUrl": "https://example.com/sonar-java-plugin/release", - "compatibility": "6.7", - "date": "2019-05-31", - "downloadURL": "https://example.com/sonar-java-plugin-5.13.0.18197.jar", - "version": "2.0", - }, - Object { - "archived": true, - "changeLogUrl": "https://example.com/sonar-java-plugin/release", - "compatibility": "6.7", - "date": "2019-05-31", - "downloadURL": "https://example.com/sonar-java-plugin-5.13.0.18197.jar", - "version": "1.0", - }, - ] - } - /> -</div> -`; - -exports[`should render correctly with organization 1`] = ` -<div - className="update-center-meta-data" -> - <div - className="update-center-meta-data-header" - > - <span - className="update-center-meta-data-vendor" - > - By - <a - href="test-org-url" - rel="noopener noreferrer" - target="_blank" - > - test-org - </a> - </span> - <span - className="update-center-meta-data-license" - > - SonarSource - </span> - <span - className="update-center-meta-data-issue-tracker" - > - <a - href="https://jira.sonarsource.com/browse/SONARJAVA" - rel="noopener noreferrer" - target="_blank" - > - Issue Tracker - </a> - </span> - <span - className="update-center-meta-data-supported" - > - Supported by SonarSource - </span> - </div> - <MetaDataVersions - versions={ - Array [ - Object { - "archived": false, - "changeLogUrl": "https://example.com/sonar-java-plugin/release", - "compatibility": "6.7", - "date": "2019-05-31", - "downloadURL": "https://example.com/sonar-java-plugin-5.13.0.18197.jar", - "version": "2.0", - }, - Object { - "archived": true, - "changeLogUrl": "https://example.com/sonar-java-plugin/release", - "compatibility": "6.7", - "date": "2019-05-31", - "downloadURL": "https://example.com/sonar-java-plugin-5.13.0.18197.jar", - "version": "1.0", - }, - ] - } - /> -</div> -`; diff --git a/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaDataVersion-test.tsx.snap b/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaDataVersion-test.tsx.snap deleted file mode 100644 index 7fd964fe2ab..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaDataVersion-test.tsx.snap +++ /dev/null @@ -1,113 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - className="update-center-meta-data-version" -> - <div - className="update-center-meta-data-version-version" - > - 5.13 - </div> - <div - className="update-center-meta-data-version-release-info" - > - <time - className="update-center-meta-data-version-release-date" - > - 2019-05-31 - </time> - <span - className="update-center-meta-data-version-compatibility" - > - 6.7 - </span> - </div> - <div - className="update-center-meta-data-version-release-links" - > - <span - className="update-center-meta-data-version-download" - key="0" - > - <a - href="https://example.com/sonar-java-plugin-5.13.0.18197.jar" - rel="noopener noreferrer" - target="_blank" - > - Download - </a> - </span> - <span - className="update-center-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> -`; - -exports[`should render correctly: with advanced downloadUrl 1`] = ` -<div - className="update-center-meta-data-version" -> - <div - className="update-center-meta-data-version-version" - > - 5.13 - </div> - <div - className="update-center-meta-data-version-release-info" - > - <time - className="update-center-meta-data-version-release-date" - > - 2019-05-31 - </time> - <span - className="update-center-meta-data-version-compatibility" - > - 6.7 - </span> - </div> - <div - className="update-center-meta-data-version-release-links" - > - <span - className="update-center-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> -`; - -exports[`should render correctly: with very few info 1`] = ` -<div - className="update-center-meta-data-version" -> - <div - className="update-center-meta-data-version-version" - > - 2.0 - </div> - <div - className="update-center-meta-data-version-release-info" - /> - <div - className="update-center-meta-data-version-release-links" - /> -</div> -`; diff --git a/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaDataVersions-test.tsx.snap b/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaDataVersions-test.tsx.snap deleted file mode 100644 index 109fe964473..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/__tests__/__snapshots__/MetaDataVersions-test.tsx.snap +++ /dev/null @@ -1,28 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - className="update-center-meta-data-versions" -> - <button - className="update-center-meta-data-versions-show-more" - onClick={[Function]} - type="button" - > - Show more versions - </button> - <MetaDataVersion - key="3.0" - versionInformation={ - Object { - "archived": false, - "changeLogUrl": "https://example.com/sonar-java-plugin/release", - "compatibility": "6.7", - "date": "2019-05-31", - "downloadURL": "https://example.com/sonar-java-plugin-5.13.0.18197.jar", - "version": "3.0", - } - } - /> -</div> -`; diff --git a/server/sonar-ui-common/components/ui/update-center/mocks/update-center-metadata.ts b/server/sonar-ui-common/components/ui/update-center/mocks/update-center-metadata.ts deleted file mode 100644 index 52e8c660d15..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/mocks/update-center-metadata.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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 { MetaDataInformation, MetaDataVersionInformation } from '../update-center-metadata'; - -export function mockMetaDataVersionInformation( - overrides?: Partial<MetaDataVersionInformation> -): MetaDataVersionInformation { - return { - 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', - ...overrides, - }; -} - -export function mockMetaDataInformation( - overrides?: Partial<MetaDataInformation> -): MetaDataInformation { - return { - 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: [ - mockMetaDataVersionInformation({ version: '2.0' }), - mockMetaDataVersionInformation({ version: '1.0', archived: true }), - ], - ...overrides, - }; -} diff --git a/server/sonar-ui-common/components/ui/update-center/update-center-metadata.ts b/server/sonar-ui-common/components/ui/update-center/update-center-metadata.ts deleted file mode 100644 index a88b385c3b6..00000000000 --- a/server/sonar-ui-common/components/ui/update-center/update-center-metadata.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2021 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. - */ -export interface MetaDataInformation { - category?: string; - isSonarSourceCommercial?: boolean; - issueTrackerURL?: string; - key?: string; - license?: string; - name: string; - organization?: { - name: string; - url?: string; - }; - sourcesURL?: string; - versions?: MetaDataVersionInformation[]; -} - -export interface MetaDataVersionInformation { - archived?: boolean; - changeLogUrl?: string; - compatibility?: string; - date?: string; - description?: string; - downloadURL?: string | AdvancedDownloadUrl[]; - version: string; -} - -export interface AdvancedDownloadUrl { - label?: string; - url: string; -} |