From: Wouter Admiraal Date: Fri, 4 Jan 2019 16:51:43 +0000 (+0100) Subject: SONAR-10487 Improve UX of filter option in Quality Profiles page X-Git-Tag: 7.6~129 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3e64f2c04ac348c8b00471032485b2ea694281fb;p=sonarqube.git SONAR-10487 Improve UX of filter option in Quality Profiles page --- diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.tsx index c6bae822049..279ca353277 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/home/ProfilesListHeader.tsx @@ -18,62 +18,56 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { IndexLink } from 'react-router'; -import { translate, translateWithParameters } from '../../../helpers/l10n'; +import { Option } from 'react-select'; +import { translate } from '../../../helpers/l10n'; import { getProfilesPath, getProfilesForLanguagePath } from '../utils'; -import Dropdown from '../../../components/controls/Dropdown'; -import DropdownIcon from '../../../components/icons-components/DropdownIcon'; +import Select from '../../../components/controls/Select'; +import { withRouter, Router } from '../../../components/hoc/withRouter'; interface Props { currentFilter?: string; languages: Array<{ key: string; name: string }>; organization: string | null; + router: Pick; } -export default function ProfilesListHeader({ currentFilter, languages, organization }: Props) { - if (languages.length < 2) { - return null; - } +export class ProfilesListHeader extends React.PureComponent { + handleChange = (option: { value: string } | null) => { + const { organization, router } = this.props; - const currentLanguage = currentFilter && languages.find(l => l.key === currentFilter); + router.replace( + !option + ? getProfilesPath(organization) + : getProfilesForLanguagePath(option.value, organization) + ); + }; - // if unknown language, then - if (currentFilter && !currentLanguage) { - return null; - } + render() { + const { currentFilter, languages } = this.props; + if (languages.length < 2) { + return null; + } + + const options: Option[] = languages.map(language => ({ + label: language.name, + value: language.key + })); - const label = currentLanguage - ? translateWithParameters('quality_profiles.x_Profiles', currentLanguage.name) - : translate('quality_profiles.all_profiles'); + const currentLanguage = currentFilter && options.find(l => l.value === currentFilter); - return ( -
- -
  • - - {translate('quality_profiles.all_profiles')} - -
  • - {languages.map(language => ( -
  • - - {language.name} - -
  • - ))} - - }> - - {label} - - -
    -
    - ); + return ( +
    + {translate('quality_profiles.filter_by')}: + +
    +`; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 425c67656a9..e527a0e54d6 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1142,6 +1142,7 @@ projects_management.project_has_been_successfully_created=Project {project} has quality_profiles.new_profile=New Profile quality_profiles.compare_with=Compare with +quality_profiles.filter_by=Filter profiles by quality_profiles.restore_profile=Restore Profile quality_profiles.restore_profile.success={1} rule(s) restored in profile "{0}" quality_profiles.restore_profile.warning={1} rule(s) restored, {2} rule(s) ignored in profile "{0}"