]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11296 Display language name after bulk activation of rules
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 24 Sep 2018 13:00:05 +0000 (15:00 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 25 Sep 2018 18:20:59 +0000 (20:20 +0200)
12 files changed:
server/sonar-web/src/main/js/api/languages.ts
server/sonar-web/src/main/js/app/types.ts
server/sonar-web/src/main/js/apps/coding-rules/components/App.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/BulkChange.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/BulkChangeModal.tsx
server/sonar-web/src/main/js/apps/overview/meta/MetaQualityProfiles.tsx
server/sonar-web/src/main/js/apps/projects/components/ProjectCardLanguages.tsx
server/sonar-web/src/main/js/apps/projects/filters/LanguagesFilter.tsx
server/sonar-web/src/main/js/apps/quality-profiles/components/App.tsx
server/sonar-web/src/main/js/components/charts/LanguageDistribution.tsx
server/sonar-web/src/main/js/store/languages.ts
server/sonar-web/src/main/js/store/rootReducer.ts

index c49c1290672a6c3667beb8b76c141131acfb65dc..ebf3efdb631ccdf74dfd6c963965d9343845f437 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { getJSON } from '../helpers/request';
+import { Language } from '../app/types';
 import throwGlobalError from '../app/utils/throwGlobalError';
 
-export interface Language {
-  key: string;
-  name: string;
-}
-
 export function getLanguages(): Promise<Language[]> {
   return getJSON('/api/languages/list').then(r => r.languages, throwGlobalError);
 }
index 4df5d148def3db2de6978a82bd083d13f5da4b9b..c706a55e75b492c3714f96f3df44b953ed67f3e8 100644 (file)
@@ -343,6 +343,15 @@ export enum IssueType {
   Hotspot = 'SECURITY_HOTSPOT'
 }
 
+export interface Language {
+  key: string;
+  name: string;
+}
+
+export interface Languages {
+  [key: string]: Language;
+}
+
 export interface LightComponent {
   key: string;
   organization: string;
index 685d05839402c06aefff9221b8d3fbfc775b1da7..e91c19c790b080c8b1c5d0a4a6a1417f1ac3aa44 100644 (file)
@@ -51,11 +51,23 @@ import FiltersHeader from '../../../components/common/FiltersHeader';
 import SearchBox from '../../../components/controls/SearchBox';
 import { searchRules, getRulesApp } from '../../../api/rules';
 import { searchQualityProfiles, Profile } from '../../../api/quality-profiles';
-import { getCurrentUser, getMyOrganizations, Store } from '../../../store/rootReducer';
+import {
+  getCurrentUser,
+  getLanguages,
+  getMyOrganizations,
+  Store
+} from '../../../store/rootReducer';
 import { translate } from '../../../helpers/l10n';
 import { RawQuery } from '../../../helpers/query';
 import { scrollToElement } from '../../../helpers/scrolling';
-import { Paging, Rule, RuleActivation, Organization, CurrentUser } from '../../../app/types';
+import {
+  CurrentUser,
+  Languages,
+  Paging,
+  Organization,
+  Rule,
+  RuleActivation
+} from '../../../app/types';
 import '../../../components/search-navigator.css';
 import '../styles.css';
 import { hasPrivateAccess } from '../../../helpers/organizations';
@@ -65,6 +77,7 @@ const LIMIT_BEFORE_LOAD_MORE = 5;
 
 interface StateToProps {
   currentUser: CurrentUser;
+  languages: Languages;
   userOrganizations: Organization[];
 }
 
@@ -544,6 +557,7 @@ export class App extends React.PureComponent<Props, State> {
                   ) : (
                     this.state.paging && (
                       <BulkChange
+                        languages={this.props.languages}
                         organization={organization}
                         query={this.state.query}
                         referencedProfiles={this.state.referencedProfiles}
@@ -636,6 +650,7 @@ function parseFacets(rawFacets: { property: string; values: { count: number; val
 
 const mapStateToProps = (state: Store) => ({
   currentUser: getCurrentUser(state),
+  languages: getLanguages(state),
   userOrganizations: getMyOrganizations(state)
 });
 
index 6b47b2d704dde38393f825b1ef68f6f87b47b890..80a997a3f168f71bbc51297c8589583246e78acf 100644 (file)
@@ -24,8 +24,10 @@ import { Profile } from '../../../api/quality-profiles';
 import Dropdown from '../../../components/controls/Dropdown';
 import { Button } from '../../../components/ui/buttons';
 import { translate } from '../../../helpers/l10n';
+import { Languages } from '../../../app/types';
 
 interface Props {
+  languages: Languages;
   organization: string | undefined;
   query: Query;
   referencedProfiles: { [profile: string]: Profile };
@@ -129,6 +131,7 @@ export default class BulkChange extends React.PureComponent<Props, State> {
           this.state.action && (
             <BulkChangeModal
               action={this.state.action}
+              languages={this.props.languages}
               onClose={this.closeModal}
               organization={this.props.organization}
               profile={this.state.profile}
index 948d37436935f1f541644fee2fee1185fde727db..1840cc0ec90f29a39362b9e40124d30b7cd0d456 100644 (file)
@@ -26,14 +26,16 @@ import Select from '../../../components/controls/Select';
 import { translate, translateWithParameters } from '../../../helpers/l10n';
 import { formatMeasure } from '../../../helpers/measures';
 import { SubmitButton, ResetButtonLink } from '../../../components/ui/buttons';
+import { Languages } from '../../../app/types';
 
 interface Props {
   action: string;
+  languages: Languages;
   onClose: () => void;
   organization: string | undefined;
-  referencedProfiles: { [profile: string]: Profile };
   profile?: Profile;
   query: Query;
+  referencedProfiles: { [profile: string]: Profile };
   total: number;
 }
 
@@ -148,6 +150,10 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> {
     if (!profile) {
       return null;
     }
+    const { languages } = this.props;
+    const language = languages[profile.language]
+      ? languages[profile.language].name
+      : profile.language;
     return (
       <div
         className={classNames('alert', {
@@ -159,14 +165,14 @@ export default class BulkChangeModal extends React.PureComponent<Props, State> {
           ? translateWithParameters(
               'coding_rules.bulk_change.warning',
               profile.name,
-              profile.language,
+              language,
               result.succeeded,
               result.failed
             )
           : translateWithParameters(
               'coding_rules.bulk_change.success',
               profile.name,
-              profile.language,
+              language,
               result.succeeded
             )}
       </div>
index eb8f8fc45f0b2a33f76244aaee4b848b05f04ff3..06452143c3337669a87ace94f05f136cc9df1993 100644 (file)
@@ -26,10 +26,10 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
 import { getQualityProfileUrl } from '../../../helpers/urls';
 import { searchRules } from '../../../api/rules';
 import { getLanguages, Store } from '../../../store/rootReducer';
-import { ComponentQualityProfile } from '../../../app/types';
+import { ComponentQualityProfile, Languages } from '../../../app/types';
 
 interface StateProps {
-  languages: { [key: string]: { name: string } };
+  languages: Languages;
 }
 
 interface OwnProps {
index 1fd92c29037cd7e91f21c4f5a08e1d061def3edf..507c75ef39ce019d8283baae748d0a7c23451ef6 100644 (file)
@@ -21,7 +21,7 @@ import * as React from 'react';
 import { sortBy } from 'lodash';
 import Tooltip from '../../../components/controls/Tooltip';
 import { translate } from '../../../helpers/l10n';
-import { Languages } from '../../../store/languages';
+import { Languages } from '../../../app/types';
 
 interface Props {
   distribution?: string;
index 33229e381b7b531ab698c664762c9d8ab480b68d..7d875b5ae853b11b2a31f960d034ba70ca5484ca 100644 (file)
@@ -23,10 +23,11 @@ import Filter from './Filter';
 import FilterHeader from './FilterHeader';
 import SearchableFilterFooter from './SearchableFilterFooter';
 import SearchableFilterOption from './SearchableFilterOption';
-import { getLanguageByKey, Languages } from '../../../store/languages';
+import { getLanguageByKey } from '../../../store/languages';
 import { translate } from '../../../helpers/l10n';
 import { Facet } from '../types';
 import { RawQuery } from '../../../helpers/query';
+import { Languages } from '../../../app/types';
 
 interface Props {
   facet?: Facet;
index 5fa5abf66427ea4bb617887f6076d931ebc8068f..dc123ff9963954aa1a9367afb110ab278cdfdbf2 100644 (file)
@@ -24,7 +24,7 @@ import { sortProfiles } from '../utils';
 import { Exporter, Profile } from '../types';
 import OrganizationHelmet from '../../../components/common/OrganizationHelmet';
 import { translate } from '../../../helpers/l10n';
-import { Languages } from '../../../store/languages';
+import { Languages } from '../../../app/types';
 import '../styles.css';
 
 interface Props {
index 9c4fbe34a9ab5d79cfa699efcf926ba268b5d74a..1ff1acac6c641810e3c1d9da8b574e8a5a80d64f 100644 (file)
@@ -22,7 +22,7 @@ import { sortBy } from 'lodash';
 import Histogram from './Histogram';
 import { formatMeasure } from '../../helpers/measures';
 import { translate } from '../../helpers/l10n';
-import { Languages } from '../../store/languages';
+import { Languages } from '../../app/types';
 
 interface Props {
   alignTicks?: boolean;
index 2cc95fe3006f7596a2568a6da275a0714e2d8f17..e80c9d2cdbcf1e5485a3401952b565f45f0afbf4 100644 (file)
@@ -19,6 +19,7 @@
  */
 import { keyBy } from 'lodash';
 import { ActionType } from './utils/actions';
+import { Languages } from '../app/types';
 
 export function receiveLanguages(languages: Array<{ key: string; name: string }>) {
   return { type: 'RECEIVE_LANGUAGES', languages };
@@ -26,10 +27,6 @@ export function receiveLanguages(languages: Array<{ key: string; name: string }>
 
 type Action = ActionType<typeof receiveLanguages, 'RECEIVE_LANGUAGES'>;
 
-export interface Languages {
-  [key: string]: { key: string; name: string };
-}
-
 export default function(state: Languages = {}, action: Action): Languages {
   if (action.type === 'RECEIVE_LANGUAGES') {
     return keyBy(action.languages, 'key');
index 8dfc49d857f1d52ed43ef598c2ebc1eca529d19d..6a913690bdb6bb6cde750ce7021e823d4bb5c7b0 100644 (file)
@@ -24,7 +24,7 @@ import languages, * as fromLanguages from './languages';
 import metrics, * as fromMetrics from './metrics';
 import organizations, * as fromOrganizations from './organizations';
 import users, * as fromUsers from './users';
-import { AppState } from '../app/types';
+import { AppState, Languages } from '../app/types';
 import permissionsApp, * as fromPermissionsApp from '../apps/permissions/shared/store/rootReducer';
 import projectAdminApp, * as fromProjectAdminApp from '../apps/project-admin/store/rootReducer';
 import settingsApp, * as fromSettingsApp from '../apps/settings/store/rootReducer';
@@ -32,7 +32,7 @@ import settingsApp, * as fromSettingsApp from '../apps/settings/store/rootReduce
 export type Store = {
   appState: AppState;
   globalMessages: fromGlobalMessages.State;
-  languages: fromLanguages.Languages;
+  languages: Languages;
   metrics: fromMetrics.State;
   organizations: fromOrganizations.State;
   users: fromUsers.State;