From 4be6479134e70c0dc38be9875eb91e24d4bd0436 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Fri, 7 Oct 2022 10:30:25 +0200 Subject: SONAR-17000 SONAR-16974 * [894088] Element inappropriately uses semantic markup * [894116] Label is not persistent --- .../audit-logs/components/AuditAppRenderer.tsx | 1 - .../js/apps/background-tasks/background-tasks.css | 4 - .../background-tasks/components/CurrentsFilter.tsx | 36 ++-- .../js/apps/background-tasks/components/Search.tsx | 46 ++++-- .../background-tasks/components/StatusFilter.tsx | 63 +++---- .../background-tasks/components/TypesFilter.tsx | 4 +- .../components/ProjectActivityApp.tsx | 4 +- .../components/ProjectActivityDateInput.tsx | 2 +- .../components/ProjectActivityPageFilters.tsx | 76 +++++++++ .../components/ProjectActivityPageHeader.tsx | 72 -------- .../__tests__/ProjectActivityPageFilters-test.tsx | 36 ++++ .../__tests__/ProjectActivityPageHeader-test.tsx | 36 ---- .../__snapshots__/ProjectActivityApp-test.tsx.snap | 2 +- .../ProjectActivityDateInput-test.tsx.snap | 4 +- .../ProjectActivityPageFilters-test.tsx.snap | 50 ++++++ .../ProjectActivityPageHeader-test.tsx.snap | 40 ----- .../quality-profiles/changelog/ChangelogSearch.tsx | 23 ++- .../__snapshots__/ChangelogSearch-test.tsx.snap | 2 +- .../src/main/js/components/controls/DateInput.tsx | 3 + .../main/js/components/controls/DateRangeInput.tsx | 60 ++++--- .../__snapshots__/DateRangeInput-test.tsx.snap | 182 ++++++++++++++------- 21 files changed, 435 insertions(+), 311 deletions(-) create mode 100644 server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageFilters.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx create mode 100644 server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityPageFilters-test.tsx delete mode 100644 server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityPageHeader-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityPageFilters-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityPageHeader-test.tsx.snap (limited to 'server/sonar-web') diff --git a/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx b/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx index 668cb99c8e4..d191cc46fb3 100644 --- a/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/audit-logs/components/AuditAppRenderer.tsx @@ -119,7 +119,6 @@ export default function AuditAppRenderer(props: AuditAppRendererProps) { void; } -export default class CurrentsFilter extends React.PureComponent { - handleChange = (value: boolean) => { - const newValue = value ? CURRENTS.ONLY_CURRENTS : CURRENTS.ALL; - this.props.onChange(newValue); - }; +export default function CurrentsFilter(props: CurrentsFilterProps) { + const { id, value, onChange } = props; + const checked = value === CURRENTS.ONLY_CURRENTS; - render() { - const checked = this.props.value === CURRENTS.ONLY_CURRENTS; - return ( -
- - {translate('yes')} - -
- ); - } + const handleChange = React.useCallback( + (value: boolean) => { + const newValue = value ? CURRENTS.ONLY_CURRENTS : CURRENTS.ALL; + onChange(newValue); + }, + [onChange] + ); + + return ( +
+ + {translate('yes')} + +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/Search.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/Search.tsx index 198317542dc..bede447ef59 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/Search.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/Search.tsx @@ -102,29 +102,49 @@ export default class Search extends React.PureComponent {
  • -
    - {translate('status')} -
    - +
    + + +
  • {types.length > 1 && (
  • -
    - {translate('type')} -
    - +
    + + +
  • )} {!component && (
  • -
    - {translate('background_tasks.currents_filter.ONLY_CURRENTS')} -
    - +
    + + +
  • )}
  • -
    {translate('date')}
    void; } -export default class StatusFilter extends React.PureComponent { - handleChange = ({ value }: BasicSelectOption) => { - this.props.onChange(value); - }; +export default function StatusFilter(props: StatusFilterProps) { + const { id, value, onChange } = props; - render() { - const options: BasicSelectOption[] = [ - { value: STATUSES.ALL, label: translate('background_task.status.ALL') }, - { - value: STATUSES.ALL_EXCEPT_PENDING, - label: translate('background_task.status.ALL_EXCEPT_PENDING') - }, - { value: TaskStatuses.Pending, label: translate('background_task.status.PENDING') }, - { value: TaskStatuses.InProgress, label: translate('background_task.status.IN_PROGRESS') }, - { value: TaskStatuses.Success, label: translate('background_task.status.SUCCESS') }, - { value: TaskStatuses.Failed, label: translate('background_task.status.FAILED') }, - { value: TaskStatuses.Canceled, label: translate('background_task.status.CANCELED') } - ]; + const options: BasicSelectOption[] = [ + { value: STATUSES.ALL, label: translate('background_task.status.ALL') }, + { + value: STATUSES.ALL_EXCEPT_PENDING, + label: translate('background_task.status.ALL_EXCEPT_PENDING') + }, + { value: TaskStatuses.Pending, label: translate('background_task.status.PENDING') }, + { value: TaskStatuses.InProgress, label: translate('background_task.status.IN_PROGRESS') }, + { value: TaskStatuses.Success, label: translate('background_task.status.SUCCESS') }, + { value: TaskStatuses.Failed, label: translate('background_task.status.FAILED') }, + { value: TaskStatuses.Canceled, label: translate('background_task.status.CANCELED') } + ]; - return ( - o.value === value)} + isSearchable={false} + /> + ); } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.tsx index b84b2150539..4ef1522f76d 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TypesFilter.tsx @@ -24,6 +24,7 @@ import { ALL_TYPES } from '../constants'; interface Props { value: string; + id: string; onChange: Function; types: string[]; } @@ -34,7 +35,7 @@ export default class TypesFilter extends React.PureComponent { }; render() { - const { value, types } = this.props; + const { value, types, id } = this.props; const options = types.map(t => { return { value: t, @@ -51,6 +52,7 @@ export default class TypesFilter extends React.PureComponent { o.value === category)} + /> + + )} + + + ); +} diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx deleted file mode 100644 index 57f22d99298..00000000000 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityPageHeader.tsx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * 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 Select from '../../../components/controls/Select'; -import { translate } from '../../../helpers/l10n'; -import { Component } from '../../../types/types'; -import { APPLICATION_EVENT_TYPES, EVENT_TYPES, Query } from '../utils'; -import ProjectActivityDateInput from './ProjectActivityDateInput'; - -interface Props { - category?: string; - from?: Date; - project: Pick; - to?: Date; - updateQuery: (changes: Partial) => void; -} - -export default class ProjectActivityPageHeader extends React.PureComponent { - handleCategoryChange = (option: { value: string } | null) => - this.props.updateQuery({ category: option ? option.value : '' }); - - render() { - const isApp = this.props.project.qualifier === 'APP'; - const eventTypes = isApp ? APPLICATION_EVENT_TYPES : EVENT_TYPES; - const options = eventTypes.map(category => ({ - label: translate('event.category', category), - value: category - })); - - return ( -
    - {!['VW', 'SVW'].includes(this.props.project.qualifier) && ( - + + + +`; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityPageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityPageHeader-test.tsx.snap deleted file mode 100644 index 5659e62e451..00000000000 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityPageHeader-test.tsx.snap +++ /dev/null @@ -1,40 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly the list of series 1`] = ` -
    -