]> source.dussan.org Git - sonarqube.git/commitdiff
apply feedback on drop of modules (#1036)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 7 Dec 2018 09:49:16 +0000 (10:49 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Jan 2019 08:43:07 +0000 (09:43 +0100)
server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx
server/sonar-web/src/main/js/apps/component-measures/drilldown/FilesView.tsx
server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/ModuleFacet.tsx [deleted file]
server/sonar-web/src/main/js/apps/issues/sidebar/Sidebar.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/Sidebar-test.tsx.snap
server/sonar-web/src/main/js/components/charts/ColorGradientLegend.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 4b545348cddd6524ebc119479822b19633b67fe4..5edd0539d22c8a68a5d525c8c82a34cd1a605e64 100644 (file)
@@ -154,17 +154,17 @@ export default class MeasureContent extends React.PureComponent<Props, State> {
     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 });
         }
       },
       () => {
index 919bb516797f28f2c8ad415094f767dc8fbb729c..867ffbe17aa9adc26f698f1635aa73ebfc37ba64 100644 (file)
@@ -73,7 +73,7 @@ export default class FilesView extends React.PureComponent<Props, State> {
     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 });
     }
   }
index 8993417c32e6e2b00f900182fb294a5b84afd3f2..deb57ee05842d8bf227977bd6b3aa9fdd5192310 100644 (file)
@@ -104,7 +104,7 @@ export default class TreeMapView extends React.PureComponent<Props, State> {
 
   getPercentColorScale = (metric: T.Metric) => {
     const color = scaleLinear<string, string>().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<Props, State> {
         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 (file)
index 54f4ad0..0000000
+++ /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<Query>) => Promise<Facet>;
-  modules: string[];
-  onChange: (changes: Partial<Query>) => 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<Props> {
-  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) => (
-    <>
-      <QualifierIcon className="little-spacer-right" qualifier="BRC" />
-      {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 (
-      <ListStyleFacet<TreeComponent>
-        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}
-      />
-    );
-  }
-}
index 7ff8a6fe4ca6e0d049dfe82db2f2ff0a1cc54138..f401c1ee99ca88e04a42135f0cb0141af2532af2 100644 (file)
@@ -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<Props> {
     };
     return (
       <>
-        {component.qualifier !== 'DIR' && (
-          <ModuleFacet
-            fetching={loadingFacets.modules === true}
-            modules={query.modules}
-            open={!!openFacets.modules}
-            referencedComponents={this.props.referencedComponentsById}
-            stats={facets.modules}
-            {...commonProps}
-          />
-        )}
         {component.qualifier !== 'DIR' && (
           <DirectoryFacet
             directories={query.directories}
index d12f303876010b6629acf0761c2d110c8dec7fae..1eafde6ef860a5e3b8b9883cda4906b179be0fff 100644 (file)
@@ -12,7 +12,6 @@ Array [
   "StandardFacet",
   "TagFacet",
   "ProjectFacet",
-  "ModuleFacet",
   "DirectoryFacet",
   "FileFacet",
   "AssigneeFacet",
@@ -64,7 +63,6 @@ Array [
   "RuleFacet",
   "StandardFacet",
   "TagFacet",
-  "ModuleFacet",
   "DirectoryFacet",
   "FileFacet",
   "AssigneeFacet",
@@ -83,7 +81,6 @@ Array [
   "RuleFacet",
   "StandardFacet",
   "TagFacet",
-  "ModuleFacet",
   "DirectoryFacet",
   "FileFacet",
   "AssigneeFacet",
index 31f359ddcc0446817b705cfb70e99530015ac1ee..921976e6b6ff38c964ff3099cd29adc99406fae9 100644 (file)
@@ -27,7 +27,6 @@ interface Props {
   colorScale:
     | ScaleOrdinal<string, string> // used for LEVEL type
     | ScaleLinear<string, string | number>; // 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<string | number> = colorScale.range();
-  if (direction === 1) {
-    colorRange.reverse();
-  }
-
   const colorDomain: Array<string | number> = colorScale.domain();
   const lastColorIdx = colorRange.length - 1;
   const lastDomainIdx = colorDomain.length - 1;
index 18b2eb9d7d8244f9871266e46fb5fed93d461fac..973eba40af402bfd68b0bcbe7ea0c31acec2429d 100644 (file)
@@ -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...