diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2021-08-17 15:50:55 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-08-20 20:03:08 +0000 |
commit | 6ef7ca151ecd602ca8e9cea21743a895a81e89ba (patch) | |
tree | 40d7a97a8075b416901a4078638e4cde9ee15942 /server/sonar-ui-common/components | |
parent | 2454e077b1d77d70508dcce6a5b015d4a69f41fa (diff) | |
download | sonarqube-6ef7ca151ecd602ca8e9cea21743a895a81e89ba.tar.gz sonarqube-6ef7ca151ecd602ca8e9cea21743a895a81e89ba.zip |
SONAR-15297 Move sonar-ui-common code to sonar-web
Diffstat (limited to 'server/sonar-ui-common/components')
339 files changed, 0 insertions, 26195 deletions
diff --git a/server/sonar-ui-common/components/__tests__/__snapshots__/lazyLoadComponent-test.tsx.snap b/server/sonar-ui-common/components/__tests__/__snapshots__/lazyLoadComponent-test.tsx.snap deleted file mode 100644 index 7f00f47e206..00000000000 --- a/server/sonar-ui-common/components/__tests__/__snapshots__/lazyLoadComponent-test.tsx.snap +++ /dev/null @@ -1,46 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should correctly set given display name 1`] = ` -<div> - <CustomDisplayName /> -</div> -`; - -exports[`should lazy load and display the component 1`] = ` -<LazyComponentWrapper> - <LazyErrorBoundary> - <Suspense - fallback={null} - /> - </LazyErrorBoundary> -</LazyComponentWrapper> -`; - -exports[`should lazy load and display the component 2`] = `null`; - -exports[`should lazy load and display the component 3`] = ` -<LazyComponentWrapper> - <LazyErrorBoundary> - <Suspense - fallback={null} - > - <Checkbox> - <a - className="icon-checkbox" - href="#" - onClick={[Function]} - role="checkbox" - /> - </Checkbox> - </Suspense> - </LazyErrorBoundary> -</LazyComponentWrapper> -`; - -exports[`should lazy load and display the component 4`] = ` -<a - class="icon-checkbox" - href="#" - role="checkbox" -/> -`; diff --git a/server/sonar-ui-common/components/__tests__/getHistory-test.ts b/server/sonar-ui-common/components/__tests__/getHistory-test.ts deleted file mode 100644 index 2df78cdd02e..00000000000 --- a/server/sonar-ui-common/components/__tests__/getHistory-test.ts +++ /dev/null @@ -1,29 +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 getHistory from '../../helpers/getHistory'; -import * as Router from 'react-router'; - -it('should get browser history properly', () => { - expect(getHistory()).not.toBeUndefined(); - expect(getHistory().getCurrentLocation().pathname).toBe('/'); - const pathname = '/foo/bar'; - Router.browserHistory.push(pathname); - expect(getHistory().getCurrentLocation().pathname).toBe(pathname); -}); diff --git a/server/sonar-ui-common/components/__tests__/lazyLoadComponent-test.tsx b/server/sonar-ui-common/components/__tests__/lazyLoadComponent-test.tsx deleted file mode 100644 index 216163e9432..00000000000 --- a/server/sonar-ui-common/components/__tests__/lazyLoadComponent-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 { mount, shallow } from 'enzyme'; -import * as React from 'react'; -import { waitAndUpdate } from '../../helpers/testUtils'; -import { lazyLoadComponent } from '../lazyLoadComponent'; - -const factory = jest.fn().mockImplementation(() => import('../controls/Checkbox')); - -beforeEach(() => { - factory.mockClear(); -}); - -it('should lazy load and display the component', async () => { - const LazyComponent = lazyLoadComponent(factory); - const wrapper = mount(<LazyComponent />); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.render()).toMatchSnapshot(); - expect(factory).toBeCalledTimes(1); - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.render()).toMatchSnapshot(); - expect(factory).toBeCalledTimes(1); -}); - -it('should correctly handle import errors', () => { - const LazyComponent = lazyLoadComponent(factory); - const wrapper = mount(<LazyComponent />); - wrapper.find('Suspense').simulateError({ request: 'test' }); - expect(wrapper.find('Alert').exists()).toBe(true); -}); - -it('should correctly set given display name', () => { - const LazyComponent = lazyLoadComponent(factory, 'CustomDisplayName'); - const wrapper = shallow( - <div> - <LazyComponent /> - </div> - ); - expect(wrapper).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/charts/AdvancedTimeline.css b/server/sonar-ui-common/components/charts/AdvancedTimeline.css deleted file mode 100644 index d71ef2dee96..00000000000 --- a/server/sonar-ui-common/components/charts/AdvancedTimeline.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. - */ -.line-tooltip { - fill: none; - stroke: var(--secondFontColor); - stroke-width: 1px; - shape-rendering: crispEdges; -} - -.chart-mouse-events-overlay { - fill: none; - stroke: none; - pointer-events: all; -} - -.chart-zoomed .line-chart-area { - clip-path: url(#chart-clip); -} - -.chart-zoomed .line-chart-path { - clip-path: url(#chart-clip); -} - -.chart-zoomed .leak-chart-rect { - clip-path: url(#chart-clip); -} - -.line-chart-dot { - fill: var(--blue); -} - -.line-chart-dot.line-chart-dot-1 { - fill: var(--darkBlue); -} - -.line-chart-dot.line-chart-dot-2 { - fill: #24c6e0; -} - -.line-chart-event { - fill: #fff; - stroke: var(--blue); - stroke-width: 2px; -} - -.line-chart-event.VERSION { - stroke: var(--blue); -} - -.line-chart-event.QUALITY_GATE { - stroke: var(--green); -} - -.line-chart-event.QUALITY_PROFILE { - stroke: var(--orange); -} - -.line-chart-event.OTHER { - stroke: var(--purple); -} - -.new-code-legend { - fill: var(--secondFontColor); - font-size: var(--smallFontSize); -} diff --git a/server/sonar-ui-common/components/charts/AdvancedTimeline.tsx b/server/sonar-ui-common/components/charts/AdvancedTimeline.tsx deleted file mode 100644 index 0a9bd4125d0..00000000000 --- a/server/sonar-ui-common/components/charts/AdvancedTimeline.tsx +++ /dev/null @@ -1,624 +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 { bisector, extent, max } from 'd3-array'; -import { scaleLinear, scalePoint, scaleTime, ScaleTime } from 'd3-scale'; -import { area, curveBasis, line as d3Line } from 'd3-shape'; -import { flatten, isEqual, sortBy, throttle, uniq } from 'lodash'; -import * as React from 'react'; -import { isDefined } from '../../helpers/types'; -import { Theme, ThemeConsumer } from '../theme'; -import './AdvancedTimeline.css'; -import './LineChart.css'; - -export interface Props { - basisCurve?: boolean; - endDate?: Date; - disableZoom?: boolean; - displayNewCodeLegend?: boolean; - formatYTick?: (tick: number | string) => string; - hideGrid?: boolean; - hideXAxis?: boolean; - height: number; - width: number; - leakPeriodDate?: Date; - // used to avoid same y ticks labels - maxYTicksCount: number; - metricType: string; - padding: number[]; - selectedDate?: Date; - series: T.Chart.Serie[]; - showAreas?: boolean; - startDate?: Date; - updateSelectedDate?: (selectedDate?: Date) => void; - updateTooltip?: (selectedDate?: Date, tooltipXPos?: number, tooltipIdx?: number) => void; - updateZoom?: (start?: Date, endDate?: Date) => void; - zoomSpeed: number; -} - -type XScale = ScaleTime<number, number>; -// TODO it should be `ScaleLinear<number, number> | ScalePoint<number> | ScalePoint<string>`, but it's super hard to make it work :'( -type YScale = any; - -const LEGEND_LINE_HEIGHT = 16; - -interface State { - leakLegendTextWidth?: number; - maxXRange: number[]; - mouseOver?: boolean; - selectedDate?: Date; - selectedDateXPos?: number; - selectedDateIdx?: number; - yScale: YScale; - xScale: XScale; -} - -export default class AdvancedTimeline extends React.PureComponent<Props, State> { - static defaultProps = { - eventSize: 8, - maxYTicksCount: 4, - padding: [26, 10, 50, 60], - zoomSpeed: 1, - }; - - constructor(props: Props) { - super(props); - const scales = this.getScales(props); - const selectedDatePos = this.getSelectedDatePos(scales.xScale, props.selectedDate); - this.state = { ...scales, ...selectedDatePos }; - this.updateTooltipPos = throttle(this.updateTooltipPos, 40); - this.handleZoomUpdate = throttle(this.handleZoomUpdate, 40); - } - - componentDidUpdate(prevProps: Props) { - let scales; - let selectedDatePos; - if ( - this.props.metricType !== prevProps.metricType || - this.props.startDate !== prevProps.startDate || - this.props.endDate !== prevProps.endDate || - this.props.width !== prevProps.width || - this.props.padding !== prevProps.padding || - this.props.height !== prevProps.height || - this.props.series !== prevProps.series - ) { - scales = this.getScales(this.props); - if (this.state.selectedDate != null) { - selectedDatePos = this.getSelectedDatePos(scales.xScale, this.state.selectedDate); - } - } - - if (!isEqual(this.props.selectedDate, prevProps.selectedDate)) { - const xScale = scales ? scales.xScale : this.state.xScale; - selectedDatePos = this.getSelectedDatePos(xScale, this.props.selectedDate); - } - - if (scales || selectedDatePos) { - if (scales) { - this.setState({ ...scales }); - } - if (selectedDatePos) { - this.setState({ ...selectedDatePos }); - } - - if (selectedDatePos && this.props.updateTooltip) { - this.props.updateTooltip( - selectedDatePos.selectedDate, - selectedDatePos.selectedDateXPos, - selectedDatePos.selectedDateIdx - ); - } - } - } - - getRatingScale = (availableHeight: number) => { - return scalePoint<number>().domain([5, 4, 3, 2, 1]).range([availableHeight, 0]); - }; - - getLevelScale = (availableHeight: number) => { - return scalePoint().domain(['ERROR', 'WARN', 'OK']).range([availableHeight, 0]); - }; - - getYScale = (props: Props, availableHeight: number, flatData: T.Chart.Point[]): YScale => { - if (props.metricType === 'RATING') { - return this.getRatingScale(availableHeight); - } else if (props.metricType === 'LEVEL') { - return this.getLevelScale(availableHeight); - } else { - return scaleLinear() - .range([availableHeight, 0]) - .domain([0, max(flatData, (d) => Number(d.y || 0)) || 1]) - .nice(); - } - }; - - getXScale = ( - { startDate, endDate }: Props, - availableWidth: number, - flatData: T.Chart.Point[] - ) => { - const dateRange = extent(flatData, (d) => d.x) as [Date, Date]; - const start = startDate && startDate > dateRange[0] ? startDate : dateRange[0]; - const end = endDate && endDate < dateRange[1] ? endDate : dateRange[1]; - const xScale: ScaleTime<number, number> = scaleTime() - .domain(sortBy([start, end])) - .range([0, availableWidth]) - .clamp(false); - return { - xScale, - maxXRange: dateRange.map(xScale), - }; - }; - - getScales = (props: Props) => { - const availableWidth = props.width - props.padding[1] - props.padding[3]; - const availableHeight = props.height - props.padding[0] - props.padding[2]; - const flatData = flatten(props.series.map((serie) => serie.data)); - return { - ...this.getXScale(props, availableWidth, flatData), - yScale: this.getYScale(props, availableHeight, flatData), - }; - }; - - getSelectedDatePos = (xScale: XScale, selectedDate?: Date) => { - const firstSerie = this.props.series[0]; - if (selectedDate && firstSerie) { - const idx = firstSerie.data.findIndex((p) => p.x.valueOf() === selectedDate.valueOf()); - const xRange = sortBy(xScale.range()); - const xPos = xScale(selectedDate); - if (idx >= 0 && xPos >= xRange[0] && xPos <= xRange[1]) { - return { - selectedDate, - selectedDateXPos: xScale(selectedDate), - selectedDateIdx: idx, - }; - } - } - return { selectedDate: undefined, selectedDateXPos: undefined, selectedDateIdx: undefined }; - }; - - getEventMarker = (size: number) => { - const half = size / 2; - return `M${half} 0 L${size} ${half} L ${half} ${size} L0 ${half} L${half} 0 L${size} ${half}`; - }; - - handleWheel = (event: React.WheelEvent<SVGElement>) => { - event.preventDefault(); - const { maxXRange, xScale } = this.state; - const parentBbox = event.currentTarget.getBoundingClientRect(); - const mouseXPos = (event.pageX - parentBbox.left) / parentBbox.width; - const xRange = xScale.range(); - - const speed = event.deltaMode - ? (25 / event.deltaMode) * this.props.zoomSpeed - : this.props.zoomSpeed; - const leftPos = xRange[0] - Math.round(speed * event.deltaY * mouseXPos); - const rightPos = xRange[1] + Math.round(speed * event.deltaY * (1 - mouseXPos)); - const startDate = leftPos > maxXRange[0] ? xScale.invert(leftPos) : undefined; - const endDate = rightPos < maxXRange[1] ? xScale.invert(rightPos) : undefined; - this.handleZoomUpdate(startDate, endDate); - }; - - handleZoomUpdate = (startDate?: Date, endDate?: Date) => { - if (this.props.updateZoom) { - this.props.updateZoom(startDate, endDate); - } - }; - - handleMouseMove = (event: React.MouseEvent<SVGElement>) => { - const parentBbox = event.currentTarget.getBoundingClientRect(); - this.updateTooltipPos(event.pageX - parentBbox.left); - }; - - handleMouseEnter = () => { - this.setState({ mouseOver: true }); - }; - - handleMouseOut = () => { - const { updateTooltip } = this.props; - if (updateTooltip) { - this.setState({ - mouseOver: false, - selectedDate: undefined, - selectedDateXPos: undefined, - selectedDateIdx: undefined, - }); - updateTooltip(undefined, undefined, undefined); - } - }; - - handleClick = () => { - const { updateSelectedDate } = this.props; - if (updateSelectedDate) { - updateSelectedDate(this.state.selectedDate || undefined); - } - }; - - setLeakLegendTextWidth = (node: SVGTextElement | null) => { - if (node) { - this.setState({ leakLegendTextWidth: node.getBoundingClientRect().width }); - } - }; - - updateTooltipPos = (xPos: number) => { - this.setState((state) => { - const firstSerie = this.props.series[0]; - if (state.mouseOver && firstSerie) { - const { updateTooltip } = this.props; - const date = state.xScale.invert(xPos); - const bisectX = bisector<T.Chart.Point, Date>((d) => d.x).right; - let idx = bisectX(firstSerie.data, date); - if (idx >= 0) { - const previousPoint = firstSerie.data[idx - 1]; - const nextPoint = firstSerie.data[idx]; - if ( - !nextPoint || - (previousPoint && - date.valueOf() - previousPoint.x.valueOf() <= nextPoint.x.valueOf() - date.valueOf()) - ) { - idx--; - } - const selectedDate = firstSerie.data[idx].x; - const xPos = state.xScale(selectedDate); - if (updateTooltip) { - updateTooltip(selectedDate, xPos, idx); - } - return { selectedDate, selectedDateXPos: xPos, selectedDateIdx: idx }; - } - } - return null; - }); - }; - - renderHorizontalGrid = () => { - const { formatYTick } = this.props; - const { xScale, yScale } = this.state; - const hasTicks = typeof yScale.ticks === 'function'; - let ticks: Array<string | number> = hasTicks - ? yScale.ticks(this.props.maxYTicksCount) - : yScale.domain(); - - if (!ticks.length) { - ticks.push(yScale.domain()[1]); - } - - // if there are duplicated ticks, that means 4 ticks are too much for this data - // so let's just use the domain values (min and max) - if (formatYTick) { - const formattedTicks = ticks.map((tick) => formatYTick(tick)); - if (ticks.length > uniq(formattedTicks).length) { - ticks = yScale.domain(); - } - } - - return ( - <g> - {ticks.map((tick) => ( - <g key={tick}> - {formatYTick != null && ( - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={xScale.range()[0]} - y={yScale(tick)}> - {formatYTick(tick)} - </text> - )} - <line - className="line-chart-grid" - x1={xScale.range()[0]} - x2={xScale.range()[1]} - y1={yScale(tick)} - y2={yScale(tick)} - /> - </g> - ))} - </g> - ); - }; - - renderXAxisTicks = () => { - const { xScale, yScale } = this.state; - const format = xScale.tickFormat(7); - const ticks = xScale.ticks(7); - const y = yScale.range()[0]; - return ( - <g transform="translate(0, 20)"> - {ticks.slice(0, -1).map((tick, index) => { - const nextTick = index + 1 < ticks.length ? ticks[index + 1] : xScale.domain()[1]; - const x = (xScale(tick) + xScale(nextTick)) / 2; - return ( - <text - className="line-chart-tick" - key={index} - textAnchor="end" - transform={`rotate(-35, ${x}, ${y})`} - x={x} - y={y}> - {format(tick)} - </text> - ); - })} - </g> - ); - }; - - renderNewCodeLegend = (params: { leakStart: number; leakWidth: number; theme: Theme }) => { - const { leakStart, leakWidth, theme } = params; - const { leakLegendTextWidth, xScale, yScale } = this.state; - const yRange = yScale.range(); - const xRange = xScale.range(); - - const legendMinWidth = (leakLegendTextWidth || 0) + theme.rawSizes.grid; - const legendPadding = theme.rawSizes.grid / 2; - - let legendBackgroundPosition; - let legendBackgroundWidth; - let legendMargin; - let legendPosition; - let legendTextAnchor; - - if (leakWidth >= legendMinWidth) { - legendBackgroundWidth = leakWidth; - legendBackgroundPosition = leakStart; - legendMargin = 0; - legendPosition = legendBackgroundPosition + legendPadding; - legendTextAnchor = 'start'; - } else { - legendBackgroundWidth = legendMinWidth; - legendBackgroundPosition = xRange[xRange.length - 1] - legendBackgroundWidth; - legendMargin = theme.rawSizes.grid / 2; - legendPosition = xRange[xRange.length - 1] - legendPadding; - legendTextAnchor = 'end'; - } - - return ( - <> - <rect - fill={theme.colors.leakPrimaryColor} - height={LEGEND_LINE_HEIGHT} - width={legendBackgroundWidth} - x={legendBackgroundPosition} - y={yRange[yRange.length - 1] - LEGEND_LINE_HEIGHT - legendMargin} - /> - <text - className="new-code-legend" - ref={this.setLeakLegendTextWidth} - x={legendPosition} - y={yRange[yRange.length - 1] - legendPadding - legendMargin} - textAnchor={legendTextAnchor}> - new code - </text> - </> - ); - }; - - renderLeak = () => { - const { displayNewCodeLegend, leakPeriodDate } = this.props; - if (!leakPeriodDate) { - return null; - } - const { xScale, yScale } = this.state; - const yRange = yScale.range(); - const xRange = xScale.range(); - - // truncate leak to start of chart to prevent weird visual artifacts when too far left - // (occurs when leak starts a long time before first analysis) - const leakStart = Math.max(xScale(leakPeriodDate), xRange[0]); - - const leakWidth = xRange[xRange.length - 1] - leakStart; - if (leakWidth < 1) { - return null; - } - - return ( - <ThemeConsumer> - {(theme) => ( - <> - {displayNewCodeLegend && this.renderNewCodeLegend({ leakStart, leakWidth, theme })} - <rect - className="leak-chart-rect" - fill={theme.colors.leakPrimaryColor} - height={yRange[0] - yRange[yRange.length - 1]} - width={leakWidth} - x={leakStart} - y={yRange[yRange.length - 1]} - /> - </> - )} - </ThemeConsumer> - ); - }; - - renderLines = () => { - const lineGenerator = d3Line<T.Chart.Point>() - .defined((d) => Boolean(d.y || d.y === 0)) - .x((d) => this.state.xScale(d.x)) - .y((d) => this.state.yScale(d.y)); - if (this.props.basisCurve) { - lineGenerator.curve(curveBasis); - } - return ( - <g> - {this.props.series.map((serie, idx) => ( - <path - className={classNames('line-chart-path', 'line-chart-path-' + idx)} - d={lineGenerator(serie.data) || undefined} - key={serie.name} - /> - ))} - </g> - ); - }; - - renderDots = () => { - return ( - <g> - {this.props.series - .map((serie, serieIdx) => - serie.data - .map((point, idx) => { - const pointNotDefined = !point.y && point.y !== 0; - const hasPointBefore = - serie.data[idx - 1] && (serie.data[idx - 1].y || serie.data[idx - 1].y === 0); - const hasPointAfter = - serie.data[idx + 1] && (serie.data[idx + 1].y || serie.data[idx + 1].y === 0); - if (pointNotDefined || hasPointBefore || hasPointAfter) { - return undefined; - } - return ( - <circle - className={classNames('line-chart-dot', 'line-chart-dot-' + serieIdx)} - cx={this.state.xScale(point.x)} - cy={this.state.yScale(point.y)} - key={serie.name + idx} - r="2" - /> - ); - }) - .filter(isDefined) - ) - .filter((dots) => dots.length > 0)} - </g> - ); - }; - - renderAreas = () => { - const areaGenerator = area<T.Chart.Point>() - .defined((d) => Boolean(d.y || d.y === 0)) - .x((d) => this.state.xScale(d.x)) - .y1((d) => this.state.yScale(d.y)) - .y0(this.state.yScale(0)); - if (this.props.basisCurve) { - areaGenerator.curve(curveBasis); - } - return ( - <g> - {this.props.series.map((serie, idx) => ( - <path - className={classNames('line-chart-area', 'line-chart-area-' + idx)} - d={areaGenerator(serie.data) || undefined} - key={serie.name} - /> - ))} - </g> - ); - }; - - renderSelectedDate = () => { - const { selectedDateIdx, selectedDateXPos, yScale } = this.state; - const firstSerie = this.props.series[0]; - if (selectedDateIdx == null || selectedDateXPos == null || !firstSerie) { - return null; - } - - return ( - <g> - <line - className="line-tooltip" - x1={selectedDateXPos} - x2={selectedDateXPos} - y1={yScale.range()[0]} - y2={yScale.range()[1]} - /> - {this.props.series.map((serie, idx) => { - const point = serie.data[selectedDateIdx]; - if (!point || (!point.y && point.y !== 0)) { - return null; - } - return ( - <circle - className={classNames('line-chart-dot', 'line-chart-dot-' + idx)} - cx={selectedDateXPos} - cy={yScale(point.y)} - key={serie.name} - r="4" - /> - ); - })} - </g> - ); - }; - - renderClipPath = () => { - return ( - <defs> - <clipPath id="chart-clip"> - <rect - height={this.state.yScale.range()[0] + 10} - transform="translate(0,-5)" - width={this.state.xScale.range()[1]} - /> - </clipPath> - </defs> - ); - }; - - renderMouseEventsOverlay = (zoomEnabled: boolean) => { - const mouseEvents: Partial<React.SVGProps<SVGRectElement>> = {}; - if (zoomEnabled) { - mouseEvents.onWheel = this.handleWheel; - } - if (this.props.updateTooltip) { - mouseEvents.onMouseEnter = this.handleMouseEnter; - mouseEvents.onMouseMove = this.handleMouseMove; - mouseEvents.onMouseOut = this.handleMouseOut; - } - if (this.props.updateSelectedDate) { - mouseEvents.onClick = this.handleClick; - } - return ( - <rect - className="chart-mouse-events-overlay" - height={this.state.yScale.range()[0]} - width={this.state.xScale.range()[1]} - {...mouseEvents} - /> - ); - }; - - render() { - if (!this.props.width || !this.props.height) { - return <div />; - } - const zoomEnabled = !this.props.disableZoom && this.props.updateZoom != null; - const isZoomed = Boolean(this.props.startDate || this.props.endDate); - return ( - <svg - className={classNames('line-chart', { 'chart-zoomed': isZoomed })} - height={this.props.height} - width={this.props.width}> - {zoomEnabled && this.renderClipPath()} - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> - {this.props.leakPeriodDate != null && this.renderLeak()} - {!this.props.hideGrid && this.renderHorizontalGrid()} - {!this.props.hideXAxis && this.renderXAxisTicks()} - {this.props.showAreas && this.renderAreas()} - {this.renderLines()} - {this.renderDots()} - {this.renderSelectedDate()} - {this.renderMouseEventsOverlay(zoomEnabled)} - </g> - </svg> - ); - } -} diff --git a/server/sonar-ui-common/components/charts/BarChart.css b/server/sonar-ui-common/components/charts/BarChart.css deleted file mode 100644 index 849885a4cda..00000000000 --- a/server/sonar-ui-common/components/charts/BarChart.css +++ /dev/null @@ -1,28 +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. - */ -.bar-chart-bar { - fill: var(--blue); -} - -.bar-chart-tick { - fill: var(--secondFontColor); - font-size: var(--smallFontSize); - text-anchor: middle; -} diff --git a/server/sonar-ui-common/components/charts/BarChart.tsx b/server/sonar-ui-common/components/charts/BarChart.tsx deleted file mode 100644 index 9f337c99ef5..00000000000 --- a/server/sonar-ui-common/components/charts/BarChart.tsx +++ /dev/null @@ -1,168 +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 { max } from 'd3-array'; -import { scaleBand, ScaleBand, scaleLinear, ScaleLinear } from 'd3-scale'; -import * as React from 'react'; -import Tooltip from '../controls/Tooltip'; -import './BarChart.css'; - -interface DataPoint { - tooltip?: React.ReactNode; - x: number; - y: number; -} - -interface Props<T> { - barsWidth: number; - data: Array<DataPoint & T>; - height: number; - onBarClick?: (point: DataPoint & T) => void; - padding?: [number, number, number, number]; - width: number; - xTicks?: string[]; - xValues?: string[]; -} - -export default class BarChart<T> extends React.PureComponent<Props<T>> { - handleClick = (point: DataPoint & T) => { - if (this.props.onBarClick) { - this.props.onBarClick(point); - } - }; - - renderXTicks = (xScale: ScaleBand<number>, yScale: ScaleLinear<number, number>) => { - const { data, xTicks = [] } = this.props; - - if (!xTicks.length) { - return null; - } - - const ticks = xTicks.map((tick, index) => { - const point = data[index]; - const x = Math.round((xScale(point.x) as number) + xScale.bandwidth() / 2); - const y = yScale.range()[0]; - const d = data[index]; - const text = ( - <text - className="bar-chart-tick" - dy="1.5em" - key={index} - onClick={() => this.handleClick(point)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - x={x} - y={y}> - {tick} - </text> - ); - return ( - <Tooltip key={index} overlay={d.tooltip || undefined}> - {text} - </Tooltip> - ); - }); - return <g>{ticks}</g>; - }; - - renderXValues = (xScale: ScaleBand<number>, yScale: ScaleLinear<number, number>) => { - const { data, xValues = [] } = this.props; - - if (!xValues.length) { - return null; - } - - const ticks = xValues.map((value, index) => { - const point = data[index]; - const x = Math.round((xScale(point.x) as number) + xScale.bandwidth() / 2); - const y = yScale(point.y); - const text = ( - <text - className="bar-chart-tick" - dy="-1em" - key={index} - onClick={() => this.handleClick(point)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - x={x} - y={y}> - {value} - </text> - ); - return ( - <Tooltip key={index} overlay={point.tooltip || undefined}> - {text} - </Tooltip> - ); - }); - return <g>{ticks}</g>; - }; - - renderBars = (xScale: ScaleBand<number>, yScale: ScaleLinear<number, number>) => { - const bars = this.props.data.map((point, index) => { - const x = Math.round(xScale(point.x) as number); - const maxY = yScale.range()[0]; - const y = Math.round(yScale(point.y)) - /* minimum bar height */ 1; - const height = maxY - y; - const rect = ( - <rect - className="bar-chart-bar" - height={height} - key={index} - onClick={() => this.handleClick(point)} - style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }} - width={this.props.barsWidth} - x={x} - y={y} - /> - ); - return ( - <Tooltip key={index} overlay={point.tooltip || undefined}> - {rect} - </Tooltip> - ); - }); - return <g>{bars}</g>; - }; - - render() { - const { barsWidth, data, width, height, padding = [10, 10, 10, 10] } = this.props; - - const availableWidth = width - padding[1] - padding[3]; - const availableHeight = height - padding[0] - padding[2]; - - const innerPadding = (availableWidth - barsWidth * data.length) / (data.length - 1); - const relativeInnerPadding = innerPadding / (innerPadding + barsWidth); - - const maxY = max(data, (d) => d.y) as number; - const xScale = scaleBand<number>() - .domain(data.map((d) => d.x)) - .range([0, availableWidth]) - .paddingInner(relativeInnerPadding); - const yScale = scaleLinear().domain([0, maxY]).range([availableHeight, 0]); - - return ( - <svg className="bar-chart" height={height} width={width}> - <g transform={`translate(${padding[3]}, ${padding[0]})`}> - {this.renderXTicks(xScale, yScale)} - {this.renderXValues(xScale, yScale)} - {this.renderBars(xScale, yScale)} - </g> - </svg> - ); - } -} diff --git a/server/sonar-ui-common/components/charts/BubbleChart.css b/server/sonar-ui-common/components/charts/BubbleChart.css deleted file mode 100644 index c5faa9af5a1..00000000000 --- a/server/sonar-ui-common/components/charts/BubbleChart.css +++ /dev/null @@ -1,56 +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. - */ -.bubble-chart text { - user-select: none; -} - -.bubble-chart-bubble { - fill: var(--blue); - fill-opacity: 0.2; - stroke: var(--blue); - cursor: pointer; - transition: fill-opacity 0.2s ease; -} - -.bubble-chart-bubble:hover { - fill-opacity: 0.8; -} - -.bubble-chart-grid { - shape-rendering: crispedges; - stroke: #eee; -} - -.bubble-chart-tick { - fill: var(--secondFontColor); - font-size: var(--smallFontSize); - text-anchor: middle; -} - -.bubble-chart-tick-y { - text-anchor: end; -} - -.bubble-chart-zoom { - position: absolute; - right: 20px; - top: 20px; - z-index: var(--aboveNormalZIndex); -} diff --git a/server/sonar-ui-common/components/charts/BubbleChart.tsx b/server/sonar-ui-common/components/charts/BubbleChart.tsx deleted file mode 100644 index d0a7ae7da23..00000000000 --- a/server/sonar-ui-common/components/charts/BubbleChart.tsx +++ /dev/null @@ -1,382 +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 { max, min } from 'd3-array'; -import { scaleLinear, ScaleLinear } from 'd3-scale'; -import { event, select } from 'd3-selection'; -import { zoom, ZoomBehavior, zoomIdentity } from 'd3-zoom'; -import { sortBy, uniq } from 'lodash'; -import * as React from 'react'; -import { Link } from 'react-router'; -import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer'; -import { translate } from '../../helpers/l10n'; -import { Location } from '../../helpers/urls'; -import Tooltip from '../controls/Tooltip'; -import './BubbleChart.css'; - -const TICKS_COUNT = 5; - -interface BubbleItem<T> { - color?: string; - key?: string; - link?: string | Location; - data?: T; - size: number; - tooltip?: React.ReactNode; - x: number; - y: number; -} - -interface Props<T> { - displayXGrid?: boolean; - displayXTicks?: boolean; - displayYGrid?: boolean; - displayYTicks?: boolean; - formatXTick: (tick: number) => string; - formatYTick: (tick: number) => string; - height: number; - items: BubbleItem<T>[]; - onBubbleClick?: (ref?: T) => void; - padding: [number, number, number, number]; - sizeDomain?: [number, number]; - sizeRange?: [number, number]; - xDomain?: [number, number]; - yDomain?: [number, number]; -} - -interface State { - transform: { x: number; y: number; k: number }; -} - -type Scale = ScaleLinear<number, number>; - -export default class BubbleChart<T> extends React.PureComponent<Props<T>, State> { - private node?: Element; - private zoom?: ZoomBehavior<Element, unknown>; - - static defaultProps = { - displayXGrid: true, - displayXTicks: true, - displayYGrid: true, - displayYTicks: true, - formatXTick: (d: number) => String(d), - formatYTick: (d: number) => String(d), - padding: [10, 10, 10, 10], - sizeRange: [5, 45], - }; - - constructor(props: Props<T>) { - super(props); - this.state = { transform: { x: 0, y: 0, k: 1 } }; - } - - componentDidUpdate() { - if (this.zoom && this.node) { - const rect = this.node.getBoundingClientRect(); - this.zoom.translateExtent([ - [0, 0], - [rect.width, rect.height], - ]); - } - } - - boundNode = (node: SVGSVGElement) => { - this.node = node; - this.zoom = zoom().scaleExtent([1, 10]).on('zoom', this.zoomed); - select(this.node).call(this.zoom); - }; - - zoomed = () => { - const { padding } = this.props; - const { x, y, k } = event.transform as { x: number; y: number; k: number }; - this.setState({ - transform: { - x: x + padding[3] * (k - 1), - y: y + padding[0] * (k - 1), - k, - }, - }); - }; - - resetZoom = (event: React.MouseEvent<Link>) => { - event.stopPropagation(); - event.preventDefault(); - if (this.zoom && this.node) { - select(this.node).call(this.zoom.transform, zoomIdentity); - } - }; - - getXRange(xScale: Scale, sizeScale: Scale, availableWidth: number) { - const minX = min(this.props.items, (d) => xScale(d.x) - sizeScale(d.size)) || 0; - const maxX = max(this.props.items, (d) => xScale(d.x) + sizeScale(d.size)) || 0; - const dMinX = minX < 0 ? xScale.range()[0] - minX : xScale.range()[0]; - const dMaxX = maxX > xScale.range()[1] ? maxX - xScale.range()[1] : 0; - return [dMinX, availableWidth - dMaxX]; - } - - getYRange(yScale: Scale, sizeScale: Scale, availableHeight: number) { - const minY = min(this.props.items, (d) => yScale(d.y) - sizeScale(d.size)) || 0; - const maxY = max(this.props.items, (d) => yScale(d.y) + sizeScale(d.size)) || 0; - const dMinY = minY < 0 ? yScale.range()[1] - minY : yScale.range()[1]; - const dMaxY = maxY > yScale.range()[0] ? maxY - yScale.range()[0] : 0; - return [availableHeight - dMaxY, dMinY]; - } - - getTicks(scale: Scale, format: (d: number) => string) { - const zoom = Math.ceil(this.state.transform.k); - const ticks = scale.ticks(TICKS_COUNT * zoom).map((tick) => format(tick)); - const uniqueTicksCount = uniq(ticks).length; - const ticksCount = - uniqueTicksCount < TICKS_COUNT * zoom ? uniqueTicksCount - 1 : TICKS_COUNT * zoom; - return scale.ticks(ticksCount); - } - - getZoomLevelLabel = () => Math.floor(this.state.transform.k * 100) + '%'; - - renderXGrid = (ticks: number[], xScale: Scale, yScale: Scale) => { - if (!this.props.displayXGrid) { - return null; - } - - const { transform } = this.state; - const lines = ticks.map((tick, index) => { - const x = xScale(tick); - const y1 = yScale.range()[0]; - const y2 = yScale.range()[1]; - return ( - <line - className="bubble-chart-grid" - key={index} - x1={x * transform.k + transform.x} - x2={x * transform.k + transform.x} - y1={y1 * transform.k} - y2={transform.k > 1 ? 0 : y2} - /> - ); - }); - - return <g>{lines}</g>; - }; - - renderYGrid = (ticks: number[], xScale: Scale, yScale: Scale) => { - if (!this.props.displayYGrid) { - return null; - } - - const { transform } = this.state; - const lines = ticks.map((tick, index) => { - const y = yScale(tick); - const x1 = xScale.range()[0]; - const x2 = xScale.range()[1]; - return ( - <line - className="bubble-chart-grid" - key={index} - x1={transform.k > 1 ? 0 : x1} - x2={x2 * transform.k} - y1={y * transform.k + transform.y} - y2={y * transform.k + transform.y} - /> - ); - }); - - return <g>{lines}</g>; - }; - - renderXTicks = (xTicks: number[], xScale: Scale, yScale: Scale) => { - if (!this.props.displayXTicks) { - return null; - } - - const { transform } = this.state; - const ticks = xTicks.map((tick, index) => { - const x = xScale(tick) * transform.k + transform.x; - const y = yScale.range()[0]; - const innerText = this.props.formatXTick(tick); - // as we modified the `x` using `transform`, check that it is inside the range again - return x > 0 && x < xScale.range()[1] ? ( - <text className="bubble-chart-tick" dy="1.5em" key={index} x={x} y={y}> - {innerText} - </text> - ) : null; - }); - - return <g>{ticks}</g>; - }; - - renderYTicks = (yTicks: number[], xScale: Scale, yScale: Scale) => { - if (!this.props.displayYTicks) { - return null; - } - - const { transform } = this.state; - const ticks = yTicks.map((tick, index) => { - const x = xScale.range()[0]; - const y = yScale(tick) * transform.k + transform.y; - const innerText = this.props.formatYTick(tick); - // as we modified the `y` using `transform`, check that it is inside the range again - return y > 0 && y < yScale.range()[0] ? ( - <text - className="bubble-chart-tick bubble-chart-tick-y" - dx="-0.5em" - dy="0.3em" - key={index} - x={x} - y={y}> - {innerText} - </text> - ) : null; - }); - - return <g>{ticks}</g>; - }; - - renderChart = (width: number) => { - const { transform } = this.state; - const availableWidth = width - this.props.padding[1] - this.props.padding[3]; - const availableHeight = this.props.height - this.props.padding[0] - this.props.padding[2]; - - const xScale = scaleLinear() - .domain(this.props.xDomain || [0, max(this.props.items, (d) => d.x) || 0]) - .range([0, availableWidth]) - .nice(); - const yScale = scaleLinear() - .domain(this.props.yDomain || [0, max(this.props.items, (d) => d.y) || 0]) - .range([availableHeight, 0]) - .nice(); - const sizeScale = scaleLinear() - .domain(this.props.sizeDomain || [0, max(this.props.items, (d) => d.size) || 0]) - .range(this.props.sizeRange || []); - - const xScaleOriginal = xScale.copy(); - const yScaleOriginal = yScale.copy(); - - xScale.range(this.getXRange(xScale, sizeScale, availableWidth)); - yScale.range(this.getYRange(yScale, sizeScale, availableHeight)); - - const bubbles = sortBy(this.props.items, (b) => -b.size).map((item, index) => { - return ( - <Bubble - color={item.color} - data={item.data} - key={item.key || index} - link={item.link} - onClick={this.props.onBubbleClick} - r={sizeScale(item.size)} - scale={1 / transform.k} - tooltip={item.tooltip} - x={xScale(item.x)} - y={yScale(item.y)} - /> - ); - }); - - const xTicks = this.getTicks(xScale, this.props.formatXTick); - const yTicks = this.getTicks(yScale, this.props.formatYTick); - - return ( - <svg - className={classNames('bubble-chart')} - height={this.props.height} - ref={this.boundNode} - width={width}> - <defs> - <clipPath id="graph-region"> - <rect - // Extend clip by 2 pixels: one for clipRect border, and one for Bubble borders - height={availableHeight + 4} - width={availableWidth + 4} - x={-2} - y={-2} - /> - </clipPath> - </defs> - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}> - <g clipPath="url(#graph-region)"> - {this.renderXGrid(xTicks, xScale, yScale)} - {this.renderYGrid(yTicks, xScale, yScale)} - <g transform={`translate(${transform.x}, ${transform.y}) scale(${transform.k})`}> - {bubbles} - </g> - </g> - {this.renderXTicks(xTicks, xScale, yScaleOriginal)} - {this.renderYTicks(yTicks, xScaleOriginal, yScale)} - </g> - </svg> - ); - }; - - render() { - return ( - <div> - <div className="bubble-chart-zoom"> - <Tooltip overlay={translate('component_measures.bubble_chart.zoom_level')}> - <Link onClick={this.resetZoom} to="#"> - {this.getZoomLevelLabel()} - </Link> - </Tooltip> - </div> - <AutoSizer disableHeight={true}>{(size) => this.renderChart(size.width)}</AutoSizer> - </div> - ); - } -} - -interface BubbleProps<T> { - color?: string; - link?: string | Location; - onClick?: (ref?: T) => void; - data?: T; - r: number; - scale: number; - tooltip?: string | React.ReactNode; - x: number; - y: number; -} - -function Bubble<T>(props: BubbleProps<T>) { - const handleClick = (event: React.MouseEvent<SVGCircleElement>) => { - if (props.onClick) { - event.stopPropagation(); - event.preventDefault(); - props.onClick(props.data); - } - }; - - let circle = ( - <circle - className="bubble-chart-bubble" - onClick={props.onClick ? handleClick : undefined} - r={props.r} - style={{ fill: props.color, stroke: props.color }} - transform={`translate(${props.x}, ${props.y}) scale(${props.scale})`} - /> - ); - - if (props.link && !props.onClick) { - circle = <Link to={props.link}>{circle}</Link>; - } - - return ( - <Tooltip overlay={props.tooltip || undefined}> - <g>{circle}</g> - </Tooltip> - ); -} diff --git a/server/sonar-ui-common/components/charts/ColorGradientLegend.css b/server/sonar-ui-common/components/charts/ColorGradientLegend.css deleted file mode 100644 index a6c96275921..00000000000 --- a/server/sonar-ui-common/components/charts/ColorGradientLegend.css +++ /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. - */ -.gradient-legend-text, -.gradient-legend-na { - text-anchor: middle; - fill: var(--secondFontColor); - font-size: 10px; -} - -.gradient-legend-text:first-of-type { - text-anchor: start; -} - -.gradient-legend-text:last-of-type { - text-anchor: end; -} diff --git a/server/sonar-ui-common/components/charts/ColorGradientLegend.tsx b/server/sonar-ui-common/components/charts/ColorGradientLegend.tsx deleted file mode 100644 index 05c417695c5..00000000000 --- a/server/sonar-ui-common/components/charts/ColorGradientLegend.tsx +++ /dev/null @@ -1,131 +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 { ScaleLinear, ScaleOrdinal } from 'd3-scale'; -import * as React from 'react'; -import { ThemeConsumer } from '../theme'; -import './ColorGradientLegend.css'; - -interface Props { - className?: string; - colorScale: - | ScaleOrdinal<string, string> // used for LEVEL type - | ScaleLinear<string, string | number>; // used for RATING or PERCENT type - height: number; - padding?: [number, number, number, number]; - showColorNA?: boolean; - width: number; -} - -const NA_SPACING = 4; -const NA_GRADIENT_LINE_INCREMENTS = [0, 8, 16, 24]; - -export default function ColorGradientLegend({ - className, - colorScale, - padding = [12, 24, 0, 0], - height, - showColorNA = false, - width, -}: Props) { - const colorRange: Array<string | number> = colorScale.range(); - const colorDomain: Array<string | number> = colorScale.domain(); - const lastColorIdx = colorRange.length - 1; - const lastDomainIdx = colorDomain.length - 1; - const widthNoPadding = width - padding[1]; - const rectHeight = height - padding[0]; - return ( - <ThemeConsumer> - {({ colors }) => ( - <svg className={className} height={height} width={width}> - <defs> - <linearGradient id="gradient-legend"> - {colorRange.map((color, idx) => ( - <stop key={idx} offset={idx / lastColorIdx} stopColor={String(color)} /> - ))} - </linearGradient> - - <pattern - id="stripes" - width="30" - height="30" - patternTransform="rotate(45 0 0)" - patternUnits="userSpaceOnUse"> - {NA_GRADIENT_LINE_INCREMENTS.map((i) => ( - <React.Fragment key={i}> - <line - x1={i} - y1="0" - x2={i} - y2="30" - style={{ stroke: colors.gray71, strokeWidth: NA_SPACING }} - /> - <line - x1={i + NA_SPACING} - y1="0" - x2={i + NA_SPACING} - y2="30" - style={{ stroke: colors.gray60, strokeWidth: NA_SPACING }} - /> - </React.Fragment> - ))} - </pattern> - </defs> - <g transform={`translate(${padding[3]}, ${padding[0]})`}> - <rect - fill="url(#gradient-legend)" - height={rectHeight} - width={widthNoPadding} - x={0} - y={0} - /> - {colorDomain.map((d, idx) => ( - <text - className="gradient-legend-text" - dy="-2px" - key={idx} - x={widthNoPadding * (idx / lastDomainIdx)} - y={0}> - {d} - </text> - ))} - </g> - {showColorNA && ( - <g transform={`translate(${widthNoPadding}, ${padding[0]})`}> - <rect - fill="url(#stripes)" - height={rectHeight} - width={padding[1] - NA_SPACING} - x={NA_SPACING} - y={0} - /> - <text - className="gradient-legend-na" - dy="-2px" - x={NA_SPACING + (padding[1] - NA_SPACING) / 2} - y={0}> - N/A - </text> - </g> - )} - </svg> - )} - </ThemeConsumer> - ); -} diff --git a/server/sonar-ui-common/components/charts/DonutChart.tsx b/server/sonar-ui-common/components/charts/DonutChart.tsx deleted file mode 100644 index e3c7b60abd2..00000000000 --- a/server/sonar-ui-common/components/charts/DonutChart.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 { arc as d3Arc, pie as d3Pie, PieArcDatum } from 'd3-shape'; -import * as React from 'react'; - -interface DataPoint { - fill: string; - value: number; -} - -export interface DonutChartProps { - data: DataPoint[]; - height: number; - padAngle?: number; - padding?: [number, number, number, number]; - thickness: number; - width: number; -} - -export default function DonutChart(props: DonutChartProps) { - const { height, padding = [0, 0, 0, 0], width } = props; - - const availableWidth = width - padding[1] - padding[3]; - const availableHeight = height - padding[0] - padding[2]; - - const size = Math.min(availableWidth, availableHeight); - const radius = Math.floor(size / 2); - - const pie = d3Pie<any, DataPoint>() - .sort(null) - .value((d) => d.value); - - if (props.padAngle !== undefined) { - pie.padAngle(props.padAngle); - } - - const sectors = pie(props.data).map((d, i) => { - return ( - <Sector - data={d} - fill={props.data[i].fill} - key={i} - radius={radius} - thickness={props.thickness} - /> - ); - }); - - return ( - <svg className="donut-chart" height={height} width={width}> - <g transform={`translate(${padding[3]}, ${padding[0]})`}> - <g transform={`translate(${radius}, ${radius})`}>{sectors}</g> - </g> - </svg> - ); -} - -interface SectorProps { - data: PieArcDatum<DataPoint>; - fill: string; - radius: number; - thickness: number; -} - -function Sector(props: SectorProps) { - const arc = d3Arc<any, PieArcDatum<DataPoint>>() - .outerRadius(props.radius) - .innerRadius(props.radius - props.thickness); - const d = arc(props.data) as string; - return <path d={d} style={{ fill: props.fill }} />; -} diff --git a/server/sonar-ui-common/components/charts/Histogram.css b/server/sonar-ui-common/components/charts/Histogram.css deleted file mode 100644 index 8ca78c53e4b..00000000000 --- a/server/sonar-ui-common/components/charts/Histogram.css +++ /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. - */ -.histogram-tick { - text-anchor: end; -} - -.histogram-tick-start { - text-anchor: start; -} - -.histogram-value { - text-anchor: start; -} diff --git a/server/sonar-ui-common/components/charts/Histogram.tsx b/server/sonar-ui-common/components/charts/Histogram.tsx deleted file mode 100644 index 61948c4e2a3..00000000000 --- a/server/sonar-ui-common/components/charts/Histogram.tsx +++ /dev/null @@ -1,138 +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 { max } from 'd3-array'; -import { scaleBand, ScaleBand, scaleLinear, ScaleLinear } from 'd3-scale'; -import * as React from 'react'; -import Tooltip from '../controls/Tooltip'; -import './BarChart.css'; -import './Histogram.css'; - -interface Props { - alignTicks?: boolean; - bars: number[]; - height: number; - padding?: [number, number, number, number]; - yTicks?: string[]; - yTooltips?: string[]; - yValues?: string[]; - width: number; -} - -const BAR_HEIGHT = 10; -const DEFAULT_PADDING = [10, 10, 10, 10]; - -type XScale = ScaleLinear<number, number>; -type YScale = ScaleBand<number>; - -export default class Histogram extends React.PureComponent<Props> { - renderBar(d: number, index: number, xScale: XScale, yScale: YScale) { - const { alignTicks, padding = DEFAULT_PADDING } = this.props; - - const width = Math.round(xScale(d)) + /* minimum bar width */ 1; - const x = xScale.range()[0] + (alignTicks ? padding[3] : 0); - const y = Math.round(yScale(index)! + yScale.bandwidth() / 2); - - return <rect className="bar-chart-bar" height={BAR_HEIGHT} width={width} x={x} y={y} />; - } - - renderValue(d: number, index: number, xScale: XScale, yScale: YScale) { - const { alignTicks, padding = DEFAULT_PADDING, yValues } = this.props; - - const value = yValues && yValues[index]; - - if (!value) { - return null; - } - - const x = xScale(d) + (alignTicks ? padding[3] : 0); - const y = Math.round(yScale(index)! + yScale.bandwidth() / 2 + BAR_HEIGHT / 2); - - return ( - <Tooltip overlay={this.props.yTooltips && this.props.yTooltips[index]}> - <text className="bar-chart-tick histogram-value" dx="1em" dy="0.3em" x={x} y={y}> - {value} - </text> - </Tooltip> - ); - } - - renderTick(index: number, xScale: XScale, yScale: YScale) { - const { alignTicks, yTicks } = this.props; - - const tick = yTicks && yTicks[index]; - - if (!tick) { - return null; - } - - const x = xScale.range()[0]; - const y = Math.round(yScale(index)! + yScale.bandwidth() / 2 + BAR_HEIGHT / 2); - const historyTickClass = alignTicks ? 'histogram-tick-start' : 'histogram-tick'; - - return ( - <text - className={'bar-chart-tick ' + historyTickClass} - dx={alignTicks ? 0 : '-1em'} - dy="0.3em" - x={x} - y={y}> - {tick} - </text> - ); - } - - renderBars(xScale: XScale, yScale: YScale) { - return ( - <g> - {this.props.bars.map((d, index) => { - return ( - <g key={index}> - {this.renderBar(d, index, xScale, yScale)} - {this.renderValue(d, index, xScale, yScale)} - {this.renderTick(index, xScale, yScale)} - </g> - ); - })} - </g> - ); - } - - render() { - const { bars, width, height, padding = DEFAULT_PADDING } = this.props; - - const availableWidth = width - padding[1] - padding[3]; - const xScale: XScale = scaleLinear() - .domain([0, max(bars)!]) - .range([0, availableWidth]); - - const availableHeight = height - padding[0] - padding[2]; - const yScale: YScale = scaleBand<number>() - .domain(bars.map((_, index) => index)) - .rangeRound([0, availableHeight]); - - return ( - <svg className="bar-chart" height={this.props.height} width={this.props.width}> - <g transform={`translate(${this.props.alignTicks ? 4 : padding[3]}, ${padding[0]})`}> - {this.renderBars(xScale, yScale)} - </g> - </svg> - ); - } -} diff --git a/server/sonar-ui-common/components/charts/LineChart.css b/server/sonar-ui-common/components/charts/LineChart.css deleted file mode 100644 index 37d7f95698c..00000000000 --- a/server/sonar-ui-common/components/charts/LineChart.css +++ /dev/null @@ -1,69 +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. - */ -.line-chart-path { - fill: none; - stroke: var(--blue); - stroke-width: 2px; -} - -.line-chart-path.line-chart-path-1 { - stroke: var(--darkBlue); -} - -.line-chart-path.line-chart-path-2 { - stroke: #24c6e0; -} - -.line-chart-area { - fill: rgba(75, 159, 213, 0.3); - stroke-width: 0; -} - -.line-chart-area.line-chart-area-1 { - fill: rgba(35, 106, 151, 0.3); -} - -.line-chart-area.line-chart-area-2 { - fill: rgba(36, 198, 224, 0.3); -} - -.line-chart-point { - fill: #fff; - stroke: var(--blue); - stroke-width: 2px; -} - -.line-chart-tick { - fill: var(--secondFontColor); - font-size: var(--smallFontSize); -} - -.line-chart-tick-x { - text-anchor: end; -} - -.line-chart-tick-x-right { - text-anchor: start; -} - -.line-chart-grid { - shape-rendering: crispedges; - stroke: #eee; -} diff --git a/server/sonar-ui-common/components/charts/LineChart.tsx b/server/sonar-ui-common/components/charts/LineChart.tsx deleted file mode 100644 index ea48e43c4e0..00000000000 --- a/server/sonar-ui-common/components/charts/LineChart.tsx +++ /dev/null @@ -1,195 +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 { extent, max } from 'd3-array'; -import { scaleLinear, ScaleLinear } from 'd3-scale'; -import { area as d3Area, curveBasis, line as d3Line } from 'd3-shape'; -import * as React from 'react'; -import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer'; -import './LineChart.css'; - -interface DataPoint { - x: number; - y?: number; -} - -interface Props { - backdropConstraints?: [number, number]; - data: DataPoint[]; - displayBackdrop?: boolean; - displayPoints?: boolean; - displayVerticalGrid?: boolean; - domain?: [number, number]; - height: number; - padding?: [number, number, number, number]; - width?: number; - xTicks?: {}[]; - xValues?: {}[]; -} - -export default class LineChart extends React.PureComponent<Props> { - renderBackdrop(xScale: ScaleLinear<number, number>, yScale: ScaleLinear<number, number>) { - const { displayBackdrop = true } = this.props; - - if (!displayBackdrop) { - return null; - } - - const area = d3Area<DataPoint>() - .x((d) => xScale(d.x)) - .y0(yScale.range()[0]) - .y1((d) => yScale(d.y || 0)) - .defined((d) => d.y != null) - .curve(curveBasis); - - let { data } = this.props; - if (this.props.backdropConstraints) { - const c = this.props.backdropConstraints; - data = data.filter((d) => c[0] <= d.x && d.x <= c[1]); - } - - return <path className="line-chart-backdrop" d={area(data) as string} />; - } - - renderPoints(xScale: ScaleLinear<number, number>, yScale: ScaleLinear<number, number>) { - const { displayPoints = true } = this.props; - - if (!displayPoints) { - return null; - } - - const points = this.props.data - .filter((point) => point.y != null) - .map((point, index) => { - const x = xScale(point.x); - const y = yScale(point.y || 0); - return <circle className="line-chart-point" cx={x} cy={y} key={index} r="3" />; - }); - return <g>{points}</g>; - } - - renderVerticalGrid(xScale: ScaleLinear<number, number>, yScale: ScaleLinear<number, number>) { - const { displayVerticalGrid = true } = this.props; - - if (!displayVerticalGrid) { - return null; - } - - const lines = this.props.data.map((point, index) => { - const x = xScale(point.x); - const y1 = yScale.range()[0]; - const y2 = yScale(point.y || 0); - return <line className="line-chart-grid" key={index} x1={x} x2={x} y1={y1} y2={y2} />; - }); - return <g>{lines}</g>; - } - - renderXTicks(xScale: ScaleLinear<number, number>, yScale: ScaleLinear<number, number>) { - const { xTicks = [] } = this.props; - - if (!xTicks.length) { - return null; - } - - const ticks = xTicks.map((tick, index) => { - const point = this.props.data[index]; - const x = xScale(point.x); - const y = yScale.range()[0]; - return ( - <text className="line-chart-tick" dy="1.5em" key={index} x={x} y={y}> - {tick} - </text> - ); - }); - return <g>{ticks}</g>; - } - - renderXValues(xScale: ScaleLinear<number, number>, yScale: ScaleLinear<number, number>) { - const { xValues = [] } = this.props; - - if (!xValues.length) { - return null; - } - - const ticks = xValues.map((value, index) => { - const point = this.props.data[index]; - const x = xScale(point.x); - const y = yScale(point.y || 0); - return ( - <text className="line-chart-tick" dy="-1em" key={index} x={x} y={y}> - {value} - </text> - ); - }); - return <g>{ticks}</g>; - } - - renderLine(xScale: ScaleLinear<number, number>, yScale: ScaleLinear<number, number>) { - const p = d3Line<DataPoint>() - .x((d) => xScale(d.x)) - .y((d) => yScale(d.y || 0)) - .defined((d) => d.y != null) - .curve(curveBasis); - return <path className="line-chart-path" d={p(this.props.data) as string} />; - } - - renderChart = (width: number) => { - const { height, padding = [10, 10, 10, 10] } = this.props; - - if (!width || !height) { - return <div />; - } - - const availableWidth = width - padding[1] - padding[3]; - const availableHeight = height - padding[0] - padding[2]; - - const xScale = scaleLinear() - .domain(extent(this.props.data, (d) => d.x) as [number, number]) - .range([0, availableWidth]); - const yScale = scaleLinear().range([availableHeight, 0]); - - if (this.props.domain) { - yScale.domain(this.props.domain); - } else { - const maxY = max(this.props.data, (d) => d.y) as number; - yScale.domain([0, maxY]); - } - - return ( - <svg className="line-chart" height={height} width={width}> - <g transform={`translate(${padding[3]}, ${padding[0]})`}> - {this.renderVerticalGrid(xScale, yScale)} - {this.renderBackdrop(xScale, yScale)} - {this.renderLine(xScale, yScale)} - {this.renderPoints(xScale, yScale)} - {this.renderXTicks(xScale, yScale)} - {this.renderXValues(xScale, yScale)} - </g> - </svg> - ); - }; - - render() { - return this.props.width !== undefined ? ( - this.renderChart(this.props.width) - ) : ( - <AutoSizer disableHeight={true}>{(size) => this.renderChart(size.width)}</AutoSizer> - ); - } -} diff --git a/server/sonar-ui-common/components/charts/TreeMap.css b/server/sonar-ui-common/components/charts/TreeMap.css deleted file mode 100644 index fe9e1d24b18..00000000000 --- a/server/sonar-ui-common/components/charts/TreeMap.css +++ /dev/null @@ -1,95 +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. - */ -.sonar-d3 .treemap-container { - position: relative; -} - -.sonar-d3 .treemap-cell { - position: absolute; - border-right: 1px solid #fff; - border-bottom: 1px solid #fff; - box-sizing: border-box; - text-align: center; - overflow: hidden; -} - -.sonar-d3 .treemap-cell:focus { - outline: none; -} - -.sonar-d3 .treemap-inner { - display: inline-flex; - vertical-align: middle; - align-items: center; - justify-content: center; - flex-wrap: wrap; - padding: var(--gridSize); - box-sizing: border-box; - line-height: 1.2; - background: rgba(0, 0, 0, 0.6); - border-radius: 2px; -} - -.sonar-d3 .treemap-inner .treemap-icon { - flex-shrink: 0; -} - -.sonar-d3 .treemap-inner .treemap-icon svg { - margin-top: 2px; -} - -.sonar-d3 .treemap-inner .treemap-icon svg path { - fill: var(--barBackgroundColor) !important; -} - -.sonar-d3 .treemap-inner .treemap-text { - flex-shrink: 1; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - text-align: center; - color: var(--barBackgroundColor); -} - -.sonar-d3 .treemap-inner .treemap-text-suffix { - color: var(--barBorderColor); - font-size: var(--smallFontSize); -} - -.sonar-d3 .treemap-link { - position: absolute; - z-index: var(--normalZIndex); - top: 5px; - right: 5px; - line-height: 14px; - font-size: var(--smallFontSize); - border-bottom: none; -} - -.sonar-d3 .treemap-link:hover { - color: #d1eafb; -} - -.sonar-d3 .treemap-link i, -.sonar-d3 .treemap-link i:before { - vertical-align: top; - font-size: inherit; - line-height: inherit; -} diff --git a/server/sonar-ui-common/components/charts/TreeMap.tsx b/server/sonar-ui-common/components/charts/TreeMap.tsx deleted file mode 100644 index de082a37a99..00000000000 --- a/server/sonar-ui-common/components/charts/TreeMap.tsx +++ /dev/null @@ -1,114 +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 { hierarchy as d3Hierarchy, treemap as d3Treemap } from 'd3-hierarchy'; -import * as React from 'react'; -import { formatMeasure, localizeMetric } from '../../helpers/measures'; -import { Location } from '../../helpers/urls'; -import './TreeMap.css'; -import TreeMapRect from './TreeMapRect'; - -export interface TreeMapItem { - color?: string; - gradient?: string; - icon?: React.ReactNode; - key: string; - label: string; - link?: string | Location; - measureValue?: string; - metric?: { key: string; type: string }; - size: number; - tooltip?: React.ReactNode; -} - -interface HierarchicalTreemapItem extends TreeMapItem { - children?: TreeMapItem[]; -} - -interface Props { - height: number; - items: TreeMapItem[]; - onRectangleClick?: (item: string) => void; - width: number; -} - -export default class TreeMap extends React.PureComponent<Props> { - mostCommitPrefix = (labels: string[]) => { - const sortedLabels = labels.slice(0).sort(); - const firstLabel = sortedLabels[0]; - const firstLabelLength = firstLabel.length; - const lastLabel = sortedLabels[sortedLabels.length - 1]; - let i = 0; - while (i < firstLabelLength && firstLabel.charAt(i) === lastLabel.charAt(i)) { - i++; - } - const prefix = firstLabel.substr(0, i); - const prefixTokens = prefix.split(/[\s\\/]/); - const lastPrefixPart = prefixTokens[prefixTokens.length - 1]; - return prefix.substr(0, prefix.length - lastPrefixPart.length); - }; - - render() { - const { items, height, width } = this.props; - const hierarchy = d3Hierarchy({ children: items } as HierarchicalTreemapItem) - .sum((d) => d.size) - .sort((a, b) => (b.value || 0) - (a.value || 0)); - - const treemap = d3Treemap<TreeMapItem>().round(true).size([width, height]); - - const nodes = treemap(hierarchy).leaves(); - const prefix = this.mostCommitPrefix(items.map((item) => item.label)); - const halfWidth = width / 2; - return ( - <div className="sonar-d3"> - <div className="treemap-container" style={{ width, height }}> - {nodes.map((node) => ( - <TreeMapRect - fill={node.data.color} - gradient={node.data.gradient} - height={node.y1 - node.y0} - icon={node.data.icon} - itemKey={node.data.key} - key={node.data.key} - label={node.data.label} - link={node.data.link} - onClick={this.props.onRectangleClick} - placement={node.x0 === 0 || node.x1 < halfWidth ? 'right' : 'left'} - prefix={prefix} - value={ - node.data.metric && ( - <> - {formatMeasure(node.data.measureValue, node.data.metric.type)} - <span className="little-spacer-left"> - {localizeMetric(node.data.metric.key)} - </span> - </> - ) - } - tooltip={node.data.tooltip} - width={node.x1 - node.x0} - x={node.x0} - y={node.y0} - /> - ))} - </div> - </div> - ); - } -} diff --git a/server/sonar-ui-common/components/charts/TreeMapRect.tsx b/server/sonar-ui-common/components/charts/TreeMapRect.tsx deleted file mode 100644 index 7226fd51928..00000000000 --- a/server/sonar-ui-common/components/charts/TreeMapRect.tsx +++ /dev/null @@ -1,142 +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 { scaleLinear } from 'd3-scale'; -import * as React from 'react'; -import { Link } from 'react-router'; -import { Location } from '../../helpers/urls'; -import Tooltip, { Placement } from '../controls/Tooltip'; -import LinkIcon from '../icons/LinkIcon'; - -const SIZE_SCALE = scaleLinear().domain([3, 15]).range([11, 18]).clamp(true); - -interface Props { - fill?: string; - gradient?: string; - height: number; - icon?: React.ReactNode; - itemKey: string; - label: string; - link?: string | Location; - onClick?: (item: string) => void; - placement?: Placement; - prefix: string; - tooltip?: React.ReactNode; - value?: React.ReactNode; - width: number; - x: number; - y: number; -} - -const TEXT_VISIBLE_AT_WIDTH = 80; -const TEXT_VISIBLE_AT_HEIGHT = 50; -const ICON_VISIBLE_AT_WIDTH = 60; -const ICON_VISIBLE_AT_HEIGHT = 30; -export default class TreeMapRect extends React.PureComponent<Props> { - handleLinkClick = (event: React.MouseEvent<HTMLAnchorElement>) => { - event.stopPropagation(); - }; - - handleRectClick = () => { - if (this.props.onClick) { - this.props.onClick(this.props.itemKey); - } - }; - - renderLink = () => { - const { link, height, width } = this.props; - const hasMinSize = width >= 24 && height >= 24 && (width >= 48 || height >= 50); - if (!hasMinSize || link == null) { - return null; - } - return ( - <Link className="treemap-link" onClick={this.handleLinkClick} to={link}> - <LinkIcon /> - </Link> - ); - }; - - renderCell = () => { - const cellStyles = { - left: this.props.x, - top: this.props.y, - width: this.props.width, - height: this.props.height, - backgroundColor: this.props.fill, - backgroundImage: this.props.gradient, - backgroundSize: '12px 12px', - fontSize: SIZE_SCALE(this.props.width / this.props.label.length), - lineHeight: `${this.props.height}px`, - cursor: this.props.onClick != null ? 'pointer' : 'default', - }; - const isTextVisible = - this.props.width >= TEXT_VISIBLE_AT_WIDTH && this.props.height >= TEXT_VISIBLE_AT_HEIGHT; - const isIconVisible = - this.props.width >= ICON_VISIBLE_AT_WIDTH && this.props.height >= ICON_VISIBLE_AT_HEIGHT; - - return ( - <div - className="treemap-cell" - onClick={this.handleRectClick} - role="treeitem" - style={cellStyles} - tabIndex={0}> - {isTextVisible && ( - <div className="treemap-inner" style={{ maxWidth: this.props.width }}> - {this.props.prefix || this.props.value ? ( - <div className="treemap-text"> - <div> - {isIconVisible && ( - <span className={classNames('treemap-icon', { 'spacer-right': isTextVisible })}> - {this.props.icon} - </span> - )} - - {this.props.prefix && ( - <> - {this.props.prefix} - <br /> - </> - )} - - {this.props.label.substr(this.props.prefix.length)} - </div> - - <div className="treemap-text-suffix little-spacer-top">{this.props.value}</div> - </div> - ) : ( - <div className="treemap-text">{this.props.label}</div> - )} - </div> - )} - {this.renderLink()} - </div> - ); - }; - - render() { - const { placement, tooltip } = this.props; - return ( - <Tooltip overlay={tooltip || undefined} placement={placement || 'left'}> - {this.renderCell()} - </Tooltip> - ); - } -} diff --git a/server/sonar-ui-common/components/charts/ZoomTimeLine.css b/server/sonar-ui-common/components/charts/ZoomTimeLine.css deleted file mode 100644 index 21997431077..00000000000 --- a/server/sonar-ui-common/components/charts/ZoomTimeLine.css +++ /dev/null @@ -1,46 +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. - */ -.chart-zoom-tick { - fill: var(--secondFontColor); - font-size: 10px; - text-anchor: middle; - user-select: none; -} - -.chart-zoom .zoom-overlay { - fill: none; - stroke: none; - cursor: crosshair; - pointer-events: all; -} - -.chart-zoom .zoom-selection { - fill: var(--secondFontColor); - fill-opacity: 0.2; - stroke: var(--secondFontColor); - shape-rendering: crispEdges; - cursor: move; -} - -.chart-zoom .zoom-selection-handle { - cursor: ew-resize; - fill-opacity: 0; - stroke: none; -} diff --git a/server/sonar-ui-common/components/charts/ZoomTimeLine.tsx b/server/sonar-ui-common/components/charts/ZoomTimeLine.tsx deleted file mode 100644 index de281613fbe..00000000000 --- a/server/sonar-ui-common/components/charts/ZoomTimeLine.tsx +++ /dev/null @@ -1,397 +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 { extent, max } from 'd3-array'; -import { scaleLinear, scalePoint, scaleTime, ScaleTime } from 'd3-scale'; -import { area, curveBasis, line as d3Line } from 'd3-shape'; -import { flatten, sortBy, throttle } from 'lodash'; -import * as React from 'react'; -import Draggable, { DraggableBounds, DraggableCore, DraggableData } from 'react-draggable'; -import { ThemeConsumer } from '../theme'; -import './LineChart.css'; -import './ZoomTimeLine.css'; - -export interface Props { - basisCurve?: boolean; - endDate?: Date; - height: number; - leakPeriodDate?: Date; - metricType: string; - padding: number[]; - series: T.Chart.Serie[]; - showAreas?: boolean; - showXTicks: boolean; - startDate?: Date; - updateZoom: (start?: Date, endDate?: Date) => void; - width: number; -} - -interface State { - overlayLeftPos?: number; - newZoomStart?: number; -} - -type XScale = ScaleTime<number, number>; -// TODO it should be `ScaleLinear<number, number> | ScalePoint<number> | ScalePoint<string>`, but it's super hard to make it work :'( -type YScale = any; - -export default class ZoomTimeLine extends React.PureComponent<Props, State> { - static defaultProps = { - padding: [0, 0, 18, 0], - showXTicks: true, - }; - - constructor(props: Props) { - super(props); - this.state = {}; - this.handleZoomUpdate = throttle(this.handleZoomUpdate, 40); - } - - getRatingScale = (availableHeight: number) => { - return scalePoint<number>().domain([5, 4, 3, 2, 1]).range([availableHeight, 0]); - }; - - getLevelScale = (availableHeight: number) => { - return scalePoint().domain(['ERROR', 'WARN', 'OK']).range([availableHeight, 0]); - }; - - getYScale = (availableHeight: number, flatData: T.Chart.Point[]): YScale => { - if (this.props.metricType === 'RATING') { - return this.getRatingScale(availableHeight); - } else if (this.props.metricType === 'LEVEL') { - return this.getLevelScale(availableHeight); - } else { - return scaleLinear() - .range([availableHeight, 0]) - .domain([0, max(flatData, (d) => Number(d.y || 0)) as number]) - .nice(); - } - }; - - getXScale = (availableWidth: number, flatData: T.Chart.Point[]): XScale => { - return scaleTime() - .domain(extent(flatData, (d) => d.x) as [Date, Date]) - .range([0, availableWidth]) - .clamp(true); - }; - - getScales = () => { - const availableWidth = this.props.width - this.props.padding[1] - this.props.padding[3]; - const availableHeight = this.props.height - this.props.padding[0] - this.props.padding[2]; - const flatData = flatten(this.props.series.map((serie) => serie.data)); - return { - xScale: this.getXScale(availableWidth, flatData), - yScale: this.getYScale(availableHeight, flatData), - }; - }; - - getEventMarker = (size: number) => { - const half = size / 2; - return `M${half} 0 L${size} ${half} L ${half} ${size} L0 ${half} L${half} 0 L${size} ${half}`; - }; - - handleDoubleClick = (xScale: XScale, xDim: number[]) => () => { - this.handleZoomUpdate(xScale, xDim); - }; - - handleSelectionDrag = (xScale: XScale, width: number, xDim: number[], checkDelta?: boolean) => ( - _: MouseEvent, - data: DraggableData - ) => { - if (!checkDelta || data.deltaX) { - const x = Math.max(xDim[0], Math.min(data.x, xDim[1] - width)); - this.handleZoomUpdate(xScale, [x, width + x]); - } - }; - - handleSelectionHandleDrag = ( - xScale: XScale, - fixedX: number, - xDim: number[], - handleDirection: string, - checkDelta?: boolean - ) => (_: MouseEvent, data: DraggableData) => { - if (!checkDelta || data.deltaX) { - const x = Math.max(xDim[0], Math.min(data.x, xDim[1])); - this.handleZoomUpdate(xScale, handleDirection === 'right' ? [fixedX, x] : [x, fixedX]); - } - }; - - handleNewZoomDragStart = (xDim: number[]) => (_: MouseEvent, data: DraggableData) => { - const overlayLeftPos = data.node.getBoundingClientRect().left; - this.setState({ - overlayLeftPos, - newZoomStart: Math.round(Math.max(xDim[0], Math.min(data.x - overlayLeftPos, xDim[1]))), - }); - }; - - handleNewZoomDrag = (xScale: XScale, xDim: number[]) => (_: MouseEvent, data: DraggableData) => { - const { newZoomStart, overlayLeftPos } = this.state; - if (newZoomStart != null && overlayLeftPos != null && data.deltaX) { - this.handleZoomUpdate( - xScale, - sortBy([newZoomStart, Math.max(xDim[0], Math.min(data.x - overlayLeftPos, xDim[1]))]) - ); - } - }; - - handleNewZoomDragEnd = (xScale: XScale, xDim: number[]) => ( - _: MouseEvent, - data: DraggableData - ) => { - const { newZoomStart, overlayLeftPos } = this.state; - if (newZoomStart !== undefined && overlayLeftPos !== undefined) { - const x = Math.round(Math.max(xDim[0], Math.min(data.x - overlayLeftPos, xDim[1]))); - this.handleZoomUpdate(xScale, newZoomStart === x ? xDim : sortBy([newZoomStart, x])); - this.setState({ newZoomStart: undefined, overlayLeftPos: undefined }); - } - }; - - handleZoomUpdate = (xScale: XScale, xArray: number[]) => { - const xRange = xScale.range(); - const startDate = - xArray[0] > xRange[0] && xArray[0] < xRange[xRange.length - 1] - ? xScale.invert(xArray[0]) - : undefined; - const endDate = - xArray[1] > xRange[0] && xArray[1] < xRange[xRange.length - 1] - ? xScale.invert(xArray[1]) - : undefined; - this.props.updateZoom(startDate, endDate); - }; - - renderBaseLine = (xScale: XScale, yScale: YScale) => { - return ( - <line - className="line-chart-grid" - x1={xScale.range()[0]} - x2={xScale.range()[1]} - y1={yScale.range()[0]} - y2={yScale.range()[0]} - /> - ); - }; - - renderTicks = (xScale: XScale, yScale: YScale) => { - const format = xScale.tickFormat(7); - const ticks = xScale.ticks(7); - const y = yScale.range()[0]; - return ( - <g> - {ticks.slice(0, -1).map((tick, index) => { - const nextTick = index + 1 < ticks.length ? ticks[index + 1] : xScale.domain()[1]; - const x = (xScale(tick) + xScale(nextTick)) / 2; - return ( - <text className="chart-zoom-tick" dy="1.3em" key={index} x={x} y={y}> - {format(tick)} - </text> - ); - })} - </g> - ); - }; - - renderLeak = (xScale: XScale, yScale: YScale) => { - const { leakPeriodDate } = this.props; - if (!leakPeriodDate) { - return null; - } - const yRange = yScale.range(); - return ( - <ThemeConsumer> - {(theme) => ( - <rect - fill={theme.colors.leakPrimaryColor} - height={yRange[0] - yRange[yRange.length - 1]} - width={xScale.range()[1] - xScale(leakPeriodDate)} - x={xScale(leakPeriodDate)} - y={yRange[yRange.length - 1]} - /> - )} - </ThemeConsumer> - ); - }; - - renderLines = (xScale: XScale, yScale: YScale) => { - const lineGenerator = d3Line<T.Chart.Point>() - .defined((d) => Boolean(d.y || d.y === 0)) - .x((d) => xScale(d.x)) - .y((d) => yScale(d.y)); - if (this.props.basisCurve) { - lineGenerator.curve(curveBasis); - } - return ( - <g> - {this.props.series.map((serie, idx) => ( - <path - className={classNames('line-chart-path', 'line-chart-path-' + idx)} - d={lineGenerator(serie.data) || undefined} - key={serie.name} - /> - ))} - </g> - ); - }; - - renderAreas = (xScale: XScale, yScale: YScale) => { - const areaGenerator = area<T.Chart.Point>() - .defined((d) => Boolean(d.y || d.y === 0)) - .x((d) => xScale(d.x)) - .y1((d) => yScale(d.y)) - .y0(yScale(0)); - if (this.props.basisCurve) { - areaGenerator.curve(curveBasis); - } - return ( - <g> - {this.props.series.map((serie, idx) => ( - <path - className={classNames('line-chart-area', 'line-chart-area-' + idx)} - d={areaGenerator(serie.data) || undefined} - key={serie.name} - /> - ))} - </g> - ); - }; - - renderZoomHandle = (options: { - xScale: XScale; - xPos: number; - fixedPos: number; - yDim: number[]; - xDim: number[]; - direction: string; - }) => ( - <Draggable - axis="x" - bounds={{ left: options.xDim[0], right: options.xDim[1] } as DraggableBounds} - onDrag={this.handleSelectionHandleDrag( - options.xScale, - options.fixedPos, - options.xDim, - options.direction, - true - )} - onStop={this.handleSelectionHandleDrag( - options.xScale, - options.fixedPos, - options.xDim, - options.direction - )} - position={{ x: options.xPos, y: 0 }}> - <rect - className="zoom-selection-handle" - height={options.yDim[0] - options.yDim[1] + 1} - width={6} - x={-3} - y={options.yDim[1]} - /> - </Draggable> - ); - - renderZoom = (xScale: XScale, yScale: YScale) => { - const xRange = xScale.range(); - const yRange = yScale.range(); - const xDim = [xRange[0], xRange[xRange.length - 1]]; - const yDim = [yRange[0], yRange[yRange.length - 1]]; - const startX = Math.round(this.props.startDate ? xScale(this.props.startDate) : xDim[0]); - const endX = Math.round(this.props.endDate ? xScale(this.props.endDate) : xDim[1]); - const xArray = sortBy([startX, endX]); - const zoomBoxWidth = xArray[1] - xArray[0]; - const showZoomArea = - this.state.newZoomStart == null || - this.state.newZoomStart === startX || - this.state.newZoomStart === endX; - - return ( - <g className="chart-zoom"> - <DraggableCore - onDrag={this.handleNewZoomDrag(xScale, xDim)} - onStart={this.handleNewZoomDragStart(xDim)} - onStop={this.handleNewZoomDragEnd(xScale, xDim)}> - <rect - className="zoom-overlay" - height={yDim[0] - yDim[1]} - width={xDim[1] - xDim[0]} - x={xDim[0]} - y={yDim[1]} - /> - </DraggableCore> - {showZoomArea && ( - <Draggable - axis="x" - bounds={{ left: xDim[0], right: Math.floor(xDim[1] - zoomBoxWidth) } as DraggableBounds} - onDrag={this.handleSelectionDrag(xScale, zoomBoxWidth, xDim, true)} - onStop={this.handleSelectionDrag(xScale, zoomBoxWidth, xDim)} - position={{ x: xArray[0], y: 0 }}> - <rect - className="zoom-selection" - height={yDim[0] - yDim[1] + 1} - onDoubleClick={this.handleDoubleClick(xScale, xDim)} - width={zoomBoxWidth} - x={0} - y={yDim[1]} - /> - </Draggable> - )} - {showZoomArea && - this.renderZoomHandle({ - xScale, - xPos: startX, - fixedPos: endX, - xDim, - yDim, - direction: 'left', - })} - {showZoomArea && - this.renderZoomHandle({ - xScale, - xPos: endX, - fixedPos: startX, - xDim, - yDim, - direction: 'right', - })} - </g> - ); - }; - - render() { - if (!this.props.width || !this.props.height) { - return <div />; - } - - const { xScale, yScale } = this.getScales(); - - return ( - <svg className="line-chart " height={this.props.height} width={this.props.width}> - <g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0] + 2})`}> - {this.renderLeak(xScale, yScale)} - {this.renderBaseLine(xScale, yScale)} - {this.props.showXTicks && this.renderTicks(xScale, yScale)} - {this.props.showAreas && this.renderAreas(xScale, yScale)} - {this.renderLines(xScale, yScale)} - {this.renderZoom(xScale, yScale)} - </g> - </svg> - ); - } -} diff --git a/server/sonar-ui-common/components/charts/__tests__/AdvancedTimeline-test.tsx b/server/sonar-ui-common/components/charts/__tests__/AdvancedTimeline-test.tsx deleted file mode 100644 index 1e16ab14f49..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/AdvancedTimeline-test.tsx +++ /dev/null @@ -1,294 +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 { ThemeConsumer } from '../../theme'; -import AdvancedTimeline from '../AdvancedTimeline'; - -const newCodeLegendClass = '.new-code-legend'; - -// Replace scaleTime with scaleUtc to avoid timezone-dependent snapshots -jest.mock('d3-scale', () => { - const { scaleUtc, ...others } = jest.requireActual('d3-scale'); - - return { - ...others, - scaleTime: scaleUtc, - }; -}); - -jest.mock('lodash', () => { - const lodash = jest.requireActual('lodash'); - return { ...lodash, throttle: (f: any) => f }; -}); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ disableZoom: false, updateZoom: () => {} })).toMatchSnapshot( - 'Zoom enabled' - ); - expect(shallowRender({ formatYTick: (t) => `Nicer tick ${t}` })).toMatchSnapshot('format y tick'); - expect(shallowRender({ width: undefined })).toMatchSnapshot('no width'); - expect(shallowRender({ height: undefined })).toMatchSnapshot('no height'); - expect(shallowRender({ showAreas: undefined })).toMatchSnapshot('no areas'); -}); - -it('should render leak correctly', () => { - const wrapper = shallowRender({ leakPeriodDate: new Date('2019-10-02') }); - - const leakNode = wrapper.find(ThemeConsumer).dive().find('.leak-chart-rect'); - expect(leakNode.exists()).toBe(true); - expect(leakNode.getElement().props.width).toBe(15); -}); - -it('should render leak legend correctly', () => { - const wrapper = shallowRender({ - displayNewCodeLegend: true, - leakPeriodDate: new Date('2019-10-02'), - }); - - const leakNode = wrapper.find(ThemeConsumer).dive(); - expect(leakNode.find(newCodeLegendClass).exists()).toBe(true); - expect(leakNode.find(newCodeLegendClass).props().textAnchor).toBe('start'); - expect(leakNode).toMatchSnapshot(); -}); - -it('should render leak legend correctly for small leak', () => { - const wrapper = shallowRender({ - displayNewCodeLegend: true, - leakPeriodDate: new Date('2020-02-06'), - series: [ - mockData(1, '2020-02-01'), - mockData(2, '2020-02-02'), - mockData(3, '2020-02-03'), - mockData(4, '2020-02-04'), - mockData(5, '2020-02-05'), - mockData(6, '2020-02-06'), - mockData(7, '2020-02-07'), - ], - }); - - const leakNode = wrapper.find(ThemeConsumer).dive(); - expect(leakNode.find(newCodeLegendClass).exists()).toBe(true); - expect(leakNode.find(newCodeLegendClass).props().textAnchor).toBe('end'); -}); - -it('should set leakLegendTextWidth correctly', () => { - const wrapper = shallowRender(); - - wrapper.instance().setLeakLegendTextWidth({ - getBoundingClientRect: () => ({ width: 12 } as DOMRect), - } as SVGTextElement); - - expect(wrapper.state().leakLegendTextWidth).toBe(12); - - wrapper.instance().setLeakLegendTextWidth(null); - - expect(wrapper.state().leakLegendTextWidth).toBe(12); -}); - -it('should render old leak correctly', () => { - const wrapper = shallowRender({ leakPeriodDate: new Date('2014-10-02') }); - - const leakNode = wrapper.find(ThemeConsumer).dive().find('.leak-chart-rect'); - expect(leakNode.exists()).toBe(true); - expect(leakNode.getElement().props.width).toBe(30); -}); - -it('should find date to display based on mouse location', () => { - const wrapper = shallowRender(); - - wrapper.instance().updateTooltipPos(0); - expect(wrapper.state().selectedDateIdx).toBeUndefined(); - - wrapper.instance().handleMouseEnter(); - wrapper.instance().updateTooltipPos(10); - expect(wrapper.state().selectedDateIdx).toBe(1); -}); - -it('should update timeline when width changes', () => { - const updateTooltip = jest.fn(); - const wrapper = shallowRender({ selectedDate: new Date('2019-10-02'), updateTooltip }); - const { xScale, selectedDateXPos } = wrapper.state(); - - wrapper.setProps({ width: 200 }); - expect(wrapper.state().xScale).not.toBe(xScale); - expect(wrapper.state().xScale).toEqual(expect.any(Function)); - expect(wrapper.state().selectedDateXPos).not.toBe(selectedDateXPos); - expect(wrapper.state().selectedDateXPos).toEqual(expect.any(Number)); - expect(updateTooltip).toBeCalled(); -}); - -it('should update tootlips when selected date changes', () => { - const updateTooltip = jest.fn(); - - const wrapper = shallowRender({ selectedDate: new Date('2019-10-01'), updateTooltip }); - const { xScale, selectedDateXPos } = wrapper.state(); - const selectedDate = new Date('2019-10-02'); - - wrapper.setProps({ selectedDate }); - expect(wrapper.state().xScale).toBe(xScale); - expect(wrapper.state().selectedDate).toBe(selectedDate); - expect(wrapper.state().selectedDateXPos).not.toBe(selectedDateXPos); - expect(wrapper.state().selectedDateXPos).toEqual(expect.any(Number)); - expect(updateTooltip).toBeCalled(); -}); - -it('should handle scroll correcly', () => { - let updateZoom = jest.fn(); - let preventDefault = jest.fn(); - let wrapper = shallowRender({ updateZoom }); - wrapper.instance().handleWheel(({ - preventDefault, - deltaX: 1, - deltaY: -2, - deltaZ: 0, - pageX: 100, - pageY: 1, - currentTarget: ({ - getBoundingClientRect: () => ({ - bottom: 0, - height: 100, - width: 50, - left: 0, - right: 0, - top: 10, - x: 12, - y: 23, - toJSON: () => '', - }), - } as any) as SVGElement, - } as any) as React.WheelEvent<SVGElement>); - expect(preventDefault).toBeCalled(); - expect(updateZoom).toBeCalledWith(new Date('2019-10-01T06:24:00.000Z'), undefined); - - updateZoom = jest.fn(); - preventDefault = jest.fn(); - wrapper = shallowRender({ updateZoom }); - wrapper.instance().handleWheel(({ - preventDefault, - deltaX: 1, - deltaY: 2, - deltaZ: 0, - pageX: 100, - pageY: 1, - deltaMode: 25, - currentTarget: ({ - getBoundingClientRect: () => ({ - bottom: 0, - height: 100, - width: 50, - left: 0, - right: 0, - top: 10, - x: 12, - y: 23, - toJSON: () => '', - }), - } as any) as SVGElement, - } as any) as React.WheelEvent<SVGElement>); - expect(preventDefault).toBeCalled(); - expect(updateZoom).toBeCalledWith(undefined, new Date('2019-10-02T20:48:00.000Z')); -}); - -it('should handle mouse out correcly', () => { - const updateTooltip = jest.fn(); - const wrapper = shallowRender({ updateTooltip: undefined }); - wrapper.setState({ - mouseOver: true, - selectedDate: new Date(), - selectedDateXPos: 1, - selectedDateIdx: 1, - }); - wrapper.instance().handleMouseOut(); - expect(wrapper.state().mouseOver).toBe(true); - - wrapper.setProps({ updateTooltip }); - wrapper.instance().handleMouseOut(); - expect(wrapper.state().mouseOver).toBe(false); - expect(wrapper.state().selectedDate).toBeUndefined(); - expect(wrapper.state().selectedDateXPos).toBeUndefined(); - expect(wrapper.state().selectedDateIdx).toBeUndefined(); - wrapper.instance().handleMouseOut(); -}); - -it('should handle click correcly', () => { - const updateSelectedDate = jest.fn(); - const wrapper = shallowRender({ updateSelectedDate }); - wrapper.setState({ selectedDate: new Date() }); - - wrapper.instance().handleClick(); - expect(updateSelectedDate).toBeCalledWith(wrapper.state().selectedDate); - - wrapper.setProps({ updateSelectedDate: undefined }); - updateSelectedDate.mockClear(); - wrapper.instance().handleClick(); - expect(updateSelectedDate).not.toBeCalled(); -}); - -function shallowRender(props?: Partial<AdvancedTimeline['props']>) { - return shallow<AdvancedTimeline>( - <AdvancedTimeline - height={100} - maxYTicksCount={10} - metricType="TEST_METRIC" - series={[ - { - name: 'test-1', - type: 'test-type-1', - translatedName: '', - data: [ - { - x: new Date('2019-10-01'), - y: 1, - }, - { - x: new Date('2019-10-02'), - y: 2, - }, - ], - }, - { - name: 'test-2', - type: 'test-type-2', - translatedName: '', - data: [ - { - x: new Date('2019-10-03'), - y: 3, - }, - ], - }, - ]} - width={100} - zoomSpeed={1} - {...props} - /> - ); -} - -function mockData(i: number, date: string): T.Chart.Serie { - return { - name: `t${i}`, - type: 'type', - translatedName: '', - data: [{ x: new Date(date), y: i }], - }; -} diff --git a/server/sonar-ui-common/components/charts/__tests__/BarChart-test.tsx b/server/sonar-ui-common/components/charts/__tests__/BarChart-test.tsx deleted file mode 100644 index b578e564fad..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/BarChart-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 { shallow } from 'enzyme'; -import * as React from 'react'; -import BarChart from '../BarChart'; - -it('should display bars', () => { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 }, - ]; - const chart = shallow(<BarChart barsWidth={20} data={data} height={100} width={100} />); - expect(chart.find('.bar-chart-bar').length).toBe(3); -}); - -it('should display ticks', () => { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 }, - ]; - const ticks = ['A', 'B', 'C']; - const chart = shallow( - <BarChart barsWidth={20} data={data} height={100} width={100} xTicks={ticks} /> - ); - expect(chart.find('.bar-chart-tick').length).toBe(3); -}); - -it('should display values', () => { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 }, - ]; - const values = ['A', 'B', 'C']; - const chart = shallow( - <BarChart barsWidth={20} data={data} height={100} width={100} xValues={values} /> - ); - expect(chart.find('.bar-chart-tick').length).toBe(3); -}); - -it('should display bars, ticks and values', () => { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 }, - ]; - const ticks = ['A', 'B', 'C']; - const values = ['A', 'B', 'C']; - const chart = shallow( - <BarChart barsWidth={20} data={data} height={100} width={100} xTicks={ticks} xValues={values} /> - ); - expect(chart.find('.bar-chart-bar').length).toBe(3); - expect(chart.find('.bar-chart-tick').length).toBe(6); -}); diff --git a/server/sonar-ui-common/components/charts/__tests__/BubbleChart-test.tsx b/server/sonar-ui-common/components/charts/__tests__/BubbleChart-test.tsx deleted file mode 100644 index dd68ae319b5..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/BubbleChart-test.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 { mount } from 'enzyme'; -import * as React from 'react'; -import { AutoSizerProps } from 'react-virtualized'; -import BubbleChart from '../BubbleChart'; - -jest.mock('react-virtualized/dist/commonjs/AutoSizer', () => ({ - AutoSizer: ({ children }: AutoSizerProps) => children({ width: 100, height: NaN }), -})); - -it('should display bubbles', () => { - const items = [ - { x: 1, y: 10, size: 7 }, - { x: 2, y: 30, size: 5 }, - ]; - const chart = mount(<BubbleChart height={100} items={items} padding={[0, 0, 0, 0]} />); - chart.find('Bubble').forEach((bubble) => expect(bubble).toMatchSnapshot()); - - chart.setProps({ height: 120 }); -}); - -it('should render bubble links', () => { - const items = [ - { x: 1, y: 10, size: 7, link: 'foo' }, - { x: 2, y: 30, size: 5, link: 'bar' }, - ]; - const chart = mount(<BubbleChart height={100} items={items} padding={[0, 0, 0, 0]} />); - chart.find('Bubble').forEach((bubble) => expect(bubble).toMatchSnapshot()); -}); - -it('should render bubbles with click handlers', () => { - const onClick = jest.fn(); - const items = [ - { x: 1, y: 10, size: 7, data: 'foo' }, - { x: 2, y: 30, size: 5, data: 'bar' }, - ]; - const chart = mount( - <BubbleChart height={100} items={items} onBubbleClick={onClick} padding={[0, 0, 0, 0]} /> - ); - chart.find('Bubble').forEach((bubble) => expect(bubble).toMatchSnapshot()); -}); diff --git a/server/sonar-ui-common/components/charts/__tests__/ColorGradientLegend-test.tsx b/server/sonar-ui-common/components/charts/__tests__/ColorGradientLegend-test.tsx deleted file mode 100644 index 76a7c853758..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/ColorGradientLegend-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 { scaleLinear } from 'd3-scale'; -import { shallow } from 'enzyme'; -import * as React from 'react'; -import testTheme from '../../../config/jest/testTheme'; -import ColorGradientLegend from '../ColorGradientLegend'; - -const { colors } = testTheme; -const COLORS = [colors.green, colors.lightGreen, colors.yellow, colors.orange, colors.red]; - -it('should render properly', () => { - const colorScale = scaleLinear<string, string>().domain([0, 25, 50, 75, 100]).range(COLORS); - const wrapper = shallow( - <ColorGradientLegend - className="measure-details-treemap-legend" - colorScale={colorScale} - showColorNA={true} - height={20} - width={200} - /> - ); - expect(wrapper.dive()).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/charts/__tests__/DonutChart-test.tsx b/server/sonar-ui-common/components/charts/__tests__/DonutChart-test.tsx deleted file mode 100644 index a26593699ce..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/DonutChart-test.tsx +++ /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. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import DonutChart, { DonutChartProps } from '../DonutChart'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find('Sector').first().dive()).toMatchSnapshot(); -}); - -it('should render correctly with padding and pad angle too', () => { - expect(shallowRender({ padAngle: 0.1, padding: [2, 2, 2, 2] })).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<DonutChartProps> = {}) { - return shallow( - <DonutChart - data={[ - { fill: '#000000', value: 25 }, - { fill: '#ffffff', value: 75 }, - ]} - height={20} - thickness={2} - width={20} - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/charts/__tests__/Histogram-test.tsx b/server/sonar-ui-common/components/charts/__tests__/Histogram-test.tsx deleted file mode 100644 index 15f4754aae0..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/Histogram-test.tsx +++ /dev/null @@ -1,68 +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 Histogram from '../Histogram'; - -it('renders', () => { - expect(shallow(<Histogram bars={[100, 75, 150]} height={75} width={100} />)).toMatchSnapshot(); -}); - -it('renders with yValues', () => { - expect( - shallow( - <Histogram - bars={[100, 75, 150]} - height={75} - width={100} - yValues={['100.0', '75.0', '150.0']} - /> - ) - ).toMatchSnapshot(); -}); - -it('renders with yValues and yTicks', () => { - expect( - shallow( - <Histogram - bars={[100, 75, 150]} - height={75} - width={100} - yTicks={['a', 'b', 'c']} - yValues={['100.0', '75.0', '150.0']} - /> - ) - ).toMatchSnapshot(); -}); - -it('renders with yValues, yTicks and yTooltips', () => { - expect( - shallow( - <Histogram - bars={[100, 75, 150]} - height={75} - width={100} - yTicks={['a', 'b', 'c']} - yTooltips={['a - 100', 'b - 75', 'c - 150']} - yValues={['100.0', '75.0', '150.0']} - /> - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/charts/__tests__/LineChart-test.tsx b/server/sonar-ui-common/components/charts/__tests__/LineChart-test.tsx deleted file mode 100644 index b9c609ac202..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/LineChart-test.tsx +++ /dev/null @@ -1,54 +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 LineChart from '../LineChart'; - -it('should display line', () => { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 }, - ]; - const chart = shallow(<LineChart data={data} height={100} width={100} />); - expect(chart.find('.line-chart-path').length).toBe(1); -}); - -it('should display ticks', () => { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 }, - ]; - const ticks = ['A', 'B', 'C']; - const chart = shallow(<LineChart data={data} height={100} width={100} xTicks={ticks} />); - expect(chart.find('.line-chart-tick').length).toBe(3); -}); - -it('should display values', () => { - const data = [ - { x: 1, y: 10 }, - { x: 2, y: 30 }, - { x: 3, y: 20 }, - ]; - const values = ['A', 'B', 'C']; - const chart = shallow(<LineChart data={data} height={100} width={100} xValues={values} />); - expect(chart.find('.line-chart-tick').length).toBe(3); -}); diff --git a/server/sonar-ui-common/components/charts/__tests__/TreeMap-test.tsx b/server/sonar-ui-common/components/charts/__tests__/TreeMap-test.tsx deleted file mode 100644 index 8b951a9d215..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/TreeMap-test.tsx +++ /dev/null @@ -1,53 +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 TreeMap from '../TreeMap'; -import TreeMapRect from '../TreeMapRect'; - -it('should render correctly', () => { - const items = [ - { key: '1', size: 10, color: '#777', label: 'SonarQube :: Server' }, - { key: '2', size: 30, color: '#777', label: 'SonarQube :: Web' }, - { - key: '3', - size: 20, - gradient: '#777', - label: 'SonarQube :: Search', - metric: { key: 'coverage', type: 'PERCENT' }, - }, - ]; - const onRectClick = jest.fn(); - const chart = mount( - <TreeMap height={100} items={items} onRectangleClick={onRectClick} width={100} /> - ); - const rects = chart.find(TreeMapRect); - expect(rects).toHaveLength(3); - - const event: React.MouseEvent<HTMLAnchorElement> = { - stopPropagation: jest.fn(), - } as any; - - (rects.first().instance() as TreeMapRect).handleLinkClick(event); - expect(event.stopPropagation).toHaveBeenCalled(); - - (rects.first().instance() as TreeMapRect).handleRectClick(); - expect(onRectClick).toHaveBeenCalledWith('2'); -}); diff --git a/server/sonar-ui-common/components/charts/__tests__/ZoomTimeLine-test.tsx b/server/sonar-ui-common/components/charts/__tests__/ZoomTimeLine-test.tsx deleted file mode 100644 index 27f3b5c854e..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/ZoomTimeLine-test.tsx +++ /dev/null @@ -1,109 +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 { scaleTime } from 'd3-scale'; -import { shallow } from 'enzyme'; -import * as React from 'react'; -import testTheme from '../../../config/jest/testTheme'; -import ZoomTimeLine from '../ZoomTimeLine'; - -const series = [ - { - data: [ - { - x: new Date('2020-01-01'), - y: 'beginning', - }, - { - x: new Date('2020-02-01'), - y: 'end', - }, - ], - name: 'foo', - translatedName: 'foo-translated', - type: 'bar', - }, -]; - -it('should render correctly', () => { - expect(shallowRender({ width: undefined })).toMatchSnapshot('no width'); - expect(shallowRender({ height: undefined })).toMatchSnapshot('no height'); -}); - -it('should draw a graph with lines', () => { - const wrapper = shallowRender(); - expect(wrapper.find('.line-chart-grid').exists()).toBe(true); - expect(wrapper.find('.line-chart-path').exists()).toBe(true); - expect(wrapper.find('.chart-zoom-tick').exists()).toBe(true); - expect(wrapper.find('.line-chart-area').exists()).toBe(false); -}); - -it('should be zoomable', () => { - expect(shallowRender().find('.chart-zoom').exists()).toBe(true); -}); - -it('should render a leak period', () => { - expect( - shallowRender({ leakPeriodDate: new Date('2020-01-01') }) - .find('ContextConsumer') - .dive() - .find(`rect[fill="${testTheme.colors.leakPrimaryColor}"]`) - .exists() - ).toBe(true); -}); - -it('should render areas under the graph lines', () => { - expect(shallowRender({ showAreas: true }).find('.line-chart-area').exists()).toBe(true); -}); - -it('should handle zoom update correctly', () => { - const updateZoom = jest.fn(); - const startDate = new Date('1970-01-01T00:00:00.001Z'); - const endDate = new Date('2000-01-01T00:00:00.001Z'); - let wrapper = shallowRender({ updateZoom, startDate, endDate }); - wrapper - .instance() - .handleZoomUpdate(scaleTime().domain([startDate, endDate]).range([0, 150]), [3, 50]); - expect(updateZoom).toBeCalledWith( - new Date('1970-08-08T03:21:36.001Z'), - new Date('1980-01-01T08:00:00.001Z') - ); - - updateZoom.mockClear(); - - // We throttle the handleZoomUpdate so re-render to avoid issue - wrapper = shallowRender({ updateZoom, startDate, endDate }); - wrapper - .instance() - .handleZoomUpdate(scaleTime().domain([startDate, endDate]).range([0, 150]), [-1, 151]); - expect(updateZoom).toBeCalledWith(undefined, undefined); -}); - -function shallowRender(props: Partial<ZoomTimeLine['props']> = {}) { - return shallow<ZoomTimeLine>( - <ZoomTimeLine - width={300} - series={series} - updateZoom={jest.fn()} - metricType="RATING" - height={300} - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/AdvancedTimeline-test.tsx.snap b/server/sonar-ui-common/components/charts/__tests__/__snapshots__/AdvancedTimeline-test.tsx.snap deleted file mode 100644 index f4569f0f9fa..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/AdvancedTimeline-test.tsx.snap +++ /dev/null @@ -1,1409 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<svg - className="line-chart" - height={100} - width={100} -> - <g - transform="translate(60, 26)" - > - <g> - <g - key="0" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={24} - y2={24} - /> - </g> - <g - key="0.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={22.4} - y2={22.4} - /> - </g> - <g - key="0.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={20.8} - y2={20.8} - /> - </g> - <g - key="0.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={19.200000000000003} - y2={19.200000000000003} - /> - </g> - <g - key="0.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={17.6} - y2={17.6} - /> - </g> - <g - key="1" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={16} - y2={16} - /> - </g> - <g - key="1.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={14.400000000000002} - y2={14.400000000000002} - /> - </g> - <g - key="1.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={12.800000000000002} - y2={12.800000000000002} - /> - </g> - <g - key="1.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={11.2} - y2={11.2} - /> - </g> - <g - key="1.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={9.600000000000001} - y2={9.600000000000001} - /> - </g> - <g - key="2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={8} - y2={8} - /> - </g> - <g - key="2.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={6.399999999999999} - y2={6.399999999999999} - /> - </g> - <g - key="2.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={4.800000000000002} - y2={4.800000000000002} - /> - </g> - <g - key="2.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={3.1999999999999993} - y2={3.1999999999999993} - /> - </g> - <g - key="2.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={1.6000000000000023} - y2={1.6000000000000023} - /> - </g> - <g - key="3" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={0} - y2={0} - /> - </g> - </g> - <g - transform="translate(0, 20)" - > - <text - className="line-chart-tick" - key="0" - textAnchor="end" - transform="rotate(-35, 1.875, 24)" - x={1.875} - y={24} - > - October - </text> - <text - className="line-chart-tick" - key="1" - textAnchor="end" - transform="rotate(-35, 5.625, 24)" - x={5.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="2" - textAnchor="end" - transform="rotate(-35, 9.375, 24)" - x={9.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="3" - textAnchor="end" - transform="rotate(-35, 13.125, 24)" - x={13.125} - y={24} - > - 06 PM - </text> - <text - className="line-chart-tick" - key="4" - textAnchor="end" - transform="rotate(-35, 16.875, 24)" - x={16.875} - y={24} - > - Wed 02 - </text> - <text - className="line-chart-tick" - key="5" - textAnchor="end" - transform="rotate(-35, 20.625, 24)" - x={20.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="6" - textAnchor="end" - transform="rotate(-35, 24.375, 24)" - x={24.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="7" - textAnchor="end" - transform="rotate(-35, 28.125, 24)" - x={28.125} - y={24} - > - 06 PM - </text> - </g> - <g> - <path - className="line-chart-path line-chart-path-0" - d="M0,16L15,8" - key="test-1" - /> - <path - className="line-chart-path line-chart-path-1" - d="M30,0Z" - key="test-2" - /> - </g> - <g> - <circle - className="line-chart-dot line-chart-dot-1" - cx={30} - cy={0} - key="test-20" - r="2" - /> - </g> - <rect - className="chart-mouse-events-overlay" - height={24} - width={30} - /> - </g> -</svg> -`; - -exports[`should render correctly: Zoom enabled 1`] = ` -<svg - className="line-chart" - height={100} - width={100} -> - <defs> - <clipPath - id="chart-clip" - > - <rect - height={34} - transform="translate(0,-5)" - width={30} - /> - </clipPath> - </defs> - <g - transform="translate(60, 26)" - > - <g> - <g - key="0" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={24} - y2={24} - /> - </g> - <g - key="0.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={22.4} - y2={22.4} - /> - </g> - <g - key="0.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={20.8} - y2={20.8} - /> - </g> - <g - key="0.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={19.200000000000003} - y2={19.200000000000003} - /> - </g> - <g - key="0.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={17.6} - y2={17.6} - /> - </g> - <g - key="1" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={16} - y2={16} - /> - </g> - <g - key="1.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={14.400000000000002} - y2={14.400000000000002} - /> - </g> - <g - key="1.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={12.800000000000002} - y2={12.800000000000002} - /> - </g> - <g - key="1.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={11.2} - y2={11.2} - /> - </g> - <g - key="1.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={9.600000000000001} - y2={9.600000000000001} - /> - </g> - <g - key="2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={8} - y2={8} - /> - </g> - <g - key="2.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={6.399999999999999} - y2={6.399999999999999} - /> - </g> - <g - key="2.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={4.800000000000002} - y2={4.800000000000002} - /> - </g> - <g - key="2.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={3.1999999999999993} - y2={3.1999999999999993} - /> - </g> - <g - key="2.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={1.6000000000000023} - y2={1.6000000000000023} - /> - </g> - <g - key="3" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={0} - y2={0} - /> - </g> - </g> - <g - transform="translate(0, 20)" - > - <text - className="line-chart-tick" - key="0" - textAnchor="end" - transform="rotate(-35, 1.875, 24)" - x={1.875} - y={24} - > - October - </text> - <text - className="line-chart-tick" - key="1" - textAnchor="end" - transform="rotate(-35, 5.625, 24)" - x={5.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="2" - textAnchor="end" - transform="rotate(-35, 9.375, 24)" - x={9.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="3" - textAnchor="end" - transform="rotate(-35, 13.125, 24)" - x={13.125} - y={24} - > - 06 PM - </text> - <text - className="line-chart-tick" - key="4" - textAnchor="end" - transform="rotate(-35, 16.875, 24)" - x={16.875} - y={24} - > - Wed 02 - </text> - <text - className="line-chart-tick" - key="5" - textAnchor="end" - transform="rotate(-35, 20.625, 24)" - x={20.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="6" - textAnchor="end" - transform="rotate(-35, 24.375, 24)" - x={24.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="7" - textAnchor="end" - transform="rotate(-35, 28.125, 24)" - x={28.125} - y={24} - > - 06 PM - </text> - </g> - <g> - <path - className="line-chart-path line-chart-path-0" - d="M0,16L15,8" - key="test-1" - /> - <path - className="line-chart-path line-chart-path-1" - d="M30,0Z" - key="test-2" - /> - </g> - <g> - <circle - className="line-chart-dot line-chart-dot-1" - cx={30} - cy={0} - key="test-20" - r="2" - /> - </g> - <rect - className="chart-mouse-events-overlay" - height={24} - onWheel={[Function]} - width={30} - /> - </g> -</svg> -`; - -exports[`should render correctly: format y tick 1`] = ` -<svg - className="line-chart" - height={100} - width={100} -> - <g - transform="translate(60, 26)" - > - <g> - <g - key="0" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={24} - > - Nicer tick 0 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={24} - y2={24} - /> - </g> - <g - key="0.2" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={22.4} - > - Nicer tick 0.2 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={22.4} - y2={22.4} - /> - </g> - <g - key="0.4" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={20.8} - > - Nicer tick 0.4 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={20.8} - y2={20.8} - /> - </g> - <g - key="0.6" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={19.200000000000003} - > - Nicer tick 0.6 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={19.200000000000003} - y2={19.200000000000003} - /> - </g> - <g - key="0.8" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={17.6} - > - Nicer tick 0.8 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={17.6} - y2={17.6} - /> - </g> - <g - key="1" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={16} - > - Nicer tick 1 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={16} - y2={16} - /> - </g> - <g - key="1.2" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={14.400000000000002} - > - Nicer tick 1.2 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={14.400000000000002} - y2={14.400000000000002} - /> - </g> - <g - key="1.4" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={12.800000000000002} - > - Nicer tick 1.4 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={12.800000000000002} - y2={12.800000000000002} - /> - </g> - <g - key="1.6" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={11.2} - > - Nicer tick 1.6 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={11.2} - y2={11.2} - /> - </g> - <g - key="1.8" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={9.600000000000001} - > - Nicer tick 1.8 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={9.600000000000001} - y2={9.600000000000001} - /> - </g> - <g - key="2" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={8} - > - Nicer tick 2 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={8} - y2={8} - /> - </g> - <g - key="2.2" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={6.399999999999999} - > - Nicer tick 2.2 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={6.399999999999999} - y2={6.399999999999999} - /> - </g> - <g - key="2.4" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={4.800000000000002} - > - Nicer tick 2.4 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={4.800000000000002} - y2={4.800000000000002} - /> - </g> - <g - key="2.6" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={3.1999999999999993} - > - Nicer tick 2.6 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={3.1999999999999993} - y2={3.1999999999999993} - /> - </g> - <g - key="2.8" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={1.6000000000000023} - > - Nicer tick 2.8 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={1.6000000000000023} - y2={1.6000000000000023} - /> - </g> - <g - key="3" - > - <text - className="line-chart-tick line-chart-tick-x" - dx="-1em" - dy="0.3em" - textAnchor="end" - x={0} - y={0} - > - Nicer tick 3 - </text> - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={0} - y2={0} - /> - </g> - </g> - <g - transform="translate(0, 20)" - > - <text - className="line-chart-tick" - key="0" - textAnchor="end" - transform="rotate(-35, 1.875, 24)" - x={1.875} - y={24} - > - October - </text> - <text - className="line-chart-tick" - key="1" - textAnchor="end" - transform="rotate(-35, 5.625, 24)" - x={5.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="2" - textAnchor="end" - transform="rotate(-35, 9.375, 24)" - x={9.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="3" - textAnchor="end" - transform="rotate(-35, 13.125, 24)" - x={13.125} - y={24} - > - 06 PM - </text> - <text - className="line-chart-tick" - key="4" - textAnchor="end" - transform="rotate(-35, 16.875, 24)" - x={16.875} - y={24} - > - Wed 02 - </text> - <text - className="line-chart-tick" - key="5" - textAnchor="end" - transform="rotate(-35, 20.625, 24)" - x={20.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="6" - textAnchor="end" - transform="rotate(-35, 24.375, 24)" - x={24.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="7" - textAnchor="end" - transform="rotate(-35, 28.125, 24)" - x={28.125} - y={24} - > - 06 PM - </text> - </g> - <g> - <path - className="line-chart-path line-chart-path-0" - d="M0,16L15,8" - key="test-1" - /> - <path - className="line-chart-path line-chart-path-1" - d="M30,0Z" - key="test-2" - /> - </g> - <g> - <circle - className="line-chart-dot line-chart-dot-1" - cx={30} - cy={0} - key="test-20" - r="2" - /> - </g> - <rect - className="chart-mouse-events-overlay" - height={24} - width={30} - /> - </g> -</svg> -`; - -exports[`should render correctly: no areas 1`] = ` -<svg - className="line-chart" - height={100} - width={100} -> - <g - transform="translate(60, 26)" - > - <g> - <g - key="0" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={24} - y2={24} - /> - </g> - <g - key="0.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={22.4} - y2={22.4} - /> - </g> - <g - key="0.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={20.8} - y2={20.8} - /> - </g> - <g - key="0.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={19.200000000000003} - y2={19.200000000000003} - /> - </g> - <g - key="0.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={17.6} - y2={17.6} - /> - </g> - <g - key="1" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={16} - y2={16} - /> - </g> - <g - key="1.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={14.400000000000002} - y2={14.400000000000002} - /> - </g> - <g - key="1.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={12.800000000000002} - y2={12.800000000000002} - /> - </g> - <g - key="1.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={11.2} - y2={11.2} - /> - </g> - <g - key="1.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={9.600000000000001} - y2={9.600000000000001} - /> - </g> - <g - key="2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={8} - y2={8} - /> - </g> - <g - key="2.2" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={6.399999999999999} - y2={6.399999999999999} - /> - </g> - <g - key="2.4" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={4.800000000000002} - y2={4.800000000000002} - /> - </g> - <g - key="2.6" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={3.1999999999999993} - y2={3.1999999999999993} - /> - </g> - <g - key="2.8" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={1.6000000000000023} - y2={1.6000000000000023} - /> - </g> - <g - key="3" - > - <line - className="line-chart-grid" - x1={0} - x2={30} - y1={0} - y2={0} - /> - </g> - </g> - <g - transform="translate(0, 20)" - > - <text - className="line-chart-tick" - key="0" - textAnchor="end" - transform="rotate(-35, 1.875, 24)" - x={1.875} - y={24} - > - October - </text> - <text - className="line-chart-tick" - key="1" - textAnchor="end" - transform="rotate(-35, 5.625, 24)" - x={5.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="2" - textAnchor="end" - transform="rotate(-35, 9.375, 24)" - x={9.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="3" - textAnchor="end" - transform="rotate(-35, 13.125, 24)" - x={13.125} - y={24} - > - 06 PM - </text> - <text - className="line-chart-tick" - key="4" - textAnchor="end" - transform="rotate(-35, 16.875, 24)" - x={16.875} - y={24} - > - Wed 02 - </text> - <text - className="line-chart-tick" - key="5" - textAnchor="end" - transform="rotate(-35, 20.625, 24)" - x={20.625} - y={24} - > - 06 AM - </text> - <text - className="line-chart-tick" - key="6" - textAnchor="end" - transform="rotate(-35, 24.375, 24)" - x={24.375} - y={24} - > - 12 PM - </text> - <text - className="line-chart-tick" - key="7" - textAnchor="end" - transform="rotate(-35, 28.125, 24)" - x={28.125} - y={24} - > - 06 PM - </text> - </g> - <g> - <path - className="line-chart-path line-chart-path-0" - d="M0,16L15,8" - key="test-1" - /> - <path - className="line-chart-path line-chart-path-1" - d="M30,0Z" - key="test-2" - /> - </g> - <g> - <circle - className="line-chart-dot line-chart-dot-1" - cx={30} - cy={0} - key="test-20" - r="2" - /> - </g> - <rect - className="chart-mouse-events-overlay" - height={24} - width={30} - /> - </g> -</svg> -`; - -exports[`should render correctly: no height 1`] = `<div />`; - -exports[`should render correctly: no width 1`] = `<div />`; - -exports[`should render leak legend correctly 1`] = ` -<Fragment> - <rect - fill="#fbf3d5" - height={16} - width={15} - x={15} - y={-16} - /> - <text - className="new-code-legend" - textAnchor="start" - x={19} - y={-4} - > - new code - </text> - <rect - className="leak-chart-rect" - fill="#fbf3d5" - height={24} - width={15} - x={15} - y={0} - /> -</Fragment> -`; diff --git a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/BubbleChart-test.tsx.snap b/server/sonar-ui-common/components/charts/__tests__/__snapshots__/BubbleChart-test.tsx.snap deleted file mode 100644 index b0f69f95417..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/BubbleChart-test.tsx.snap +++ /dev/null @@ -1,187 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should display bubbles 1`] = ` -<Bubble - key="0" - r={45} - scale={1} - x={33.21428571428571} - y={70.07936507936509} -> - <Tooltip> - <g> - <circle - className="bubble-chart-bubble" - r={45} - style={ - Object { - "fill": undefined, - "stroke": undefined, - } - } - transform="translate(33.21428571428571, 70.07936507936509) scale(1)" - /> - </g> - </Tooltip> -</Bubble> -`; - -exports[`should display bubbles 2`] = ` -<Bubble - key="1" - r={33.57142857142858} - scale={1} - x={66.42857142857142} - y={33.57142857142858} -> - <Tooltip> - <g> - <circle - className="bubble-chart-bubble" - r={33.57142857142858} - style={ - Object { - "fill": undefined, - "stroke": undefined, - } - } - transform="translate(66.42857142857142, 33.57142857142858) scale(1)" - /> - </g> - </Tooltip> -</Bubble> -`; - -exports[`should render bubble links 1`] = ` -<Bubble - key="0" - link="foo" - r={45} - scale={1} - x={33.21428571428571} - y={70.07936507936509} -> - <Tooltip> - <g> - <Link - onlyActiveOnIndex={false} - style={Object {}} - to="foo" - > - <a - onClick={[Function]} - style={Object {}} - > - <circle - className="bubble-chart-bubble" - r={45} - style={ - Object { - "fill": undefined, - "stroke": undefined, - } - } - transform="translate(33.21428571428571, 70.07936507936509) scale(1)" - /> - </a> - </Link> - </g> - </Tooltip> -</Bubble> -`; - -exports[`should render bubble links 2`] = ` -<Bubble - key="1" - link="bar" - r={33.57142857142858} - scale={1} - x={66.42857142857142} - y={33.57142857142858} -> - <Tooltip> - <g> - <Link - onlyActiveOnIndex={false} - style={Object {}} - to="bar" - > - <a - onClick={[Function]} - style={Object {}} - > - <circle - className="bubble-chart-bubble" - r={33.57142857142858} - style={ - Object { - "fill": undefined, - "stroke": undefined, - } - } - transform="translate(66.42857142857142, 33.57142857142858) scale(1)" - /> - </a> - </Link> - </g> - </Tooltip> -</Bubble> -`; - -exports[`should render bubbles with click handlers 1`] = ` -<Bubble - data="foo" - key="0" - onClick={[MockFunction]} - r={45} - scale={1} - x={33.21428571428571} - y={70.07936507936509} -> - <Tooltip> - <g> - <circle - className="bubble-chart-bubble" - onClick={[Function]} - r={45} - style={ - Object { - "fill": undefined, - "stroke": undefined, - } - } - transform="translate(33.21428571428571, 70.07936507936509) scale(1)" - /> - </g> - </Tooltip> -</Bubble> -`; - -exports[`should render bubbles with click handlers 2`] = ` -<Bubble - data="bar" - key="1" - onClick={[MockFunction]} - r={33.57142857142858} - scale={1} - x={66.42857142857142} - y={33.57142857142858} -> - <Tooltip> - <g> - <circle - className="bubble-chart-bubble" - onClick={[Function]} - r={33.57142857142858} - style={ - Object { - "fill": undefined, - "stroke": undefined, - } - } - transform="translate(66.42857142857142, 33.57142857142858) scale(1)" - /> - </g> - </Tooltip> -</Bubble> -`; diff --git a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/ColorGradientLegend-test.tsx.snap b/server/sonar-ui-common/components/charts/__tests__/__snapshots__/ColorGradientLegend-test.tsx.snap deleted file mode 100644 index 0bbe8ee462d..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/ColorGradientLegend-test.tsx.snap +++ /dev/null @@ -1,220 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render properly 1`] = ` -<svg - className="measure-details-treemap-legend" - height={20} - width={200} -> - <defs> - <linearGradient - id="gradient-legend" - > - <stop - key="0" - offset={0} - stopColor="#00aa00" - /> - <stop - key="1" - offset={0.25} - stopColor="#b0d513" - /> - <stop - key="2" - offset={0.5} - stopColor="#eabe06" - /> - <stop - key="3" - offset={0.75} - stopColor="#ed7d20" - /> - <stop - key="4" - offset={1} - stopColor="#d4333f" - /> - </linearGradient> - <pattern - height="30" - id="stripes" - patternTransform="rotate(45 0 0)" - patternUnits="userSpaceOnUse" - width="30" - > - <line - style={ - Object { - "stroke": "#b4b4b4", - "strokeWidth": 4, - } - } - x1={0} - x2={0} - y1="0" - y2="30" - /> - <line - style={ - Object { - "stroke": "#999", - "strokeWidth": 4, - } - } - x1={4} - x2={4} - y1="0" - y2="30" - /> - <line - style={ - Object { - "stroke": "#b4b4b4", - "strokeWidth": 4, - } - } - x1={8} - x2={8} - y1="0" - y2="30" - /> - <line - style={ - Object { - "stroke": "#999", - "strokeWidth": 4, - } - } - x1={12} - x2={12} - y1="0" - y2="30" - /> - <line - style={ - Object { - "stroke": "#b4b4b4", - "strokeWidth": 4, - } - } - x1={16} - x2={16} - y1="0" - y2="30" - /> - <line - style={ - Object { - "stroke": "#999", - "strokeWidth": 4, - } - } - x1={20} - x2={20} - y1="0" - y2="30" - /> - <line - style={ - Object { - "stroke": "#b4b4b4", - "strokeWidth": 4, - } - } - x1={24} - x2={24} - y1="0" - y2="30" - /> - <line - style={ - Object { - "stroke": "#999", - "strokeWidth": 4, - } - } - x1={28} - x2={28} - y1="0" - y2="30" - /> - </pattern> - </defs> - <g - transform="translate(0, 12)" - > - <rect - fill="url(#gradient-legend)" - height={8} - width={176} - x={0} - y={0} - /> - <text - className="gradient-legend-text" - dy="-2px" - key="0" - x={0} - y={0} - > - 0 - </text> - <text - className="gradient-legend-text" - dy="-2px" - key="1" - x={44} - y={0} - > - 25 - </text> - <text - className="gradient-legend-text" - dy="-2px" - key="2" - x={88} - y={0} - > - 50 - </text> - <text - className="gradient-legend-text" - dy="-2px" - key="3" - x={132} - y={0} - > - 75 - </text> - <text - className="gradient-legend-text" - dy="-2px" - key="4" - x={176} - y={0} - > - 100 - </text> - </g> - <g - transform="translate(176, 12)" - > - <rect - fill="url(#stripes)" - height={8} - width={20} - x={4} - y={0} - /> - <text - className="gradient-legend-na" - dy="-2px" - x={14} - y={0} - > - N/A - </text> - </g> -</svg> -`; diff --git a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/DonutChart-test.tsx.snap b/server/sonar-ui-common/components/charts/__tests__/__snapshots__/DonutChart-test.tsx.snap deleted file mode 100644 index f4da702a0d2..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/DonutChart-test.tsx.snap +++ /dev/null @@ -1,122 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<svg - className="donut-chart" - height={20} - width={20} -> - <g - transform="translate(0, 0)" - > - <g - transform="translate(10, 10)" - > - <Sector - data={ - Object { - "data": Object { - "fill": "#000000", - "value": 25, - }, - "endAngle": 1.5707963267948968, - "index": 0, - "padAngle": 0, - "startAngle": 0, - "value": 25, - } - } - fill="#000000" - key="0" - radius={10} - thickness={2} - /> - <Sector - data={ - Object { - "data": Object { - "fill": "#ffffff", - "value": 75, - }, - "endAngle": 6.283185307179586, - "index": 1, - "padAngle": 0, - "startAngle": 1.5707963267948968, - "value": 75, - } - } - fill="#ffffff" - key="1" - radius={10} - thickness={2} - /> - </g> - </g> -</svg> -`; - -exports[`should render correctly 2`] = ` -<path - d="M6.123233995736766e-16,-10A10,10,0,0,1,10,2.220446049250313e-15L8,1.7763568394002505e-15A8,8,0,0,0,4.898587196589413e-16,-8Z" - style={ - Object { - "fill": "#000000", - } - } -/> -`; - -exports[`should render correctly with padding and pad angle too 1`] = ` -<svg - className="donut-chart" - height={20} - width={20} -> - <g - transform="translate(2, 2)" - > - <g - transform="translate(8, 8)" - > - <Sector - data={ - Object { - "data": Object { - "fill": "#000000", - "value": 25, - }, - "endAngle": 1.6207963267948966, - "index": 0, - "padAngle": 0.1, - "startAngle": 0, - "value": 25, - } - } - fill="#000000" - key="0" - radius={8} - thickness={2} - /> - <Sector - data={ - Object { - "data": Object { - "fill": "#ffffff", - "value": 75, - }, - "endAngle": 6.283185307179585, - "index": 1, - "padAngle": 0.1, - "startAngle": 1.6207963267948966, - "value": 75, - } - } - fill="#ffffff" - key="1" - radius={8} - thickness={2} - /> - </g> - </g> -</svg> -`; diff --git a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/Histogram-test.tsx.snap b/server/sonar-ui-common/components/charts/__tests__/__snapshots__/Histogram-test.tsx.snap deleted file mode 100644 index f52a4ea6cf3..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/Histogram-test.tsx.snap +++ /dev/null @@ -1,352 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` -<svg - className="bar-chart" - height={75} - width={100} -> - <g - transform="translate(10, 10)" - > - <g> - <g - key="0" - > - <rect - className="bar-chart-bar" - height={10} - width={54} - x={0} - y={10} - /> - </g> - <g - key="1" - > - <rect - className="bar-chart-bar" - height={10} - width={41} - x={0} - y={28} - /> - </g> - <g - key="2" - > - <rect - className="bar-chart-bar" - height={10} - width={81} - x={0} - y={46} - /> - </g> - </g> - </g> -</svg> -`; - -exports[`renders with yValues 1`] = ` -<svg - className="bar-chart" - height={75} - width={100} -> - <g - transform="translate(10, 10)" - > - <g> - <g - key="0" - > - <rect - className="bar-chart-bar" - height={10} - width={54} - x={0} - y={10} - /> - <Tooltip> - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={53.33333333333333} - y={15} - > - 100.0 - </text> - </Tooltip> - </g> - <g - key="1" - > - <rect - className="bar-chart-bar" - height={10} - width={41} - x={0} - y={28} - /> - <Tooltip> - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={40} - y={33} - > - 75.0 - </text> - </Tooltip> - </g> - <g - key="2" - > - <rect - className="bar-chart-bar" - height={10} - width={81} - x={0} - y={46} - /> - <Tooltip> - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={80} - y={51} - > - 150.0 - </text> - </Tooltip> - </g> - </g> - </g> -</svg> -`; - -exports[`renders with yValues and yTicks 1`] = ` -<svg - className="bar-chart" - height={75} - width={100} -> - <g - transform="translate(10, 10)" - > - <g> - <g - key="0" - > - <rect - className="bar-chart-bar" - height={10} - width={54} - x={0} - y={10} - /> - <Tooltip> - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={53.33333333333333} - y={15} - > - 100.0 - </text> - </Tooltip> - <text - className="bar-chart-tick histogram-tick" - dx="-1em" - dy="0.3em" - x={0} - y={15} - > - a - </text> - </g> - <g - key="1" - > - <rect - className="bar-chart-bar" - height={10} - width={41} - x={0} - y={28} - /> - <Tooltip> - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={40} - y={33} - > - 75.0 - </text> - </Tooltip> - <text - className="bar-chart-tick histogram-tick" - dx="-1em" - dy="0.3em" - x={0} - y={33} - > - b - </text> - </g> - <g - key="2" - > - <rect - className="bar-chart-bar" - height={10} - width={81} - x={0} - y={46} - /> - <Tooltip> - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={80} - y={51} - > - 150.0 - </text> - </Tooltip> - <text - className="bar-chart-tick histogram-tick" - dx="-1em" - dy="0.3em" - x={0} - y={51} - > - c - </text> - </g> - </g> - </g> -</svg> -`; - -exports[`renders with yValues, yTicks and yTooltips 1`] = ` -<svg - className="bar-chart" - height={75} - width={100} -> - <g - transform="translate(10, 10)" - > - <g> - <g - key="0" - > - <rect - className="bar-chart-bar" - height={10} - width={54} - x={0} - y={10} - /> - <Tooltip - overlay="a - 100" - > - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={53.33333333333333} - y={15} - > - 100.0 - </text> - </Tooltip> - <text - className="bar-chart-tick histogram-tick" - dx="-1em" - dy="0.3em" - x={0} - y={15} - > - a - </text> - </g> - <g - key="1" - > - <rect - className="bar-chart-bar" - height={10} - width={41} - x={0} - y={28} - /> - <Tooltip - overlay="b - 75" - > - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={40} - y={33} - > - 75.0 - </text> - </Tooltip> - <text - className="bar-chart-tick histogram-tick" - dx="-1em" - dy="0.3em" - x={0} - y={33} - > - b - </text> - </g> - <g - key="2" - > - <rect - className="bar-chart-bar" - height={10} - width={81} - x={0} - y={46} - /> - <Tooltip - overlay="c - 150" - > - <text - className="bar-chart-tick histogram-value" - dx="1em" - dy="0.3em" - x={80} - y={51} - > - 150.0 - </text> - </Tooltip> - <text - className="bar-chart-tick histogram-tick" - dx="-1em" - dy="0.3em" - x={0} - y={51} - > - c - </text> - </g> - </g> - </g> -</svg> -`; diff --git a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/ZoomTimeLine-test.tsx.snap b/server/sonar-ui-common/components/charts/__tests__/__snapshots__/ZoomTimeLine-test.tsx.snap deleted file mode 100644 index adb3c28e914..00000000000 --- a/server/sonar-ui-common/components/charts/__tests__/__snapshots__/ZoomTimeLine-test.tsx.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: no height 1`] = `<div />`; - -exports[`should render correctly: no width 1`] = `<div />`; diff --git a/server/sonar-ui-common/components/controls/ActionsDropdown.tsx b/server/sonar-ui-common/components/controls/ActionsDropdown.tsx deleted file mode 100644 index e4de6ff3baa..00000000000 --- a/server/sonar-ui-common/components/controls/ActionsDropdown.tsx +++ /dev/null @@ -1,138 +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 { LocationDescriptor } from 'history'; -import * as React from 'react'; -import { Link } from 'react-router'; -import { translate } from '../../helpers/l10n'; -import DropdownIcon from '../icons/DropdownIcon'; -import SettingsIcon from '../icons/SettingsIcon'; -import { PopupPlacement } from '../ui/popups'; -import { Button } from './buttons'; -import { ClipboardBase } from './clipboard'; -import Dropdown from './Dropdown'; -import Tooltip from './Tooltip'; - -export interface ActionsDropdownProps { - className?: string; - children: React.ReactNode; - onOpen?: () => void; - overlayPlacement?: PopupPlacement; - small?: boolean; - toggleClassName?: string; -} - -export default function ActionsDropdown(props: ActionsDropdownProps) { - const { children, className, overlayPlacement, small, toggleClassName } = props; - return ( - <Dropdown - className={className} - onOpen={props.onOpen} - overlay={<ul className="menu">{children}</ul>} - overlayPlacement={overlayPlacement}> - <Button - className={classNames('dropdown-toggle', toggleClassName, { - 'button-small': small, - })}> - <SettingsIcon size={small ? 12 : 14} /> - <DropdownIcon className="little-spacer-left" /> - </Button> - </Dropdown> - ); -} - -interface ItemProps { - className?: string; - children: React.ReactNode; - /** used to pass a string to copy to clipboard */ - copyValue?: string; - destructive?: boolean; - /** used to pass a name of downloaded file */ - download?: string; - id?: string; - onClick?: () => void; - to?: LocationDescriptor; -} - -export class ActionsDropdownItem extends React.PureComponent<ItemProps> { - handleClick = (event: React.SyntheticEvent<HTMLAnchorElement>) => { - event.preventDefault(); - event.currentTarget.blur(); - if (this.props.onClick) { - this.props.onClick(); - } - }; - - render() { - const className = classNames(this.props.className, { 'text-danger': this.props.destructive }); - - if (this.props.download && typeof this.props.to === 'string') { - return ( - <li> - <a - className={className} - download={this.props.download} - href={this.props.to} - id={this.props.id}> - {this.props.children} - </a> - </li> - ); - } - - if (this.props.to) { - return ( - <li> - <Link className={className} id={this.props.id} to={this.props.to}> - {this.props.children} - </Link> - </li> - ); - } - - if (this.props.copyValue) { - return ( - <ClipboardBase> - {({ setCopyButton, copySuccess }) => ( - <Tooltip overlay={translate('copied_action')} visible={copySuccess}> - <li data-clipboard-text={this.props.copyValue} ref={setCopyButton}> - <a className={className} href="#" id={this.props.id} onClick={this.handleClick}> - {this.props.children} - </a> - </li> - </Tooltip> - )} - </ClipboardBase> - ); - } - - return ( - <li> - <a className={className} href="#" id={this.props.id} onClick={this.handleClick}> - {this.props.children} - </a> - </li> - ); - } -} - -export function ActionsDropdownDivider() { - return <li className="divider" />; -} diff --git a/server/sonar-ui-common/components/controls/BackButton.tsx b/server/sonar-ui-common/components/controls/BackButton.tsx deleted file mode 100644 index 0022b4f322e..00000000000 --- a/server/sonar-ui-common/components/controls/BackButton.tsx +++ /dev/null @@ -1,72 +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 { ThemeConsumer } from '../theme'; -import Tooltip from './Tooltip'; - -interface Props { - className?: string; - disabled?: boolean; - onClick: () => void; - tooltip?: string; -} - -export default class BackButton extends React.PureComponent<Props> { - handleClick = (event: React.SyntheticEvent<HTMLAnchorElement>) => { - event.preventDefault(); - event.currentTarget.blur(); - if (!this.props.disabled) { - this.props.onClick(); - } - }; - - renderIcon = () => ( - <ThemeConsumer> - {(theme) => ( - <svg height="24" viewBox="0 0 21 24" width="21"> - <path - d="M3.845 12.9992l5.993 5.993.052.056c.049.061.093.122.129.191.082.159.121.339.111.518-.006.102-.028.203-.064.298-.149.39-.537.652-.954.644-.102-.002-.204-.019-.301-.052-.148-.05-.273-.135-.387-.241l-8.407-8.407 8.407-8.407.056-.052c.061-.048.121-.092.19-.128.116-.06.237-.091.366-.108.076-.004.075-.004.153-.003.155.015.3.052.437.129.088.051.169.115.239.19.246.266.33.656.214.999-.051.149-.135.273-.241.387l-5.983 5.984c5.287-.044 10.577-.206 15.859.013.073.009.091.009.163.027.187.047.359.15.49.292.075.081.136.175.18.276.044.101.072.209.081.319.032.391-.175.775-.521.962-.097.052-.202.089-.311.107-.073.012-.091.01-.165.013H3.845z" - fill={this.props.disabled ? theme.colors.disableGrayText : theme.colors.secondFontColor} - /> - </svg> - )} - </ThemeConsumer> - ); - - render() { - const { tooltip = translate('issues.return_to_list') } = this.props; - return ( - <Tooltip overlay={tooltip}> - <a - className={classNames( - 'link-no-underline', - { 'cursor-not-allowed': this.props.disabled }, - this.props.className - )} - href="#" - onClick={this.handleClick}> - {this.renderIcon()} - </a> - </Tooltip> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/BoxedGroupAccordion.tsx b/server/sonar-ui-common/components/controls/BoxedGroupAccordion.tsx deleted file mode 100644 index ce713c7c9c1..00000000000 --- a/server/sonar-ui-common/components/controls/BoxedGroupAccordion.tsx +++ /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. - */ -import * as classNames from 'classnames'; -import * as React from 'react'; -import OpenCloseIcon from '../icons/OpenCloseIcon'; - -interface Props { - children: React.ReactNode; - className?: string; - data?: string; - onClick: (data?: string) => void; - open: boolean; - renderHeader?: () => React.ReactNode; - title: React.ReactNode; -} - -interface State { - hoveringInner: boolean; -} - -export default class BoxedGroupAccordion extends React.PureComponent<Props, State> { - state: State = { hoveringInner: false }; - - handleClick = () => { - this.props.onClick(this.props.data); - }; - - onDetailEnter = () => { - this.setState({ hoveringInner: true }); - }; - - onDetailLeave = () => { - this.setState({ hoveringInner: false }); - }; - - render() { - const { className, open, renderHeader, title } = this.props; - return ( - <div - className={classNames('boxed-group boxed-group-accordion', className, { - 'no-hover': this.state.hoveringInner, - })}> - <div className="boxed-group-header" onClick={this.handleClick} role="listitem"> - <span className="boxed-group-accordion-title"> - <OpenCloseIcon className="little-spacer-right" open={open} /> - {title} - </span> - {renderHeader && renderHeader()} - </div> - {open && ( - <div - className="boxed-group-inner" - onMouseEnter={this.onDetailEnter} - onMouseLeave={this.onDetailLeave}> - {this.props.children} - </div> - )} - </div> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/BoxedTabs.tsx b/server/sonar-ui-common/components/controls/BoxedTabs.tsx deleted file mode 100644 index 976cb63f348..00000000000 --- a/server/sonar-ui-common/components/controls/BoxedTabs.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 React from 'react'; -import { styled, themeColor, ThemedProps, themeSize } from '../theme'; - -export interface BoxedTabsProps<K> { - className?: string; - onSelect: (key: K) => void; - selected?: K; - tabs: Array<{ key: K; label: React.ReactNode }>; -} - -const TabContainer = styled.div` - display: flex; - flex-direction: row; -`; - -const baseBorder = ({ theme }: ThemedProps) => `1px solid ${theme.colors.barBorderColor}`; - -const highlightHoverMixin = ({ theme }: ThemedProps) => ` - &:hover { - background-color: ${theme.colors.barBackgroundColorHighlight}; - } -`; - -const StyledTab = styled.button<{ active: boolean }>` - position: relative; - background-color: ${(props) => (props.active ? 'white' : props.theme.colors.barBackgroundColor)}; - border-top: ${baseBorder}; - border-left: ${baseBorder}; - border-right: none; - border-bottom: none; - margin-bottom: -1px; - min-width: 128px; - min-height: 56px; - ${(props) => !props.active && 'cursor: pointer;'} - outline: 0; - padding: calc(2 * ${themeSize('gridSize')}); - - ${(props) => (!props.active ? highlightHoverMixin : null)} - - &:last-child { - border-right: ${baseBorder}; - } -`; - -const ActiveBorder = styled.div<{ active: boolean }>` - display: ${(props) => (props.active ? 'block' : 'none')}; - background-color: ${themeColor('blue')}; - height: 3px; - width: 100%; - position: absolute; - left: 0; - top: -1px; -`; - -export default function BoxedTabs<K>(props: BoxedTabsProps<K>) { - const { className, tabs, selected } = props; - - return ( - <TabContainer className={className}> - {tabs.map(({ key, label }, i) => ( - <StyledTab - active={selected === key} - key={i} - onClick={() => selected !== key && props.onSelect(key)} - type="button"> - <ActiveBorder active={selected === key} /> - {label} - </StyledTab> - ))} - </TabContainer> - ); -} diff --git a/server/sonar-ui-common/components/controls/Checkbox.css b/server/sonar-ui-common/components/controls/Checkbox.css deleted file mode 100644 index 6306f855eb6..00000000000 --- a/server/sonar-ui-common/components/controls/Checkbox.css +++ /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. - */ -.icon-checkbox { - display: inline-block; - line-height: 1; - vertical-align: top; - padding: 1px 2px; - box-sizing: border-box; -} - -a.icon-checkbox { - border-bottom: none; -} - -.icon-checkbox:focus { - outline: none; -} - -.icon-checkbox:before { - content: ' '; - display: inline-block; - width: 10px; - height: 10px; - border: 1px solid var(--darkBlue); - border-radius: 2px; - transition: border-color 0.2s ease, background-color 0.2s ease, background-image 0.2s ease, - box-shadow 0.4s ease; -} - -.icon-checkbox:not(.icon-checkbox-disabled):focus:before, -.link-checkbox:not(.disabled):focus:focus .icon-checkbox:before { - box-shadow: 0 0 0 3px rgba(35, 106, 151, 0.25); -} - -.icon-checkbox-checked:before { - background-color: var(--blue); - background-image: url('data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2014%2014%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20stroke-linejoin%3D%22round%22%20stroke-miterlimit%3D%221.414%22%3E%3Cpath%20d%3D%22M12%204.665c0%20.172-.06.318-.18.438l-5.55%205.55c-.12.12-.266.18-.438.18s-.318-.06-.438-.18L2.18%207.438C2.06%207.317%202%207.17%202%207s.06-.318.18-.44l.878-.876c.12-.12.267-.18.44-.18.17%200%20.317.06.437.18l1.897%201.903%204.233-4.24c.12-.12.266-.18.438-.18s.32.06.44.18l.876.88c.12.12.18.265.18.438z%22%20fill%3D%22%23fff%22%20fill-rule%3D%22nonzero%22%2F%3E%3C%2Fsvg%3E'); - border-color: var(--blue); -} - -.icon-checkbox-checked.icon-checkbox-single:before { - background-image: url('data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2014%2014%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20stroke-linejoin%3D%22round%22%20stroke-miterlimit%3D%221.414%22%3E%3Cpath%20d%3D%22M10%204.698C10%204.312%209.688%204%209.302%204H4.698C4.312%204%204%204.312%204%204.698v4.604c0%20.386.312.698.698.698h4.604c.386%200%20.698-.312.698-.698V4.698z%22%20fill%3D%22%23fff%22%2F%3E%3C%2Fsvg%3E'); -} - -.icon-checkbox-disabled:before { - border: 1px solid var(--disableGrayText); - cursor: not-allowed; -} - -.icon-checkbox-disabled.icon-checkbox-checked:before { - background-color: var(--disableGrayText); -} - -.icon-checkbox-invisible { - visibility: hidden; -} - -.link-checkbox { - color: inherit; - border-bottom: none; -} - -.link-checkbox.disabled, -.link-checkbox.disabled:hover, -.link-checkbox.disabled label { - color: var(--secondFontColor); - cursor: not-allowed; -} - -.link-checkbox:hover, -.link-checkbox:active, -.link-checkbox:focus { - color: inherit; -} diff --git a/server/sonar-ui-common/components/controls/Checkbox.tsx b/server/sonar-ui-common/components/controls/Checkbox.tsx deleted file mode 100644 index 1526eb501fc..00000000000 --- a/server/sonar-ui-common/components/controls/Checkbox.tsx +++ /dev/null @@ -1,97 +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 from '../ui/DeferredSpinner'; -import './Checkbox.css'; - -interface Props { - checked: boolean; - disabled?: boolean; - children?: React.ReactNode; - className?: string; - id?: string; - loading?: boolean; - onCheck: (checked: boolean, id?: string) => void; - right?: boolean; - thirdState?: boolean; - title?: string; -} - -export default class Checkbox extends React.PureComponent<Props> { - static defaultProps = { - thirdState: false, - }; - - handleClick = (event: React.SyntheticEvent<HTMLElement>) => { - event.preventDefault(); - event.currentTarget.blur(); - if (!this.props.disabled) { - this.props.onCheck(!this.props.checked, this.props.id); - } - }; - - render() { - const { checked, children, disabled, id, loading, right, thirdState, title } = this.props; - const className = classNames('icon-checkbox', { - 'icon-checkbox-checked': checked, - 'icon-checkbox-single': thirdState, - 'icon-checkbox-disabled': disabled, - }); - - if (children) { - return ( - <a - aria-checked={checked} - className={classNames('link-checkbox', this.props.className, { - note: disabled, - disabled, - })} - href="#" - id={id} - onClick={this.handleClick} - role="checkbox" - title={title}> - {right && children} - <DeferredSpinner loading={Boolean(loading)}> - <i className={className} /> - </DeferredSpinner> - {!right && children} - </a> - ); - } - - if (loading) { - return <DeferredSpinner />; - } - - return ( - <a - aria-checked={checked} - className={classNames(className, this.props.className)} - href="#" - id={id} - onClick={this.handleClick} - role="checkbox" - title={title} - /> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/ClickEventBoundary.tsx b/server/sonar-ui-common/components/controls/ClickEventBoundary.tsx deleted file mode 100644 index 64891b31b47..00000000000 --- a/server/sonar-ui-common/components/controls/ClickEventBoundary.tsx +++ /dev/null @@ -1,35 +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'; - -export interface ClickEventBoundaryProps { - children: React.ReactElement; -} - -export default function ClickEventBoundary({ children }: ClickEventBoundaryProps) { - return React.cloneElement(children, { - onClick: (e: React.SyntheticEvent<MouseEvent>) => { - e.stopPropagation(); - if (typeof children.props.onClick === 'function') { - children.props.onClick(e); - } - }, - }); -} diff --git a/server/sonar-ui-common/components/controls/ConfirmButton.tsx b/server/sonar-ui-common/components/controls/ConfirmButton.tsx deleted file mode 100644 index 9ab6717f2b7..00000000000 --- a/server/sonar-ui-common/components/controls/ConfirmButton.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 * as React from 'react'; -import ConfirmModal, { ConfirmModalProps } from './ConfirmModal'; -import ModalButton, { ChildrenProps, ModalProps } from './ModalButton'; - -interface Props<T> extends ConfirmModalProps<T> { - children: (props: ChildrenProps) => React.ReactNode; - modalBody: React.ReactNode; - modalHeader: string; - modalHeaderDescription?: React.ReactNode; -} - -interface State { - modal: boolean; -} - -export default class ConfirmButton<T> extends React.PureComponent<Props<T>, State> { - renderConfirmModal = ({ onClose }: ModalProps) => { - const { - children, - modalBody, - modalHeader, - modalHeaderDescription, - ...confirmModalProps - } = this.props; - return ( - <ConfirmModal - header={modalHeader} - headerDescription={modalHeaderDescription} - onClose={onClose} - {...confirmModalProps}> - {modalBody} - </ConfirmModal> - ); - }; - - render() { - return <ModalButton modal={this.renderConfirmModal}>{this.props.children}</ModalButton>; - } -} diff --git a/server/sonar-ui-common/components/controls/ConfirmModal.tsx b/server/sonar-ui-common/components/controls/ConfirmModal.tsx deleted file mode 100644 index 44a4010beb7..00000000000 --- a/server/sonar-ui-common/components/controls/ConfirmModal.tsx +++ /dev/null @@ -1,108 +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 DeferredSpinner from '../ui/DeferredSpinner'; -import { ResetButtonLink, SubmitButton } from './buttons'; -import ClickEventBoundary from './ClickEventBoundary'; -import { ModalProps } from './Modal'; -import SimpleModal, { ChildrenProps } from './SimpleModal'; - -export interface ConfirmModalProps<T> extends ModalProps { - cancelButtonText?: string; - confirmButtonText: string; - confirmData?: T; - confirmDisable?: boolean; - isDestructive?: boolean; - onConfirm: (data?: T) => void | Promise<void | Response>; -} - -interface Props<T> extends ConfirmModalProps<T> { - header: string; - headerDescription?: React.ReactNode; - onClose: () => void; -} - -export default class ConfirmModal<T = string> extends React.PureComponent<Props<T>> { - mounted = false; - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - handleSubmit = () => { - const result = this.props.onConfirm(this.props.confirmData); - if (result) { - return result.then(this.props.onClose, () => {}); - } else { - this.props.onClose(); - return undefined; - } - }; - - renderModalContent = ({ onCloseClick, onFormSubmit, submitting }: ChildrenProps) => { - const { - children, - confirmButtonText, - confirmDisable, - header, - headerDescription, - isDestructive, - cancelButtonText = translate('cancel'), - } = this.props; - return ( - <ClickEventBoundary> - <form onSubmit={onFormSubmit}> - <header className="modal-head"> - <h2>{header}</h2> - {headerDescription} - </header> - <div className="modal-body">{children}</div> - <footer className="modal-foot"> - <DeferredSpinner className="spacer-right" loading={submitting} /> - <SubmitButton - autoFocus={true} - className={isDestructive ? 'button-red' : undefined} - disabled={submitting || confirmDisable}> - {confirmButtonText} - </SubmitButton> - <ResetButtonLink disabled={submitting} onClick={onCloseClick}> - {cancelButtonText} - </ResetButtonLink> - </footer> - </form> - </ClickEventBoundary> - ); - }; - - render() { - const { header, onClose, noBackdrop, size } = this.props; - const modalProps = { header, onClose, noBackdrop, size }; - return ( - <SimpleModal onSubmit={this.handleSubmit} {...modalProps}> - {this.renderModalContent} - </SimpleModal> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/DocumentClickHandler.tsx b/server/sonar-ui-common/components/controls/DocumentClickHandler.tsx deleted file mode 100644 index 45765c95874..00000000000 --- a/server/sonar-ui-common/components/controls/DocumentClickHandler.tsx +++ /dev/null @@ -1,53 +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'; - -interface Props { - children: React.ReactNode; - onClick: () => void; -} - -export default class DocumentClickHandler extends React.Component<Props> { - componentDidMount() { - setTimeout(() => { - this.addClickHandler(); - }, 0); - } - - componentWillUnmount() { - this.removeClickHandler(); - } - - addClickHandler = () => { - document.addEventListener('click', this.handleDocumentClick); - }; - - removeClickHandler = () => { - document.removeEventListener('click', this.handleDocumentClick); - }; - - handleDocumentClick = () => { - this.props.onClick(); - }; - - render() { - return this.props.children; - } -} diff --git a/server/sonar-ui-common/components/controls/Dropdown.css b/server/sonar-ui-common/components/controls/Dropdown.css deleted file mode 100644 index 41b7bd79b15..00000000000 --- a/server/sonar-ui-common/components/controls/Dropdown.css +++ /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. - */ -.dropdown { - position: relative; - display: inline-block; - vertical-align: middle; -} - -.dropdown-bottom-hint { - line-height: 16px; - margin-bottom: -5px; - padding: 5px 10px; - border-top: 1px solid var(--barBorderColor); - background-color: var(--barBackgroundColor); - color: var(--secondFontColor); - font-size: 11px; -} diff --git a/server/sonar-ui-common/components/controls/Dropdown.tsx b/server/sonar-ui-common/components/controls/Dropdown.tsx deleted file mode 100644 index 89b5733cf9a..00000000000 --- a/server/sonar-ui-common/components/controls/Dropdown.tsx +++ /dev/null @@ -1,160 +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 { Popup, PopupPlacement } from '../ui/popups'; -import './Dropdown.css'; -import ScreenPositionFixer from './ScreenPositionFixer'; -import Toggler from './Toggler'; - -interface OnClickCallback { - (event?: React.SyntheticEvent<HTMLElement>): void; -} - -interface RenderProps { - closeDropdown: () => void; - onToggleClick: OnClickCallback; - open: boolean; -} - -interface Props { - children: - | ((renderProps: RenderProps) => JSX.Element) - | React.ReactElement<{ onClick: OnClickCallback }>; - className?: string; - closeOnClick?: boolean; - closeOnClickOutside?: boolean; - onOpen?: () => void; - overlay: React.ReactNode; - overlayPlacement?: PopupPlacement; - noOverlayPadding?: boolean; - tagName?: string; -} - -interface State { - open: boolean; -} - -export default class Dropdown extends React.PureComponent<Props, State> { - state: State = { open: false }; - - componentDidUpdate(_: Props, prevState: State) { - if (!prevState.open && this.state.open && this.props.onOpen) { - this.props.onOpen(); - } - } - - closeDropdown = () => this.setState({ open: false }); - - handleToggleClick = (event?: React.SyntheticEvent<HTMLElement>) => { - if (event) { - event.preventDefault(); - event.currentTarget.blur(); - } - this.setState((state) => ({ open: !state.open })); - }; - - render() { - const a11yAttrs = { - 'aria-expanded': String(this.state.open), - 'aria-haspopup': 'true', - }; - - const child = React.isValidElement(this.props.children) - ? React.cloneElement(this.props.children, { onClick: this.handleToggleClick, ...a11yAttrs }) - : this.props.children({ - closeDropdown: this.closeDropdown, - onToggleClick: this.handleToggleClick, - open: this.state.open, - }); - - const { closeOnClick = true, closeOnClickOutside = false } = this.props; - - const toggler = ( - <Toggler - closeOnClick={closeOnClick} - closeOnClickOutside={closeOnClickOutside} - onRequestClose={this.closeDropdown} - open={this.state.open} - overlay={ - <DropdownOverlay - noPadding={this.props.noOverlayPadding} - placement={this.props.overlayPlacement}> - {this.props.overlay} - </DropdownOverlay> - }> - {child} - </Toggler> - ); - - return React.createElement( - this.props.tagName || 'div', - { className: classNames('dropdown', this.props.className) }, - toggler - ); - } -} - -interface OverlayProps { - className?: string; - children: React.ReactNode; - noPadding?: boolean; - placement?: PopupPlacement; -} - -// TODO use the same styling for <Select /> -// TODO use the same styling for <DateInput /> - -export class DropdownOverlay extends React.Component<OverlayProps> { - get placement() { - return this.props.placement || PopupPlacement.Bottom; - } - - renderPopup = (leftFix?: number, topFix?: number) => ( - <Popup - arrowStyle={ - leftFix !== undefined && topFix !== undefined - ? { transform: `translate(${-leftFix}px, ${-topFix}px)` } - : undefined - } - className={this.props.className} - noPadding={this.props.noPadding} - placement={this.placement} - style={ - leftFix !== undefined && topFix !== undefined - ? { marginLeft: `calc(50% + ${leftFix}px)` } - : undefined - }> - {this.props.children} - </Popup> - ); - - render() { - if (this.placement === PopupPlacement.Bottom) { - return ( - <ScreenPositionFixer> - {({ leftFix, topFix }) => this.renderPopup(leftFix, topFix)} - </ScreenPositionFixer> - ); - } else { - return this.renderPopup(); - } - } -} diff --git a/server/sonar-ui-common/components/controls/EscKeydownHandler.tsx b/server/sonar-ui-common/components/controls/EscKeydownHandler.tsx deleted file mode 100644 index 487bf13a6af..00000000000 --- a/server/sonar-ui-common/components/controls/EscKeydownHandler.tsx +++ /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. - */ -import * as React from 'react'; -import { KeyCodes } from '../../helpers/keycodes'; - -interface Props { - children: React.ReactNode; - onKeydown: () => void; -} - -export default class EscKeydownHandler extends React.Component<Props> { - componentDidMount() { - setTimeout(() => { - document.addEventListener('keydown', this.handleKeyDown, false); - }, 0); - } - - componentWillUnmount() { - document.removeEventListener('keydown', this.handleKeyDown, false); - } - - handleKeyDown = (event: KeyboardEvent) => { - if (event.keyCode === KeyCodes.Escape) { - this.props.onKeydown(); - } - }; - - render() { - return this.props.children; - } -} diff --git a/server/sonar-ui-common/components/controls/FavoriteButton.tsx b/server/sonar-ui-common/components/controls/FavoriteButton.tsx deleted file mode 100644 index e3727dd338a..00000000000 --- a/server/sonar-ui-common/components/controls/FavoriteButton.tsx +++ /dev/null @@ -1,53 +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 FavoriteIcon from '../icons/FavoriteIcon'; -import { ButtonLink } from './buttons'; -import Tooltip from './Tooltip'; - -export interface Props { - className?: string; - favorite: boolean; - qualifier: string; - toggleFavorite: () => void; -} - -export default class FavoriteButton extends React.PureComponent<Props> { - render() { - const { className, favorite, qualifier, toggleFavorite } = this.props; - const tooltip = favorite - ? translate('favorite.current', qualifier) - : translate('favorite.check', qualifier); - const ariaLabel = translate('favorite.action', favorite ? 'remove' : 'add'); - - return ( - <Tooltip overlay={tooltip}> - <ButtonLink - aria-label={ariaLabel} - className={classNames('favorite-link', 'link-no-underline', className)} - onClick={toggleFavorite}> - <FavoriteIcon favorite={favorite} /> - </ButtonLink> - </Tooltip> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/GlobalMessages.tsx b/server/sonar-ui-common/components/controls/GlobalMessages.tsx deleted file mode 100644 index d59f8d131e8..00000000000 --- a/server/sonar-ui-common/components/controls/GlobalMessages.tsx +++ /dev/null @@ -1,124 +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 { keyframes } from '@emotion/core'; -import * as React from 'react'; -import { cutLongWords } from '../../helpers/path'; -import { styled, themeGet, themeSize } from '../theme'; -import { ClearButton } from './buttons'; - -interface Message { - id: string; - level: 'ERROR' | 'SUCCESS'; - message: string; -} - -export interface GlobalMessagesProps { - closeGlobalMessage: (id: string) => void; - messages: Message[]; -} - -export default function GlobalMessages({ closeGlobalMessage, messages }: GlobalMessagesProps) { - if (messages.length === 0) { - return null; - } - - return ( - <MessagesContainer> - {messages.map((message) => ( - <GlobalMessage closeGlobalMessage={closeGlobalMessage} key={message.id} message={message} /> - ))} - </MessagesContainer> - ); -} - -const MessagesContainer = styled.div` - position: fixed; - z-index: ${themeGet('zIndexes', 'processContainerZIndex')}; - top: 0; - left: 50%; - width: 350px; - margin-left: -175px; -`; - -export class GlobalMessage extends React.PureComponent<{ - closeGlobalMessage: (id: string) => void; - message: Message; -}> { - handleClose = () => { - this.props.closeGlobalMessage(this.props.message.id); - }; - - render() { - const { message } = this.props; - return ( - <Message - data-test={`global-message__${message.level}`} - level={message.level} - role={message.level === 'SUCCESS' ? 'status' : 'alert'}> - {cutLongWords(message.message)} - <CloseButton - className="button-small" - color="#fff" - level={message.level} - onClick={this.handleClose} - /> - </Message> - ); - } -} - -const appearAnim = keyframes` - from { - opacity: 0; - } - to { - opacity: 1; - } -`; - -const Message = styled.div<Pick<Message, 'level'>>` - position: relative; - padding: 0 30px 0 10px; - line-height: ${themeSize('controlHeight')}; - border-radius: 0 0 3px 3px; - box-sizing: border-box; - color: #ffffff; - background-color: ${({ level, theme }) => - level === 'SUCCESS' ? theme.colors.green : theme.colors.red}; - text-align: center; - opacity: 0; - animation: ${appearAnim} 0.2s ease forwards; - - & + & { - margin-top: calc(${themeSize('gridSize')} / 2); - border-radius: 3px; - } -`; - -const CloseButton = styled(ClearButton)<Pick<Message, 'level'>>` - position: absolute; - top: calc(${themeSize('gridSize')} / 4); - right: calc(${themeSize('gridSize')} / 4); - - &:hover svg, - &:focus svg { - color: ${({ level, theme }) => (level === 'SUCCESS' ? theme.colors.green : theme.colors.red)}; - } -`; diff --git a/server/sonar-ui-common/components/controls/HelpTooltip.css b/server/sonar-ui-common/components/controls/HelpTooltip.css deleted file mode 100644 index 11376bc7c33..00000000000 --- a/server/sonar-ui-common/components/controls/HelpTooltip.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. - */ -.help-tooltip { - display: inline-flex; - align-items: center; - vertical-align: middle; -} - -.help-toolip-link { - display: block; - width: 12px; - height: 12px; - border: none; -} diff --git a/server/sonar-ui-common/components/controls/HelpTooltip.tsx b/server/sonar-ui-common/components/controls/HelpTooltip.tsx deleted file mode 100644 index 00a4bf4610c..00000000000 --- a/server/sonar-ui-common/components/controls/HelpTooltip.tsx +++ /dev/null @@ -1,66 +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 HelpIcon from '../icons/HelpIcon'; -import { IconProps } from '../icons/Icon'; -import { ThemeConsumer } from '../theme'; -import './HelpTooltip.css'; -import Tooltip, { Placement } from './Tooltip'; - -interface Props extends Pick<IconProps, 'size'> { - className?: string; - children?: React.ReactNode; - onShow?: () => void; - overlay: React.ReactNode; - placement?: Placement; -} - -export default function HelpTooltip({ size = 12, ...props }: Props) { - return ( - <div className={classNames('help-tooltip', props.className)}> - <Tooltip - mouseLeaveDelay={0.25} - onShow={props.onShow} - overlay={props.overlay} - placement={props.placement}> - <span className="display-inline-flex-center"> - {props.children || ( - <ThemeConsumer> - {(theme) => <HelpIcon fill={theme.colors.gray71} size={size} />} - </ThemeConsumer> - )} - </span> - </Tooltip> - </div> - ); -} - -export function DarkHelpTooltip({ size = 12, ...props }: Omit<Props, 'children'>) { - return ( - <HelpTooltip {...props}> - <ThemeConsumer> - {({ colors }) => ( - <HelpIcon fill={colors.transparentBlack} fillInner={colors.white} size={size} /> - )} - </ThemeConsumer> - </HelpTooltip> - ); -} diff --git a/server/sonar-ui-common/components/controls/IdentityProviderLink.css b/server/sonar-ui-common/components/controls/IdentityProviderLink.css deleted file mode 100644 index 889f14acf90..00000000000 --- a/server/sonar-ui-common/components/controls/IdentityProviderLink.css +++ /dev/null @@ -1,67 +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. - */ -a.identity-provider-link { - display: block; - width: auto; - line-height: 22px; - padding: var(--gridSize) calc(1.5 * var(--gridSize)); - border: 1px solid rgba(0, 0, 0, 0.15); - border-radius: 2px; - box-sizing: border-box; - background-color: var(--darkBlue); - color: #fff; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -a.identity-provider-link.small { - line-height: 14px; - padding: calc(var(--gridSize) / 2) var(--gridSize); -} - -a.identity-provider-link:hover, -a.identity-provider-link:focus { - box-shadow: inset 0 0 0 100px rgba(255, 255, 255, 0.1); -} - -a.identity-provider-link.dark-text { - color: var(--secondFontColor); -} - -a.identity-provider-link.dark-text:hover, -a.identity-provider-link.dark-text:focus { - box-shadow: inset 0 0 0 100px rgba(0, 0, 0, 0.1); -} - -a.identity-provider-link > img { - padding-right: calc(1.5 * var(--gridSize)); -} - -a.identity-provider-link.small > img { - padding-right: var(--gridSize); -} - -a.identity-provider-link > span::before { - content: ''; - opacity: 0.4; - border-left: 1px var(--gray71) solid; - margin-right: calc(1.5 * var(--gridSize)); -} diff --git a/server/sonar-ui-common/components/controls/IdentityProviderLink.tsx b/server/sonar-ui-common/components/controls/IdentityProviderLink.tsx deleted file mode 100644 index 53c85f31a03..00000000000 --- a/server/sonar-ui-common/components/controls/IdentityProviderLink.tsx +++ /dev/null @@ -1,63 +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 { isDarkColor } from '../../helpers/colors'; -import { getBaseUrl } from '../../helpers/urls'; -import './IdentityProviderLink.css'; - -interface Props { - backgroundColor: string; - children: React.ReactNode; - className?: string; - iconPath: string; - name: string; - onClick?: () => void; - small?: boolean; - url: string | undefined; -} - -export default function IdentityProviderLink({ - backgroundColor, - children, - className, - iconPath, - name, - onClick, - small, - url, -}: Props) { - const size = small ? 14 : 20; - - return ( - <a - className={classNames( - 'identity-provider-link', - { 'dark-text': !isDarkColor(backgroundColor), small }, - className - )} - href={url} - onClick={onClick} - style={{ backgroundColor }}> - <img alt={name} height={size} src={getBaseUrl() + iconPath} width={size} /> - {children} - </a> - ); -} diff --git a/server/sonar-ui-common/components/controls/InputValidationField.tsx b/server/sonar-ui-common/components/controls/InputValidationField.tsx deleted file mode 100644 index bb9cfcab90f..00000000000 --- a/server/sonar-ui-common/components/controls/InputValidationField.tsx +++ /dev/null @@ -1,52 +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 ModalValidationField from './ModalValidationField'; - -interface Props { - autoFocus?: boolean; - className?: string; - description?: string; - dirty: boolean; - disabled: boolean; - error: string | undefined; - id?: string; - label?: React.ReactNode; - name: string; - onBlur: (event: React.FocusEvent<any>) => void; - onChange: (event: React.ChangeEvent<any>) => void; - placeholder?: string; - touched: boolean | undefined; - type?: string; - value: string; -} - -export default function InputValidationField({ className, ...props }: Props) { - const { description, dirty, error, label, touched, ...inputProps } = props; - const modalValidationProps = { description, dirty, error, label, touched }; - return ( - <ModalValidationField {...modalValidationProps}> - {({ className: validationClassName }) => ( - <input className={classNames(className, validationClassName)} {...inputProps} /> - )} - </ModalValidationField> - ); -} diff --git a/server/sonar-ui-common/components/controls/ListFooter.tsx b/server/sonar-ui-common/components/controls/ListFooter.tsx deleted file mode 100644 index 8617c126d65..00000000000 --- a/server/sonar-ui-common/components/controls/ListFooter.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 * as classNames from 'classnames'; -import * as React from 'react'; -import { translate, translateWithParameters } from '../../helpers/l10n'; -import { formatMeasure } from '../../helpers/measures'; -import DeferredSpinner from '../ui/DeferredSpinner'; -import { Button } from './buttons'; - -export interface ListFooterProps { - count: number; - className?: string; - loading?: boolean; - loadMore?: () => void; - needReload?: boolean; - reload?: () => void; - ready?: boolean; - total?: number; -} - -export default function ListFooter(props: ListFooterProps) { - const { className, count, loading, needReload, total, ready = true } = props; - const hasMore = total && total > count; - - let button; - if (needReload && props.reload) { - button = ( - <Button className="spacer-left" data-test="reload" disabled={loading} onClick={props.reload}> - {translate('reload')} - </Button> - ); - } else if (hasMore && props.loadMore) { - button = ( - <Button - className="spacer-left" - disabled={loading} - data-test="show-more" - onClick={props.loadMore}> - {translate('show_more')} - </Button> - ); - } - - return ( - <footer - className={classNames('spacer-top note text-center', { 'new-loading': !ready }, className)}> - {translateWithParameters( - 'x_of_y_shown', - formatMeasure(count, 'INT', null), - formatMeasure(total, 'INT', null) - )} - {button} - {loading && <DeferredSpinner className="text-bottom spacer-left position-absolute" />} - </footer> - ); -} diff --git a/server/sonar-ui-common/components/controls/Modal.css b/server/sonar-ui-common/components/controls/Modal.css deleted file mode 100644 index 04e3de15a21..00000000000 --- a/server/sonar-ui-common/components/controls/Modal.css +++ /dev/null @@ -1,211 +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. - */ -.modal, -.ReactModal__Content { - position: fixed; - z-index: var(--modalZIndex); - top: 0; - left: 50%; - margin-left: -270px; - width: 540px; - background-color: #fff; - opacity: 0; - transition: all 0.2s ease; - border-radius: 3px; -} - -.modal:focus, -.ReactModal__Content:focus { - outline: none; -} - -.modal.in, -.ReactModal__Content--after-open { - top: 15%; - opacity: 1; -} - -.modal-small { - width: 450px; - margin-left: -225px; -} - -.modal-medium { - width: 830px; - margin-left: -415px; -} - -.modal-large { - width: calc(100% - 40px); - max-width: 1280px; - min-width: 1040px; - margin-left: 0; - transform: translateX(-50%); -} - -.modal-overlay, -.ReactModal__Overlay { - position: fixed; - z-index: var(--modalOverlayZIndex); - top: 0; - bottom: 0; - left: 0; - right: 0; - background-color: rgba(0, 0, 0, 0.7); - opacity: 0; - transition: all 0.2s ease; -} - -.modal-overlay.in, -.ReactModal__Overlay--after-open { - opacity: 1; -} - -.modal-no-backdrop { - background-color: transparent; -} - -.modal-open, -.ReactModal__Body--open { - overflow: hidden; - margin-right: var(--sbw); -} - -.modal-head { - padding: calc(4 * var(--gridSize)); - padding-bottom: 0; -} - -.modal-head h1, -.modal-head h2 { - margin: 0; - font-size: var(--bigFontSize); - font-weight: bold; - line-height: normal; - overflow-wrap: break-word; -} - -.modal-body { - padding: var(--pagePadding) calc(4 * var(--gridSize)); -} - -.modal-container { - max-height: 60vh; - box-sizing: border-box; - overflow-y: auto; - border-top: 1px solid var(--barBorderColor); - margin-top: var(--pagePadding); - padding-right: calc(4 * var(--gridSize)); -} - -.modal-container > :last-child { - margin-bottom: var(--pagePadding); -} - -.modal-field, -.modal-validation-field { - clear: both; - display: block; - padding: 0; - margin-bottom: calc(var(--gridSize) * 2); -} - -.modal-field label, -.modal-validation-field label { - display: block; - font-weight: bold; - padding-bottom: calc(var(--gridSize) / 2); -} - -.modal-field a.icon-checkbox, -.modal-field input, -.modal-field select, -.modal-field textarea, -.modal-field .Select { - margin-right: 5px; -} - -.modal-field a.icon-checkbox { - height: 24px; -} - -.modal-field input[type='radio'], -.modal-field input[type='checkbox'] { - margin-top: 5px; - margin-bottom: 4px; -} - -.modal-field > .icon-checkbox { - padding-top: 6px; - padding-right: 8px; -} - -.modal-field input[type='text'], -.modal-field input[type='email'], -.modal-field input[type='password'], -.modal-field textarea, -.modal-field select, -.modal-field .Select { - width: 100%; -} - -.modal-validation-field input, -.modal-validation-field textarea, -.modal-validation-field .Select { - margin-right: var(--gridSize); - margin-bottom: 2px; - width: calc(100% - 3 * var(--gridSize)); -} - -.modal-field textarea, -.modal-validation-field textarea { - max-width: 100%; - min-width: 100%; - max-height: 50vh; - min-height: var(--controlHeight); -} -.modal-validation-field input:not(.is-invalid), -.modal-validation-field .Select:not(.is-invalid) { - margin-bottom: calc(var(--tinyControlHeight) + 2px); -} - -.modal-field-description { - line-height: 1.4; - color: var(--secondFontColor); - font-size: var(--smallFontSize); - overflow: hidden; - text-overflow: ellipsis; - margin-top: 2px; -} - -.modal-foot { - padding: var(--pagePadding) calc(4 * var(--gridSize)); - border-top: 1px solid var(--barBorderColor); - background-color: var(--barBackgroundColor); - border-radius: 3px; - text-align: right; -} - -.modal-foot button, -.modal-foot .button, -.modal-foot input[type='submit'], -.modal-foot input[type='button'] { - margin-left: var(--gridSize); -} diff --git a/server/sonar-ui-common/components/controls/Modal.tsx b/server/sonar-ui-common/components/controls/Modal.tsx deleted file mode 100644 index 4583856b3c6..00000000000 --- a/server/sonar-ui-common/components/controls/Modal.tsx +++ /dev/null @@ -1,76 +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 * as ReactModal from 'react-modal'; -import { getReactDomContainerSelector } from '../../helpers/init'; -import './Modal.css'; - -ReactModal.setAppElement(getReactDomContainerSelector()); - -export interface ModalProps { - children: React.ReactNode; - size?: 'small' | 'medium' | 'large'; - noBackdrop?: boolean; -} - -interface Props extends ModalProps { - /* String or object className to be applied to the modal content. */ - className?: string; - - /* String or object className to be applied to the overlay. */ - overlayClassName?: string; - - /* Function that will be run after the modal has opened. */ - onAfterOpen?(): void; - - /* Function that will be run after the modal has closed. */ - onAfterClose?(): void; - - /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ - onRequestClose?(event: React.MouseEvent | React.KeyboardEvent): void; - - /* Boolean indicating if the modal should be focused after render */ - shouldFocusAfterRender?: boolean; - - /* Boolean indicating if the overlay should close the modal. Defaults to true. */ - shouldCloseOnOverlayClick?: boolean; - - /* Boolean indicating if pressing the esc key should close the modal */ - shouldCloseOnEsc?: boolean; - - /* String indicating how the content container should be announced to screenreaders. */ - contentLabel: string; -} - -export default function Modal(props: Props) { - return ( - <ReactModal - className={classNames('modal', { - 'modal-small': props.size === 'small', - 'modal-medium': props.size === 'medium', - 'modal-large': props.size === 'large', - })} - isOpen={true} - overlayClassName={classNames('modal-overlay', { 'modal-no-backdrop': props.noBackdrop })} - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/controls/ModalButton.tsx b/server/sonar-ui-common/components/controls/ModalButton.tsx deleted file mode 100644 index 2166b6464c4..00000000000 --- a/server/sonar-ui-common/components/controls/ModalButton.tsx +++ /dev/null @@ -1,80 +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'; - -export interface ChildrenProps { - onClick: () => void; - onFormSubmit: (event: React.FormEvent<HTMLFormElement>) => void; -} - -export interface ModalProps { - onClose: () => void; -} - -export interface Props { - children: (props: ChildrenProps) => React.ReactNode; - modal: (props: ModalProps) => React.ReactNode; -} - -interface State { - modal: boolean; -} - -export default class ModalButton extends React.PureComponent<Props, State> { - mounted = false; - state: State = { modal: false }; - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - handleButtonClick = () => { - this.setState({ modal: true }); - }; - - handleFormSubmit = (event?: React.FormEvent<HTMLFormElement>) => { - if (event) { - event.preventDefault(); - } - this.setState({ modal: true }); - }; - - handleCloseModal = () => { - if (this.mounted) { - this.setState({ modal: false }); - } - }; - - render() { - return ( - <> - {this.props.children({ - onClick: this.handleButtonClick, - onFormSubmit: this.handleFormSubmit, - })} - {this.state.modal && this.props.modal({ onClose: this.handleCloseModal })} - </> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/ModalValidationField.tsx b/server/sonar-ui-common/components/controls/ModalValidationField.tsx deleted file mode 100644 index 2aa649de238..00000000000 --- a/server/sonar-ui-common/components/controls/ModalValidationField.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 AlertErrorIcon from '../icons/AlertErrorIcon'; -import AlertSuccessIcon from '../icons/AlertSuccessIcon'; - -interface Props { - children: (props: { className?: string }) => React.ReactNode; - description?: string; - dirty: boolean; - error: string | undefined; - label?: React.ReactNode; - touched: boolean | undefined; -} - -export default function ModalValidationField(props: Props) { - const { description, dirty, error } = props; - - const isValid = dirty && props.touched && error === undefined; - const showError = dirty && props.touched && error !== undefined; - return ( - <div className="modal-validation-field"> - {props.label} - {props.children({ className: classNames({ 'is-invalid': showError, 'is-valid': isValid }) })} - {showError && <AlertErrorIcon className="little-spacer-top" />} - {isValid && <AlertSuccessIcon className="little-spacer-top" />} - {showError && <p className="text-danger">{error}</p>} - {description && <div className="modal-field-description">{description}</div>} - </div> - ); -} diff --git a/server/sonar-ui-common/components/controls/OutsideClickHandler.tsx b/server/sonar-ui-common/components/controls/OutsideClickHandler.tsx deleted file mode 100644 index eaea43f89ba..00000000000 --- a/server/sonar-ui-common/components/controls/OutsideClickHandler.tsx +++ /dev/null @@ -1,64 +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 { findDOMNode } from 'react-dom'; - -interface Props { - children: React.ReactNode; - onClickOutside: () => void; -} - -export default class OutsideClickHandler extends React.Component<Props> { - mounted = false; - - componentDidMount() { - this.mounted = true; - setTimeout(() => { - this.addClickHandler(); - }, 0); - } - - componentWillUnmount() { - this.mounted = false; - this.removeClickHandler(); - } - - addClickHandler = () => { - window.addEventListener('click', this.handleWindowClick); - }; - - removeClickHandler = () => { - window.removeEventListener('click', this.handleWindowClick); - }; - - handleWindowClick = (event: MouseEvent) => { - if (this.mounted) { - // eslint-disable-next-line react/no-find-dom-node - const node = findDOMNode(this); - if (!node || !node.contains(event.target as Node)) { - this.props.onClickOutside(); - } - } - }; - - render() { - return this.props.children; - } -} diff --git a/server/sonar-ui-common/components/controls/Radio.css b/server/sonar-ui-common/components/controls/Radio.css deleted file mode 100644 index 6d53c4b383b..00000000000 --- a/server/sonar-ui-common/components/controls/Radio.css +++ /dev/null @@ -1,76 +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. - */ -.icon-radio { - position: relative; - display: inline-block; - vertical-align: top; - width: 14px; - height: 14px; - margin: 1px; - border: 1px solid var(--gray80); - border-radius: 12px; - box-sizing: border-box; - transition: border-color 0.3s ease; - flex-shrink: 0; -} - -.icon-radio:after { - position: absolute; - top: 2px; - left: 2px; - display: block; - width: 8px; - height: 8px; - border-radius: 8px; - background-color: var(--darkBlue); - content: ''; - opacity: 0; - transition: opacity 0.3s ease; -} - -.link-radio .icon-radio.is-checked:after { - opacity: 1; -} - -.link-radio { - color: inherit; - border-bottom: none; -} - -.link-radio:not(.disabled):hover, -.link-radio:not(.disabled):active, -.link-radio:not(.disabled):focus { - color: inherit; -} - -.link-radio:not(.disabled):hover > .icon-radio { - border-color: var(--blue); -} - -.link-radio.disabled, -.link-radio.disabled:hover, -.link-radio.disabled label { - color: var(--disableGrayText); - cursor: not-allowed; -} - -.link-radio.disabled .icon-radio:after { - background-color: var(--disableGrayBg); -} diff --git a/server/sonar-ui-common/components/controls/Radio.tsx b/server/sonar-ui-common/components/controls/Radio.tsx deleted file mode 100644 index c664c6f2499..00000000000 --- a/server/sonar-ui-common/components/controls/Radio.tsx +++ /dev/null @@ -1,56 +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 './Radio.css'; - -interface Props { - checked: boolean; - className?: string; - disabled?: boolean; - onCheck: (value: string) => void; - value: string; -} - -export default class Radio extends React.PureComponent<Props> { - handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => { - event.preventDefault(); - - if (!this.props.disabled) { - this.props.onCheck(this.props.value); - } - }; - - render() { - const { className, checked, children, disabled } = this.props; - - return ( - <a - aria-checked={checked} - className={classNames('display-inline-flex-center link-radio', className, { disabled })} - href="#" - onClick={this.handleClick} - role="radio"> - <i className={classNames('icon-radio', 'spacer-right', { 'is-checked': checked })} /> - {children} - </a> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/RadioCard.css b/server/sonar-ui-common/components/controls/RadioCard.css deleted file mode 100644 index f51fe41c930..00000000000 --- a/server/sonar-ui-common/components/controls/RadioCard.css +++ /dev/null @@ -1,134 +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. - */ -.radio-card { - display: flex; - flex-direction: column; - width: 450px; - min-height: 210px; - background-color: #fff; - border: solid 1px var(--barBorderColor); - border-radius: 3px; - box-sizing: border-box; - margin-right: calc(2 * var(--gridSize)); - transition: all 0.2s ease; -} - -.radio-card.animated { - height: 0; - border-width: 0; - overflow: hidden; -} - -.radio-card.animated.open { - height: 210px; - border-width: 1px; -} - -.radio-card.highlight { - box-shadow: var(--defaultShadow); -} - -.radio-card:last-child { - margin-right: 0; -} - -.radio-card:focus { - outline: none; -} - -.radio-card-vertical { - width: 100%; - min-height: auto; -} - -.radio-card-actionable { - cursor: pointer; -} - -.radio-card-actionable:not(.disabled):hover { - box-shadow: var(--defaultShadow); - transform: translateY(-2px); -} - -.radio-card-actionable.selected { - border-color: var(--darkBlue); -} - -/* - * Disabled transform property because it moves the element to a new stacking context - * creating z-index conflicts with other components. - * This is a problem with a vertical list of RadioCards where a select might be above another RadioCard - */ -.radio-card-actionable.radio-card-vertical:not(.disabled):hover { - box-shadow: none; - transform: none; -} - -.radio-card-actionable.radio-card-vertical:not(.selected):not(.disabled):hover { - border-color: var(--lightBlue); -} - -.radio-card-actionable.selected .radio-card-recommended { - border: solid 1px var(--darkBlue); - border-top: none; -} - -.radio-card-actionable.disabled { - cursor: not-allowed; - background-color: var(--disableGrayBg); - border-color: var(--disableGrayBorder); -} - -.radio-card-actionable.disabled h2, -.radio-card-actionable.disabled ul { - color: var(--disableGrayText); -} - -.radio-card-header { - display: flex; - justify-content: space-between; - align-items: center; - padding: calc(2 * var(--gridSize)) calc(2 * var(--gridSize)) 0; -} - -.radio-card-body { - flex-grow: 1; - display: flex; - flex-direction: column; - justify-content: space-between; - padding: 0 calc(2 * var(--gridSize)) calc(2 * var(--gridSize)); -} - -.radio-card-body .alert { - margin-bottom: 0; -} - -.radio-card-recommended { - position: relative; - padding: 6px calc(var(--gridSize) * 2); - left: -1px; - bottom: -1px; - width: 450px; - color: #fff; - background-color: var(--blue); - border-radius: 0 0 3px 3px; - box-sizing: border-box; - font-size: var(--smallFontSize); -} diff --git a/server/sonar-ui-common/components/controls/RadioCard.tsx b/server/sonar-ui-common/components/controls/RadioCard.tsx deleted file mode 100644 index 0fdd1348a9d..00000000000 --- a/server/sonar-ui-common/components/controls/RadioCard.tsx +++ /dev/null @@ -1,92 +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'; -import RecommendedIcon from '../icons/RecommendedIcon'; -import './Radio.css'; -import './RadioCard.css'; - -export interface RadioCardProps { - className?: string; - disabled?: boolean; - onClick?: () => void; - selected?: boolean; -} - -interface Props extends RadioCardProps { - children: React.ReactNode; - recommended?: string; - title: React.ReactNode; - titleInfo?: React.ReactNode; - vertical?: boolean; -} - -export default function RadioCard(props: Props) { - const { - className, - disabled, - onClick, - recommended, - selected, - titleInfo, - vertical = false, - } = props; - const isActionable = Boolean(onClick); - return ( - <div - aria-checked={selected} - className={classNames( - 'radio-card', - { - 'radio-card-actionable': isActionable, - 'radio-card-vertical': vertical, - disabled, - selected, - }, - className - )} - onClick={isActionable && !disabled ? onClick : undefined} - role="radio" - tabIndex={0}> - <h2 className="radio-card-header big-spacer-bottom"> - <span className="display-flex-center link-radio"> - {isActionable && ( - <i className={classNames('icon-radio', 'spacer-right', { 'is-checked': selected })} /> - )} - {props.title} - </span> - {titleInfo} - </h2> - <div className="radio-card-body">{props.children}</div> - {recommended && ( - <div className="radio-card-recommended"> - <RecommendedIcon className="spacer-right" /> - <FormattedMessage - defaultMessage={recommended} - id={recommended} - values={{ recommended: <strong>{translate('recommended')}</strong> }} - /> - </div> - )} - </div> - ); -} diff --git a/server/sonar-ui-common/components/controls/RadioToggle.css b/server/sonar-ui-common/components/controls/RadioToggle.css deleted file mode 100644 index 4ca9c28df7c..00000000000 --- a/server/sonar-ui-common/components/controls/RadioToggle.css +++ /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. - */ -.radio-toggle { - display: inline-block; - vertical-align: middle; - font-size: 0; - white-space: nowrap; -} - -.radio-toggle > li { - display: inline-block; - vertical-align: middle; - font-size: var(--smallFontSize); -} - -.radio-toggle > li:first-child > label { - border-top-left-radius: 2px; - border-bottom-left-radius: 2px; -} - -.radio-toggle > li:last-child > label { - border-top-right-radius: 2px; - border-bottom-right-radius: 2px; -} - -.radio-toggle > li + li > label { - border-left: none; -} - -.radio-toggle > li > label { - display: inline-block; - padding: 0 12px; - margin: 0; - border: 1px solid var(--darkBlue); - color: var(--darkBlue); - height: calc(var(--controlHeight) - 2px); - line-height: calc(var(--controlHeight) - 2px); - cursor: pointer; - font-weight: 600; -} - -.radio-toggle input[type='radio'] { - display: none; -} - -.radio-toggle input[type='radio']:checked + label { - background-color: var(--darkBlue); - color: #fff; -} - -.radio-toggle input[type='radio']:disabled + label { - color: var(--disableGrayText); - border-color: var(--disableGrayBorder); - background: var(--disableGrayBg); - cursor: not-allowed; -} diff --git a/server/sonar-ui-common/components/controls/RadioToggle.tsx b/server/sonar-ui-common/components/controls/RadioToggle.tsx deleted file mode 100644 index 51187d25cbb..00000000000 --- a/server/sonar-ui-common/components/controls/RadioToggle.tsx +++ /dev/null @@ -1,74 +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 './RadioToggle.css'; -import Tooltip from './Tooltip'; - -type ToggleValueType = string | number | boolean; -interface Option { - disabled?: boolean; - label: string; - tooltip?: string; - value: ToggleValueType; -} - -interface Props { - className?: string; - name: string; - onCheck: (value: ToggleValueType) => void; - options: Option[]; - value?: ToggleValueType; -} - -export default class RadioToggle extends React.PureComponent<Props> { - static defaultProps = { - disabled: false, - value: null, - }; - - renderOption = (option: Option) => { - const checked = option.value === this.props.value; - const htmlId = this.props.name + '__' + option.value; - return ( - <li key={option.value.toString()}> - <input - checked={checked} - disabled={option.disabled} - id={htmlId} - name={this.props.name} - onChange={() => this.props.onCheck(option.value)} - type="radio" - /> - <Tooltip overlay={option.tooltip || undefined}> - <label htmlFor={htmlId}>{option.label}</label> - </Tooltip> - </li> - ); - }; - - render() { - return ( - <ul className={classNames('radio-toggle', this.props.className)}> - {this.props.options.map(this.renderOption)} - </ul> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/ReloadButton.tsx b/server/sonar-ui-common/components/controls/ReloadButton.tsx deleted file mode 100644 index 0d7d7960d4c..00000000000 --- a/server/sonar-ui-common/components/controls/ReloadButton.tsx +++ /dev/null @@ -1,63 +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 { ThemeConsumer } from '../theme'; -import Tooltip from './Tooltip'; - -interface Props { - className?: string; - tooltip?: string; - onClick: () => void; -} - -export default class ReloadButton extends React.PureComponent<Props> { - handleClick = (event: React.SyntheticEvent<HTMLAnchorElement>) => { - event.preventDefault(); - event.currentTarget.blur(); - this.props.onClick(); - }; - - render() { - const { tooltip = translate('reload') } = this.props; - return ( - <Tooltip overlay={tooltip}> - <a - className={classNames('link-no-underline', this.props.className)} - href="#" - onClick={this.handleClick}> - { - <ThemeConsumer> - {(theme) => ( - <svg height="24" viewBox="0 0 18 24" width="18"> - <path - d="M16.6454 8.1084c-.3-.5-.9-.7-1.4-.4-.5.3-.7.9-.4 1.4.9 1.6 1.1 3.4.6 5.1-.5 1.7-1.7 3.2-3.2 4-3.3 1.8-7.4.6-9.1-2.7-1.8-3.1-.8-6.9 2.1-8.8v3.3h2v-7h-7v2h3.9c-3.7 2.5-5 7.5-2.8 11.4 1.6 3 4.6 4.6 7.7 4.6 1.4 0 2.8-.3 4.2-1.1 2-1.1 3.5-3 4.2-5.2.6-2.2.3-4.6-.8-6.6z" - fill={theme.colors.secondFontColor} - /> - </svg> - )} - </ThemeConsumer> - } - </a> - </Tooltip> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/ScreenPositionFixer.tsx b/server/sonar-ui-common/components/controls/ScreenPositionFixer.tsx deleted file mode 100644 index 0065201d22e..00000000000 --- a/server/sonar-ui-common/components/controls/ScreenPositionFixer.tsx +++ /dev/null @@ -1,117 +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 { throttle } from 'lodash'; -import * as React from 'react'; -import { findDOMNode } from 'react-dom'; -import { Theme, withTheme } from '../theme'; - -interface Props { - /** - * First time `children` are rendered with `undefined` fixes to measure the offset. - * Second time it renders with the computed fixes. - */ - children: (props: Fixes) => React.ReactNode; - - /** - * Use this flag to force re-positioning. - * Use cases: - * - when you need to measure `children` size first - * - when you load content asynchronously - */ - ready?: boolean; - theme: Theme; -} - -interface Fixes { - leftFix?: number; - topFix?: number; -} - -export class ScreenPositionFixer extends React.Component<Props, Fixes> { - throttledPosition: () => void; - - constructor(props: Props) { - super(props); - this.state = {}; - this.throttledPosition = throttle(this.position, 50); - } - - componentDidMount() { - this.addEventListeners(); - this.position(); - } - - componentDidUpdate(prevProps: Props) { - if (!prevProps.ready && this.props.ready) { - this.position(); - } else if (prevProps.ready && !this.props.ready) { - this.reset(); - } - } - - componentWillUnmount() { - this.removeEventListeners(); - } - - addEventListeners = () => { - window.addEventListener('resize', this.throttledPosition); - }; - - removeEventListeners = () => { - window.removeEventListener('resize', this.throttledPosition); - }; - - reset = () => { - this.setState({ leftFix: undefined, topFix: undefined }); - }; - - position = () => { - const edgeMargin = 0.5 * this.props.theme.rawSizes.grid; - - // eslint-disable-next-line react/no-find-dom-node - const node = findDOMNode(this); - if (node && node instanceof Element) { - const { width, height, left, top } = node.getBoundingClientRect(); - const { clientHeight, clientWidth } = document.documentElement; - - let leftFix = 0; - if (left < edgeMargin) { - leftFix = edgeMargin - left; - } else if (left + width > clientWidth - edgeMargin) { - leftFix = clientWidth - edgeMargin - left - width; - } - - let topFix = 0; - if (top < edgeMargin) { - topFix = edgeMargin - top; - } else if (top + height > clientHeight - edgeMargin) { - topFix = clientHeight - edgeMargin - top - height; - } - - this.setState({ leftFix, topFix }); - } - }; - - render() { - return this.props.children(this.state); - } -} - -export default withTheme(ScreenPositionFixer); diff --git a/server/sonar-ui-common/components/controls/SearchBox.css b/server/sonar-ui-common/components/controls/SearchBox.css deleted file mode 100644 index 3e91462ef5c..00000000000 --- a/server/sonar-ui-common/components/controls/SearchBox.css +++ /dev/null @@ -1,104 +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. - */ -.search-box { - position: relative; - display: inline-block; - vertical-align: middle; - font-size: 0; - white-space: nowrap; -} - -.search-box, -.search-box-input { - width: 100%; - max-width: 300px; -} - -.search-box-input { - /* for magnifier icon */ - padding-left: var(--controlHeight) !important; - /* for clear button */ - padding-right: var(--controlHeight) !important; - font-size: var(--baseFontSize); -} - -.search-box-input::-webkit-search-decoration, -.search-box-input::-webkit-search-cancel-button, -.search-box-input::-webkit-search-results-button, -.search-box-input::-webkit-search-results-decoration { - -webkit-appearance: none; - display: none; -} - -.search-box-input::-ms-clear, -.search-box-input::-ms-reveal { - display: none; - width: 0; - height: 0; -} - -.search-box-note { - position: absolute; - top: 1px; - left: 40px; - right: var(--controlHeight); - line-height: var(--controlHeight); - color: var(--secondFontColor); - font-size: var(--smallFontSize); - text-align: right; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - pointer-events: none; -} - -.search-box-input:focus ~ .search-box-magnifier { - color: var(--blue); -} - -.search-box-magnifier { - position: absolute; - top: 4px; - left: 4px; - color: var(--gray60); - transition: color 0.3s ease; -} - -.search-box > .deferred-spinner { - position: absolute; - top: 4px; - left: 5px; -} - -.search-box-clear { - position: absolute; - top: 4px; - right: 4px; -} - -.search-box-input-note { - position: absolute; - top: 100%; - left: 0; - line-height: 1; - color: var(--secondFontColor); - font-size: var(--smallFontSize); - white-space: nowrap; -} diff --git a/server/sonar-ui-common/components/controls/SearchBox.tsx b/server/sonar-ui-common/components/controls/SearchBox.tsx deleted file mode 100644 index c3889b50825..00000000000 --- a/server/sonar-ui-common/components/controls/SearchBox.tsx +++ /dev/null @@ -1,176 +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 { Cancelable, debounce } from 'lodash'; -import * as React from 'react'; -import { translate, translateWithParameters } from '../../helpers/l10n'; -import SearchIcon from '../icons/SearchIcon'; -import DeferredSpinner from '../ui/DeferredSpinner'; -import { ClearButton } from './buttons'; -import './SearchBox.css'; - -interface Props { - autoFocus?: boolean; - className?: string; - id?: string; - innerRef?: (node: HTMLInputElement | null) => void; - loading?: boolean; - maxLength?: number; - minLength?: number; - onChange: (value: string) => void; - onClick?: React.MouseEventHandler<HTMLInputElement>; - onFocus?: React.FocusEventHandler<HTMLInputElement>; - onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>; - placeholder: string; - value?: string; -} - -interface State { - value: string; -} - -const DEFAULT_MAX_LENGTH = 100; - -export default class SearchBox extends React.PureComponent<Props, State> { - debouncedOnChange: ((query: string) => void) & Cancelable; - input?: HTMLInputElement | null; - - constructor(props: Props) { - super(props); - this.state = { value: props.value || '' }; - this.debouncedOnChange = debounce(this.props.onChange, 250); - } - - componentDidUpdate(prevProps: Props) { - if ( - // input is controlled - this.props.value !== undefined && - // parent is aware of last change - // can happen when previous value was less than min length - this.state.value === prevProps.value && - this.state.value !== this.props.value - ) { - this.setState({ value: this.props.value }); - } - } - - changeValue = (value: string, debounced = true) => { - const { minLength } = this.props; - if (value.length === 0) { - // immediately notify when value is empty - this.props.onChange(''); - // and cancel scheduled callback - this.debouncedOnChange.cancel(); - } else if (!minLength || minLength <= value.length) { - if (debounced) { - this.debouncedOnChange(value); - } else { - this.props.onChange(value); - } - } - }; - - handleInputChange = (event: React.SyntheticEvent<HTMLInputElement>) => { - const { value } = event.currentTarget; - this.setState({ value }); - this.changeValue(value); - }; - - handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => { - if (event.keyCode === 27) { - // escape - event.preventDefault(); - this.handleResetClick(); - } - if (this.props.onKeyDown) { - this.props.onKeyDown(event); - } - }; - - handleResetClick = () => { - this.changeValue('', false); - if (this.props.value === undefined || this.props.value === '') { - this.setState({ value: '' }); - } - if (this.input) { - this.input.focus(); - } - }; - - ref = (node: HTMLInputElement | null) => { - this.input = node; - if (this.props.innerRef) { - this.props.innerRef(node); - } - }; - - render() { - const { loading, minLength, maxLength = DEFAULT_MAX_LENGTH } = this.props; - const { value } = this.state; - - const inputClassName = classNames('search-box-input', { - touched: value.length > 0 && (!minLength || minLength > value.length), - }); - - const tooShort = minLength !== undefined && value.length > 0 && value.length < minLength; - - return ( - <div - className={classNames('search-box', this.props.className)} - id={this.props.id} - title={tooShort ? translateWithParameters('select2.tooShort', minLength!) : ''}> - <input - aria-label={translate('search_verb')} - autoComplete="off" - autoFocus={this.props.autoFocus} - className={inputClassName} - maxLength={maxLength} - onChange={this.handleInputChange} - onClick={this.props.onClick} - onFocus={this.props.onFocus} - onKeyDown={this.handleInputKeyDown} - placeholder={this.props.placeholder} - ref={this.ref} - type="search" - value={value} - /> - - <DeferredSpinner loading={loading !== undefined ? loading : false}> - <SearchIcon className="search-box-magnifier" /> - </DeferredSpinner> - - {value && ( - <ClearButton - aria-label={translate('clear')} - className="button-tiny search-box-clear" - iconProps={{ size: 12 }} - onClick={this.handleResetClick} - /> - )} - - {tooShort && ( - <span className="search-box-note"> - {translateWithParameters('select2.tooShort', minLength!)} - </span> - )} - </div> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/SearchSelect.tsx b/server/sonar-ui-common/components/controls/SearchSelect.tsx deleted file mode 100644 index be783afe805..00000000000 --- a/server/sonar-ui-common/components/controls/SearchSelect.tsx +++ /dev/null @@ -1,154 +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 { debounce } from 'lodash'; -import * as React from 'react'; -import { translate, translateWithParameters } from '../../helpers/l10n'; -import Select, { Creatable } from './Select'; - -interface Props<T> { - autofocus?: boolean; - canCreate?: boolean; - className?: string; - clearable?: boolean; - defaultOptions?: T[]; - minimumQueryLength?: number; - multi?: boolean; - onSearch: (query: string) => Promise<T[]>; - onSelect?: (option: T) => void; - onMultiSelect?: (options: T[]) => void; - promptTextCreator?: (label: string) => string; - renderOption?: (option: T) => JSX.Element; - resetOnBlur?: boolean; - value?: T | T[]; -} - -interface State<T> { - loading: boolean; - options: T[]; - query: string; -} - -export default class SearchSelect<T extends { value: string }> extends React.PureComponent< - Props<T>, - State<T> -> { - mounted = false; - - constructor(props: Props<T>) { - super(props); - this.state = { loading: false, options: props.defaultOptions || [], query: '' }; - this.handleSearch = debounce(this.handleSearch, 250); - } - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - get autofocus() { - return this.props.autofocus !== undefined ? this.props.autofocus : true; - } - - get minimumQueryLength() { - return this.props.minimumQueryLength !== undefined ? this.props.minimumQueryLength : 2; - } - - get resetOnBlur() { - return this.props.resetOnBlur !== undefined ? this.props.resetOnBlur : true; - } - - handleSearch = (query: string) => { - // Ignore the result if the query changed - const currentQuery = query; - this.props.onSearch(currentQuery).then( - (options) => { - if (this.mounted) { - this.setState((state) => ({ - loading: false, - options: state.query === currentQuery ? options : state.options, - })); - } - }, - () => { - if (this.mounted) { - this.setState({ loading: false }); - } - } - ); - }; - - handleChange = (option: T | T[]) => { - if (Array.isArray(option)) { - if (this.props.onMultiSelect) { - this.props.onMultiSelect(option); - } - } else if (this.props.onSelect) { - this.props.onSelect(option); - } - }; - - handleInputChange = (query: string) => { - if (query.length >= this.minimumQueryLength) { - this.setState({ loading: true, query }); - this.handleSearch(query); - } else { - // `onInputChange` is called with an empty string after a user selects a value - // in this case we shouldn't reset `options`, because it also resets select value :( - const options = (query.length === 0 && this.props.defaultOptions) || []; - this.setState({ options, query }); - } - }; - - // disable internal filtering - handleFilterOption = () => true; - - render() { - const Component = this.props.canCreate ? Creatable : Select; - return ( - <Component - autoFocus={this.autofocus} - className={this.props.className} - clearable={this.props.clearable} - escapeClearsValue={false} - filterOption={this.handleFilterOption} - isLoading={this.state.loading} - multi={this.props.multi} - noResultsText={ - this.state.query.length < this.minimumQueryLength - ? translateWithParameters('select2.tooShort', this.minimumQueryLength) - : translate('select2.noMatches') - } - onBlurResetsInput={this.resetOnBlur} - onChange={this.handleChange} - onInputChange={this.handleInputChange} - optionRenderer={this.props.renderOption} - options={this.state.options} - placeholder={translate('search_verb')} - promptTextCreator={this.props.promptTextCreator} - searchable={true} - value={this.props.value} - valueRenderer={this.props.renderOption} - /> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/Select.css b/server/sonar-ui-common/components/controls/Select.css deleted file mode 100644 index 8f89447cc47..00000000000 --- a/server/sonar-ui-common/components/controls/Select.css +++ /dev/null @@ -1,477 +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. - */ -.Select { - position: relative; - display: inline-block; - vertical-align: middle; - font-size: var(--smallFontSize); - text-align: left; -} - -.Select, -.Select div, -.Select input, -.Select span { - box-sizing: border-box; -} - -.Select.is-disabled > .Select-control { - background-color: var(--disableGrayBg) !important; - border-color: var(--disableGrayBorder) !important; -} - -.Select.is-disabled > .Select-control:hover { - box-shadow: none !important; -} - -.Select.is-disabled .Select-arrow-zone { - cursor: not-allowed !important; - pointer-events: none !important; -} - -.Select.is-disabled .Select-placeholder, -.Select.is-disabled .Select-value { - color: var(--disableGrayText) !important; -} - -.Select-control { - position: relative; - display: table; - width: 100%; - height: var(--controlHeight); - line-height: calc(var(--controlHeight) - 2px); - border: 1px solid var(--gray80); - border-collapse: separate; - border-radius: 2px; - background-color: #fff; - color: var(--baseFontColor); - cursor: default; - outline: none; - overflow: hidden; -} - -.is-searchable.is-open > .Select-control { - cursor: text; -} - -.is-open > .Select-control { - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; - background: #fff; -} - -.is-open > .Select-control > .Select-arrow { - border-color: transparent transparent #999; - border-width: 0 5px 5px; -} - -.is-searchable.is-focused:not(.is-open) > .Select-control { - cursor: text; -} - -.is-focused:not(.is-open) > .Select-control { - border-color: var(--blue); -} - -.Select-placeholder { - color: var(--secondFontColor); -} - -.Select-placeholder, -:not(.Select--multi) > .Select-control .Select-value { - bottom: 0; - left: 0; - line-height: 23px; - padding-left: 8px; - padding-right: 24px; - position: absolute; - right: 0; - top: 0; - max-width: 100%; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.Select-value [class^='icon-'] { - padding-top: 5px; -} - -.Select-value svg, -.Select-value img { - padding-top: 3px; -} - -.Select-option svg, -.Select-option img, -.Select-option [class^='icon-'] { - padding-top: 2px; -} - -.has-value:not(.Select--multi) > .Select-control > .Select-value .Select-value-label, -.has-value.is-pseudo-focused:not(.Select--multi) - > .Select-control - > .Select-value - .Select-value-label { - color: var(--baseFontColor); -} - -.has-value:not(.Select--multi) > .Select-control > .Select-value a.Select-value-label, -.has-value.is-pseudo-focused:not(.Select--multi) - > .Select-control - > .Select-value - a.Select-value-label { - cursor: pointer; - text-decoration: none; -} - -.has-value:not(.Select--multi) > .Select-control > .Select-value a.Select-value-label:hover, -.has-value.is-pseudo-focused:not(.Select--multi) - > .Select-control - > .Select-value - a.Select-value-label:hover, -.has-value:not(.Select--multi) > .Select-control > .Select-value a.Select-value-label:focus, -.has-value.is-pseudo-focused:not(.Select--multi) - > .Select-control - > .Select-value - a.Select-value-label:focus { - color: #007eff; - outline: none; - text-decoration: underline; -} - -.Select-input { - vertical-align: top; - height: 22px; - padding-left: 8px; - padding-right: 8px; - outline: none; -} - -.Select-input > input { - background: none transparent; - border: 0 none; - cursor: default; - display: inline-block; - font-family: inherit; - font-size: var(--smallFontSize); - height: 22px; - margin: 0; - outline: none; - padding: 0; - box-shadow: none; - -webkit-appearance: none; -} - -.is-focused .Select-input > input { - cursor: text; -} - -.has-value.is-pseudo-focused .Select-input { - opacity: 0; -} - -.Select-control:not(.is-searchable) > .Select-input { - outline: none; -} - -.Select-loading-zone { - cursor: pointer; - display: table-cell; - position: relative; - text-align: center; - vertical-align: middle; - width: 16px; -} - -.Select-loading { - -webkit-animation: Select-animation-spin 400ms infinite linear; - -o-animation: Select-animation-spin 400ms infinite linear; - animation: Select-animation-spin 400ms infinite linear; - width: 16px; - height: 16px; - box-sizing: border-box; - border-radius: 50%; - border: 2px solid #ccc; - border-right-color: var(--baseFontColor); - display: inline-block; - position: relative; - vertical-align: middle; -} - -.Select-clear-zone { - -webkit-animation: Select-animation-fadeIn 200ms; - -o-animation: Select-animation-fadeIn 200ms; - animation: Select-animation-fadeIn 200ms; - color: #999; - cursor: pointer; - display: table-cell; - position: relative; - text-align: center; - vertical-align: middle; - width: 16px; - height: 16px; - padding-right: 4px; -} - -.Select-clear-zone:hover .Select-clear { - background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxNCAxNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjEuNDE0MjE7Ij4gICAgPGcgdHJhbnNmb3JtPSJtYXRyaXgoMC4wMjM0Mzc1LDAsMCwwLjAyMzQzNzUsLTUuMDE1NjIsLTUuMDE1NjIpIj4gICAgICAgIDxwYXRoIGQ9Ik04MTAsMjc0TDU3Miw1MTJMODEwLDc1MEw3NTAsODEwTDUxMiw1NzJMMjc0LDgxMEwyMTQsNzUwTDQ1Miw1MTJMMjE0LDI3NEwyNzQsMjE0TDUxMiw0NTJMNzUwLDIxNEw4MTAsMjc0WiIgc3R5bGU9ImZpbGw6cmdiKDIzMSwyMCw1Nik7ZmlsbC1ydWxlOm5vbnplcm87Ii8+ICAgIDwvZz48L3N2Zz4=); -} - -.Select-clear { - display: block; - width: 9px; - height: 9px; - background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxNCAxNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjEuNDE0MjE7Ij4gICAgPGcgdHJhbnNmb3JtPSJtYXRyaXgoMC4wMjM0Mzc1LDAsMCwwLjAyMzQzNzUsLTUuMDE1NjIsLTUuMDE1NjIpIj4gICAgICAgIDxwYXRoIGQ9Ik04MTAsMjc0TDU3Miw1MTJMODEwLDc1MEw3NTAsODEwTDUxMiw1NzJMMjc0LDgxMEwyMTQsNzUwTDQ1Miw1MTJMMjE0LDI3NEwyNzQsMjE0TDUxMiw0NTJMNzUwLDIxNEw4MTAsMjc0WiIgc3R5bGU9ImZpbGw6cmdiKDE1MywxNTMsMTUzKTtmaWxsLXJ1bGU6bm9uemVybzsiLz4gICAgPC9nPjwvc3ZnPg==); - background-size: 9px 9px; - text-indent: -9999px; -} - -.Select--multi .Select-clear-zone { - width: 17px; -} - -.Select-arrow-zone { - cursor: pointer; - display: table-cell; - position: relative; - text-align: center; - vertical-align: middle; - width: 20px; - padding-right: 5px; -} - -.Select-arrow { - border-color: #999 transparent transparent; - border-style: solid; - border-width: 4px 4px 2px; - display: inline-block; - height: 0; - width: 0; -} - -.is-open .Select-arrow, -.Select-arrow-zone:hover > .Select-arrow { - border-top-color: #666; -} - -@-webkit-keyframes Select-animation-fadeIn { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -@keyframes Select-animation-fadeIn { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -.Select-menu-outer { - border-bottom-right-radius: 4px; - border-bottom-left-radius: 4px; - background-color: #fff; - border: 1px solid #ccc; - border-top-color: var(--barBorderColor); - box-sizing: border-box; - margin-top: -1px; - max-height: 200px; - position: absolute; - top: 100%; - width: 100%; - z-index: var(--dropdownMenuZIndex); - -webkit-overflow-scrolling: touch; - box-shadow: var(--defaultShadow); -} - -.Select-menu { - max-height: 198px; - padding: 5px 0; - overflow-y: auto; -} - -.Select-option { - display: block; - line-height: 20px; - padding: 0 8px; - box-sizing: border-box; - color: var(--baseFontColor); - font-size: var(--smallFontSize); - cursor: pointer; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -.Select-option:last-child { - border-bottom-right-radius: 2px; - border-bottom-left-radius: 2px; -} - -.Select-option.is-focused { - background-color: var(--barBackgroundColor); -} - -.Select-option.is-disabled { - cursor: default; - opacity: 0.4; - font-style: italic; -} - -.Select-noresults { - box-sizing: border-box; - color: var(--gray60); - cursor: default; - display: block; - padding: 8px 10px; -} - -.Select--multi .Select-value { - background-color: rgba(0, 126, 255, 0.08); - border-radius: 2px; - border: 1px solid rgba(0, 126, 255, 0.24); - color: var(--baseFontColor); - display: inline-block; - font-size: var(--smallFontSize); - line-height: 14px; - margin: 1px 4px 1px 1px; - vertical-align: top; -} - -.Select-value-label { - font-size: var(--smallFontSize); -} - -.is-searchable.is-open .Select-value-label { - opacity: 0.5; -} - -.Select-big .Select-control { - padding-top: 4px; - padding-bottom: 4px; -} - -.Select-big .Select-placeholder { - margin-top: 4px; - margin-bottom: 4px; -} - -.Select-big .Select-value-label { - display: inline-block; - margin-top: 7px; - line-height: 16px; -} - -.Select-big .Select-option { - padding: 7px 8px; - line-height: 16px; -} - -.Select-big img, -.Select-big svg { - padding-top: 0; -} - -.Select--multi .Select-value-icon, -.Select--multi .Select-value-label { - display: inline-block; - vertical-align: middle; -} - -.Select--multi .Select-value-label { - display: inline-block; - max-width: 200px; - border-bottom-right-radius: 2px; - border-top-right-radius: 2px; - cursor: default; - padding: 2px 5px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.Select--multi a.Select-value-label { - color: #007eff; - cursor: pointer; - text-decoration: none; -} - -.Select--multi a.Select-value-label:hover { - text-decoration: underline; -} - -.Select--multi .Select-value-icon { - cursor: pointer; - border-bottom-left-radius: 2px; - border-top-left-radius: 2px; - border-right: 1px solid rgba(0, 126, 255, 0.24); - padding: 1px 5px; -} - -.Select--multi .Select-value-icon:hover, -.Select--multi .Select-value-icon:focus { - background-color: rgba(0, 113, 230, 0.08); - color: #0071e6; -} - -.Select--multi .Select-value-icon:active { - background-color: rgba(0, 126, 255, 0.24); -} - -.Select--multi.is-disabled .Select-value { - background-color: #fcfcfc; - border: 1px solid #e3e3e3; - color: var(--baseFontColor); -} - -.Select--multi.is-disabled .Select-value-icon { - cursor: not-allowed; - border-right: 1px solid #e3e3e3; -} - -.Select--multi.is-disabled .Select-value-icon:hover, -.Select--multi.is-disabled .Select-value-icon:focus, -.Select--multi.is-disabled .Select-value-icon:active { - background-color: #fcfcfc; -} - -.Select-aria-only { - display: none; -} - -@keyframes Select-animation-spin { - to { - transform: rotate(1turn); - } -} - -@-webkit-keyframes Select-animation-spin { - to { - -webkit-transform: rotate(1turn); - } -} diff --git a/server/sonar-ui-common/components/controls/Select.tsx b/server/sonar-ui-common/components/controls/Select.tsx deleted file mode 100644 index f100c9a2cde..00000000000 --- a/server/sonar-ui-common/components/controls/Select.tsx +++ /dev/null @@ -1,72 +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 { - defaultFilterOptions as reactSelectDefaultFilterOptions, - ReactAsyncSelectProps, - ReactCreatableSelectProps, - ReactSelectProps, -} from 'react-select'; -import { lazyLoadComponent } from '../lazyLoadComponent'; -import { ClearButton } from './buttons'; -import './Select.css'; - -declare module 'react-select' { - export function defaultFilterOptions(...args: any[]): any; -} - -const ReactSelectLib = import('react-select'); -const ReactSelect = lazyLoadComponent(() => ReactSelectLib); -const ReactCreatable = lazyLoadComponent(() => - ReactSelectLib.then((lib) => ({ default: lib.Creatable })) -); -const ReactAsync = lazyLoadComponent(() => ReactSelectLib.then((lib) => ({ default: lib.Async }))); - -function renderInput() { - return <ClearButton className="button-tiny spacer-left text-middle" iconProps={{ size: 12 }} />; -} - -interface WithInnerRef { - innerRef?: (element: React.Component) => void; -} - -export default function Select({ innerRef, ...props }: WithInnerRef & ReactSelectProps) { - // TODO try to define good defaults, if any - // ReactSelect doesn't declare `clearRenderer` prop - const ReactSelectAny = ReactSelect as any; - // hide the "x" icon when select is empty - const clearable = props.clearable ? Boolean(props.value) : false; - return ( - <ReactSelectAny {...props} clearable={clearable} clearRenderer={renderInput} ref={innerRef} /> - ); -} - -export const defaultFilterOptions = reactSelectDefaultFilterOptions; - -export function Creatable(props: ReactCreatableSelectProps) { - // ReactSelect doesn't declare `clearRenderer` prop - const ReactCreatableAny = ReactCreatable as any; - return <ReactCreatableAny {...props} clearRenderer={renderInput} />; -} - -// TODO figure out why `ref` prop is incompatible -export function AsyncSelect(props: ReactAsyncSelectProps & { ref?: any }) { - return <ReactAsync {...props} />; -} diff --git a/server/sonar-ui-common/components/controls/SelectList.css b/server/sonar-ui-common/components/controls/SelectList.css deleted file mode 100644 index 30b95c80033..00000000000 --- a/server/sonar-ui-common/components/controls/SelectList.css +++ /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. - */ -.select-list-container { - min-width: 500px; - box-sizing: border-box; -} - -.select-list-control { - margin-bottom: 10px; - box-sizing: border-box; -} - -.select-list-list-container { - border: 1px solid #bfbfbf; - box-sizing: border-box; - height: 400px; - overflow: auto; -} - -.select-list-list-checkbox { - display: flex !important; - align-items: center; -} - -.select-list-list-checkbox i { - display: inline-block; - vertical-align: middle; - margin-right: 10px; -} - -.select-list-list-disabled { - cursor: not-allowed; -} - -.select-list-list-disabled > a { - pointer-events: none; -} - -.select-list-list-item { - display: inline-block; - vertical-align: middle; -} diff --git a/server/sonar-ui-common/components/controls/SelectList.tsx b/server/sonar-ui-common/components/controls/SelectList.tsx deleted file mode 100644 index 1e49c82d3ed..00000000000 --- a/server/sonar-ui-common/components/controls/SelectList.tsx +++ /dev/null @@ -1,189 +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 ListFooter from './ListFooter'; -import RadioToggle from './RadioToggle'; -import SearchBox from './SearchBox'; -import './SelectList.css'; -import SelectListListContainer from './SelectListListContainer'; - -export enum SelectListFilter { - All = 'all', - Selected = 'selected', - Unselected = 'deselected', -} - -interface Props { - allowBulkSelection?: boolean; - elements: string[]; - elementsTotalCount?: number; - disabledElements?: string[]; - labelSelected?: string; - labelUnselected?: string; - labelAll?: string; - needToReload?: boolean; - onSearch: (searchParams: SelectListSearchParams) => Promise<void>; - onSelect: (element: string) => Promise<void>; - onUnselect: (element: string) => Promise<void>; - pageSize?: number; - readOnly?: boolean; - renderElement: (element: string) => React.ReactNode; - selectedElements: string[]; - withPaging?: boolean; -} - -export interface SelectListSearchParams { - filter: SelectListFilter; - page?: number; - pageSize?: number; - query: string; -} - -interface State { - lastSearchParams: SelectListSearchParams; - loading: boolean; -} - -const DEFAULT_PAGE_SIZE = 100; - -export default class SelectList extends React.PureComponent<Props, State> { - mounted = false; - - constructor(props: Props) { - super(props); - - this.state = { - lastSearchParams: { - filter: SelectListFilter.Selected, - page: 1, - pageSize: props.pageSize ? props.pageSize : DEFAULT_PAGE_SIZE, - query: '', - }, - loading: false, - }; - } - - componentDidMount() { - this.mounted = true; - this.search({}); - } - - componentWillUnmount() { - this.mounted = false; - } - - stopLoading = () => { - if (this.mounted) { - this.setState({ loading: false }); - } - }; - - getFilter = () => - this.state.lastSearchParams.query === '' - ? this.state.lastSearchParams.filter - : SelectListFilter.All; - - search = (searchParams: Partial<SelectListSearchParams>) => - this.setState( - (prevState) => ({ - loading: true, - lastSearchParams: { ...prevState.lastSearchParams, ...searchParams }, - }), - () => - this.props - .onSearch({ - filter: this.getFilter(), - page: this.props.withPaging ? this.state.lastSearchParams.page : undefined, - pageSize: this.props.withPaging ? this.state.lastSearchParams.pageSize : undefined, - query: this.state.lastSearchParams.query, - }) - .then(this.stopLoading) - .catch(this.stopLoading) - ); - - changeFilter = (filter: SelectListFilter) => this.search({ filter, page: 1 }); - - handleQueryChange = (query: string) => this.search({ page: 1, query }); - - onLoadMore = () => - this.search({ - page: - this.state.lastSearchParams.page != null ? this.state.lastSearchParams.page + 1 : undefined, - }); - - onReload = () => this.search({ page: 1 }); - - render() { - const { - labelSelected = translate('selected'), - labelUnselected = translate('unselected'), - labelAll = translate('all'), - } = this.props; - const { filter } = this.state.lastSearchParams; - - const disabled = this.state.lastSearchParams.query !== ''; - - return ( - <div className="select-list"> - <div className="display-flex-center"> - <RadioToggle - className="select-list-filter spacer-right" - name="filter" - onCheck={this.changeFilter} - options={[ - { disabled, label: labelSelected, value: SelectListFilter.Selected }, - { disabled, label: labelUnselected, value: SelectListFilter.Unselected }, - { disabled, label: labelAll, value: SelectListFilter.All }, - ]} - value={filter} - /> - <SearchBox - autoFocus={true} - loading={this.state.loading} - onChange={this.handleQueryChange} - placeholder={translate('search_verb')} - value={this.state.lastSearchParams.query} - /> - </div> - <SelectListListContainer - allowBulkSelection={this.props.allowBulkSelection} - disabledElements={this.props.disabledElements || []} - elements={this.props.elements} - filter={this.getFilter()} - onSelect={this.props.onSelect} - onUnselect={this.props.onUnselect} - readOnly={this.props.readOnly} - renderElement={this.props.renderElement} - selectedElements={this.props.selectedElements} - /> - {!!this.props.elementsTotalCount && ( - <ListFooter - count={this.props.elements.length} - loadMore={this.onLoadMore} - needReload={this.props.needToReload} - reload={this.onReload} - total={this.props.elementsTotalCount} - /> - )} - </div> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/SelectListListContainer.tsx b/server/sonar-ui-common/components/controls/SelectListListContainer.tsx deleted file mode 100644 index c39d45133c7..00000000000 --- a/server/sonar-ui-common/components/controls/SelectListListContainer.tsx +++ /dev/null @@ -1,129 +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 DeferredSpinner from '../ui/DeferredSpinner'; -import Checkbox from './Checkbox'; -import { SelectListFilter } from './SelectList'; -import SelectListListElement from './SelectListListElement'; - -interface Props { - allowBulkSelection?: boolean; - elements: string[]; - disabledElements: string[]; - filter: SelectListFilter; - onSelect: (element: string) => Promise<void>; - onUnselect: (element: string) => Promise<void>; - readOnly?: boolean; - renderElement: (element: string) => React.ReactNode; - selectedElements: string[]; -} - -interface State { - loading: boolean; -} - -export default class SelectListListContainer extends React.PureComponent<Props, State> { - mounted = false; - state: State = { loading: false }; - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - stopLoading = () => { - if (this.mounted) { - this.setState({ loading: false }); - } - }; - - isDisabled = (element: string): boolean => { - return this.props.readOnly || this.props.disabledElements.includes(element); - }; - - isSelected = (element: string): boolean => { - return this.props.selectedElements.includes(element); - }; - - handleBulkChange = (checked: boolean) => { - this.setState({ loading: true }); - if (checked) { - Promise.all(this.props.elements.map((element) => this.props.onSelect(element))) - .then(this.stopLoading) - .catch(this.stopLoading); - } else { - Promise.all(this.props.selectedElements.map((element) => this.props.onUnselect(element))) - .then(this.stopLoading) - .catch(this.stopLoading); - } - }; - - renderBulkSelector() { - const { elements, readOnly, selectedElements } = this.props; - return ( - <> - <li> - <Checkbox - checked={selectedElements.length > 0} - disabled={this.state.loading || readOnly} - onCheck={this.handleBulkChange} - thirdState={selectedElements.length > 0 && elements.length !== selectedElements.length}> - <span className="big-spacer-left"> - {translate('bulk_change')} - <DeferredSpinner className="spacer-left" loading={this.state.loading} timeout={10} /> - </span> - </Checkbox> - </li> - <li className="divider" /> - </> - ); - } - - render() { - const { allowBulkSelection, elements, filter } = this.props; - - return ( - <div className={classNames('select-list-list-container spacer-top')}> - <ul className="menu"> - {allowBulkSelection && - elements.length > 0 && - filter === SelectListFilter.All && - this.renderBulkSelector()} - {elements.map((element) => ( - <SelectListListElement - disabled={this.isDisabled(element)} - element={element} - key={element} - onSelect={this.props.onSelect} - onUnselect={this.props.onUnselect} - renderElement={this.props.renderElement} - selected={this.isSelected(element)} - /> - ))} - </ul> - </div> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/SelectListListElement.tsx b/server/sonar-ui-common/components/controls/SelectListListElement.tsx deleted file mode 100644 index defd493f344..00000000000 --- a/server/sonar-ui-common/components/controls/SelectListListElement.tsx +++ /dev/null @@ -1,76 +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 Checkbox from './Checkbox'; - -interface Props { - active?: boolean; - disabled?: boolean; - element: string; - onSelect: (element: string) => Promise<void>; - onUnselect: (element: string) => Promise<void>; - renderElement: (element: string) => React.ReactNode; - selected: boolean; -} - -interface State { - loading: boolean; -} - -export default class SelectListListElement extends React.PureComponent<Props, State> { - mounted = false; - state: State = { loading: false }; - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - stopLoading = () => { - if (this.mounted) { - this.setState({ loading: false }); - } - }; - - handleCheck = (checked: boolean) => { - this.setState({ loading: true }); - const request = checked ? this.props.onSelect : this.props.onUnselect; - request(this.props.element).then(this.stopLoading, this.stopLoading); - }; - - render() { - return ( - <li className={classNames({ 'select-list-list-disabled': this.props.disabled })}> - <Checkbox - checked={this.props.selected} - className={classNames('select-list-list-checkbox', { active: this.props.active })} - disabled={this.props.disabled} - loading={this.state.loading} - onCheck={this.handleCheck}> - <span className="little-spacer-left">{this.props.renderElement(this.props.element)}</span> - </Checkbox> - </li> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/SimpleModal.tsx b/server/sonar-ui-common/components/controls/SimpleModal.tsx deleted file mode 100644 index a0b8bc103b3..00000000000 --- a/server/sonar-ui-common/components/controls/SimpleModal.tsx +++ /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. - */ -import * as React from 'react'; -import Modal, { ModalProps } from './Modal'; - -export interface ChildrenProps { - onCloseClick: (event?: React.SyntheticEvent<HTMLElement>) => void; - onFormSubmit: (event: React.SyntheticEvent<HTMLFormElement>) => void; - onSubmitClick: (event?: React.SyntheticEvent<HTMLElement>) => void; - submitting: boolean; -} - -interface Props extends ModalProps { - children: (props: ChildrenProps) => React.ReactNode; - header: string; - onClose: () => void; - onSubmit: () => void | Promise<void | Response>; -} - -interface State { - submitting: boolean; -} - -export default class SimpleModal extends React.Component<Props, State> { - mounted = false; - state: State = { submitting: false }; - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - stopSubmitting = () => { - if (this.mounted) { - this.setState({ submitting: false }); - } - }; - - handleCloseClick = (event?: React.SyntheticEvent<HTMLElement>) => { - if (event) { - event.preventDefault(); - event.currentTarget.blur(); - } - this.props.onClose(); - }; - - handleFormSubmit = (event: React.SyntheticEvent<HTMLFormElement>) => { - event.preventDefault(); - this.submit(); - }; - - handleSubmitClick = (event?: React.SyntheticEvent<HTMLElement>) => { - if (event) { - event.preventDefault(); - event.currentTarget.blur(); - } - this.submit(); - }; - - submit = () => { - const result = this.props.onSubmit(); - if (result) { - this.setState({ submitting: true }); - result.then(this.stopSubmitting, this.stopSubmitting); - } - }; - - render() { - const { children, header, onClose, onSubmit, ...modalProps } = this.props; - return ( - <Modal contentLabel={header} onRequestClose={onClose} {...modalProps}> - {children({ - onCloseClick: this.handleCloseClick, - onFormSubmit: this.handleFormSubmit, - onSubmitClick: this.handleSubmitClick, - submitting: this.state.submitting, - })} - </Modal> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/Tabs.css b/server/sonar-ui-common/components/controls/Tabs.css deleted file mode 100644 index 334fe14f255..00000000000 --- a/server/sonar-ui-common/components/controls/Tabs.css +++ /dev/null @@ -1,60 +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. - */ -.flex-tabs { - display: flex; - clear: left; - margin-bottom: calc(3 * var(--gridSize)); - border-bottom: 1px solid var(--barBorderColor); - font-size: var(--mediumFontSize); -} - -.flex-tabs > li > a { - position: relative; - display: block; - top: 1px; - height: 100%; - width: 100%; - box-sizing: border-box; - color: var(--secondFontColor); - font-weight: 600; - cursor: pointer; - padding-bottom: calc(1.5 * var(--gridSize)); - border-bottom: 3px solid transparent; - transition: color 0.2s ease; -} - -.flex-tabs > li ~ li { - margin-left: calc(4 * var(--gridSize)); -} - -.flex-tabs > li > a:hover { - color: var(--baseFontColor); -} - -.flex-tabs > li > a.selected { - color: var(--blue); - border-bottom-color: var(--blue); -} - -.flex-tabs > li > a.disabled { - color: var(--disableGrayText) !important; - cursor: not-allowed !important; - pointer-events: none !important; -} diff --git a/server/sonar-ui-common/components/controls/Tabs.tsx b/server/sonar-ui-common/components/controls/Tabs.tsx deleted file mode 100644 index b187255ad46..00000000000 --- a/server/sonar-ui-common/components/controls/Tabs.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 * as React from 'react'; -import './Tabs.css'; - -interface Props<T extends string> { - onChange: (tab: T) => void; - selected?: T; - tabs: Array<{ disabled?: boolean; key: T; node: React.ReactNode }>; -} - -export default function Tabs<T extends string>({ onChange, selected, tabs }: Props<T>) { - return ( - <ul className="flex-tabs"> - {tabs.map((tab) => ( - <Tab - disabled={tab.disabled} - key={tab.key} - name={tab.key} - onSelect={onChange} - selected={selected === tab.key}> - {tab.node} - </Tab> - ))} - </ul> - ); -} - -interface TabProps<T> { - children: React.ReactNode; - disabled?: boolean; - name: T; - onSelect: (tab: T) => void; - selected: boolean; -} - -export class Tab<T> extends React.PureComponent<TabProps<T>> { - handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => { - event.preventDefault(); - event.stopPropagation(); - if (!this.props.disabled) { - this.props.onSelect(this.props.name); - } - }; - - render() { - const { children, disabled, name, selected } = this.props; - return ( - <li> - <a - className={classNames('js-' + name, { disabled, selected })} - href="#" - onClick={this.handleClick}> - {children} - </a> - </li> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/Toggle.css b/server/sonar-ui-common/components/controls/Toggle.css deleted file mode 100644 index f9b0cfeb75b..00000000000 --- a/server/sonar-ui-common/components/controls/Toggle.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. - */ -.button.boolean-toggle { - display: inline-block; - vertical-align: middle; - width: 48px; - height: var(--controlHeight); - padding: 1px; - border: 1px solid var(--gray80); - border-radius: var(--controlHeight); - box-sizing: border-box; - background-color: #fff; - cursor: pointer; - transition: all 0.3s ease; -} - -.button.boolean-toggle:hover { - background-color: #fff; -} - -.button.boolean-toggle:focus { - border-color: var(--blue); - background-color: #f6f6f6; -} - -.boolean-toggle-handle { - display: flex; - justify-content: center; - align-items: center; - width: 20px; - height: 20px; - border: 1px solid var(--gray80); - border-radius: 22px; - box-sizing: border-box; - background-color: #f6f6f6; - transition: transform 0.3s cubic-bezier(0.87, -0.41, 0.19, 1.44), border 0.3s ease; -} - -.boolean-toggle-handle > * { - opacity: 0; - transition: opacity 0.3s ease; -} - -.button.boolean-toggle-on { - border-color: var(--darkBlue); - background-color: var(--darkBlue); - color: var(--darkBlue); -} - -.button.boolean-toggle-on:hover { - background-color: var(--darkBlue); -} - -.button.boolean-toggle-on:focus { - background-color: var(--darkBlue); -} - -.button.boolean-toggle-on .boolean-toggle-handle { - border-color: #f6f6f6; - transform: translateX(var(--controlHeight)); -} - -.button.boolean-toggle-on .boolean-toggle-handle > * { - opacity: 1; -} diff --git a/server/sonar-ui-common/components/controls/Toggle.tsx b/server/sonar-ui-common/components/controls/Toggle.tsx deleted file mode 100644 index 52448e8b074..00000000000 --- a/server/sonar-ui-common/components/controls/Toggle.tsx +++ /dev/null @@ -1,60 +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 CheckIcon from '../icons/CheckIcon'; -import { Button } from './buttons'; -import './Toggle.css'; - -interface Props { - disabled?: boolean; - name?: string; - onChange?: (value: boolean) => void; - value: boolean | string; -} - -export default class Toggle extends React.PureComponent<Props> { - getValue = () => { - const { value } = this.props; - return typeof value === 'string' ? value === 'true' : value; - }; - - handleClick = () => { - if (this.props.onChange) { - const value = this.getValue(); - this.props.onChange(!value); - } - }; - - render() { - const { disabled, name } = this.props; - const value = this.getValue(); - const className = classNames('boolean-toggle', { 'boolean-toggle-on': value }); - - return ( - <Button className={className} disabled={disabled} name={name} onClick={this.handleClick}> - <div aria-label={translate(value ? 'on' : 'off')} className="boolean-toggle-handle"> - <CheckIcon size={12} /> - </div> - </Button> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/Toggler.tsx b/server/sonar-ui-common/components/controls/Toggler.tsx deleted file mode 100644 index b610a9b9fd5..00000000000 --- a/server/sonar-ui-common/components/controls/Toggler.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 * as React from 'react'; -import DocumentClickHandler from './DocumentClickHandler'; -import EscKeydownHandler from './EscKeydownHandler'; -import OutsideClickHandler from './OutsideClickHandler'; - -interface Props { - children?: React.ReactNode; - closeOnClick?: boolean; - closeOnClickOutside?: boolean; - closeOnEscape?: boolean; - onRequestClose: () => void; - open: boolean; - overlay: React.ReactNode; -} - -export default class Toggler extends React.Component<Props> { - renderOverlay() { - const { - closeOnClick = false, - closeOnClickOutside = true, - closeOnEscape = true, - onRequestClose, - overlay, - } = this.props; - - let renderedOverlay; - if (closeOnEscape) { - renderedOverlay = <EscKeydownHandler onKeydown={onRequestClose}>{overlay}</EscKeydownHandler>; - } else { - renderedOverlay = overlay; - } - - if (closeOnClick) { - return ( - <DocumentClickHandler onClick={onRequestClose}>{renderedOverlay}</DocumentClickHandler> - ); - } else if (closeOnClickOutside) { - return ( - <OutsideClickHandler onClickOutside={onRequestClose}>{renderedOverlay}</OutsideClickHandler> - ); - } else { - return renderedOverlay; - } - } - - render() { - return ( - <> - {this.props.children} - {this.props.open && this.renderOverlay()} - </> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/Tooltip.css b/server/sonar-ui-common/components/controls/Tooltip.css deleted file mode 100644 index d49494f1f77..00000000000 --- a/server/sonar-ui-common/components/controls/Tooltip.css +++ /dev/null @@ -1,134 +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. - */ -.tooltip { - position: absolute; - z-index: var(--tooltipZIndex); - display: block; - height: auto; - box-sizing: border-box; - font-size: var(--baseFontSize); - font-weight: 300; - line-height: 1.5; - animation: fadeIn 0.3s forwards; -} - -.tooltip.top { - padding: 5px 0; - margin-top: -3px; -} - -.tooltip.right { - padding: 0 5px; - margin-left: 3px; -} - -.tooltip.bottom { - padding: 5px 0; - margin-top: 3px; -} - -.tooltip.left { - padding: 0 5px; - margin-left: -3px; -} - -.tooltip-inner { - max-width: 300px; - text-align: left; - text-decoration: none; - border-radius: 4px; - overflow: hidden; - word-break: break-word; -} - -.tooltip-inner { - padding: 12px 17px; - color: #fff; - background-color: #475760; - letter-spacing: 0.04em; -} - -.tooltip-inner .alert { - margin-bottom: 5px; - border-radius: 4px; -} - -.tooltip-inner a { - border-bottom-color: #8da6b3; - color: #a5d0ea; -} - -.tooltip-inner hr { - background-color: #5d6d75; -} - -.tooltip-arrow { - position: absolute; - width: 0; - height: 0; - border: solid transparent; -} - -.tooltip.top .tooltip-arrow { - bottom: 0; - left: 50%; - border-width: 5px 5px 0; - transform: translateX(-5px); - border-top-color: #475760; -} - -.tooltip.right .tooltip-arrow { - top: 50%; - left: 0; - transform: translateY(-5px); - border-width: 5px 5px 5px 0; - border-right-color: #475760; -} - -.tooltip.left .tooltip-arrow { - top: 50%; - right: 0; - transform: translateY(-5px); - border-width: 5px 0 5px 5px; - border-left-color: #475760; -} - -.tooltip.bottom .tooltip-arrow { - top: 0; - left: 50%; - transform: translateX(-5px); - border-width: 0 5px 5px; - border-bottom-color: #475760; -} - -/* Workaround for react issue with onMouseLeave in disabled buttons: https://github.com/facebook/react/issues/4251 */ -.tooltip button[disabled] { - pointer-events: none; -} - -@keyframes fadeIn { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} diff --git a/server/sonar-ui-common/components/controls/Tooltip.tsx b/server/sonar-ui-common/components/controls/Tooltip.tsx deleted file mode 100644 index de4f670a637..00000000000 --- a/server/sonar-ui-common/components/controls/Tooltip.tsx +++ /dev/null @@ -1,407 +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 { throttle } from 'lodash'; -import * as React from 'react'; -import { createPortal, findDOMNode } from 'react-dom'; -import ThemeContext from '../theme'; -import ScreenPositionFixer from './ScreenPositionFixer'; -import './Tooltip.css'; - -export type Placement = 'bottom' | 'right' | 'left' | 'top'; - -export interface TooltipProps { - classNameSpace?: string; - children: React.ReactElement<{}>; - mouseEnterDelay?: number; - mouseLeaveDelay?: number; - onShow?: () => void; - onHide?: () => void; - overlay: React.ReactNode; - placement?: Placement; - visible?: boolean; -} - -interface Measurements { - height: number; - left: number; - top: number; - width: number; -} - -interface OwnState { - flipped: boolean; - placement?: Placement; - visible: boolean; -} - -type State = OwnState & Partial<Measurements>; - -const FLIP_MAP: { [key in Placement]: Placement } = { - left: 'right', - right: 'left', - top: 'bottom', - bottom: 'top', -}; - -function isMeasured(state: State): state is OwnState & Measurements { - return state.height !== undefined; -} - -export default function Tooltip(props: TooltipProps) { - // overlay is a ReactNode, so it can be `undefined` or `null` - // this allows to easily render a tooltip conditionally - // more generaly we avoid rendering empty tooltips - return props.overlay != null && props.overlay !== '' ? ( - <TooltipInner {...props} /> - ) : ( - props.children - ); -} - -export class TooltipInner extends React.Component<TooltipProps, State> { - throttledPositionTooltip: () => void; - mouseEnterTimeout?: number; - mouseLeaveTimeout?: number; - tooltipNode?: HTMLElement | null; - mounted = false; - mouseIn = false; - - static defaultProps = { - mouseEnterDelay: 0.1, - }; - - constructor(props: TooltipProps) { - super(props); - this.state = { - flipped: false, - placement: props.placement, - visible: props.visible !== undefined ? props.visible : false, - }; - this.throttledPositionTooltip = throttle(this.positionTooltip, 10); - } - - componentDidMount() { - this.mounted = true; - if (this.props.visible === true) { - this.positionTooltip(); - this.addEventListeners(); - } - } - - componentDidUpdate(prevProps: TooltipProps, prevState: State) { - if (this.props.placement !== prevProps.placement) { - this.setState({ placement: this.props.placement }); - // Break. This will trigger a new componentDidUpdate() call, so the below - // positionTooltip() call will be correct. Otherwise, it might not use - // the new state.placement value. - return; - } - - if ( - // opens - (this.props.visible === true && !prevProps.visible) || - (this.props.visible === undefined && - this.state.visible === true && - prevState.visible === false) - ) { - this.positionTooltip(); - this.addEventListeners(); - } else if ( - // closes - (!this.props.visible && prevProps.visible === true) || - (this.props.visible === undefined && - this.state.visible === false && - prevState.visible === true) - ) { - this.clearPosition(); - this.removeEventListeners(); - } - } - - componentWillUnmount() { - this.mounted = false; - this.removeEventListeners(); - this.clearTimeouts(); - } - - static contextType = ThemeContext; - - addEventListeners = () => { - window.addEventListener('resize', this.throttledPositionTooltip); - window.addEventListener('scroll', this.throttledPositionTooltip); - }; - - removeEventListeners = () => { - window.removeEventListener('resize', this.throttledPositionTooltip); - window.removeEventListener('scroll', this.throttledPositionTooltip); - }; - - clearTimeouts = () => { - window.clearTimeout(this.mouseEnterTimeout); - window.clearTimeout(this.mouseLeaveTimeout); - }; - - isVisible = () => { - return this.props.visible !== undefined ? this.props.visible : this.state.visible; - }; - - getPlacement = (): Placement => { - return this.state.placement || 'bottom'; - }; - - tooltipNodeRef = (node: HTMLElement | null) => { - this.tooltipNode = node; - }; - - adjustArrowPosition = ( - placement: Placement, - { leftFix, topFix }: { leftFix: number; topFix: number } - ) => { - switch (placement) { - case 'left': - case 'right': - return { marginTop: -topFix }; - default: - return { marginLeft: -leftFix }; - } - }; - - positionTooltip = () => { - // `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.tooltipNode) { - const toggleRect = toggleNode.getBoundingClientRect(); - const tooltipRect = this.tooltipNode.getBoundingClientRect(); - const { width, height } = tooltipRect; - - let left = 0; - let top = 0; - - switch (this.getPlacement()) { - case 'bottom': - left = toggleRect.left + toggleRect.width / 2 - width / 2; - top = toggleRect.top + toggleRect.height; - break; - case 'top': - left = toggleRect.left + toggleRect.width / 2 - width / 2; - top = toggleRect.top - height; - break; - case 'right': - left = toggleRect.left + toggleRect.width; - top = toggleRect.top + toggleRect.height / 2 - height / 2; - break; - case 'left': - left = toggleRect.left - width; - top = toggleRect.top + toggleRect.height / 2 - height / 2; - break; - } - - // save width and height (and later set in `render`) to avoid resizing the tooltip element, - // when it's placed close to the window edge - this.setState({ - left: window.pageXOffset + left, - top: window.pageYOffset + top, - width, - height, - }); - } - }; - - clearPosition = () => { - this.setState({ - flipped: false, - left: undefined, - top: undefined, - width: undefined, - height: undefined, - placement: this.props.placement, - }); - }; - - handleMouseEnter = () => { - this.mouseEnterTimeout = window.setTimeout(() => { - // for some reason even after the `this.mouseEnterTimeout` is cleared, it still triggers - // to workaround this issue, check that its value is not `undefined` - // (if it's `undefined`, it means the timer has been reset) - if ( - this.mounted && - this.props.visible === undefined && - this.mouseEnterTimeout !== undefined - ) { - this.setState({ visible: true }); - } - }, (this.props.mouseEnterDelay || 0) * 1000); - - if (this.props.onShow) { - this.props.onShow(); - } - }; - - handleMouseLeave = () => { - if (this.mouseEnterTimeout !== undefined) { - window.clearTimeout(this.mouseEnterTimeout); - this.mouseEnterTimeout = undefined; - } - - if (!this.mouseIn) { - this.mouseLeaveTimeout = window.setTimeout(() => { - if (this.mounted && this.props.visible === undefined && !this.mouseIn) { - this.setState({ visible: false }); - } - }, (this.props.mouseLeaveDelay || 0) * 1000); - - if (this.props.onHide) { - this.props.onHide(); - } - } - }; - - handleOverlayMouseEnter = () => { - this.mouseIn = true; - }; - - handleOverlayMouseLeave = () => { - this.mouseIn = false; - this.handleMouseLeave(); - }; - - needsFlipping = (leftFix: number, topFix: number) => { - // We can live with a tooltip that's slightly positioned over the toggle - // node. Only trigger if it really starts overlapping, as the re-positioning - // is quite expensive, needing 2 re-renders. - const threshold = this.context.rawSizes.grid; - switch (this.getPlacement()) { - case 'left': - case 'right': - return Math.abs(leftFix) > threshold; - case 'top': - case 'bottom': - return Math.abs(topFix) > threshold; - } - return false; - }; - - renderActual = ({ leftFix = 0, topFix = 0 }) => { - if ( - !this.state.flipped && - (leftFix !== 0 || topFix !== 0) && - this.needsFlipping(leftFix, topFix) - ) { - // Update state in a render function... Not a good idea, but we need to - // render in order to know if we need to flip... To prevent React from - // complaining, we update the state using a setTimeout() call. - setTimeout(() => { - this.setState( - ({ placement = 'bottom' }) => ({ - flipped: true, - // Set height to undefined to force ScreenPositionFixer to - // re-compute our positioning. - height: undefined, - placement: FLIP_MAP[placement], - }), - () => { - if (this.state.visible) { - // Force a re-positioning, as "only" updating the state doesn't - // recompute the position, only re-renders with the previous - // position (which is no longer correct). - this.positionTooltip(); - } - } - ); - }, 1); - return null; - } - - const { classNameSpace = 'tooltip' } = this.props; - const placement = this.getPlacement(); - const style = isMeasured(this.state) - ? { - left: this.state.left + leftFix, - top: this.state.top + topFix, - width: this.state.width, - height: this.state.height, - } - : undefined; - - return ( - <div - className={`${classNameSpace} ${placement}`} - onMouseEnter={this.handleOverlayMouseEnter} - onMouseLeave={this.handleOverlayMouseLeave} - ref={this.tooltipNodeRef} - style={style}> - <div className={`${classNameSpace}-inner`}>{this.props.overlay}</div> - <div - className={`${classNameSpace}-arrow`} - style={ - isMeasured(this.state) - ? this.adjustArrowPosition(placement, { leftFix, topFix }) - : undefined - } - /> - </div> - ); - }; - - render() { - return ( - <> - {React.cloneElement(this.props.children, { - onMouseEnter: this.handleMouseEnter, - onMouseLeave: this.handleMouseLeave, - })} - {this.isVisible() && ( - <TooltipPortal> - <ScreenPositionFixer ready={isMeasured(this.state)}> - {this.renderActual} - </ScreenPositionFixer> - </TooltipPortal> - )} - </> - ); - } -} - -class TooltipPortal extends React.Component { - el: HTMLElement; - - constructor(props: {}) { - super(props); - this.el = document.createElement('div'); - } - - 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/controls/ValidationForm.tsx b/server/sonar-ui-common/components/controls/ValidationForm.tsx deleted file mode 100644 index 37e7127014a..00000000000 --- a/server/sonar-ui-common/components/controls/ValidationForm.tsx +++ /dev/null @@ -1,72 +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 { Formik, FormikActions, FormikProps } from 'formik'; -import * as React from 'react'; - -export type ChildrenProps<V> = T.Omit<FormikProps<V>, 'handleSubmit'>; - -interface Props<V> { - children: (props: ChildrenProps<V>) => React.ReactNode; - initialValues: V; - isInitialValid?: boolean; - onSubmit: (data: V) => Promise<void>; - validate: (data: V) => { [P in keyof V]?: string } | Promise<{ [P in keyof V]?: string }>; -} - -export default class ValidationForm<V> extends React.Component<Props<V>> { - mounted = false; - - componentDidMount() { - this.mounted = true; - } - - componentWillUnmount() { - this.mounted = false; - } - - handleSubmit = (data: V, { setSubmitting }: FormikActions<V>) => { - const result = this.props.onSubmit(data); - const stopSubmitting = () => { - if (this.mounted) { - setSubmitting(false); - } - }; - - if (result) { - result.then(stopSubmitting, stopSubmitting); - } else { - stopSubmitting(); - } - }; - - render() { - return ( - <Formik<V> - initialValues={this.props.initialValues} - isInitialValid={this.props.isInitialValid} - onSubmit={this.handleSubmit} - validate={this.props.validate}> - {({ handleSubmit, ...props }) => ( - <form onSubmit={handleSubmit}>{this.props.children(props)}</form> - )} - </Formik> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/ValidationInput.tsx b/server/sonar-ui-common/components/controls/ValidationInput.tsx deleted file mode 100644 index 1f966232028..00000000000 --- a/server/sonar-ui-common/components/controls/ValidationInput.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 React from 'react'; -import AlertErrorIcon from '../icons/AlertErrorIcon'; -import AlertSuccessIcon from '../icons/AlertSuccessIcon'; -import MandatoryFieldMarker from '../ui/MandatoryFieldMarker'; -import HelpTooltip from './HelpTooltip'; - -interface Props { - description?: React.ReactNode; - children: React.ReactNode; - className?: string; - error: string | undefined; - help?: string; - id: string; - isInvalid: boolean; - isValid: boolean; - label: React.ReactNode; - required?: boolean; -} - -export default function ValidationInput(props: Props) { - const hasError = props.isInvalid && props.error !== undefined; - return ( - <div className={props.className}> - <label htmlFor={props.id}> - <span className="text-middle"> - <strong>{props.label}</strong> - {props.required && <MandatoryFieldMarker />} - </span> - {props.help && <HelpTooltip className="spacer-left" overlay={props.help} />} - </label> - <div className="little-spacer-top spacer-bottom"> - {props.children} - {props.isInvalid && <AlertErrorIcon className="spacer-left text-middle" />} - {hasError && ( - <span className="little-spacer-left text-danger text-middle">{props.error}</span> - )} - {props.isValid && <AlertSuccessIcon className="spacer-left text-middle" />} - </div> - {props.description && <div className="note abs-width-400">{props.description}</div>} - </div> - ); -} diff --git a/server/sonar-ui-common/components/controls/ValidationModal.tsx b/server/sonar-ui-common/components/controls/ValidationModal.tsx deleted file mode 100644 index 7dd77c81eea..00000000000 --- a/server/sonar-ui-common/components/controls/ValidationModal.tsx +++ /dev/null @@ -1,83 +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 DeferredSpinner from '../ui/DeferredSpinner'; -import { ResetButtonLink, SubmitButton } from './buttons'; -import Modal, { ModalProps } from './Modal'; -import ValidationForm, { ChildrenProps } from './ValidationForm'; - -interface Props<V> extends ModalProps { - children: (props: ChildrenProps<V>) => React.ReactNode; - confirmButtonText: string; - header: string; - initialValues: V; - isDestructive?: boolean; - isInitialValid?: boolean; - onClose: () => void; - onSubmit: (data: V) => Promise<void>; - validate: (data: V) => { [P in keyof V]?: string }; -} - -export default class ValidationModal<V> extends React.PureComponent<Props<V>> { - handleSubmit = (data: V) => { - return this.props.onSubmit(data).then(() => { - this.props.onClose(); - }); - }; - - render() { - return ( - <Modal - contentLabel={this.props.header} - noBackdrop={this.props.noBackdrop} - onRequestClose={this.props.onClose} - size={this.props.size}> - <ValidationForm - initialValues={this.props.initialValues} - isInitialValid={this.props.isInitialValid} - onSubmit={this.handleSubmit} - validate={this.props.validate}> - {(props) => ( - <> - <header className="modal-head"> - <h2>{this.props.header}</h2> - </header> - - <div className="modal-body">{this.props.children(props)}</div> - - <footer className="modal-foot"> - <DeferredSpinner className="spacer-right" loading={props.isSubmitting} /> - <SubmitButton - className={this.props.isDestructive ? 'button-red' : undefined} - disabled={props.isSubmitting || !props.isValid || !props.dirty}> - {this.props.confirmButtonText} - </SubmitButton> - <ResetButtonLink disabled={props.isSubmitting} onClick={this.props.onClose}> - {translate('cancel')} - </ResetButtonLink> - </footer> - </> - )} - </ValidationForm> - </Modal> - ); - } -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ActionsDropdown-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ActionsDropdown-test.tsx deleted file mode 100644 index a74b20fd933..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ActionsDropdown-test.tsx +++ /dev/null @@ -1,92 +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. - */ -/* eslint-disable sonarjs/no-duplicate-string */ -import { mount, shallow } from 'enzyme'; -import * as React from 'react'; -import { click } from '../../../helpers/testUtils'; -import { PopupPlacement } from '../../ui/popups'; -import ActionsDropdown, { - ActionsDropdownDivider, - ActionsDropdownItem, - ActionsDropdownProps, -} from '../ActionsDropdown'; - -describe('ActionsDropdown', () => { - it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ small: false })).toMatchSnapshot(); - }); - - function shallowRender(props: Partial<ActionsDropdownProps> = {}) { - return shallow( - <ActionsDropdown - className="foo" - onOpen={jest.fn()} - overlayPlacement={PopupPlacement.Bottom} - small={true} - toggleClassName="bar" - {...props}> - <span>Hello world</span> - </ActionsDropdown> - ); - } -}); - -describe('ActionsDropdownItem', () => { - it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ destructive: true, id: 'baz', to: 'path/name' })).toMatchSnapshot(); - expect(shallowRender({ download: 'foo/bar', to: 'path/name' })).toMatchSnapshot(); - }); - - it('should trigger click', () => { - const onClick = jest.fn(); - const wrapper = shallowRender({ onClick }); - click(wrapper.find('a')); - expect(onClick).toBeCalled(); - }); - - it('should render correctly copy item', () => { - const wrapper = mountRender({ copyValue: 'my content to copy to clipboard' }); - expect(wrapper).toMatchSnapshot(); - }); - - function shallowRender(props: Partial<ActionsDropdownItem['props']> = {}) { - return shallow(renderContent(props)); - } - - function mountRender(props: Partial<ActionsDropdownItem['props']> = {}) { - return mount(renderContent(props)); - } - - function renderContent(props: Partial<ActionsDropdownItem['props']> = {}) { - return ( - <ActionsDropdownItem className="foo" {...props}> - <span>Hello world</span> - </ActionsDropdownItem> - ); - } -}); - -describe('ActionsDropdownDivider', () => { - it('should render correctly', () => { - expect(shallow(<ActionsDropdownDivider />)).toMatchSnapshot(); - }); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/BackButton-test.tsx b/server/sonar-ui-common/components/controls/__tests__/BackButton-test.tsx deleted file mode 100644 index 0f206076ad9..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/BackButton-test.tsx +++ /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. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import testTheme from '../../../config/jest/testTheme'; -import { click } from '../../../helpers/testUtils'; -import { ThemeProvider } from '../../theme'; -import BackButton from '../BackButton'; - -it('should render properly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find('ContextConsumer').dive()).toMatchSnapshot(); -}); - -it('should handle click', () => { - const onClick = jest.fn(); - const wrapper = shallowRender({ onClick }); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('a')); - expect(onClick).toBeCalled(); -}); - -function shallowRender(props: Partial<BackButton['props']> = {}) { - return shallow<BackButton>(<BackButton onClick={jest.fn()} {...props} />, { - wrappingComponent: ThemeProvider, - wrappingComponentProps: { - theme: testTheme, - }, - }); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/BoxedGroupAccordion-test.tsx b/server/sonar-ui-common/components/controls/__tests__/BoxedGroupAccordion-test.tsx deleted file mode 100644 index 970a3546c3a..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/BoxedGroupAccordion-test.tsx +++ /dev/null @@ -1,52 +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 BoxedGroupAccordion from '../BoxedGroupAccordion'; - -it('should render correctly', () => { - expect(getWrapper()).toMatchSnapshot(); -}); - -it('should show the inner content after a click', () => { - const onClick = jest.fn(); - const wrapper = getWrapper({ onClick }); - click(wrapper.find('.boxed-group-header')); - - expect(onClick).lastCalledWith('foo'); - wrapper.setProps({ open: true }); - - expect(wrapper.find('.boxed-group-inner').exists()).toBe(true); -}); - -function getWrapper(props = {}) { - return shallow( - <BoxedGroupAccordion - data="foo" - onClick={() => {}} - open={false} - renderHeader={() => <div>header content</div>} - title="Foo" - {...props}> - <div>inner content</div> - </BoxedGroupAccordion> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/BoxedTabs-test.tsx b/server/sonar-ui-common/components/controls/__tests__/BoxedTabs-test.tsx deleted file mode 100644 index 6db0b5c28e1..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/BoxedTabs-test.tsx +++ /dev/null @@ -1,66 +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 BoxedTabs, { BoxedTabsProps } from '../BoxedTabs'; - -it('should render correctly', () => { - expect(mountRender()).toMatchSnapshot(); -}); - -it('should call onSelect when a tab is clicked', () => { - const onSelect = jest.fn(); - const wrapper = shallowRender({ onSelect }); - - wrapper.find('Styled(button)').get(1).props.onClick(); - - expect(onSelect).toHaveBeenCalledWith('b'); -}); - -function shallowRender(overrides: Partial<BoxedTabsProps<string>> = {}) { - return shallow(dom(overrides)); -} - -function mountRender(overrides: Partial<BoxedTabsProps<string>> = {}) { - return mount(dom(overrides)); -} - -function dom<K>(overrides: Partial<BoxedTabsProps<K>>) { - return ( - <BoxedTabs - className="boxed-tabs" - onSelect={jest.fn()} - selected="a" - tabs={[ - { key: 'a', label: 'labela' }, - { key: 'b', label: 'labelb' }, - { - key: 'c', - label: ( - <span> - Complex label <strong>!!!</strong> - </span> - ), - }, - ]} - {...overrides} - /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/Checkbox-test.tsx b/server/sonar-ui-common/components/controls/__tests__/Checkbox-test.tsx deleted file mode 100644 index b56cce6c559..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/Checkbox-test.tsx +++ /dev/null @@ -1,115 +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 Checkbox from '../Checkbox'; - -it('should render', () => { - const checkbox = shallow(<Checkbox checked={true} onCheck={() => {}} title="Title value" />); - expect(checkbox).toMatchSnapshot(); -}); - -it('should render unchecked', () => { - const checkbox = shallow(<Checkbox checked={false} onCheck={() => true} />); - expect(checkbox.is('.icon-checkbox-checked')).toBe(false); - expect(checkbox.prop('aria-checked')).toBe(false); -}); - -it('should render checked', () => { - const checkbox = shallow(<Checkbox checked={true} onCheck={() => true} />); - expect(checkbox.is('.icon-checkbox-checked')).toBe(true); - expect(checkbox.prop('aria-checked')).toBe(true); -}); - -it('should render disabled', () => { - const checkbox = shallow(<Checkbox checked={true} disabled={true} onCheck={() => true} />); - expect(checkbox.is('.icon-checkbox-disabled')).toBe(true); -}); - -it('should render unchecked third state', () => { - const checkbox = shallow(<Checkbox checked={false} onCheck={() => true} thirdState={true} />); - expect(checkbox.is('.icon-checkbox-single')).toBe(true); - expect(checkbox.is('.icon-checkbox-checked')).toBe(false); -}); - -it('should render checked third state', () => { - const checkbox = shallow(<Checkbox checked={true} onCheck={() => true} thirdState={true} />); - expect(checkbox.is('.icon-checkbox-single')).toBe(true); - expect(checkbox.is('.icon-checkbox-checked')).toBe(true); -}); - -it('should render with a spinner', () => { - const checkbox = shallow(<Checkbox checked={false} loading={true} onCheck={() => true} />); - expect(checkbox.find('DeferredSpinner').exists()).toBe(true); -}); - -it('should render children', () => { - const checkbox = shallow( - <Checkbox checked={false} onCheck={() => true}> - <span>foo</span> - </Checkbox> - ); - expect(checkbox.hasClass('link-checkbox')).toBe(true); - expect(checkbox.find('span').exists()).toBe(true); -}); - -it('should render children with a spinner', () => { - const checkbox = shallow( - <Checkbox checked={false} loading={true} onCheck={() => true}> - <span>foo</span> - </Checkbox> - ); - expect(checkbox.hasClass('link-checkbox')).toBe(true); - expect(checkbox.find('span').exists()).toBe(true); - expect(checkbox.find('DeferredSpinner').exists()).toBe(true); -}); - -it('should call onCheck', () => { - const onCheck = jest.fn(); - const checkbox = shallow(<Checkbox checked={false} onCheck={onCheck} />); - click(checkbox); - expect(onCheck).toBeCalledWith(true, undefined); -}); - -it('should not call onCheck when disabled', () => { - const onCheck = jest.fn(); - const checkbox = shallow(<Checkbox checked={false} disabled={true} onCheck={onCheck} />); - click(checkbox); - expect(onCheck).toHaveBeenCalledTimes(0); -}); - -it('should call onCheck with id as second parameter', () => { - const onCheck = jest.fn(); - const checkbox = shallow(<Checkbox checked={false} id="foo" onCheck={onCheck} />); - click(checkbox); - expect(onCheck).toBeCalledWith(true, 'foo'); -}); - -it('should apply custom class', () => { - const checkbox = shallow( - <Checkbox checked={true} className="customclass" onCheck={() => true} /> - ); - expect(checkbox.is('.customclass')).toBe(true); -}); - -it('should render the checkbox on the right', () => { - expect(shallow(<Checkbox checked={true} onCheck={() => true} right={true} />)).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/ClickEventBoundary-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ClickEventBoundary-test.tsx deleted file mode 100644 index c2f6d701a76..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ClickEventBoundary-test.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 { mount } from 'enzyme'; -import * as React from 'react'; -import ClickEventBoundary from '../ClickEventBoundary'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should correctly capture a click event', () => { - const parentOnClick = jest.fn(); - const childOnClick = jest.fn(); - const wrapper = shallowRender({ onClick: parentOnClick }, { onClick: childOnClick }); - // Don't use our click() helper, so we make sure the bubbling works correctly. - wrapper.find('button').simulate('click'); - expect(childOnClick).toBeCalled(); - expect(parentOnClick).not.toBeCalled(); -}); - -function shallowRender(parentProps = {}, childProps = {}) { - // We need to mount in order to support event bubbling. - return mount( - <div {...parentProps}> - <ClickEventBoundary> - <button type="button" {...childProps}> - Click me - </button> - </ClickEventBoundary> - </div> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ConfirmButton-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ConfirmButton-test.tsx deleted file mode 100644 index 69b6fde10d5..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ConfirmButton-test.tsx +++ /dev/null @@ -1,44 +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 ConfirmButton from '../ConfirmButton'; - -it('should display a modal button', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should display a confirm modal', () => { - expect( - shallowRender().find('ModalButton').prop<Function>('modal')({ onClose: jest.fn() }) - ).toMatchSnapshot(); -}); - -function shallowRender() { - return shallow( - <ConfirmButton - confirmButtonText="submit" - modalBody={<div />} - modalHeader="title" - onConfirm={jest.fn()}> - {() => 'Confirm button'} - </ConfirmButton> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ConfirmModal-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ConfirmModal-test.tsx deleted file mode 100644 index cfefbac465a..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ConfirmModal-test.tsx +++ /dev/null @@ -1,60 +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 { submit, waitAndUpdate } from '../../../helpers/testUtils'; -import ConfirmModal from '../ConfirmModal'; - -it('should render correctly', () => { - const wrapper = shallow( - <ConfirmModal - confirmButtonText="confirm" - confirmData="data" - header="title" - onClose={jest.fn()} - onConfirm={jest.fn()}> - <p>My confirm message</p> - </ConfirmModal> - ); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find('SimpleModal').dive()).toMatchSnapshot(); -}); - -it('should confirm and close after confirm', async () => { - const onClose = jest.fn(); - const onConfirm = jest.fn(() => Promise.resolve()); - const wrapper = shallow( - <ConfirmModal - confirmButtonText="confirm" - confirmData="data" - header="title" - onClose={onClose} - onConfirm={onConfirm}> - <p>My confirm message</p> - </ConfirmModal> - ); - const modalContent = wrapper.find('SimpleModal').dive(); - submit(modalContent.find('form')); - expect(onConfirm).toBeCalledWith('data'); - expect(modalContent.find('footer')).toMatchSnapshot(); - - await waitAndUpdate(wrapper); - expect(onClose).toHaveBeenCalled(); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/Dropdown-test.tsx b/server/sonar-ui-common/components/controls/__tests__/Dropdown-test.tsx deleted file mode 100644 index 6c051fefb3e..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/Dropdown-test.tsx +++ /dev/null @@ -1,111 +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, ShallowWrapper } from 'enzyme'; -import * as React from 'react'; -import { click } from '../../../helpers/testUtils'; -import { Popup, PopupPlacement } from '../../ui/popups'; -import { Button } from '../buttons'; -import Dropdown, { DropdownOverlay } from '../Dropdown'; -import ScreenPositionFixer from '../ScreenPositionFixer'; - -describe('Dropdown', () => { - it('renders', () => { - expect( - shallow(<Dropdown overlay={<div id="overlay" />}>{() => <div />}</Dropdown>) - .find('div') - .exists() - ).toBe(true); - }); - - it('toggles with element child', () => { - checkToggle( - shallow( - <Dropdown overlay={<div id="overlay" />}> - <Button /> - </Dropdown> - ) - ); - - checkToggle( - shallow( - <Dropdown overlay={<div id="overlay" />}> - <a href="#">click me!</a> - </Dropdown> - ), - 'a' - ); - }); - - it('toggles with render prop', () => { - checkToggle( - shallow( - <Dropdown overlay={<div id="overlay" />}> - {({ onToggleClick }) => <Button onClick={onToggleClick} />} - </Dropdown> - ) - ); - }); - - it('should call onOpen', () => { - const onOpen = jest.fn(); - const wrapper = mount( - <Dropdown onOpen={onOpen} overlay={<div id="overlay" />}> - <Button /> - </Dropdown> - ); - expect(onOpen).not.toBeCalled(); - click(wrapper.find('Button')); - expect(onOpen).toBeCalled(); - }); - - function checkToggle(wrapper: ShallowWrapper, selector = 'Button') { - expect(wrapper.state()).toEqual({ open: false }); - - click(wrapper.find(selector)); - expect(wrapper.state()).toEqual({ open: true }); - - click(wrapper.find(selector)); - expect(wrapper.state()).toEqual({ open: false }); - } -}); - -describe('DropdownOverlay', () => { - it('should render overlay with screen fixer', () => { - const wrapper = shallow( - <DropdownOverlay> - <div /> - </DropdownOverlay>, - // disable ScreenPositionFixer positioning - { disableLifecycleMethods: true } - ); - - expect(wrapper.is(ScreenPositionFixer)).toBe(true); - expect(wrapper.dive().dive().dive().is(Popup)).toBe(true); - }); - - it('should render overlay without screen fixer', () => { - const wrapper = shallow( - <DropdownOverlay placement={PopupPlacement.BottomRight}> - <div /> - </DropdownOverlay> - ); - expect(wrapper.is('Popup')).toBe(true); - }); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/EscKeydownHandler-test.tsx b/server/sonar-ui-common/components/controls/__tests__/EscKeydownHandler-test.tsx deleted file mode 100644 index 6c852477b81..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/EscKeydownHandler-test.tsx +++ /dev/null @@ -1,46 +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 { KeyCodes } from '../../../helpers/keycodes'; -import { keydown } from '../../../helpers/testUtils'; -import EscKeydownHandler from '../EscKeydownHandler'; - -jest.useFakeTimers(); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should correctly trigger the keydown handler when hitting Esc', () => { - const onKeydown = jest.fn(); - shallowRender({ onKeydown }); - jest.runAllTimers(); - keydown(KeyCodes.Escape); - expect(onKeydown).toBeCalled(); -}); - -function shallowRender(props: Partial<EscKeydownHandler['props']> = {}) { - return shallow<EscKeydownHandler>( - <EscKeydownHandler onKeydown={jest.fn()} {...props}> - <span>Hi there</span> - </EscKeydownHandler> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/FavoriteButton-test.tsx b/server/sonar-ui-common/components/controls/__tests__/FavoriteButton-test.tsx deleted file mode 100644 index d0978f050d4..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/FavoriteButton-test.tsx +++ /dev/null @@ -1,54 +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 FavoriteButton, { Props } from '../FavoriteButton'; - -it('should render favorite', () => { - const favorite = renderFavoriteBase({ favorite: true }); - expect(favorite).toMatchSnapshot(); -}); - -it('should render not favorite', () => { - const favorite = renderFavoriteBase({ favorite: false }); - expect(favorite).toMatchSnapshot(); -}); - -it('should update properly', () => { - const favorite = renderFavoriteBase({ favorite: false }); - expect(favorite).toMatchSnapshot(); - - favorite.setProps({ favorite: true }); - expect(favorite).toMatchSnapshot(); -}); - -it('should toggle favorite', () => { - const toggleFavorite = jest.fn(); - const favorite = renderFavoriteBase({ toggleFavorite }); - click(favorite.find('ButtonLink')); - expect(toggleFavorite).toBeCalled(); -}); - -function renderFavoriteBase(props: Partial<Props> = {}) { - return shallow( - <FavoriteButton favorite={true} qualifier="TRK" toggleFavorite={jest.fn()} {...props} /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/GlobalMessages-test.tsx b/server/sonar-ui-common/components/controls/__tests__/GlobalMessages-test.tsx deleted file mode 100644 index af48c1a9701..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/GlobalMessages-test.tsx +++ /dev/null @@ -1,64 +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 { matchers } from 'jest-emotion'; -import * as React from 'react'; -import testTheme from '../../../config/jest/testTheme'; -import GlobalMessages, { GlobalMessagesProps } from '../GlobalMessages'; - -expect.extend(matchers); - -it('should not render when no message', () => { - expect(shallowRender({ messages: [] }).type()).toBeNull(); -}); - -it('should render correctly with a message', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find('GlobalMessage').first().dive()).toMatchSnapshot(); - expect(wrapper.find('GlobalMessage').last().dive()).toMatchSnapshot(); -}); - -it('should render with correct css', () => { - const wrapper = shallowRender(); - expect(wrapper.render()).toMatchSnapshot(); - expect(wrapper.find('GlobalMessage').first().render()).toHaveStyleRule( - 'background-color', - testTheme.colors.red - ); - - expect(wrapper.find('GlobalMessage').last().render()).toHaveStyleRule( - 'background-color', - testTheme.colors.green - ); -}); - -function shallowRender(props: Partial<GlobalMessagesProps> = {}) { - return shallow( - <GlobalMessages - closeGlobalMessage={jest.fn()} - messages={[ - { id: '1', level: 'ERROR', message: 'Test' }, - { id: '2', level: 'SUCCESS', message: 'Test 2' }, - ]} - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/HelpTooltip-test.tsx b/server/sonar-ui-common/components/controls/__tests__/HelpTooltip-test.tsx deleted file mode 100644 index 6bd89e53b25..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/HelpTooltip-test.tsx +++ /dev/null @@ -1,52 +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 testTheme from '../../../config/jest/testTheme'; -import { ThemeProvider } from '../../theme'; -import HelpTooltip, { DarkHelpTooltip } from '../HelpTooltip'; - -it('should render properly', () => { - const wrapper = shallow(<HelpTooltip overlay={<div className="my-overlay" />} />, { - wrappingComponent: ThemeProvider, - wrappingComponentProps: { - theme: testTheme, - }, - }); - expect(wrapper).toMatchSnapshot('default'); - expect(wrapper.find('ContextConsumer').dive()).toMatchSnapshot('default icon'); - - wrapper.setProps({ size: 18 }); - expect(wrapper.find('ContextConsumer').dive().prop('size')).toBe(18); -}); - -it('should render dark helptooltip properly', () => { - const wrapper = shallow(<DarkHelpTooltip overlay={<div className="my-overlay" />} size={14} />, { - wrappingComponent: ThemeProvider, - wrappingComponentProps: { - theme: testTheme, - }, - }); - expect(wrapper).toMatchSnapshot('dark'); - expect(wrapper.find('ContextConsumer').dive()).toMatchSnapshot('dark icon'); - - wrapper.setProps({ size: undefined }); - expect(wrapper.find('ContextConsumer').dive().prop('size')).toBe(12); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/IdentityProviderLink-test.tsx b/server/sonar-ui-common/components/controls/__tests__/IdentityProviderLink-test.tsx deleted file mode 100644 index 0050cd6f277..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/IdentityProviderLink-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 IdentityProviderLink from '../IdentityProviderLink'; - -const identityProvider = { - backgroundColor: '#000', - iconPath: '/some/path', - key: 'foo', - name: 'Foo', -}; - -it('should render correctly', () => { - expect( - shallow( - <IdentityProviderLink - backgroundColor={identityProvider.backgroundColor} - iconPath={identityProvider.iconPath} - name={identityProvider.name} - url="/url/foo/bar"> - Link text - </IdentityProviderLink> - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/InputValidationField-test.tsx b/server/sonar-ui-common/components/controls/__tests__/InputValidationField-test.tsx deleted file mode 100644 index 6c7c421452c..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/InputValidationField-test.tsx +++ /dev/null @@ -1,44 +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 InputValidationField from '../InputValidationField'; - -it('should render correctly', () => { - expect(getWrapper()).toMatchSnapshot(); -}); - -function getWrapper(props = {}) { - return shallow( - <InputValidationField - description="Field description" - dirty={true} - disabled={false} - error="Bad formatting" - label="Foo field" - name="field" - onBlur={jest.fn()} - onChange={jest.fn()} - touched={true} - value="foo" - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ListFooter-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ListFooter-test.tsx deleted file mode 100644 index 8970e984359..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ListFooter-test.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 { shallow } from 'enzyme'; -import * as React from 'react'; -import { click } from '../../../helpers/testUtils'; -import { Button } from '../buttons'; -import ListFooter, { ListFooterProps } from '../ListFooter'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ loading: true })).toMatchSnapshot('loading'); - expect(shallowRender({ needReload: true, reload: jest.fn() })).toMatchSnapshot('reload'); - expect(shallowRender({ loading: true, needReload: true, reload: jest.fn() })).toMatchSnapshot( - 'reload, loading' - ); - expect(shallowRender({ loadMore: undefined })).toMatchSnapshot( - 'empty if no loadMore nor reload props' - ); - expect(shallowRender({ count: 5 })).toMatchSnapshot('empty if everything is loaded'); -}); - -it('should properly call loadMore', () => { - const loadMore = jest.fn(); - const wrapper = shallowRender({ loadMore }); - click(wrapper.find(Button)); - expect(loadMore).toBeCalled(); -}); - -it('should properly call reload', () => { - const reload = jest.fn(); - const wrapper = shallowRender({ needReload: true, reload }); - click(wrapper.find(Button)); - expect(reload).toBeCalled(); -}); - -function shallowRender(props: Partial<ListFooterProps> = {}) { - return shallow<ListFooterProps>( - <ListFooter count={3} loadMore={jest.fn()} total={5} {...props} /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ModalButton-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ModalButton-test.tsx deleted file mode 100644 index 490609803a7..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ModalButton-test.tsx +++ /dev/null @@ -1,38 +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 ModalButton from '../ModalButton'; - -it('should open/close modal', () => { - const wrapper = shallow( - <ModalButton modal={({ onClose }) => <button id="js-close" onClick={onClose} type="button" />}> - {({ onClick }) => <button id="js-open" onClick={onClick} type="button" />} - </ModalButton> - ); - - expect(wrapper.find('#js-open').exists()).toBe(true); - expect(wrapper.find('#js-close').exists()).toBe(false); - click(wrapper.find('#js-open')); - expect(wrapper.find('#js-close').exists()).toBe(true); - click(wrapper.find('#js-close')); - expect(wrapper.find('#js-close').exists()).toBe(false); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/ModalValidationField-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ModalValidationField-test.tsx deleted file mode 100644 index 27f9743870d..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ModalValidationField-test.tsx +++ /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. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import ModalValidationField from '../ModalValidationField'; - -it('should display the field without any error/validation', () => { - expect(getWrapper({ description: 'Describe Foo.', touched: false })).toMatchSnapshot(); - expect(getWrapper({ dirty: false })).toMatchSnapshot(); -}); - -it('should display the field as valid', () => { - expect(getWrapper({ error: undefined })).toMatchSnapshot(); -}); - -it('should display the field with an error', () => { - expect(getWrapper()).toMatchSnapshot(); -}); - -function getWrapper(props = {}) { - return shallow( - <ModalValidationField - dirty={true} - error="Is required" - label={<label>Foo</label>} - touched={true} - {...props}> - {({ className }) => <input className={className} type="text" />} - </ModalValidationField> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/OutsideClickHandler-test.tsx b/server/sonar-ui-common/components/controls/__tests__/OutsideClickHandler-test.tsx deleted file mode 100644 index 4f540f59fec..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/OutsideClickHandler-test.tsx +++ /dev/null @@ -1,74 +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 OutsideClickHandler from '../OutsideClickHandler'; - -jest.useFakeTimers(); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should register for click event', () => { - const addEventListener = jest.spyOn(window, 'addEventListener'); - const removeEventListener = jest.spyOn(window, 'removeEventListener'); - - const wrapper = shallowRender(); - - jest.runAllTimers(); - - expect(addEventListener).toHaveBeenCalledWith('click', expect.anything()); - - wrapper.instance().componentWillUnmount(); - - expect(removeEventListener).toHaveBeenCalledWith('click', expect.anything()); -}); - -it('should call event handler on click on window', () => { - const onClickOutside = jest.fn(); - - const map: { [key: string]: EventListener } = {}; - window.addEventListener = jest.fn((event, callback) => { - map[event] = callback as EventListener; - }); - - mount( - <div id="outside-element"> - <OutsideClickHandler onClickOutside={onClickOutside}> - <div id="children" /> - </OutsideClickHandler> - </div> - ); - - jest.runAllTimers(); - - map['click'](new Event('click')); - expect(onClickOutside).toHaveBeenCalled(); -}); - -function shallowRender(props: Partial<OutsideClickHandler['props']> = {}) { - return shallow<OutsideClickHandler>( - <OutsideClickHandler onClickOutside={jest.fn()} {...props}> - <div id="children" /> - </OutsideClickHandler> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/Radio-test.tsx b/server/sonar-ui-common/components/controls/__tests__/Radio-test.tsx deleted file mode 100644 index 60d2050a45d..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/Radio-test.tsx +++ /dev/null @@ -1,52 +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 Radio from '../Radio'; - -it('should render properly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot('not checked'); - - wrapper.setProps({ checked: true }); - expect(wrapper).toMatchSnapshot('checked'); -}); - -it('should invoke callback on click', () => { - const onCheck = jest.fn(); - const value = 'value'; - const wrapper = shallowRender({ onCheck, value }); - - click(wrapper); - expect(onCheck).toHaveBeenCalled(); -}); - -it('should not invoke callback on click when disabled', () => { - const onCheck = jest.fn(); - const wrapper = shallowRender({ disabled: true, onCheck }); - - click(wrapper); - expect(onCheck).not.toHaveBeenCalled(); -}); - -function shallowRender(props?: Partial<Radio['props']>) { - return shallow<Radio>(<Radio checked={false} onCheck={jest.fn()} value="value" {...props} />); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/RadioCard-test.tsx b/server/sonar-ui-common/components/controls/__tests__/RadioCard-test.tsx deleted file mode 100644 index 2232f38b252..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/RadioCard-test.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 { shallow } from 'enzyme'; -import * as React from 'react'; -import { click } from '../../../helpers/testUtils'; -import RadioCard from '../RadioCard'; - -it('should render correctly', () => { - expect( - shallow( - <RadioCard recommended="Recommended for you" title="Radio Card" titleInfo="info"> - <div>content</div> - </RadioCard> - ) - ).toMatchSnapshot(); - - expect( - shallow( - <RadioCard - recommended="Recommended for you" - title="Radio Card Vertical" - titleInfo="info" - vertical={true}> - <div>content</div> - </RadioCard> - ) - ).toMatchSnapshot(); -}); - -it('should be actionable', () => { - const onClick = jest.fn(); - const wrapper = shallow( - <RadioCard onClick={onClick} title="Radio Card"> - <div>content</div> - </RadioCard> - ); - - expect(wrapper).toMatchSnapshot(); - click(wrapper); - wrapper.setProps({ selected: true, titleInfo: 'info' }); - expect(wrapper).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/RadioToggle-test.tsx b/server/sonar-ui-common/components/controls/__tests__/RadioToggle-test.tsx deleted file mode 100644 index 3653374e31a..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/RadioToggle-test.tsx +++ /dev/null @@ -1,94 +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 { change } from '../../../helpers/testUtils'; -import RadioToggle from '../RadioToggle'; - -it('renders', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('calls onCheck', () => { - const onCheck = jest.fn(); - const wrapper = shallowRender({ onCheck }); - change(wrapper.find('input[id="sample__two"]'), ''); - expect(onCheck).toBeCalledWith('two'); -}); - -it('handles numeric values', () => { - const onCheck = jest.fn(); - const wrapper = shallowRender({ - onCheck, - options: [ - { value: 1, label: 'first', tooltip: 'foo' }, - { value: 2, label: 'second', tooltip: 'bar' }, - ], - value: 1, - }); - change(wrapper.find('input[id="sample__2"]'), ''); - expect(onCheck).toBeCalledWith(2); -}); - -it('handles boolean values', () => { - const onCheck = jest.fn(); - const wrapper = shallowRender({ - onCheck, - options: [ - { value: true, label: 'yes', tooltip: 'foo' }, - { value: false, label: 'no', tooltip: 'bar' }, - ], - value: true, - }); - change(wrapper.find('input[id="sample__false"]'), ''); - expect(onCheck).toBeCalledWith(false); -}); - -it('initialize value', () => { - const onCheck = jest.fn(); - const wrapper = shallowRender({ - onCheck, - options: [ - { value: 1, label: 'first', tooltip: 'foo' }, - { value: 2, label: 'second', tooltip: 'bar', disabled: true }, - ], - value: 2, - }); - expect(wrapper.find('input[checked=true]').prop('id')).toBe('sample__2'); -}); - -it('accepts advanced options fields', () => { - expect( - shallowRender({ - options: [ - { value: 'one', label: 'first', tooltip: 'foo' }, - { value: 'two', label: 'second', tooltip: 'bar', disabled: true }, - ], - }) - ).toMatchSnapshot(); -}); - -function shallowRender(props?: Partial<RadioToggle['props']>) { - const options = [ - { value: 'one', label: 'first' }, - { value: 'two', label: 'second' }, - ]; - return shallow(<RadioToggle name="sample" onCheck={() => true} options={options} {...props} />); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ReloadButton-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ReloadButton-test.tsx deleted file mode 100644 index c22fd1f313e..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ReloadButton-test.tsx +++ /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. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import testTheme from '../../../config/jest/testTheme'; -import { click } from '../../../helpers/testUtils'; -import { ThemeProvider } from '../../theme'; -import ReloadButton from '../ReloadButton'; - -it('should render properly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find('ContextConsumer').dive()).toMatchSnapshot(); -}); - -it('should handle click', () => { - const onClick = jest.fn(); - const wrapper = shallowRender({ onClick }); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('a')); - expect(onClick).toBeCalled(); -}); - -function shallowRender(props: Partial<ReloadButton['props']> = {}) { - return shallow<ReloadButton>(<ReloadButton onClick={jest.fn()} {...props} />, { - wrappingComponent: ThemeProvider, - wrappingComponentProps: { - theme: testTheme, - }, - }); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ScreenPositionFixer-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ScreenPositionFixer-test.tsx deleted file mode 100644 index f857666cecd..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ScreenPositionFixer-test.tsx +++ /dev/null @@ -1,95 +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 testTheme from '../../../config/jest/testTheme'; -import { resizeWindowTo, setNodeRect } from '../../../helpers/testUtils'; -import { ScreenPositionFixer } from '../ScreenPositionFixer'; - -jest.mock('lodash', () => { - const lodash = jest.requireActual('lodash'); - lodash.throttle = (fn: any) => () => fn(); - return lodash; -}); - -jest.mock('react-dom', () => ({ - findDOMNode: jest.fn(), -})); - -beforeEach(() => { - setNodeRect({ left: 50, top: 50 }); - resizeWindowTo(1000, 1000); -}); - -it('should fix position', () => { - const children = jest.fn(() => <div />); - mountRender({ children }); - - setNodeRect({ left: 50, top: 50 }); - resizeWindowTo(75, 1000); - expect(children).toHaveBeenLastCalledWith({ leftFix: -29, topFix: 0 }); - - resizeWindowTo(1000, 75); - expect(children).toHaveBeenLastCalledWith({ leftFix: 0, topFix: -29 }); - - setNodeRect({ left: -10, top: 50 }); - resizeWindowTo(1000, 1000); - expect(children).toHaveBeenLastCalledWith({ leftFix: 14, topFix: 0 }); - - setNodeRect({ left: 50, top: -10 }); - resizeWindowTo(); - expect(children).toHaveBeenLastCalledWith({ leftFix: 0, topFix: 14 }); -}); - -it('should render two times', () => { - const children = jest.fn(() => <div />); - mountRender({ children }); - expect(children).toHaveBeenCalledTimes(2); - expect(children).toHaveBeenCalledWith({}); - expect(children).toHaveBeenLastCalledWith({ leftFix: 0, topFix: 0 }); -}); - -it('should re-position when `ready` turns to `true`', () => { - const children = jest.fn(() => <div />); - const wrapper = mountRender({ children, ready: false }); - expect(children).toHaveBeenCalledTimes(2); - wrapper.setProps({ ready: true }); - // 2 + 1 (props change) + 1 (new measurement) - expect(children).toHaveBeenCalledTimes(4); -}); - -it('should re-position when window is resized', () => { - const children = jest.fn(() => <div />); - const wrapper = mountRender({ children }); - expect(children).toHaveBeenCalledTimes(2); - - resizeWindowTo(); - // 2 + 1 (new measurement) - expect(children).toHaveBeenCalledTimes(3); - - wrapper.unmount(); - resizeWindowTo(); - expect(children).toHaveBeenCalledTimes(3); -}); - -function mountRender(props: Partial<ScreenPositionFixer['props']>) { - // eslint-disable-next-line react/no-children-prop - return mount(<ScreenPositionFixer theme={testTheme} children={() => <div />} {...props} />); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/SearchBox-test.tsx b/server/sonar-ui-common/components/controls/__tests__/SearchBox-test.tsx deleted file mode 100644 index 7afa1839c5f..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/SearchBox-test.tsx +++ /dev/null @@ -1,90 +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 { change, click } from '../../../helpers/testUtils'; -import SearchBox from '../SearchBox'; - -jest.mock('lodash', () => { - const lodash = jest.requireActual('lodash'); - const debounce = (fn: Function) => { - const debounced: any = (...args: any[]) => fn(...args); - debounced.cancel = jest.fn(); - return debounced; - }; - return Object.assign({}, lodash, { debounce }); -}); - -it('renders', () => { - const wrapper = shallow( - <SearchBox - maxLength={150} - minLength={2} - onChange={jest.fn()} - placeholder="placeholder" - value="foo" - /> - ); - expect(wrapper).toMatchSnapshot(); -}); - -it('warns when input is too short', () => { - const wrapper = shallow( - <SearchBox minLength={2} onChange={jest.fn()} placeholder="placeholder" value="f" /> - ); - expect(wrapper.find('.search-box-note').exists()).toBe(true); -}); - -it('shows clear button only when there is a value', () => { - const wrapper = shallow(<SearchBox onChange={jest.fn()} placeholder="placeholder" value="f" />); - expect(wrapper.find('.search-box-clear').exists()).toBe(true); - wrapper.setProps({ value: '' }); - expect(wrapper.find('.search-box-clear').exists()).toBe(false); -}); - -it('attaches ref', () => { - const ref = jest.fn(); - mount(<SearchBox innerRef={ref} onChange={jest.fn()} placeholder="placeholder" value="f" />); - expect(ref).toBeCalled(); - expect(ref.mock.calls[0][0]).toBeInstanceOf(HTMLInputElement); -}); - -it('resets', () => { - const onChange = jest.fn(); - const wrapper = shallow(<SearchBox onChange={onChange} placeholder="placeholder" value="f" />); - click(wrapper.find('.search-box-clear')); - expect(onChange).toBeCalledWith(''); -}); - -it('changes', () => { - const onChange = jest.fn(); - const wrapper = shallow(<SearchBox onChange={onChange} placeholder="placeholder" value="f" />); - change(wrapper.find('.search-box-input'), 'foo'); - expect(onChange).toBeCalledWith('foo'); -}); - -it('does not change when value is too short', () => { - const onChange = jest.fn(); - const wrapper = shallow( - <SearchBox minLength={3} onChange={onChange} placeholder="placeholder" value="" /> - ); - change(wrapper.find('.search-box-input'), 'fo'); - expect(onChange).not.toBeCalled(); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/SearchSelect-test.tsx b/server/sonar-ui-common/components/controls/__tests__/SearchSelect-test.tsx deleted file mode 100644 index ed13eea6fa7..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/SearchSelect-test.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 { shallow } from 'enzyme'; -import * as React from 'react'; -import SearchSelect from '../SearchSelect'; - -jest.mock('lodash', () => { - const lodash = require.requireActual('lodash'); - lodash.debounce = jest.fn((fn) => fn); - return lodash; -}); - -it('should render Select', () => { - expect(shallow(<SearchSelect onSearch={jest.fn()} onSelect={jest.fn()} />)).toMatchSnapshot(); -}); - -it('should call onSelect', () => { - const onSelect = jest.fn(); - const wrapper = shallow(<SearchSelect onSearch={jest.fn()} onSelect={onSelect} />); - wrapper.prop('onChange')({ value: 'foo' }); - expect(onSelect).lastCalledWith({ value: 'foo' }); -}); - -it('should call onSearch', () => { - const onSearch = jest.fn().mockReturnValue(Promise.resolve([])); - const wrapper = shallow( - <SearchSelect minimumQueryLength={2} onSearch={onSearch} onSelect={jest.fn()} /> - ); - wrapper.prop('onInputChange')('f'); - expect(onSearch).not.toHaveBeenCalled(); - wrapper.prop('onInputChange')('foo'); - expect(onSearch).lastCalledWith('foo'); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/SelectList-test.tsx b/server/sonar-ui-common/components/controls/__tests__/SelectList-test.tsx deleted file mode 100644 index ab3eb4f8072..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/SelectList-test.tsx +++ /dev/null @@ -1,148 +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 SelectList, { SelectListFilter } from '../SelectList'; - -const elements = ['foo', 'bar', 'baz']; -const selectedElements = [elements[0]]; -const disabledElements = [elements[1]]; - -it('should display properly with basics features', async () => { - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper.instance().mounted).toBe(true); - - expect(wrapper).toMatchSnapshot(); - - wrapper.instance().componentWillUnmount(); - expect(wrapper.instance().mounted).toBe(false); -}); - -it('should display properly with advanced features', async () => { - const wrapper = shallowRender({ - allowBulkSelection: true, - elementsTotalCount: 125, - pageSize: 10, - readOnly: true, - withPaging: true, - }); - await waitAndUpdate(wrapper); - - expect(wrapper).toMatchSnapshot(); -}); - -it('should display a loader when searching', async () => { - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper.state().loading).toBe(false); - - wrapper.instance().search({}); - expect(wrapper.state().loading).toBe(true); - expect(wrapper).toMatchSnapshot(); - - await waitAndUpdate(wrapper); - expect(wrapper.state().loading).toBe(false); -}); - -it('should cancel filter selection when search is active', async () => { - const spy = jest.fn().mockResolvedValue({}); - const wrapper = shallowRender({ onSearch: spy }); - wrapper.instance().changeFilter(SelectListFilter.Unselected); - await waitAndUpdate(wrapper); - - expect(spy).toHaveBeenCalledWith({ - query: '', - filter: SelectListFilter.Unselected, - page: undefined, - pageSize: undefined, - }); - expect(wrapper).toMatchSnapshot(); - - const query = 'test'; - wrapper.instance().handleQueryChange(query); - expect(spy).toHaveBeenCalledWith({ - query, - filter: SelectListFilter.All, - page: undefined, - pageSize: undefined, - }); - - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); - - wrapper.instance().handleQueryChange(''); - expect(spy).toHaveBeenCalledWith({ - query: '', - filter: SelectListFilter.Unselected, - page: undefined, - pageSize: undefined, - }); - - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); -}); - -it('should display pagination element properly and call search method with correct parameters', () => { - const spy = jest.fn().mockResolvedValue({}); - const wrapper = shallowRender({ elementsTotalCount: 100, onSearch: spy, withPaging: true }); - expect(wrapper).toMatchSnapshot(); - expect(spy).toHaveBeenCalledWith({ - query: '', - filter: SelectListFilter.Selected, - page: 1, - pageSize: 100, - }); // Basic default call - - wrapper.instance().onLoadMore(); - expect(spy).toHaveBeenCalledWith({ - query: '', - filter: SelectListFilter.Selected, - page: 2, - pageSize: 100, - }); // Load more call - - wrapper.instance().onReload(); - expect(spy).toHaveBeenCalledWith({ - query: '', - filter: SelectListFilter.Selected, - page: 1, - pageSize: 100, - }); // Reload call - - wrapper.setProps({ needToReload: true }); - expect(wrapper).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<SelectList['props']> = {}) { - return shallow<SelectList>( - <SelectList - disabledElements={disabledElements} - elements={elements} - onSearch={jest.fn(() => Promise.resolve())} - onSelect={jest.fn(() => Promise.resolve())} - onUnselect={jest.fn(() => Promise.resolve())} - renderElement={(foo: string) => foo} - selectedElements={selectedElements} - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/SelectListListContainer-test.tsx b/server/sonar-ui-common/components/controls/__tests__/SelectListListContainer-test.tsx deleted file mode 100644 index 1b24bc866c1..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/SelectListListContainer-test.tsx +++ /dev/null @@ -1,44 +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 { SelectListFilter } from '../SelectList'; -import SelectListListContainer from '../SelectListListContainer'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<SelectListListContainer['props']> = {}) { - return shallow( - <SelectListListContainer - allowBulkSelection={true} - disabledElements={[]} - elements={['foo', 'bar', 'baz']} - filter={SelectListFilter.All} - onSelect={jest.fn(() => Promise.resolve())} - onUnselect={jest.fn(() => Promise.resolve())} - readOnly={false} - renderElement={(foo: string) => foo} - selectedElements={['foo']} - {...props} - /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/SelectListListElement-test.tsx b/server/sonar-ui-common/components/controls/__tests__/SelectListListElement-test.tsx deleted file mode 100644 index ca127222e04..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/SelectListListElement-test.tsx +++ /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. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { waitAndUpdate } from '../../../helpers/testUtils'; -import SelectListListElement from '../SelectListListElement'; - -const listElement = ( - <SelectListListElement - element="foo" - key="foo" - onSelect={jest.fn(() => Promise.resolve())} - onUnselect={jest.fn(() => Promise.resolve())} - renderElement={(foo: string) => foo} - selected={false} - /> -); - -it('should display a loader when checking', async () => { - const wrapper = shallow<SelectListListElement>(listElement); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.state().loading).toBe(false); - - (wrapper.instance() as SelectListListElement).handleCheck(true); - expect(wrapper.state().loading).toBe(true); - expect(wrapper).toMatchSnapshot(); - - await waitAndUpdate(wrapper); - expect(wrapper.state().loading).toBe(false); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/SimpleModal-test.tsx b/server/sonar-ui-common/components/controls/__tests__/SimpleModal-test.tsx deleted file mode 100644 index 5a8e6bb0cd7..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/SimpleModal-test.tsx +++ /dev/null @@ -1,65 +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, waitAndUpdate } from '../../../helpers/testUtils'; -import { Button } from '../buttons'; -import SimpleModal, { ChildrenProps } from '../SimpleModal'; - -it('renders', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('closes', () => { - const onClose = jest.fn(); - const children = ({ onCloseClick }: ChildrenProps) => ( - <Button onClick={onCloseClick}>close</Button> - ); - const wrapper = shallowRender({ children, onClose }); - click(wrapper.find('Button')); - expect(onClose).toBeCalled(); -}); - -it('submits', async () => { - const onSubmit = jest.fn(() => Promise.resolve()); - const children = ({ onSubmitClick, submitting }: ChildrenProps) => ( - <Button disabled={submitting} onClick={onSubmitClick}> - close - </Button> - ); - const wrapper = shallowRender({ children, onSubmit }); - wrapper.instance().mounted = true; - expect(wrapper).toMatchSnapshot(); - - click(wrapper.find('Button')); - expect(onSubmit).toBeCalled(); - expect(wrapper).toMatchSnapshot(); - - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot(); -}); - -function shallowRender({ children = () => <div />, ...props }: Partial<SimpleModal['props']> = {}) { - return shallow<SimpleModal>( - <SimpleModal header="" onClose={jest.fn()} onSubmit={jest.fn()} {...props}> - {children} - </SimpleModal> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/Tabs-test.tsx b/server/sonar-ui-common/components/controls/__tests__/Tabs-test.tsx deleted file mode 100644 index 11cf4e5e353..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/Tabs-test.tsx +++ /dev/null @@ -1,81 +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 Tabs, { Tab } from '../Tabs'; - -it('should render correctly', () => { - const wrapper = shallow( - <Tabs - onChange={jest.fn()} - selected="bar" - tabs={[ - { key: 'foo', node: 'Foo' }, - { key: 'bar', node: 'Bar' }, - ]} - /> - ); - - expect(wrapper).toMatchSnapshot(); -}); - -it('should switch tabs', () => { - const onChange = jest.fn(); - const wrapper = shallow( - <Tabs - onChange={onChange} - selected="bar" - tabs={[ - { key: 'foo', node: 'Foo' }, - { key: 'bar', node: 'Bar' }, - ]} - /> - ); - - click(shallow(wrapper.find('Tab').get(0)).find('.js-foo')); - expect(onChange).toBeCalledWith('foo'); - click(shallow(wrapper.find('Tab').get(1)).find('.js-bar')); - expect(onChange).toBeCalledWith('bar'); -}); - -it('should render single tab correctly', () => { - const onSelect = jest.fn(); - const wrapper = shallow( - <Tab name="foo" onSelect={onSelect} selected={true}> - <span>Foo</span> - </Tab> - ); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('a')); - expect(onSelect).toBeCalledWith('foo'); -}); - -it('should disable single tab', () => { - const onSelect = jest.fn(); - const wrapper = shallow( - <Tab disabled={true} name="foo" onSelect={onSelect} selected={true}> - <span>Foo</span> - </Tab> - ); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('a')); - expect(onSelect).not.toBeCalled(); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/Toggle-test.tsx b/server/sonar-ui-common/components/controls/__tests__/Toggle-test.tsx deleted file mode 100644 index f3e39aca5df..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/Toggle-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 { Button } from '../buttons'; -import Toggle from '../Toggle'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('on'); - expect(shallowRender({ value: false })).toMatchSnapshot('off'); - expect(shallowRender({ disabled: true })).toMatchSnapshot('disabled'); -}); - -it('should call onChange when clicked', () => { - const onChange = jest.fn(); - const wrapper = shallowRender({ disabled: false, onChange, value: true }); - click(wrapper.find(Button)); - expect(onChange).toBeCalledWith(false); -}); - -function shallowRender(props?: Partial<Toggle['props']>) { - return shallow( - <Toggle disabled={true} name="toggle-name" onChange={jest.fn()} value={true} {...props} /> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/Toggler-test.tsx b/server/sonar-ui-common/components/controls/__tests__/Toggler-test.tsx deleted file mode 100644 index 679177cfda3..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/Toggler-test.tsx +++ /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. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import Toggler from '../Toggler'; - -it('should render only children', () => { - expect(shallowRender({ open: false })).toMatchSnapshot(); -}); - -it('should render children and overlay', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should render when closeOnClick=true', () => { - expect(shallowRender({ closeOnClick: true })).toMatchSnapshot(); -}); - -it('should not render click wrappers', () => { - expect( - shallowRender({ closeOnClick: false, closeOnClickOutside: false, closeOnEscape: false }) - ).toMatchSnapshot(); -}); - -function shallowRender(props?: Partial<Toggler['props']>) { - return shallow( - <Toggler onRequestClose={jest.fn()} open={true} overlay={<div id="overlay" />} {...props}> - <div id="toggle" /> - </Toggler> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/Tooltip-test.tsx b/server/sonar-ui-common/components/controls/__tests__/Tooltip-test.tsx deleted file mode 100644 index e2a395b609e..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/Tooltip-test.tsx +++ /dev/null @@ -1,118 +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 Tooltip, { TooltipInner, TooltipProps } from '../Tooltip'; - -jest.useFakeTimers(); -jest.mock('react-dom', () => { - const actual = jest.requireActual('react-dom'); - return Object.assign({}, actual, { - findDOMNode: jest.fn().mockReturnValue(undefined), - }); -}); - -beforeEach(jest.clearAllMocks); - -it('should render', () => { - expect(shallowRenderTooltipInner()).toMatchSnapshot(); - expect( - shallow( - <TooltipInner overlay={<span id="overlay" />} visible={true}> - <div id="tooltip" /> - </TooltipInner>, - { disableLifecycleMethods: true } - ) - ).toMatchSnapshot(); -}); - -it('should open & close', () => { - const onShow = jest.fn(); - const onHide = jest.fn(); - const wrapper = shallowRenderTooltipInner({ onHide, onShow }); - - wrapper.find('#tooltip').simulate('mouseenter'); - jest.runOnlyPendingTimers(); - wrapper.update(); - expect(wrapper.find('TooltipPortal').exists()).toBe(true); - expect(onShow).toBeCalled(); - - wrapper.find('#tooltip').simulate('mouseleave'); - jest.runOnlyPendingTimers(); - wrapper.update(); - expect(wrapper.find('TooltipPortal').exists()).toBe(false); - expect(onHide).toBeCalled(); -}); - -it('should not open when mouse goes away quickly', () => { - const onShow = jest.fn(); - const onHide = jest.fn(); - const wrapper = shallowRenderTooltipInner({ onHide, onShow }); - - wrapper.find('#tooltip').simulate('mouseenter'); - wrapper.find('#tooltip').simulate('mouseleave'); - jest.runOnlyPendingTimers(); - wrapper.update(); - - expect(wrapper.find('TooltipPortal').exists()).toBe(false); -}); - -it('should not render tooltip without overlay', () => { - const wrapper = shallowRenderTooltip(); - expect(wrapper.type()).toBe('div'); -}); - -it('should not render empty tooltips', () => { - expect(shallowRenderTooltip()).toMatchSnapshot(); - expect(shallowRenderTooltip()).toMatchSnapshot(); -}); - -it('should adjust arrow position', () => { - const wrapper = shallowRenderTooltipInner(); - - expect(wrapper.instance().adjustArrowPosition('left', { leftFix: 10, topFix: 20 })).toEqual({ - marginTop: -20, - }); - expect(wrapper.instance().adjustArrowPosition('right', { leftFix: 10, topFix: 20 })).toEqual({ - marginTop: -20, - }); - expect(wrapper.instance().adjustArrowPosition('top', { leftFix: 10, topFix: 20 })).toEqual({ - marginLeft: -10, - }); - expect(wrapper.instance().adjustArrowPosition('bottom', { leftFix: 10, topFix: 20 })).toEqual({ - marginLeft: -10, - }); -}); - -function shallowRenderTooltip() { - return shallow<TooltipProps>( - <Tooltip overlay={undefined}> - <div id="tooltip" /> - </Tooltip> - ); -} - -function shallowRenderTooltipInner(props?: Partial<TooltipProps>) { - return shallow<TooltipInner>( - <TooltipInner overlay={<span id="overlay" />} {...props}> - <div id="tooltip" /> - </TooltipInner> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/ValidationForm-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ValidationForm-test.tsx deleted file mode 100644 index 64827f932ed..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ValidationForm-test.tsx +++ /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. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import ValidationForm from '../ValidationForm'; - -it('should render and submit', async () => { - const render = jest.fn(); - const onSubmit = jest.fn(); - const setSubmitting = jest.fn(); - const wrapper = shallow( - <ValidationForm initialValues={{ foo: 'bar' }} onSubmit={onSubmit} validate={jest.fn()}> - {render} - </ValidationForm> - ); - expect(wrapper).toMatchSnapshot(); - wrapper.dive(); - expect(render).toBeCalledWith( - expect.objectContaining({ dirty: false, errors: {}, values: { foo: 'bar' } }) - ); - - wrapper.prop<Function>('onSubmit')({ foo: 'bar' }, { setSubmitting }); - expect(setSubmitting).toBeCalledWith(false); - - onSubmit.mockResolvedValue(undefined).mockClear(); - setSubmitting.mockClear(); - wrapper.prop<Function>('onSubmit')({ foo: 'bar' }, { setSubmitting }); - await new Promise(setImmediate); - expect(setSubmitting).toBeCalledWith(false); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/ValidationInput-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ValidationInput-test.tsx deleted file mode 100644 index 97d4a2a5937..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ValidationInput-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 { shallow } from 'enzyme'; -import * as React from 'react'; -import ValidationInput from '../ValidationInput'; - -it('should render', () => { - expect( - shallow( - <ValidationInput - description="My description" - error={undefined} - help="Help message" - id="field-id" - isInvalid={false} - isValid={false} - label="Field label" - required={true}> - <div /> - </ValidationInput> - ) - ).toMatchSnapshot(); -}); - -it('should render with error', () => { - expect( - shallow( - <ValidationInput - description={<div>My description</div>} - error="Field error message" - id="field-id" - isInvalid={true} - isValid={false} - label="Field label"> - <div /> - </ValidationInput> - ) - ).toMatchSnapshot(); -}); - -it('should render when valid', () => { - expect( - shallow( - <ValidationInput - description="My description" - error={undefined} - id="field-id" - isInvalid={false} - isValid={true} - label="Field label" - required={true}> - <div /> - </ValidationInput> - ) - ).toMatchSnapshot(); -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/ValidationModal-test.tsx b/server/sonar-ui-common/components/controls/__tests__/ValidationModal-test.tsx deleted file mode 100644 index e3825083577..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/ValidationModal-test.tsx +++ /dev/null @@ -1,68 +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 ValidationForm from '../ValidationForm'; -import ValidationModal from '../ValidationModal'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find(ValidationForm).dive().dive()).toMatchSnapshot(); -}); - -it('should handle submit', async () => { - const data = { field: 'foo' }; - const onSubmit = jest.fn().mockResolvedValue({}); - const onClose = jest.fn(); - const wrapper = shallowRender({ onClose, onSubmit }); - - wrapper.instance().handleSubmit(data); - expect(onSubmit).toBeCalledWith(data); - - await waitAndUpdate(wrapper); - expect(onClose).toBeCalled(); -}); - -function shallowRender(props: Partial<ValidationModal<{ field: string }>['props']> = {}) { - return shallow<ValidationModal<{ field: string }>>( - <ValidationModal<{ field: string }> - confirmButtonText="confirm" - header="title" - initialValues={{ field: 'foo' }} - isDestructive={true} - isInitialValid={true} - onClose={jest.fn()} - onSubmit={jest.fn()} - validate={jest.fn()} - {...props}> - {(props) => ( - <input - name="field" - onBlur={props.handleBlur} - onChange={props.handleChange} - type="text" - value={props.values.field} - /> - )} - </ValidationModal> - ); -} diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ActionsDropdown-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ActionsDropdown-test.tsx.snap deleted file mode 100644 index 4bd6a2ea46d..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ActionsDropdown-test.tsx.snap +++ /dev/null @@ -1,143 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ActionsDropdown should render correctly 1`] = ` -<Dropdown - className="foo" - onOpen={[MockFunction]} - overlay={ - <ul - className="menu" - > - <span> - Hello world - </span> - </ul> - } - overlayPlacement="bottom" -> - <Button - className="dropdown-toggle bar button-small" - > - <SettingsIcon - size={12} - /> - <DropdownIcon - className="little-spacer-left" - /> - </Button> -</Dropdown> -`; - -exports[`ActionsDropdown should render correctly 2`] = ` -<Dropdown - className="foo" - onOpen={[MockFunction]} - overlay={ - <ul - className="menu" - > - <span> - Hello world - </span> - </ul> - } - overlayPlacement="bottom" -> - <Button - className="dropdown-toggle bar" - > - <SettingsIcon - size={14} - /> - <DropdownIcon - className="little-spacer-left" - /> - </Button> -</Dropdown> -`; - -exports[`ActionsDropdownDivider should render correctly 1`] = ` -<li - className="divider" -/> -`; - -exports[`ActionsDropdownItem should render correctly 1`] = ` -<li> - <a - className="foo" - href="#" - onClick={[Function]} - > - <span> - Hello world - </span> - </a> -</li> -`; - -exports[`ActionsDropdownItem should render correctly 2`] = ` -<li> - <Link - className="foo text-danger" - id="baz" - onlyActiveOnIndex={false} - style={Object {}} - to="path/name" - > - <span> - Hello world - </span> - </Link> -</li> -`; - -exports[`ActionsDropdownItem should render correctly 3`] = ` -<li> - <a - className="foo" - download="foo/bar" - href="path/name" - > - <span> - Hello world - </span> - </a> -</li> -`; - -exports[`ActionsDropdownItem should render correctly copy item 1`] = ` -<ActionsDropdownItem - className="foo" - copyValue="my content to copy to clipboard" -> - <ClipboardBase> - <Tooltip - overlay="copied_action" - visible={false} - > - <TooltipInner - mouseEnterDelay={0.1} - overlay="copied_action" - visible={false} - > - <li - data-clipboard-text="my content to copy to clipboard" - onMouseEnter={[Function]} - onMouseLeave={[Function]} - > - <a - className="foo" - href="#" - onClick={[Function]} - > - <span> - Hello world - </span> - </a> - </li> - </TooltipInner> - </Tooltip> - </ClipboardBase> -</ActionsDropdownItem> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BackButton-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BackButton-test.tsx.snap deleted file mode 100644 index 57a5f2c6135..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BackButton-test.tsx.snap +++ /dev/null @@ -1,46 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should handle click 1`] = ` -<Tooltip - overlay="issues.return_to_list" -> - <a - className="link-no-underline" - href="#" - onClick={[Function]} - > - <ContextConsumer> - <Component /> - </ContextConsumer> - </a> -</Tooltip> -`; - -exports[`should render properly 1`] = ` -<Tooltip - overlay="issues.return_to_list" -> - <a - className="link-no-underline" - href="#" - onClick={[Function]} - > - <ContextConsumer> - <Component /> - </ContextConsumer> - </a> -</Tooltip> -`; - -exports[`should render properly 2`] = ` -<svg - height="24" - viewBox="0 0 21 24" - width="21" -> - <path - d="M3.845 12.9992l5.993 5.993.052.056c.049.061.093.122.129.191.082.159.121.339.111.518-.006.102-.028.203-.064.298-.149.39-.537.652-.954.644-.102-.002-.204-.019-.301-.052-.148-.05-.273-.135-.387-.241l-8.407-8.407 8.407-8.407.056-.052c.061-.048.121-.092.19-.128.116-.06.237-.091.366-.108.076-.004.075-.004.153-.003.155.015.3.052.437.129.088.051.169.115.239.19.246.266.33.656.214.999-.051.149-.135.273-.241.387l-5.983 5.984c5.287-.044 10.577-.206 15.859.013.073.009.091.009.163.027.187.047.359.15.49.292.075.081.136.175.18.276.044.101.072.209.081.319.032.391-.175.775-.521.962-.097.052-.202.089-.311.107-.073.012-.091.01-.165.013H3.845z" - fill="#777" - /> -</svg> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BoxedGroupAccordion-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BoxedGroupAccordion-test.tsx.snap deleted file mode 100644 index 0c7b74b79d9..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BoxedGroupAccordion-test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - className="boxed-group boxed-group-accordion" -> - <div - className="boxed-group-header" - onClick={[Function]} - role="listitem" - > - <span - className="boxed-group-accordion-title" - > - <OpenCloseIcon - className="little-spacer-right" - open={false} - /> - Foo - </span> - <div> - header content - </div> - </div> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BoxedTabs-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BoxedTabs-test.tsx.snap deleted file mode 100644 index 22d8f761533..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/BoxedTabs-test.tsx.snap +++ /dev/null @@ -1,178 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -.emotion-6 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; -} - -.emotion-1 { - position: relative; - background-color: white; - border-top: 1px solid #e6e6e6; - border-left: 1px solid #e6e6e6; - border-right: none; - border-bottom: none; - margin-bottom: -1px; - min-width: 128px; - min-height: 56px; - outline: 0; - padding: calc(2 * 8px); -} - -.emotion-1:last-child { - border-right: 1px solid #e6e6e6; -} - -.emotion-0 { - display: block; - background-color: #4b9fd5; - height: 3px; - width: 100%; - position: absolute; - left: 0; - top: -1px; -} - -.emotion-3 { - position: relative; - background-color: #f3f3f3; - border-top: 1px solid #e6e6e6; - border-left: 1px solid #e6e6e6; - border-right: none; - border-bottom: none; - margin-bottom: -1px; - min-width: 128px; - min-height: 56px; - cursor: pointer; - outline: 0; - padding: calc(2 * 8px); -} - -.emotion-3:hover { - background-color: #f8f8f8; -} - -.emotion-3:last-child { - border-right: 1px solid #e6e6e6; -} - -.emotion-2 { - display: none; - background-color: #4b9fd5; - height: 3px; - width: 100%; - position: absolute; - left: 0; - top: -1px; -} - -<BoxedTabs - className="boxed-tabs" - onSelect={[MockFunction]} - selected="a" - tabs={ - Array [ - Object { - "key": "a", - "label": "labela", - }, - Object { - "key": "b", - "label": "labelb", - }, - Object { - "key": "c", - "label": <span> - Complex label - <strong> - !!! - </strong> - </span>, - }, - ] - } -> - <Styled(div) - className="boxed-tabs" - > - <div - className="boxed-tabs emotion-6" - > - <Styled(button) - active={true} - key="0" - onClick={[Function]} - type="button" - > - <button - className="emotion-1" - onClick={[Function]} - type="button" - > - <Styled(div) - active={true} - > - <div - className="emotion-0" - /> - </Styled(div)> - labela - </button> - </Styled(button)> - <Styled(button) - active={false} - key="1" - onClick={[Function]} - type="button" - > - <button - className="emotion-3" - onClick={[Function]} - type="button" - > - <Styled(div) - active={false} - > - <div - className="emotion-2" - /> - </Styled(div)> - labelb - </button> - </Styled(button)> - <Styled(button) - active={false} - key="2" - onClick={[Function]} - type="button" - > - <button - className="emotion-3" - onClick={[Function]} - type="button" - > - <Styled(div) - active={false} - > - <div - className="emotion-2" - /> - </Styled(div)> - <span> - Complex label - <strong> - !!! - </strong> - </span> - </button> - </Styled(button)> - </div> - </Styled(div)> -</BoxedTabs> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Checkbox-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Checkbox-test.tsx.snap deleted file mode 100644 index 69c0c60af8c..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Checkbox-test.tsx.snap +++ /dev/null @@ -1,22 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render 1`] = ` -<a - aria-checked={true} - className="icon-checkbox icon-checkbox-checked" - href="#" - onClick={[Function]} - role="checkbox" - title="Title value" -/> -`; - -exports[`should render the checkbox on the right 1`] = ` -<a - aria-checked={true} - className="icon-checkbox icon-checkbox-checked" - href="#" - onClick={[Function]} - role="checkbox" -/> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ClickEventBoundary-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ClickEventBoundary-test.tsx.snap deleted file mode 100644 index 62eac278e7f..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ClickEventBoundary-test.tsx.snap +++ /dev/null @@ -1,14 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div> - <ClickEventBoundary> - <button - onClick={[Function]} - type="button" - > - Click me - </button> - </ClickEventBoundary> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ConfirmButton-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ConfirmButton-test.tsx.snap deleted file mode 100644 index f94c3829503..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ConfirmButton-test.tsx.snap +++ /dev/null @@ -1,20 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should display a confirm modal 1`] = ` -<ConfirmModal - confirmButtonText="submit" - header="title" - onClose={[MockFunction]} - onConfirm={[MockFunction]} -> - <div /> -</ConfirmModal> -`; - -exports[`should display a modal button 1`] = ` -<ModalButton - modal={[Function]} -> - <Component /> -</ModalButton> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ConfirmModal-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ConfirmModal-test.tsx.snap deleted file mode 100644 index f1367ae048a..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ConfirmModal-test.tsx.snap +++ /dev/null @@ -1,81 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should confirm and close after confirm 1`] = ` -<footer - className="modal-foot" -> - <DeferredSpinner - className="spacer-right" - loading={true} - /> - <SubmitButton - autoFocus={true} - disabled={true} - > - confirm - </SubmitButton> - <ResetButtonLink - disabled={true} - onClick={[Function]} - > - cancel - </ResetButtonLink> -</footer> -`; - -exports[`should render correctly 1`] = ` -<SimpleModal - header="title" - onClose={[MockFunction]} - onSubmit={[Function]} -> - <Component /> -</SimpleModal> -`; - -exports[`should render correctly 2`] = ` -<Modal - contentLabel="title" - onRequestClose={[MockFunction]} -> - <ClickEventBoundary> - <form - onSubmit={[Function]} - > - <header - className="modal-head" - > - <h2> - title - </h2> - </header> - <div - className="modal-body" - > - <p> - My confirm message - </p> - </div> - <footer - className="modal-foot" - > - <DeferredSpinner - className="spacer-right" - loading={false} - /> - <SubmitButton - autoFocus={true} - > - confirm - </SubmitButton> - <ResetButtonLink - disabled={false} - onClick={[Function]} - > - cancel - </ResetButtonLink> - </footer> - </form> - </ClickEventBoundary> -</Modal> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/EscKeydownHandler-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/EscKeydownHandler-test.tsx.snap deleted file mode 100644 index 239d6bfe358..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/EscKeydownHandler-test.tsx.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<span> - Hi there -</span> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/FavoriteButton-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/FavoriteButton-test.tsx.snap deleted file mode 100644 index f66e2ddd464..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/FavoriteButton-test.tsx.snap +++ /dev/null @@ -1,65 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render favorite 1`] = ` -<Tooltip - overlay="favorite.current.TRK" -> - <ButtonLink - aria-label="favorite.action.remove" - className="favorite-link link-no-underline" - onClick={[MockFunction]} - > - <FavoriteIcon - favorite={true} - /> - </ButtonLink> -</Tooltip> -`; - -exports[`should render not favorite 1`] = ` -<Tooltip - overlay="favorite.check.TRK" -> - <ButtonLink - aria-label="favorite.action.add" - className="favorite-link link-no-underline" - onClick={[MockFunction]} - > - <FavoriteIcon - favorite={false} - /> - </ButtonLink> -</Tooltip> -`; - -exports[`should update properly 1`] = ` -<Tooltip - overlay="favorite.check.TRK" -> - <ButtonLink - aria-label="favorite.action.add" - className="favorite-link link-no-underline" - onClick={[MockFunction]} - > - <FavoriteIcon - favorite={false} - /> - </ButtonLink> -</Tooltip> -`; - -exports[`should update properly 2`] = ` -<Tooltip - overlay="favorite.current.TRK" -> - <ButtonLink - aria-label="favorite.action.remove" - className="favorite-link link-no-underline" - onClick={[MockFunction]} - > - <FavoriteIcon - favorite={true} - /> - </ButtonLink> -</Tooltip> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/GlobalMessages-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/GlobalMessages-test.tsx.snap deleted file mode 100644 index fdeaf6c28e4..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/GlobalMessages-test.tsx.snap +++ /dev/null @@ -1,212 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly with a message 1`] = ` -<Styled(div)> - <GlobalMessage - closeGlobalMessage={[MockFunction]} - key="1" - message={ - Object { - "id": "1", - "level": "ERROR", - "message": "Test", - } - } - /> - <GlobalMessage - closeGlobalMessage={[MockFunction]} - key="2" - message={ - Object { - "id": "2", - "level": "SUCCESS", - "message": "Test 2", - } - } - /> -</Styled(div)> -`; - -exports[`should render correctly with a message 2`] = ` -<Styled(div) - data-test="global-message__ERROR" - level="ERROR" - role="alert" -> - Test - <Styled(ClearButton) - className="button-small" - color="#fff" - level="ERROR" - onClick={[Function]} - /> -</Styled(div)> -`; - -exports[`should render correctly with a message 3`] = ` -<Styled(div) - data-test="global-message__SUCCESS" - level="SUCCESS" - role="status" -> - Test 2 - <Styled(ClearButton) - className="button-small" - color="#fff" - level="SUCCESS" - onClick={[Function]} - /> -</Styled(div)> -`; - -exports[`should render with correct css 1`] = ` -@keyframes animation-0 { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -@keyframes animation-0 { - from { - opacity: 0; - } - - to { - opacity: 1; - } -} - -.emotion-4 { - position: fixed; - z-index: 7000; - top: 0; - left: 50%; - width: 350px; - margin-left: -175px; -} - -.emotion-1 { - position: relative; - padding: 0 30px 0 10px; - line-height: 24px; - border-radius: 0 0 3px 3px; - box-sizing: border-box; - color: #ffffff; - background-color: #d4333f; - text-align: center; - opacity: 0; - -webkit-animation: animation-0 0.2s ease forwards; - animation: animation-0 0.2s ease forwards; -} - -.emotion-1 + .emotion-1 { - margin-top: calc(8px / 2); - border-radius: 3px; -} - -.emotion-0 { - position: absolute; - top: calc(8px / 4); - right: calc(8px / 4); -} - -.emotion-0:hover svg, -.emotion-0:focus svg { - color: #d4333f; -} - -.emotion-3 { - position: relative; - padding: 0 30px 0 10px; - line-height: 24px; - border-radius: 0 0 3px 3px; - box-sizing: border-box; - color: #ffffff; - background-color: #00aa00; - text-align: center; - opacity: 0; - -webkit-animation: animation-0 0.2s ease forwards; - animation: animation-0 0.2s ease forwards; -} - -.emotion-3 + .emotion-3 { - margin-top: calc(8px / 2); - border-radius: 3px; -} - -.emotion-2 { - position: absolute; - top: calc(8px / 4); - right: calc(8px / 4); -} - -.emotion-2:hover svg, -.emotion-2:focus svg { - color: #00aa00; -} - -<div - class="emotion-4" -> - <div - class="emotion-1" - data-test="global-message__ERROR" - role="alert" - > - Test - <button - class="button button-small emotion-0 button-icon" - level="ERROR" - style="color:#fff" - type="button" - > - <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="M14 4.242L11.758 2l-3.76 3.76L4.242 2 2 4.242l3.756 3.756L2 11.758 4.242 14l3.756-3.76 3.76 3.76L14 11.758l-3.76-3.76L14 4.242z" - style="fill:currentColor" - /> - </svg> - </button> - </div> - <div - class="emotion-3" - data-test="global-message__SUCCESS" - role="status" - > - Test 2 - <button - class="button button-small emotion-2 button-icon" - level="SUCCESS" - style="color:#fff" - type="button" - > - <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="M14 4.242L11.758 2l-3.76 3.76L4.242 2 2 4.242l3.756 3.756L2 11.758 4.242 14l3.756-3.76 3.76 3.76L14 11.758l-3.76-3.76L14 4.242z" - style="fill:currentColor" - /> - </svg> - </button> - </div> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/HelpTooltip-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/HelpTooltip-test.tsx.snap deleted file mode 100644 index abf28dfdd32..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/HelpTooltip-test.tsx.snap +++ /dev/null @@ -1,53 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render dark helptooltip properly: dark 1`] = ` -<HelpTooltip - overlay={ - <div - className="my-overlay" - /> - } -> - <ContextConsumer> - <Component /> - </ContextConsumer> -</HelpTooltip> -`; - -exports[`should render dark helptooltip properly: dark icon 1`] = ` -<HelpIcon - fill="rgba(0, 0, 0, 0.25)" - fillInner="#ffffff" - size={14} -/> -`; - -exports[`should render properly: default 1`] = ` -<div - className="help-tooltip" -> - <Tooltip - mouseLeaveDelay={0.25} - overlay={ - <div - className="my-overlay" - /> - } - > - <span - className="display-inline-flex-center" - > - <ContextConsumer> - <Component /> - </ContextConsumer> - </span> - </Tooltip> -</div> -`; - -exports[`should render properly: default icon 1`] = ` -<HelpIcon - fill="#b4b4b4" - size={12} -/> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/IdentityProviderLink-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/IdentityProviderLink-test.tsx.snap deleted file mode 100644 index d3a38a52376..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/IdentityProviderLink-test.tsx.snap +++ /dev/null @@ -1,21 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<a - className="identity-provider-link" - href="/url/foo/bar" - style={ - Object { - "backgroundColor": "#000", - } - } -> - <img - alt="Foo" - height={20} - src="/some/path" - width={20} - /> - Link text -</a> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/InputValidationField-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/InputValidationField-test.tsx.snap deleted file mode 100644 index 16f3e1c2dfa..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/InputValidationField-test.tsx.snap +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<ModalValidationField - description="Field description" - dirty={true} - error="Bad formatting" - label="Foo field" - touched={true} -> - <Component /> -</ModalValidationField> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ListFooter-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ListFooter-test.tsx.snap deleted file mode 100644 index 2d55aa0d03b..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ListFooter-test.tsx.snap +++ /dev/null @@ -1,85 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -<footer - className="spacer-top note text-center" -> - x_of_y_shown.3.5 - <Button - className="spacer-left" - data-test="show-more" - onClick={[MockFunction]} - > - show_more - </Button> -</footer> -`; - -exports[`should render correctly: empty if everything is loaded 1`] = ` -<footer - className="spacer-top note text-center" -> - x_of_y_shown.5.5 -</footer> -`; - -exports[`should render correctly: empty if no loadMore nor reload props 1`] = ` -<footer - className="spacer-top note text-center" -> - x_of_y_shown.3.5 -</footer> -`; - -exports[`should render correctly: loading 1`] = ` -<footer - className="spacer-top note text-center" -> - x_of_y_shown.3.5 - <Button - className="spacer-left" - data-test="show-more" - disabled={true} - onClick={[MockFunction]} - > - show_more - </Button> - <DeferredSpinner - className="text-bottom spacer-left position-absolute" - /> -</footer> -`; - -exports[`should render correctly: reload 1`] = ` -<footer - className="spacer-top note text-center" -> - x_of_y_shown.3.5 - <Button - className="spacer-left" - data-test="reload" - onClick={[MockFunction]} - > - reload - </Button> -</footer> -`; - -exports[`should render correctly: reload, loading 1`] = ` -<footer - className="spacer-top note text-center" -> - x_of_y_shown.3.5 - <Button - className="spacer-left" - data-test="reload" - disabled={true} - onClick={[MockFunction]} - > - reload - </Button> - <DeferredSpinner - className="text-bottom spacer-left position-absolute" - /> -</footer> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ModalValidationField-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ModalValidationField-test.tsx.snap deleted file mode 100644 index 4b4e605c0ad..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ModalValidationField-test.tsx.snap +++ /dev/null @@ -1,73 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should display the field as valid 1`] = ` -<div - className="modal-validation-field" -> - <label> - Foo - </label> - <input - className="is-valid" - type="text" - /> - <AlertSuccessIcon - className="little-spacer-top" - /> -</div> -`; - -exports[`should display the field with an error 1`] = ` -<div - className="modal-validation-field" -> - <label> - Foo - </label> - <input - className="is-invalid" - type="text" - /> - <AlertErrorIcon - className="little-spacer-top" - /> - <p - className="text-danger" - > - Is required - </p> -</div> -`; - -exports[`should display the field without any error/validation 1`] = ` -<div - className="modal-validation-field" -> - <label> - Foo - </label> - <input - className="" - type="text" - /> - <div - className="modal-field-description" - > - Describe Foo. - </div> -</div> -`; - -exports[`should display the field without any error/validation 2`] = ` -<div - className="modal-validation-field" -> - <label> - Foo - </label> - <input - className="" - type="text" - /> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/OutsideClickHandler-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/OutsideClickHandler-test.tsx.snap deleted file mode 100644 index a4f533d8e3a..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/OutsideClickHandler-test.tsx.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - id="children" -/> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Radio-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Radio-test.tsx.snap deleted file mode 100644 index 8649fba79b8..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Radio-test.tsx.snap +++ /dev/null @@ -1,29 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render properly: checked 1`] = ` -<a - aria-checked={true} - className="display-inline-flex-center link-radio" - href="#" - onClick={[Function]} - role="radio" -> - <i - className="icon-radio spacer-right is-checked" - /> -</a> -`; - -exports[`should render properly: not checked 1`] = ` -<a - aria-checked={false} - className="display-inline-flex-center link-radio" - href="#" - onClick={[Function]} - role="radio" -> - <i - className="icon-radio spacer-right" - /> -</a> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/RadioCard-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/RadioCard-test.tsx.snap deleted file mode 100644 index e58f9d73597..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/RadioCard-test.tsx.snap +++ /dev/null @@ -1,172 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should be actionable 1`] = ` -<div - className="radio-card radio-card-actionable" - onClick={[MockFunction]} - role="radio" - tabIndex={0} -> - <h2 - className="radio-card-header big-spacer-bottom" - > - <span - className="display-flex-center link-radio" - > - <i - className="icon-radio spacer-right" - /> - Radio Card - </span> - </h2> - <div - className="radio-card-body" - > - <div> - content - </div> - </div> -</div> -`; - -exports[`should be actionable 2`] = ` -<div - aria-checked={true} - className="radio-card radio-card-actionable selected" - onClick={ - [MockFunction] { - "calls": Array [ - Array [ - Object { - "currentTarget": Object { - "blur": [Function], - }, - "preventDefault": [Function], - "stopPropagation": [Function], - "target": Object { - "blur": [Function], - }, - }, - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], - } - } - role="radio" - tabIndex={0} -> - <h2 - className="radio-card-header big-spacer-bottom" - > - <span - className="display-flex-center link-radio" - > - <i - className="icon-radio spacer-right is-checked" - /> - Radio Card - </span> - info - </h2> - <div - className="radio-card-body" - > - <div> - content - </div> - </div> -</div> -`; - -exports[`should render correctly 1`] = ` -<div - className="radio-card" - role="radio" - tabIndex={0} -> - <h2 - className="radio-card-header big-spacer-bottom" - > - <span - className="display-flex-center link-radio" - > - Radio Card - </span> - info - </h2> - <div - className="radio-card-body" - > - <div> - content - </div> - </div> - <div - className="radio-card-recommended" - > - <RecommendedIcon - className="spacer-right" - /> - <FormattedMessage - defaultMessage="Recommended for you" - id="Recommended for you" - values={ - Object { - "recommended": <strong> - recommended - </strong>, - } - } - /> - </div> -</div> -`; - -exports[`should render correctly 2`] = ` -<div - className="radio-card radio-card-vertical" - role="radio" - tabIndex={0} -> - <h2 - className="radio-card-header big-spacer-bottom" - > - <span - className="display-flex-center link-radio" - > - Radio Card Vertical - </span> - info - </h2> - <div - className="radio-card-body" - > - <div> - content - </div> - </div> - <div - className="radio-card-recommended" - > - <RecommendedIcon - className="spacer-right" - /> - <FormattedMessage - defaultMessage="Recommended for you" - id="Recommended for you" - values={ - Object { - "recommended": <strong> - recommended - </strong>, - } - } - /> - </div> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/RadioToggle-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/RadioToggle-test.tsx.snap deleted file mode 100644 index 791d312e720..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/RadioToggle-test.tsx.snap +++ /dev/null @@ -1,92 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`accepts advanced options fields 1`] = ` -<ul - className="radio-toggle" -> - <li - key="one" - > - <input - checked={false} - id="sample__one" - name="sample" - onChange={[Function]} - type="radio" - /> - <Tooltip - overlay="foo" - > - <label - htmlFor="sample__one" - > - first - </label> - </Tooltip> - </li> - <li - key="two" - > - <input - checked={false} - disabled={true} - id="sample__two" - name="sample" - onChange={[Function]} - type="radio" - /> - <Tooltip - overlay="bar" - > - <label - htmlFor="sample__two" - > - second - </label> - </Tooltip> - </li> -</ul> -`; - -exports[`renders 1`] = ` -<ul - className="radio-toggle" -> - <li - key="one" - > - <input - checked={false} - id="sample__one" - name="sample" - onChange={[Function]} - type="radio" - /> - <Tooltip> - <label - htmlFor="sample__one" - > - first - </label> - </Tooltip> - </li> - <li - key="two" - > - <input - checked={false} - id="sample__two" - name="sample" - onChange={[Function]} - type="radio" - /> - <Tooltip> - <label - htmlFor="sample__two" - > - second - </label> - </Tooltip> - </li> -</ul> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ReloadButton-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ReloadButton-test.tsx.snap deleted file mode 100644 index 9510ca69cca..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ReloadButton-test.tsx.snap +++ /dev/null @@ -1,46 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should handle click 1`] = ` -<Tooltip - overlay="reload" -> - <a - className="link-no-underline" - href="#" - onClick={[Function]} - > - <ContextConsumer> - <Component /> - </ContextConsumer> - </a> -</Tooltip> -`; - -exports[`should render properly 1`] = ` -<Tooltip - overlay="reload" -> - <a - className="link-no-underline" - href="#" - onClick={[Function]} - > - <ContextConsumer> - <Component /> - </ContextConsumer> - </a> -</Tooltip> -`; - -exports[`should render properly 2`] = ` -<svg - height="24" - viewBox="0 0 18 24" - width="18" -> - <path - d="M16.6454 8.1084c-.3-.5-.9-.7-1.4-.4-.5.3-.7.9-.4 1.4.9 1.6 1.1 3.4.6 5.1-.5 1.7-1.7 3.2-3.2 4-3.3 1.8-7.4.6-9.1-2.7-1.8-3.1-.8-6.9 2.1-8.8v3.3h2v-7h-7v2h3.9c-3.7 2.5-5 7.5-2.8 11.4 1.6 3 4.6 4.6 7.7 4.6 1.4 0 2.8-.3 4.2-1.1 2-1.1 3.5-3 4.2-5.2.6-2.2.3-4.6-.8-6.6z" - fill="#777" - /> -</svg> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SearchBox-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SearchBox-test.tsx.snap deleted file mode 100644 index 4ed69eb6a29..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SearchBox-test.tsx.snap +++ /dev/null @@ -1,37 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` -<div - className="search-box" - title="" -> - <input - aria-label="search_verb" - autoComplete="off" - className="search-box-input" - maxLength={150} - onChange={[Function]} - onKeyDown={[Function]} - placeholder="placeholder" - type="search" - value="foo" - /> - <DeferredSpinner - loading={false} - > - <SearchIcon - className="search-box-magnifier" - /> - </DeferredSpinner> - <ClearButton - aria-label="clear" - className="button-tiny search-box-clear" - iconProps={ - Object { - "size": 12, - } - } - onClick={[Function]} - /> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SearchSelect-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SearchSelect-test.tsx.snap deleted file mode 100644 index 792343f1a73..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SearchSelect-test.tsx.snap +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render Select 1`] = ` -<Select - autoFocus={true} - escapeClearsValue={false} - filterOption={[Function]} - isLoading={false} - noResultsText="select2.tooShort.2" - onBlurResetsInput={true} - onChange={[Function]} - onInputChange={[Function]} - options={Array []} - placeholder="search_verb" - searchable={true} -/> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectList-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectList-test.tsx.snap deleted file mode 100644 index 14d46bbffc3..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectList-test.tsx.snap +++ /dev/null @@ -1,558 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should cancel filter selection when search is active 1`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": false, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": false, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": false, - "label": "all", - "value": "all", - }, - ] - } - value="deselected" - /> - <SearchBox - autoFocus={true} - loading={false} - onChange={[Function]} - placeholder="search_verb" - value="" - /> - </div> - <SelectListListContainer - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="deselected" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> -</div> -`; - -exports[`should cancel filter selection when search is active 2`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": true, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": true, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": true, - "label": "all", - "value": "all", - }, - ] - } - value="deselected" - /> - <SearchBox - autoFocus={true} - loading={false} - onChange={[Function]} - placeholder="search_verb" - value="test" - /> - </div> - <SelectListListContainer - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="all" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> -</div> -`; - -exports[`should cancel filter selection when search is active 3`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": false, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": false, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": false, - "label": "all", - "value": "all", - }, - ] - } - value="deselected" - /> - <SearchBox - autoFocus={true} - loading={false} - onChange={[Function]} - placeholder="search_verb" - value="" - /> - </div> - <SelectListListContainer - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="deselected" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> -</div> -`; - -exports[`should display a loader when searching 1`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": false, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": false, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": false, - "label": "all", - "value": "all", - }, - ] - } - value="selected" - /> - <SearchBox - autoFocus={true} - loading={true} - onChange={[Function]} - placeholder="search_verb" - value="" - /> - </div> - <SelectListListContainer - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="selected" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> -</div> -`; - -exports[`should display pagination element properly and call search method with correct parameters 1`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": false, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": false, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": false, - "label": "all", - "value": "all", - }, - ] - } - value="selected" - /> - <SearchBox - autoFocus={true} - loading={true} - onChange={[Function]} - placeholder="search_verb" - value="" - /> - </div> - <SelectListListContainer - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="selected" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> - <ListFooter - count={3} - loadMore={[Function]} - reload={[Function]} - total={100} - /> -</div> -`; - -exports[`should display pagination element properly and call search method with correct parameters 2`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": false, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": false, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": false, - "label": "all", - "value": "all", - }, - ] - } - value="selected" - /> - <SearchBox - autoFocus={true} - loading={true} - onChange={[Function]} - placeholder="search_verb" - value="" - /> - </div> - <SelectListListContainer - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="selected" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> - <ListFooter - count={3} - loadMore={[Function]} - needReload={true} - reload={[Function]} - total={100} - /> -</div> -`; - -exports[`should display properly with advanced features 1`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": false, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": false, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": false, - "label": "all", - "value": "all", - }, - ] - } - value="selected" - /> - <SearchBox - autoFocus={true} - loading={false} - onChange={[Function]} - placeholder="search_verb" - value="" - /> - </div> - <SelectListListContainer - allowBulkSelection={true} - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="selected" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - readOnly={true} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> - <ListFooter - count={3} - loadMore={[Function]} - reload={[Function]} - total={125} - /> -</div> -`; - -exports[`should display properly with basics features 1`] = ` -<div - className="select-list" -> - <div - className="display-flex-center" - > - <RadioToggle - className="select-list-filter spacer-right" - disabled={false} - name="filter" - onCheck={[Function]} - options={ - Array [ - Object { - "disabled": false, - "label": "selected", - "value": "selected", - }, - Object { - "disabled": false, - "label": "unselected", - "value": "deselected", - }, - Object { - "disabled": false, - "label": "all", - "value": "all", - }, - ] - } - value="selected" - /> - <SearchBox - autoFocus={true} - loading={false} - onChange={[Function]} - placeholder="search_verb" - value="" - /> - </div> - <SelectListListContainer - disabledElements={ - Array [ - "bar", - ] - } - elements={ - Array [ - "foo", - "bar", - "baz", - ] - } - filter="selected" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selectedElements={ - Array [ - "foo", - ] - } - /> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectListListContainer-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectListListContainer-test.tsx.snap deleted file mode 100644 index bf96116e95a..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectListListContainer-test.tsx.snap +++ /dev/null @@ -1,61 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<div - className="select-list-list-container spacer-top" -> - <ul - className="menu" - > - <li> - <Checkbox - checked={true} - disabled={false} - onCheck={[Function]} - thirdState={true} - > - <span - className="big-spacer-left" - > - bulk_change - <DeferredSpinner - className="spacer-left" - loading={false} - timeout={10} - /> - </span> - </Checkbox> - </li> - <li - className="divider" - /> - <SelectListListElement - disabled={false} - element="foo" - key="foo" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selected={true} - /> - <SelectListListElement - disabled={false} - element="bar" - key="bar" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selected={false} - /> - <SelectListListElement - disabled={false} - element="baz" - key="baz" - onSelect={[MockFunction]} - onUnselect={[MockFunction]} - renderElement={[Function]} - selected={false} - /> - </ul> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectListListElement-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectListListElement-test.tsx.snap deleted file mode 100644 index e5d4ba3601f..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SelectListListElement-test.tsx.snap +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should display a loader when checking 1`] = ` -<li - className="" -> - <Checkbox - checked={false} - className="select-list-list-checkbox" - loading={false} - onCheck={[Function]} - thirdState={false} - > - <span - className="little-spacer-left" - > - foo - </span> - </Checkbox> -</li> -`; - -exports[`should display a loader when checking 2`] = ` -<li - className="" -> - <Checkbox - checked={false} - className="select-list-list-checkbox" - loading={true} - onCheck={[Function]} - thirdState={false} - > - <span - className="little-spacer-left" - > - foo - </span> - </Checkbox> -</li> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SimpleModal-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SimpleModal-test.tsx.snap deleted file mode 100644 index 49b14a9e20f..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/SimpleModal-test.tsx.snap +++ /dev/null @@ -1,52 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` -<Modal - contentLabel="" - onRequestClose={[MockFunction]} -> - <div /> -</Modal> -`; - -exports[`submits 1`] = ` -<Modal - contentLabel="" - onRequestClose={[MockFunction]} -> - <Button - disabled={false} - onClick={[Function]} - > - close - </Button> -</Modal> -`; - -exports[`submits 2`] = ` -<Modal - contentLabel="" - onRequestClose={[MockFunction]} -> - <Button - disabled={true} - onClick={[Function]} - > - close - </Button> -</Modal> -`; - -exports[`submits 3`] = ` -<Modal - contentLabel="" - onRequestClose={[MockFunction]} -> - <Button - disabled={false} - onClick={[Function]} - > - close - </Button> -</Modal> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Tabs-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Tabs-test.tsx.snap deleted file mode 100644 index 2db4cec05a8..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Tabs-test.tsx.snap +++ /dev/null @@ -1,52 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should disable single tab 1`] = ` -<li> - <a - className="js-foo disabled selected" - href="#" - onClick={[Function]} - > - <span> - Foo - </span> - </a> -</li> -`; - -exports[`should render correctly 1`] = ` -<ul - className="flex-tabs" -> - <Tab - key="foo" - name="foo" - onSelect={[MockFunction]} - selected={false} - > - Foo - </Tab> - <Tab - key="bar" - name="bar" - onSelect={[MockFunction]} - selected={true} - > - Bar - </Tab> -</ul> -`; - -exports[`should render single tab correctly 1`] = ` -<li> - <a - className="js-foo selected" - href="#" - onClick={[Function]} - > - <span> - Foo - </span> - </a> -</li> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Toggle-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Toggle-test.tsx.snap deleted file mode 100644 index 8862993eb41..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Toggle-test.tsx.snap +++ /dev/null @@ -1,55 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: disabled 1`] = ` -<Button - className="boolean-toggle boolean-toggle-on" - disabled={true} - name="toggle-name" - onClick={[Function]} -> - <div - aria-label="on" - className="boolean-toggle-handle" - > - <CheckIcon - size={12} - /> - </div> -</Button> -`; - -exports[`should render correctly: off 1`] = ` -<Button - className="boolean-toggle" - disabled={true} - name="toggle-name" - onClick={[Function]} -> - <div - aria-label="off" - className="boolean-toggle-handle" - > - <CheckIcon - size={12} - /> - </div> -</Button> -`; - -exports[`should render correctly: on 1`] = ` -<Button - className="boolean-toggle boolean-toggle-on" - disabled={true} - name="toggle-name" - onClick={[Function]} -> - <div - aria-label="on" - className="boolean-toggle-handle" - > - <CheckIcon - size={12} - /> - </div> -</Button> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Toggler-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Toggler-test.tsx.snap deleted file mode 100644 index dfe5d96a394..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Toggler-test.tsx.snap +++ /dev/null @@ -1,58 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should not render click wrappers 1`] = ` -<Fragment> - <div - id="toggle" - /> - <div - id="overlay" - /> -</Fragment> -`; - -exports[`should render children and overlay 1`] = ` -<Fragment> - <div - id="toggle" - /> - <OutsideClickHandler - onClickOutside={[MockFunction]} - > - <EscKeydownHandler - onKeydown={[MockFunction]} - > - <div - id="overlay" - /> - </EscKeydownHandler> - </OutsideClickHandler> -</Fragment> -`; - -exports[`should render only children 1`] = ` -<Fragment> - <div - id="toggle" - /> -</Fragment> -`; - -exports[`should render when closeOnClick=true 1`] = ` -<Fragment> - <div - id="toggle" - /> - <DocumentClickHandler - onClick={[MockFunction]} - > - <EscKeydownHandler - onKeydown={[MockFunction]} - > - <div - id="overlay" - /> - </EscKeydownHandler> - </DocumentClickHandler> -</Fragment> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Tooltip-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Tooltip-test.tsx.snap deleted file mode 100644 index 786b1bfe0ad..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/Tooltip-test.tsx.snap +++ /dev/null @@ -1,40 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should not render empty tooltips 1`] = ` -<div - id="tooltip" -/> -`; - -exports[`should not render empty tooltips 2`] = ` -<div - id="tooltip" -/> -`; - -exports[`should render 1`] = ` -<Fragment> - <div - id="tooltip" - onMouseEnter={[Function]} - onMouseLeave={[Function]} - /> -</Fragment> -`; - -exports[`should render 2`] = ` -<Fragment> - <div - id="tooltip" - onMouseEnter={[Function]} - onMouseLeave={[Function]} - /> - <TooltipPortal> - <WithTheme(ScreenPositionFixer) - ready={false} - > - <Component /> - </WithTheme(ScreenPositionFixer)> - </TooltipPortal> -</Fragment> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationForm-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationForm-test.tsx.snap deleted file mode 100644 index e00f009ef2f..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationForm-test.tsx.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render and submit 1`] = ` -<Formik - enableReinitialize={false} - initialValues={ - Object { - "foo": "bar", - } - } - isInitialValid={false} - onSubmit={[Function]} - validate={[MockFunction]} - validateOnBlur={true} - validateOnChange={true} -> - <Component /> -</Formik> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationInput-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationInput-test.tsx.snap deleted file mode 100644 index c2d68a1d2bf..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationInput-test.tsx.snap +++ /dev/null @@ -1,98 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render 1`] = ` -<div> - <label - htmlFor="field-id" - > - <span - className="text-middle" - > - <strong> - Field label - </strong> - <MandatoryFieldMarker /> - </span> - <HelpTooltip - className="spacer-left" - overlay="Help message" - /> - </label> - <div - className="little-spacer-top spacer-bottom" - > - <div /> - </div> - <div - className="note abs-width-400" - > - My description - </div> -</div> -`; - -exports[`should render when valid 1`] = ` -<div> - <label - htmlFor="field-id" - > - <span - className="text-middle" - > - <strong> - Field label - </strong> - <MandatoryFieldMarker /> - </span> - </label> - <div - className="little-spacer-top spacer-bottom" - > - <div /> - <AlertSuccessIcon - className="spacer-left text-middle" - /> - </div> - <div - className="note abs-width-400" - > - My description - </div> -</div> -`; - -exports[`should render with error 1`] = ` -<div> - <label - htmlFor="field-id" - > - <span - className="text-middle" - > - <strong> - Field label - </strong> - </span> - </label> - <div - className="little-spacer-top spacer-bottom" - > - <div /> - <AlertErrorIcon - className="spacer-left text-middle" - /> - <span - className="little-spacer-left text-danger text-middle" - > - Field error message - </span> - </div> - <div - className="note abs-width-400" - > - <div> - My description - </div> - </div> -</div> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationModal-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationModal-test.tsx.snap deleted file mode 100644 index 67db9979a9e..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/ValidationModal-test.tsx.snap +++ /dev/null @@ -1,110 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<Modal - contentLabel="title" - onRequestClose={[MockFunction]} -> - <ValidationForm - initialValues={ - Object { - "field": "foo", - } - } - isInitialValid={true} - onSubmit={[Function]} - validate={[MockFunction]} - > - <Component /> - </ValidationForm> -</Modal> -`; - -exports[`should render correctly 2`] = ` -<ContextProvider - value={ - Object { - "dirty": false, - "errors": Object {}, - "handleBlur": [Function], - "handleChange": [Function], - "handleReset": [Function], - "handleSubmit": [Function], - "initialValues": Object { - "field": "foo", - }, - "isSubmitting": false, - "isValid": true, - "isValidating": false, - "registerField": [Function], - "resetForm": [Function], - "setError": [Function], - "setErrors": [Function], - "setFieldError": [Function], - "setFieldTouched": [Function], - "setFieldValue": [Function], - "setFormikState": [Function], - "setStatus": [Function], - "setSubmitting": [Function], - "setTouched": [Function], - "setValues": [Function], - "submitCount": 0, - "submitForm": [Function], - "touched": Object {}, - "unregisterField": [Function], - "validate": [MockFunction], - "validateField": [Function], - "validateForm": [Function], - "validateOnBlur": true, - "validateOnChange": true, - "validationSchema": undefined, - "values": Object { - "field": "foo", - }, - } - } -> - <form - onSubmit={[Function]} - > - <header - className="modal-head" - > - <h2> - title - </h2> - </header> - <div - className="modal-body" - > - <input - name="field" - onBlur={[Function]} - onChange={[Function]} - type="text" - value="foo" - /> - </div> - <footer - className="modal-foot" - > - <DeferredSpinner - className="spacer-right" - loading={false} - /> - <SubmitButton - className="button-red" - disabled={true} - > - confirm - </SubmitButton> - <ResetButtonLink - disabled={false} - onClick={[MockFunction]} - > - cancel - </ResetButtonLink> - </footer> - </form> -</ContextProvider> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/buttons-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/buttons-test.tsx.snap deleted file mode 100644 index 8d915b89387..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/buttons-test.tsx.snap +++ /dev/null @@ -1,31 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Button should render correctly 1`] = ` -<button - className="button" - onClick={[Function]} - type="button" -> - My button -</button> -`; - -exports[`ButtonIcon should render correctly 1`] = ` -<Tooltip - mouseEnterDelay={0.4} - overlay="my tooltip" - visible={true} -> - <Button - className="button-icon" - stopPropagation={true} - style={ - Object { - "color": "#236a97", - } - } - > - <i /> - </Button> -</Tooltip> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/clipboard-test.tsx.snap b/server/sonar-ui-common/components/controls/__tests__/__snapshots__/clipboard-test.tsx.snap deleted file mode 100644 index de2081cb464..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/__snapshots__/clipboard-test.tsx.snap +++ /dev/null @@ -1,52 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ClipboardBase should display correctly 1`] = ` -<Button> - copy -</Button> -`; - -exports[`ClipboardButton should display correctly 1`] = ` -<Tooltip - overlay="copied_action" - visible={false} -> - <Button - className="no-select" - data-clipboard-text="foo" - innerRef={[Function]} - > - <CopyIcon - className="little-spacer-right" - /> - copy - </Button> -</Tooltip> -`; - -exports[`ClipboardButton should render a custom label if provided 1`] = ` -<Tooltip - overlay="copied_action" - visible={false} -> - <Button - className="no-select" - data-clipboard-text="foo" - innerRef={[Function]} - > - Foo Bar - </Button> -</Tooltip> -`; - -exports[`ClipboardIconButton should display correctly 1`] = ` -<ButtonIcon - aria-label="copy_to_clipboard" - className="no-select" - data-clipboard-text="foo" - innerRef={[Function]} - tooltip="copy_to_clipboard" -> - <CopyIcon /> -</ButtonIcon> -`; diff --git a/server/sonar-ui-common/components/controls/__tests__/buttons-test.tsx b/server/sonar-ui-common/components/controls/__tests__/buttons-test.tsx deleted file mode 100644 index c199c5778cc..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/buttons-test.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 { shallow } from 'enzyme'; -import * as React from 'react'; -import { click, mockEvent } from '../../../helpers/testUtils'; -import { Button, ButtonIcon, ButtonIconProps } from '../buttons'; - -describe('Button', () => { - it('should render correctly', () => { - const onClick = jest.fn(); - const preventDefault = jest.fn(); - const stopPropagation = jest.fn(); - const wrapper = shallowRender({ onClick }); - expect(wrapper).toMatchSnapshot(); - click(wrapper.find('button'), mockEvent({ preventDefault, stopPropagation })); - expect(onClick).toBeCalled(); - expect(preventDefault).toBeCalled(); - expect(stopPropagation).not.toBeCalled(); - }); - - it('should not stop propagation, but prevent default of the click event', () => { - const preventDefault = jest.fn(); - const stopPropagation = jest.fn(); - const wrapper = shallowRender({ preventDefault: false, stopPropagation: true }); - click(wrapper.find('button'), mockEvent({ preventDefault, stopPropagation })); - expect(preventDefault).not.toBeCalled(); - expect(stopPropagation).toBeCalled(); - }); - - it('should disable buttons with a class', () => { - const preventDefault = jest.fn(); - const onClick = jest.fn(); - const button = shallowRender({ disabled: true, onClick, preventDefault: false }).find('button'); - expect(button.props().disabled).toBeUndefined(); - expect(button.props().className).toContain('disabled'); - expect(button.props()['aria-disabled']).toBe(true); - click(button, mockEvent({ preventDefault })); - expect(onClick).not.toBeCalled(); - expect(preventDefault).toBeCalled(); - }); - - function shallowRender(props: Partial<Button['props']> = {}) { - return shallow<Button>(<Button {...props}>My button</Button>); - } -}); - -describe('ButtonIcon', () => { - it('should render correctly', () => { - const wrapper = shallowRender(); - expect(wrapper).toMatchSnapshot(); - }); - - function shallowRender(props: Partial<ButtonIconProps> = {}) { - return shallow( - <ButtonIcon tooltip="my tooltip" tooltipProps={{ visible: true }} {...props}> - <i /> - </ButtonIcon> - ).dive(); - } -}); diff --git a/server/sonar-ui-common/components/controls/__tests__/clipboard-test.tsx b/server/sonar-ui-common/components/controls/__tests__/clipboard-test.tsx deleted file mode 100644 index 36b2d6f02db..00000000000 --- a/server/sonar-ui-common/components/controls/__tests__/clipboard-test.tsx +++ /dev/null @@ -1,102 +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 { Button } from '../buttons'; -import { ClipboardBase, ClipboardButton, ClipboardIconButton } from '../clipboard'; - -const constructor = jest.fn(); -const destroy = jest.fn(); -const on = jest.fn(); - -jest.mock( - 'clipboard', - () => - function (...args: any) { - constructor(...args); - return { - destroy, - on, - }; - } -); - -jest.useFakeTimers(); - -describe('ClipboardBase', () => { - it('should display correctly', () => { - const children = jest.fn().mockReturnValue(<Button>copy</Button>); - const wrapper = shallowRender(children); - const instance = wrapper.instance(); - expect(wrapper).toMatchSnapshot(); - instance.handleSuccessCopy(); - expect(children).toBeCalledWith({ copySuccess: true, setCopyButton: instance.setCopyButton }); - jest.runAllTimers(); - expect(children).toBeCalledWith({ copySuccess: false, setCopyButton: instance.setCopyButton }); - }); - - it('should allow its content to be copied', () => { - const wrapper = mountRender(({ setCopyButton }) => ( - <Button innerRef={setCopyButton}>click</Button> - )); - const button = wrapper.find('button').getDOMNode(); - const instance = wrapper.instance(); - - expect(constructor).toBeCalledWith(button); - expect(on).toBeCalledWith('success', instance.handleSuccessCopy); - - jest.clearAllMocks(); - - wrapper.unmount(); - expect(destroy).toBeCalled(); - }); - - function shallowRender(children?: ClipboardBase['props']['children']) { - return shallow<ClipboardBase>(<ClipboardBase>{children || (() => null)}</ClipboardBase>); - } - - function mountRender(children?: ClipboardBase['props']['children']) { - return mount<ClipboardBase>(<ClipboardBase>{children || (() => null)}</ClipboardBase>); - } -}); - -describe('ClipboardButton', () => { - it('should display correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - }); - - it('should render a custom label if provided', () => { - expect(shallowRender('Foo Bar')).toMatchSnapshot(); - }); - - function shallowRender(children?: React.ReactNode) { - return shallow(<ClipboardButton copyValue="foo">{children}</ClipboardButton>).dive(); - } -}); - -describe('ClipboardIconButton', () => { - it('should display correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - }); - - function shallowRender() { - return shallow(<ClipboardIconButton copyValue="foo" />).dive(); - } -}); diff --git a/server/sonar-ui-common/components/controls/buttons.css b/server/sonar-ui-common/components/controls/buttons.css deleted file mode 100644 index 8a8f9447cb3..00000000000 --- a/server/sonar-ui-common/components/controls/buttons.css +++ /dev/null @@ -1,322 +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. - */ -.button { - display: inline-flex; - align-items: center; - justify-content: center; - vertical-align: middle; - height: var(--controlHeight); - line-height: calc(var(--controlHeight) - 2px); - padding: 0 var(--gridSize); - border: 1px solid var(--darkBlue); - border-radius: 2px; - box-sizing: border-box; - background: transparent; - color: var(--darkBlue); - font-weight: 600; - font-size: var(--smallFontSize); - text-decoration: none; - cursor: pointer; - outline: none; - transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease; -} - -.button:hover, -.button.button-active { - background: var(--darkBlue); - color: var(--white); -} - -.button:active { - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} - -.button:focus { - box-shadow: 0 0 0 3px rgba(35, 106, 151, 0.25); -} - -.button-primary { - background: var(--darkBlue); - border-color: var(--darkBlue); - color: var(--white); -} - -.button-primary:hover { - background: var(--veryDarkBlue); - border-color: var(--veryDarkBlue); -} - -.button-primary.button-light { - background: var(--blue); - border-color: var(--blue); - color: var(--white); -} - -.button-primary.button-light:hover { - background: var(--darkBlue); - border-color: var(--darkBlue); -} - -.button.disabled { - color: var(--disableGrayText) !important; - border-color: var(--disableGrayBorder) !important; - background: var(--disableGrayBg) !important; - cursor: not-allowed !important; - box-shadow: none !important; -} - -/* #region .button-red */ -.button-red { - border-color: var(--red); - color: var(--red); -} - -.button-red:hover, -.button-red.active { - background: var(--red); - color: var(--white); -} - -.button-red:focus { - box-shadow: 0 0 0 3px rgba(212, 51, 63, 0.25); -} - -/* #endregion */ - -/* #region .button-success */ -.button-success { - border-color: var(--green); - color: var(--green); -} - -.button-success:hover, -.button-success.active { - background: var(--green); - color: var(--white); -} - -.button-success:focus { - box-shadow: 0 0 0 3px rgba(0, 170, 0, 0.25); -} - -/* #endregion */ - -/* #region .button-link */ -.button-link { - display: inline-flex; - height: auto; - /* Keep this to not inherit the height from .button */ - line-height: 1; - margin: 0; - padding: 0; - border: none; - border-radius: 0; - background: transparent; - color: var(--darkBlue); - border-bottom: 1px solid var(--lightBlue); - font-weight: 400; - font-size: inherit; - transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, border-bottom 0.2s ease; -} - -.dropdown .button-link { - border-bottom: none; -} - -.button-link:hover { - background: transparent; - color: var(--blue); -} - -.button-link:active, -.button-link:focus { - box-shadow: none; - outline: 1px dotted var(--blue); -} - -.button-link.disabled { - color: var(--secondFontColor); - background: transparent !important; - cursor: default; -} - -/* #endregion */ - -.button-small { - height: var(--smallControlHeight); - line-height: 18px; - padding: 0 6px; - font-size: 11px; -} - -.button-tiny { - height: var(--tinyControlHeight); - line-height: var(--tinyControlHeight); - padding: 0 calc(var(--gridSize) / 2); -} - -.button-large { - height: var(--largeControlHeight); - padding: 0 16px; - font-size: var(--mediumFontSize); -} - -.button-huge { - flex-direction: column; - padding: calc(2 * var(--gridSize)); - width: 200px; - height: 200px; - background-color: var(--white); - border: solid 1px var(--white); - border-radius: 3px; - transition: all 0.2s ease; - box-shadow: 0 1px 1px 1px var(--barBorderColor); -} - -.button-huge:hover, -.button-huge:focus, -.button-huge:active { - background-color: var(--white); - color: var(--darkBlue); - box-shadow: var(--defaultShadow); - transform: translateY(-2px); -} - -/* #region .button-group */ -/* TODO drop usage of this class in SQ (already dropped from SC) */ -.button-group { - display: inline-block; - vertical-align: middle; - font-size: 0; - white-space: nowrap; -} - -.button-group > button, -.button-group > .button { - position: relative; - z-index: var(--normalZIndex); - display: inline-block; - vertical-align: middle; - margin: 0; - cursor: pointer; -} - -.button-group > .button:hover:not(.disabled), -.button-group > .button:focus:not(.disabled), -.button-group > .button:active:not(.disabled), -.button-group > .button.active:not(.disabled) { - z-index: var(--aboveNormalZIndex); -} - -.button-group > .button.disabled { - z-index: var(--belowNormalZIndex); -} - -.button-group > .button:not(:first-child) { - border-top-left-radius: 0; - border-bottom-left-radius: 0; -} - -.button-group > .button:not(:last-child):not(.dropdown-toggle) { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -.button-group > .button + .button { - margin-left: -1px; -} - -.button-group > a:not(.button) { - vertical-align: middle; - margin: 0 8px; - font-size: var(--smallFontSize); -} - -/* #endregion */ - -/* #region .button-icon */ -.button-icon { - display: inline-flex; - justify-content: center; - align-items: center; - vertical-align: middle; - width: var(--controlHeight); - height: var(--controlHeight); - padding: 0; - border: none; - color: inherit; -} - -.button-icon.button-small { - width: var(--smallControlHeight); - height: var(--smallControlHeight); - padding: 0; -} - -.button-icon.button-small svg { - margin-top: 0; -} - -.button-icon.button-tiny { - width: var(--tinyControlHeight); - height: var(--tinyControlHeight); - padding: 0; -} - -.button-icon.button-tiny svg { - margin-top: 0; -} - -.button-icon:hover, -.button-icon:focus { - background-color: currentColor; -} - -.button-icon:not(.disabled):hover svg, -.button-icon:not(.disabled):focus svg { - color: var(--white); -} - -.button.button-icon.disabled { - background: transparent !important; -} - -/* #endregion */ - -.button-list { - display: inline-flex; - justify-content: space-between; - height: auto; - border: 1px solid var(--barBorderColor); - padding: var(--gridSize); - margin: calc(var(--gridSize) / 2); - color: var(--secondFontColor); - font-weight: normal; -} - -.button-list:hover { - background-color: white; - border-color: var(--blue); - color: var(--darkBlue); -} - -.no-select { - user-select: none !important; -} diff --git a/server/sonar-ui-common/components/controls/buttons.tsx b/server/sonar-ui-common/components/controls/buttons.tsx deleted file mode 100644 index f43c62bc9a6..00000000000 --- a/server/sonar-ui-common/components/controls/buttons.tsx +++ /dev/null @@ -1,182 +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 ChevronRightIcon from '../icons/ChevronRightIcon'; -import ClearIcon, { ClearIconProps } from '../icons/ClearIcon'; -import DeleteIcon from '../icons/DeleteIcon'; -import EditIcon from '../icons/EditIcon'; -import { IconProps } from '../icons/Icon'; -import { ThemeConsumer } from '../theme'; -import './buttons.css'; -import Tooltip, { TooltipProps } from './Tooltip'; - -type AllowedButtonAttributes = Pick< - React.ButtonHTMLAttributes<HTMLButtonElement>, - 'className' | 'disabled' | 'id' | 'style' | 'title' ->; - -interface ButtonProps extends AllowedButtonAttributes { - autoFocus?: boolean; - children?: React.ReactNode; - innerRef?: (node: HTMLElement | null) => void; - name?: string; - onClick?: () => void; - preventDefault?: boolean; - stopPropagation?: boolean; - type?: 'button' | 'submit' | 'reset' | undefined; -} - -export class Button extends React.PureComponent<ButtonProps> { - handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { - const { disabled, onClick, preventDefault = true, stopPropagation = false } = this.props; - - event.currentTarget.blur(); - if (preventDefault || disabled) { - event.preventDefault(); - } - if (stopPropagation) { - event.stopPropagation(); - } - - if (onClick && !disabled) { - onClick(); - } - }; - - render() { - const { - className, - disabled, - innerRef, - onClick, - preventDefault, - stopPropagation, - type = 'button', - ...props - } = this.props; - return ( - // eslint-disable-next-line react/button-has-type - <button - {...props} - aria-disabled={disabled} - className={classNames('button', className, { disabled })} - id={this.props.id} - onClick={this.handleClick} - ref={this.props.innerRef} - type={type} - /> - ); - } -} - -export function ButtonLink({ className, ...props }: ButtonProps) { - return <Button {...props} className={classNames('button-link', className)} />; -} - -export function SubmitButton(props: T.Omit<ButtonProps, 'type'>) { - // do not prevent default to actually submit a form - return <Button {...props} preventDefault={false} type="submit" />; -} - -export function ResetButtonLink(props: T.Omit<ButtonProps, 'type'>) { - return <ButtonLink {...props} type="reset" />; -} - -export interface ButtonIconProps extends ButtonProps { - 'aria-label'?: string; - 'aria-labelledby'?: string; - className?: string; - color?: string; - onClick?: () => void; - tooltip?: React.ReactNode; - tooltipProps?: Partial<TooltipProps>; -} - -export function ButtonIcon(props: ButtonIconProps) { - const { className, color, tooltip, tooltipProps, ...other } = props; - return ( - <ThemeConsumer> - {(theme) => ( - <Tooltip mouseEnterDelay={0.4} overlay={tooltip} {...tooltipProps}> - <Button - className={classNames(className, 'button-icon')} - stopPropagation={true} - style={{ color: color || theme.colors.darkBlue }} - {...other} - /> - </Tooltip> - )} - </ThemeConsumer> - ); -} - -interface ClearButtonProps extends ButtonIconProps { - className?: string; - iconProps?: ClearIconProps; - onClick?: () => void; -} - -export function ClearButton({ color, iconProps = {}, ...props }: ClearButtonProps) { - return ( - <ThemeConsumer> - {(theme) => ( - <ButtonIcon color={color || theme.colors.gray60} {...props}> - <ClearIcon {...iconProps} /> - </ButtonIcon> - )} - </ThemeConsumer> - ); -} - -interface ActionButtonProps extends ButtonIconProps { - className?: string; - iconProps?: IconProps; - onClick?: () => void; -} - -export function DeleteButton({ iconProps = {}, ...props }: ActionButtonProps) { - return ( - <ThemeConsumer> - {(theme) => ( - <ButtonIcon color={theme.colors.red} {...props}> - <DeleteIcon {...iconProps} /> - </ButtonIcon> - )} - </ThemeConsumer> - ); -} - -export function EditButton({ iconProps = {}, ...props }: ActionButtonProps) { - return ( - <ButtonIcon {...props}> - <EditIcon {...iconProps} /> - </ButtonIcon> - ); -} - -export function ListButton({ className, children, ...props }: ButtonProps) { - return ( - <Button className={classNames('button-list', className)} {...props}> - {children} - <ChevronRightIcon /> - </Button> - ); -} diff --git a/server/sonar-ui-common/components/controls/clipboard.tsx b/server/sonar-ui-common/components/controls/clipboard.tsx deleted file mode 100644 index 427000c17a7..00000000000 --- a/server/sonar-ui-common/components/controls/clipboard.tsx +++ /dev/null @@ -1,148 +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 Clipboard from 'clipboard'; -import * as React from 'react'; -import { translate } from '../../helpers/l10n'; -import CopyIcon from '../icons/CopyIcon'; -import { Button, ButtonIcon } from './buttons'; -import Tooltip from './Tooltip'; - -export interface State { - copySuccess: boolean; -} - -interface RenderProps { - setCopyButton: (node: HTMLElement | null) => void; - copySuccess: boolean; -} - -interface BaseProps { - children: (props: RenderProps) => React.ReactNode; -} - -export class ClipboardBase extends React.PureComponent<BaseProps, State> { - private clipboard?: Clipboard; - private copyButton?: HTMLElement | null; - mounted = false; - state: State = { copySuccess: false }; - - componentDidMount() { - this.mounted = true; - if (this.copyButton) { - this.clipboard = new Clipboard(this.copyButton); - this.clipboard.on('success', this.handleSuccessCopy); - } - } - - componentDidUpdate() { - if (this.clipboard) { - this.clipboard.destroy(); - } - if (this.copyButton) { - this.clipboard = new Clipboard(this.copyButton); - this.clipboard.on('success', this.handleSuccessCopy); - } - } - - componentWillUnmount() { - this.mounted = false; - if (this.clipboard) { - this.clipboard.destroy(); - } - } - - setCopyButton = (node: HTMLElement | null) => { - this.copyButton = node; - }; - - handleSuccessCopy = () => { - if (this.mounted) { - this.setState({ copySuccess: true }); - setTimeout(() => { - if (this.mounted) { - this.setState({ copySuccess: false }); - } - }, 1000); - } - }; - - render() { - return this.props.children({ - setCopyButton: this.setCopyButton, - copySuccess: this.state.copySuccess, - }); - } -} - -interface ButtonProps { - className?: string; - copyValue: string; - children?: React.ReactNode; -} - -export function ClipboardButton({ className, children, copyValue }: ButtonProps) { - return ( - <ClipboardBase> - {({ setCopyButton, copySuccess }) => ( - <Tooltip overlay={translate('copied_action')} visible={copySuccess}> - <Button - className={classNames('no-select', className)} - data-clipboard-text={copyValue} - innerRef={setCopyButton}> - {children || ( - <> - <CopyIcon className="little-spacer-right" /> - {translate('copy')} - </> - )} - </Button> - </Tooltip> - )} - </ClipboardBase> - ); -} - -interface IconButtonProps { - 'aria-label'?: string; - className?: string; - copyValue: string; -} - -export function ClipboardIconButton(props: IconButtonProps) { - const { className, copyValue } = props; - return ( - <ClipboardBase> - {({ setCopyButton, copySuccess }) => { - return ( - <ButtonIcon - aria-label={props['aria-label'] ?? translate('copy_to_clipboard')} - className={classNames('no-select', className)} - data-clipboard-text={copyValue} - innerRef={setCopyButton} - tooltip={translate(copySuccess ? 'copied_action' : 'copy_to_clipboard')} - tooltipProps={copySuccess ? { visible: copySuccess } : undefined}> - <CopyIcon /> - </ButtonIcon> - ); - }} - </ClipboardBase> - ); -} diff --git a/server/sonar-ui-common/components/icons/AlertErrorIcon.tsx b/server/sonar-ui-common/components/icons/AlertErrorIcon.tsx deleted file mode 100644 index c6c71782d7a..00000000000 --- a/server/sonar-ui-common/components/icons/AlertErrorIcon.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 * as React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function AlertErrorIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <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: fill || theme.colors.red }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/AlertSuccessIcon.tsx b/server/sonar-ui-common/components/icons/AlertSuccessIcon.tsx deleted file mode 100644 index 707d0f9e9f6..00000000000 --- a/server/sonar-ui-common/components/icons/AlertSuccessIcon.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 * as React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function AlertSuccessIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M12.607 6.554q0-0.25-0.161-0.411l-0.813-0.804q-0.17-0.17-0.402-0.17t-0.402 0.17l-3.643 3.634-2.018-2.018q-0.17-0.17-0.402-0.17t-0.402 0.17l-0.813 0.804q-0.161 0.161-0.161 0.411 0 0.241 0.161 0.402l3.232 3.232q0.17 0.17 0.402 0.17 0.241 0 0.411-0.17l4.848-4.848q0.161-0.161 0.161-0.402zM14.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: fill || theme.colors.green }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/AlertWarnIcon.tsx b/server/sonar-ui-common/components/icons/AlertWarnIcon.tsx deleted file mode 100644 index 7dc322657d2..00000000000 --- a/server/sonar-ui-common/components/icons/AlertWarnIcon.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 * as React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function AlertWarnIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 1.143q1.866 0 3.442.92t2.496 2.496.92 3.442-.92 3.442-2.496 2.496-3.442.92-3.442-.92-2.496-2.496-.92-3.442.92-3.442 2.496-2.496T8 1.143zm1.143 11.134v-1.696q0-.125-.08-.21t-.196-.085H7.153q-.116 0-.205.089t-.089.205v1.696q0 .116.089.205t.205.089h1.714q.116 0 .196-.085t.08-.21zm-.018-3.072l.161-5.545q0-.107-.089-.161-.089-.071-.214-.071H7.019q-.125 0-.214.071-.089.054-.089.161l.152 5.545q0 .089.089.156t.214.067h1.652q.125 0 .21-.067t.094-.156z" - style={{ fill: fill || theme.colors.orange }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ArrowIcon.tsx b/server/sonar-ui-common/components/icons/ArrowIcon.tsx deleted file mode 100644 index c27e7307897..00000000000 --- a/server/sonar-ui-common/components/icons/ArrowIcon.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 React from 'react'; -import Icon, { IconProps } from './Icon'; - -interface Props extends IconProps { - animated?: boolean; - inverseDirection?: boolean; -} - -export default function ArrowIcon({ - animated = false, - fill = 'currentColor', - inverseDirection = false, - ...iconProps -}: Props) { - const style: React.CSSProperties = {}; - if (inverseDirection) { - style.transform = 'scaleX(-1)'; - } - - if (animated) { - style.transition = 'transform 0.2s'; - } - return ( - <Icon style={style} {...iconProps}> - <path - d="M13.99 6.867l.668.005H4.99l3.04-3.046a.79.79 0 00.23-.561.789.789 0 00-.23-.56l-.473-.474A.784.784 0 006.998 2a.784.784 0 00-.558.23L1.23 7.44A.783.783 0 001 8c0 .212.081.41.23.56l5.21 5.21c.149.148.347.23.558.23.212 0 .41-.082.559-.23l.472-.473a.782.782 0 000-1.106L4.956 9.128H14a.819.819 0 00.801-.81v-.67c0-.435-.376-.78-.812-.78z" - fill={fill} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/BackIcon.tsx b/server/sonar-ui-common/components/icons/BackIcon.tsx deleted file mode 100644 index 34974ee8374..00000000000 --- a/server/sonar-ui-common/components/icons/BackIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function BackIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M3.6 8.69l4.07 4.13.04.04a.7.7 0 01.12.7.69.69 0 01-.86.4.73.73 0 01-.26-.16L1 8l5.71-5.8.04-.03A.73.73 0 017.13 2l.1-.01c.1.01.2.04.3.09a.7.7 0 01.3.82c-.03.1-.09.19-.16.27L3.61 7.3c3.59-.03 7.18-.14 10.77.01.05 0 .06 0 .1.02a.68.68 0 01.52.61.7.7 0 01-.57.74h-.1z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/BranchIcon.tsx b/server/sonar-ui-common/components/icons/BranchIcon.tsx deleted file mode 100644 index b6e9207cc58..00000000000 --- a/server/sonar-ui-common/components/icons/BranchIcon.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 * as React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function BranchIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M12.5 6.5c0-1.1-.9-2-2-2s-2 .9-2 2c0 .8.5 1.5 1.2 1.8-.3.6-.7 1.1-1.2 1.4-.9.5-1.9.5-2.5.4V4c.9-.2 1.5-1 1.5-1.9 0-1.1-.9-2-2-2s-2 .9-2 2C3.5 3 4.1 3.8 5 4v8c-.9.2-1.5 1-1.5 1.9 0 1.1.9 2 2 2s2-.9 2-2c0-.9-.6-1.7-1.5-1.9v-1c.2 0 .5.1.7.1.7 0 1.5-.1 2.2-.6.8-.5 1.4-1.2 1.7-2.1 1.1 0 1.9-.9 1.9-1.9zm-8-4.4c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1-1-.5-1-1zm2 11.9c0 .6-.4 1-1 1s-1-.4-1-1 .4-1 1-1 1 .4 1 1zm4-6.5c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/BubblesIcon.tsx b/server/sonar-ui-common/components/icons/BubblesIcon.tsx deleted file mode 100644 index 50a40c5c2f5..00000000000 --- a/server/sonar-ui-common/components/icons/BubblesIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function BubblesIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon style={{ fillRule: 'nonzero' }} {...iconProps}> - <path - d="M4.1 10.2c1 0 1.9.8 1.9 1.9S5.1 14 4.1 14s-1.9-.8-1.9-1.9.8-1.9 1.9-1.9m0-2C2 8.2.2 9.9.2 12.1S1.9 16 4.1 16 8 14.3 8 12.1 6.2 8.2 4.1 8.2zM10.3 2c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7-3.8-1.6-3.8-3.7S8.2 2 10.3 2m0-2C7.1 0 4.5 2.6 4.5 5.7s2.6 5.7 5.7 5.7S16 8.9 16 5.7 13.4 0 10.3 0z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/BugIcon.tsx b/server/sonar-ui-common/components/icons/BugIcon.tsx deleted file mode 100644 index 77f19836614..00000000000 --- a/server/sonar-ui-common/components/icons/BugIcon.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 React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function BugIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M10.09,1.88A2.86,2.86,0,0,0,8,1a2.87,2.87,0,0,0-2.11.87A2.93,2.93,0,0,0,5,4h6A2.93,2.93,0,0,0,10.09,1.88Z" - style={{ fill }} - /> - <path - d="M14.54,9H13V5.6L14.3,4.42a.5.5,0,0,0,0-.71.49.49,0,0,0-.7,0L12.17,5H3.82L2.34,3.66a.5.5,0,0,0-.67.74L2.94,5.55V9H1.46a.5.5,0,0,0,0,1H3a5.2,5.2,0,0,0,1.05,2.32l-2,1.81a.5.5,0,1,0,.67.74l2-1.82A4.62,4.62,0,0,0,7,14.1V8A1,1,0,0,1,8,7a.94.94,0,0,1,1,.9v6.17A4.55,4.55,0,0,0,11.18,13l2,1.83a.51.51,0,0,0,.33.13.48.48,0,0,0,.37-.17.49.49,0,0,0,0-.7l-2-1.8a5.34,5.34,0,0,0,1-2.29h1.64a.5.5,0,0,0,0-1Z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/BugTrackerIcon.tsx b/server/sonar-ui-common/components/icons/BugTrackerIcon.tsx deleted file mode 100644 index db03eee3115..00000000000 --- a/server/sonar-ui-common/components/icons/BugTrackerIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function BugTrackerIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M13.5 9.5c1.003.033 1.466 1.952 0 2h-2.618L9.685 9.107 8 14.162 6.096 8.45l-.832 3.05-2.829-.002c-.984-.097-1.369-1.951.065-1.998h1.236l2.168-7.95L8 7.838l1.315-3.945L12.118 9.5H13.5z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/BulletListIcon.tsx b/server/sonar-ui-common/components/icons/BulletListIcon.tsx deleted file mode 100644 index bceb30427a4..00000000000 --- a/server/sonar-ui-common/components/icons/BulletListIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function BulletListIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M2.968 11.274v1.51q0 0.102-0.075 0.177t-0.177 0.075h-1.51q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h1.51q0.102 0 0.177 0.075t0.075 0.177zM2.968 8.255v1.51q0 0.102-0.075 0.177t-0.177 0.075h-1.51q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h1.51q0.102 0 0.177 0.075t0.075 0.177zM2.968 5.235v1.51q0 0.102-0.075 0.177t-0.177 0.075h-1.51q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h1.51q0.102 0 0.177 0.075t0.075 0.177zM15.045 11.274v1.51q0 0.102-0.075 0.177t-0.177 0.075h-10.568q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h10.568q0.102 0 0.177 0.075t0.075 0.177zM2.968 2.216v1.51q0 0.102-0.075 0.177t-0.177 0.075h-1.51q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h1.51q0.102 0 0.177 0.075t0.075 0.177zM15.045 8.255v1.51q0 0.102-0.075 0.177t-0.177 0.075h-10.568q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h10.568q0.102 0 0.177 0.075t0.075 0.177zM15.045 5.235v1.51q0 0.102-0.075 0.177t-0.177 0.075h-10.568q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h10.568q0.102 0 0.177 0.075t0.075 0.177zM15.045 2.216v1.51q0 0.102-0.075 0.177t-0.177 0.075h-10.568q-0.102 0-0.177-0.075t-0.075-0.177v-1.51q0-0.102 0.075-0.177t0.177-0.075h10.568q0.102 0 0.177 0.075t0.075 0.177z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/CalendarIcon.tsx b/server/sonar-ui-common/components/icons/CalendarIcon.tsx deleted file mode 100644 index bb70dfd4d6e..00000000000 --- a/server/sonar-ui-common/components/icons/CalendarIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function CalendarIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M2 14h2.25v-2.25H2V14zm2.75 0h2.5v-2.25h-2.5V14zM2 11.25h2.25v-2.5H2v2.5zm2.75 0h2.5v-2.5h-2.5v2.5zM2 8.25h2.25V6H2v2.25zM7.75 14h2.5v-2.25h-2.5V14zm-3-5.75h2.5V6h-2.5v2.25zm6 5.75H13v-2.25h-2.25V14zm-3-2.75h2.5v-2.5h-2.5v2.5zM5 4.5V2.25a.24.24 0 0 0-.074-.176A.24.24 0 0 0 4.75 2h-.5a.24.24 0 0 0-.176.074A.24.24 0 0 0 4 2.25V4.5a.24.24 0 0 0 .074.176.24.24 0 0 0 .176.074h.5a.24.24 0 0 0 .176-.074A.24.24 0 0 0 5 4.5zm5.75 6.75H13v-2.5h-2.25v2.5zm-3-3h2.5V6h-2.5v2.25zm3 0H13V6h-2.25v2.25zM11 4.5V2.25a.24.24 0 0 0-.074-.176A.24.24 0 0 0 10.75 2h-.5a.24.24 0 0 0-.176.074.24.24 0 0 0-.074.176V4.5a.24.24 0 0 0 .074.176.24.24 0 0 0 .176.074h.5a.24.24 0 0 0 .176-.074A.24.24 0 0 0 11 4.5zm3-.5v10c0 .27-.099.505-.297.703A.961.961 0 0 1 13 15H2a.961.961 0 0 1-.703-.297A.961.961 0 0 1 1 14V4c0-.27.099-.505.297-.703A.961.961 0 0 1 2 3h1v-.75c0-.344.122-.638.367-.883S3.907 1 4.25 1h.5c.344 0 .638.122.883.367S6 1.907 6 2.25V3h3v-.75c0-.344.122-.638.367-.883S9.907 1 10.25 1h.5c.344 0 .638.122.883.367s.367.54.367.883V3h1c.27 0 .505.099.703.297A.961.961 0 0 1 14 4z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ChartLegendIcon.tsx b/server/sonar-ui-common/components/icons/ChartLegendIcon.tsx deleted file mode 100644 index 4d4d305190a..00000000000 --- a/server/sonar-ui-common/components/icons/ChartLegendIcon.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 * as React from 'react'; -import { ThemedIcon } from './Icon'; - -interface Props { - className?: string; - index: number; - size?: number; -} - -export default function ChartLegendIcon({ index, ...iconProps }: Props) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => { - const COLORS = [theme.colors.blue, theme.colors.darkBlue, '#24c6e0']; - return ( - <path - d="M14.325 7.143v1.714q0 0.357-0.25 0.607t-0.607 0.25h-10.857q-0.357 0-0.607-0.25t-0.25-0.607v-1.714q0-0.357 0.25-0.607t0.607-0.25h10.857q0.357 0 0.607 0.25t0.25 0.607z" - style={{ fill: COLORS[index] || COLORS[0] }} - /> - ); - }} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/CheckIcon.tsx b/server/sonar-ui-common/components/icons/CheckIcon.tsx deleted file mode 100644 index 9248e6178e8..00000000000 --- a/server/sonar-ui-common/components/icons/CheckIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function CheckIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M14.92 4.804q0 0.357-0.25 0.607l-7.679 7.679q-0.25 0.25-0.607 0.25t-0.607-0.25l-4.446-4.446q-0.25-0.25-0.25-0.607t0.25-0.607l1.214-1.214q0.25-0.25 0.607-0.25t0.607 0.25l2.625 2.634 5.857-5.866q0.25-0.25 0.607-0.25t0.607 0.25l1.214 1.214q0.25 0.25 0.25 0.607z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ChevronDownIcon.tsx b/server/sonar-ui-common/components/icons/ChevronDownIcon.tsx deleted file mode 100644 index 0931930ee5c..00000000000 --- a/server/sonar-ui-common/components/icons/ChevronDownIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ChevronDownIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M7.72 11.596L3.119 6.992A.382.382 0 0 1 3 6.713c0-.108.04-.2.118-.279l1.03-1.03a.382.382 0 0 1 .278-.117c.108 0 .201.04.28.117L8 8.7l3.294-3.295a.382.382 0 0 1 .28-.117c.108 0 .2.04.279.117l1.03 1.03a.382.382 0 0 1 .117.28c0 .107-.04.2-.118.278L8.28 11.596a.382.382 0 0 1-.279.117.382.382 0 0 1-.28-.117z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ChevronLeftIcon.tsx b/server/sonar-ui-common/components/icons/ChevronLeftIcon.tsx deleted file mode 100644 index 8f4824699ab..00000000000 --- a/server/sonar-ui-common/components/icons/ChevronLeftIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ChevronLeftIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M4.404 8.28l4.604 4.602a.382.382 0 0 0 .279.118c.108 0 .2-.04.279-.118l1.03-1.03a.382.382 0 0 0 .117-.278.382.382 0 0 0-.117-.28L7.3 8l3.295-3.294a.382.382 0 0 0 .117-.28.382.382 0 0 0-.117-.279l-1.03-1.03A.382.382 0 0 0 9.286 3a.382.382 0 0 0-.278.118L4.404 7.72A.382.382 0 0 0 4.287 8c0 .108.04.201.117.28z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ChevronRightIcon.tsx b/server/sonar-ui-common/components/icons/ChevronRightIcon.tsx deleted file mode 100644 index 21d6049ed6f..00000000000 --- a/server/sonar-ui-common/components/icons/ChevronRightIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ChevronRightIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M11.596 8.28l-4.604 4.602a.382.382 0 0 1-.279.118.382.382 0 0 1-.279-.118l-1.03-1.03a.382.382 0 0 1-.117-.278c0-.108.04-.201.117-.28L8.7 8 5.404 4.706a.382.382 0 0 1-.117-.28c0-.108.04-.2.117-.279l1.03-1.03A.382.382 0 0 1 6.714 3c.107 0 .2.04.278.118l4.604 4.603a.382.382 0 0 1 .117.279c0 .108-.04.201-.117.28z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ChevronUpIcon.tsx b/server/sonar-ui-common/components/icons/ChevronUpIcon.tsx deleted file mode 100644 index 842fc9f69a8..00000000000 --- a/server/sonar-ui-common/components/icons/ChevronUpIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ChevronUpIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M8.28 4.404l4.602 4.604a.382.382 0 0 1 .118.279c0 .108-.04.2-.118.279l-1.03 1.03a.382.382 0 0 1-.278.117.382.382 0 0 1-.28-.117L8 7.3l-3.294 3.295a.382.382 0 0 1-.28.117.382.382 0 0 1-.279-.117l-1.03-1.03A.382.382 0 0 1 3 9.286c0-.107.04-.2.118-.278L7.72 4.404A.382.382 0 0 1 8 4.287c.108 0 .201.04.28.117z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ChevronsIcon.tsx b/server/sonar-ui-common/components/icons/ChevronsIcon.tsx deleted file mode 100644 index 2ad6f90ed97..00000000000 --- a/server/sonar-ui-common/components/icons/ChevronsIcon.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 React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ChevronsIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M6.27 11.07L3.2 8l3.07-3.07L5.33 4l-4 4 4 4 .94-.93zm3.46 0L12.8 8 9.73 4.93l.94-.93 4 4-4 4-.94-.93z" - fill={fill} - fillRule="nonzero" - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ClearIcon.tsx b/server/sonar-ui-common/components/icons/ClearIcon.tsx deleted file mode 100644 index 91eb6f706d6..00000000000 --- a/server/sonar-ui-common/components/icons/ClearIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export interface ClearIconProps extends IconProps { - thin?: boolean; -} - -export default function ClearIcon({ fill = 'currentColor', thin, ...iconProps }: ClearIconProps) { - return ( - <Icon {...iconProps}> - {thin ? ( - <path - d="M14 3.209l-1.209-1.209-4.791 4.791-4.791-4.791-1.209 1.209 4.791 4.791-4.791 4.791 1.209 1.209 4.791-4.791 4.791 4.791 1.209-1.209-4.791-4.791z" - style={{ fill }} - /> - ) : ( - <path - d="M14 4.242L11.758 2l-3.76 3.76L4.242 2 2 4.242l3.756 3.756L2 11.758 4.242 14l3.756-3.76 3.76 3.76L14 11.758l-3.76-3.76L14 4.242z" - style={{ fill }} - /> - )} - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ClockIcon.tsx b/server/sonar-ui-common/components/icons/ClockIcon.tsx deleted file mode 100644 index c777a4a8e60..00000000000 --- a/server/sonar-ui-common/components/icons/ClockIcon.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 Icon, { IconProps } from './Icon'; - -export default function ClockIcon({ className, ...iconProps }: IconProps) { - return ( - <Icon className={classNames('icon-clock', className)} {...iconProps}> - <g fill="#fff" stroke="#ADADAD" transform="matrix(1.4 0 0 1.4 .3 .7)"> - <circle cx="5.5" cy="5.2" r="5" /> - <path d="M5.6 2.9v2.7l2-.5" fillRule="nonzero" /> - </g> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/CodeSmellIcon.tsx b/server/sonar-ui-common/components/icons/CodeSmellIcon.tsx deleted file mode 100644 index d705bcd0ec7..00000000000 --- a/server/sonar-ui-common/components/icons/CodeSmellIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function CodeSmellIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M8,15.1a7,7,0,1,0-7-7A7,7,0,0,0,8,15.1Zm.74-8.9,1.46-2.52a.29.29,0,0,1,.25-.14.3.3,0,0,1,.15,0,5.26,5.26,0,0,1,2.61,4.53.28.28,0,0,1-.29.29H10a.28.28,0,0,1-.29-.29,1.78,1.78,0,0,0-.88-1.51A.29.29,0,0,1,8.75,6.2Zm.11,3.44A.23.23,0,0,1,9,9.6a.29.29,0,0,1,.25.14l1.46,2.52a.18.18,0,0,1,0,.13.3.3,0,0,1-.15.27,5.3,5.3,0,0,1-5.23,0,.3.3,0,0,1-.1-.4L6.73,9.74A.29.29,0,0,1,7,9.6a.23.23,0,0,1,.14,0A1.79,1.79,0,0,0,8.86,9.64ZM5.33,3.59a.3.3,0,0,1,.41.1L7.2,6.21a.29.29,0,0,1-.1.4,1.79,1.79,0,0,0-.87,1.51.28.28,0,0,1-.29.29H3a.32.32,0,0,1-.32-.29A5.26,5.26,0,0,1,5.33,3.59Z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/CogIcon.tsx b/server/sonar-ui-common/components/icons/CogIcon.tsx deleted file mode 100644 index 4d7da4238f6..00000000000 --- a/server/sonar-ui-common/components/icons/CogIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function CogIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M14.922 9.704L13.6 8.696a4.55 4.551 0 000-1.057l1.323-1.006a.62.62 0 00.156-.805l-1.374-2.314a.658.658 0 00-.795-.28l-1.558.611a5.275 5.275 0 00-.935-.53l-.24-1.611a.631.631 0 00-.635-.537H6.787a.63.63 0 00-.633.532l-.239 1.616a5.62 5.62 0 00-.934.53l-1.563-.611a.645.645 0 00-.789.273L1.253 5.826a.616.616 0 00.157.808L2.73 7.64a4.517 4.519 0 000 1.058L1.41 9.705a.62.62 0 00-.158.805l1.374 2.314a.658.658 0 00.794.28l1.557-.61c.293.206.607.384.937.53l.24 1.61a.63.63 0 00.632.537H9.54a.63.63 0 00.634-.532l.24-1.616a5.62 5.62 0 00.934-.53l1.563.611a.645.645 0 00.789-.273l1.382-2.328a.618.619 0 00-.16-.8zm-6.758 1.382C6.51 11.087 5.17 9.78 5.17 8.17S6.51 5.252 8.164 5.252c1.654 0 2.995 1.307 2.995 2.917-.001 1.61-1.342 2.915-2.995 2.917z" - fill={fill} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/CollapseIcon.tsx b/server/sonar-ui-common/components/icons/CollapseIcon.tsx deleted file mode 100644 index 688f7e1a54f..00000000000 --- a/server/sonar-ui-common/components/icons/CollapseIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function CollapseIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M8 8.509v3.56c0 .138-.05.257-.151.357-.1.101-.22.151-.358.151a.489.489 0 0 1-.357-.15l-1.145-1.145-2.638 2.639a.251.251 0 0 1-.366 0l-.906-.906a.251.251 0 0 1 0-.366l2.639-2.638-1.144-1.145a.489.489 0 0 1-.151-.357c0-.138.05-.257.15-.358.101-.1.22-.151.358-.151h3.56c.138 0 .257.05.358.151.1.1.151.22.151.358zm6-5.34c0 .068-.026.129-.08.182l-2.638 2.638 1.144 1.145c.101.1.151.22.151.357 0 .138-.05.257-.15.358-.101.1-.22.151-.358.151h-3.56a.489.489 0 0 1-.358-.151A.489.489 0 0 1 8 7.491v-3.56c0-.138.05-.257.151-.357.1-.101.22-.151.358-.151.137 0 .257.05.357.15l1.145 1.145 2.638-2.639a.251.251 0 0 1 .366 0l.906.906c.053.053.079.114.079.183z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ContinuousIntegrationIcon.tsx b/server/sonar-ui-common/components/icons/ContinuousIntegrationIcon.tsx deleted file mode 100644 index 62ab2447fd1..00000000000 --- a/server/sonar-ui-common/components/icons/ContinuousIntegrationIcon.tsx +++ /dev/null @@ -1,35 +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 Icon, { IconProps } from './Icon'; - -export default function ContinuousIntegrationIcon({ - fill = 'currentColor', - ...iconProps -}: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M13.805 9.25c0 .016 0 .04-.008.055C13.133 12.07 10.852 14 7.969 14c-1.524 0-3-.602-4.11-1.656l-1.007 1.008a.497.497 0 0 1-.352.148.504.504 0 0 1-.5-.5V9.5c0-.273.227-.5.5-.5H6c.273 0 .5.227.5.5a.497.497 0 0 1-.148.352l-1.07 1.07a3.988 3.988 0 0 0 6.125-.828c.187-.305.28-.602.413-.914.04-.11.117-.18.235-.18h1.5c.14 0 .25.117.25.25zM14 3v3.5c0 .273-.227.5-.5.5H10a.504.504 0 0 1-.5-.5c0-.133.055-.258.148-.352l1.079-1.078A4.019 4.019 0 0 0 8 4c-1.39 0-2.68.719-3.406 1.906-.188.305-.282.602-.414.914-.04.11-.117.18-.235.18H2.391a.252.252 0 0 1-.25-.25v-.055C2.812 3.922 5.117 2 8 2c1.531 0 3.023.61 4.133 1.656l1.015-1.008A.497.497 0 0 1 13.5 2.5c.273 0 .5.227.5.5z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/CopyIcon.tsx b/server/sonar-ui-common/components/icons/CopyIcon.tsx deleted file mode 100644 index 2787990b1f3..00000000000 --- a/server/sonar-ui-common/components/icons/CopyIcon.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 React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function CopyIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <g fill={fill} fillRule="nonzero"> - <path d="M2.931 15.005V3H2v13h9v-.995z" /> - <path d="M10 4.015h3V14H4V1h6v3.015zM9 8V6H8v2H6v1h2v2h1V9h2V8H9z" /> - <path d="M11 1v2h2a2.151 2.151 0 0 0-2-2z" /> - </g> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/DeleteIcon.tsx b/server/sonar-ui-common/components/icons/DeleteIcon.tsx deleted file mode 100644 index 1fb013182da..00000000000 --- a/server/sonar-ui-common/components/icons/DeleteIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function DeleteIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M13.571429 1.8750019h-3.214285l-.251787-.5113283a.64285716.65624976 0 0 0-.5758927-.3636718H6.4678572a.63535718.64859353 0 0 0-.5732142.3636718l-.2517858.5113283H2.4285714A.42857144.43749984 0 0 0 2 2.3125018v.8749996a.42857144.43749984 0 0 0 .4285714.4374999H13.571429A.42857144.43749984 0 0 0 14 3.1875014v-.8749996a.42857144.43749984 0 0 0-.428571-.4374999zM3.4250001 13.769529a1.2857144 1.3124996 0 0 0 1.2830357 1.230468h6.5839282A1.2857144 1.3124996 0 0 0 12.575 13.769529l.567857-9.269528H2.8571428z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/DetachIcon.tsx b/server/sonar-ui-common/components/icons/DetachIcon.tsx deleted file mode 100644 index 4066ddf3327..00000000000 --- a/server/sonar-ui-common/components/icons/DetachIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function DetachIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M12 9.25v2.5A2.25 2.25 0 0 1 9.75 14h-6.5A2.25 2.25 0 0 1 1 11.75v-6.5A2.25 2.25 0 0 1 3.25 3h5.5c.14 0 .25.11.25.25v.5c0 .14-.11.25-.25.25h-5.5C2.562 4 2 4.563 2 5.25v6.5c0 .688.563 1.25 1.25 1.25h6.5c.688 0 1.25-.563 1.25-1.25v-2.5c0-.14.11-.25.25-.25h.5c.14 0 .25.11.25.25zm3-6.75v4c0 .273-.227.5-.5.5a.497.497 0 0 1-.352-.148l-1.375-1.375L7.68 10.57a.27.27 0 0 1-.18.078.27.27 0 0 1-.18-.078l-.89-.89a.27.27 0 0 1-.078-.18.27.27 0 0 1 .078-.18l5.093-5.093-1.375-1.375A.497.497 0 0 1 10 2.5c0-.273.227-.5.5-.5h4c.273 0 .5.227.5.5z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/DropdownIcon.tsx b/server/sonar-ui-common/components/icons/DropdownIcon.tsx deleted file mode 100644 index 7abed26df45..00000000000 --- a/server/sonar-ui-common/components/icons/DropdownIcon.tsx +++ /dev/null @@ -1,46 +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 Icon, { IconProps } from './Icon'; - -interface DropdownIconProps { - turned?: boolean; -} - -export default function DropdownIcon({ - fill = 'currentColor', - size = 16, - turned = false, - ...iconProps -}: IconProps & DropdownIconProps) { - return ( - <Icon - height={size} - style={turned ? { transform: 'rotate(180deg)' } : undefined} - viewBox="0 0 7 16" - width={(size / 16) * 7} - {...iconProps}> - <path - d="M7 6.469a.42.42 0 0 1-.13.307L3.808 9.84a.42.42 0 0 1-.308.13.42.42 0 0 1-.308-.13L.13 6.776A.42.42 0 0 1 0 6.47a.42.42 0 0 1 .13-.308.42.42 0 0 1 .307-.13h6.126a.42.42 0 0 1 .307.13.42.42 0 0 1 .13.308z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/EditIcon.tsx b/server/sonar-ui-common/components/icons/EditIcon.tsx deleted file mode 100644 index 45bf6814d46..00000000000 --- a/server/sonar-ui-common/components/icons/EditIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function EditIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M4.875 12.986l.721-.72-1.861-1.862-.721.72v.848h1.014v1.014h.847zm4.143-7.35c0-.117-.058-.175-.174-.175a.183.183 0 0 0-.135.056L4.416 9.81a.183.183 0 0 0-.056.135c0 .116.058.174.175.174a.183.183 0 0 0 .134-.056L8.962 5.77a.183.183 0 0 0 .056-.134zM8.59 4.115l3.295 3.295L5.295 14H2v-3.295l6.59-6.59zm5.41.76a.97.97 0 0 1-.293.713l-1.315 1.315-3.295-3.295L10.412 2.3c.19-.2.428-.301.713-.301.28 0 .52.1.72.301l1.862 1.853c.195.206.293.447.293.721z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/EllipsisIcon.tsx b/server/sonar-ui-common/components/icons/EllipsisIcon.tsx deleted file mode 100644 index c584514131a..00000000000 --- a/server/sonar-ui-common/components/icons/EllipsisIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function EllipsisIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M5.273 7.182v1.636a.818.818 0 0 1-.818.818H2.818A.818.818 0 0 1 2 8.818V7.182c0-.452.366-.818.818-.818h1.637c.451 0 .818.366.818.818zm4.363 0v1.636a.818.818 0 0 1-.818.818H7.182a.818.818 0 0 1-.818-.818V7.182c0-.452.366-.818.818-.818h1.636c.452 0 .818.366.818.818zm4.364 0v1.636a.818.818 0 0 1-.818.818h-1.637a.818.818 0 0 1-.818-.818V7.182c0-.452.367-.818.818-.818h1.637c.452 0 .818.366.818.818z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ExpandIcon.tsx b/server/sonar-ui-common/components/icons/ExpandIcon.tsx deleted file mode 100644 index 2de2405df9a..00000000000 --- a/server/sonar-ui-common/components/icons/ExpandIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ExpandIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M7.898 9.25a.247.247 0 0 1-.078.18l-2.593 2.593 1.125 1.125a.48.48 0 0 1 .148.352.48.48 0 0 1-.148.352A.48.48 0 0 1 6 14H2.5a.48.48 0 0 1-.352-.148A.48.48 0 0 1 2 13.5V10a.48.48 0 0 1 .148-.352A.48.48 0 0 1 2.5 9.5a.48.48 0 0 1 .352.148l1.125 1.125L6.57 8.18a.247.247 0 0 1 .36 0l.89.89a.247.247 0 0 1 .078.18zM14 2.5V6a.48.48 0 0 1-.148.352.48.48 0 0 1-.352.148.48.48 0 0 1-.352-.148l-1.125-1.125L9.43 7.82a.247.247 0 0 1-.36 0l-.89-.89a.247.247 0 0 1 0-.36l2.593-2.593-1.125-1.125A.48.48 0 0 1 9.5 2.5a.48.48 0 0 1 .148-.352A.48.48 0 0 1 10 2h3.5a.48.48 0 0 1 .352.148A.48.48 0 0 1 14 2.5z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ExpandSnippetIcon.tsx b/server/sonar-ui-common/components/icons/ExpandSnippetIcon.tsx deleted file mode 100644 index 1b6a2ce7f52..00000000000 --- a/server/sonar-ui-common/components/icons/ExpandSnippetIcon.tsx +++ /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. - */ -import * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ExpandSnippetIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <g fill="none" fillRule="evenodd"> - <path - d="M8 1v4H4" - stroke={fill} - strokeWidth="2" - transform="scale(-.83333 -.84583) rotate(45 7.66 -19.75)" - /> - <path d="M3 5.78h10v1.7H3z" fill={fill} /> - <path d="M7.17 2.4h1.66v5.07H7.17z" fill={fill} /> - <g> - <path - d="M8.16 1.81V6.1H3.9" - stroke={fill} - strokeWidth="2" - transform="scale(.83333 .84583) rotate(45 -4.2 13.2)" - /> - <path d="M13 10.01H3v-1.7h10z" fill={fill} /> - <path d="M8.83 13.4H7.17V9.15h1.66z" fill={fill} /> - </g> - </g> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/FavoriteIcon.tsx b/server/sonar-ui-common/components/icons/FavoriteIcon.tsx deleted file mode 100644 index af3ae770ebd..00000000000 --- a/server/sonar-ui-common/components/icons/FavoriteIcon.tsx +++ /dev/null @@ -1,44 +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 { ThemeConsumer } from '../theme'; -import Icon, { IconProps } from './Icon'; - -interface Props extends IconProps { - favorite: boolean; -} - -export default function FavoriteIcon({ className, favorite, fill, ...iconProps }: Props) { - return ( - <ThemeConsumer> - {(theme) => ( - <Icon - className={classNames('icon-outline', { 'is-filled': favorite }, className)} - style={{ color: fill || theme.colors.orange }} - {...iconProps}> - <g transform="matrix(0.988024,0,0,0.988024,0.0957953,0.717719)"> - <path d="M15.428,5.777C15.428,5.908 15.35,6.051 15.195,6.205L11.954,9.366L12.722,13.83C12.728,13.872 12.731,13.932 12.731,14.009C12.731,14.134 12.7,14.24 12.637,14.326C12.575,14.412 12.484,14.455 12.365,14.455C12.252,14.455 12.133,14.42 12.008,14.348L7.999,12.241L3.99,14.348C3.859,14.42 3.74,14.455 3.633,14.455C3.508,14.455 3.414,14.412 3.352,14.326C3.289,14.24 3.258,14.134 3.258,14.009C3.258,13.973 3.264,13.914 3.276,13.83L4.044,9.366L0.794,6.205C0.645,6.045 0.57,5.902 0.57,5.777C0.57,5.557 0.737,5.42 1.07,5.366L5.552,4.714L7.561,0.652C7.674,0.408 7.82,0.286 7.999,0.286C8.177,0.286 8.323,0.408 8.436,0.652L10.445,4.714L14.927,5.366C15.261,5.42 15.427,5.557 15.427,5.777L15.428,5.777Z" /> - </g> - </Icon> - )} - </ThemeConsumer> - ); -} diff --git a/server/sonar-ui-common/components/icons/FilterIcon.tsx b/server/sonar-ui-common/components/icons/FilterIcon.tsx deleted file mode 100644 index 8d5851eb570..00000000000 --- a/server/sonar-ui-common/components/icons/FilterIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function FilterIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M13.957 2.333a.536.536 0 0 1-.12.596l-4.2 4.202v6.323a.552.552 0 0 1-.333.503.632.632 0 0 1-.213.043.51.51 0 0 1-.384-.162l-2.181-2.182a.542.542 0 0 1-.162-.383V7.13L2.162 2.929a.536.536 0 0 1-.12-.596A.552.552 0 0 1 2.547 2h10.908c.222 0 .418.137.503.333z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/GroupIcon.tsx b/server/sonar-ui-common/components/icons/GroupIcon.tsx deleted file mode 100644 index 9efe35a17ab..00000000000 --- a/server/sonar-ui-common/components/icons/GroupIcon.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 React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function GroupIcon({ fill, size = 36, ...iconProps }: IconProps) { - return ( - <ThemedIcon viewBox="0 0 36 36" {...iconProps}> - {({ theme }) => ( - <g transform="matrix(0.0625,0,0,0.0625,3,4)"> - <path - d="M148.25,224C121.25,224.833 99.167,235.5 82,256L48.5,256C34.833,256 23.333,252.625 14,245.875C4.667,239.125 0,229.25 0,216.25C0,157.417 10.333,128 31,128C32,128 35.625,129.75 41.875,133.25C48.125,136.75 56.25,140.292 66.25,143.875C76.25,147.458 86.167,149.25 96,149.25C107.167,149.25 118.25,147.333 129.25,143.5C128.417,149.667 128,155.167 128,160C128,183.167 134.75,204.5 148.25,224ZM416,383.25C416,403.25 409.917,419.042 397.75,430.625C385.583,442.208 369.417,448 349.25,448L130.75,448C110.583,448 94.417,442.208 82.25,430.625C70.083,419.042 64,403.25 64,383.25C64,374.417 64.292,365.792 64.875,357.375C65.458,348.958 66.625,339.875 68.375,330.125C70.125,320.375 72.333,311.333 75,303C77.667,294.667 81.25,286.542 85.75,278.625C90.25,270.708 95.417,263.958 101.25,258.375C107.083,252.792 114.208,248.333 122.625,245C131.042,241.667 140.333,240 150.5,240C152.167,240 155.75,241.792 161.25,245.375C166.75,248.958 172.833,252.958 179.5,257.375C186.167,261.792 195.083,265.792 206.25,269.375C217.417,272.958 228.667,274.75 240,274.75C251.333,274.75 262.583,272.958 273.75,269.375C284.917,265.792 293.833,261.792 300.5,257.375C307.167,252.958 313.25,248.958 318.75,245.375C324.25,241.792 327.833,240 329.5,240C339.667,240 348.958,241.667 357.375,245C365.792,248.333 372.917,252.792 378.75,258.375C384.583,263.958 389.75,270.708 394.25,278.625C398.75,286.542 402.333,294.667 405,303C407.667,311.333 409.875,320.375 411.625,330.125C413.375,339.875 414.542,348.958 415.125,357.375C415.708,365.792 416,374.417 416,383.25ZM160,64C160,81.667 153.75,96.75 141.25,109.25C128.75,121.75 113.667,128 96,128C78.333,128 63.25,121.75 50.75,109.25C38.25,96.75 32,81.667 32,64C32,46.333 38.25,31.25 50.75,18.75C63.25,6.25 78.333,0 96,0C113.667,0 128.75,6.25 141.25,18.75C153.75,31.25 160,46.333 160,64ZM336,160C336,186.5 326.625,209.125 307.875,227.875C289.125,246.625 266.5,256 240,256C213.5,256 190.875,246.625 172.125,227.875C153.375,209.125 144,186.5 144,160C144,133.5 153.375,110.875 172.125,92.125C190.875,73.375 213.5,64 240,64C266.5,64 289.125,73.375 307.875,92.125C326.625,110.875 336,133.5 336,160ZM480,216.25C480,229.25 475.333,239.125 466,245.875C456.667,252.625 445.167,256 431.5,256L398,256C380.833,235.5 358.75,224.833 331.75,224C345.25,204.5 352,183.167 352,160C352,155.167 351.583,149.667 350.75,143.5C361.75,147.333 372.833,149.25 384,149.25C393.833,149.25 403.75,147.458 413.75,143.875C423.75,140.292 431.875,136.75 438.125,133.25C444.375,129.75 448,128 449,128C469.667,128 480,157.417 480,216.25ZM448,64C448,81.667 441.75,96.75 429.25,109.25C416.75,121.75 401.667,128 384,128C366.333,128 351.25,121.75 338.75,109.25C326.25,96.75 320,81.667 320,64C320,46.333 326.25,31.25 338.75,18.75C351.25,6.25 366.333,0 384,0C401.667,0 416.75,6.25 429.25,18.75C441.75,31.25 448,46.333 448,64Z" - style={{ fill: fill || theme.colors.gray67 }} - /> - </g> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/HelpIcon.tsx b/server/sonar-ui-common/components/icons/HelpIcon.tsx deleted file mode 100644 index 641e76849d2..00000000000 --- a/server/sonar-ui-common/components/icons/HelpIcon.tsx +++ /dev/null @@ -1,42 +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 Icon, { IconProps } from './Icon'; - -interface Props extends IconProps { - fillInner?: string; -} - -export default function HelpIcon({ fill = 'currentColor', fillInner, ...iconProps }: Props) { - return ( - <Icon {...iconProps}> - <path - d="M9.167 12.375v-1.75a.284.284 0 00-.082-.21.284.284 0 00-.21-.082h-1.75a.284.284 0 00-.21.082.284.284 0 00-.082.21v1.75c0 .085.028.155.082.21a.284.284 0 00.21.082h1.75a.284.284 0 00.21-.082.284.284 0 00.082-.21zM11.5 6.25c0-.535-.169-1.03-.506-1.486a3.452 3.452 0 00-1.262-1.057 3.462 3.462 0 00-1.55-.374c-1.476 0-2.603.647-3.381 1.942-.091.146-.067.273.073.383l1.203.911c.042.036.1.055.173.055a.269.269 0 00.228-.11c.322-.413.583-.692.784-.838.206-.146.468-.219.784-.219.291 0 .551.079.779.237.228.158.342.337.342.538 0 .23-.061.416-.183.556-.121.14-.328.276-.62.41a3.13 3.13 0 00-1.052.788c-.32.356-.479.737-.479 1.144v.328c0 .085.028.155.082.21a.284.284 0 00.21.082h1.75a.284.284 0 00.21-.082.284.284 0 00.082-.21c0-.115.065-.266.196-.45a1.54 1.54 0 01.496-.452c.195-.11.344-.196.447-.26a3.84 3.84 0 00.42-.319c.175-.149.31-.294.405-.437a2.407 2.407 0 00.369-1.29zM15 8c0 1.27-.313 2.441-.939 3.514a6.969 6.969 0 01-2.547 2.547A6.848 6.848 0 018 15a6.848 6.848 0 01-3.514-.939 6.969 6.969 0 01-2.547-2.547A6.848 6.848 0 011 8c0-1.27.313-2.441.939-3.514A6.969 6.969 0 014.486 1.94 6.848 6.848 0 018 1c1.27 0 2.441.313 3.514.939a6.969 6.969 0 012.547 2.547A6.848 6.848 0 0115 8z" - fill={fill} - /> - {fillInner && ( - <path - d="M9.167 12.375v-1.75a.284.284 0 00-.082-.21.284.284 0 00-.21-.082h-1.75a.284.284 0 00-.21.082.284.284 0 00-.082.21v1.75c0 .085.028.155.082.21a.284.284 0 00.21.082h1.75a.284.284 0 00.21-.082.284.284 0 00.082-.21zM11.5 6.25c0-.535-.169-1.03-.506-1.486a3.452 3.452 0 00-1.262-1.057 3.462 3.462 0 00-1.55-.374c-1.476 0-2.603.647-3.381 1.942-.091.146-.067.273.073.383l1.203.911c.042.036.1.055.173.055a.269.269 0 00.228-.11c.322-.413.583-.692.784-.838.206-.146.468-.219.784-.219.291 0 .551.079.779.237.228.158.342.337.342.538 0 .23-.061.416-.183.556-.121.14-.328.276-.62.41a3.13 3.13 0 00-1.052.788c-.32.356-.479.737-.479 1.144v.328c0 .085.028.155.082.21a.284.284 0 00.21.082h1.75a.284.284 0 00.21-.082.284.284 0 00.082-.21c0-.115.065-.266.196-.45a1.54 1.54 0 01.496-.452c.195-.11.344-.196.447-.26a3.84 3.84 0 00.42-.319c.175-.149.31-.294.405-.437a2.407 2.407 0 00.369-1.29z" - fill={fillInner} - /> - )} - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/HistoryIcon.tsx b/server/sonar-ui-common/components/icons/HistoryIcon.tsx deleted file mode 100644 index 55d61aff599..00000000000 --- a/server/sonar-ui-common/components/icons/HistoryIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function HistoryIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M14.7 3.4v3.3c0 .1 0 .2-.1.2s-.2 0-.3-.1l-.9-.9-4.8 4.8c-.1.1-.1.1-.2.1s-.1 0-.2-.1L6.4 9l-3.2 3.2-1.5-1.5 4.5-4.5c.1-.1.1-.1.2-.1s.1 0 .2.1L8.4 8l3.5-3.5-.9-1c-.1-.1-.1-.2-.1-.3s.1-.1.2-.1h3.3c.1 0 .1 0 .2.1.1 0 .1.1.1.2z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/HomeIcon.tsx b/server/sonar-ui-common/components/icons/HomeIcon.tsx deleted file mode 100644 index e6d28870174..00000000000 --- a/server/sonar-ui-common/components/icons/HomeIcon.tsx +++ /dev/null @@ -1,44 +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 { ThemeConsumer } from '../theme'; -import Icon, { IconProps } from './Icon'; - -interface Props extends IconProps { - filled?: boolean; -} - -export default function HomeIcon({ className, fill, filled = false, ...iconProps }: Props) { - return ( - <ThemeConsumer> - {(theme) => ( - <Icon - className={classNames(className, 'icon-outline', { 'is-filled': filled })} - style={{ color: fill || theme.colors.orange }} - {...iconProps}> - <g transform="matrix(0.870918,0,0,0.870918,0.978227,0.978227)"> - <path d="M15.9,7.8L8.2,0.1C8.1,0 7.9,0 7.8,0.1L0.1,7.8C0,7.9 0,8.1 0.1,8.2C0.2,8.3 0.2,8.3 0.3,8.3L2.2,8.3L2.2,15.8C2.2,15.9 2.2,15.9 2.3,16C2.3,16 2.4,16.1 2.5,16.1L6.2,16.1C6.3,16.1 6.5,16 6.5,15.8L6.5,10.5L9.7,10.5L9.7,15.8C9.7,15.9 9.8,16.1 10,16.1L13.7,16.1C13.8,16.1 14,16 14,15.8L14,8.2L15.9,8.2C16,8.2 16,8.2 16.1,8.1C16,8 16.1,7.9 15.9,7.8Z" /> - </g> - </Icon> - )} - </ThemeConsumer> - ); -} diff --git a/server/sonar-ui-common/components/icons/HouseIcon.tsx b/server/sonar-ui-common/components/icons/HouseIcon.tsx deleted file mode 100644 index c4ff402ebb1..00000000000 --- a/server/sonar-ui-common/components/icons/HouseIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function HouseIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M13.002 8.848v4.168a.56.56 0 0 1-.556.555H9.11v-3.334H6.89v3.334H3.554a.56.56 0 0 1-.556-.555V8.848c0-.018.01-.035.01-.052L8 4.68l4.993 4.116c.009.017.009.034.009.052zm1.936-.6l-.538.643a.289.289 0 0 1-.183.096h-.026a.273.273 0 0 1-.182-.061L8 3.916l-6.009 5.01a.297.297 0 0 1-.208.06.289.289 0 0 1-.183-.095l-.538-.642a.285.285 0 0 1 .035-.391L7.34 2.656a1.07 1.07 0 0 1 1.32 0l2.119 1.772V2.735c0-.157.121-.278.278-.278h1.667c.156 0 .278.121.278.278v3.542l1.901 1.58c.113.096.13.279.035.392z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/Icon.tsx b/server/sonar-ui-common/components/icons/Icon.tsx deleted file mode 100644 index d0d6356b4b9..00000000000 --- a/server/sonar-ui-common/components/icons/Icon.tsx +++ /dev/null @@ -1,81 +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 { Theme, ThemeConsumer } from '../theme'; - -export interface IconProps extends React.AriaAttributes { - className?: string; - fill?: string; - size?: number; -} - -interface Props extends React.AriaAttributes { - children: React.ReactNode; - className?: string; - size?: number; - style?: React.CSSProperties; - - // try to avoid using these: - width?: number; - height?: number; - viewBox?: string; -} - -export default function Icon({ - children, - className, - size = 16, - style, - height = size, - width = size, - viewBox = '0 0 16 16', - ...iconProps -}: Props) { - return ( - <svg - className={className} - height={height} - style={{ - fillRule: 'evenodd', - clipRule: 'evenodd', - strokeLinejoin: 'round', - strokeMiterlimit: 1.41421, - ...style, - }} - version="1.1" - viewBox={viewBox} - width={width} - xmlnsXlink="http://www.w3.org/1999/xlink" - xmlSpace="preserve" - {...iconProps}> - {children} - </svg> - ); -} - -interface ThemedProps extends Props { - children: (themeContext: { theme: Theme }) => React.ReactNode; -} - -export function ThemedIcon({ children, ...iconProps }: ThemedProps) { - return ( - <ThemeConsumer>{(theme) => <Icon {...iconProps}>{children({ theme })}</Icon>}</ThemeConsumer> - ); -} diff --git a/server/sonar-ui-common/components/icons/InfoIcon.tsx b/server/sonar-ui-common/components/icons/InfoIcon.tsx deleted file mode 100644 index 80029d0e93b..00000000000 --- a/server/sonar-ui-common/components/icons/InfoIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function InfoIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M10.333 12.375v-1.458a.288.288 0 0 0-.291-.292h-.875V5.958a.288.288 0 0 0-.292-.291H5.958a.288.288 0 0 0-.291.291v1.459c0 .164.127.291.291.291h.875v2.917h-.875a.288.288 0 0 0-.291.292v1.458c0 .164.127.292.291.292h4.084a.288.288 0 0 0 .291-.292zM9.167 4.208V2.75a.288.288 0 0 0-.292-.292h-1.75a.288.288 0 0 0-.292.292v1.458c0 .164.128.292.292.292h1.75a.288.288 0 0 0 .292-.292zM15 8c0 3.865-3.135 7-7 7s-7-3.135-7-7 3.135-7 7-7 7 3.135 7 7z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/IssueIcon.tsx b/server/sonar-ui-common/components/icons/IssueIcon.tsx deleted file mode 100644 index e78a91bbc44..00000000000 --- a/server/sonar-ui-common/components/icons/IssueIcon.tsx +++ /dev/null @@ -1,44 +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 BugIcon from './BugIcon'; -import CodeSmellIcon from './CodeSmellIcon'; -import { IconProps } from './Icon'; -import SecurityHotspotIcon from './SecurityHotspotIcon'; -import VulnerabilityIcon from './VulnerabilityIcon'; - -interface Props extends IconProps { - type: T.IssueType; -} - -export default function IssueIcon({ type, ...iconProps }: Props) { - switch (type) { - case 'BUG': - return <BugIcon {...iconProps} />; - case 'VULNERABILITY': - return <VulnerabilityIcon {...iconProps} />; - case 'CODE_SMELL': - return <CodeSmellIcon {...iconProps} />; - case 'SECURITY_HOTSPOT': - return <SecurityHotspotIcon {...iconProps} />; - default: - return null; - } -} diff --git a/server/sonar-ui-common/components/icons/IssueTypeIcon.tsx b/server/sonar-ui-common/components/icons/IssueTypeIcon.tsx deleted file mode 100644 index 9815ce40a84..00000000000 --- a/server/sonar-ui-common/components/icons/IssueTypeIcon.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 { IconProps } from './Icon'; -import IssueIcon from './IssueIcon'; - -export interface Props extends IconProps { - query: string; -} - -export default function IssueTypeIcon({ query, ...iconProps }: Props) { - let type: T.IssueType; - - switch (query.toLowerCase()) { - case 'bug': - case 'bugs': - case 'new_bugs': - type = 'BUG'; - break; - case 'vulnerability': - case 'vulnerabilities': - case 'new_vulnerabilities': - type = 'VULNERABILITY'; - break; - case 'code_smell': - case 'code_smells': - case 'new_code_smells': - type = 'CODE_SMELL'; - break; - case 'security_hotspot': - case 'security_hotspots': - case 'new_security_hotspots': - type = 'SECURITY_HOTSPOT'; - break; - default: - return null; - } - - return <IssueIcon type={type} {...iconProps} />; -} diff --git a/server/sonar-ui-common/components/icons/LightBulbIcon.tsx b/server/sonar-ui-common/components/icons/LightBulbIcon.tsx deleted file mode 100644 index 1ebcef9ed4e..00000000000 --- a/server/sonar-ui-common/components/icons/LightBulbIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function LightBulbIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M10.042 5.083a.3.3 0 0 1-.292.292.3.3 0 0 1-.292-.292c0-.629-.975-.875-1.458-.875a.3.3 0 0 1-.292-.291A.3.3 0 0 1 8 3.625c.848 0 2.042.447 2.042 1.458zm1.458 0c0-1.823-1.85-2.916-3.5-2.916S4.5 3.26 4.5 5.083c0 .584.237 1.194.62 1.641.173.2.373.392.556.602.647.774 1.194 1.686 1.285 2.716h2.078c.091-1.03.638-1.942 1.285-2.716.183-.21.383-.402.556-.602.383-.447.62-1.057.62-1.64zm1.167 0c0 .94-.31 1.75-.94 2.443-.628.693-1.457 1.668-1.53 2.643a.876.876 0 0 1 .428.748.852.852 0 0 1-.228.583.852.852 0 0 1 .228.583c0 .301-.155.575-.41.739a.89.89 0 0 1 .118.428c0 .592-.465.875-.993.875A1.479 1.479 0 0 1 8 15a1.479 1.479 0 0 1-1.34-.875c-.528 0-.993-.283-.993-.875 0-.146.045-.3.118-.428a.876.876 0 0 1-.41-.739c0-.218.082-.428.228-.583a.852.852 0 0 1-.228-.583c0-.301.164-.593.428-.748-.073-.975-.902-1.95-1.53-2.643a3.507 3.507 0 0 1-.94-2.443C3.333 2.604 5.694 1 8 1c2.306 0 4.667 1.604 4.667 4.083z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/LinkIcon.tsx b/server/sonar-ui-common/components/icons/LinkIcon.tsx deleted file mode 100644 index 04288a05331..00000000000 --- a/server/sonar-ui-common/components/icons/LinkIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function LinkIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <g transform="matrix(0.823497,0,0,0.823497,1.47008,1.4122)"> - <path - d="M13.501,11.429C13.501,11.191 13.418,10.989 13.251,10.822L11.394,8.965C11.227,8.798 11.025,8.715 10.787,8.715C10.537,8.715 10.323,8.81 10.144,9.001C10.162,9.019 10.219,9.074 10.314,9.166C10.409,9.258 10.473,9.322 10.506,9.358C10.539,9.394 10.583,9.451 10.64,9.528C10.697,9.605 10.735,9.681 10.756,9.756C10.777,9.831 10.787,9.913 10.787,10.002C10.787,10.24 10.704,10.442 10.537,10.609C10.37,10.776 10.168,10.859 9.93,10.859C9.841,10.859 9.759,10.849 9.684,10.828C9.609,10.807 9.533,10.769 9.456,10.712C9.379,10.655 9.322,10.611 9.286,10.578C9.25,10.545 9.186,10.481 9.094,10.386C9.002,10.291 8.947,10.234 8.929,10.216C8.732,10.401 8.634,10.618 8.634,10.868C8.634,11.106 8.717,11.308 8.884,11.475L10.723,13.323C10.884,13.484 11.086,13.564 11.33,13.564C11.568,13.564 11.77,13.487 11.937,13.332L13.25,12.028C13.417,11.861 13.5,11.662 13.5,11.43L13.501,11.429ZM7.224,5.134C7.224,4.896 7.141,4.694 6.974,4.527L5.135,2.679C4.968,2.512 4.766,2.429 4.528,2.429C4.296,2.429 4.094,2.509 3.921,2.67L2.608,3.974C2.441,4.141 2.358,4.34 2.358,4.572C2.358,4.81 2.441,5.012 2.608,5.179L4.465,7.036C4.626,7.197 4.828,7.277 5.072,7.277C5.322,7.277 5.536,7.185 5.715,7C5.697,6.982 5.64,6.927 5.545,6.835C5.45,6.743 5.386,6.679 5.353,6.643C5.32,6.607 5.276,6.55 5.219,6.473C5.162,6.396 5.124,6.32 5.103,6.245C5.082,6.17 5.072,6.088 5.072,5.999C5.072,5.761 5.155,5.559 5.322,5.392C5.489,5.225 5.691,5.142 5.929,5.142C6.018,5.142 6.1,5.152 6.175,5.173C6.25,5.194 6.326,5.232 6.403,5.289C6.48,5.346 6.537,5.39 6.573,5.423C6.609,5.456 6.673,5.52 6.765,5.615C6.857,5.71 6.912,5.767 6.93,5.785C7.127,5.6 7.225,5.383 7.225,5.133L7.224,5.134ZM15.215,11.429C15.215,12.143 14.962,12.747 14.456,13.242L13.143,14.546C12.649,15.04 12.045,15.287 11.33,15.287C10.61,15.287 10.003,15.034 9.509,14.528L7.67,12.68C7.176,12.186 6.929,11.582 6.929,10.867C6.929,10.135 7.191,9.513 7.715,9.001L6.929,8.215C6.417,8.739 5.798,9.001 5.072,9.001C4.358,9.001 3.751,8.751 3.251,8.251L1.394,6.394C0.894,5.894 0.644,5.287 0.644,4.573C0.644,3.859 0.897,3.255 1.403,2.76L2.716,1.456C3.21,0.962 3.814,0.715 4.529,0.715C5.249,0.715 5.856,0.968 6.35,1.474L8.189,3.322C8.683,3.816 8.93,4.42 8.93,5.135C8.93,5.867 8.668,6.489 8.144,7.001L8.93,7.787C9.442,7.263 10.061,7.001 10.787,7.001C11.501,7.001 12.108,7.251 12.608,7.751L14.465,9.608C14.965,10.108 15.215,10.715 15.215,11.429L15.215,11.429Z" - style={{ fill }} - /> - </g> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ListIcon.tsx b/server/sonar-ui-common/components/icons/ListIcon.tsx deleted file mode 100644 index fdc9e5c840d..00000000000 --- a/server/sonar-ui-common/components/icons/ListIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function ListIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M15.045 11.526v1.007q0 0.204-0.149 0.354t-0.354 0.149h-13.084q-0.204 0-0.354-0.149t-0.149-0.354v-1.006q0-0.204 0.149-0.354t0.354-0.149h13.084q0.204 0 0.354 0.149t0.149 0.354zM15.045 8.506v1.006q0 0.204-0.149 0.354t-0.354 0.149h-13.084q-0.204 0-0.354-0.149t-0.149-0.354v-1.006q0-0.204 0.149-0.354t0.354-0.149h13.084q0.204 0 0.354 0.149t0.149 0.354zM15.045 5.487v1.006q0 0.204-0.149 0.354t-0.354 0.149h-13.084q-0.204 0-0.354-0.149t-0.149-0.354v-1.006q0-0.204 0.149-0.354t0.354-0.149h13.084q0.204 0 0.354 0.149t0.149 0.354zM15.045 2.468v1.006q0 0.204-0.149 0.354t-0.354 0.149h-13.084q-0.204 0-0.354-0.149t-0.149-0.354v-1.006q0-0.204 0.149-0.354t0.354-0.149h13.084q0.204 0 0.354 0.149t0.149 0.354z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/LockIcon.tsx b/server/sonar-ui-common/components/icons/LockIcon.tsx deleted file mode 100644 index f9cd73e4981..00000000000 --- a/server/sonar-ui-common/components/icons/LockIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function LockIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M5.455 7.364h5.09v-1.91A2.55 2.55 0 0 0 8 2.91a2.55 2.55 0 0 0-2.545 2.546v1.909zm8.272.954v5.727a.955.955 0 0 1-.954.955H3.227a.955.955 0 0 1-.954-.955V8.318c0-.527.427-.954.954-.954h.318v-1.91C3.545 3.01 5.554 1 8 1s4.455 2.009 4.455 4.455v1.909h.318c.527 0 .954.427.954.954z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/LongLivingBranchIcon.tsx b/server/sonar-ui-common/components/icons/LongLivingBranchIcon.tsx deleted file mode 100644 index 893c07178e4..00000000000 --- a/server/sonar-ui-common/components/icons/LongLivingBranchIcon.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 React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function LongLivingBranchIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <g transform="translate(5, 0)"> - <path - d="M4.5 8c0-.9-.6-1.7-1.5-1.9V4c.9-.2 1.5-1 1.5-1.9 0-1.1-.9-2-2-2s-2 .9-2 2C.5 3 1.1 3.8 2 4v2.1C1.1 6.3.5 7.1.5 8s.6 1.7 1.5 2v2.1c-.9.2-1.5 1-1.5 1.9 0 1.1.9 2 2 2s2-.9 2-2c0-.9-.6-1.7-1.5-1.9V10c.9-.3 1.5-1 1.5-2zm-3-5.9c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1-1-.5-1-1zm0 5.9c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1-1-.4-1-1zm2 6c0 .6-.4 1-1 1s-1-.4-1-1 .4-1 1-1 1 .5 1 1z" - style={{ fill: fill || theme.colors.blue }} - /> - </g> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/MeasuresIcon.tsx b/server/sonar-ui-common/components/icons/MeasuresIcon.tsx deleted file mode 100644 index 07ad0c47ecd..00000000000 --- a/server/sonar-ui-common/components/icons/MeasuresIcon.tsx +++ /dev/null @@ -1,29 +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 Icon, { IconProps } from './Icon'; - -export default function MeasuresIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps} style={{ fillRule: 'nonzero' }}> - <path d="M3.33 6.13h2v6.54h-2zm3.74-2.8h1.86v9.34H7.07zm3.73 5.34h1.87v4H10.8z" fill={fill} /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/MinimizeIcon.tsx b/server/sonar-ui-common/components/icons/MinimizeIcon.tsx deleted file mode 100644 index 66f64ed6157..00000000000 --- a/server/sonar-ui-common/components/icons/MinimizeIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function MinimizeIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M14 12.1v1.267c0 .176-.08.325-.239.448a.918.918 0 0 1-.58.185H2.819a.918.918 0 0 1-.58-.185C2.08 13.692 2 13.543 2 13.367V12.1c0-.176.08-.326.239-.449a.918.918 0 0 1 .58-.185h10.363c.227 0 .42.062.58.185.158.123.238.273.238.449z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/NotificationIcon.tsx b/server/sonar-ui-common/components/icons/NotificationIcon.tsx deleted file mode 100644 index 10bf7da86d9..00000000000 --- a/server/sonar-ui-common/components/icons/NotificationIcon.tsx +++ /dev/null @@ -1,52 +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 { IconProps, ThemedIcon } from './Icon'; - -interface Props extends IconProps { - hasUnread?: boolean; -} - -export default function NotificationIcon({ - fill = 'currentColor', - hasUnread, - ...iconProps -}: Props) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => - hasUnread ? ( - <> - <path - d="M8 1a.875.875 0 0 0-.875.875v.57c-2.009.418-3.498 2.118-3.498 4.242 0 2.798-.987 3.652-1.516 4.22a.856.856 0 0 0-.236.593.875.875 0 0 0 .877.875h10.496a.875.875 0 0 0 .877-.875.854.854 0 0 0-.236-.594c-.497-.534-1.388-1.342-1.494-3.76a2.814 2.814 0 0 1-.768.108A2.814 2.814 0 0 1 8.814 4.44a2.814 2.814 0 0 1 .665-1.818 4.543 4.543 0 0 0-.604-.178v-.57A.875.875 0 0 0 8 1zM6.25 13.25a1.75 1.75 0 0 0 3.5 0h-3.5z" - style={{ fill }} - /> - <circle cx="11.627" cy="4.441" r="2" style={{ fill: theme.colors.blue }} /> - </> - ) : ( - <path - d="M8 15a1.75 1.75 0 0 0 1.75-1.75h-3.5c0 .967.784 1.75 1.75 1.75zm5.89-4.094c-.529-.567-1.517-1.421-1.517-4.218 0-2.125-1.49-3.826-3.499-4.243v-.57a.875.875 0 1 0-1.748 0v.57c-2.01.417-3.499 2.118-3.499 4.243 0 2.797-.988 3.65-1.517 4.218a.854.854 0 0 0-.235.594.876.876 0 0 0 .878.875h10.494a.876.876 0 0 0 .878-.875.853.853 0 0 0-.235-.594z" - style={{ fill }} - /> - ) - } - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/OnboardingAddMembersIcon.tsx b/server/sonar-ui-common/components/icons/OnboardingAddMembersIcon.tsx deleted file mode 100644 index 255c2d8f391..00000000000 --- a/server/sonar-ui-common/components/icons/OnboardingAddMembersIcon.tsx +++ /dev/null @@ -1,44 +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 { IconProps, ThemedIcon } from './Icon'; - -export default function OnboardingAddMembersIcon({ fill, size = 64, ...iconProps }: IconProps) { - return ( - <ThemedIcon height={(size / 64) * 80} viewBox="0 0 64 80" width={size} {...iconProps}> - {({ theme }) => ( - <g> - <path - d="M49 34c0 9.389-7.611 17-17 17s-17-7.611-17-17 7.611-17 17-17 17 7.611 17 17z" - style={{ fill: 'none', stroke: fill || theme.colors.darkBlue, strokeWidth: 2 }} - /> - <path - d="M36 32c0 2.2-1.8 4-4 4s-4-1.8-4-4v-1c0-2.2 1.8-4 4-4s4 1.8 4 4v1zm4 39a8 8 0 1 1-16 0 8 8 0 0 1 16 0z" - style={{ fill: 'none', stroke: fill || theme.colors.darkBlue, strokeWidth: 2 }} - /> - <path - d="M33 70h2v2h-2v2h-2v-2h-2v-2h2v-2h2v2zm-5-14l-.072-.001c-1.521-.054-2.834-1.337-2.925-2.855L25 50h2c0 1.745-.532 3.91.952 3.999L28 54h8v.002l.072-.005c.506-.042.922-.489.928-1.003V50h2c0 1.024.011 2.048-.001 3.072-.054 1.518-1.337 2.834-2.855 2.925l-.072.002L36 56v8h-2v-7.982c-1.333.007-2.667.007-4 0V64h-2v-8zm-7 0H1V10 0h62v56H43v-2h18V10H3v44h18v2zm38-4H43v-2h14V14H7v36h14v2H5V12h54v40zm-19-9l1 .017c-.03 1.79-2.454 2.506-3.918 2.717-4.074.584-8.503.911-12.176-.477-.949-.358-1.887-1.119-1.906-2.24l.191-.017H23v-3.566l5.38-3.228.913-.913 1.414 1.414-1.087 1.087L25 40.566v2.438c.067 1.304 10.98 2.117 13.844.157.076-.052.152-.172.156-.178v-2.417l-4.62-2.772-1.087-1.087 1.414-1.414.913.913L41 39.434V43h-1zm14-4h-2v-2h2v2zm-42 0h-2v-2h2v2zm42-4h-2v-2h2v2zm-42 0h-2v-2h2v2zm42-4h-2v-2h2v2zm-42 0h-2v-2h2v2zm20.198-10.999c3.529.062 6.837 1.669 9.386 4.169l-1.289 1.539c-4.178-4.152-11.167-5.254-16.359-.228l-.231.228-1.41-1.418c2.633-2.617 6.031-4.313 9.903-4.29zM3 2v6h58V2H3zm56 4H17V4h42v2zM11 6H9V4h2v2zM7 6H5V4h2v2zm8 0h-2V4h2v2z" - style={{ fill: fill || theme.colors.darkBlue, fillRule: 'nonzero' }} - /> - </g> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/OnboardingProjectIcon.tsx b/server/sonar-ui-common/components/icons/OnboardingProjectIcon.tsx deleted file mode 100644 index 79fedae1598..00000000000 --- a/server/sonar-ui-common/components/icons/OnboardingProjectIcon.tsx +++ /dev/null @@ -1,35 +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 { IconProps, ThemedIcon } from './Icon'; - -export default function OnboardingProjectIcon({ fill, size = 64, ...iconProps }: IconProps) { - return ( - <ThemedIcon size={size} viewBox="0 0 64 64" {...iconProps}> - {({ theme }) => ( - <g fill="none" fillRule="evenodd" stroke={fill || theme.colors.darkBlue} strokeWidth="2"> - <path d="M2 59h60V13H2zm0-46h60V5H2zm3-4h2m2 0h2m2 0h2m2 0h42" /> - <path d="M59 34h-6l-2-4h-6l-2 5h-6l-2 2h-6l-2-4h-6l-2 5h-6l-2 4H5m1 14v-9m4 9v-6m4 6V43m4 13V45m4 11V42m4 14V39m4 17V41m4 15V46m4 10V40m4 16V44m4 12V37m4 19V38m4 18V43m4 13V39m-3-18h-2m-2 0h-2m-2 0h-2M9 29h14M9 33h7m17-12h8m-14 4h8m-8-4h4m-21 4h12v-4H10z" /> - <path d="M58 31V17H6v22" /> - </g> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/OnboardingTeamIcon.tsx b/server/sonar-ui-common/components/icons/OnboardingTeamIcon.tsx deleted file mode 100644 index be4ab97b640..00000000000 --- a/server/sonar-ui-common/components/icons/OnboardingTeamIcon.tsx +++ /dev/null @@ -1,35 +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 { IconProps, ThemedIcon } from './Icon'; - -export default function OnboardingTeamIcon({ fill, size = 64, ...iconProps }: IconProps) { - return ( - <ThemedIcon size={size} viewBox="0 0 64 64" {...iconProps}> - {({ theme }) => ( - <g fill="none" fillRule="evenodd" stroke={fill || theme.colors.darkBlue} strokeWidth="2"> - <path d="M32 9v5M11.5195 43.0898l7.48-4.091m33.481-18.0994l-7.48 4.1m-33.481-4.1l7.48 4.1M45 38.999l7.48 4.101M32 50v5m15-23c0 8.284-6.715 15-15 15s-15-6.716-15-15c0-8.285 6.715-15 15-15s15 6.715 15 15z" /> - <path d="M40 38c0 1.656-3.58 2-8 2s-8-.344-8-2m16 0v-3l-5-3-1-1m-10 7v-3l5-3 1-1m6-4c0 2.2-1.8 4-4 4s-4-1.8-4-4v-1c0-2.2 1.8-4 4-4s4 1.8 4 4v1zm-.0098-21.71c7.18 1.069 13.439 4.96 17.609 10.51m-17.609 42.91c7.18-1.07 13.439-4.96 17.609-10.51M6.6299 41.25c-1.06-2.88-1.63-6-1.63-9.25s.57-6.37 1.63-9.25m3.7705-6.9502c4.17-5.55 10.43-9.44 17.609-10.51m-17.609 42.9104c4.17 5.55 10.43 9.439 17.609 10.51M57.3701 22.75c1.06 2.88 1.63 6 1.63 9.25s-.57 6.37-1.63 9.25" /> - <path d="M36 5c0 2.209-1.79 4-4 4-2.209 0-4-1.791-4-4 0-2.21 1.791-4 4-4 2.21 0 4 1.79 4 4zm-5 0h2M12 19c0 2.209-1.79 4-4 4-2.209 0-4-1.791-4-4 0-2.21 1.791-4 4-4 2.21 0 4 1.79 4 4zm-5 0h2m51 0c0 2.209-1.79 4-4 4-2.209 0-4-1.791-4-4 0-2.21 1.791-4 4-4 2.21 0 4 1.79 4 4zm-5 0h2M12 45c0 2.209-1.79 4-4 4-2.209 0-4-1.791-4-4 0-2.21 1.791-4 4-4 2.21 0 4 1.79 4 4zm-5 0h2m51 0c0 2.209-1.79 4-4 4-2.209 0-4-1.791-4-4 0-2.21 1.791-4 4-4 2.21 0 4 1.79 4 4zm-5 0h2M36 59c0 2.209-1.79 4-4 4-2.209 0-4-1.791-4-4 0-2.21 1.791-4 4-4 2.21 0 4 1.79 4 4zm-5 0h2" /> - </g> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/OpenCloseIcon.tsx b/server/sonar-ui-common/components/icons/OpenCloseIcon.tsx deleted file mode 100644 index 8b50014773d..00000000000 --- a/server/sonar-ui-common/components/icons/OpenCloseIcon.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 * as React from 'react'; -import ChevronDownIcon from './ChevronDownIcon'; -import ChevronRightIcon from './ChevronRightIcon'; -import { IconProps } from './Icon'; - -interface Props extends IconProps { - open: boolean; -} - -export default function OpenCloseIcon({ open, ...iconProps }: Props) { - return open ? <ChevronDownIcon {...iconProps} /> : <ChevronRightIcon {...iconProps} />; -} diff --git a/server/sonar-ui-common/components/icons/PendingIcon.tsx b/server/sonar-ui-common/components/icons/PendingIcon.tsx deleted file mode 100644 index 437abb33a70..00000000000 --- a/server/sonar-ui-common/components/icons/PendingIcon.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 React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function PendingIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <g transform="matrix(0.0364583,0,0,0.0364583,1,-0.166667)"> - <path - d="M224,136L224,248C224,250.333 223.25,252.25 221.75,253.75C220.25,255.25 218.333,256 216,256L136,256C133.667,256 131.75,255.25 130.25,253.75C128.75,252.25 128,250.333 128,248L128,232C128,229.667 128.75,227.75 130.25,226.25C131.75,224.75 133.667,224 136,224L192,224L192,136C192,133.667 192.75,131.75 194.25,130.25C195.75,128.75 197.667,128 200,128L216,128C218.333,128 220.25,128.75 221.75,130.25C223.25,131.75 224,133.667 224,136ZM328,224C328,199.333 321.917,176.583 309.75,155.75C297.583,134.917 281.083,118.417 260.25,106.25C239.417,94.083 216.667,88 192,88C167.333,88 144.583,94.083 123.75,106.25C102.917,118.417 86.417,134.917 74.25,155.75C62.083,176.583 56,199.333 56,224C56,248.667 62.083,271.417 74.25,292.25C86.417,313.083 102.917,329.583 123.75,341.75C144.583,353.917 167.333,360 192,360C216.667,360 239.417,353.917 260.25,341.75C281.083,329.583 297.583,313.083 309.75,292.25C321.917,271.417 328,248.667 328,224ZM384,224C384,258.833 375.417,290.958 358.25,320.375C341.083,349.792 317.792,373.083 288.375,390.25C258.958,407.417 226.833,416 192,416C157.167,416 125.042,407.417 95.625,390.25C66.208,373.083 42.917,349.792 25.75,320.375C8.583,290.958 0,258.833 0,224C0,189.167 8.583,157.042 25.75,127.625C42.917,98.208 66.208,74.917 95.625,57.75C125.042,40.583 157.167,32 192,32C226.833,32 258.958,40.583 288.375,57.75C317.792,74.917 341.083,98.208 358.25,127.625C375.417,157.042 384,189.167 384,224Z" - style={{ fill: fill || theme.colors.gray67 }} - /> - </g> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/PinIcon.tsx b/server/sonar-ui-common/components/icons/PinIcon.tsx deleted file mode 100644 index 4521f86a5e8..00000000000 --- a/server/sonar-ui-common/components/icons/PinIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function PinIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M7.25 7.25v-3.5a.243.243 0 0 0-.07-.18A.243.243 0 0 0 7 3.5a.243.243 0 0 0-.18.07.243.243 0 0 0-.07.18v3.5c0 .073.023.133.07.18.047.047.107.07.18.07a.243.243 0 0 0 .18-.07.243.243 0 0 0 .07-.18zM12.5 10a.482.482 0 0 1-.148.352.482.482 0 0 1-.352.148H8.648l-.398 3.773a.29.29 0 0 1-.082.161.219.219 0 0 1-.16.066H8c-.141 0-.224-.07-.25-.211L7.156 10.5H4a.482.482 0 0 1-.352-.148A.482.482 0 0 1 3.5 10c0-.641.204-1.217.613-1.73.409-.513.871-.77 1.387-.77v-4a.96.96 0 0 1-.703-.297A.96.96 0 0 1 4.5 2.5a.96.96 0 0 1 .297-.703A.96.96 0 0 1 5.5 1.5h5a.96.96 0 0 1 .703.297.96.96 0 0 1 .297.703.96.96 0 0 1-.297.703.96.96 0 0 1-.703.297v4c.516 0 .978.257 1.387.77.409.513.613 1.089.613 1.73z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/PlusCircleIcon.tsx b/server/sonar-ui-common/components/icons/PlusCircleIcon.tsx deleted file mode 100644 index 2591a7737db..00000000000 --- a/server/sonar-ui-common/components/icons/PlusCircleIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function PlusCircleIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M8 1c3.863 0 7 3.137 7 7s-3.137 7-7 7-7-3.137-7-7 3.137-7 7-7zm3.726 7.985A.274.274 0 0 0 12 8.711V7.289a.274.274 0 0 0-.274-.274H8.985V4.274A.274.274 0 0 0 8.711 4H7.289a.274.274 0 0 0-.274.274v2.741H4.274A.274.274 0 0 0 4 7.289v1.422c0 .152.123.274.274.274h2.741v2.741c0 .151.122.274.274.274h1.422a.274.274 0 0 0 .274-.274V8.985h2.741z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/PlusIcon.tsx b/server/sonar-ui-common/components/icons/PlusIcon.tsx deleted file mode 100644 index 39df3134c6f..00000000000 --- a/server/sonar-ui-common/components/icons/PlusIcon.tsx +++ /dev/null @@ -1,29 +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 Icon, { IconProps } from './Icon'; - -export default function PlusIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path d="M1,7L7,7L7,1L9,1L9,7L15,7L15,9L9,9L9,15L7,15L7,9L1,9L1,7Z" style={{ fill }} /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ProjectLinkIcon.tsx b/server/sonar-ui-common/components/icons/ProjectLinkIcon.tsx deleted file mode 100644 index b158f9839b2..00000000000 --- a/server/sonar-ui-common/components/icons/ProjectLinkIcon.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 BugTrackerIcon from './BugTrackerIcon'; -import ContinuousIntegrationIcon from './ContinuousIntegrationIcon'; -import DetachIcon from './DetachIcon'; -import HouseIcon from './HouseIcon'; -import { IconProps } from './Icon'; -import SCMIcon from './SCMIcon'; - -interface ProjectLinkIconProps { - type: string; -} - -export default function ProjectLinkIcon({ type, ...iconProps }: IconProps & ProjectLinkIconProps) { - switch (type) { - case 'issue': - return <BugTrackerIcon {...iconProps} />; - case 'homepage': - return <HouseIcon {...iconProps} />; - case 'ci': - return <ContinuousIntegrationIcon {...iconProps} />; - case 'scm': - return <SCMIcon {...iconProps} />; - default: - return <DetachIcon {...iconProps} />; - } -} diff --git a/server/sonar-ui-common/components/icons/PullRequestIcon.tsx b/server/sonar-ui-common/components/icons/PullRequestIcon.tsx deleted file mode 100644 index dc249a94b71..00000000000 --- a/server/sonar-ui-common/components/icons/PullRequestIcon.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 * as React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function PullRequestIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M13,11.9L13,5.5C13,5.4 13.232,1.996 7.9,2L9.1,0.8L8.5,0.1L5.9,2.6L8.5,5.1L9.2,4.4L7.905,3.008C12.256,2.99 12,5.4 12,5.5L12,11.9C11.1,12.1 10.5,12.9 10.5,13.8C10.5,14.9 11.4,15.8 12.5,15.8C13.6,15.8 14.5,14.9 14.5,13.8C14.5,12.9 13.9,12.2 13,11.9ZM4,11.9C4.9,12.2 5.5,12.9 5.5,13.8C5.5,14.9 4.6,15.8 3.5,15.8C2.4,15.8 1.5,14.9 1.5,13.8C1.5,12.9 2.1,12.1 3,11.9L3,4.1C2.1,3.9 1.5,3.1 1.5,2.2C1.5,1.1 2.4,0.2 3.5,0.2C4.6,0.2 5.5,1.1 5.5,2.2C5.5,3.1 4.9,3.9 4,4.1L4,11.9ZM12.5,14.9C11.9,14.9 11.5,14.5 11.5,13.9C11.5,13.3 11.9,12.9 12.5,12.9C13.1,12.9 13.5,13.3 13.5,13.9C13.5,14.5 13.1,14.9 12.5,14.9ZM3.5,14.9C2.9,14.9 2.5,14.5 2.5,13.9C2.5,13.3 2.9,12.9 3.5,12.9C4.1,12.9 4.5,13.3 4.5,13.9C4.5,14.5 4.1,14.9 3.5,14.9ZM2.5,2.2C2.5,1.6 2.9,1.2 3.5,1.2C4.1,1.2 4.5,1.6 4.5,2.2C4.5,2.8 4.1,3.2 3.5,3.2C2.9,3.2 2.5,2.8 2.5,2.2Z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/QualifierIcon.tsx b/server/sonar-ui-common/components/icons/QualifierIcon.tsx deleted file mode 100644 index 0fb2a5d0045..00000000000 --- a/server/sonar-ui-common/components/icons/QualifierIcon.tsx +++ /dev/null @@ -1,185 +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 { IconProps, ThemedIcon } from './Icon'; - -const qualifierIcons: T.Dict<(props: IconProps) => React.ReactElement> = { - app: ApplicationIcon, - brc: SubProjectIcon, - dev: DeveloperIcon, - dir: DirectoryIcon, - fil: FileIcon, - svw: SubPortfolioIcon, - trk: ProjectIcon, - uts: UnitTestIcon, - vw: PortfolioIcon, - - // deprecated: - cla: UnitTestIcon, - dev_prj: ProjectIcon, - lib: LibraryIcon, - pac: DirectoryIcon, -}; - -interface QualifierIconProps { - className?: string; - fill?: string; - qualifier: string | null | undefined; -} - -export default function QualifierIcon(props: QualifierIconProps) { - if (!props.qualifier) { - return null; - } - - const qualifier = props.qualifier.toLowerCase(); - const FoundIcon = qualifierIcons[qualifier]; - return FoundIcon ? <FoundIcon className={props.className} fill={props.fill} /> : null; -} - -function ApplicationIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M3.014 10.986a2 2 0 1 1-.001 4.001 2 2 0 0 1 .001-4.001zm9.984 0a2 2 0 1 1-.001 4.001 2 2 0 0 1 .001-4.001zm-5.004-.021c1.103 0 2 .896 2 2s-.897 2-2 2a2 2 0 0 1 0-4zm-4.98 1.021a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm9.984 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm-5.004-.021a1 1 0 1 1 0 2 1 1 0 0 1 0-2zM2.984 6a2 2 0 1 1-.001 4.001A2 2 0 0 1 2.984 6zm9.984 0a2 2 0 1 1-.001 4.001A2 2 0 0 1 12.968 6zm-5.004-.021c1.103 0 2 .897 2 2a2 2 0 1 1-2-2zM2.984 7a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm9.984 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm-5.004-.021a1.001 1.001 0 0 1 0 2 1 1 0 0 1 0-2zM3 1.025a2 2 0 1 1-.001 4.001A2 2 0 0 1 3 1.025zm9.984 0a2 2 0 1 1-.001 4.001 2 2 0 0 1 .001-4.001zM7.98 1.004c1.103 0 2 .896 2 2s-.897 2-2 2a2 2 0 0 1 0-4zM3 2.025a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm9.984 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2zM7.98 2.004a1.001 1.001 0 0 1 0 2 1 1 0 0 1 0-2z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function DeveloperIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M7.974 8.02a3.5 3.5 0 0 1-2.482-1.017 3.428 3.428 0 0 1-1.028-2.455c0-.927.365-1.8 1.028-2.455a3.505 3.505 0 0 1 2.482-1.017 3.5 3.5 0 0 1 2.482 1.017 3.434 3.434 0 0 1 1.027 2.455c0 .928-.365 1.8-1.027 2.455A3.504 3.504 0 0 1 7.974 8.02zm0-5.778c-1.286 0-2.332 1.034-2.332 2.306s1.046 2.307 2.332 2.307c1.285 0 2.332-1.035 2.332-2.307S9.258 2.242 7.974 2.242zm3.534 6.418c.127.016.243.045.348.086.17.066.302.146.406.246.132.124.253.282.36.47.126.218.226.442.3.668.08.253.15.535.206.838.056.313.095.604.113.867.02.28.03.57.03.862 0 .532-.174.758-.306.882-.142.132-.397.31-.973.31H3.948c-.233 0-.437-.03-.606-.09-.14-.05-.26-.123-.366-.222-.13-.123-.306-.35-.306-.88 0-.294.01-.584.03-.863.018-.263.056-.554.112-.867a6.5 6.5 0 0 1 .207-.838c.073-.226.173-.45.298-.667.108-.19.23-.347.36-.47.106-.1.238-.18.407-.247.105-.04.22-.07.348-.086.202.13.432.277.683.435.342.217.756.4 1.265.564.523.166 1.06.25 1.59.25a5.25 5.25 0 0 0 1.592-.25c.51-.164.923-.348 1.266-.565.25-.158.48-.304.682-.435l-.002.002zm-.244-1.18c-.055 0-.184.066-.387.196-.202.13-.43.276-.685.437-.255.16-.586.307-.994.437-.408.13-.818.196-1.23.196-.41 0-.82-.065-1.228-.196a4.303 4.303 0 0 1-.993-.437c-.255-.16-.484-.306-.686-.437-.202-.13-.33-.196-.386-.196-.374 0-.716.06-1.026.183-.31.12-.572.283-.787.487a3.28 3.28 0 0 0-.57.737 4.662 4.662 0 0 0-.395.888c-.098.303-.18.633-.244.988a9.652 9.652 0 0 0-.128.992c-.02.306-.032.62-.032.942 0 .73.224 1.304.672 1.726.448.42 1.043.632 1.785.632h8.044c.743 0 1.34-.21 1.787-.633.447-.42.67-.996.67-1.725 0-.32-.01-.635-.03-.942a9.159 9.159 0 0 0-.374-1.98c-.098-.304-.23-.6-.395-.888a3.23 3.23 0 0 0-.57-.737 2.404 2.404 0 0 0-.788-.487 2.779 2.779 0 0 0-1.026-.183h-.004z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function DirectoryIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M14 12.286V5.703a.673.673 0 0 0-.195-.5.644.644 0 0 0-.49-.203H6.704a.686.686 0 0 1-.5-.214.707.707 0 0 1-.203-.51v-.57c0-.2-.07-.363-.207-.502A.679.679 0 0 0 5.29 3H2.707a.672.672 0 0 0-.5.204.683.683 0 0 0-.206.5v8.582c0 .2.07.367.206.506.137.14.304.208.5.208h10.61a.66.66 0 0 0 .49-.208.685.685 0 0 0 .194-.506H14zm1-6.598v6.65c0 .458-.152.83-.475 1.16-.324.326-.7.502-1.15.502H2.647c-.452 0-.84-.175-1.162-.503a1.572 1.572 0 0 1-.486-1.158V3.654a1.6 1.6 0 0 1 .486-1.17A1.578 1.578 0 0 1 2.648 2h2.7c.45 0 .84.157 1.164.485.324.328.488.714.488 1.17V4h6.373c.452 0 .83.174 1.152.5.323.33.475.73.475 1.187v.001z" - style={{ fill: fill || theme.colors.orange }} - /> - )} - </ThemedIcon> - ); -} - -function FileIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M14 15H2V1l7.997.02c1 .034 1.759.758 2.428 1.42.667.663 1.561 1.605 1.574 2.555H14V15zM9 2H3v12h10V6H9V2zm3 10H4v-1h8v1zm0-2H4V9h8v1zm-1.988-5h3.008c-.012-.674-.714-1.443-1.204-1.937-.488-.495-1.039-1.058-1.816-1.055v2.96l.012.032z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function LibraryIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M1 13h4V3H1v10zm3-1H2v-2h2v2zM2 4h2v4H2V4zm4 9h4V3H6v10zm3-1H7v-2h2v2zM7 4h2v4H7V4zm4 9h4V3h-4v10zm3-1h-2v-2h2v2zm-2-8h2v4h-2V4z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function PortfolioIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M14.97 14.97H1.016V1.015H14.97V14.97zm-1-12.955H2.015V13.97H13.97V2.015zm-.973 10.982H9V9h3.997v3.997zM7 12.996H3.004V9H7v3.996zM11.997 10H10v1.997h1.997V10zM6 10H4.004v1.996H6V10zm1-3H3.006V3.006H7V7zm5.985 0H9V3.015h3.985V7zM6 4.006H4.006V6H6V4.006zm5.985.009H10V6h1.985V4.015z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function ProjectIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M14.985 13.988L1 14.005 1.02 5h13.966v8.988h-.001zM1.998 5.995l.006 7.02L14.022 13 14 6.004l-12.002-.01v.001zM3 4.5V4h9.996l.004.5h1l-.005-1.497-11.98.003L2 4.5h1zm1-2v-.504h8.002L12 2.5h1l-.004-1.495H3.003L3 2.5h1z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function SubPortfolioIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M14 7h2v9H7v-2H0V0h14v7zM8 8v7h7V8H8zm3 6H9v-2h2v2zm3 0h-2v-2h2v2zm-1-7V1H1v12h6V7h6zm-7 5H2V8h4v4zm5-1H9V9h2v2zm3 0h-2V9h2v2zM5 9H3v2h2V9zm1-3H2V2h4v4zm6 0H8V2h4v4zM5 3H3v2h2V3zm6 0H9v2h2V3z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function SubProjectIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 9V8h6v1h1v1h1v6H6v-6h1V9h1zm7 2H7v4h8v-4zm-1-7v3h-1V5H1v7h4v1H0V4h14zm-1-2v1.5h-1V3H2v.5H1V2h12zm-1-2v1.5h-1V1H3v.5H2V0h10z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function UnitTestIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M14 15H2V1l7.997.02c1.013-.03 1.57.893 2.239 1.555.667.663 1.75 1.47 1.763 2.42H14V15zM9 2H3v12h10V6H9V2zM7 8l-3 2.5L7 13V8zm1 5l3-2.5L8 8v5zm2.012-8h3.008c-.012-.674-.78-1.258-1.27-1.752-.488-.495-.973-1.243-1.75-1.24v2.96l.012.032z" - style={{ fill: fill || theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/RecommendedIcon.tsx b/server/sonar-ui-common/components/icons/RecommendedIcon.tsx deleted file mode 100644 index 06b7abb5483..00000000000 --- a/server/sonar-ui-common/components/icons/RecommendedIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function RecommendedIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M15.089 13.199l-1.742-3.736c-0.962 1.401-2.464 2.398-4.203 2.701l1.459 3.128c0.186 0.4 0.764 0.373 0.914-0.040l0.748-2.054 0.154-0.072 2.054 0.748c0.412 0.151 0.804-0.276 0.618-0.675zM8.040 0.384c-3.003 0-5.446 2.443-5.446 5.446s2.443 5.446 5.446 5.446c3.003 0 5.446-2.443 5.446-5.446s-2.443-5.446-5.446-5.446zM10.689 5.429l-0.966 0.941 0.228 1.33c0.070 0.406-0.358 0.711-0.718 0.522l-1.194-0.628-1.194 0.628c-0.363 0.19-0.788-0.118-0.718-0.522l0.228-1.33-0.966-0.941c-0.293-0.286-0.131-0.786 0.274-0.844l1.335-0.194 0.597-1.209c0.181-0.367 0.707-0.368 0.888 0l0.597 1.209 1.335 0.194c0.405 0.059 0.568 0.558 0.274 0.844zM2.732 9.463l-1.742 3.736c-0.187 0.4 0.208 0.825 0.618 0.674l2.054-0.748 0.154 0.072 0.748 2.054c0.15 0.412 0.727 0.441 0.914 0.040l1.459-3.128c-1.739-0.302-3.241-1.3-4.203-2.701z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/RocketIcon.tsx b/server/sonar-ui-common/components/icons/RocketIcon.tsx deleted file mode 100644 index ad24c87365f..00000000000 --- a/server/sonar-ui-common/components/icons/RocketIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function RocketIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M13.754 2.002C11.41 1.96 8.74 3.184 7.049 5.084A6.345 6.345 0 002.7 6.935a.25.25 0 00.14.426l1.927.276-.238.266a.25.25 0 00.01.344l3.213 3.213a.25.25 0 00.344.01l.266-.239.276 1.928c.014.093.088.162.177.192a.23.23 0 00.072.011.282.282 0 00.193-.08 6.331 6.331 0 001.836-4.332c1.901-1.694 3.136-4.365 3.081-6.704a.251.251 0 00-.244-.244zM11.45 6.318a1.246 1.246 0 01-.884.365c-.32 0-.64-.122-.884-.365a1.252 1.252 0 010-1.768 1.251 1.251 0 011.768 0 1.251 1.251 0 010 1.768zm-8.088 4.135c-.535.535-1.27 2.952-1.351 3.225a.25.25 0 00.311.311c.274-.082 2.69-.816 3.226-1.351a1.547 1.547 0 000-2.185 1.548 1.548 0 00-2.186 0z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/RuleScopeIcon.tsx b/server/sonar-ui-common/components/icons/RuleScopeIcon.tsx deleted file mode 100644 index 115da520908..00000000000 --- a/server/sonar-ui-common/components/icons/RuleScopeIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function RuleScopeIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M8 3.071c2.724 0 4.929 2.204 4.929 4.929s-2.204 4.929-4.929 4.929c-2.724 0-4.929-2.204-4.929-4.929s2.204-4.929 4.929-4.929zM8 1.357c-3.669 0-6.643 2.974-6.643 6.643s2.974 6.643 6.643 6.643 6.643-2.974 6.643-6.643-2.974-6.643-6.643-6.643zM8 6.286c0.945 0 1.714 0.769 1.714 1.714s-0.769 1.714-1.714 1.714-1.714-0.769-1.714-1.714 0.769-1.714 1.714-1.714zM8 4.571c-1.893 0-3.429 1.535-3.429 3.429s1.535 3.429 3.429 3.429 3.429-1.535 3.429-3.429-1.535-3.429-3.429-3.429z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/SCMIcon.tsx b/server/sonar-ui-common/components/icons/SCMIcon.tsx deleted file mode 100644 index fdbd75fab76..00000000000 --- a/server/sonar-ui-common/components/icons/SCMIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function SCMIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M12.557 4.545c.241.247.443.743.443 1.098v7.714c0 .355-.28.643-.625.643h-8.75A.634.634 0 0 1 3 13.357V2.643C3 2.288 3.28 2 3.625 2h5.833c.345 0 .827.208 1.068.455l2.031 2.09zM9.667 2.91v2.518h2.448a.86.86 0 0 0-.144-.275L9.934 3.058a.823.823 0 0 0-.267-.147zm2.5 10.232V6.286H9.458a.634.634 0 0 1-.625-.643V2.857h-5v10.286h8.334z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/SearchIcon.tsx b/server/sonar-ui-common/components/icons/SearchIcon.tsx deleted file mode 100644 index 0da433a21e2..00000000000 --- a/server/sonar-ui-common/components/icons/SearchIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function SearchIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M10.308 7.077c0-.89-.316-1.65-.949-2.283a3.111 3.111 0 0 0-2.282-.948c-.89 0-1.65.316-2.283.948a3.111 3.111 0 0 0-.948 2.283c0 .89.316 1.65.948 2.282a3.111 3.111 0 0 0 2.283.949c.89 0 1.65-.316 2.282-.949a3.111 3.111 0 0 0 .949-2.282zm3.692 6c0 .25-.091.466-.274.649a.887.887 0 0 1-.65.274.857.857 0 0 1-.648-.274L9.954 11.26c-.86.596-1.82.894-2.877.894a4.989 4.989 0 0 1-1.972-.4 5.076 5.076 0 0 1-1.623-1.082A5.076 5.076 0 0 1 2.4 9.049 4.989 4.989 0 0 1 2 7.077c0-.688.133-1.345.4-1.972a5.076 5.076 0 0 1 1.082-1.623A5.076 5.076 0 0 1 5.105 2.4 4.989 4.989 0 0 1 7.077 2c.687 0 1.345.133 1.972.4a5.076 5.076 0 0 1 1.623 1.082c.454.454.815.995 1.082 1.623.266.627.4 1.284.4 1.972a4.938 4.938 0 0 1-.894 2.877l2.473 2.474a.883.883 0 0 1 .267.649z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/SecurityHotspotIcon.tsx b/server/sonar-ui-common/components/icons/SecurityHotspotIcon.tsx deleted file mode 100644 index 6ac2e9297ae..00000000000 --- a/server/sonar-ui-common/components/icons/SecurityHotspotIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function SecurityHotspotIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M14.08 3.23a1 1 0 00-.67-.77L8.16 1a1.06 1.06 0 00-.5 0L2.41 2.46a.94.94 0 00-.67.77c-.08.57-.74 5.63 1.14 8.31A9 9 0 007.68 15a.85.85 0 00.23 0 .78.78 0 00.22 0 8.93 8.93 0 004.81-3.46c1.85-2.68 1.21-7.74 1.14-8.31zM12.21 8a6.15 6.15 0 01-.86 2.42A7.92 7.92 0 018 13V8zM8 3v5H3.59a24.29 24.29 0 010-3.82z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/SettingsIcon.tsx b/server/sonar-ui-common/components/icons/SettingsIcon.tsx deleted file mode 100644 index 9156f96aa28..00000000000 --- a/server/sonar-ui-common/components/icons/SettingsIcon.tsx +++ /dev/null @@ -1,38 +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 Icon, { IconProps } from './Icon'; - -export default function SettingsIcon({ - fill = 'currentColor', - size = 14, - ...iconProps -}: IconProps) { - return ( - <Icon size={size} viewBox="0 0 14 14" {...iconProps}> - <g transform="matrix(0.0364583,0,0,0.0364583,0,-1.16667)"> - <path - d="M256,224C256,206.333 249.75,191.25 237.25,178.75C224.75,166.25 209.667,160 192,160C174.333,160 159.25,166.25 146.75,178.75C134.25,191.25 128,206.333 128,224C128,241.667 134.25,256.75 146.75,269.25C159.25,281.75 174.333,288 192,288C209.667,288 224.75,281.75 237.25,269.25C249.75,256.75 256,241.667 256,224ZM384,196.75L384,252.25C384,254.25 383.333,256.167 382,258C380.667,259.833 379,260.917 377,261.25L330.75,268.25C327.583,277.25 324.333,284.833 321,291C326.833,299.333 335.75,310.833 347.75,325.5C349.417,327.5 350.25,329.583 350.25,331.75C350.25,333.917 349.5,335.833 348,337.5C343.5,343.667 335.25,352.667 323.25,364.5C311.25,376.333 303.417,382.25 299.75,382.25C297.75,382.25 295.583,381.5 293.25,380L258.75,353C251.417,356.833 243.833,360 236,362.5C233.333,385.167 230.917,400.667 228.75,409C227.583,413.667 224.583,416 219.75,416L164.25,416C161.917,416 159.875,415.292 158.125,413.875C156.375,412.458 155.417,410.667 155.25,408.5L148.25,362.5C140.083,359.833 132.583,356.75 125.75,353.25L90.5,380C88.833,381.5 86.75,382.25 84.25,382.25C81.917,382.25 79.833,381.333 78,379.5C57,360.5 43.25,346.5 36.75,337.5C35.583,335.833 35,333.917 35,331.75C35,329.75 35.667,327.833 37,326C39.5,322.5 43.75,316.958 49.75,309.375C55.75,301.792 60.25,295.917 63.25,291.75C58.75,283.417 55.333,275.167 53,267L7.25,260.25C5.083,259.917 3.333,258.875 2,257.125C0.667,255.375 0,253.417 0,251.25L0,195.75C0,193.75 0.667,191.833 2,190C3.333,188.167 4.917,187.083 6.75,186.75L53.25,179.75C55.583,172.083 58.833,164.417 63,156.75C56.333,147.25 47.417,135.75 36.25,122.25C34.583,120.25 33.75,118.25 33.75,116.25C33.75,114.583 34.5,112.667 36,110.5C40.333,104.5 48.542,95.542 60.625,83.625C72.708,71.708 80.583,65.75 84.25,65.75C86.417,65.75 88.583,66.583 90.75,68.25L125.25,95C132.583,91.167 140.167,88 148,85.5C150.667,62.833 153.083,47.333 155.25,39C156.417,34.333 159.417,32 164.25,32L219.75,32C222.083,32 224.125,32.708 225.875,34.125C227.625,35.542 228.583,37.333 228.75,39.5L235.75,85.5C243.917,88.167 251.417,91.25 258.25,94.75L293.75,68C295.25,66.5 297.25,65.75 299.75,65.75C301.917,65.75 304,66.583 306,68.25C327.5,88.083 341.25,102.25 347.25,110.75C348.417,112.083 349,113.917 349,116.25C349,118.25 348.333,120.167 347,122C344.5,125.5 340.25,131.042 334.25,138.625C328.25,146.208 323.75,152.083 320.75,156.25C325.083,164.583 328.5,172.75 331,180.75L376.75,187.75C378.917,188.083 380.667,189.125 382,190.875C383.333,192.625 384,194.583 384,196.75Z" - style={{ fill }} - /> - </g> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/SeverityIcon.tsx b/server/sonar-ui-common/components/icons/SeverityIcon.tsx deleted file mode 100644 index 298d39aaeff..00000000000 --- a/server/sonar-ui-common/components/icons/SeverityIcon.tsx +++ /dev/null @@ -1,107 +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 { IconProps, ThemedIcon } from './Icon'; - -interface Props extends IconProps { - severity: string | null | undefined; -} - -const severityIcons: T.Dict<(props: IconProps) => React.ReactElement> = { - blocker: BlockerSeverityIcon, - critical: CriticalSeverityIcon, - major: MajorSeverityIcon, - minor: MinorSeverityIcon, - info: InfoSeverityIcon, -}; - -export default function SeverityIcon({ severity, ...iconProps }: Props) { - if (!severity) { - return null; - } - - const Icon = severityIcons[severity.toLowerCase()]; - return Icon ? <Icon {...iconProps} /> : null; -} - -function BlockerSeverityIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 14c-3.311 0-6-2.689-6-6s2.689-6 6-6 6 2.689 6 6-2.689 6-6 6zM7 9h2V4H7v5zm0 3h2v-2H7v2z" - style={{ fill: theme.colors.red, fillRule: 'nonzero' }} - /> - )} - </ThemedIcon> - ); -} - -function CriticalSeverityIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm1 10V7.414l1.893 1.893c.13.124.282.216.457.261a1.006 1.006 0 0 0 1.176-.591 1.01 1.01 0 0 0 .01-.729 1.052 1.052 0 0 0-.229-.355c-1.212-1.212-2.394-2.456-3.638-3.636a1.073 1.073 0 0 0-.169-.123 1.05 1.05 0 0 0-.448-.133h-.104a1.053 1.053 0 0 0-.493.16 1.212 1.212 0 0 0-.162.132C6.08 5.505 4.836 6.687 3.656 7.932a.994.994 0 0 0-.051 1.275c.208.271.548.42.888.389.198-.019.378-.098.535-.218.041-.035.04-.034.079-.071L7 7.414V12h2z" - style={{ fill: theme.colors.red, fillRule: 'nonzero' }} - /> - )} - </ThemedIcon> - ); -} - -function MajorSeverityIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm.08 2.903c.071.008.14.019.208.039.138.042.26.114.37.205 1.244 1.146 2.426 2.357 3.639 3.536.1.103.181.218.234.352a1.01 1.01 0 0 1 .001.728 1.002 1.002 0 0 1-1.169.609 1.042 1.042 0 0 1-.46-.255L8 7.295l-2.903 2.822c-.039.036-.039.036-.08.07a1.002 1.002 0 0 1-1.604-.947c.032-.196.122-.37.253-.519C4.847 7.51 6.09 6.362 7.303 5.183c.052-.048.106-.093.167-.131a1.041 1.041 0 0 1 .61-.149z" - style={{ fill: theme.colors.red }} - /> - )} - </ThemedIcon> - ); -} - -function MinorSeverityIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm1 6.586V4H7v4.586L5.107 6.693a1.178 1.178 0 0 0-.165-.134 1.041 1.041 0 0 0-.662-.152 1 1 0 0 0-.587 1.7c1.212 1.212 2.394 2.456 3.638 3.636.094.08.195.146.311.191a1.008 1.008 0 0 0 1.065-.227c1.213-1.212 2.457-2.394 3.637-3.639a.994.994 0 0 0 .051-1.275 1.012 1.012 0 0 0-.888-.389 1.041 1.041 0 0 0-.535.218c-.04.034-.04.034-.079.071L9 8.586z" - style={{ fill: theme.colors.lightGreen }} - /> - )} - </ThemedIcon> - ); -} - -function InfoSeverityIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 2c3.311 0 6 2.689 6 6s-2.689 6-6 6-6-2.689-6-6 2.689-6 6-6zm1 5H7v5h2V7zm0-3H7v2h2V4z" - style={{ fill: theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/ShortLivingBranchIcon.tsx b/server/sonar-ui-common/components/icons/ShortLivingBranchIcon.tsx deleted file mode 100644 index 388bc50a262..00000000000 --- a/server/sonar-ui-common/components/icons/ShortLivingBranchIcon.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 React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function ShortLivingBranchIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <g transform="translate(3, 0)"> - <path - d="M9.5 6.5c0-1.1-.9-2-2-2s-2 .9-2 2c0 .8.5 1.5 1.2 1.8-.3.6-.7 1.1-1.2 1.4-.9.5-1.9.5-2.5.4V4c.9-.2 1.5-1 1.5-1.9 0-1.1-.9-2-2-2s-2 .9-2 2C.5 3 1.1 3.8 2 4v8c-.9.2-1.5 1-1.5 1.9 0 1.1.9 2 2 2s2-.9 2-2c0-.9-.6-1.7-1.5-1.9v-1c.2 0 .5.1.7.1.7 0 1.5-.1 2.2-.6.8-.5 1.4-1.2 1.7-2.1 1.1 0 1.9-.9 1.9-1.9zm-8-4.4c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1-1-.5-1-1zm2 11.9c0 .6-.4 1-1 1s-1-.4-1-1 .4-1 1-1 1 .4 1 1zm4-6.5c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1z" - style={{ fill: fill || theme.colors.blue }} - /> - </g> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/SortAscIcon.tsx b/server/sonar-ui-common/components/icons/SortAscIcon.tsx deleted file mode 100644 index 34dc1ca3002..00000000000 --- a/server/sonar-ui-common/components/icons/SortAscIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function SortAscIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M6.571 12.857q0 0.107-0.089 0.214l-2.848 2.848q-0.089 0.080-0.205 0.080-0.107 0-0.205-0.080l-2.857-2.857q-0.134-0.143-0.063-0.313 0.071-0.179 0.268-0.179h1.714v-12.286q0-0.125 0.080-0.205t0.205-0.080h1.714q0.125 0 0.205 0.080t0.080 0.205v12.286h1.714q0.125 0 0.205 0.080t0.080 0.205zM16 14v1.714q0 0.125-0.080 0.205t-0.205 0.080h-7.429q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h7.429q0.125 0 0.205 0.080t0.080 0.205zM14.286 9.429v1.714q0 0.125-0.080 0.205t-0.205 0.080h-5.714q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h5.714q0.125 0 0.205 0.080t0.080 0.205zM12.571 4.857v1.714q0 0.125-0.080 0.205t-0.205 0.080h-4q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h4q0.125 0 0.205 0.080t0.080 0.205zM10.857 0.286v1.714q0 0.125-0.080 0.205t-0.205 0.080h-2.286q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h2.286q0.125 0 0.205 0.080t0.080 0.205z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/SortDescIcon.tsx b/server/sonar-ui-common/components/icons/SortDescIcon.tsx deleted file mode 100644 index 9a4cba2e914..00000000000 --- a/server/sonar-ui-common/components/icons/SortDescIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function SortDescIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M10.857 14v1.714q0 0.125-0.080 0.205t-0.205 0.080h-2.286q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h2.286q0.125 0 0.205 0.080t0.080 0.205zM6.571 12.857q0 0.107-0.089 0.214l-2.848 2.848q-0.089 0.080-0.205 0.080-0.107 0-0.205-0.080l-2.857-2.857q-0.134-0.143-0.063-0.313 0.071-0.179 0.268-0.179h1.714v-12.286q0-0.125 0.080-0.205t0.205-0.080h1.714q0.125 0 0.205 0.080t0.080 0.205v12.286h1.714q0.125 0 0.205 0.080t0.080 0.205zM12.571 9.429v1.714q0 0.125-0.080 0.205t-0.205 0.080h-4q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h4q0.125 0 0.205 0.080t0.080 0.205zM14.286 4.857v1.714q0 0.125-0.080 0.205t-0.205 0.080h-5.714q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h5.714q0.125 0 0.205 0.080t0.080 0.205zM16 0.286v1.714q0 0.125-0.080 0.205t-0.205 0.080h-7.429q-0.125 0-0.205-0.080t-0.080-0.205v-1.714q0-0.125 0.080-0.205t0.205-0.080h7.429q0.125 0 0.205 0.080t0.080 0.205z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/StatusIcon.tsx b/server/sonar-ui-common/components/icons/StatusIcon.tsx deleted file mode 100644 index d5cf66bef86..00000000000 --- a/server/sonar-ui-common/components/icons/StatusIcon.tsx +++ /dev/null @@ -1,106 +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 { IconProps, ThemedIcon } from './Icon'; - -interface Props extends IconProps { - status: string; -} - -const statusIcons: T.Dict<(props: IconProps) => React.ReactElement> = { - open: OpenStatusIcon, - confirmed: ConfirmedStatusIcon, - reopened: ReopenedStatusIcon, - resolved: ResolvedStatusIcon, - closed: ClosedStatusIcon, - to_review: OpenStatusIcon, - in_review: ConfirmedStatusIcon, - reviewed: ResolvedStatusIcon, -}; - -export default function StatusIcon({ status, ...iconProps }: Props) { - const Icon = statusIcons[status.toLowerCase()]; - return Icon ? <Icon {...iconProps} /> : null; -} - -function OpenStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 3.75c-.77 0-1.482.19-2.133.57A4.25 4.25 0 0 0 4.32 5.867c-.38.65-.57 1.362-.57 2.133 0 .77.19 1.482.57 2.133.38.65.896 1.167 1.547 1.547.65.38 1.362.57 2.133.57.77 0 1.482-.19 2.133-.57a4.242 4.242 0 0 0 1.547-1.547c.38-.65.57-1.362.57-2.133 0-.77-.19-1.482-.57-2.133a4.25 4.25 0 0 0-1.547-1.547A4.153 4.153 0 0 0 8 3.75zM14 8c0 1.09-.268 2.092-.805 3.012a5.96 5.96 0 0 1-2.183 2.183A5.863 5.863 0 0 1 8 14a5.863 5.863 0 0 1-3.012-.805 5.96 5.96 0 0 1-2.183-2.183A5.863 5.863 0 0 1 2 8c0-1.09.268-2.092.805-3.012a5.96 5.96 0 0 1 2.183-2.183A5.863 5.863 0 0 1 8 2c1.09 0 2.092.268 3.012.805a5.96 5.96 0 0 1 2.183 2.183C13.732 5.908 14 6.91 14 8z" - style={{ fill: theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function ConfirmedStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M10 8c0 .552-.195 1.023-.586 1.414-.39.39-.862.586-1.414.586a1.926 1.926 0 0 1-1.414-.586A1.928 1.928 0 0 1 6 8c0-.552.195-1.023.586-1.414C6.976 6.196 7.448 6 8 6c.552 0 1.023.195 1.414.586.39.39.586.862.586 1.414zM8 3.75c-.77 0-1.482.19-2.133.57A4.25 4.25 0 0 0 4.32 5.867c-.38.65-.57 1.362-.57 2.133 0 .77.19 1.482.57 2.133.38.65.896 1.167 1.547 1.547.65.38 1.362.57 2.133.57.77 0 1.482-.19 2.133-.57a4.242 4.242 0 0 0 1.547-1.547c.38-.65.57-1.362.57-2.133 0-.77-.19-1.482-.57-2.133a4.25 4.25 0 0 0-1.547-1.547A4.153 4.153 0 0 0 8 3.75zM14 8c0 1.09-.268 2.092-.805 3.012a5.96 5.96 0 0 1-2.183 2.183A5.863 5.863 0 0 1 8 14a5.863 5.863 0 0 1-3.012-.805 5.96 5.96 0 0 1-2.183-2.183A5.863 5.863 0 0 1 2 8c0-1.09.268-2.092.805-3.012a5.96 5.96 0 0 1 2.183-2.183A5.863 5.863 0 0 1 8 2c1.09 0 2.092.268 3.012.805a5.96 5.96 0 0 1 2.183 2.183C13.732 5.908 14 6.91 14 8z" - style={{ fill: theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function ReopenedStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 12.25v-8.5c-.77 0-1.482.19-2.133.57A4.25 4.25 0 0 0 4.32 5.867c-.38.65-.57 1.362-.57 2.133 0 .77.19 1.482.57 2.133.38.65.896 1.167 1.547 1.547.65.38 1.362.57 2.133.57zM14 8c0 1.09-.268 2.092-.805 3.012a5.96 5.96 0 0 1-2.183 2.183A5.863 5.863 0 0 1 8 14a5.863 5.863 0 0 1-3.012-.805 5.96 5.96 0 0 1-2.183-2.183A5.863 5.863 0 0 1 2 8c0-1.09.268-2.092.805-3.012a5.96 5.96 0 0 1 2.183-2.183A5.863 5.863 0 0 1 8 2c1.09 0 2.092.268 3.012.805a5.96 5.96 0 0 1 2.183 2.183C13.732 5.908 14 6.91 14 8z" - style={{ fill: theme.colors.blue }} - /> - )} - </ThemedIcon> - ); -} - -function ResolvedStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M12.03 6.734a.49.49 0 0 0-.14-.36l-.71-.702a.48.48 0 0 0-.352-.15.474.474 0 0 0-.35.15l-3.19 3.18-1.765-1.766a.479.479 0 0 0-.35-.15.479.479 0 0 0-.353.15l-.71.703a.482.482 0 0 0-.14.358c0 .14.046.258.14.352l2.828 2.828c.098.1.216.15.35.15.142 0 .26-.05.36-.15l4.243-4.242a.475.475 0 0 0 .14-.352l-.001.001zM14 8c0 1.09-.268 2.092-.805 3.012a5.96 5.96 0 0 1-2.183 2.183A5.863 5.863 0 0 1 8 14a5.863 5.863 0 0 1-3.012-.805 5.96 5.96 0 0 1-2.183-2.183A5.863 5.863 0 0 1 2 8c0-1.09.268-2.092.805-3.012a5.96 5.96 0 0 1 2.183-2.183A5.863 5.863 0 0 1 8 2c1.09 0 2.092.268 3.012.805a5.96 5.96 0 0 1 2.183 2.183C13.732 5.908 14 6.91 14 8z" - style={{ fill: theme.colors.baseFontColor }} - /> - )} - </ThemedIcon> - ); -} - -function ClosedStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M14 8c0 1.09-.268 2.092-.805 3.012a5.96 5.96 0 0 1-2.183 2.183A5.863 5.863 0 0 1 8 14a5.863 5.863 0 0 1-3.012-.805 5.96 5.96 0 0 1-2.183-2.183A5.863 5.863 0 0 1 2 8c0-1.09.268-2.092.805-3.012a5.96 5.96 0 0 1 2.183-2.183A5.863 5.863 0 0 1 8 2c1.09 0 2.092.268 3.012.805a5.96 5.96 0 0 1 2.183 2.183C13.732 5.908 14 6.91 14 8z" - style={{ fill: theme.colors.baseFontColor }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/TagsIcon.tsx b/server/sonar-ui-common/components/icons/TagsIcon.tsx deleted file mode 100644 index 649256cf8fa..00000000000 --- a/server/sonar-ui-common/components/icons/TagsIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function TagsIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M4.303 5.36a.94.94 0 0 0-.944-.945.94.94 0 0 0-.944.944c0 .524.42.944.944.944a.94.94 0 0 0 .944-.944zm7.866 4.246a.95.95 0 0 1-.273.663l-3.62 3.627a.95.95 0 0 1-1.334 0L1.671 8.618C1.295 8.249 1 7.534 1 7.01V3.944A.95.95 0 0 1 1.944 3H5.01c.523 0 1.238.295 1.614.67l5.271 5.265a.98.98 0 0 1 .273.67zm2.831 0a.95.95 0 0 1-.273.663l-3.62 3.627a.98.98 0 0 1-.67.273c-.384 0-.575-.177-.826-.435l3.465-3.465a.95.95 0 0 0 0-1.334L7.805 3.67C7.429 3.295 6.714 3 6.19 3h1.651c.524 0 1.239.295 1.615.67l5.271 5.265a.98.98 0 0 1 .273.67z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/TestStatusIcon.tsx b/server/sonar-ui-common/components/icons/TestStatusIcon.tsx deleted file mode 100644 index cbcb77ad3a2..00000000000 --- a/server/sonar-ui-common/components/icons/TestStatusIcon.tsx +++ /dev/null @@ -1,89 +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 { IconProps, ThemedIcon } from './Icon'; - -interface Props extends IconProps { - status: string; -} - -const statusIcons: T.Dict<(props: IconProps) => React.ReactElement> = { - ok: OkTestStatusIcon, - failure: FailureTestStatusIcon, - error: ErrorTestStatusIcon, - skipped: SkippedTestStatusIcon, -}; - -export default function TestStatusIcon({ status, ...iconProps }: Props) { - const Icon = statusIcons[status.toLowerCase()]; - return Icon ? <Icon {...iconProps} /> : null; -} - -function OkTestStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M12.03 6.734a.49.49 0 0 0-.14-.36l-.71-.702a.48.48 0 0 0-.352-.15.474.474 0 0 0-.35.15l-3.19 3.18-1.765-1.766a.479.479 0 0 0-.35-.15.479.479 0 0 0-.353.15l-.71.703a.482.482 0 0 0-.14.358c0 .14.046.258.14.352l2.828 2.828c.098.1.216.15.35.15.142 0 .26-.05.36-.15l4.243-4.242a.475.475 0 0 0 .14-.352l-.001.001zM14 8c0 1.09-.268 2.092-.805 3.012a5.96 5.96 0 0 1-2.183 2.183A5.863 5.863 0 0 1 8 14a5.863 5.863 0 0 1-3.012-.805 5.96 5.96 0 0 1-2.183-2.183A5.863 5.863 0 0 1 2 8c0-1.09.268-2.092.805-3.012a5.96 5.96 0 0 1 2.183-2.183A5.863 5.863 0 0 1 8 2c1.09 0 2.092.268 3.012.805a5.96 5.96 0 0 1 2.183 2.183C13.732 5.908 14 6.91 14 8z" - style={{ fill: theme.colors.green }} - /> - )} - </ThemedIcon> - ); -} - -function FailureTestStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M8 14c-3.311 0-6-2.689-6-6s2.689-6 6-6 6 2.689 6 6-2.689 6-6 6zM7 9h2V4H7v5zm0 3h2v-2H7v2z" - style={{ fill: theme.colors.orange, fillRule: 'nonzero' }} - /> - )} - </ThemedIcon> - ); -} - -function ErrorTestStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M10.977 9.766a.497.497 0 0 0-.149-.352L9.414 8l1.414-1.414a.497.497 0 0 0 0-.711l-.703-.703a.497.497 0 0 0-.71 0L8 6.586 6.586 5.172a.497.497 0 0 0-.711 0l-.703.703a.497.497 0 0 0 0 .71L6.586 8 5.172 9.414a.497.497 0 0 0 0 .711l.703.703a.497.497 0 0 0 .71 0L8 9.414l1.414 1.414a.497.497 0 0 0 .711 0l.703-.703a.515.515 0 0 0 .149-.36zM14 8c0 3.313-2.688 6-6 6-3.313 0-6-2.688-6-6 0-3.313 2.688-6 6-6 3.313 0 6 2.688 6 6z" - style={{ fill: theme.colors.red, fillRule: 'nonzero' }} - /> - )} - </ThemedIcon> - ); -} - -function SkippedTestStatusIcon(iconProps: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M11.5 8.5v-1c0-.273-.227-.5-.5-.5H5c-.273 0-.5.227-.5.5v1c0 .273.227.5.5.5h6c.273 0 .5-.227.5-.5zM14 8c0 3.313-2.688 6-6 6-3.313 0-6-2.688-6-6 0-3.313 2.688-6 6-6 3.313 0 6 2.688 6 6z" - style={{ fill: theme.colors.gray71, fillRule: 'nonzero' }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/TreeIcon.tsx b/server/sonar-ui-common/components/icons/TreeIcon.tsx deleted file mode 100644 index 5b9992352e3..00000000000 --- a/server/sonar-ui-common/components/icons/TreeIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function TreeIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M15.045 2.467c0-0.277-0.225-0.503-0.503-0.503h-13.084c-0.277 0-0.503 0.225-0.503 0.503v1.007c0 0.277 0.225 0.503 0.503 0.503h13.084c0.277 0 0.503-0.225 0.503-0.503v-1.007zM15.045 5.487c0-0.277-0.194-0.503-0.432-0.503h-11.216c-0.238 0-0.432 0.225-0.432 0.503v1.007c0 0.277 0.193 0.503 0.432 0.503h11.216c0.238 0 0.432-0.225 0.432-0.503v-1.007zM15.045 8.506c0-0.277-0.161-0.503-0.359-0.503h-9.346c-0.198 0-0.359 0.225-0.359 0.503v1.007c0 0.277 0.161 0.503 0.359 0.503h9.346c0.198 0 0.359-0.225 0.359-0.503v-1.007zM15.045 11.527c0-0.277-0.129-0.503-0.287-0.503h-7.477c-0.159 0-0.288 0.225-0.288 0.503v1.007c0 0.277 0.129 0.503 0.288 0.503h7.477c0.159 0 0.287-0.225 0.287-0.503v-1.007z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/TreemapIcon.tsx b/server/sonar-ui-common/components/icons/TreemapIcon.tsx deleted file mode 100644 index 66d14f39793..00000000000 --- a/server/sonar-ui-common/components/icons/TreemapIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function TreemapIcon({ fill = 'currentColor', size = 14, ...iconProps }: IconProps) { - return ( - <Icon size={size} {...iconProps}> - <path - d="M0 0h8v16h-8zM9.143 0h6.857v9.143h-6.857zM9.143 10.286h6.857v5.714h-6.857z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/VisibleIcon.tsx b/server/sonar-ui-common/components/icons/VisibleIcon.tsx deleted file mode 100644 index d50d4d873d3..00000000000 --- a/server/sonar-ui-common/components/icons/VisibleIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function VisibleIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M13.524 8.403q-1.093-1.697-2.74-2.539 0.439 0.748 0.439 1.618 0 1.331-0.946 2.276t-2.276 0.946-2.276-0.946-0.946-2.276q0-0.87 0.439-1.618-1.647 0.842-2.74 2.539 0.957 1.474 2.399 2.348t3.125 0.874 3.125-0.874 2.399-2.348zM8.345 5.641q0-0.144-0.101-0.245t-0.245-0.101q-0.899 0-1.543 0.644t-0.644 1.543q0 0.144 0.101 0.245t0.245 0.101 0.245-0.101 0.101-0.245q0-0.619 0.439-1.057t1.057-0.439q0.144 0 0.245-0.101t0.101-0.245zM14.444 8.403q0 0.245-0.144 0.496-1.007 1.654-2.708 2.65t-3.593 0.996-3.593-1-2.708-2.647q-0.144-0.252-0.144-0.496t0.144-0.496q1.007-1.647 2.708-2.647t3.593-1 3.593 1 2.708 2.647q0.144 0.252 0.144 0.496z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/VulnerabilityIcon.tsx b/server/sonar-ui-common/components/icons/VulnerabilityIcon.tsx deleted file mode 100644 index 34da45580b4..00000000000 --- a/server/sonar-ui-common/components/icons/VulnerabilityIcon.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 * as React from 'react'; -import Icon, { IconProps } from './Icon'; - -export default function VulnerabilityIcon({ fill = 'currentColor', ...iconProps }: IconProps) { - return ( - <Icon {...iconProps}> - <path - d="M12,7.05H6V5a2,2,0,1,1,4,0,1,1,0,0,0,2,0A4,4,0,1,0,4,5V7.06A1.12,1.12,0,0,0,3,8.17V14a1.12,1.12,0,0,0,1.12,1.12H12A1.12,1.12,0,0,0,13.1,14V8.17A1.12,1.12,0,0,0,12,7.05ZM8,13a2,2,0,1,1,2-2A2,2,0,0,1,8,13Z" - style={{ fill }} - /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/WarningIcon.tsx b/server/sonar-ui-common/components/icons/WarningIcon.tsx deleted file mode 100644 index ceda2ea90ae..00000000000 --- a/server/sonar-ui-common/components/icons/WarningIcon.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 * as React from 'react'; -import { IconProps, ThemedIcon } from './Icon'; - -export default function WarningIcon({ fill, ...iconProps }: IconProps) { - return ( - <ThemedIcon {...iconProps}> - {({ theme }) => ( - <path - d="M9 12.242v-1.484c0-.14-.11-.258-.25-.258h-1.5c-.14 0-.25.117-.25.258v1.484c0 .14.11.258.25.258h1.5c.14 0 .25-.117.25-.258zM8.984 9.32l.141-3.586a.189.189 0 0 0-.078-.148C9 5.546 8.93 5.5 8.859 5.5H7.141c-.07 0-.141.047-.188.086-.055.039-.078.117-.078.164l.133 3.57c0 .102.117.18.265.18H8.72c.14 0 .258-.078.265-.18zm-.109-7.297l6 11A1 1 0 0 1 14 14.5H2a1 1 0 0 1-.875-1.477l6-11a.994.994 0 0 1 1.75 0z" - style={{ fill: fill || theme.colors.warningIconColor }} - /> - )} - </ThemedIcon> - ); -} diff --git a/server/sonar-ui-common/components/icons/__tests__/Icon-test.tsx b/server/sonar-ui-common/components/icons/__tests__/Icon-test.tsx deleted file mode 100644 index 341eb88a17e..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/Icon-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 Icon, { IconProps } from '../Icon'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -function shallowRender(props: Partial<IconProps> = {}) { - return shallow( - <Icon {...props}> - <path d="test-path" /> - </Icon> - ); -} diff --git a/server/sonar-ui-common/components/icons/__tests__/IssueIcon-test.tsx b/server/sonar-ui-common/components/icons/__tests__/IssueIcon-test.tsx deleted file mode 100644 index 852beec5385..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/IssueIcon-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 IssueIcon from '../IssueIcon'; - -it('should render correctly', () => { - expect(shallowRender('BUG')).toMatchSnapshot(); - expect(shallowRender('VULNERABILITY')).toMatchSnapshot(); - expect(shallowRender('CODE_SMELL')).toMatchSnapshot(); - expect(shallowRender('SECURITY_HOTSPOT')).toMatchSnapshot(); -}); - -function shallowRender(type: T.IssueType) { - return shallow(<IssueIcon type={type} />); -} diff --git a/server/sonar-ui-common/components/icons/__tests__/IssueTypeIcon-test.tsx b/server/sonar-ui-common/components/icons/__tests__/IssueTypeIcon-test.tsx deleted file mode 100644 index dbd892fdb52..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/IssueTypeIcon-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 IssueTypeIcon, { Props } from '../IssueTypeIcon'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ className: 'my-class', query: 'security_hotspots' })).toMatchSnapshot(); - expect(shallowRender({ query: 'new_code_smells' })).toMatchSnapshot(); - expect(shallowRender({ query: 'vulnerability' })).toMatchSnapshot(); - expect(shallowRender({ query: 'unknown' }).type()).toBeNull(); -}); - -function shallowRender(props: Partial<Props> = {}) { - return shallow(<IssueTypeIcon query="bugs" {...props} />); -} diff --git a/server/sonar-ui-common/components/icons/__tests__/TestStatusIcon-test.tsx b/server/sonar-ui-common/components/icons/__tests__/TestStatusIcon-test.tsx deleted file mode 100644 index c683e6cd02f..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/TestStatusIcon-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 TestStatusIcon from '../TestStatusIcon'; - -it('should render correctly', () => { - expect(shallowRender('OK')).toMatchSnapshot(); - expect(shallowRender('failure')).toMatchSnapshot(); - expect(shallowRender('skipped')).toMatchSnapshot(); - expect(shallowRender('Error')).toMatchSnapshot(); -}); - -function shallowRender(status: string) { - return shallow(<TestStatusIcon status={status} />); -} diff --git a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap b/server/sonar-ui-common/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap deleted file mode 100644 index a61c0314f87..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/Icon-test.tsx.snap +++ /dev/null @@ -1,24 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<svg - height={16} - style={ - Object { - "clipRule": "evenodd", - "fillRule": "evenodd", - "strokeLinejoin": "round", - "strokeMiterlimit": 1.41421, - } - } - version="1.1" - viewBox="0 0 16 16" - width={16} - xmlSpace="preserve" - xmlnsXlink="http://www.w3.org/1999/xlink" -> - <path - d="test-path" - /> -</svg> -`; diff --git a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/IssueIcon-test.tsx.snap b/server/sonar-ui-common/components/icons/__tests__/__snapshots__/IssueIcon-test.tsx.snap deleted file mode 100644 index f3f5fcf1a7a..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/IssueIcon-test.tsx.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = `<BugIcon />`; - -exports[`should render correctly 2`] = `<VulnerabilityIcon />`; - -exports[`should render correctly 3`] = `<CodeSmellIcon />`; - -exports[`should render correctly 4`] = `<SecurityHotspotIcon />`; diff --git a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/IssueTypeIcon-test.tsx.snap b/server/sonar-ui-common/components/icons/__tests__/__snapshots__/IssueTypeIcon-test.tsx.snap deleted file mode 100644 index 4373bb03f4c..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/IssueTypeIcon-test.tsx.snap +++ /dev/null @@ -1,26 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<IssueIcon - type="BUG" -/> -`; - -exports[`should render correctly 2`] = ` -<IssueIcon - className="my-class" - type="SECURITY_HOTSPOT" -/> -`; - -exports[`should render correctly 3`] = ` -<IssueIcon - type="CODE_SMELL" -/> -`; - -exports[`should render correctly 4`] = ` -<IssueIcon - type="VULNERABILITY" -/> -`; diff --git a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/TestStatusIcon-test.tsx.snap b/server/sonar-ui-common/components/icons/__tests__/__snapshots__/TestStatusIcon-test.tsx.snap deleted file mode 100644 index 12b493c10ed..00000000000 --- a/server/sonar-ui-common/components/icons/__tests__/__snapshots__/TestStatusIcon-test.tsx.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = `<OkTestStatusIcon />`; - -exports[`should render correctly 2`] = `<FailureTestStatusIcon />`; - -exports[`should render correctly 3`] = `<SkippedTestStatusIcon />`; - -exports[`should render correctly 4`] = `<ErrorTestStatusIcon />`; diff --git a/server/sonar-ui-common/components/intl/DateFormatter.tsx b/server/sonar-ui-common/components/intl/DateFormatter.tsx deleted file mode 100644 index c33b8a78ff5..00000000000 --- a/server/sonar-ui-common/components/intl/DateFormatter.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 * as React from 'react'; -import { DateSource, FormattedDate } from 'react-intl'; -import { parseDate } from '../../helpers/dates'; - -export interface DateFormatterProps { - children?: (formattedDate: string) => React.ReactNode; - date: DateSource; - long?: boolean; -} - -export const formatterOption = { year: 'numeric', month: 'short', day: '2-digit' }; - -export const longFormatterOption = { year: 'numeric', month: 'long', day: 'numeric' }; - -export default function DateFormatter({ children, date, long }: DateFormatterProps) { - return ( - <FormattedDate value={parseDate(date)} {...(long ? longFormatterOption : formatterOption)}> - {children} - </FormattedDate> - ); -} diff --git a/server/sonar-ui-common/components/intl/DateFromNow.tsx b/server/sonar-ui-common/components/intl/DateFromNow.tsx deleted file mode 100644 index 13c383d5288..00000000000 --- a/server/sonar-ui-common/components/intl/DateFromNow.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 { differenceInHours } from 'date-fns'; -import * as React from 'react'; -import { DateSource, FormattedRelative } from 'react-intl'; -import { parseDate } from '../../helpers/dates'; -import { translate } from '../../helpers/l10n'; -import DateTimeFormatter from './DateTimeFormatter'; - -export interface DateFromNowProps { - children?: (formattedDate: string) => React.ReactNode; - date?: DateSource; - hourPrecision?: boolean; -} - -export default function DateFromNow(props: DateFromNowProps) { - const { children: originalChildren = (f: string) => f, date, hourPrecision } = props; - let children = originalChildren; - - if (!date) { - /* - * We return a JSX.Element to bypass typescript issue with functional components return type - * (https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20544) - */ - // eslint-disable-next-line react/jsx-no-useless-fragment - return <>{originalChildren(translate('never'))}</>; - } - - if (date && hourPrecision && differenceInHours(Date.now(), date) < 1) { - children = () => originalChildren(translate('less_than_1_hour_ago')); - } - - const parsedDate = parseDate(date); - - return ( - <DateTimeFormatter date={parsedDate}> - {(formattedDate) => ( - <span title={formattedDate}> - <FormattedRelative value={parsedDate}>{children}</FormattedRelative> - </span> - )} - </DateTimeFormatter> - ); -} diff --git a/server/sonar-ui-common/components/intl/DateTimeFormatter.tsx b/server/sonar-ui-common/components/intl/DateTimeFormatter.tsx deleted file mode 100644 index ebc3e37b473..00000000000 --- a/server/sonar-ui-common/components/intl/DateTimeFormatter.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 * as React from 'react'; -import { DateSource, FormattedDate } from 'react-intl'; -import { parseDate } from '../../helpers/dates'; - -interface Props { - children?: (formattedDate: string) => React.ReactNode; - date: DateSource; -} - -export const formatterOption = { - year: 'numeric', - month: 'long', - day: 'numeric', - hour: 'numeric', - minute: 'numeric', -}; - -export default function DateTimeFormatter({ children, date }: Props) { - return ( - <FormattedDate value={parseDate(date)} {...formatterOption}> - {children} - </FormattedDate> - ); -} diff --git a/server/sonar-ui-common/components/intl/TimeFormatter.tsx b/server/sonar-ui-common/components/intl/TimeFormatter.tsx deleted file mode 100644 index 8fb5af05440..00000000000 --- a/server/sonar-ui-common/components/intl/TimeFormatter.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 * as React from 'react'; -import { DateSource, FormattedTime } from 'react-intl'; -import { parseDate } from '../../helpers/dates'; - -export interface TimeFormatterProps { - children?: (formattedDate: string) => React.ReactNode; - date: DateSource; - long?: boolean; -} - -export const formatterOption = { hour: 'numeric', minute: 'numeric' }; - -export const longFormatterOption = { hour: 'numeric', minute: 'numeric', second: 'numeric' }; - -export default function TimeFormatter({ children, date, long }: TimeFormatterProps) { - return ( - <FormattedTime value={parseDate(date)} {...(long ? longFormatterOption : formatterOption)}> - {children} - </FormattedTime> - ); -} diff --git a/server/sonar-ui-common/components/intl/__mocks__/DateFromNow.tsx b/server/sonar-ui-common/components/intl/__mocks__/DateFromNow.tsx deleted file mode 100644 index 76a585b4045..00000000000 --- a/server/sonar-ui-common/components/intl/__mocks__/DateFromNow.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 * as React from 'react'; -import { DateSource } from 'react-intl'; - -interface Props { - children?: (formattedDate: string) => React.ReactNode; - date: DateSource; -} - -export default function DateFromNow({ children, date }: Props) { - return children && children(date.toString()); -} diff --git a/server/sonar-ui-common/components/intl/__tests__/DateFormatter-test.tsx b/server/sonar-ui-common/components/intl/__tests__/DateFormatter-test.tsx deleted file mode 100644 index 6780d67d21c..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/DateFormatter-test.tsx +++ /dev/null @@ -1,35 +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 DateFormatter, { DateFormatterProps } from '../DateFormatter'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('standard'); - expect(shallowRender({ long: true })).toMatchSnapshot('long'); -}); - -function shallowRender(overrides: Partial<DateFormatterProps> = {}) { - return shallow( - <DateFormatter date={new Date('2020-02-20T20:20:20Z')} {...overrides}> - {(formatted) => <span>{formatted}</span>} - </DateFormatter> - ); -} diff --git a/server/sonar-ui-common/components/intl/__tests__/DateFromNow-test.tsx b/server/sonar-ui-common/components/intl/__tests__/DateFromNow-test.tsx deleted file mode 100644 index c7edcfaa1a4..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/DateFromNow-test.tsx +++ /dev/null @@ -1,66 +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 { FormattedRelative, IntlProvider } from 'react-intl'; -import DateFromNow, { DateFromNowProps } from '../DateFromNow'; -import DateTimeFormatter from '../DateTimeFormatter'; - -const date = '2020-02-20T20:20:20Z'; - -it('should render correctly', () => { - const wrapper = shallowRender(); - - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find(DateTimeFormatter).props().children!(date)).toMatchSnapshot('children'); -}); - -it('should render correctly when there is no date', () => { - const children = jest.fn(); - - shallowRender({ date: undefined }, children); - - expect(children).toHaveBeenCalledWith('never'); -}); - -it('should render correctly when the date is less than one hour in the past', () => { - const veryCloseDate = new Date(date); - veryCloseDate.setMinutes(veryCloseDate.getMinutes() - 10); - jest.spyOn(Date, 'now').mockImplementation(() => (new Date(date) as unknown) as number); - const children = jest.fn(); - - shallowRender({ date: veryCloseDate, hourPrecision: true }, children) - .dive() - .dive() - .find(FormattedRelative) - .props().children!(date); - - expect(children).toHaveBeenCalledWith('less_than_1_hour_ago'); -}); - -function shallowRender(overrides: Partial<DateFromNowProps> = {}, children: jest.Mock = jest.fn()) { - return shallow<DateFromNowProps>( - <IntlProvider defaultLocale="en-US" locale="en"> - <DateFromNow date={date} {...overrides}> - {(formattedDate) => children(formattedDate)} - </DateFromNow> - </IntlProvider> - ).dive(); -} diff --git a/server/sonar-ui-common/components/intl/__tests__/DateTimeFormatter-test.tsx b/server/sonar-ui-common/components/intl/__tests__/DateTimeFormatter-test.tsx deleted file mode 100644 index 8d6dbf2add7..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/DateTimeFormatter-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 DateTimeFormatter from '../DateTimeFormatter'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('standard'); -}); - -function shallowRender() { - return shallow( - <DateTimeFormatter date={new Date('2020-02-20T20:20:20Z')}> - {(formatted) => <span>{formatted}</span>} - </DateTimeFormatter> - ); -} diff --git a/server/sonar-ui-common/components/intl/__tests__/TimeFormatter-test.tsx b/server/sonar-ui-common/components/intl/__tests__/TimeFormatter-test.tsx deleted file mode 100644 index 0af517feb93..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/TimeFormatter-test.tsx +++ /dev/null @@ -1,35 +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 TimeFormatter, { TimeFormatterProps } from '../TimeFormatter'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('standard'); - expect(shallowRender({ long: true })).toMatchSnapshot('long'); -}); - -function shallowRender(overrides: Partial<TimeFormatterProps> = {}) { - return shallow( - <TimeFormatter date={new Date('2020-02-20T20:20:20Z')} {...overrides}> - {(formatted) => <span>{formatted}</span>} - </TimeFormatter> - ); -} diff --git a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateFormatter-test.tsx.snap b/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateFormatter-test.tsx.snap deleted file mode 100644 index 2f603c6c1bd..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateFormatter-test.tsx.snap +++ /dev/null @@ -1,23 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: long 1`] = ` -<FormattedDate - day="numeric" - month="long" - value={2020-02-20T20:20:20.000Z} - year="numeric" -> - <Component /> -</FormattedDate> -`; - -exports[`should render correctly: standard 1`] = ` -<FormattedDate - day="2-digit" - month="short" - value={2020-02-20T20:20:20.000Z} - year="numeric" -> - <Component /> -</FormattedDate> -`; diff --git a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateFromNow-test.tsx.snap b/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateFromNow-test.tsx.snap deleted file mode 100644 index 19ee5460047..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateFromNow-test.tsx.snap +++ /dev/null @@ -1,22 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<DateTimeFormatter - date={2020-02-20T20:20:20.000Z} -> - <Component /> -</DateTimeFormatter> -`; - -exports[`should render correctly: children 1`] = ` -<span - title="2020-02-20T20:20:20Z" -> - <FormattedRelative - updateInterval={10000} - value={2020-02-20T20:20:20.000Z} - > - [Function] - </FormattedRelative> -</span> -`; diff --git a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateTimeFormatter-test.tsx.snap b/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateTimeFormatter-test.tsx.snap deleted file mode 100644 index c991112f771..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/DateTimeFormatter-test.tsx.snap +++ /dev/null @@ -1,14 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: standard 1`] = ` -<FormattedDate - day="numeric" - hour="numeric" - minute="numeric" - month="long" - value={2020-02-20T20:20:20.000Z} - year="numeric" -> - <Component /> -</FormattedDate> -`; diff --git a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/TimeFormatter-test.tsx.snap b/server/sonar-ui-common/components/intl/__tests__/__snapshots__/TimeFormatter-test.tsx.snap deleted file mode 100644 index 7c19be3a479..00000000000 --- a/server/sonar-ui-common/components/intl/__tests__/__snapshots__/TimeFormatter-test.tsx.snap +++ /dev/null @@ -1,22 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: long 1`] = ` -<FormattedTime - hour="numeric" - minute="numeric" - second="numeric" - value={2020-02-20T20:20:20.000Z} -> - <Component /> -</FormattedTime> -`; - -exports[`should render correctly: standard 1`] = ` -<FormattedTime - hour="numeric" - minute="numeric" - value={2020-02-20T20:20:20.000Z} -> - <Component /> -</FormattedTime> -`; diff --git a/server/sonar-ui-common/components/lazyLoadComponent.tsx b/server/sonar-ui-common/components/lazyLoadComponent.tsx deleted file mode 100644 index 25b96db6c36..00000000000 --- a/server/sonar-ui-common/components/lazyLoadComponent.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 * as React from 'react'; -import { IS_SSR } from '../helpers/init'; -import { translate } from '../helpers/l10n'; -import { requestTryAndRepeatUntil } from '../helpers/request'; -import { Alert } from './ui/Alert'; - -export function lazyLoadComponent<T extends React.ComponentType<any>>( - factory: () => Promise<{ default: T }>, - displayName?: string -) { - const LazyComponent = React.lazy(() => - requestTryAndRepeatUntil(factory, { max: 2, slowThreshold: 2 }, () => true) - ); - - function LazyComponentWrapper(props: React.ComponentProps<T>) { - if (IS_SSR) { - return null; - } - return ( - <LazyErrorBoundary> - <React.Suspense fallback={null}> - <LazyComponent {...props} /> - </React.Suspense> - </LazyErrorBoundary> - ); - } - - LazyComponentWrapper.displayName = displayName; - return LazyComponentWrapper; -} - -interface ErrorBoundaryProps { - children: React.ReactNode; -} - -interface ErrorBoundaryState { - hasError: boolean; -} - -export class LazyErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> { - state: ErrorBoundaryState = { hasError: false }; - - static getDerivedStateFromError() { - // Update state so the next render will show the fallback UI. - return { hasError: true }; - } - - render() { - if (this.state.hasError) { - return <Alert variant="error">{translate('default_error_message')}</Alert>; - } - return this.props.children; - } -} diff --git a/server/sonar-ui-common/components/theme.ts b/server/sonar-ui-common/components/theme.ts deleted file mode 100644 index a63104f1e56..00000000000 --- a/server/sonar-ui-common/components/theme.ts +++ /dev/null @@ -1,65 +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 { css, ThemeContext as EmotionThemeContext } from '@emotion/core'; -import emotionStyled, { CreateStyled } from '@emotion/styled'; -import { - ThemeProvider as EmotionThemeProvider, - ThemeProviderProps, - useTheme as emotionUseTheme, - withTheme, -} from 'emotion-theming'; -import * as React from 'react'; - -export interface Theme { - colors: T.Dict<string>; - sizes: T.Dict<string>; - rawSizes: T.Dict<number>; - fonts: T.Dict<string>; - zIndexes: T.Dict<string>; - others: T.Dict<string>; -} - -export interface ThemedProps { - theme: Theme; -} - -const ThemeContext = EmotionThemeContext as React.Context<Theme>; - -export const styled = emotionStyled as CreateStyled<Theme>; -export const ThemeConsumer = ThemeContext.Consumer; -export const ThemeProvider = EmotionThemeProvider as React.ProviderExoticComponent< - ThemeProviderProps<Theme> ->; -export const useTheme = emotionUseTheme as () => Theme; - -export function themeGet(type: keyof Theme, name: string | number) { - return function ({ theme }: Partial<ThemedProps>) { - return theme?.[type][name]; - }; -} -export function themeColor(name: keyof Theme['colors']) { - return themeGet('colors', name); -} -export function themeSize(name: keyof Theme['sizes']) { - return themeGet('sizes', name); -} - -export { css, withTheme }; -export default ThemeContext; 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; -} |