From c2858bb2ddc16be6c94871693c26d9b1c2017ef0 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 7 Dec 2018 10:49:16 +0100 Subject: [PATCH] apply feedback on drop of modules (#1036) --- .../components/MeasureContent.tsx | 4 +- .../drilldown/FilesView.tsx | 2 +- .../drilldown/TreeMapView.tsx | 3 +- .../js/apps/issues/sidebar/ModuleFacet.tsx | 112 ------------------ .../main/js/apps/issues/sidebar/Sidebar.tsx | 11 -- .../__snapshots__/Sidebar-test.tsx.snap | 3 - .../components/charts/ColorGradientLegend.tsx | 6 - .../resources/org/sonar/l10n/core.properties | 6 +- 8 files changed, 7 insertions(+), 140 deletions(-) delete mode 100644 server/sonar-web/src/main/js/apps/issues/sidebar/ModuleFacet.tsx diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx index 4b545348cdd..5edd0539d22 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx @@ -154,17 +154,17 @@ export default class MeasureContent extends React.PureComponent { this.setState({ loadingMoreComponents: true }); getComponentTree(strategy, baseComponent.key, metricKeys, opts).then( r => { - if (metric === this.props.requestedMetric) { + if (metric.key === this.props.requestedMetric.key) { if (this.mounted) { this.setState(state => ({ components: [ ...state.components, ...r.components.map(component => enhanceComponent(component, metric, metrics)) ], + loadingMoreComponents: false, paging: r.paging })); } - this.setState({ loadingMoreComponents: false }); } }, () => { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx index 919bb516797..867ffbe17aa 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx @@ -73,7 +73,7 @@ export default class FilesView extends React.PureComponent { if (this.props.selectedKey !== undefined && prevProps.selectedKey !== this.props.selectedKey) { this.scrollToElement(); } - if (prevProps.metric.key !== this.props.metric.key) { + if (prevProps.metric.key !== this.props.metric.key || prevProps.view !== this.props.view) { this.setState({ showBestMeasures: this.props.defaultShowBestMeasures }); } } diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx index 8993417c32e..deb57ee0584 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx @@ -104,7 +104,7 @@ export default class TreeMapView extends React.PureComponent { getPercentColorScale = (metric: T.Metric) => { const color = scaleLinear().domain([0, 25, 50, 75, 100]); - color.range(metric.direction === 1 ? [...COLORS].reverse() : COLORS); + color.range(metric.higherValuesAreBetter ? [...COLORS].reverse() : COLORS); return color; }; @@ -166,7 +166,6 @@ export default class TreeMapView extends React.PureComponent { className="measure-details-treemap-legend" colorNA={theme.secondFontColor} colorScale={colorScale} - direction={metric.direction} height={20} width={200} /> diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/ModuleFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/ModuleFacet.tsx deleted file mode 100644 index 54f4ad07233..00000000000 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/ModuleFacet.tsx +++ /dev/null @@ -1,112 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * 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 { omit } from 'lodash'; -import { Query, ReferencedComponent, Facet } from '../utils'; -import QualifierIcon from '../../../components/icons-components/QualifierIcon'; -import { translate } from '../../../helpers/l10n'; -import ListStyleFacet from '../../../components/facet/ListStyleFacet'; -import { TreeComponent, getTree } from '../../../api/components'; -import { highlightTerm } from '../../../helpers/search'; - -interface Props { - componentKey: string; - fetching: boolean; - loadSearchResultCount: (property: string, changes: Partial) => Promise; - modules: string[]; - onChange: (changes: Partial) => void; - onToggle: (property: string) => void; - open: boolean; - query: Query; - referencedComponents: { [componentKey: string]: ReferencedComponent }; - stats: { [x: string]: number } | undefined; -} - -export default class ModuleFacet extends React.PureComponent { - getModuleName = (module: string) => { - const { referencedComponents } = this.props; - return referencedComponents[module] ? referencedComponents[module].name : module; - }; - - getSearchResultKey = (module: TreeComponent) => { - return module.id; - }; - - getSearchResultText = (module: TreeComponent) => { - return module.name; - }; - - handleSearch = (query: string, page: number) => { - return getTree({ - component: this.props.componentKey, - q: query, - qualifiers: 'BRC', - p: page, - ps: 30 - }).then(({ components, paging }) => ({ paging, results: components })); - }; - - loadSearchResultCount = (modules: TreeComponent[]) => { - return this.props.loadSearchResultCount('modules', { - modules: modules.map(module => module.id) - }); - }; - - renderModule = (module: React.ReactNode) => ( - <> - - {module} - - ); - - renderFacetItem = (module: string) => { - const name = this.getModuleName(module); - return this.renderModule(name); - }; - - renderSearchResult = (module: TreeComponent, term: string) => { - return this.renderModule(highlightTerm(module.name, term)); - }; - - render() { - return ( - - facetHeader={translate('issues.facet.modules')} - fetching={this.props.fetching} - getFacetItemText={this.getModuleName} - getSearchResultKey={this.getSearchResultKey} - getSearchResultText={this.getSearchResultText} - loadSearchResultCount={this.loadSearchResultCount} - minSearchLength={3} - onChange={this.props.onChange} - onSearch={this.handleSearch} - onToggle={this.props.onToggle} - open={this.props.open} - property="modules" - query={omit(this.props.query, 'modules')} - renderFacetItem={this.renderFacetItem} - renderSearchResult={this.renderSearchResult} - searchPlaceholder={translate('search.search_for_modules')} - stats={this.props.stats} - values={this.props.modules} - /> - ); - } -} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx index 7ff8a6fe4ca..f401c1ee99c 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx @@ -24,7 +24,6 @@ import CreationDateFacet from './CreationDateFacet'; import DirectoryFacet from './DirectoryFacet'; import FileFacet from './FileFacet'; import LanguageFacet from './LanguageFacet'; -import ModuleFacet from './ModuleFacet'; import ProjectFacet from './ProjectFacet'; import ResolutionFacet from './ResolutionFacet'; import RuleFacet from './RuleFacet'; @@ -77,16 +76,6 @@ export default class Sidebar extends React.PureComponent { }; return ( <> - {component.qualifier !== 'DIR' && ( - - )} {component.qualifier !== 'DIR' && ( // used for LEVEL type | ScaleLinear; // used for RATING or PERCENT type - direction?: number; height: number; padding?: [number, number, number, number]; width: number; @@ -39,16 +38,11 @@ export default function ColorGradientLegend({ className, colorScale, colorNA, - direction, padding = [12, 24, 0, 0], height, width }: Props) { const colorRange: Array = colorScale.range(); - if (direction === 1) { - colorRange.reverse(); - } - const colorDomain: Array = colorScale.domain(); const lastColorIdx = colorRange.length - 1; const lastDomainIdx = colorDomain.length - 1; 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 18b2eb9d7d8..973eba40af4 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -929,7 +929,7 @@ property.sonar.branch.longLivedBranches.regex.description=Regular expression use #------------------------------------------------------------------------------ search.shortcut_hint=Hint: Press {shortcut} from anywhere to open this search bar. search.show_more.hint=Press {0} to display -search.placeholder=Search for projects, sub-projects and files... +search.placeholder=Search for projects and files... search.search_for_projects=Search for projects... search.search_for_users=Search for users... search.search_for_users_or_groups=Search for users or groups... @@ -1210,7 +1210,7 @@ quality_gates.projects=Projects quality_gates.add_condition=Add Condition quality_gates.update_condition=Update Condition quality_gates.no_conditions=No Conditions -quality_gates.introduction=Only project measures are checked against thresholds. Sub-projects, directories and files are ignored. +quality_gates.introduction=Only project measures are checked against thresholds. Directories and files are ignored. quality_gates.health_icons=Project health icons represent: quality_gates.projects_for_default=Every project not specifically associated to a quality gate will be associated to this one by default. quality_gates.projects.with=With @@ -2536,7 +2536,7 @@ documentation.on_this_page=On this page # #------------------------------------------------------------------------------ code.open_component_page=Open Component's Page -code.search_placeholder=Search for files and sub-projects... +code.search_placeholder=Search for files... code.search_placeholder.portfolio=Search for projects and sub-portfolios... -- 2.39.5