diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-08-24 13:50:18 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-08-26 10:12:03 +0200 |
commit | 223bcb955ba554be354f6b4b1ca0c1acb9431d66 (patch) | |
tree | c055f39d1cf688974d275877c5ff07490c32295f /server/sonar-web/src/main/js/apps | |
parent | 4fa812ee4cb69d00e761b7887fdd30820d6748a9 (diff) | |
download | sonarqube-223bcb955ba554be354f6b4b1ca0c1acb9431d66.tar.gz sonarqube-223bcb955ba554be354f6b4b1ca0c1acb9431d66.zip |
use the single web app
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
206 files changed, 859 insertions, 1315 deletions
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 86522a8dc40..f21ca4be2ce 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 @@ -8,12 +8,12 @@ define([ return ModalForm.extend({ template: Templates['account-change-password'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); 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') }]); } }, @@ -32,7 +32,7 @@ define([ }; var opts = { type: 'POST', - url: baseUrl + '/api/users/change_password', + url: window.baseUrl + '/api/users/change_password', data: data, statusCode: { // do not show global error diff --git a/server/sonar-web/src/main/js/apps/api-documentation/action-view.js b/server/sonar-web/src/main/js/apps/api-documentation/action-view.js index 6df5db30ee5..df6b6e6b345 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/action-view.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/action-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/api-documentation/actions-view.js b/server/sonar-web/src/main/js/apps/api-documentation/actions-view.js index 683485c101b..e98839b6428 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/actions-view.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/actions-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './action-view' -], function (ActionView) { +], function (Marionette, ActionView) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/api-documentation/app.js b/server/sonar-web/src/main/js/apps/api-documentation/app.js index bc38d046613..7e211afe09e 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/app.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/app.js @@ -1,30 +1,13 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', + 'backbone.marionette', './router', './controller', './layout', './list', './list-view', './filters-view' -], function (Router, Controller, Layout, List, ListView, FiltersView) { +], function (Backbone, Marionette, Router, Controller, Layout, List, ListView, FiltersView) { var $ = jQuery, App = new Marionette.Application(), @@ -69,9 +52,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/api-documentation/controller.js b/server/sonar-web/src/main/js/apps/api-documentation/controller.js index 69ae9413bac..0e33de26422 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/controller.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/controller.js @@ -1,26 +1,9 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', + 'backbone.marionette', './actions-view', './header-view' -], function (ActionsView, HeaderView) { +], function (Backbone, Marionette, ActionsView, HeaderView) { return Marionette.Controller.extend({ diff --git a/server/sonar-web/src/main/js/apps/api-documentation/filters-view.js b/server/sonar-web/src/main/js/apps/api-documentation/filters-view.js index 8465cfe9db3..525dfeb6030 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/filters-view.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/filters-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['api-documentation-filters'], diff --git a/server/sonar-web/src/main/js/apps/api-documentation/header-view.js b/server/sonar-web/src/main/js/apps/api-documentation/header-view.js index 259fffae1c6..5a2a7641860 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/header-view.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/header-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['api-documentation-header'], diff --git a/server/sonar-web/src/main/js/apps/api-documentation/item-view.js b/server/sonar-web/src/main/js/apps/api-documentation/item-view.js index 2c88eb9e13f..79619bda267 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/item-view.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/item-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ tagName: 'a', diff --git a/server/sonar-web/src/main/js/apps/api-documentation/layout.js b/server/sonar-web/src/main/js/apps/api-documentation/layout.js index 67b30bb34b0..6478b6471e9 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/layout.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/layout.js @@ -1,25 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', + '../../components/common/jquery-isolated-scroll', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['api-documentation-layout'], diff --git a/server/sonar-web/src/main/js/apps/api-documentation/list-view.js b/server/sonar-web/src/main/js/apps/api-documentation/list-view.js index b90ba7f725a..b0b22a0ae50 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/list-view.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/list-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './item-view' -], function (ItemView) { +], function (Marionette, ItemView) { return Marionette.CollectionView.extend({ className: 'list-group', diff --git a/server/sonar-web/src/main/js/apps/api-documentation/list.js b/server/sonar-web/src/main/js/apps/api-documentation/list.js index 131b3352e8d..e525c84a818 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/list.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/list.js @@ -1,23 +1,6 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Collection.extend({ url: baseUrl + '/api/webservices/list', diff --git a/server/sonar-web/src/main/js/apps/api-documentation/router.js b/server/sonar-web/src/main/js/apps/api-documentation/router.js index fee3493fb18..65f1c62a6fd 100644 --- a/server/sonar-web/src/main/js/apps/api-documentation/router.js +++ b/server/sonar-web/src/main/js/apps/api-documentation/router.js @@ -1,23 +1,6 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Router.extend({ 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 61f5e97ddd2..67b18ef2b11 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 @@ -1,4 +1,6 @@ define([ + 'backbone', + 'backbone.marionette', './models/state', './layout', './models/rules', @@ -13,7 +15,9 @@ define([ './facets-view', './filters-view' ], - function (State, + function (Backbone, + Marionette, + State, Layout, Rules, Facets, @@ -71,7 +75,7 @@ define([ App.manualRepository = function () { return { key: 'manual', - name: t('coding_rules.manual_rule'), + name: window.t('coding_rules.manual_rule'), language: 'none' }; }; @@ -104,7 +108,7 @@ define([ }); App.on('start', function (options) { - $.when(window.requestMessages(), appXHR).done(function () { + $.when(appXHR).done(function () { init.call(App, options); }); }); 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 bdd2cbb5f34..d9bff5b021d 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 @@ -36,14 +36,14 @@ define([ 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('<div class="alert alert-success">' + message + '</div>'); }, 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('<div class="alert alert-warning">' + message + '</div>'); }, 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 6695943968d..7cabf7b44e2 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 @@ -46,7 +46,7 @@ define([ 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 7aad57ad48c..b43aadb3ff1 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 @@ -32,7 +32,7 @@ define([ }, getUrl: function () { - return baseUrl; + return window.baseUrl; }, onRender: function () { @@ -42,17 +42,17 @@ define([ 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 1a05fff7479..50bef351339 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 @@ -51,7 +51,7 @@ define([ 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 () { @@ -63,7 +63,7 @@ define([ 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/language-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js index 478c589032c..1873599e3cd 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js @@ -24,7 +24,7 @@ define([ return CustomValuesFacet.extend({ getUrl: function () { - return baseUrl + '/api/languages/list'; + return window.baseUrl + '/api/languages/list'; }, prepareAjaxSearch: function () { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js index 08283dc5b18..ae064ba3b2a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js @@ -24,7 +24,7 @@ define([ return CustomValuesFacet.extend({ getUrl: function () { - return baseUrl + '/api/rules/repositories'; + return window.baseUrl + '/api/rules/repositories'; }, prepareAjaxSearch: function () { 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 96854e47564..2d2b6b654e8 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 @@ -27,7 +27,7 @@ define([ 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/facets/tag-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js index 9a5b0f21570..3e6a064ef6c 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js @@ -24,7 +24,7 @@ define([ return CustomValuesFacet.extend({ getUrl: function () { - return baseUrl + '/api/rules/tags'; + return window.baseUrl + '/api/rules/tags'; }, prepareAjaxSearch: function () { diff --git a/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js b/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js index 4626acd9d02..c7a289e9c29 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/filters-view.js @@ -1,26 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './rule/manual-rule-creation-view', './templates' -], function (ManualRuleCreationView) { +], function (Marionette, ManualRuleCreationView) { return Marionette.ItemView.extend({ template: Templates['coding-rules-filters'], @@ -36,7 +18,9 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { canWrite: this.options.app.canWrite }); + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + canWrite: this.options.app.canWrite + }); } }); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/layout.js b/server/sonar-web/src/main/js/apps/coding-rules/layout.js index 34f66a61a2e..d2fff28e341 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/layout.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/layout.js @@ -1,25 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', + '../../components/common/jquery-isolated-scroll', './templates' -], function () { +], function (Marionette) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js b/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js index 51993df4b98..fbc5ecdd8b0 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/models/rule.js @@ -1,23 +1,6 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ idAttribute: 'key', diff --git a/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js b/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js index f1f83bcf1bd..39a833309e5 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/models/rules.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', './rule' -], function (Rule) { +], function (Backbone, Rule) { return Backbone.Collection.extend({ model: Rule, 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 05856342aa4..f1536004dff 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 @@ -1,23 +1,6 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', + 'backbone.marionette', './models/rules', './rule/rule-meta-view', './rule/rule-description-view', @@ -27,9 +10,12 @@ define([ './rule/manual-rule-creation-view', './rule/custom-rule-creation-view', './rule/rule-issues-view', + '../../components/common/dialogs', './templates' ], - function (Rules, + function (Backbone, + Marionette, + Rules, MetaView, DescView, ParamView, @@ -37,7 +23,8 @@ define([ CustomRulesView, ManualRuleCreationView, CustomRuleCreationView, - IssuesView) { + IssuesView, + confirmDialog) { var $ = jQuery; @@ -163,9 +150,9 @@ define([ deleteRule: function () { var that = this, ruleType = this.model.has('templateKey') ? 'custom' : 'manual'; - window.confirmDialog({ - title: t('delete'), - html: tp('coding_rules.delete.' + ruleType + '.confirm', this.model.get('name')), + confirmDialog({ + 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 e15a1149e69..1ee49177642 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 @@ -19,8 +19,9 @@ */ define([ 'components/common/modal-form', + '../../../libs/csv', '../templates' -], function (ModalFormView) { +], function (ModalFormView, csvEscape) { var $ = jQuery; @@ -128,7 +129,7 @@ define([ }; }).get(); options.params = params.map(function (param) { - return param.key + '=' + window.csvEscape(param.value); + return param.key + '=' + csvEscape(param.value); }).join(';'); this.sendRequest(action, options); }, @@ -172,7 +173,7 @@ define([ }).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 { @@ -194,7 +195,7 @@ define([ 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 e50b7c11005..5dc0c9ac732 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 @@ -1,25 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', + '../../../components/common/dialogs', '../templates' -], function () { +], function (Marionette, confirmDialog) { var $ = jQuery; @@ -37,9 +20,9 @@ define([ deleteRule: function () { var that = this; - window.confirmDialog({ - title: t('delete'), - html: t('are_you_sure'), + confirmDialog({ + 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/custom-rules-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js index 56ae2a95833..bd51911930d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js @@ -1,27 +1,9 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './custom-rule-view', './custom-rule-creation-view', '../templates' -], function (CustomRuleView, CustomRuleCreationView) { +], function (Marionette, CustomRuleView, CustomRuleCreationView) { return Marionette.CompositeView.extend({ template: Templates['coding-rules-custom-rules'], 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 66617fc33ed..32c707f6c9a 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 @@ -119,7 +119,7 @@ define([ }).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/profile-activation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js index 87296ca2e0f..663895b4823 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js @@ -1,26 +1,9 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', 'components/common/modal-form', + '../../../libs/csv', '../templates' -], function (ModalForm) { +], function (Backbone, ModalForm, csvEscape) { var $ = jQuery; @@ -28,7 +11,7 @@ define([ template: Templates['coding-rules-profile-activation'], ui: function () { - return _.extend(this._super(), { + return _.extend(ModalForm.prototype.ui.apply(this, arguments), { qualityProfileSelect: '#coding-rules-quality-profile-activation-select', qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity', qualityProfileActivate: '#coding-rules-quality-profile-activation-activate', @@ -37,13 +20,13 @@ define([ }, events: function () { - return _.extend(this._super(), { + return _.extend(ModalForm.prototype.events.apply(this, arguments), { 'click @ui.qualityProfileActivate': 'activate' }); }, onRender: function () { - this._super(); + ModalForm.prototype.onRender.apply(this, arguments); this.ui.qualityProfileSelect.select2({ width: '250px', @@ -82,7 +65,7 @@ define([ }; }).get(), paramsHash = (params.map(function (param) { - return param.key + '=' + window.csvEscape(param.value); + return param.key + '=' + csvEscape(param.value); })).join(';'); if (this.model) { @@ -146,7 +129,7 @@ define([ var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')); - return _.extend(this._super(), { + return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), { change: this.model && this.model.has('severity'), params: params, qualityProfiles: availableProfiles, 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 c84213c614d..cd36bb7d3d9 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 @@ -1,25 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', + '../../../components/common/dialogs', '../templates' -], function () { +], function (Marionette, confirmDialog) { return Marionette.ItemView.extend({ template: Templates['coding-rules-rule-description'], @@ -80,8 +63,8 @@ define([ removeExtendedDescription: function () { var that = this; - window.confirmDialog({ - html: t('coding_rules.remove_extended_description.confirm'), + confirmDialog({ + 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-issues-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js index ebbd0f62149..373c4a54a45 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', '../templates' -], function () { +], function (Marionette) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js index d8565818c52..f31fbb7656e 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js @@ -1,26 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './rule-filter-mixin', '../templates' -], function (RuleFilterMixin) { +], function (Marionette, RuleFilterMixin) { return Marionette.ItemView.extend(RuleFilterMixin).extend({ template: Templates['coding-rules-rule-meta'], diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js index 2e5a927621d..d49a6adcb21 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', '../templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['coding-rules-rule-parameters'], 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 42902e38c3c..5701de25f80 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 @@ -1,26 +1,10 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', + 'backbone.marionette', './profile-activation-view', + '../../../components/common/dialogs', '../templates' -], function (ProfileActivationView) { +], function (Backbone, Marionette, ProfileActivationView, confirmDialog) { return Marionette.ItemView.extend({ tagName: 'tr', @@ -65,9 +49,9 @@ define([ revert: function () { var that = this, ruleKey = this.options.rule.get('key'); - window.confirmDialog({ - title: t('coding_rules.revert_to_parent_definition'), - html: tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name), + confirmDialog({ + 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 jQuery.ajax({ type: 'POST', @@ -87,9 +71,9 @@ define([ deactivate: function () { var that = this, ruleKey = this.options.rule.get('key'); - window.confirmDialog({ - title: t('coding_rules.deactivate'), - html: tp('coding_rules.deactivate.confirm'), + confirmDialog({ + title: window.t('coding_rules.deactivate'), + html: window.tp('coding_rules.deactivate.confirm'), yesHandler: function () { return jQuery.ajax({ type: 'POST', diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js index fc7662e5073..562f349939a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js @@ -1,27 +1,9 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './rule-profile-view', './profile-activation-view', '../templates' -], function (ProfileView, ProfileActivationView) { +], function (Marionette, ProfileView, ProfileActivationView) { return Marionette.CompositeView.extend({ template: Templates['coding-rules-rule-profiles'], 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 2aefada2578..20b4f0f4b3f 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 @@ -1,29 +1,12 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(function () { +define([ + 'backbone.marionette' +], function (Marionette) { return 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 1041a326de9..f3c8de7de57 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 @@ -1,28 +1,11 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', 'components/navigator/workspace-list-item-view', './rule/profile-activation-view', + '../../components/common/dialogs', './rule/rule-filter-mixin', './templates' -], function (WorkspaceListItemView, ProfileActivationView, RuleFilterMixin) { +], function (Backbone, WorkspaceListItemView, ProfileActivationView, confirmDialog, RuleFilterMixin) { return WorkspaceListItemView.extend(RuleFilterMixin).extend({ className: 'coding-rule', @@ -78,9 +61,9 @@ define([ var that = this, ruleKey = this.model.get('key'), activation = this.model.get('activation'); - window.confirmDialog({ - title: t('coding_rules.deactivate'), - html: tp('coding_rules.deactivate.confirm'), + confirmDialog({ + title: window.t('coding_rules.deactivate'), + html: window.tp('coding_rules.deactivate.confirm'), yesHandler: function () { return jQuery.ajax({ type: 'POST', diff --git a/server/sonar-web/src/main/js/apps/computation/app.js b/server/sonar-web/src/main/js/apps/computation/app.js index 43e64d86b5d..73ac19753ac 100644 --- a/server/sonar-web/src/main/js/apps/computation/app.js +++ b/server/sonar-web/src/main/js/apps/computation/app.js @@ -1,4 +1,6 @@ define([ + 'backbone', + 'backbone.marionette', './router', './layout', './reports', @@ -6,7 +8,7 @@ define([ './search-view', './list-view', './list-footer-view' -], function (Router, Layout, Reports, HeaderView, SearchView, ListView, ListFooterView) { +], function (Backbone, Marionette, Router, Layout, Reports, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -47,9 +49,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/computation/header-view.js b/server/sonar-web/src/main/js/apps/computation/header-view.js index 8e010c0eded..6a36a006cbb 100644 --- a/server/sonar-web/src/main/js/apps/computation/header-view.js +++ b/server/sonar-web/src/main/js/apps/computation/header-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['computation-header'] diff --git a/server/sonar-web/src/main/js/apps/computation/layout.js b/server/sonar-web/src/main/js/apps/computation/layout.js index 2e7edcd22bf..b8de14574a0 100644 --- a/server/sonar-web/src/main/js/apps/computation/layout.js +++ b/server/sonar-web/src/main/js/apps/computation/layout.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['computation-layout'], diff --git a/server/sonar-web/src/main/js/apps/computation/list-footer-view.js b/server/sonar-web/src/main/js/apps/computation/list-footer-view.js index 5034f25a3e8..c6f98d9238f 100644 --- a/server/sonar-web/src/main/js/apps/computation/list-footer-view.js +++ b/server/sonar-web/src/main/js/apps/computation/list-footer-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['computation-list-footer'], diff --git a/server/sonar-web/src/main/js/apps/computation/list-item-view.js b/server/sonar-web/src/main/js/apps/computation/list-item-view.js index afcf2f15d3f..44e5e32dcaf 100644 --- a/server/sonar-web/src/main/js/apps/computation/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/computation/list-item-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ tagName: 'li', diff --git a/server/sonar-web/src/main/js/apps/computation/list-view.js b/server/sonar-web/src/main/js/apps/computation/list-view.js index 24878864d30..b56e64f951d 100644 --- a/server/sonar-web/src/main/js/apps/computation/list-view.js +++ b/server/sonar-web/src/main/js/apps/computation/list-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './list-item-view', './templates' -], function (ListItemView) { +], function (Marionette, ListItemView) { return Marionette.CollectionView.extend({ tagName: 'ul', diff --git a/server/sonar-web/src/main/js/apps/computation/report.js b/server/sonar-web/src/main/js/apps/computation/report.js index 2eac3f23e84..a1895bd4d3c 100644 --- a/server/sonar-web/src/main/js/apps/computation/report.js +++ b/server/sonar-web/src/main/js/apps/computation/report.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ idAttribute: 'key', diff --git a/server/sonar-web/src/main/js/apps/computation/reports.js b/server/sonar-web/src/main/js/apps/computation/reports.js index 9c8144333bb..04b6eae2eaa 100644 --- a/server/sonar-web/src/main/js/apps/computation/reports.js +++ b/server/sonar-web/src/main/js/apps/computation/reports.js @@ -1,6 +1,7 @@ define([ + 'backbone', './report' -], function (Report) { +], function (Backbone, Report) { return Backbone.Collection.extend({ model: Report, @@ -15,7 +16,7 @@ define([ fetch: function (options) { var opts = _.defaults(options || {}, { q: this.q }, { q: 'history' }); - opts.url = baseUrl + '/api/computation/' + opts.q; + opts.url = window.baseUrl + '/api/computation/' + opts.q; this.q = opts.q; return Backbone.Collection.prototype.fetch.call(this, opts); }, diff --git a/server/sonar-web/src/main/js/apps/computation/router.js b/server/sonar-web/src/main/js/apps/computation/router.js index 6d874801cd3..611a685ea19 100644 --- a/server/sonar-web/src/main/js/apps/computation/router.js +++ b/server/sonar-web/src/main/js/apps/computation/router.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Router.extend({ routes: { diff --git a/server/sonar-web/src/main/js/apps/computation/search-view.js b/server/sonar-web/src/main/js/apps/computation/search-view.js index 75ab65c4dad..68a0cb7dd34 100644 --- a/server/sonar-web/src/main/js/apps/computation/search-view.js +++ b/server/sonar-web/src/main/js/apps/computation/search-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['computation-search'], diff --git a/server/sonar-web/src/main/js/apps/custom-measures/app.js b/server/sonar-web/src/main/js/apps/custom-measures/app.js index de6316fb658..ad941ec3f65 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/app.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/app.js @@ -1,10 +1,11 @@ define([ + 'backbone.marionette', './layout', './custom-measures', './header-view', './list-view', './list-footer-view' -], function (Layout, CustomMeasures, HeaderView, ListView, ListFooterView) { +], function (Marionette, Layout, CustomMeasures, HeaderView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -16,13 +17,13 @@ define([ // Collection this.customMeasures = new CustomMeasures({ - projectId: options.projectId + projectId: options.component.uuid }); // Header View this.headerView = new HeaderView({ collection: this.customMeasures, - projectId: options.projectId + projectId: options.component.uuid }); this.layout.headerRegion.show(this.headerView); @@ -43,9 +44,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js b/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js index fce8bf4fbdf..aaa8c2d1b66 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js @@ -1,10 +1,12 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ idAttribute: 'id', urlRoot: function () { - return baseUrl + '/api/custom_measures'; + return window.baseUrl + '/api/custom_measures'; }, sync: function (method, model, options) { diff --git a/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js b/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js index 2febc1ea652..ae23b352832 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js @@ -1,6 +1,7 @@ define([ + 'backbone', './custom-measure' -], function (CustomMeasure) { +], function (Backbone, CustomMeasure) { return Backbone.Collection.extend({ model: CustomMeasure, @@ -10,7 +11,7 @@ define([ }, url: function () { - return baseUrl + '/api/custom_measures/search'; + return window.baseUrl + '/api/custom_measures/search'; }, parse: function (r) { @@ -24,7 +25,7 @@ define([ var opts = _.defaults(options || {}, { data: {} }); this.q = opts.data.q; opts.data.projectId = this.projectId; - return this._super(opts); + return Backbone.Collection.prototype.fetch.call(this, opts); }, fetchMore: function () { diff --git a/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js b/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js index 1838b83e044..b3092fd0343 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/delete-view.js @@ -6,8 +6,8 @@ define([ return ModalForm.extend({ template: Templates['custom-measures-delete'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, diff --git a/server/sonar-web/src/main/js/apps/custom-measures/form-view.js b/server/sonar-web/src/main/js/apps/custom-measures/form-view.js index 30ed30082b9..15d9e405098 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/form-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/form-view.js @@ -14,7 +14,7 @@ define([ }, onRender: function () { - this._super(); + ModalForm.prototype.onRender.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); this.$('#create-custom-measure-metric').select2({ width: '250px', @@ -23,12 +23,12 @@ define([ }, onDestroy: function () { - this._super(); + ModalForm.prototype.onDestroy.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, @@ -42,7 +42,7 @@ define([ serializeData: function () { var metrics = this.getAvailableMetrics(), isNew = !this.model; - return _.extend(this._super(), { + return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), { metrics: metrics, canCreateMetric: !isNew || (isNew && metrics.length > 0) }); diff --git a/server/sonar-web/src/main/js/apps/custom-measures/header-view.js b/server/sonar-web/src/main/js/apps/custom-measures/header-view.js index 8b22efcec5a..87bc3f1d628 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/header-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/header-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './create-view', './templates' -], function (CreateView) { +], function (Marionette, CreateView) { return Marionette.ItemView.extend({ template: Templates['custom-measures-header'], diff --git a/server/sonar-web/src/main/js/apps/custom-measures/layout.js b/server/sonar-web/src/main/js/apps/custom-measures/layout.js index b4aa4ece791..bf72535e6dc 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/layout.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/layout.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['custom-measures-layout'], diff --git a/server/sonar-web/src/main/js/apps/custom-measures/list-footer-view.js b/server/sonar-web/src/main/js/apps/custom-measures/list-footer-view.js index d66c27ad335..6ca83eb4990 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/list-footer-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/list-footer-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['custom-measures-list-footer'], @@ -23,7 +24,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { total: this.collection.total, count: this.collection.length, more: this.collection.hasMore() diff --git a/server/sonar-web/src/main/js/apps/custom-measures/list-item-view.js b/server/sonar-web/src/main/js/apps/custom-measures/list-item-view.js index 97d9671eb17..b2da300354b 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/list-item-view.js @@ -1,8 +1,9 @@ define([ + 'backbone.marionette', './update-view', './delete-view', './templates' -], function (UpdateView, DeleteView) { +], function (Marionette, UpdateView, DeleteView) { return Marionette.ItemView.extend({ tagName: 'li', diff --git a/server/sonar-web/src/main/js/apps/custom-measures/list-view.js b/server/sonar-web/src/main/js/apps/custom-measures/list-view.js index 24878864d30..b56e64f951d 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/list-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/list-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './list-item-view', './templates' -], function (ListItemView) { +], function (Marionette, ListItemView) { return Marionette.CollectionView.extend({ tagName: 'ul', diff --git a/server/sonar-web/src/main/js/apps/dashboard/app.jsx b/server/sonar-web/src/main/js/apps/dashboard/app.jsx new file mode 100644 index 00000000000..98ae2f4691f --- /dev/null +++ b/server/sonar-web/src/main/js/apps/dashboard/app.jsx @@ -0,0 +1,10 @@ +export default { + start(options) { + let widgets = window.widgets || []; + widgets.forEach(widget => { + require([`widgets/${widget.name}/widget`], Widget => { + new Widget(widget.options); + }); + }); + } +}; diff --git a/server/sonar-web/src/main/js/apps/drilldown/app.js b/server/sonar-web/src/main/js/apps/drilldown/app.js index e46612c1a13..b2f9cca9940 100644 --- a/server/sonar-web/src/main/js/apps/drilldown/app.js +++ b/server/sonar-web/src/main/js/apps/drilldown/app.js @@ -1,30 +1,12 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', 'components/source-viewer/main' -], function (SourceViewer) { +], function (Marionette, SourceViewer) { var $ = jQuery, App = new Marionette.Application(), init = function (options) { - App.addRegions({ viewerRegion: options.el }); + App.addRegions({ viewerRegion: '#source-viewer' }); $('.js-drilldown-link').on('click', function (e) { e.preventDefault(); $(e.currentTarget).closest('table').find('.selected').removeClass('selected'); @@ -42,9 +24,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/global-permissions/app.jsx b/server/sonar-web/src/main/js/apps/global-permissions/app.jsx index 28dc73b7f42..478924e9233 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/app.jsx +++ b/server/sonar-web/src/main/js/apps/global-permissions/app.jsx @@ -5,9 +5,7 @@ const $ = jQuery; export default { start(options) { - window.requestMessages().done(() => { - var el = document.querySelector(options.el); - React.render(<Main/>, el); - }); + var el = document.querySelector(options.el); + React.render(<Main/>, el); } }; diff --git a/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js b/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js index 5b25ec62db2..fbc0691ed6d 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js +++ b/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js @@ -8,7 +8,7 @@ define([ template: Templates['global-permissions-groups'], onRender: function () { - this._super(); + Modal.prototype.onRender.apply(this, arguments); new window.SelectList({ el: this.$('#global-permissions-groups'), width: '100%', @@ -35,7 +35,7 @@ define([ onDestroy: function () { this.options.refresh(); - this._super(); + Modal.prototype.onDestroy.apply(this, arguments); } }); diff --git a/server/sonar-web/src/main/js/apps/global-permissions/users-view.js b/server/sonar-web/src/main/js/apps/global-permissions/users-view.js index b5660c650da..1c0a0937038 100644 --- a/server/sonar-web/src/main/js/apps/global-permissions/users-view.js +++ b/server/sonar-web/src/main/js/apps/global-permissions/users-view.js @@ -8,7 +8,7 @@ define([ template: Templates['global-permissions-users'], onRender: function () { - this._super(); + Modal.prototype.onRender.apply(this, arguments); new window.SelectList({ el: this.$('#global-permissions-users'), width: '100%', @@ -35,7 +35,7 @@ define([ onDestroy: function () { this.options.refresh(); - this._super(); + Modal.prototype.onDestroy.apply(this, arguments); } }); diff --git a/server/sonar-web/src/main/js/apps/groups/app.js b/server/sonar-web/src/main/js/apps/groups/app.js index 55c6dfef534..abd897234a5 100644 --- a/server/sonar-web/src/main/js/apps/groups/app.js +++ b/server/sonar-web/src/main/js/apps/groups/app.js @@ -1,11 +1,12 @@ define([ + 'backbone.marionette', './layout', './groups', './header-view', './search-view', './list-view', './list-footer-view' -], function (Layout, Groups, HeaderView, SearchView, ListView, ListFooterView) { +], function (Marionette, Layout, Groups, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -37,9 +38,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/groups/delete-view.js b/server/sonar-web/src/main/js/apps/groups/delete-view.js index 85b33a632b5..14c35a1873f 100644 --- a/server/sonar-web/src/main/js/apps/groups/delete-view.js +++ b/server/sonar-web/src/main/js/apps/groups/delete-view.js @@ -6,8 +6,8 @@ define([ return ModalForm.extend({ template: Templates['groups-delete'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, @@ -28,10 +28,10 @@ define([ }); }, - showErrors: function (errors, warnings) { + showErrors: function () { this.$('.js-modal-text').addClass('hidden'); this.disableForm(); - this._super(errors, warnings); + ModalForm.prototype.showErrors.apply(this, arguments); } }); diff --git a/server/sonar-web/src/main/js/apps/groups/form-view.js b/server/sonar-web/src/main/js/apps/groups/form-view.js index 7e3c26b98ee..29a654db85e 100644 --- a/server/sonar-web/src/main/js/apps/groups/form-view.js +++ b/server/sonar-web/src/main/js/apps/groups/form-view.js @@ -7,17 +7,17 @@ define([ template: Templates['groups-form'], onRender: function () { - this._super(); + ModalForm.prototype.onRender.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onDestroy: function () { - this._super(); + ModalForm.prototype.onDestroy.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); } }); diff --git a/server/sonar-web/src/main/js/apps/groups/group.js b/server/sonar-web/src/main/js/apps/groups/group.js index aced6727b91..5d7807b51d2 100644 --- a/server/sonar-web/src/main/js/apps/groups/group.js +++ b/server/sonar-web/src/main/js/apps/groups/group.js @@ -1,8 +1,10 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ urlRoot: function () { - return baseUrl + '/api/usergroups'; + return window.baseUrl + '/api/usergroups'; }, sync: function (method, model, options) { diff --git a/server/sonar-web/src/main/js/apps/groups/groups.js b/server/sonar-web/src/main/js/apps/groups/groups.js index dcfbb8c731b..46c46fe8078 100644 --- a/server/sonar-web/src/main/js/apps/groups/groups.js +++ b/server/sonar-web/src/main/js/apps/groups/groups.js @@ -1,12 +1,13 @@ define([ + 'backbone', './group' -], function (Group) { +], function (Backbone, Group) { return Backbone.Collection.extend({ model: Group, url: function () { - return baseUrl + '/api/usergroups/search'; + return window.baseUrl + '/api/usergroups/search'; }, parse: function (r) { @@ -19,7 +20,7 @@ define([ fetch: function (options) { var d = (options && options.data) || {}; this.q = d.q; - return this._super(options); + return Backbone.Collection.prototype.fetch.apply(this, arguments); }, fetchMore: function () { diff --git a/server/sonar-web/src/main/js/apps/groups/header-view.js b/server/sonar-web/src/main/js/apps/groups/header-view.js index da6f7f60919..a60f0c51f34 100644 --- a/server/sonar-web/src/main/js/apps/groups/header-view.js +++ b/server/sonar-web/src/main/js/apps/groups/header-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './create-view', './templates' -], function (CreateView) { +], function (Marionette, CreateView) { return Marionette.ItemView.extend({ template: Templates['groups-header'], diff --git a/server/sonar-web/src/main/js/apps/groups/layout.js b/server/sonar-web/src/main/js/apps/groups/layout.js index 18f6c7738d1..e6cddd674ce 100644 --- a/server/sonar-web/src/main/js/apps/groups/layout.js +++ b/server/sonar-web/src/main/js/apps/groups/layout.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['groups-layout'], diff --git a/server/sonar-web/src/main/js/apps/groups/list-footer-view.js b/server/sonar-web/src/main/js/apps/groups/list-footer-view.js index 3c0fbe198c5..ee4467b3e87 100644 --- a/server/sonar-web/src/main/js/apps/groups/list-footer-view.js +++ b/server/sonar-web/src/main/js/apps/groups/list-footer-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['groups-list-footer'], @@ -23,7 +24,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { total: this.collection.total, count: this.collection.length, more: this.collection.hasMore() diff --git a/server/sonar-web/src/main/js/apps/groups/list-item-view.js b/server/sonar-web/src/main/js/apps/groups/list-item-view.js index 45ce8b9688a..20a24cf3bc0 100644 --- a/server/sonar-web/src/main/js/apps/groups/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/groups/list-item-view.js @@ -1,9 +1,10 @@ define([ + 'backbone.marionette', './update-view', './delete-view', './users-view', './templates' -], function (UpdateView, DeleteView, UsersView) { +], function (Marionette, UpdateView, DeleteView, UsersView) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/groups/list-view.js b/server/sonar-web/src/main/js/apps/groups/list-view.js index 24878864d30..b56e64f951d 100644 --- a/server/sonar-web/src/main/js/apps/groups/list-view.js +++ b/server/sonar-web/src/main/js/apps/groups/list-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './list-item-view', './templates' -], function (ListItemView) { +], function (Marionette, ListItemView) { return Marionette.CollectionView.extend({ tagName: 'ul', diff --git a/server/sonar-web/src/main/js/apps/groups/search-view.js b/server/sonar-web/src/main/js/apps/groups/search-view.js index 1540d7eb36e..efcd9247db8 100644 --- a/server/sonar-web/src/main/js/apps/groups/search-view.js +++ b/server/sonar-web/src/main/js/apps/groups/search-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['groups-search'], diff --git a/server/sonar-web/src/main/js/apps/groups/users-view.js b/server/sonar-web/src/main/js/apps/groups/users-view.js index de5901fc5f1..5db80139c8b 100644 --- a/server/sonar-web/src/main/js/apps/groups/users-view.js +++ b/server/sonar-web/src/main/js/apps/groups/users-view.js @@ -8,7 +8,8 @@ define([ template: Templates['groups-users'], onRender: function () { - this._super(); + Modal.prototype.onRender.apply(this, arguments); + //noinspection Eslint new window.SelectList({ el: this.$('#groups-users'), width: '100%', @@ -18,9 +19,9 @@ define([ return item.name + '<br><span class="note">' + item.login + '</span>'; }, queryParam: 'q', - searchUrl: baseUrl + '/api/usergroups/users?ps=100&id=' + this.model.id, - selectUrl: baseUrl + '/api/usergroups/add_user', - deselectUrl: baseUrl + '/api/usergroups/remove_user', + searchUrl: window.baseUrl + '/api/usergroups/users?ps=100&id=' + this.model.id, + selectUrl: window.baseUrl + '/api/usergroups/add_user', + deselectUrl: window.baseUrl + '/api/usergroups/remove_user', extra: { id: this.model.id }, @@ -35,7 +36,7 @@ define([ onDestroy: function () { this.model.collection.refresh(); - this._super(); + Modal.prototype.onDestroy.apply(this, arguments); } }); diff --git a/server/sonar-web/src/main/js/apps/issues/app-context.js b/server/sonar-web/src/main/js/apps/issues/app-context.js index 3d7db3aa2ef..63221207568 100644 --- a/server/sonar-web/src/main/js/apps/issues/app-context.js +++ b/server/sonar-web/src/main/js/apps/issues/app-context.js @@ -1,4 +1,6 @@ define([ + 'backbone', + 'backbone.marionette', './models/state', './layout', './models/issues', @@ -10,19 +12,19 @@ define([ './workspace-header-view', './facets-view', './helpers/format-facet-value' -], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView, - FacetsView) { +], function (Backbone, Marionette, State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, + WorkspaceHeaderView, FacetsView) { var $ = jQuery, App = new Marionette.Application(), init = function (options) { - this.config = options.config; + this.options = options; this.state = new State({ isContext: true, - contextQuery: { componentUuids: options.config.resource }, - contextComponentUuid: options.config.resource, - contextComponentName: options.config.resourceName, - contextComponentQualifier: options.config.resourceQualifier + contextQuery: { componentUuids: options.component.uuid }, + contextComponentUuid: options.component.uuid, + contextComponentName: options.component.name, + contextComponentQualifier: options.component.qualifier }); this.updateContextFacets(); this.list = new Issues(); @@ -62,7 +64,7 @@ define([ }; App.getContextQuery = function () { - return { componentUuids: this.config.resource }; + return { componentUuids: this.options.component.uuid }; }; App.getRestrictedFacets = function () { @@ -81,15 +83,13 @@ define([ facetsFromServer = this.state.get('facetsFromServer'); return this.state.set({ facets: facets, - allFacets: _.difference(allFacets, this.getRestrictedFacets()[this.config.resourceQualifier]), - facetsFromServer: _.difference(facetsFromServer, this.getRestrictedFacets()[this.config.resourceQualifier]) + allFacets: _.difference(allFacets, this.getRestrictedFacets()[this.options.component.qualifier]), + facetsFromServer: _.difference(facetsFromServer, this.getRestrictedFacets()[this.options.component.qualifier]) }); }; App.on('start', function (options) { - $.when(window.requestMessages()).done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/issues/app.js b/server/sonar-web/src/main/js/apps/issues/app.js index 12e5671c5c3..f07102efcf7 100644 --- a/server/sonar-web/src/main/js/apps/issues/app.js +++ b/server/sonar-web/src/main/js/apps/issues/app.js @@ -1,4 +1,6 @@ define([ + 'backbone', + 'backbone.marionette', './models/state', './layout', './models/issues', @@ -11,8 +13,8 @@ define([ './facets-view', './filters-view', './helpers/format-facet-value' -], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView, - FacetsView, FiltersView) { +], function (Backbone, Marionette, State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, + WorkspaceHeaderView, FacetsView, FiltersView) { var $ = jQuery, App = new Marionette.Application(), @@ -61,9 +63,7 @@ define([ }; App.on('start', function (options) { - $.when(window.requestMessages()).done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js b/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js index 8792113e213..43b60af89e9 100644 --- a/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js +++ b/server/sonar-web/src/main/js/apps/issues/component-viewer/main.js @@ -36,7 +36,7 @@ define([ if (!selectedIssueView) { return; } - return selectedIssueView.find('.js-issue-' + action).click(); + selectedIssueView.find('.js-issue-' + action).click(); }; key('up', 'componentViewer', function () { that.options.app.controller.selectPrev(); diff --git a/server/sonar-web/src/main/js/apps/issues/controller.js b/server/sonar-web/src/main/js/apps/issues/controller.js index 16f5dc53c93..c0467e9b6a1 100644 --- a/server/sonar-web/src/main/js/apps/issues/controller.js +++ b/server/sonar-web/src/main/js/apps/issues/controller.js @@ -1,8 +1,9 @@ define([ + 'backbone', 'components/navigator/controller', './component-viewer/main', './workspace-home-view' -], function (Controller, ComponentViewer, HomeView) { +], function (Backbone, Controller, ComponentViewer, HomeView) { var $ = jQuery, FIELDS = 'component,componentId,project,subProject,rule,status,resolution,author,reporter,assignee,debt,line,' + diff --git a/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js index 3645b7215d6..26fa0f3899c 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js @@ -9,7 +9,7 @@ define([ template: Templates['issues-assignee-facet'], getUrl: function () { - return baseUrl + '/api/users/search'; + return window.baseUrl + '/api/users/search'; }, prepareAjaxSearch: function () { 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 ee987a3d067..7bf8f5e30de 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 @@ -4,7 +4,7 @@ define([ return CustomValuesFacet.extend({ getUrl: function () { - return baseUrl + '/api/issues/authors'; + return window.baseUrl + '/api/issues/authors'; }, prepareSearch: function () { @@ -13,13 +13,13 @@ define([ 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: { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/base-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/base-facet.js index 923e1d4e6d1..8cb5f444520 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/base-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/base-facet.js @@ -16,7 +16,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { state: this.options.app.state.toJSON() }); } 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 11b3aebdd74..0b198e1853c 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 @@ -27,13 +27,13 @@ define([ 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() 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 3418158fba4..f18c712d2f6 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 @@ -4,7 +4,7 @@ define([ return CustomValuesFacet.extend({ getUrl: function () { - return baseUrl + '/api/languages/list'; + return window.baseUrl + '/api/languages/list'; }, prepareSearch: function () { @@ -13,13 +13,13 @@ define([ 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: { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/mode-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/mode-facet.js index 454b4e96803..ac81b8c3b8d 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/mode-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/mode-facet.js @@ -16,7 +16,9 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { mode: this.options.app.state.getFacetMode() }); + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { + mode: this.options.app.state.getFacetMode() + }); } }); 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 429d9e876c2..15e174ebf38 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 @@ -7,9 +7,9 @@ define([ getUrl: function () { var q = this.options.app.state.get('contextComponentQualifier'); if (q === 'VW' || q === 'SVW') { - return baseUrl + '/api/components/search'; + return window.baseUrl + '/api/components/search'; } else { - return baseUrl + '/api/resources/search?f=s2&q=TRK&display_uuid=true'; + return window.baseUrl + '/api/resources/search?f=s2&q=TRK&display_uuid=true'; } }, @@ -29,13 +29,13 @@ define([ 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: { diff --git a/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js index 6340aefe04f..6bbb5c5e8ad 100644 --- a/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js +++ b/server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js @@ -4,7 +4,7 @@ define([ return CustomValuesFacet.extend({ getUrl: function () { - return baseUrl + '/api/users/search'; + return window.baseUrl + '/api/users/search'; }, prepareAjaxSearch: function () { 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 569fcf6c7de..55002f35a9b 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 @@ -4,7 +4,7 @@ define([ return CustomValuesFacet.extend({ prepareSearch: function () { - var url = baseUrl + '/api/rules/search?f=name,langName', + var url = window.baseUrl + '/api/rules/search?f=name,langName', languages = this.options.app.state.get('query').languages; if (languages != null) { url += '&languages=' + languages; @@ -14,13 +14,13 @@ define([ 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: { 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 96a0d85729e..9a70ea7a006 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 @@ -4,7 +4,7 @@ define([ return CustomValuesFacet.extend({ prepareSearch: function () { - var url = baseUrl + '/api/issues/tags?ps=10', + var url = window.baseUrl + '/api/issues/tags?ps=10', tags = this.options.app.state.get('query').tags; if (tags != null) { url += '&tags=' + tags; @@ -14,10 +14,10 @@ define([ 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: { diff --git a/server/sonar-web/src/main/js/apps/issues/filters-view.js b/server/sonar-web/src/main/js/apps/issues/filters-view.js index 03813eff3c0..568402c3582 100644 --- a/server/sonar-web/src/main/js/apps/issues/filters-view.js +++ b/server/sonar-web/src/main/js/apps/issues/filters-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/issues/issue-filter-view.js b/server/sonar-web/src/main/js/apps/issues/issue-filter-view.js index 28a6a86e212..c448fb1f0de 100644 --- a/server/sonar-web/src/main/js/apps/issues/issue-filter-view.js +++ b/server/sonar-web/src/main/js/apps/issues/issue-filter-view.js @@ -12,11 +12,11 @@ define([ var property = $(e.currentTarget).data('property'), value = $(e.currentTarget).data('value'); this.trigger('select', property, value); - this._super(e); + ActionOptionsView.prototype.selectOption.apply(this, arguments); }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), { s: this.model.get('severity') }); } diff --git a/server/sonar-web/src/main/js/apps/issues/layout.js b/server/sonar-web/src/main/js/apps/issues/layout.js index 5dbbcaf1139..3edcb430d41 100644 --- a/server/sonar-web/src/main/js/apps/issues/layout.js +++ b/server/sonar-web/src/main/js/apps/issues/layout.js @@ -1,6 +1,8 @@ define([ + 'backbone.marionette', + '../../components/common/jquery-isolated-scroll', './templates' -], function () { +], function (Marionette) { var $ = jQuery; return Marionette.LayoutView.extend({ diff --git a/server/sonar-web/src/main/js/apps/issues/models/filter.js b/server/sonar-web/src/main/js/apps/issues/models/filter.js index aa31f8ab267..d1cbabc4d4a 100644 --- a/server/sonar-web/src/main/js/apps/issues/models/filter.js +++ b/server/sonar-web/src/main/js/apps/issues/models/filter.js @@ -1,8 +1,10 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ url: function () { - return baseUrl + '/api/issue_filters/show/' + this.id; + return window.baseUrl + '/api/issue_filters/show/' + this.id; }, parse: function (r) { diff --git a/server/sonar-web/src/main/js/apps/issues/models/filters.js b/server/sonar-web/src/main/js/apps/issues/models/filters.js index bb66327e423..cde0286b159 100644 --- a/server/sonar-web/src/main/js/apps/issues/models/filters.js +++ b/server/sonar-web/src/main/js/apps/issues/models/filters.js @@ -1,6 +1,7 @@ define([ + 'backbone', './filter' -], function (Filter) { +], function (Backbone, Filter) { return Backbone.Collection.extend({ model: Filter diff --git a/server/sonar-web/src/main/js/apps/issues/models/issue.js b/server/sonar-web/src/main/js/apps/issues/models/issue.js index 6266434fa23..2a096b4db32 100644 --- a/server/sonar-web/src/main/js/apps/issues/models/issue.js +++ b/server/sonar-web/src/main/js/apps/issues/models/issue.js @@ -8,7 +8,7 @@ define([ keepFields.forEach(function (field) { attrs[field] = this.get(field); }.bind(this)); - return this._super(attrs, options); + Issue.prototype.reset.call(this, attrs, options); } }); diff --git a/server/sonar-web/src/main/js/apps/issues/models/issues.js b/server/sonar-web/src/main/js/apps/issues/models/issues.js index aca2e2ac2bf..7f613e0adb7 100644 --- a/server/sonar-web/src/main/js/apps/issues/models/issues.js +++ b/server/sonar-web/src/main/js/apps/issues/models/issues.js @@ -1,12 +1,13 @@ define([ + 'backbone', './issue' -], function (Issue) { +], function (Backbone, Issue) { return Backbone.Collection.extend({ model: Issue, url: function () { - return baseUrl + '/api/issues/search'; + return window.baseUrl + '/api/issues/search'; }, _injectRelational: function (issue, source, baseField, lookupField) { diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js index 928b4b42c5f..5fc1867969e 100644 --- a/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js +++ b/server/sonar-web/src/main/js/apps/issues/workspace-header-view.js @@ -24,7 +24,7 @@ define([ }, onDestroy: function () { - this._super(); + WorkspaceHeaderView.prototype.onDestroy.apply(this, arguments); window.onBulkIssues = this._onBulkIssues; }, @@ -51,7 +51,7 @@ define([ render: function () { if (!this._suppressUpdate) { - this._super(); + WorkspaceHeaderView.prototype.render.apply(this, arguments); } }, @@ -105,7 +105,7 @@ define([ selectedCount = this.options.app.list.where({ selected: true }).length, allSelected = issuesCount > 0 && issuesCount === selectedCount, someSelected = !allSelected && selectedCount > 0; - return _.extend(this._super(), { + return _.extend(WorkspaceHeaderView.prototype.serializeData.apply(this, arguments), { selectedCount: selectedCount, allSelected: allSelected, someSelected: someSelected diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js index 942e86e4ba7..c501d4af3cf 100644 --- a/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js +++ b/server/sonar-web/src/main/js/apps/issues/workspace-home-view.js @@ -1,21 +1,23 @@ define([ + 'backbone', + 'backbone.marionette', './templates' -], function () { +], function (Backbone, Marionette) { var $ = jQuery; Handlebars.registerHelper('issuesHomeLink', function (property, value) { - return baseUrl + '/issues/search#resolved=false|createdInLast=1w|' + + return window.baseUrl + '/issues/search#resolved=false|createdInLast=1w|' + property + '=' + (encodeURIComponent(value)); }); Handlebars.registerHelper('myIssuesHomeLink', function (property, value) { - return baseUrl + '/issues/search#resolved=false|createdInLast=1w|assignees=__me__|' + + return window.baseUrl + '/issues/search#resolved=false|createdInLast=1w|assignees=__me__|' + property + '=' + (encodeURIComponent(value)); }); Handlebars.registerHelper('issueFilterHomeLink', function (id) { - return baseUrl + '/issues/search#id=' + id; + return window.baseUrl + '/issues/search#id=' + id; }); return Marionette.ItemView.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 ada57f15a2d..4b85cce7b32 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 @@ -1,10 +1,12 @@ -define(function () { +define([ + 'backbone.marionette' +], function (Marionette) { return 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/main/app.jsx b/server/sonar-web/src/main/js/apps/main/app.jsx new file mode 100644 index 00000000000..25c2d1dff30 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/main/app.jsx @@ -0,0 +1,166 @@ +import $ from 'jquery'; +import {getCurrentUser} from '../../api/users'; +import {component} from '../../api/navigation'; +import NavApp from '../nav/app'; + +const APP_URL_MAPPING = { + '': 'dashboard/app', + 'account': 'account/app', + 'api_documentation': 'api-documentation/app', + 'coding_rules': 'coding-rules/app', + 'component_issues': 'issues/app-context', + 'component': 'source-viewer/app', + 'computation': 'computation/app', + 'custom_measures': 'custom-measures/app', + 'dashboard': 'dashboard/app', + 'drilldown': 'drilldown/app', + 'groups': 'groups/app', + 'issues': 'issues/app', + 'maintenance': { name: 'maintenance/app', options: { setup: false } }, + 'markdown': 'markdown/app', + 'measures': 'measures/app', + 'metrics': 'metrics/app', + 'overview': 'overview/app', + 'permission_templates': 'select-list/app', + 'profiles': 'quality-profiles/app', + 'project_roles': 'select-list/app', + 'provisioning': 'provisioning/app', + 'quality_gates': 'quality-gates/app', + 'roles/global': 'global-permissions/app', + 'roles/projects': 'project-permissions/app', + 'setup': { name: 'maintenance/app', options: { setup: true } }, + 'updatecenter': 'update-center/app', + 'users': 'users/app' +}; + + +class App { + constructor(options) { + this.user = null; + this.component = null; + this.options = options; + } + + /** + * Start the Main App + */ + start() { + App.initLanguage(this.options.lang); + $.when( + window.requestMessages(), + this.loadUserDetails(), + this.loadComponentDetails() + ).done(() => { + this.startNav(); + this.startPageApp(); + }); + } + + + /** + * Start the Navigation App + */ + startNav() { + NavApp.start(_.extend({}, this.options, { user: this.user })); + } + + + /** + * Start an App for the current page + */ + startPageApp() { + let app = this.getApp(); + app && this.startApp(app); + } + + + /** + * Start an App with a given name + * @param {object} app + */ + startApp(app) { + let appScript = 'apps/' + app.name; + require([appScript], App => { + let appOptions = { + el: '#content', + component: this.options.component, + user: this.user, + urlRoot: app.urlRoot + }; + _.extend(appOptions, app.options); + App.start(appOptions); + }); + } + + + /** + * Initialize formatting libraries for a given language + * @param {string} lang + */ + static initLanguage(lang) { + moment.lang(lang); + numeral.language(lang); + } + + + /** + * Get a part of a page URL representing a App name + * @returns {string} + */ + static getAppPath() { + let path = window.location.pathname; + let relativePath = path.substr(window.baseUrl.length); + return relativePath.substr(1) + '/'; + } + + + /** + * Try to get a App name for the current page + * @returns {null|object} + */ + getApp() { + let appPath = App.getAppPath(); + let matchedUrl = _.find(Object.keys(APP_URL_MAPPING), urlPrefix => { + let test = urlPrefix + '/'; + return appPath.indexOf(test) === 0; + }); + if (matchedUrl == null) { + return null; + } + let app = APP_URL_MAPPING[matchedUrl]; + return { + name: typeof app === 'string' ? app : app.name, + options: typeof app === 'string' ? {} : app.options, + urlRoot: window.baseUrl + '/' + matchedUrl + }; + } + + + /** + * Load current component details + * @returns {jqXHR} + */ + loadComponentDetails() { + if (!this.options.componentKey) { + return $.Deferred().resolve().promise(); + } + return component(this.options.componentKey).done(component => { + this.options.component = component; + this.options.component.qualifier = _.last(component.breadcrumbs).qualifier; + }); + } + + + /** + * Load current user details + * @returns {jqXHR} + */ + loadUserDetails() { + return getCurrentUser().done(user => { + this.user = user; + this.user.isAdmin = user.permissions.global.indexOf('admin') !== -1; + }); + } +} + +export default App; diff --git a/server/sonar-web/src/main/js/apps/maintenance/app.js b/server/sonar-web/src/main/js/apps/maintenance/app.js index cc7b016bef0..52fc0c26e1e 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/app.js +++ b/server/sonar-web/src/main/js/apps/maintenance/app.js @@ -1,6 +1,8 @@ define([ + 'backbone', + 'backbone.marionette', './main-view' -], function (MainView) { +], function (Backbone, Marionette, MainView) { var App = new Marionette.Application(); diff --git a/server/sonar-web/src/main/js/apps/maintenance/main-view.js b/server/sonar-web/src/main/js/apps/maintenance/main-view.js index 47b380973da..8f7d0eea860 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/main-view.js +++ b/server/sonar-web/src/main/js/apps/maintenance/main-view.js @@ -1,6 +1,8 @@ define([ + 'backbone', + 'backbone.marionette', './templates' -], function () { +], function (Backbone, Marionette) { var $ = jQuery; @@ -15,7 +17,7 @@ define([ var that = this; this.requestOptions = { type: 'GET', - url: baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') + url: window.baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') }; setInterval(function () { that.refresh(); @@ -55,7 +57,9 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { setup: this.options.setup }); + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + setup: this.options.setup + }); } }); diff --git a/server/sonar-web/src/main/js/apps/markdown/app.js b/server/sonar-web/src/main/js/apps/markdown/app.js index 80215acba17..0941401c0ad 100644 --- a/server/sonar-web/src/main/js/apps/markdown/app.js +++ b/server/sonar-web/src/main/js/apps/markdown/app.js @@ -1,23 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(['./markdown-help-view'], function (MarkdownView) { +define([ + 'backbone.marionette', + './markdown-help-view' +], function (Marionette, MarkdownView) { var App = new Marionette.Application(); diff --git a/server/sonar-web/src/main/js/apps/markdown/markdown-help-view.js b/server/sonar-web/src/main/js/apps/markdown/markdown-help-view.js index 050128861bd..68426edcb19 100644 --- a/server/sonar-web/src/main/js/apps/markdown/markdown-help-view.js +++ b/server/sonar-web/src/main/js/apps/markdown/markdown-help-view.js @@ -1,23 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(['./templates'], function () { +define([ + 'backbone.marionette', + './templates' +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['markdown-help'] diff --git a/server/sonar-web/src/main/js/apps/measures/app.js b/server/sonar-web/src/main/js/apps/measures/app.js index d5f3110dbc5..ad43571ffec 100644 --- a/server/sonar-web/src/main/js/apps/measures/app.js +++ b/server/sonar-web/src/main/js/apps/measures/app.js @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ define([ + 'backbone.marionette', './measures-filter-bar', 'components/navigator/filters/base-filters', 'components/navigator/filters/checkbox-filters', @@ -28,7 +29,7 @@ define([ 'components/navigator/filters/string-filters', 'components/navigator/filters/metric-filters' ], - function (FilterBar, BaseFilters, CheckboxFilterView, ChoiceFilters, AjaxSelectFilters, FavoriteFilters, + function (Marionette, FilterBar, BaseFilters, CheckboxFilterView, ChoiceFilters, AjaxSelectFilters, FavoriteFilters, RangeFilters, StringFilterView, MetricFilterView) { var NavigatorApp = new Marionette.Application(), diff --git a/server/sonar-web/src/main/js/apps/metrics/app.js b/server/sonar-web/src/main/js/apps/metrics/app.js index 4e42d95a09d..832f72bcd02 100644 --- a/server/sonar-web/src/main/js/apps/metrics/app.js +++ b/server/sonar-web/src/main/js/apps/metrics/app.js @@ -1,10 +1,11 @@ define([ + 'backbone.marionette', './layout', './metrics', './header-view', './list-view', './list-footer-view' -], function (Layout, Metrics, HeaderView, ListView, ListFooterView) { +], function (Marionette, Layout, Metrics, HeaderView, ListView, ListFooterView) { var $ = jQuery, App = new Marionette.Application(), @@ -54,7 +55,7 @@ define([ }; App.on('start', function (options) { - $.when(window.requestMessages(), App.requestDomains(), App.requestTypes()).done(function () { + $.when(App.requestDomains(), App.requestTypes()).done(function () { init.call(App, options); }); }); diff --git a/server/sonar-web/src/main/js/apps/metrics/delete-view.js b/server/sonar-web/src/main/js/apps/metrics/delete-view.js index 8719b9fdb3a..2f8bd2a7222 100644 --- a/server/sonar-web/src/main/js/apps/metrics/delete-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/delete-view.js @@ -6,8 +6,8 @@ define([ return ModalForm.extend({ template: Templates['metrics-delete'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, diff --git a/server/sonar-web/src/main/js/apps/metrics/form-view.js b/server/sonar-web/src/main/js/apps/metrics/form-view.js index 03e66f715b6..18dbdbbf174 100644 --- a/server/sonar-web/src/main/js/apps/metrics/form-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/form-view.js @@ -10,7 +10,7 @@ define([ onRender: function () { var that = this; - this._super(); + ModalForm.prototype.onRender.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); this.$('#create-metric-domain').select2({ width: '250px', @@ -36,17 +36,17 @@ define([ }, onDestroy: function () { - this._super(); + ModalForm.prototype.onDestroy.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), { domains: this.options.domains, types: this.options.types }); diff --git a/server/sonar-web/src/main/js/apps/metrics/header-view.js b/server/sonar-web/src/main/js/apps/metrics/header-view.js index 78a9b0da0d0..bc5f6891617 100644 --- a/server/sonar-web/src/main/js/apps/metrics/header-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/header-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './create-view', './templates' -], function (CreateView) { +], function (Marionette, CreateView) { return Marionette.ItemView.extend({ template: Templates['metrics-header'], diff --git a/server/sonar-web/src/main/js/apps/metrics/layout.js b/server/sonar-web/src/main/js/apps/metrics/layout.js index 9575307d96f..59ef53f5c3c 100644 --- a/server/sonar-web/src/main/js/apps/metrics/layout.js +++ b/server/sonar-web/src/main/js/apps/metrics/layout.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['metrics-layout'], diff --git a/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js b/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js index 932dfd6d35f..806ddc9c863 100644 --- a/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['metrics-list-footer'], @@ -23,7 +24,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { total: this.collection.total, count: this.collection.length, more: this.collection.hasMore() diff --git a/server/sonar-web/src/main/js/apps/metrics/list-item-view.js b/server/sonar-web/src/main/js/apps/metrics/list-item-view.js index c6989e3b7b3..c1b84f3baca 100644 --- a/server/sonar-web/src/main/js/apps/metrics/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/list-item-view.js @@ -1,8 +1,9 @@ define([ + 'backbone.marionette', './update-view', './delete-view', './templates' -], function (UpdateView, DeleteView) { +], function (Marionette, UpdateView, DeleteView) { return Marionette.ItemView.extend({ tagName: 'li', diff --git a/server/sonar-web/src/main/js/apps/metrics/list-view.js b/server/sonar-web/src/main/js/apps/metrics/list-view.js index b015c65d966..8eca5ef012f 100644 --- a/server/sonar-web/src/main/js/apps/metrics/list-view.js +++ b/server/sonar-web/src/main/js/apps/metrics/list-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './list-item-view', './templates' -], function (ListItemView) { +], function (Marionette, ListItemView) { return Marionette.CollectionView.extend({ tagName: 'ul', diff --git a/server/sonar-web/src/main/js/apps/metrics/metric.js b/server/sonar-web/src/main/js/apps/metrics/metric.js index cb160c882d0..8a2c3e82e49 100644 --- a/server/sonar-web/src/main/js/apps/metrics/metric.js +++ b/server/sonar-web/src/main/js/apps/metrics/metric.js @@ -1,10 +1,12 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ idAttribute: 'id', urlRoot: function () { - return baseUrl + '/api/metrics'; + return window.baseUrl + '/api/metrics'; }, sync: function (method, model, options) { diff --git a/server/sonar-web/src/main/js/apps/metrics/metrics.js b/server/sonar-web/src/main/js/apps/metrics/metrics.js index 393ebe3c2b1..4ff94e99b29 100644 --- a/server/sonar-web/src/main/js/apps/metrics/metrics.js +++ b/server/sonar-web/src/main/js/apps/metrics/metrics.js @@ -1,12 +1,13 @@ define([ + 'backbone', './metric' -], function (Metric) { +], function (Backbone, Metric) { return Backbone.Collection.extend({ model: Metric, url: function () { - return baseUrl + '/api/metrics/search'; + return window.baseUrl + '/api/metrics/search'; }, parse: function (r) { @@ -20,7 +21,7 @@ define([ var opts = _.defaults(options || {}, { data: {} }); this.q = opts.data.q; opts.data.isCustom = true; - return this._super(opts); + return Backbone.Collection.prototype.fetch.call(this, opts); }, fetchMore: function () { diff --git a/server/sonar-web/src/main/js/apps/nav/app.jsx b/server/sonar-web/src/main/js/apps/nav/app.jsx index 1362bb8976b..04b0f1018fc 100644 --- a/server/sonar-web/src/main/js/apps/nav/app.jsx +++ b/server/sonar-web/src/main/js/apps/nav/app.jsx @@ -5,11 +5,9 @@ import SettingsNav from './settings/settings-nav'; export default { start(options) { - window.requestMessages().done(() => { - this.renderGlobalNav(options); - options.space === 'component' && this.renderComponentNav(options); - options.space === 'settings' && this.renderSettingsNav(options); - }); + this.renderGlobalNav(options); + options.space === 'component' && this.renderComponentNav(options); + options.space === 'settings' && this.renderSettingsNav(options); }, renderGlobalNav(options) { diff --git a/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx b/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx index c50cd53be52..5115a27f73b 100644 --- a/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx +++ b/server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx @@ -13,6 +13,10 @@ const MORE_URLS = ['/dashboards', '/dashboard', '/plugins/resource']; export default React.createClass({ mixins: [DashboardNameMixin, LinksMixin], + getDefaultProps() { + return { conf: {} }; + }, + renderOverviewLink() { const url = `/overview/index?id=${encodeURIComponent(this.props.component.key)}`; return this.renderLink(url, window.t('overview.page'), '/overview'); diff --git a/server/sonar-web/src/main/js/apps/nav/component/component-nav.jsx b/server/sonar-web/src/main/js/apps/nav/component/component-nav.jsx index 855482981d9..fdc8a089e69 100644 --- a/server/sonar-web/src/main/js/apps/nav/component/component-nav.jsx +++ b/server/sonar-web/src/main/js/apps/nav/component/component-nav.jsx @@ -3,47 +3,43 @@ import ComponentNavFavorite from './component-nav-favorite'; import ComponentNavBreadcrumbs from './component-nav-breadcrumbs'; import ComponentNavMeta from './component-nav-meta'; import ComponentNavMenu from './component-nav-menu'; +import RecentHistory from '../../../libs/recent-history'; -let $ = jQuery; +const TOP_LEVEL_QUALIFIERS = ['TRK', 'VW', 'SVW', 'DEV']; export default React.createClass({ - getInitialState() { - return { component: {}, conf: {} }; - }, - componentDidMount() { - this.loadDetails(); + this.addToHistory(); }, - loadDetails() { - const url = `${window.baseUrl}/api/navigation/component`; - const data = { componentKey: this.props.componentKey }; - $.get(url, data).done(r => { - this.setState({ - component: r, - conf: r.configuration || {} - }); - }); + addToHistory() { + let qualifier = _.last(this.props.component.breadcrumbs).qualifier; + if (TOP_LEVEL_QUALIFIERS.indexOf(qualifier) !== -1) { + RecentHistory.add( + this.props.component.key, + this.props.component.name, + qualifier.toLowerCase()); + } }, render() { return ( <div className="container"> <ComponentNavFavorite - component={this.state.component.key} - favorite={this.state.component.isFavorite} - canBeFavorite={this.state.component.canBeFavorite}/> + component={this.props.component.key} + favorite={this.props.component.isFavorite} + canBeFavorite={this.props.component.canBeFavorite}/> <ComponentNavBreadcrumbs - breadcrumbs={this.state.component.breadcrumbs}/> + breadcrumbs={this.props.component.breadcrumbs}/> <ComponentNavMeta - version={this.state.component.version} - snapshotDate={this.state.component.snapshotDate}/> + version={this.props.component.version} + snapshotDate={this.props.component.snapshotDate}/> <ComponentNavMenu - component={this.state.component} - conf={this.state.conf}/> + component={this.props.component} + conf={this.props.component.configuration}/> </div> ); } diff --git a/server/sonar-web/src/main/js/apps/nav/global/global-nav-menu.jsx b/server/sonar-web/src/main/js/apps/nav/global/global-nav-menu.jsx index 6249b8b11fb..1b945c62fcd 100644 --- a/server/sonar-web/src/main/js/apps/nav/global/global-nav-menu.jsx +++ b/server/sonar-web/src/main/js/apps/nav/global/global-nav-menu.jsx @@ -91,7 +91,7 @@ export default React.createClass({ }, renderAdministrationLink() { - if (!window.SS.isUserAdmin) { + if (!this.props.user.isAdmin) { return null; } const url = `${window.baseUrl}/settings`; diff --git a/server/sonar-web/src/main/js/apps/nav/global/global-nav-user.jsx b/server/sonar-web/src/main/js/apps/nav/global/global-nav-user.jsx index d07c9a4d201..64c913461f1 100644 --- a/server/sonar-web/src/main/js/apps/nav/global/global-nav-user.jsx +++ b/server/sonar-web/src/main/js/apps/nav/global/global-nav-user.jsx @@ -1,5 +1,6 @@ import React from 'react'; import Avatar from 'components/shared/avatar'; +import RecentHistory from '../../../libs/recent-history'; export default React.createClass({ renderAuthenticated() { @@ -38,9 +39,7 @@ export default React.createClass({ handleLogout(e) { e.preventDefault(); - if (window.sonarRecentHistory) { - window.sonarRecentHistory.clear(); - } + RecentHistory.clear(); const logoutUrl = `${window.baseUrl}/sessions/logout`; window.location = logoutUrl; }, diff --git a/server/sonar-web/src/main/js/apps/nav/global/search-view.js b/server/sonar-web/src/main/js/apps/nav/global/search-view.js index 233a1dc5f29..ccfe575526b 100644 --- a/server/sonar-web/src/main/js/apps/nav/global/search-view.js +++ b/server/sonar-web/src/main/js/apps/nav/global/search-view.js @@ -1,7 +1,9 @@ define([ + 'backbone', + 'backbone.marionette', 'components/common/selectable-collection-view', '../templates' -], function (SelectableCollectionView) { +], function (Backbone, Marionette, SelectableCollectionView) { var $ = jQuery, @@ -120,7 +122,7 @@ define([ that.favorite = r.map(function (f) { var isFile = ['FIL', 'UTS'].indexOf(f.qualifier) !== -1; return { - url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(f.key) + dashboardParameters(true), + url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(f.key) + window.dashboardParameters(true), name: isFile ? window.collapsedDirFromPath(f.lname) + window.fileFromPath(f.lname) : f.name, icon: 'favorite' }; @@ -133,19 +135,20 @@ define([ var recentHistory = JSON.parse(localStorage.getItem('sonar_recent_history')), history = (recentHistory || []).map(function (historyItem, index) { return { - url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) + dashboardParameters(true), + url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) + + window.dashboardParameters(true), 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 }; }); @@ -155,7 +158,7 @@ define([ search: function (q) { if (q.length < 2) { this.resetResultsToDefault(); - return; + return $.Deferred().resolve().promise(); } var that = this, url = baseUrl + '/api/components/suggestions', @@ -167,7 +170,7 @@ define([ collection.push(_.extend(item, { q: domain.q, extra: index === 0 ? domain.name : null, - url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) + dashboardParameters(true) + url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) + window.dashboardParameters(true) })); }); }); @@ -182,22 +185,22 @@ define([ 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); }, @@ -211,7 +214,7 @@ define([ 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); }, @@ -221,7 +224,7 @@ define([ 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/apps/overview/app.jsx b/server/sonar-web/src/main/js/apps/overview/app.jsx index 475b1c0348f..4f85ebd82f1 100644 --- a/server/sonar-web/src/main/js/apps/overview/app.jsx +++ b/server/sonar-web/src/main/js/apps/overview/app.jsx @@ -6,17 +6,16 @@ const $ = jQuery; export default { start(options) { + _.extend(options, window.overview); $('html').toggleClass('dashboard-page', options.component.hasSnapshot); - window.requestMessages().done(() => { - const el = document.querySelector(options.el); - const inner = options.component.hasSnapshot ? ( - <Main - component={options.component} - gate={options.gate} - measures={options.measures} - leak={options.leak}/> - ) : <Empty/>; - React.render(inner, el); - }); + const el = document.querySelector(options.el); + const inner = options.component.hasSnapshot ? ( + <Main + component={options.component} + gate={options.gate} + measures={options.measures} + leak={options.leak}/> + ) : <Empty/>; + React.render(inner, el); } }; diff --git a/server/sonar-web/src/main/js/apps/project-permissions/app.jsx b/server/sonar-web/src/main/js/apps/project-permissions/app.jsx index 28dc73b7f42..478924e9233 100644 --- a/server/sonar-web/src/main/js/apps/project-permissions/app.jsx +++ b/server/sonar-web/src/main/js/apps/project-permissions/app.jsx @@ -5,9 +5,7 @@ const $ = jQuery; export default { start(options) { - window.requestMessages().done(() => { - var el = document.querySelector(options.el); - React.render(<Main/>, el); - }); + var el = document.querySelector(options.el); + React.render(<Main/>, el); } }; diff --git a/server/sonar-web/src/main/js/apps/project-permissions/groups-view.js b/server/sonar-web/src/main/js/apps/project-permissions/groups-view.js index 5e00efe9b86..5f1ee7bb807 100644 --- a/server/sonar-web/src/main/js/apps/project-permissions/groups-view.js +++ b/server/sonar-web/src/main/js/apps/project-permissions/groups-view.js @@ -8,7 +8,7 @@ define([ template: Templates['project-permissions-groups'], onRender: function () { - this._super(); + Modal.prototype.onRender.apply(this, arguments); new window.SelectList({ el: this.$('#project-permissions-groups'), width: '100%', @@ -35,8 +35,10 @@ define([ }, onDestroy: function () { - this.options.refresh && this.options.refresh(); - this._super(); + if (this.options.refresh) { + this.options.refresh(); + } + Modal.prototype.onDestroy.apply(this, arguments); }, serializeData: function () { diff --git a/server/sonar-web/src/main/js/apps/project-permissions/users-view.js b/server/sonar-web/src/main/js/apps/project-permissions/users-view.js index 5f54a1ad2a9..316c4508d00 100644 --- a/server/sonar-web/src/main/js/apps/project-permissions/users-view.js +++ b/server/sonar-web/src/main/js/apps/project-permissions/users-view.js @@ -8,7 +8,7 @@ define([ template: Templates['project-permissions-users'], onRender: function () { - this._super(); + Modal.prototype.onRender.apply(this, arguments); new window.SelectList({ el: this.$('#project-permissions-users'), width: '100%', @@ -35,14 +35,17 @@ define([ }, onDestroy: function () { - this.options.refresh && this.options.refresh(); - this._super(); + if (this.options.refresh) { + this.options.refresh(); + } + Modal.prototype.onDestroy.apply(this, arguments); }, serializeData: function () { return _.extend(Modal.prototype.serializeData.apply(this, arguments), { projectName: this.options.projectName }) + } }); diff --git a/server/sonar-web/src/main/js/apps/provisioning/app.js b/server/sonar-web/src/main/js/apps/provisioning/app.js index aa754e5ba77..01145ce4957 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/app.js +++ b/server/sonar-web/src/main/js/apps/provisioning/app.js @@ -1,11 +1,12 @@ define([ + 'backbone.marionette', './layout', './projects', './header-view', './search-view', './list-view', './list-footer-view' -], function (Layout, Projects, HeaderView, SearchView, ListView, ListFooterView) { +], function (Marionette, Layout, Projects, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -37,9 +38,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/provisioning/bulk-delete-view.js b/server/sonar-web/src/main/js/apps/provisioning/bulk-delete-view.js index 731e3e163d2..af82066c0ef 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/bulk-delete-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/bulk-delete-view.js @@ -6,8 +6,8 @@ define([ return ModalForm.extend({ template: Templates['provisioning-bulk-delete'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, diff --git a/server/sonar-web/src/main/js/apps/provisioning/delete-view.js b/server/sonar-web/src/main/js/apps/provisioning/delete-view.js index dd503c4b1a4..02b8069b076 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/delete-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/delete-view.js @@ -6,8 +6,8 @@ define([ return ModalForm.extend({ template: Templates['provisioning-delete'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, diff --git a/server/sonar-web/src/main/js/apps/provisioning/form-view.js b/server/sonar-web/src/main/js/apps/provisioning/form-view.js index bb0fc0bcef5..cb301b78997 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/form-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/form-view.js @@ -7,17 +7,17 @@ define([ template: Templates['provisioning-form'], onRender: function () { - this._super(); + ModalForm.prototype.onRender.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onDestroy: function () { - this._super(); + ModalForm.prototype.onDestroy.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); } diff --git a/server/sonar-web/src/main/js/apps/provisioning/header-view.js b/server/sonar-web/src/main/js/apps/provisioning/header-view.js index 37165494eac..c98eb7a12cb 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/header-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/header-view.js @@ -1,8 +1,9 @@ define([ + 'backbone.marionette', './create-view', './bulk-delete-view', './templates' -], function (CreateView, BulkDeleteView) { +], function (Marionette, CreateView, BulkDeleteView) { return Marionette.ItemView.extend({ template: Templates['provisioning-header'], diff --git a/server/sonar-web/src/main/js/apps/provisioning/layout.js b/server/sonar-web/src/main/js/apps/provisioning/layout.js index 31b67e8b774..3fa806b7a46 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/layout.js +++ b/server/sonar-web/src/main/js/apps/provisioning/layout.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['provisioning-layout'], diff --git a/server/sonar-web/src/main/js/apps/provisioning/list-footer-view.js b/server/sonar-web/src/main/js/apps/provisioning/list-footer-view.js index 902b9322372..76176ca4769 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/list-footer-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/list-footer-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['provisioning-list-footer'], @@ -23,7 +24,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { total: this.collection.total, count: this.collection.length, more: this.collection.hasMore() diff --git a/server/sonar-web/src/main/js/apps/provisioning/list-item-view.js b/server/sonar-web/src/main/js/apps/provisioning/list-item-view.js index ead9b009ca3..9940f3f0e0e 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/list-item-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './delete-view', './templates' -], function (DeleteView) { +], function (Marionette, DeleteView) { return Marionette.ItemView.extend({ tagName: 'li', diff --git a/server/sonar-web/src/main/js/apps/provisioning/list-view.js b/server/sonar-web/src/main/js/apps/provisioning/list-view.js index 24878864d30..b56e64f951d 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/list-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/list-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './list-item-view', './templates' -], function (ListItemView) { +], function (Marionette, ListItemView) { return Marionette.CollectionView.extend({ tagName: 'ul', diff --git a/server/sonar-web/src/main/js/apps/provisioning/project.js b/server/sonar-web/src/main/js/apps/provisioning/project.js index fa34df605f2..a2e13d09239 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/project.js +++ b/server/sonar-web/src/main/js/apps/provisioning/project.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ idAttribute: 'uuid', @@ -8,7 +10,7 @@ define(function () { }, urlRoot: function () { - return baseUrl + '/api/projects'; + return window.baseUrl + '/api/projects'; }, sync: function (method, model, options) { diff --git a/server/sonar-web/src/main/js/apps/provisioning/projects.js b/server/sonar-web/src/main/js/apps/provisioning/projects.js index 05a59f822af..51697b78fc8 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/projects.js +++ b/server/sonar-web/src/main/js/apps/provisioning/projects.js @@ -1,12 +1,13 @@ define([ + 'backbone', './project' -], function (Project) { +], function (Backbone, Project) { return Backbone.Collection.extend({ model: Project, url: function () { - return baseUrl + '/api/projects/provisioned'; + return window.baseUrl + '/api/projects/provisioned'; }, parse: function (r) { @@ -19,7 +20,7 @@ define([ fetch: function (options) { var d = (options && options.data) || {}; this.q = d.q; - return this._super(options); + return Backbone.Collection.prototype.fetch.apply(this, arguments); }, fetchMore: function () { diff --git a/server/sonar-web/src/main/js/apps/provisioning/search-view.js b/server/sonar-web/src/main/js/apps/provisioning/search-view.js index 55c0fafc4fb..5f10d839e8a 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/search-view.js +++ b/server/sonar-web/src/main/js/apps/provisioning/search-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['provisioning-search'], @@ -90,7 +91,7 @@ define([ selectedCount = this.collection.where({ selected: true }).length, allSelected = projectsCount > 0 && projectsCount === selectedCount, someSelected = !allSelected && selectedCount > 0; - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { selectedCount: selectedCount, allSelected: allSelected, someSelected: someSelected diff --git a/server/sonar-web/src/main/js/apps/quality-gates/actions-view.js b/server/sonar-web/src/main/js/apps/quality-gates/actions-view.js index 156c7d88104..44013fbc930 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/actions-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/actions-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './create-view', './templates' -], function (CreateView) { +], function (Marionette, CreateView) { return Marionette.ItemView.extend({ template: Templates['quality-gate-actions'], diff --git a/server/sonar-web/src/main/js/apps/quality-gates/app.js b/server/sonar-web/src/main/js/apps/quality-gates/app.js index 6f939c9aa24..1c8f38fea0d 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/app.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/app.js @@ -1,11 +1,13 @@ define([ + 'backbone', + 'backbone.marionette', './gates', './gates-view', './actions-view', './router', './layout', './controller' -], function (Gates, GatesView, ActionsView, Router, Layout, Controller) { +], function (Backbone, Marionette, Gates, GatesView, ActionsView, Router, Layout, Controller) { var $ = jQuery, App = new Marionette.Application(); @@ -52,7 +54,7 @@ define([ }); App.on('start', function (options) { - $.when(window.requestMessages(), appXHR).done(function () { + $.when(appXHR).done(function () { init.call(App, options); }); }); diff --git a/server/sonar-web/src/main/js/apps/quality-gates/condition.js b/server/sonar-web/src/main/js/apps/quality-gates/condition.js index 9ca451ee5a0..bb14f8226c0 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/condition.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/condition.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ @@ -7,7 +9,7 @@ define(function () { }, url: function () { - return baseUrl + '/api/qualitygates'; + return window.baseUrl + '/api/qualitygates'; }, createUrl: function () { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/conditions.js b/server/sonar-web/src/main/js/apps/quality-gates/conditions.js index 49cbb23f069..08d1cb52133 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/conditions.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/conditions.js @@ -1,6 +1,7 @@ define([ + 'backbone', './condition' -], function (Condition) { +], function (Backbone, Condition) { return Backbone.Collection.extend({ model: Condition, diff --git a/server/sonar-web/src/main/js/apps/quality-gates/controller.js b/server/sonar-web/src/main/js/apps/quality-gates/controller.js index 890adc1ad8b..90b1c4b0d9f 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/controller.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/controller.js @@ -1,8 +1,9 @@ define([ + 'backbone.marionette', './gate', './details-view', './header-view' -], function (Gate, DetailsView, HeaderView) { +], function (Marionette, Gate, DetailsView, HeaderView) { return Marionette.Controller.extend({ diff --git a/server/sonar-web/src/main/js/apps/quality-gates/copy-view.js b/server/sonar-web/src/main/js/apps/quality-gates/copy-view.js index fdd6c974cf8..012683d9ee8 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/copy-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/copy-view.js @@ -7,7 +7,7 @@ define([ prepareRequest: function () { var that = this; - var url = baseUrl + '/api/qualitygates/copy', + var url = window.baseUrl + '/api/qualitygates/copy', name = this.$('#quality-gate-form-name').val(), options = { url: url, diff --git a/server/sonar-web/src/main/js/apps/quality-gates/create-view.js b/server/sonar-web/src/main/js/apps/quality-gates/create-view.js index f58863ba315..acb0cc5e5e3 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/create-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/create-view.js @@ -7,7 +7,7 @@ define([ prepareRequest: function () { var that = this; - var url = baseUrl + '/api/qualitygates/create', + var url = window.baseUrl + '/api/qualitygates/create', name = this.$('#quality-gate-form-name').val(), options = { url: url, diff --git a/server/sonar-web/src/main/js/apps/quality-gates/details-view.js b/server/sonar-web/src/main/js/apps/quality-gates/details-view.js index 9af1b38e65e..6451104db2c 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/details-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/details-view.js @@ -1,9 +1,10 @@ define([ + 'backbone.marionette', './conditions', './gate-conditions-view', './gate-projects-view', './templates' -], function (Conditions, DetailConditionsView, ProjectsView) { +], function (Marionette, Conditions, DetailConditionsView, ProjectsView) { return Marionette.LayoutView.extend({ template: Templates['quality-gate-detail'], diff --git a/server/sonar-web/src/main/js/apps/quality-gates/form-view.js b/server/sonar-web/src/main/js/apps/quality-gates/form-view.js index 9b61f400bf3..6d696825899 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/form-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/form-view.js @@ -1,8 +1,9 @@ define([ + 'backbone', 'components/common/modal-form', './gate', './templates' -], function (ModalForm, Gate) { +], function (Backbone, ModalForm, Gate) { return ModalForm.extend({ template: Templates['quality-gate-form'], 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 0dfbea0ab17..7d9bbc741eb 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 @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './gate-conditions-delete-view', './templates' -], function (DeleteConditionView) { +], function (Marionette, DeleteConditionView) { return Marionette.ItemView.extend({ tagName: 'tr', @@ -90,7 +91,7 @@ define([ 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-delete-view.js b/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-delete-view.js index c8ed23a2883..eaf001b0658 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-delete-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-delete-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', 'components/common/modal-form', './templates' -], function (ModalForm) { +], function (Marionette, ModalForm) { return ModalForm.extend({ template: Templates['quality-gates-condition-delete'], diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-empty-view.js b/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-empty-view.js index 03390ac7a89..5bab8c1ff29 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-empty-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-empty-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ tagName: 'tr', 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 b0c0857cc95..5eb29360449 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 @@ -1,9 +1,10 @@ define([ + 'backbone.marionette', './condition', './gate-condition-view', './gate-conditions-empty-view', './templates' -], function (Condition, ConditionView, ConditionsEmptyView) { +], function (Marionette, Condition, ConditionView, ConditionsEmptyView) { return Marionette.CompositeView.extend({ template: Templates['quality-gate-detail-conditions'], @@ -34,7 +35,7 @@ define([ this.ui.metricSelect.select2({ allowClear: false, width: '250px', - placeholder: t('alerts.select_metric') + placeholder: window.t('alerts.select_metric') }); }, 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 c188c473be5..5337fad8c52 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 @@ -1,13 +1,15 @@ define([ + 'backbone.marionette', 'components/common/select-list', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['quality-gate-detail-projects'], onRender: function () { if (!this.model.isDefault()) { + //noinspection Eslint new window.SelectList({ el: this.$('#select-list-projects'), width: '100%', @@ -16,23 +18,23 @@ define([ format: function (item) { return item.name; }, - searchUrl: baseUrl + '/api/qualitygates/search?gateId=' + this.model.id, - selectUrl: baseUrl + '/api/qualitygates/select', - deselectUrl: baseUrl + '/api/qualitygates/deselect', + searchUrl: window.baseUrl + '/api/qualitygates/search?gateId=' + this.model.id, + selectUrl: window.baseUrl + '/api/qualitygates/select', + deselectUrl: window.baseUrl + '/api/qualitygates/deselect', extra: { gateId: this.model.id }, 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') } }); } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gate-view.js b/server/sonar-web/src/main/js/apps/quality-gates/gate-view.js index 30036a3c313..c9fdb2ba12e 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gate-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gate-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ tagName: 'a', diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gate.js b/server/sonar-web/src/main/js/apps/quality-gates/gate.js index 54b4e6ce13c..5bcda8336b1 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gate.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gate.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ @@ -7,7 +9,7 @@ define(function () { }, url: function () { - return baseUrl + '/api/qualitygates'; + return window.baseUrl + '/api/qualitygates'; }, showUrl: function () { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gates-view.js b/server/sonar-web/src/main/js/apps/quality-gates/gates-view.js index cd36c381a39..2e58b9466f9 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gates-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gates-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './gate-view', './templates' -], function (ItemView) { +], function (Marionette, ItemView) { return Marionette.CompositeView.extend({ className: 'list-group', diff --git a/server/sonar-web/src/main/js/apps/quality-gates/gates.js b/server/sonar-web/src/main/js/apps/quality-gates/gates.js index d33b35bcfe5..55c6d681084 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/gates.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/gates.js @@ -1,12 +1,13 @@ define([ + 'backbone', './gate' -], function (Gate) { +], function (Backbone, Gate) { return Backbone.Collection.extend({ model: Gate, url: function () { - return baseUrl + '/api/qualitygates/list'; + return window.baseUrl + '/api/qualitygates/list'; }, parse: function (r) { diff --git a/server/sonar-web/src/main/js/apps/quality-gates/header-view.js b/server/sonar-web/src/main/js/apps/quality-gates/header-view.js index b86b2c9ba62..dd6bea9ee74 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/header-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/header-view.js @@ -1,9 +1,10 @@ define([ + 'backbone.marionette', './rename-view', './copy-view', './delete-view', './templates' -], function (RenameView, CopyView, DeleteView) { +], function (Marionette, RenameView, CopyView, DeleteView) { return Marionette.ItemView.extend({ template: Templates['quality-gate-detail-header'], diff --git a/server/sonar-web/src/main/js/apps/quality-gates/intro-view.js b/server/sonar-web/src/main/js/apps/quality-gates/intro-view.js index c9588a3d48f..83d6b354d13 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/intro-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/intro-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['quality-gates-intro'] diff --git a/server/sonar-web/src/main/js/apps/quality-gates/layout.js b/server/sonar-web/src/main/js/apps/quality-gates/layout.js index db02143caa6..bee18432f0c 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/layout.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/layout.js @@ -1,7 +1,9 @@ define([ + 'backbone.marionette', './intro-view', + '../../components/common/jquery-isolated-scroll', './templates' -], function (IntroView) { +], function (Marionette, IntroView) { return Marionette.LayoutView.extend({ template: Templates['quality-gates-layout'], diff --git a/server/sonar-web/src/main/js/apps/quality-gates/rename-view.js b/server/sonar-web/src/main/js/apps/quality-gates/rename-view.js index d9b5946653a..29db22d6fa4 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/rename-view.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/rename-view.js @@ -7,7 +7,7 @@ define([ prepareRequest: function () { var that = this; - var url = baseUrl + '/api/qualitygates/rename', + var url = window.baseUrl + '/api/qualitygates/rename', name = this.$('#quality-gate-form-name').val(), options = { url: url, diff --git a/server/sonar-web/src/main/js/apps/quality-gates/router.js b/server/sonar-web/src/main/js/apps/quality-gates/router.js index 582c47361d5..35a41f33864 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/router.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/router.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Router.extend({ routes: { diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/actions-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/actions-view.js index fc107d10cef..9aad03fa56b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/actions-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/actions-view.js @@ -1,28 +1,10 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './create-profile-view', './restore-profile-view', './restore-built-in-profiles-view', './templates' -], function (CreateProfileView, RestoreProfileView, RestoreBuiltInProfilesView) { +], function (Marionette, CreateProfileView, RestoreProfileView, RestoreBuiltInProfilesView) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/app.js b/server/sonar-web/src/main/js/apps/quality-profiles/app.js index cd94804cb03..c506cb2a56d 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/app.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/app.js @@ -1,21 +1,22 @@ define([ + 'backbone', + 'backbone.marionette', './router', './controller', './layout', './profiles', './actions-view', './profiles-view' -], function (Router, Controller, Layout, Profiles, ActionsView, ProfilesView) { +], function (Backbone, Marionette, Router, Controller, Layout, Profiles, ActionsView, ProfilesView) { var $ = jQuery, App = new Marionette.Application(), - requestUser = $.get(baseUrl + '/api/users/current').done(function (r) { - App.canWrite = r.permissions.global.indexOf('profileadmin') !== -1; - }), requestExporters = $.get(baseUrl + '/api/qualityprofiles/exporters').done(function (r) { App.exporters = r.exporters; }), init = function (options) { + App.canWrite = options.user.permissions.global.indexOf('profileadmin') !== -1; + // Layout this.layout = new Layout({ el: options.el }); this.layout.render(); @@ -52,7 +53,7 @@ define([ }; App.on('start', function (options) { - $.when(window.requestMessages(), requestUser, requestExporters).done(function () { + $.when(requestExporters).done(function () { init.call(App, options); }); }); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/change-profile-parent-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/change-profile-parent-view.js index a0813a661c9..d694679452a 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/change-profile-parent-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/change-profile-parent-view.js @@ -1,26 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', 'components/common/modal-form', './templates' -], function (ModalFormView) { +], function (Marionette, ModalFormView) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/controller.js b/server/sonar-web/src/main/js/apps/quality-profiles/controller.js index 987cb0b3728..b3010cb4bd9 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/controller.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/controller.js @@ -1,26 +1,8 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './profile-header-view', './profile-details-view' -], function (ProfileHeaderView, ProfileDetailsView) { +], function (Marionette, ProfileHeaderView, ProfileDetailsView) { var $ = jQuery; 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 d241c123e17..cea70a76069 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 @@ -34,16 +34,16 @@ }); Handlebars.registerHelper('severityChangelog', function (severity) { - var label = '<i class="icon-severity-' + severity.toLowerCase() + '"></i> ' + t('severity', severity), - message = tp('quality_profiles.severity_set_to_x', label); + var label = '<i class="icon-severity-' + severity.toLowerCase() + '"></i> ' + 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/intro-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/intro-view.js index abfb416541b..8b6172ac012 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/intro-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/intro-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['quality-profiles-intro'] diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/layout.js b/server/sonar-web/src/main/js/apps/quality-profiles/layout.js index 44cafd82d32..f83319a72dc 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/layout.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/layout.js @@ -1,26 +1,9 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './intro-view', + '../../components/common/jquery-isolated-scroll', './templates' -], function (IntroView) { +], function (Marionette, IntroView) { return Marionette.LayoutView.extend({ template: Templates['quality-profiles-layout'], diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profile-changelog-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/profile-changelog-view.js index 28838846bba..0a8ab424273 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profile-changelog-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profile-changelog-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['quality-profile-changelog'], diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profile-comparison-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/profile-comparison-view.js index d5f5ea37d4b..9dc9894d166 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profile-comparison-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profile-comparison-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['quality-profile-comparison'], 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 112c5b39b96..e0361b19f93 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 @@ -1,30 +1,12 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './change-profile-parent-view', './profile-changelog-view', './profile-comparison-view', 'components/common/select-list', './helpers', './templates' -], function (ChangeProfileParentView, ProfileChangelogView, ProfileComparisonView) { +], function (Marionette, ChangeProfileParentView, ProfileChangelogView, ProfileComparisonView) { var $ = jQuery; @@ -87,14 +69,14 @@ define([ 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_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') } }); this.listenTo(this.projectsSelectList.collection, 'change:selected', this.onProjectsChange); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profile-header-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/profile-header-view.js index 57a5d310736..2137bebae18 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profile-header-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profile-header-view.js @@ -1,28 +1,10 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './copy-profile-view', './rename-profile-view', './delete-profile-view', './templates' -], function (ProfileCopyView, ProfileRenameView, ProfileDeleteView) { +], function (Marionette, ProfileCopyView, ProfileRenameView, ProfileDeleteView) { var $ = jQuery; @@ -62,7 +44,7 @@ define([ onDeleteClick: function (e) { e.preventDefault(); - this.delete(); + this.deleteProfile(); }, copy: function () { @@ -77,7 +59,7 @@ define([ this.model.trigger('setAsDefault', this.model); }, - delete: function () { + deleteProfile: function () { new ProfileDeleteView({ model: this.model }).render(); }, diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profile-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/profile-view.js index 34de0a2d0c0..1b7b8dfa471 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profile-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profile-view.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ tagName: 'a', diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profile.js b/server/sonar-web/src/main/js/apps/quality-profiles/profile.js index 7315821cf1c..a9b91c3c1c2 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profile.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profile.js @@ -1,23 +1,6 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(function () { +define([ + 'backbone' +], function (Backbone) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profiles-empty-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/profiles-empty-view.js index f4844bfc85f..9ee9388beea 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profiles-empty-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profiles-empty-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ className: 'list-group-item', diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profiles-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/profiles-view.js index 677888f451c..42573bc63b1 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profiles-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profiles-view.js @@ -1,27 +1,9 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone.marionette', './profile-view', './profiles-empty-view', './templates' -], function (ProfileView, ProfilesEmptyView) { +], function (Marionette, ProfileView, ProfilesEmptyView) { return Marionette.CompositeView.extend({ className: 'list-group', diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/profiles.js b/server/sonar-web/src/main/js/apps/quality-profiles/profiles.js index 8b556ce8aa5..a0f93dd496f 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/profiles.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/profiles.js @@ -1,25 +1,7 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ define([ + 'backbone', './profile' -], function (Profile) { +], function (Backbone, Profile) { return Backbone.Collection.extend({ model: Profile, diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/restore-built-in-profiles-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/restore-built-in-profiles-view.js index bd223c261f3..2d39c14761c 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/restore-built-in-profiles-view.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/restore-built-in-profiles-view.js @@ -27,7 +27,7 @@ define([ return ModalFormView.extend({ template: Templates['quality-profiles-restore-built-in-profiles'], - onFormSubmit: function (e) { + onFormSubmit: function () { ModalFormView.prototype.onFormSubmit.apply(this, arguments); this.disableForm(); this.sendRequest(); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/router.js b/server/sonar-web/src/main/js/apps/quality-profiles/router.js index 7970d6d2ea6..a4702143fbf 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/router.js +++ b/server/sonar-web/src/main/js/apps/quality-profiles/router.js @@ -1,23 +1,6 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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. - */ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Router.extend({ routes: { diff --git a/server/sonar-web/src/main/js/apps/select-list/app.js b/server/sonar-web/src/main/js/apps/select-list/app.js new file mode 100644 index 00000000000..5339644f14e --- /dev/null +++ b/server/sonar-web/src/main/js/apps/select-list/app.js @@ -0,0 +1,11 @@ +define([ + '../../components/common/select-list' +], function () { + + return { + start: function () { + // do nothing + } + }; + +}); diff --git a/server/sonar-web/src/main/js/apps/source-viewer/app.js b/server/sonar-web/src/main/js/apps/source-viewer/app.js index 1c6947db3ee..31b6047d152 100644 --- a/server/sonar-web/src/main/js/apps/source-viewer/app.js +++ b/server/sonar-web/src/main/js/apps/source-viewer/app.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', 'components/source-viewer/main' -], function (SourceViewer) { +], function (Marionette, SourceViewer) { var App = new Marionette.Application(), init = function (options) { @@ -8,20 +9,20 @@ define([ var viewer = new SourceViewer(); this.mainRegion.show(viewer); - viewer.open(options.file.uuid); - if (typeof options.file.line === 'number') { + viewer.open(options.component.uuid); + if (window.line) { viewer.on('loaded', function () { viewer - .highlightLine(options.file.line) - .scrollToLine(options.file.line); + .highlightLine(window.line) + .scrollToLine(window.line); }); } }; App.on('start', function (options) { - window.requestMessages().done(function () { + if (options.component) { init.call(App, options); - }); + } }); return App; diff --git a/server/sonar-web/src/main/js/apps/update-center/app.js b/server/sonar-web/src/main/js/apps/update-center/app.js index a866a0c2879..4630c21b4fe 100644 --- a/server/sonar-web/src/main/js/apps/update-center/app.js +++ b/server/sonar-web/src/main/js/apps/update-center/app.js @@ -1,4 +1,6 @@ define([ + 'backbone', + 'backbone.marionette', './layout', './header-view', './search-view', @@ -7,7 +9,7 @@ define([ './controller', './router', './plugins' -], function (Layout, HeaderView, SearchView, ListView, FooterView, Controller, Router, Plugins) { +], function (Backbone, Marionette, Layout, HeaderView, SearchView, ListView, FooterView, Controller, Router, Plugins) { var App = new Marionette.Application(), init = function (options) { @@ -27,7 +29,7 @@ define([ this.controller = new Controller({ collection: this.plugins, state: this.state }); // Router - this.router = new Router({ controller: this.controller}); + this.router = new Router({ controller: this.controller }); // Header this.headerView = new HeaderView({ collection: this.plugins }); @@ -54,9 +56,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/update-center/controller.js b/server/sonar-web/src/main/js/apps/update-center/controller.js index a8f069c9dc0..5aaf9a21e94 100644 --- a/server/sonar-web/src/main/js/apps/update-center/controller.js +++ b/server/sonar-web/src/main/js/apps/update-center/controller.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone.marionette' +], function (Marionette) { return Marionette.Controller.extend({ initialize: function (options) { diff --git a/server/sonar-web/src/main/js/apps/update-center/footer-view.js b/server/sonar-web/src/main/js/apps/update-center/footer-view.js index 2f83d509dc7..58cddde9754 100644 --- a/server/sonar-web/src/main/js/apps/update-center/footer-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/footer-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['update-center-footer'], @@ -10,7 +11,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { total: this.collection.where({ _hidden: false }).length }); } diff --git a/server/sonar-web/src/main/js/apps/update-center/header-view.js b/server/sonar-web/src/main/js/apps/update-center/header-view.js index 99e1095ad7f..1963823c939 100644 --- a/server/sonar-web/src/main/js/apps/update-center/header-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/header-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['update-center-header'], @@ -18,7 +19,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { installing: this.collection._installedCount, uninstalling: this.collection._uninstalledCount }); diff --git a/server/sonar-web/src/main/js/apps/update-center/layout.js b/server/sonar-web/src/main/js/apps/update-center/layout.js index 58e480d16de..5db9c1e5a34 100644 --- a/server/sonar-web/src/main/js/apps/update-center/layout.js +++ b/server/sonar-web/src/main/js/apps/update-center/layout.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['update-center-layout'], diff --git a/server/sonar-web/src/main/js/apps/update-center/list-item-view.js b/server/sonar-web/src/main/js/apps/update-center/list-item-view.js index 67750c343ec..9aab6cb612a 100644 --- a/server/sonar-web/src/main/js/apps/update-center/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/list-item-view.js @@ -1,7 +1,9 @@ define([ + 'backbone', + 'backbone.marionette', './plugin-changelog-view', './templates' -], function (PluginChangelogView) { +], function (Backbone, Marionette, PluginChangelogView) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/update-center/list-view.js b/server/sonar-web/src/main/js/apps/update-center/list-view.js index e188597e511..eb1fe1bc495 100644 --- a/server/sonar-web/src/main/js/apps/update-center/list-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/list-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './list-item-view' -], function (ListItemView) { +], function (Marionette, ListItemView) { return Marionette.CollectionView.extend({ tagName: 'ul', diff --git a/server/sonar-web/src/main/js/apps/update-center/plugin-changelog-view.js b/server/sonar-web/src/main/js/apps/update-center/plugin-changelog-view.js index 9ece2454bb7..bf96fc5ac1b 100644 --- a/server/sonar-web/src/main/js/apps/update-center/plugin-changelog-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/plugin-changelog-view.js @@ -1,5 +1,6 @@ define([ 'components/common/popup', + '../../components/common/jquery-isolated-scroll', './templates' ], function (Popup) { @@ -7,18 +8,18 @@ define([ template: Templates['update-center-plugin-changelog'], onRender: function () { - this._super(); + Popup.prototype.onRender.apply(this, arguments); this.$('.bubble-popup-container').isolatedScroll(); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onClose: function () { - this._super(); + Popup.prototype.onClose.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Popup.prototype.serializeData.apply(this, arguments), { // if there is no status, this is a new plugin // => force COMPATIBLE status status: this.model.get('status') || 'COMPATIBLE' diff --git a/server/sonar-web/src/main/js/apps/update-center/plugin.js b/server/sonar-web/src/main/js/apps/update-center/plugin.js index 697979e4ed0..623e05b6d1d 100644 --- a/server/sonar-web/src/main/js/apps/update-center/plugin.js +++ b/server/sonar-web/src/main/js/apps/update-center/plugin.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ idAttribute: 'key', diff --git a/server/sonar-web/src/main/js/apps/update-center/plugins.js b/server/sonar-web/src/main/js/apps/update-center/plugins.js index 021e124511c..d03988858f4 100644 --- a/server/sonar-web/src/main/js/apps/update-center/plugins.js +++ b/server/sonar-web/src/main/js/apps/update-center/plugins.js @@ -1,6 +1,7 @@ define([ + 'backbone', './plugin' -], function (Plugin) { +], function (Backbone, Plugin) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/apps/update-center/router.js b/server/sonar-web/src/main/js/apps/update-center/router.js index 0a9af1440cc..48f3df055ea 100644 --- a/server/sonar-web/src/main/js/apps/update-center/router.js +++ b/server/sonar-web/src/main/js/apps/update-center/router.js @@ -1,4 +1,6 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Router.extend({ routes: { diff --git a/server/sonar-web/src/main/js/apps/update-center/search-view.js b/server/sonar-web/src/main/js/apps/update-center/search-view.js index b46cf5ce293..8cccae1ae57 100644 --- a/server/sonar-web/src/main/js/apps/update-center/search-view.js +++ b/server/sonar-web/src/main/js/apps/update-center/search-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['update-center-search'], @@ -77,7 +78,9 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { state: this.options.state.toJSON() }); + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + state: this.options.state.toJSON() + }); } }); diff --git a/server/sonar-web/src/main/js/apps/users/app.js b/server/sonar-web/src/main/js/apps/users/app.js index 9fa9df3759a..575f2afc320 100644 --- a/server/sonar-web/src/main/js/apps/users/app.js +++ b/server/sonar-web/src/main/js/apps/users/app.js @@ -1,11 +1,12 @@ define([ + 'backbone.marionette', './layout', './users', './header-view', './search-view', './list-view', './list-footer-view' -], function (Layout, Users, HeaderView, SearchView, ListView, ListFooterView) { +], function (Marionette, Layout, Users, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -37,9 +38,7 @@ define([ }; App.on('start', function (options) { - window.requestMessages().done(function () { - init.call(App, options); - }); + init.call(App, options); }); return App; diff --git a/server/sonar-web/src/main/js/apps/users/change-password-view.js b/server/sonar-web/src/main/js/apps/users/change-password-view.js index 659d3012a79..edda928fb99 100644 --- a/server/sonar-web/src/main/js/apps/users/change-password-view.js +++ b/server/sonar-web/src/main/js/apps/users/change-password-view.js @@ -6,8 +6,8 @@ define([ return ModalForm.extend({ template: Templates['users-change-password'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, diff --git a/server/sonar-web/src/main/js/apps/users/deactivate-view.js b/server/sonar-web/src/main/js/apps/users/deactivate-view.js index 000a350ea57..26143c09b2e 100644 --- a/server/sonar-web/src/main/js/apps/users/deactivate-view.js +++ b/server/sonar-web/src/main/js/apps/users/deactivate-view.js @@ -6,8 +6,8 @@ define([ return ModalForm.extend({ template: Templates['users-deactivate'], - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, diff --git a/server/sonar-web/src/main/js/apps/users/form-view.js b/server/sonar-web/src/main/js/apps/users/form-view.js index 50b18c1d237..c05f57afc09 100644 --- a/server/sonar-web/src/main/js/apps/users/form-view.js +++ b/server/sonar-web/src/main/js/apps/users/form-view.js @@ -9,23 +9,23 @@ define([ template: Templates['users-form'], events: function () { - return _.extend(this._super(), { + return _.extend(ModalForm.prototype.events.apply(this, arguments), { 'click #create-user-add-scm-account': 'onAddScmAccountClick' }); }, onRender: function () { - this._super(); + ModalForm.prototype.onRender.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onDestroy: function () { - this._super(); + ModalForm.prototype.onDestroy.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function (e) { - this._super(e); + onFormSubmit: function () { + ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, diff --git a/server/sonar-web/src/main/js/apps/users/groups-view.js b/server/sonar-web/src/main/js/apps/users/groups-view.js index 09a127fc6fd..2949f0acee6 100644 --- a/server/sonar-web/src/main/js/apps/users/groups-view.js +++ b/server/sonar-web/src/main/js/apps/users/groups-view.js @@ -9,7 +9,8 @@ define([ itemTemplate: Templates['users-group'], onRender: function () { - this._super(); + Modal.prototype.onRender.apply(this, arguments); + //noinspection Eslint new window.SelectList({ el: this.$('#users-groups'), width: '100%', @@ -19,9 +20,9 @@ define([ return item.name + '<br><span class="note">' + item.description + '</span>'; }, queryParam: 'q', - searchUrl: baseUrl + '/api/users/groups?ps=100&login=' + this.model.id, - selectUrl: baseUrl + '/api/usergroups/add_user', - deselectUrl: baseUrl + '/api/usergroups/remove_user', + searchUrl: window.baseUrl + '/api/users/groups?ps=100&login=' + this.model.id, + selectUrl: window.baseUrl + '/api/usergroups/add_user', + deselectUrl: window.baseUrl + '/api/usergroups/remove_user', extra: { login: this.model.id }, diff --git a/server/sonar-web/src/main/js/apps/users/header-view.js b/server/sonar-web/src/main/js/apps/users/header-view.js index c8b76193b4c..a07bd44e6e0 100644 --- a/server/sonar-web/src/main/js/apps/users/header-view.js +++ b/server/sonar-web/src/main/js/apps/users/header-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './create-view', './templates' -], function (CreateView) { +], function (Marionette, CreateView) { return Marionette.ItemView.extend({ template: Templates['users-header'], diff --git a/server/sonar-web/src/main/js/apps/users/layout.js b/server/sonar-web/src/main/js/apps/users/layout.js index 9acb054bdad..3fb4ee142bb 100644 --- a/server/sonar-web/src/main/js/apps/users/layout.js +++ b/server/sonar-web/src/main/js/apps/users/layout.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.LayoutView.extend({ template: Templates['users-layout'], diff --git a/server/sonar-web/src/main/js/apps/users/list-footer-view.js b/server/sonar-web/src/main/js/apps/users/list-footer-view.js index cf802586354..7758d24d75b 100644 --- a/server/sonar-web/src/main/js/apps/users/list-footer-view.js +++ b/server/sonar-web/src/main/js/apps/users/list-footer-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['users-list-footer'], @@ -23,7 +24,7 @@ define([ }, serializeData: function () { - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { total: this.collection.total, count: this.collection.length, more: this.collection.hasMore() diff --git a/server/sonar-web/src/main/js/apps/users/list-item-view.js b/server/sonar-web/src/main/js/apps/users/list-item-view.js index b11e39e2766..b123e560225 100644 --- a/server/sonar-web/src/main/js/apps/users/list-item-view.js +++ b/server/sonar-web/src/main/js/apps/users/list-item-view.js @@ -1,10 +1,11 @@ define([ + 'backbone.marionette', './update-view', './change-password-view', './deactivate-view', './groups-view', './templates' -], function (UpdateView, ChangePasswordView, DeactivateView, GroupsView) { +], function (Marionette, UpdateView, ChangePasswordView, DeactivateView, GroupsView) { return Marionette.ItemView.extend({ tagName: 'li', @@ -101,7 +102,7 @@ define([ scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit, groups = this.model.get('groups'), groupsLimit = groups.length > this.groupsLimit ? this.groupsLimit - 1 : this.groupsLimit; - return _.extend(this._super(), { + return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { firstScmAccounts: _.first(scmAccounts, scmAccountsLimit), moreScmAccountsCount: scmAccounts.length - scmAccountsLimit, firstGroups: _.first(groups, groupsLimit), diff --git a/server/sonar-web/src/main/js/apps/users/list-view.js b/server/sonar-web/src/main/js/apps/users/list-view.js index 24878864d30..b56e64f951d 100644 --- a/server/sonar-web/src/main/js/apps/users/list-view.js +++ b/server/sonar-web/src/main/js/apps/users/list-view.js @@ -1,7 +1,8 @@ define([ + 'backbone.marionette', './list-item-view', './templates' -], function (ListItemView) { +], function (Marionette, ListItemView) { return Marionette.CollectionView.extend({ tagName: 'ul', diff --git a/server/sonar-web/src/main/js/apps/users/search-view.js b/server/sonar-web/src/main/js/apps/users/search-view.js index 5129bf5a253..295f50b0b4b 100644 --- a/server/sonar-web/src/main/js/apps/users/search-view.js +++ b/server/sonar-web/src/main/js/apps/users/search-view.js @@ -1,6 +1,7 @@ define([ + 'backbone.marionette', './templates' -], function () { +], function (Marionette) { return Marionette.ItemView.extend({ template: Templates['users-search'], diff --git a/server/sonar-web/src/main/js/apps/users/user.js b/server/sonar-web/src/main/js/apps/users/user.js index 746ffe8bdd7..e438a4b5f22 100644 --- a/server/sonar-web/src/main/js/apps/users/user.js +++ b/server/sonar-web/src/main/js/apps/users/user.js @@ -1,10 +1,12 @@ -define(function () { +define([ + 'backbone' +], function (Backbone) { return Backbone.Model.extend({ idAttribute: 'login', urlRoot: function () { - return baseUrl + '/api/users'; + return window.baseUrl + '/api/users'; }, defaults: function () { diff --git a/server/sonar-web/src/main/js/apps/users/users.js b/server/sonar-web/src/main/js/apps/users/users.js index 9c45979a9fe..1c199d05ace 100644 --- a/server/sonar-web/src/main/js/apps/users/users.js +++ b/server/sonar-web/src/main/js/apps/users/users.js @@ -1,12 +1,13 @@ define([ + 'backbone', './user' -], function (User) { +], function (Backbone, User) { return Backbone.Collection.extend({ model: User, url: function () { - return baseUrl + '/api/users/search'; + return window.baseUrl + '/api/users/search'; }, parse: function (r) { @@ -19,7 +20,7 @@ define([ fetch: function (options) { var d = (options && options.data) || {}; this.q = d.q; - return this._super(options); + return Backbone.Collection.prototype.fetch.apply(this, arguments); }, fetchMore: function () { |