aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx1
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacetFooter.tsx15
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacetFooter.tsx15
4 files changed, 27 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx
index 057d51961f8..c883f930557 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacet.tsx
@@ -50,6 +50,7 @@ class LanguageFacet extends React.PureComponent<Props> {
<LanguageFacetFooter
onSelect={this.handleSelect}
referencedLanguages={this.props.referencedLanguages}
+ selected={Object.keys(this.props.stats)}
/>
);
};
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacetFooter.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacetFooter.tsx
index 34b27b53aeb..97d247d1363 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacetFooter.tsx
+++ b/server/sonar-web/src/main/js/apps/coding-rules/components/LanguageFacetFooter.tsx
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { difference } from 'lodash';
import Select from '../../../components/controls/Select';
import { translate } from '../../../helpers/l10n';
@@ -26,17 +27,25 @@ type Option = { label: string; value: string };
interface Props {
referencedLanguages: { [language: string]: { key: string; name: string } };
onSelect: (value: string) => void;
+ selected: string[];
}
export default class LanguageFacetFooter extends React.PureComponent<Props> {
handleChange = (option: Option) => this.props.onSelect(option.value);
render() {
- const options = Object.values(this.props.referencedLanguages).map(language => ({
- label: language.name,
- value: language.key
+ const options = difference(
+ Object.keys(this.props.referencedLanguages),
+ this.props.selected
+ ).map(key => ({
+ label: this.props.referencedLanguages[key].name,
+ value: key
}));
+ if (options.length === 0) {
+ return null;
+ }
+
return (
<div className="search-navigator-facet-footer">
<Select
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx
index 95d7cae343a..3c9d5f0bfab 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacet.tsx
@@ -107,7 +107,9 @@ export default class LanguageFacet extends React.PureComponent<Props> {
return null;
}
- return <LanguageFacetFooter onSelect={this.handleSelect} />;
+ return (
+ <LanguageFacetFooter onSelect={this.handleSelect} selected={Object.keys(this.props.stats)} />
+ );
}
render() {
diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacetFooter.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacetFooter.tsx
index a218c09cc80..ebc49ff62c8 100644
--- a/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacetFooter.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/sidebar/LanguageFacetFooter.tsx
@@ -19,6 +19,7 @@
*/
import * as React from 'react';
import { connect } from 'react-redux';
+import { differenceWith } from 'lodash';
import Select from '../../../components/controls/Select';
import { translate } from '../../../helpers/l10n';
import { getLanguages } from '../../../store/rootReducer';
@@ -26,6 +27,7 @@ import { getLanguages } from '../../../store/rootReducer';
interface Props {
languages: Array<{ key: string; name: string }>;
onSelect: (value: string) => void;
+ selected: string[];
}
class LanguageFacetFooter extends React.PureComponent<Props> {
@@ -34,10 +36,15 @@ class LanguageFacetFooter extends React.PureComponent<Props> {
};
render() {
- const options = this.props.languages.map(language => ({
- label: language.name,
- value: language.key
- }));
+ const options = differenceWith(
+ this.props.languages,
+ this.props.selected,
+ (language, key) => language.key === key
+ ).map(language => ({ label: language.name, value: language.key }));
+
+ if (options.length === 0) {
+ return null;
+ }
return (
<div className="search-navigator-facet-footer">