* 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);
}
Hotspot = 'SECURITY_HOTSPOT'
}
+export interface Language {
+ key: string;
+ name: string;
+}
+
+export interface Languages {
+ [key: string]: Language;
+}
+
export interface LightComponent {
key: string;
organization: string;
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';
interface StateToProps {
currentUser: CurrentUser;
+ languages: Languages;
userOrganizations: Organization[];
}
) : (
this.state.paging && (
<BulkChange
+ languages={this.props.languages}
organization={organization}
query={this.state.query}
referencedProfiles={this.state.referencedProfiles}
const mapStateToProps = (state: Store) => ({
currentUser: getCurrentUser(state),
+ languages: getLanguages(state),
userOrganizations: getMyOrganizations(state)
});
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 };
this.state.action && (
<BulkChangeModal
action={this.state.action}
+ languages={this.props.languages}
onClose={this.closeModal}
organization={this.props.organization}
profile={this.state.profile}
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;
}
if (!profile) {
return null;
}
+ const { languages } = this.props;
+ const language = languages[profile.language]
+ ? languages[profile.language].name
+ : profile.language;
return (
<div
className={classNames('alert', {
? 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>
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 {
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;
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;
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 {
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;
*/
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 };
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');
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';
export type Store = {
appState: AppState;
globalMessages: fromGlobalMessages.State;
- languages: fromLanguages.Languages;
+ languages: Languages;
metrics: fromMetrics.State;
organizations: fromOrganizations.State;
users: fromUsers.State;