From: Stas Vilchik Date: Tue, 8 Dec 2015 16:55:39 +0000 (+0100) Subject: improve code quality X-Git-Tag: 5.3-RC2~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=120dc80f1074dbd533e05b33d5a7fd797702e701;p=sonarqube.git improve code quality --- diff --git a/server/sonar-web/.eslintrc b/server/sonar-web/.eslintrc index 19e2098c50f..77cfb1f6edd 100644 --- a/server/sonar-web/.eslintrc +++ b/server/sonar-web/.eslintrc @@ -14,21 +14,17 @@ }, "globals": { - "define": true, - "require": true, - "numeral": true, "key": true, "d3": true, - "baseUrl": true, - "t": true, - "tp": true + "baseUrl": true }, "parser": "babel-eslint", "plugins": [ "react", - "mocha" + "mocha", + "import" ], "rules": { @@ -74,6 +70,12 @@ "react/prop-types": 0, "react/react-in-jsx-scope": 2, "react/self-closing-comp": 2, - "react/sort-comp": 1 + "react/sort-comp": 1, + + "import/no-unresolved": 2, + "import/named": 2, + "import/export": 2, + "import/no-duplicates": 2, + "import/imports-first": 2 } } diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 38d0e420486..04d8169b95a 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -19,6 +19,7 @@ "d3": "3.5.6", "del": "2.0.2", "eslint": "^1.10.3", + "eslint-plugin-import": "^0.11.0", "eslint-plugin-mocha": "^1.1.0", "eslint-plugin-react": "^3.11.3", "event-stream": "3.3.1", diff --git a/server/sonar-web/src/main/js/apps/account/change-password-view.js b/server/sonar-web/src/main/js/apps/account/change-password-view.js index 6bd5d992b21..4df1c081161 100644 --- a/server/sonar-web/src/main/js/apps/account/change-password-view.js +++ b/server/sonar-web/src/main/js/apps/account/change-password-view.js @@ -10,7 +10,7 @@ export default ModalForm.extend({ if (this.checkPasswords()) { this.sendRequest(); } else { - this.showErrors([{ msg: t('user.password_doesnt_match_confirmation') }]); + this.showErrors([{ msg: window.t('user.password_doesnt_match_confirmation') }]); } }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/app.js b/server/sonar-web/src/main/js/apps/coding-rules/app.js index 61089511594..feb040c3562 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/app.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/app.js @@ -63,7 +63,7 @@ var App = new Marionette.Application(), App.manualRepository = function () { return { key: 'manual', - name: t('coding_rules.manual_rule'), + name: window.t('coding_rules.manual_rule'), language: 'none' }; }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js b/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js index d816c21c219..453aa8fd107 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js @@ -15,14 +15,14 @@ export default ModalFormView.extend({ showSuccessMessage: function (profile, succeeded) { var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }), profileName = profileBase != null ? profileBase.name : profile, - message = tp('coding_rules.bulk_change.success', profileName, profileBase.language, succeeded); + message = window.tp('coding_rules.bulk_change.success', profileName, profileBase.language, succeeded); this.ui.messagesContainer.append('
' + message + '
'); }, showWarnMessage: function (profile, succeeded, failed) { var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }), profileName = profileBase != null ? profileBase.name : profile, - message = tp('coding_rules.bulk_change.warning', profileName, profileBase.language, succeeded, failed); + message = window.tp('coding_rules.bulk_change.warning', profileName, profileBase.language, succeeded, failed); this.ui.messagesContainer.append('
' + message + '
'); }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js index 2062e292b99..2ab853c763a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js @@ -26,7 +26,7 @@ export default BaseFacet.extend({ forbid: function () { BaseFacet.prototype.forbid.apply(this, arguments); - this.$el.prop('title', t('coding_rules.filters.active_severity.inactive')); + this.$el.prop('title', window.t('coding_rules.filters.active_severity.inactive')); }, allow: function () { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js index 9b2e01ef70a..bf3739cf70c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js @@ -22,17 +22,17 @@ export default BaseFacet.extend({ prepareSearch: function () { this.$('.js-custom-value').select2({ - placeholder: t('search_verb'), + placeholder: window.t('search_verb'), minimumInputLength: 1, allowClear: false, formatNoMatches: function () { - return t('select2.noMatches'); + return window.t('select2.noMatches'); }, formatSearching: function () { - return t('select2.searching'); + return window.t('select2.searching'); }, formatInputTooShort: function () { - return tp('select2.tooShort', 1); + return window.tp('select2.tooShort', 1); }, width: '100%', ajax: this.prepareAjaxSearch() diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js index d72f47e4584..490498a13cb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js @@ -30,7 +30,7 @@ export default BaseFacet.extend({ forbid: function () { BaseFacet.prototype.forbid.apply(this, arguments); - this.$el.prop('title', t('coding_rules.filters.inheritance.inactive')); + this.$el.prop('title', window.t('coding_rules.filters.inheritance.inactive')); }, allow: function () { @@ -42,7 +42,7 @@ export default BaseFacet.extend({ var values = ['NONE', 'INHERITED', 'OVERRIDES']; return values.map(function (key) { return { - label: t('coding_rules.filters.inheritance', key.toLowerCase()), + label: window.t('coding_rules.filters.inheritance', key.toLowerCase()), val: key }; }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js index 23b0e41e089..fa453552567 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js @@ -7,7 +7,7 @@ export default BaseFacet.extend({ getValues: function () { var values = this.model.getValues(); var x = values.map(function (value) { - return _.extend(value, { label: t('rules.status', value.val.toLowerCase()) }); + return _.extend(value, { label: window.t('rules.status', value.val.toLowerCase()) }); }); return x; }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js index f8dee5b02cd..87ae705c660 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js @@ -130,8 +130,8 @@ export default Marionette.LayoutView.extend({ var that = this, ruleType = this.model.has('templateKey') ? 'custom' : 'manual'; confirmDialog({ - title: t('delete'), - html: tp('coding_rules.delete.' + ruleType + '.confirm', this.model.get('name')), + title: window.t('delete'), + html: window.tp('coding_rules.delete.' + ruleType + '.confirm', this.model.get('name')), yesHandler: function () { var url = baseUrl + '/api/rules/delete', options = { key: that.model.id }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js index ff0da3c7803..b4712e1c15e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js @@ -153,7 +153,7 @@ export default ModalFormView.extend({ }).fail(function (jqXHR) { if (jqXHR.status === 409) { that.existingRule = jqXHR.responseJSON.rule; - that.showErrors([], [{ msg: t('coding_rules.reactivate.help') }]); + that.showErrors([], [{ msg: window.t('coding_rules.reactivate.help') }]); that.ui.customRuleCreationCreate.addClass('hidden'); that.ui.customRuleCreationReactivate.removeClass('hidden'); } else { @@ -175,7 +175,7 @@ export default ModalFormView.extend({ var statuses = ['READY', 'BETA', 'DEPRECATED'].map(function (status) { return { id: status, - text: t('rules.status', status.toLowerCase()) + text: window.t('rules.status', status.toLowerCase()) }; }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js index 6e7002ba587..791334b4a0f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js @@ -19,8 +19,8 @@ export default Marionette.ItemView.extend({ deleteRule: function () { var that = this; confirmDialog({ - title: t('delete'), - html: t('are_you_sure'), + title: window.t('delete'), + html: window.t('are_you_sure'), yesHandler: function () { var url = baseUrl + '/api/rules/delete', options = { key: that.model.id }; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js index cb0869490d0..dab19f1fb13 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js @@ -99,7 +99,7 @@ export default ModalFormView.extend({ }).fail(function (jqXHR) { if (jqXHR.status === 409) { that.existingRule = jqXHR.responseJSON.rule; - that.showErrors([], [{ msg: t('coding_rules.reactivate.help') }]); + that.showErrors([], [{ msg: window.t('coding_rules.reactivate.help') }]); that.ui.manualRuleCreationCreate.addClass('hidden'); that.ui.manualRuleCreationReactivate.removeClass('hidden'); } else { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js index c1a2bc458e5..9b88e3267ce 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js @@ -64,7 +64,7 @@ export default Marionette.ItemView.extend({ removeExtendedDescription: function () { var that = this; confirmDialog({ - html: t('coding_rules.remove_extended_description.confirm'), + html: window.t('coding_rules.remove_extended_description.confirm'), yesHandler: function () { that.ui.extendDescriptionText.val(''); that.submitExtendDescription(); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js index 1c74fc9dd63..6139044cbf6 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js @@ -50,8 +50,8 @@ export default Marionette.ItemView.extend({ var that = this, ruleKey = this.options.rule.get('key'); confirmDialog({ - title: t('coding_rules.revert_to_parent_definition'), - html: tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name), + title: window.t('coding_rules.revert_to_parent_definition'), + html: window.tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name), yesHandler: function () { return $.ajax({ type: 'POST', @@ -72,8 +72,8 @@ export default Marionette.ItemView.extend({ var that = this, ruleKey = this.options.rule.get('key'); confirmDialog({ - title: t('coding_rules.deactivate'), - html: tp('coding_rules.deactivate.confirm'), + title: window.t('coding_rules.deactivate'), + html: window.tp('coding_rules.deactivate.confirm'), yesHandler: function () { return $.ajax({ type: 'POST', @@ -137,5 +137,3 @@ export default Marionette.ItemView.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-empty-view.js b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-empty-view.js index 6563efc2e3a..5045ff3891d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-empty-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-empty-view.js @@ -4,8 +4,6 @@ export default Marionette.ItemView.extend({ className: 'search-navigator-no-results', template: function () { - return t('coding_rules.no_results'); + return window.t('coding_rules.no_results'); } }); - - diff --git a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js index 5897372020b..05e54964103 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js @@ -62,8 +62,8 @@ export default WorkspaceListItemView.extend(RuleFilterMixin).extend({ ruleKey = this.model.get('key'), activation = this.model.get('activation'); confirmDialog({ - title: t('coding_rules.deactivate'), - html: tp('coding_rules.deactivate.confirm'), + title: window.t('coding_rules.deactivate'), + html: window.tp('coding_rules.deactivate.confirm'), yesHandler: function () { return $.ajax({ type: 'POST', diff --git a/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js index 6567912ab1e..ec9d1a2966e 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/author-facet.js @@ -11,13 +11,13 @@ export default CustomValuesFacet.extend({ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return t('select2.noMatches'); + return window.t('select2.noMatches'); }, formatSearching: function () { - return t('select2.searching'); + return window.t('select2.searching'); }, formatInputTooShort: function () { - return tp('select2.tooShort', 2); + return window.tp('select2.tooShort', 2); }, width: '100%', ajax: { @@ -38,5 +38,3 @@ export default CustomValuesFacet.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/issues/facets/custom-values-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/custom-values-facet.js index bf86b4970fb..e9bb08d5853 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/custom-values-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/custom-values-facet.js @@ -26,13 +26,13 @@ export default BaseFacet.extend({ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return t('select2.noMatches'); + return window.t('select2.noMatches'); }, formatSearching: function () { - return t('select2.searching'); + return window.t('select2.searching'); }, formatInputTooShort: function () { - return tp('select2.tooShort', 2); + return window.tp('select2.tooShort', 2); }, width: '100%', ajax: this.prepareAjaxSearch() @@ -65,5 +65,3 @@ export default BaseFacet.extend({ return this.options.app.state.updateFilter(obj); } }); - - diff --git a/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js index c3d6f274420..e1d48fd5ac2 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/language-facet.js @@ -12,13 +12,13 @@ export default CustomValuesFacet.extend({ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return t('select2.noMatches'); + return window.t('select2.noMatches'); }, formatSearching: function () { - return t('select2.searching'); + return window.t('select2.searching'); }, formatInputTooShort: function () { - return tp('select2.tooShort', 2); + return window.tp('select2.tooShort', 2); }, width: '100%', ajax: { @@ -62,5 +62,3 @@ export default CustomValuesFacet.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js index 5c8eef0fd0e..b4657f808df 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/project-facet.js @@ -28,13 +28,13 @@ export default CustomValuesFacet.extend({ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return t('select2.noMatches'); + return window.t('select2.noMatches'); }, formatSearching: function () { - return t('select2.searching'); + return window.t('select2.searching'); }, formatInputTooShort: function () { - return tp('select2.tooShort', 2); + return window.tp('select2.tooShort', 2); }, width: '100%', ajax: { @@ -78,5 +78,3 @@ export default CustomValuesFacet.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js index 8d50f462c0e..d049890807b 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js @@ -13,13 +13,13 @@ export default CustomValuesFacet.extend({ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return t('select2.noMatches'); + return window.t('select2.noMatches'); }, formatSearching: function () { - return t('select2.searching'); + return window.t('select2.searching'); }, formatInputTooShort: function () { - return tp('select2.tooShort', 2); + return window.tp('select2.tooShort', 2); }, width: '100%', ajax: { @@ -74,5 +74,3 @@ export default CustomValuesFacet.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js index 291bcf6f393..52b0a49c5bb 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js @@ -13,10 +13,10 @@ export default CustomValuesFacet.extend({ minimumInputLength: 0, allowClear: false, formatNoMatches: function () { - return t('select2.noMatches'); + return window.t('select2.noMatches'); }, formatSearching: function () { - return t('select2.searching'); + return window.t('select2.searching'); }, width: '100%', ajax: { @@ -50,5 +50,3 @@ export default CustomValuesFacet.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-list-empty-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-list-empty-view.js index b40c68d0ab6..391dbbfd461 100644 --- a/server/sonar-web/src/main/js/apps/issues/workspace-list-empty-view.js +++ b/server/sonar-web/src/main/js/apps/issues/workspace-list-empty-view.js @@ -4,8 +4,6 @@ export default Marionette.ItemView.extend({ className: 'search-navigator-no-results', template: function () { - return t('issue_filter.no_issues'); + return window.t('issue_filter.no_issues'); } }); - - diff --git a/server/sonar-web/src/main/js/apps/overview/domains/duplications-domain.js b/server/sonar-web/src/main/js/apps/overview/domains/duplications-domain.js index 2223139a760..861e82ad2b5 100644 --- a/server/sonar-web/src/main/js/apps/overview/domains/duplications-domain.js +++ b/server/sonar-web/src/main/js/apps/overview/domains/duplications-domain.js @@ -8,13 +8,12 @@ import { DomainTreemap } from '../components/domain-treemap'; import { DomainBubbleChart } from '../components/domain-bubble-chart'; import { getPeriodLabel, getPeriodDate } from './../helpers/periods'; import { TooltipsMixin } from '../../../components/mixins/tooltips-mixin'; -import { filterMetrics, filterMetricsForDomains } from '../helpers/metrics'; +import { filterMetrics, filterMetricsForDomains, getMetricName } from '../helpers/metrics'; import { DomainLeakTitle } from '../main/components'; import { CHART_COLORS_RANGE_PERCENT } from '../../../helpers/constants'; import { formatMeasure, formatMeasureVariation } from '../../../helpers/measures'; import { DonutChart } from '../../../components/charts/donut-chart'; import { DrilldownLink } from '../../../components/shared/drilldown-link'; -import { getMetricName } from '../helpers/metrics'; export const DuplicationsMain = React.createClass({ diff --git a/server/sonar-web/src/main/js/apps/projects/form-view.js b/server/sonar-web/src/main/js/apps/projects/form-view.js index c5e12ab40d8..8f8951c7b1a 100644 --- a/server/sonar-web/src/main/js/apps/projects/form-view.js +++ b/server/sonar-web/src/main/js/apps/projects/form-view.js @@ -1,5 +1,4 @@ -import ModalForm from 'components/common/modal-form'; -import './templates'; +import ModalForm from '../../components/common/modal-form'; export default ModalForm.extend({ @@ -19,5 +18,3 @@ export default ModalForm.extend({ } }); - - diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gate-condition-view.js b/server/sonar-web/src/main/js/apps/quality-gates/gate-condition-view.js index 9ab319a78e7..fef2d7638ac 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gate-condition-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gate-condition-view.js @@ -90,11 +90,9 @@ export default Marionette.ItemView.extend({ return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { canEdit: this.options.canEdit, periods: this.options.periods, - periodText: period ? period.text : t('value'), + periodText: period ? period.text : window.t('value'), metric: this.getMetric(), isDiffMetric: this.isDiffMetric() }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-view.js b/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-view.js index 4994a9da37b..e7f75a33107 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-view.js @@ -34,7 +34,7 @@ export default Marionette.CompositeView.extend({ this.ui.metricSelect.select2({ allowClear: false, width: '250px', - placeholder: t('alerts.select_metric') + placeholder: window.t('alerts.select_metric') }); }, @@ -71,5 +71,3 @@ export default Marionette.CompositeView.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gate-projects-view.js b/server/sonar-web/src/main/js/apps/quality-gates/gate-projects-view.js index ff7816bd659..5d0493a59f5 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gate-projects-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gate-projects-view.js @@ -25,14 +25,14 @@ export default Marionette.ItemView.extend({ selectParameter: 'projectId', selectParameterValue: 'id', labels: { - selected: t('quality_gates.projects.with'), - deselected: t('quality_gates.projects.without'), - all: t('quality_gates.projects.all'), - noResults: t('quality_gates.projects.noResults') + selected: window.t('quality_gates.projects.with'), + deselected: window.t('quality_gates.projects.without'), + all: window.t('quality_gates.projects.all'), + noResults: window.t('quality_gates.projects.noResults') }, tooltips: { - select: t('quality_gates.projects.select_hint'), - deselect: t('quality_gates.projects.deselect_hint') + select: window.t('quality_gates.projects.select_hint'), + deselect: window.t('quality_gates.projects.deselect_hint') } }); } @@ -44,5 +44,3 @@ export default Marionette.ItemView.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/helpers.js b/server/sonar-web/src/main/js/apps/quality-profiles/helpers.js index 7e060b9599b..479b9b18299 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/helpers.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/helpers.js @@ -15,15 +15,19 @@ Handlebars.registerHelper('exporterUrl', function (profile, exporterKey) { }); Handlebars.registerHelper('severityChangelog', function (severity) { - var label = ' ' + t('severity', severity), - message = tp('quality_profiles.severity_set_to_x', label); + var label = ' ' + window.t('severity', severity), + message = window.tp('quality_profiles.severity_set_to_x', label); return new Handlebars.SafeString(message); }); Handlebars.registerHelper('parameterChangelog', function (value, parameter) { if (parameter) { - return new Handlebars.SafeString(tp('quality_profiles.parameter_set_to_x', value, parameter)); + return new Handlebars.SafeString( + window.tp('quality_profiles.parameter_set_to_x', value, parameter) + ); } else { - return new Handlebars.SafeString(tp('quality_profiles.changelog.parameter_reset_to_default_value_x', parameter)); + return new Handlebars.SafeString( + window.tp('quality_profiles.changelog.parameter_reset_to_default_value_x', parameter) + ); } }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profile-details-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/profile-details-view.js index b5f9167033d..10fc51c4a30 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profile-details-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profile-details-view.js @@ -74,14 +74,14 @@ export default Marionette.LayoutView.extend({ selectParameter: 'projectUuid', selectParameterValue: 'uuid', labels: { - selected: t('quality_gates.projects.with'), - deselected: t('quality_gates.projects.without'), - all: t('quality_gates.projects.all'), - noResults: t('quality_gates.projects.noResults') + selected: window.t('quality_gates.projects.with'), + deselected: window.t('quality_gates.projects.without'), + all: window.t('quality_gates.projects.all'), + noResults: window.t('quality_gates.projects.noResults') }, tooltips: { - select: t('quality_profiles.projects.select_hint'), - deselect: t('quality_profiles.projects.deselect_hint') + select: window.t('quality_profiles.projects.select_hint'), + deselect: window.t('quality_profiles.projects.deselect_hint') } }); this.listenTo(this.projectsSelectList.collection, 'change:selected', this.onProjectsChange); @@ -158,5 +158,3 @@ export default Marionette.LayoutView.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js index e732493b89a..76f1ea1eb1a 100644 --- a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js @@ -122,7 +122,7 @@ export default ActionOptionsView.extend({ if (this.assignees) { return this.assignees; } - var assignees = [{ id: '', text: t('unassigned') }], + var assignees = [{ id: '', text: window.t('unassigned') }], currentUser = window.SS.user, currentUserName = window.SS.userName; assignees.push({ id: currentUser, text: currentUserName }); @@ -138,5 +138,3 @@ export default ActionOptionsView.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js b/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js index 244d65e6a79..ad924a6302e 100644 --- a/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js @@ -26,7 +26,7 @@ export default ActionOptionsView.extend({ }, getActionPlans: function () { - return [{ key: '', name: t('issue.unplanned') }].concat(this.collection.toJSON()); + return [{ key: '', name: window.t('issue.unplanned') }].concat(this.collection.toJSON()); }, serializeData: function () { @@ -35,5 +35,3 @@ export default ActionOptionsView.extend({ }); } }); - - diff --git a/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js index 153cae4fc9e..f3df5eea122 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js @@ -250,7 +250,7 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({ }), defaultValue = this.model.has('defaultValue') ? this.model.get('defaultValue') : - this.model.get('multiple') ? t('all') : t('any'); + this.model.get('multiple') ? window.t('all') : window.t('any'); return this.isDefaultValue() ? defaultValue : value.join(', '); }, @@ -387,5 +387,3 @@ export default { DetailsChoiceFilterView: DetailsChoiceFilterView, ChoiceFilterView: ChoiceFilterView }; - - diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js index cf0ef14db0a..27b9af66d37 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/main.js +++ b/server/sonar-web/src/main/js/components/source-viewer/main.js @@ -712,7 +712,7 @@ export default Marionette.LayoutView.extend({ $(e.currentTarget).tooltip({ container: 'body', placement: 'right', - title: tp('source_viewer.tooltip.new_code', this.sinceLabel), + title: window.tp('source_viewer.tooltip.new_code', this.sinceLabel), trigger: 'manual' }).tooltip('show'); }, diff --git a/server/sonar-web/src/main/js/components/widgets/barchart.js b/server/sonar-web/src/main/js/components/widgets/barchart.js index ea15e5ea684..03fca21da0d 100644 --- a/server/sonar-web/src/main/js/components/widgets/barchart.js +++ b/server/sonar-web/src/main/js/components/widgets/barchart.js @@ -1,6 +1,7 @@ import $ from 'jquery'; import _ from 'underscore'; import moment from 'moment'; +import d3 from 'd3'; function trans (left, top) { return 'translate(' + left + ', ' + top + ')'; diff --git a/server/sonar-web/src/main/js/helpers/handlebars-helpers.js b/server/sonar-web/src/main/js/helpers/handlebars-helpers.js index e2a5110ee74..b9c54ea4562 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars-helpers.js +++ b/server/sonar-web/src/main/js/helpers/handlebars-helpers.js @@ -1,5 +1,6 @@ import _ from 'underscore'; import moment from 'moment'; +import numeral from 'numeral'; import Handlebars from 'hbsfy/runtime'; import md5 from 'blueimp-md5'; import { formatMeasure, formatMeasureVariation } from './measures'; @@ -77,7 +78,7 @@ Handlebars.registerHelper('severityIcon', function (severity) { Handlebars.registerHelper('severityHelper', function (severity) { return new Handlebars.SafeString( - ' ' + t('severity', severity) + ' ' + window.t('severity', severity) ); }); @@ -88,9 +89,9 @@ Handlebars.registerHelper('statusIcon', function (status) { }); Handlebars.registerHelper('statusHelper', function (status, resolution) { - var s = ' ' + t('issue.status', status); + var s = ' ' + window.t('issue.status', status); if (resolution != null) { - s = s + ' (' + t('issue.resolution', resolution) + ')'; + s = s + ' (' + window.t('issue.resolution', resolution) + ')'; } return new Handlebars.SafeString(s); }); @@ -450,13 +451,13 @@ Handlebars.registerHelper('operators', function (options) { Handlebars.registerHelper('changelog', function (diff) { var message = ''; if (diff.newValue != null) { - message = tp('issue.changelog.changed_to', t('issue.changelog.field', diff.key), diff.newValue); + message = window.tp('issue.changelog.changed_to', window.t('issue.changelog.field', diff.key), diff.newValue); } else { - message = tp('issue.changelog.removed', t('issue.changelog.field', diff.key)); + message = window.tp('issue.changelog.removed', window.t('issue.changelog.field', diff.key)); } if (diff.oldValue != null) { message += ' ('; - message += tp('issue.changelog.was', diff.oldValue); + message += window.tp('issue.changelog.was', diff.oldValue); message += ')'; } return message; diff --git a/server/sonar-web/src/main/js/main/nav/global/search-view.js b/server/sonar-web/src/main/js/main/nav/global/search-view.js index 65a3a4a7740..fbe9f3bcddc 100644 --- a/server/sonar-web/src/main/js/main/nav/global/search-view.js +++ b/server/sonar-web/src/main/js/main/nav/global/search-view.js @@ -155,16 +155,16 @@ export default Marionette.LayoutView.extend({ url: url, name: historyItem.name, q: historyItem.icon, - extra: index === 0 ? t('browsed_recently') : null + extra: index === 0 ? window.t('browsed_recently') : null }; }), favorite = _.first(this.favorite, 6).map(function (f, index) { - return _.extend(f, { extra: index === 0 ? t('favorite') : null }); + return _.extend(f, { extra: index === 0 ? window.t('favorite') : null }); }), qualifiers = this.model.get('qualifiers').map(function (q, index) { return { url: baseUrl + '/all_projects?qualifier=' + encodeURIComponent(q), - name: t('qualifiers.all', q), + name: window.t('qualifiers.all', q), extra: index === 0 ? '' : null }; }); @@ -201,22 +201,22 @@ export default Marionette.LayoutView.extend({ getNavigationFindings: function (q) { var DEFAULT_ITEMS = [ - { name: t('issues.page'), url: baseUrl + '/issues/search' }, - { name: t('layout.measures'), url: baseUrl + '/measures/search?qualifiers[]=TRK' }, - { name: t('coding_rules.page'), url: baseUrl + '/coding_rules' }, - { name: t('quality_profiles.page'), url: baseUrl + '/profiles' }, - { name: t('quality_gates.page'), url: baseUrl + '/quality_gates' }, - { name: t('comparison_global.page'), url: baseUrl + '/comparison' } + { name: window.t('issues.page'), url: baseUrl + '/issues/search' }, + { name: window.t('layout.measures'), url: baseUrl + '/measures/search?qualifiers[]=TRK' }, + { name: window.t('coding_rules.page'), url: baseUrl + '/coding_rules' }, + { name: window.t('quality_profiles.page'), url: baseUrl + '/profiles' }, + { name: window.t('quality_gates.page'), url: baseUrl + '/quality_gates' }, + { name: window.t('comparison_global.page'), url: baseUrl + '/comparison' } ], customItems = []; if (window.SS.isUserAdmin) { - customItems.push({ name: t('layout.settings'), url: baseUrl + '/settings' }); + customItems.push({ name: window.t('layout.settings'), url: baseUrl + '/settings' }); } var findings = [].concat(DEFAULT_ITEMS, customItems).filter(function (f) { return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { - findings[0].extra = t('navigation'); + findings[0].extra = window.t('navigation'); } return _.first(findings, 6); }, @@ -230,7 +230,7 @@ export default Marionette.LayoutView.extend({ return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { - findings[0].extra = t('dashboard.global_dashboards'); + findings[0].extra = window.t('dashboard.global_dashboards'); } return _.first(findings, 6); }, @@ -240,10 +240,8 @@ export default Marionette.LayoutView.extend({ return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { - findings[0].extra = t('favorite'); + findings[0].extra = window.t('favorite'); } return _.first(findings, 6); } }); - - diff --git a/server/sonar-web/src/main/js/main/processes.js b/server/sonar-web/src/main/js/main/processes.js index 1d685ab953d..af67b1b6197 100644 --- a/server/sonar-web/src/main/js/main/processes.js +++ b/server/sonar-web/src/main/js/main/processes.js @@ -30,7 +30,7 @@ var Process = Backbone.Model.extend({ fail: function (message) { var that = this, - msg = message || t('process.fail'); + msg = message || window.t('process.fail'); if (msg === 'process.fail') { // no translation msg = 'An error happened, some parts of the page might not render correctly. ' + diff --git a/server/sonar-web/src/main/js/widgets/old/tag-cloud.js b/server/sonar-web/src/main/js/widgets/old/tag-cloud.js index d09f38b55bb..cd2851ab8a2 100644 --- a/server/sonar-web/src/main/js/widgets/old/tag-cloud.js +++ b/server/sonar-web/src/main/js/widgets/old/tag-cloud.js @@ -64,7 +64,7 @@ TagCloud.prototype.tooltip = function (d) { var suffixKey = d.value === 1 ? 'issue' : 'issues', - suffix = t(suffixKey); + suffix = window.t(suffixKey); return (d.value + '\u00a0') + suffix; };