From e1b6cbcba2e342b4671a1bf88e1fd174b55b44cf Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 10 Sep 2015 10:42:07 +0200 Subject: [PATCH] Revert "use single web app" --- .../dashboard/widget/issue_filter.html.erb | 17 +- .../widget/project_issue_filter.html.erb | 27 +- server/sonar-web/.eslintignore | 1 - server/sonar-web/.eslintrc | 205 -------- server/sonar-web/.jshintrc | 96 ++++ server/sonar-web/Gruntfile.coffee | 38 +- server/sonar-web/package.json | 2 +- .../sonar-web/src/main/js/api/navigation.jsx | 26 - server/sonar-web/src/main/js/api/users.jsx | 13 - .../sonar-web/src/main/js/apps/account/app.js | 2 +- .../js/apps/account/change-password-view.js | 8 +- .../js/apps/api-documentation/action-view.js | 22 +- .../js/apps/api-documentation/actions-view.js | 22 +- .../src/main/js/apps/api-documentation/app.js | 27 +- .../js/apps/api-documentation/controller.js | 23 +- .../js/apps/api-documentation/filters-view.js | 22 +- .../js/apps/api-documentation/header-view.js | 22 +- .../js/apps/api-documentation/item-view.js | 22 +- .../main/js/apps/api-documentation/layout.js | 23 +- .../js/apps/api-documentation/list-view.js | 22 +- .../main/js/apps/api-documentation/list.js | 23 +- .../main/js/apps/api-documentation/router.js | 23 +- .../src/main/js/apps/coding-rules/app.js | 10 +- .../coding-rules/bulk-change-modal-view.js | 4 +- .../facets/active-severity-facet.js | 2 +- .../facets/custom-values-facet.js | 10 +- .../coding-rules/facets/inheritance-facet.js | 4 +- .../coding-rules/facets/language-facet.js | 2 +- .../coding-rules/facets/repository-facet.js | 2 +- .../apps/coding-rules/facets/status-facet.js | 2 +- .../js/apps/coding-rules/facets/tag-facet.js | 2 +- .../main/js/apps/coding-rules/filters-view.js | 26 +- .../src/main/js/apps/coding-rules/layout.js | 23 +- .../main/js/apps/coding-rules/models/rule.js | 23 +- .../main/js/apps/coding-rules/models/rules.js | 22 +- .../js/apps/coding-rules/rule-details-view.js | 35 +- .../rule/custom-rule-creation-view.js | 9 +- .../coding-rules/rule/custom-rule-view.js | 29 +- .../coding-rules/rule/custom-rules-view.js | 22 +- .../rule/manual-rule-creation-view.js | 2 +- .../rule/profile-activation-view.js | 33 +- .../rule/rule-description-view.js | 27 +- .../coding-rules/rule/rule-issues-view.js | 22 +- .../apps/coding-rules/rule/rule-meta-view.js | 22 +- .../coding-rules/rule/rule-parameters-view.js | 22 +- .../coding-rules/rule/rule-profile-view.js | 36 +- .../coding-rules/rule/rule-profiles-view.js | 22 +- .../coding-rules/workspace-list-empty-view.js | 25 +- .../coding-rules/workspace-list-item-view.js | 29 +- .../src/main/js/apps/computation/app.js | 8 +- .../main/js/apps/computation/header-view.js | 3 +- .../src/main/js/apps/computation/layout.js | 3 +- .../js/apps/computation/list-footer-view.js | 3 +- .../js/apps/computation/list-item-view.js | 3 +- .../src/main/js/apps/computation/list-view.js | 3 +- .../src/main/js/apps/computation/report.js | 4 +- .../src/main/js/apps/computation/reports.js | 5 +- .../src/main/js/apps/computation/router.js | 4 +- .../main/js/apps/computation/search-view.js | 3 +- .../src/main/js/apps/custom-measures/app.js | 11 +- .../js/apps/custom-measures/custom-measure.js | 6 +- .../apps/custom-measures/custom-measures.js | 7 +- .../js/apps/custom-measures/delete-view.js | 4 +- .../main/js/apps/custom-measures/form-view.js | 10 +- .../js/apps/custom-measures/header-view.js | 3 +- .../main/js/apps/custom-measures/layout.js | 3 +- .../apps/custom-measures/list-footer-view.js | 5 +- .../js/apps/custom-measures/list-item-view.js | 3 +- .../main/js/apps/custom-measures/list-view.js | 3 +- .../src/main/js/apps/dashboard/app.jsx | 10 - .../src/main/js/apps/drilldown/app.js | 32 +- .../main/js/apps/global-permissions/app.jsx | 6 +- .../js/apps/global-permissions/groups-view.js | 4 +- .../js/apps/global-permissions/users-view.js | 4 +- .../sonar-web/src/main/js/apps/groups/app.js | 7 +- .../src/main/js/apps/groups/delete-view.js | 8 +- .../src/main/js/apps/groups/form-view.js | 8 +- .../src/main/js/apps/groups/group.js | 6 +- .../src/main/js/apps/groups/groups.js | 7 +- .../src/main/js/apps/groups/header-view.js | 3 +- .../src/main/js/apps/groups/layout.js | 3 +- .../main/js/apps/groups/list-footer-view.js | 5 +- .../src/main/js/apps/groups/list-item-view.js | 3 +- .../src/main/js/apps/groups/list-view.js | 3 +- .../src/main/js/apps/groups/search-view.js | 3 +- .../src/main/js/apps/groups/users-view.js | 11 +- .../src/main/js/apps/issues/app-context.js | 26 +- .../sonar-web/src/main/js/apps/issues/app.js | 10 +- .../js/apps/issues/component-viewer/main.js | 2 +- .../src/main/js/apps/issues/controller.js | 3 +- .../js/apps/issues/facets/assignee-facet.js | 2 +- .../js/apps/issues/facets/author-facet.js | 8 +- .../main/js/apps/issues/facets/base-facet.js | 2 +- .../apps/issues/facets/custom-values-facet.js | 6 +- .../js/apps/issues/facets/language-facet.js | 8 +- .../main/js/apps/issues/facets/mode-facet.js | 4 +- .../js/apps/issues/facets/project-facet.js | 10 +- .../js/apps/issues/facets/reporter-facet.js | 2 +- .../main/js/apps/issues/facets/rule-facet.js | 8 +- .../main/js/apps/issues/facets/tag-facet.js | 6 +- .../src/main/js/apps/issues/filters-view.js | 3 +- .../main/js/apps/issues/issue-filter-view.js | 4 +- .../src/main/js/apps/issues/layout.js | 4 +- .../src/main/js/apps/issues/models/filter.js | 6 +- .../src/main/js/apps/issues/models/filters.js | 3 +- .../src/main/js/apps/issues/models/issue.js | 2 +- .../src/main/js/apps/issues/models/issues.js | 5 +- .../js/apps/issues/workspace-header-view.js | 6 +- .../js/apps/issues/workspace-home-view.js | 10 +- .../apps/issues/workspace-list-empty-view.js | 6 +- .../sonar-web/src/main/js/apps/main/app.jsx | 171 ------- .../src/main/js/apps/maintenance/app.js | 4 +- .../src/main/js/apps/maintenance/main-view.js | 10 +- .../src/main/js/apps/markdown/app.js | 24 +- .../js/apps/markdown/markdown-help-view.js | 24 +- .../src/main/js/apps/measures/app.js | 3 +- .../sonar-web/src/main/js/apps/metrics/app.js | 5 +- .../src/main/js/apps/metrics/delete-view.js | 4 +- .../src/main/js/apps/metrics/form-view.js | 10 +- .../src/main/js/apps/metrics/header-view.js | 3 +- .../src/main/js/apps/metrics/layout.js | 3 +- .../main/js/apps/metrics/list-footer-view.js | 5 +- .../main/js/apps/metrics/list-item-view.js | 3 +- .../src/main/js/apps/metrics/list-view.js | 3 +- .../src/main/js/apps/metrics/metric.js | 6 +- .../src/main/js/apps/metrics/metrics.js | 7 +- server/sonar-web/src/main/js/apps/nav/app.jsx | 8 +- .../apps/nav/component/component-nav-menu.jsx | 4 - .../js/apps/nav/component/component-nav.jsx | 42 +- .../js/apps/nav/global/global-nav-menu.jsx | 2 +- .../js/apps/nav/global/global-nav-user.jsx | 5 +- .../main/js/apps/nav/global/search-view.js | 39 +- .../src/main/js/apps/overview/app.jsx | 21 +- .../main/js/apps/project-permissions/app.jsx | 11 +- .../apps/project-permissions/groups-view.js | 8 +- .../js/apps/project-permissions/users-view.js | 16 +- .../src/main/js/apps/provisioning/app.js | 7 +- .../js/apps/provisioning/bulk-delete-view.js | 4 +- .../main/js/apps/provisioning/delete-view.js | 4 +- .../main/js/apps/provisioning/form-view.js | 8 +- .../main/js/apps/provisioning/header-view.js | 3 +- .../src/main/js/apps/provisioning/layout.js | 3 +- .../js/apps/provisioning/list-footer-view.js | 5 +- .../js/apps/provisioning/list-item-view.js | 3 +- .../main/js/apps/provisioning/list-view.js | 3 +- .../src/main/js/apps/provisioning/project.js | 6 +- .../src/main/js/apps/provisioning/projects.js | 7 +- .../main/js/apps/provisioning/search-view.js | 5 +- .../js/apps/quality-gates/actions-view.js | 3 +- .../src/main/js/apps/quality-gates/app.js | 6 +- .../main/js/apps/quality-gates/condition.js | 6 +- .../main/js/apps/quality-gates/conditions.js | 3 +- .../main/js/apps/quality-gates/controller.js | 3 +- .../main/js/apps/quality-gates/copy-view.js | 2 +- .../main/js/apps/quality-gates/create-view.js | 2 +- .../js/apps/quality-gates/details-view.js | 3 +- .../main/js/apps/quality-gates/form-view.js | 3 +- .../apps/quality-gates/gate-condition-view.js | 5 +- .../gate-conditions-delete-view.js | 3 +- .../gate-conditions-empty-view.js | 3 +- .../quality-gates/gate-conditions-view.js | 5 +- .../apps/quality-gates/gate-projects-view.js | 22 +- .../main/js/apps/quality-gates/gate-view.js | 3 +- .../src/main/js/apps/quality-gates/gate.js | 6 +- .../main/js/apps/quality-gates/gates-view.js | 3 +- .../src/main/js/apps/quality-gates/gates.js | 5 +- .../main/js/apps/quality-gates/header-view.js | 3 +- .../main/js/apps/quality-gates/intro-view.js | 3 +- .../src/main/js/apps/quality-gates/layout.js | 4 +- .../main/js/apps/quality-gates/rename-view.js | 2 +- .../src/main/js/apps/quality-gates/router.js | 4 +- .../js/apps/quality-profiles/actions-view.js | 22 +- .../src/main/js/apps/quality-profiles/app.js | 11 +- .../change-profile-parent-view.js | 22 +- .../js/apps/quality-profiles/controller.js | 22 +- .../main/js/apps/quality-profiles/helpers.js | 10 +- .../js/apps/quality-profiles/intro-view.js | 22 +- .../main/js/apps/quality-profiles/layout.js | 23 +- .../profile-changelog-view.js | 22 +- .../profile-comparison-view.js | 22 +- .../quality-profiles/profile-details-view.js | 34 +- .../quality-profiles/profile-header-view.js | 26 +- .../js/apps/quality-profiles/profile-view.js | 22 +- .../main/js/apps/quality-profiles/profile.js | 23 +- .../quality-profiles/profiles-empty-view.js | 3 +- .../js/apps/quality-profiles/profiles-view.js | 22 +- .../main/js/apps/quality-profiles/profiles.js | 22 +- .../restore-built-in-profiles-view.js | 2 +- .../main/js/apps/quality-profiles/router.js | 23 +- .../src/main/js/apps/select-list/app.js | 11 - .../src/main/js/apps/source-viewer/app.js | 15 +- .../src/main/js/apps/update-center/app.js | 12 +- .../main/js/apps/update-center/controller.js | 4 +- .../main/js/apps/update-center/footer-view.js | 5 +- .../main/js/apps/update-center/header-view.js | 5 +- .../src/main/js/apps/update-center/layout.js | 3 +- .../js/apps/update-center/list-item-view.js | 4 +- .../main/js/apps/update-center/list-view.js | 3 +- .../update-center/plugin-changelog-view.js | 7 +- .../src/main/js/apps/update-center/plugin.js | 4 +- .../src/main/js/apps/update-center/plugins.js | 3 +- .../src/main/js/apps/update-center/router.js | 4 +- .../main/js/apps/update-center/search-view.js | 7 +- .../sonar-web/src/main/js/apps/users/app.js | 7 +- .../js/apps/users/change-password-view.js | 4 +- .../src/main/js/apps/users/deactivate-view.js | 4 +- .../src/main/js/apps/users/form-view.js | 10 +- .../src/main/js/apps/users/groups-view.js | 9 +- .../src/main/js/apps/users/header-view.js | 3 +- .../src/main/js/apps/users/layout.js | 3 +- .../main/js/apps/users/list-footer-view.js | 5 +- .../src/main/js/apps/users/list-item-view.js | 5 +- .../src/main/js/apps/users/list-view.js | 3 +- .../src/main/js/apps/users/search-view.js | 3 +- .../sonar-web/src/main/js/apps/users/user.js | 6 +- .../sonar-web/src/main/js/apps/users/users.js | 7 +- .../src/main/js/components/common/dialogs.js | 44 ++ .../src/main/js/components/common/dialogs.jsx | 44 -- .../common/handlebars-extensions.js | 30 +- .../common/jquery-isolated-scroll.js | 33 ++ .../common/jquery-isolated-scroll.jsx | 12 - .../src/main/js/components/common/modals.js | 23 +- .../src/main/js/components/common/popup.js | 4 +- .../main/js/components/common/processes.js | 30 +- .../main/js/components/common/select-list.js | 23 +- .../common/selectable-collection-view.js | 4 +- .../issue/collections/action-plans.js | 6 +- .../js/components/issue/collections/issues.js | 5 +- .../main/js/components/issue/issue-view.js | 7 +- .../js/components/issue/manual-issue-view.js | 5 +- .../js/components/issue/models/changelog.js | 6 +- .../main/js/components/issue/models/issue.js | 8 +- .../issue/views/assign-form-view.js | 2 +- .../components/issue/views/plan-form-view.js | 2 +- .../components/issue/views/tags-form-view.js | 2 +- .../js/components/navigator/controller.js | 23 +- .../js/components/navigator/facets-view.js | 22 +- .../components/navigator/facets/base-facet.js | 23 +- .../navigator/filters/ajax-select-filters.js | 164 +++--- .../navigator/filters/base-filters.js | 81 +-- .../navigator/filters/checkbox-filters.js | 37 +- .../navigator/filters/choice-filters.js | 141 +++--- .../navigator/filters/favorite-filters.js | 22 +- .../navigator/filters/filter-bar.js | 43 +- .../navigator/filters/metric-filters.js | 73 ++- .../filters/more-criteria-filters.js | 53 +- .../navigator/filters/range-filters.js | 57 ++- .../navigator/filters/string-filters.js | 45 +- .../js/components/navigator/models/facet.js | 23 +- .../js/components/navigator/models/facets.js | 22 +- .../js/components/navigator/models/state.js | 23 +- .../main/js/components/navigator/router.js | 23 +- .../navigator/workspace-header-view.js | 23 +- .../navigator/workspace-list-item-view.js | 23 +- .../navigator/workspace-list-view.js | 23 +- .../src/main/js/components/shared/avatar.jsx | 4 +- .../js/components/source-viewer/header.js | 5 +- .../main/js/components/source-viewer/main.js | 27 +- .../components/source-viewer/more-actions.js | 22 +- .../source-viewer/popups/coverage-popup.js | 1 - .../source-viewer/popups/scm-popup.js | 1 - .../js/components/source-viewer/source.js | 23 +- .../js/components/workspace/models/item.js | 23 +- .../js/components/workspace/models/items.js | 28 +- .../workspace/views/base-viewer-view.js | 25 +- .../components/workspace/views/item-view.js | 22 +- .../components/workspace/views/items-view.js | 22 +- .../components/workspace/views/rule-view.js | 22 +- .../workspace/views/viewer-header-view.js | 22 +- .../sonar-web/src/main/js/libs/application.js | 195 ++++---- server/sonar-web/src/main/js/libs/csv.js | 27 + server/sonar-web/src/main/js/libs/csv.jsx | 4 - server/sonar-web/src/main/js/libs/inputs.js | 18 +- .../src/main/js/libs/recent-history.js | 75 +++ .../src/main/js/libs/recent-history.jsx | 35 -- .../src/main/js/libs/select2-jquery-ui-fix.js | 2 +- .../js/libs/third-party/backbone-super.js | 111 ++++ .../js/libs/third-party/shim/backbone-shim.js | 3 + .../{ => third-party}/shim/jquery-shim.js | 0 .../libs/third-party/shim/marionette-shim.js | 3 + .../{ => third-party}/shim/underscore-shim.js | 0 .../sonar-web/src/main/js/libs/translate.js | 26 +- .../src/main/js/libs/widgets/bubble-chart.js | 25 +- .../src/main/js/libs/widgets/pie-chart.js | 22 + .../src/main/js/libs/widgets/tag-cloud.js | 2 +- .../src/main/js/libs/widgets/timeline.js | 2 +- server/sonar-web/src/main/js/main.js | 22 - .../main/js/widgets/issue-filter/widget.js | 33 +- .../app/controllers/dashboard_controller.rb | 7 +- .../WEB-INF/app/views/account/index.html.erb | 8 + .../views/api_documentation/index.html.erb | 7 + .../app/views/coding_rules/index.html.erb | 7 + .../app/views/component/index.html.erb | 20 +- .../app/views/component_issues/index.html.erb | 3 + .../app/views/computation/index.html.erb | 7 + .../app/views/custom_measures/index.html.erb | 7 + .../app/views/dashboard/configure.html.erb | 4 - .../app/views/dashboard/index.html.erb | 11 +- .../app/views/dashboard/no_dashboard.html.erb | 7 + .../app/views/drilldown/measures.html.erb | 8 + .../WEB-INF/app/views/groups/index.html.erb | 8 +- .../WEB-INF/app/views/issues/search.html.erb | 7 + .../WEB-INF/app/views/layouts/_head.html.erb | 74 +-- .../app/views/layouts/_navbar.html.erb | 29 ++ .../app/views/layouts/_nolayout.html.erb | 28 +- .../views/layouts/_recent_history.html.erb | 9 + .../app/views/layouts/application.html.erb | 1 + .../app/views/maintenance/index.html.erb | 8 + .../WEB-INF/app/views/markdown/help.html.erb | 6 + .../app/views/measures/search.html.erb | 6 + .../WEB-INF/app/views/metrics/index.html.erb | 7 + .../WEB-INF/app/views/overview/index.html.erb | 9 +- .../views/permission_templates/index.html.erb | 4 + .../WEB-INF/app/views/profiles/index.html.erb | 7 + .../app/views/project_roles/index.html.erb | 61 +++ .../app/views/provisioning/index.html.erb | 7 + .../app/views/quality_gates/index.html.erb | 7 + .../WEB-INF/app/views/roles/global.html.erb | 7 + .../WEB-INF/app/views/roles/projects.html.erb | 7 + .../WEB-INF/app/views/setup/index.html.erb | 8 + .../app/views/updatecenter/index.html.erb | 7 + .../WEB-INF/app/views/users/index.html.erb | 7 + .../src/test/json/component-navigation.json | 32 -- server/sonar-web/test/helpers/test-page.js | 9 +- server/sonar-web/test/intern.js | 10 +- server/sonar-web/test/medium/base.html | 75 ++- .../test/medium/coding-rules.spec.js | 78 +-- .../sonar-web/test/medium/computation.spec.js | 4 +- .../test/medium/custom-measures.spec.js | 16 +- .../test/medium/global-permissions.spec.js | 2 +- server/sonar-web/test/medium/issues.spec.js | 472 +++++++++--------- .../test/medium/project-permissions.spec.js | 18 +- .../test/medium/quality-profiles.spec.js | 87 +++- .../test/medium/source-viewer.spec.js | 8 +- server/sonar-web/test/medium/test-main.js | 33 -- .../test/medium/update-center.spec.js | 34 +- server/sonar-web/test/medium/users.spec.js | 14 +- .../sonar-web/test/unit/application.spec.js | 4 +- server/sonar-web/test/unit/csv.spec.js | 16 - .../test/unit/recent-history.spec.js | 43 -- 340 files changed, 3647 insertions(+), 2430 deletions(-) delete mode 100644 server/sonar-web/.eslintignore delete mode 100644 server/sonar-web/.eslintrc create mode 100644 server/sonar-web/.jshintrc delete mode 100644 server/sonar-web/src/main/js/api/navigation.jsx delete mode 100644 server/sonar-web/src/main/js/api/users.jsx delete mode 100644 server/sonar-web/src/main/js/apps/dashboard/app.jsx delete mode 100644 server/sonar-web/src/main/js/apps/main/app.jsx delete mode 100644 server/sonar-web/src/main/js/apps/select-list/app.js create mode 100644 server/sonar-web/src/main/js/components/common/dialogs.js delete mode 100644 server/sonar-web/src/main/js/components/common/dialogs.jsx create mode 100644 server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.js delete mode 100644 server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.jsx create mode 100644 server/sonar-web/src/main/js/libs/csv.js delete mode 100644 server/sonar-web/src/main/js/libs/csv.jsx create mode 100644 server/sonar-web/src/main/js/libs/recent-history.js delete mode 100644 server/sonar-web/src/main/js/libs/recent-history.jsx create mode 100644 server/sonar-web/src/main/js/libs/third-party/backbone-super.js create mode 100644 server/sonar-web/src/main/js/libs/third-party/shim/backbone-shim.js rename server/sonar-web/src/main/js/libs/{ => third-party}/shim/jquery-shim.js (100%) create mode 100644 server/sonar-web/src/main/js/libs/third-party/shim/marionette-shim.js rename server/sonar-web/src/main/js/libs/{ => third-party}/shim/underscore-shim.js (100%) delete mode 100644 server/sonar-web/src/main/js/main.js create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar.html.erb create mode 100644 server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_recent_history.html.erb delete mode 100644 server/sonar-web/src/test/json/component-navigation.json delete mode 100644 server/sonar-web/test/medium/test-main.js delete mode 100644 server/sonar-web/test/unit/csv.spec.js delete mode 100644 server/sonar-web/test/unit/recent-history.spec.js diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_filter.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_filter.html.erb index a4540dfc3b7..ee3fef4309d 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_filter.html.erb +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/issue_filter.html.erb @@ -28,14 +28,15 @@ return; } - window.widgets.push({ - name: 'issue-filter', - options: { - el: '#<%= container_id -%>', - query: query, - distributionAxis: '<%= distribution_axis -%>', - displayMode: '<%= display_mode -%>' - } + require(['widgets/issue-filter/widget'], function (IssueFilter) { + window.requestMessages().done(function () { + new IssueFilter({ + el: '#<%= container_id -%>', + query: query, + distributionAxis: '<%= distribution_axis -%>', + displayMode: '<%= display_mode -%>' + }); + }); }); })(); diff --git a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_issue_filter.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_issue_filter.html.erb index ebe21326eff..0815b95e88e 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_issue_filter.html.erb +++ b/server/sonar-server/src/main/resources/org/sonar/server/dashboard/widget/project_issue_filter.html.erb @@ -34,19 +34,20 @@ return; } - window.widgets.push({ - name: 'issue-filter', - options: { - el: '#<%= container_id -%>', - query: query, - distributionAxis: '<%= distribution_axis -%>', - displayMode: '<%= display_mode -%>', - <% if period_date %> - periodDate: '<%= period_date -%>', - <% end %> - componentUuid: '<%= @project.uuid -%>', - componentKey: '<%= @project.key -%>' - } + require(['widgets/issue-filter/widget'], function (IssueFilter) { + window.requestMessages().done(function () { + new IssueFilter({ + el: '#<%= container_id -%>', + query: query, + distributionAxis: '<%= distribution_axis -%>', + displayMode: '<%= display_mode -%>', + <% if period_date %> + periodDate: '<%= period_date -%>', + <% end %> + componentUuid: '<%= @project.uuid -%>', + componentKey: '<%= @project.key -%>' + }); + }); }); })(); diff --git a/server/sonar-web/.eslintignore b/server/sonar-web/.eslintignore deleted file mode 100644 index 681af342526..00000000000 --- a/server/sonar-web/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -src/main/js/libs/third-party diff --git a/server/sonar-web/.eslintrc b/server/sonar-web/.eslintrc deleted file mode 100644 index 00b2641ae48..00000000000 --- a/server/sonar-web/.eslintrc +++ /dev/null @@ -1,205 +0,0 @@ -{ - "env": { - "browser": true, - "es6": true - }, - "ecmaFeatures": { - "modules": true, - "jsx": true - }, - - "rules": { - ////////// Possible Errors ////////// - - "comma-dangle": 0, // disallow trailing commas in object literals - "no-cond-assign": 2, // disallow assignment in conditional expressions - "no-console": 2, // disallow use of console (off by default in the node environment) - "no-constant-condition": 2, // disallow use of constant expressions in conditions - "no-control-regex": 0, // disallow control characters in regular expressions - "no-debugger": 2, // disallow use of debugger - "no-dupe-keys": 2, // disallow duplicate keys when creating object literals - "no-empty": 2, // disallow empty statements - "no-empty-class": 2, // disallow the use of empty character classes in regular expressions - "no-ex-assign": 2, // disallow assigning to the exception in a catch block - "no-extra-boolean-cast": 0, // disallow double-negation boolean casts in a boolean context - "no-extra-parens": 0, // disallow unnecessary parentheses (off by default) - "no-extra-semi": 2, // disallow unnecessary semicolons - "no-func-assign": 2, // disallow overwriting functions written as function declarations - "no-inner-declarations": 2, // disallow function or variable declarations in nested blocks - "no-invalid-regexp": 2, // disallow invalid regular expression strings in the RegExp constructor - "no-irregular-whitespace": 2, // disallow irregular whitespace outside of strings and comments - "no-negated-in-lhs": 2, // disallow negation of the left operand of an in expression - "no-obj-calls": 2, // disallow the use of object properties of the global object (Math and JSON) as functions - "no-regex-spaces": 2, // disallow multiple spaces in a regular expression literal - "no-reserved-keys": 2, // disallow reserved words being used as object literal keys (off by default) - "no-sparse-arrays": 2, // disallow sparse arrays - "no-unreachable": 2, // disallow unreachable statements after a return, throw, continue, or break statement - "use-isnan": 2, // disallow comparisons with the value NaN - "valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default) - "valid-typeof": 2, // Ensure that the results of typeof are compared against a valid string - - - ////////// Best Practices ////////// - - "block-scoped-var": 0, // treat var statements as if they were block scoped (off by default) - "complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default) - "consistent-return": 0, // require return statements to either always or never specify values - "curly": 2, // specify curly brace conventions for all control statements - "default-case": 1, // require default case in switch statements (off by default) - "dot-notation": 0, // encourages use of dot notation whenever possible - "eqeqeq": 2, // require the use of === and !== - "guard-for-in": 2, // make sure for-in loops have an if statement (off by default) - "no-alert": 1, // disallow the use of alert, confirm, and prompt - "no-caller": 2, // disallow use of arguments.caller or arguments.callee - "no-div-regex": 2, // disallow division operators explicitly at beginning of regular expression (off by default) - "no-else-return": 0, // disallow else after a return in an if (off by default) - "no-empty-label": 2, // disallow use of labels for anything other then loops and switches - "no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default) - "no-eval": 2, // disallow use of eval() - "no-extend-native": 2, // disallow adding to native types - "no-extra-bind": 0, // disallow unnecessary function binding - "no-fallthrough": 2, // disallow fallthrough of case statements - "no-floating-decimal": 0, // disallow the use of leading or trailing decimal points in numeric literals (off by default) - "no-implied-eval": 2, // disallow use of eval()-like methods - "no-iterator": 2, // disallow usage of __iterator__ property - "no-labels": 2, // disallow use of labeled statements - "no-lone-blocks": 0, // disallow unnecessary nested blocks - "no-loop-func": 0, // disallow creation of functions within loops - "no-multi-spaces": 2, // disallow use of multiple spaces - "no-multi-str": 0, // disallow use of multiline strings - "no-native-reassign": 0, // disallow reassignments of native objects - "no-new": 0, // disallow use of new operator when not part of the assignment or comparison - "no-new-func": 2, // disallow use of new operator for Function object - "no-new-wrappers": 2, // disallows creating new instances of String, Number, and Boolean - "no-octal": 2, // disallow use of octal literals - "no-octal-escape": 2, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251"; - "no-process-env": 2, // disallow use of process.env (off by default) - "no-proto": 2, // disallow usage of __proto__ property - "no-redeclare": 2, // disallow declaring the same variable more then once - "no-return-assign": 2, // disallow use of assignment in return statement - "no-script-url": 2, // disallow use of javascript: urls. - "no-self-compare": 2, // disallow comparisons where both sides are exactly the same (off by default) - "no-sequences": 2, // disallow use of comma operator - "no-unused-expressions": 2, // disallow usage of expressions in statement position - "no-void": 1, // disallow use of void operator (off by default) - "no-warning-comments": 0, // disallow usage of configurable warning terms in comments, e.g. TODO or FIXME (off by default) - "no-with": 2, // disallow use of the with statement - "radix": 2, // require use of the second argument for parseInt() (off by default) - "vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default) - "wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default) - "yoda": 0, // require or disallow Yoda conditions - - - ////////// Strict Mode ////////// - - "global-strict": 0, // (deprecated) require or disallow the "use strict" pragma in the global scope (off by default in the node environment) - "no-extra-strict": 0, // (deprecated) disallow unnecessary use of "use strict"; when already in strict mode - "strict": 0, // controls location of Use Strict Directives - - - ////////// Variables ////////// - - "no-catch-shadow": 2, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) - "no-delete-var": 0, // disallow deletion of variables - "no-label-var": 2, // disallow labels that share a name with a variable - "no-shadow": 1, // disallow declaration of variables already declared in the outer scope - "no-shadow-restricted-names": 1, // disallow shadowing of names such as arguments - "no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block - "no-undef-init": 2, // disallow use of undefined when initializing variables - "no-undefined": 2, // disallow use of undefined variable (off by default) - "no-unused-vars": 2, // disallow declaration of variables that are not used in the code - "no-use-before-define": 0, // disallow use of variables before they are defined - - - ////////// Node.js ////////// - - "handle-callback-err": 0, // enforces error handling in callbacks (off by default) (on by default in the node environment) - "no-mixed-requires": 0, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment) - "no-new-require": 0, // disallow use of new operator with the require function (off by default) (on by default in the node environment) - "no-path-concat": 0, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment) - "no-process-exit": 0, // disallow process.exit() (on by default in the node environment) - "no-restricted-modules": 0, // restrict usage of specified node modules (off by default) - "no-sync": 0, // disallow use of synchronous methods (off by default) - - - ////////// Stylistic Issues ////////// - - "brace-style": 0, // enforce one true brace style (off by default) - "camelcase": 0, // require camel case names - "comma-spacing": 0, // enforce spacing before and after comma - "comma-style": 0, // enforce one true comma style (off by default) - "consistent-this": 0, // enforces consistent naming when capturing the current execution context (off by default) - "eol-last": 0, // enforce newline at the end of file, with no multiple empty lines - "func-names": 0, // require function expressions to have a name (off by default) - "func-style": 0, // enforces use of function declarations or expressions (off by default) - "key-spacing": 0, // enforces spacing between keys and values in object literal properties - "max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default) - "new-cap": 0, // require a capital letter for constructors - "new-parens": 0, // disallow the omission of parentheses when invoking a constructor with no arguments - "no-array-constructor": 2, // disallow use of the Array constructor - "no-inline-comments": 0, // disallow comments inline after code (off by default) - "no-lonely-if": 0, // disallow if as the only statement in an else block (off by default) - "no-mixed-spaces-and-tabs": 2, // disallow mixed spaces and tabs for indentation - "no-multiple-empty-lines": 0, // disallow multiple empty lines (off by default) - "no-nested-ternary": 1, // disallow nested ternary expressions (off by default) - "no-new-object": 0, // disallow use of the Object constructor - "no-space-before-semi": 2, // disallow space before semicolon - "no-spaced-func": 0, // disallow space between function identifier and application - "no-ternary": 0, // disallow the use of ternary operators (off by default) - "no-trailing-spaces": 2, // disallow trailing whitespace at the end of lines - "no-underscore-dangle": 0, // disallow dangling underscores in identifiers - "no-wrap-func": 0, // disallow wrapping of non-IIFE statements in parens - "one-var": 0, // allow just one var statement per function (off by default) - "operator-assignment": 0, // require assignment operator shorthand where possible or prohibit it entirely (off by default) - "padded-blocks": 0, // enforce padding within blocks (off by default) - "quote-props": 0, // require quotes around object literal property names (off by default) - "quotes": [2, "single"], // specify whether double or single quotes should be used - "semi": 2, // require or disallow use of semicolons instead of ASI - "sort-vars": 0, // sort variables within the same declaration block (off by default) - "space-after-function-name": 0, // require a space after function names (off by default) - "space-after-keywords": 0, // require a space after certain keywords (off by default) - "space-before-blocks": 0, // require or disallow space before blocks (off by default) - "space-in-brackets": 0, // require or disallow spaces inside brackets (off by default) - "space-in-parens": 0, // require or disallow spaces inside parentheses (off by default) - "space-infix-ops": 0, // require spaces around operators - "space-return-throw-case": 2, // require a space after return, throw, and case - "space-unary-ops": 0, // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default) - "spaced-line-comment": 0, // require or disallow a space immediately following the // in a line comment (off by default) - "wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default) - - - ////////// ECMAScript 6 ////////// - - "no-var": 0, // require let or const instead of var (off by default) - "generator-star": 0, // enforce the position of the * in generator functions (off by default) - - - ////////// Legacy ////////// - - "max-depth": 0, // specify the maximum depth that blocks can be nested (off by default) - "max-len": 0, // specify the maximum length of a line in your program (off by default) - "max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default) - "max-statements": 0, // specify the maximum number of statement allowed in a function (off by default) - "no-bitwise": 0, // disallow use of bitwise operators (off by default) - "no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default) - }, - - "globals": { - "define": true, - "require": true, - "jQuery": true, - "$": true, - - "_": true, - "Templates": true, - "Handlebars": true, - "moment": true, - "numeral": true, - "key": true, - "d3": true, - "baseUrl": true - }, - "plugins": [ - "react" - ] -} diff --git a/server/sonar-web/.jshintrc b/server/sonar-web/.jshintrc new file mode 100644 index 00000000000..5b2eb1b387b --- /dev/null +++ b/server/sonar-web/.jshintrc @@ -0,0 +1,96 @@ +{ + "maxerr": 50, + + "bitwise": true, + "camelcase": false, + "curly": true, + "eqeqeq": true, + "forin": true, + "freeze": true, + "immed": false, + "indent": 2, + "latedef": false, + "newcap": false, + "noarg": true, + "noempty": true, + "nonbsp": true, + "nonew": false, + "plusplus": false, + "quotmark": "single", + "undef": true, + "unused": false, + "strict": false, + "maxparams": false, + "maxdepth": 4, + "maxstatements": false, + "maxcomplexity": false, + "maxlen": 120, + + "asi": false, + "boss": false, + "debug": false, + "eqnull": true, + "esnext": false, + "moz": false, + "evil": false, + "expr": false, + "funcscope": false, + "globalstrict": false, + "iterator": false, + "lastsemic": false, + "laxbreak": false, + "laxcomma": false, + "loopfunc": false, + "multistr": false, + "noyield": false, + "notypeof": false, + "proto": false, + "scripturl": false, + "shadow": false, + "sub": false, + "supernew": false, + "validthis": false, + + "browser": true, + "browserify": false, + "couch": false, + "devel": true, + "dojo": false, + "jasmine": false, + "jquery": true, + "mocha": false, + "mootools": false, + "node": false, + "nonstandard": false, + "prototypejs": false, + "qunit": false, + "rhino": false, + "shelljs": false, + "worker": false, + "wsh": false, + "yui": false, + + "globals": { + "jQuery": true, + "$j": true, + "_": true, + "d3": true, + "define": true, + "require": true, + "requirejs": true, + "console": true, + "baseUrl": true, + "key": true, + "Backbone": true, + "Marionette": true, + "Handlebars": true, + "Templates": true, + "t": true, + "tp": true, + "moment": true, + "numeral": true, + "openPopup": true, + "dashboardParameters": true, + "getTemplate": true + } +} diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index 433ab2fbbe3..4ec0a00bfa8 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -59,6 +59,9 @@ module.exports = (grunt) -> '<%= BUILD_PATH %>/js/libs/third-party/d3.js' '<%= BUILD_PATH %>/js/libs/third-party/latinize.js' '<%= BUILD_PATH %>/js/libs/third-party/underscore.js' + '<%= BUILD_PATH %>/js/libs/third-party/backbone.js' + '<%= BUILD_PATH %>/js/libs/third-party/backbone-super.js' + '<%= BUILD_PATH %>/js/libs/third-party/backbone.marionette.js' '<%= BUILD_PATH %>/js/libs/third-party/handlebars.js' '<%= BUILD_PATH %>/js/libs/third-party/select2.js' '<%= BUILD_PATH %>/js/libs/third-party/keymaster.js' @@ -86,10 +89,15 @@ module.exports = (grunt) -> '<%= BUILD_PATH %>/js/libs/sortable.js' '<%= BUILD_PATH %>/js/libs/inputs.js' + '<%= BUILD_PATH %>/js/components/common/dialogs.js' + '<%= BUILD_PATH %>/js/components/common/processes.js' + '<%= BUILD_PATH %>/js/components/common/jquery-isolated-scroll.js' '<%= BUILD_PATH %>/js/components/common/handlebars-extensions.js' '<%= BUILD_PATH %>/js/libs/application.js' + '<%= BUILD_PATH %>/js/libs/csv.js' '<%= BUILD_PATH %>/js/libs/dashboard.js' + '<%= BUILD_PATH %>/js/libs/recent-history.js' '<%= BUILD_PATH %>/js/libs/third-party/require.js' ] @@ -98,35 +106,26 @@ module.exports = (grunt) -> options: baseUrl: '<%= BUILD_PATH %>/js/' preserveLicenseComments: false - optimize: 'none' paths: 'react': 'libs/third-party/react-with-addons' - 'underscore': 'libs/shim/underscore-shim' - 'jquery': 'libs/shim/jquery-shim' - 'backbone': 'libs/third-party/backbone' - 'backbone.marionette': 'libs/third-party/backbone.marionette' - - main: options: - name: 'main' - out: '<%= ASSETS_PATH %>/js/main.js' + 'underscore': 'libs/third-party/shim/underscore-shim' + 'jquery': 'libs/third-party/shim/jquery-shim' + 'backbone': 'libs/third-party/shim/backbone-shim' + 'backbone.marionette': 'libs/third-party/shim/marionette-shim' issuesContext: options: - exclude: ['backbone', 'backbone.marionette'] name: 'apps/issues/app-context' out: '<%= ASSETS_PATH %>/js/apps/issues/app-context.js' selectList: options: - exclude: ['backbone', 'backbone.marionette'] name: 'components/common/select-list' out: '<%= ASSETS_PATH %>/js/components/common/select-list.js' app: options: - exclude: ['backbone', 'backbone.marionette'] name: 'apps/<%= grunt.option("app") %>/app' out: '<%= ASSETS_PATH %>/js/apps/<%= grunt.option("app") %>/app.js' widget: options: - exclude: ['backbone', 'backbone.marionette'] name: 'widgets/<%= grunt.option("widget") %>/widget' out: '<%= ASSETS_PATH %>/js/widgets/<%= grunt.option("widget") %>/widget.js' @@ -134,13 +133,13 @@ module.exports = (grunt) -> concurrent: build: tasks: [ + 'uglify:build' # apps 'build-app:account' 'build-app:api-documentation' 'build-app:coding-rules' 'build-app:computation' 'build-app:custom-measures' - 'build-app:dashboard' 'build-app:drilldown' 'build-app:global-permissions' 'build-app:groups' @@ -163,8 +162,6 @@ module.exports = (grunt) -> # other 'requirejs:issuesContext' 'requirejs:selectList' - # main - 'requirejs:main' ] @@ -267,17 +264,16 @@ module.exports = (grunt) -> expand: true, cwd: '<%= SOURCE_PATH %>/js', src: ['**/*.js'], dest: '<%= BUILD_PATH %>/js' 'assets-js': src: '<%= BUILD_PATH %>/js/sonar.js', dest: '<%= ASSETS_PATH %>/js/sonar.js' - 'assets-libs-js': - expand: true, cwd: '<%= BUILD_PATH %>/js/libs', src: ['**/*.js'], dest: '<%= ASSETS_PATH %>/js/libs' 'assets-all-js': expand: true, cwd: '<%= BUILD_PATH %>/js', src: ['**/*.js'], dest: '<%= ASSETS_PATH %>/js' 'assets-css': src: '<%= BUILD_PATH %>/css/sonar.css', dest: '<%= ASSETS_PATH %>/css/sonar.css' - uglify_parallel: + uglify: build: - expand: true, cwd: '<%= ASSETS_PATH %>/js', src: ['**/*.js'], dest: '<%= ASSETS_PATH %>/js' + src: '<%= ASSETS_PATH %>/js/sonar.js' + dest: '<%= ASSETS_PATH %>/js/sonar.js' replace: @@ -347,7 +343,7 @@ module.exports = (grunt) -> ['copy:assets-css', 'copy:assets-all-js'] grunt.registerTask 'build-suffix', - ['copy:assets-css', 'copy:assets-js', 'copy:assets-libs-js', 'concurrent:build', 'uglify_parallel:build'] + ['copy:assets-css', 'copy:assets-js', 'concurrent:build'] grunt.registerTask 'test-suffix', ['intern:test', 'rename:lcov', 'replace:lcov'] diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 3fb2d923e8e..f464079925c 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -12,10 +12,10 @@ "grunt-contrib-handlebars": "0.9.2", "grunt-contrib-less": "1.0.1", "grunt-contrib-requirejs": "0.4.4", + "grunt-contrib-uglify": "0.9.1", "grunt-contrib-watch": "0.6.1", "grunt-rename": "^0.1.4", "grunt-text-replace": "0.4.0", - "grunt-uglify-parallel": "0.0.1", "intern": "^3.0.0-rc.1", "jit-grunt": "0.9.1", "sinon": "^1.15.4", diff --git a/server/sonar-web/src/main/js/api/navigation.jsx b/server/sonar-web/src/main/js/api/navigation.jsx deleted file mode 100644 index 8204fc34c11..00000000000 --- a/server/sonar-web/src/main/js/api/navigation.jsx +++ /dev/null @@ -1,26 +0,0 @@ -function _request(options) { - let $ = jQuery; - return $.ajax(options); -} - -function _url(path) { - return window.baseUrl + path; -} - -function _typeError(method, message) { - throw new TypeError(`navigation#${method}: ${message}`); -} - -export function global() { - let url = _url('/api/navigation/global'); - return _request({ type: 'GET', url }); -} - -export function component(componentKey) { - if (typeof componentKey !== 'string' || !componentKey.length) { - return _typeError('component', 'please provide componentKey'); - } - let url = _url('/api/navigation/component'); - let data = { componentKey }; - return _request({ type: 'GET', url, data }); -} diff --git a/server/sonar-web/src/main/js/api/users.jsx b/server/sonar-web/src/main/js/api/users.jsx deleted file mode 100644 index 66a5718dfcd..00000000000 --- a/server/sonar-web/src/main/js/api/users.jsx +++ /dev/null @@ -1,13 +0,0 @@ -function _request(options) { - let $ = jQuery; - return $.ajax(options); -} - -function _url(path) { - return window.baseUrl + path; -} - -export function getCurrentUser() { - let url = _url('/api/users/current'); - return _request({ type: 'GET', url }); -} diff --git a/server/sonar-web/src/main/js/apps/account/app.js b/server/sonar-web/src/main/js/apps/account/app.js index efe802f1383..7559a916e48 100644 --- a/server/sonar-web/src/main/js/apps/account/app.js +++ b/server/sonar-web/src/main/js/apps/account/app.js @@ -3,7 +3,7 @@ define([ ], function (ChangePasswordView) { var $ = jQuery; - var shouldShowAvatars = window.sonar.properties['sonar.lf.enableGravatar']; + var shouldShowAvatars = window.SS && window.SS.lf && window.SS.lf.enableGravatar; var favorites = $('.js-account-favorites tr'); function showExtraFavorites () { 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 f21ca4be2ce..86522a8dc40 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); if (this.checkPasswords()) { this.sendRequest(); } else { - this.showErrors([{ msg: window.t('user.password_doesnt_match_confirmation') }]); + this.showErrors([{ msg: t('user.password_doesnt_match_confirmation') }]); } }, @@ -32,7 +32,7 @@ define([ }; var opts = { type: 'POST', - url: window.baseUrl + '/api/users/change_password', + url: 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 df6b6e6b345..6df5db30ee5 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 e98839b6428..683485c101b 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,7 +1,25 @@ +/* + * 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 (Marionette, ActionView) { +], function (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 7e211afe09e..bc38d046613 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,13 +1,30 @@ +/* + * 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 (Backbone, Marionette, Router, Controller, Layout, List, ListView, FiltersView) { +], function (Router, Controller, Layout, List, ListView, FiltersView) { var $ = jQuery, App = new Marionette.Application(), @@ -52,7 +69,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + window.requestMessages().done(function () { + 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 0e33de26422..69ae9413bac 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,9 +1,26 @@ +/* + * 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 (Backbone, Marionette, ActionsView, HeaderView) { +], function (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 525dfeb6030..8465cfe9db3 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 5a2a7641860..259fffae1c6 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 79619bda267..2c88eb9e13f 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 6478b6471e9..67b30bb34b0 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,8 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 b0b22a0ae50..b90ba7f725a 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,7 +1,25 @@ +/* + * 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 (Marionette, ItemView) { +], function (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 e525c84a818..131b3352e8d 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,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { 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 65f1c62a6fd..fee3493fb18 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,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { 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 67b18ef2b11..61f5e97ddd2 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,6 +1,4 @@ define([ - 'backbone', - 'backbone.marionette', './models/state', './layout', './models/rules', @@ -15,9 +13,7 @@ define([ './facets-view', './filters-view' ], - function (Backbone, - Marionette, - State, + function (State, Layout, Rules, Facets, @@ -75,7 +71,7 @@ define([ App.manualRepository = function () { return { key: 'manual', - name: window.t('coding_rules.manual_rule'), + name: t('coding_rules.manual_rule'), language: 'none' }; }; @@ -108,7 +104,7 @@ define([ }); App.on('start', function (options) { - $.when(appXHR).done(function () { + $.when(window.requestMessages(), 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 d9bff5b021d..bdd2cbb5f34 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 = window.tp('coding_rules.bulk_change.success', profileName, profileBase.language, succeeded); + message = tp('coding_rules.bulk_change.success', profileName, profileBase.language, succeeded); this.ui.messagesContainer.append('
' + message + '
'); }, showWarnMessage: function (profile, succeeded, failed) { var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }), profileName = profileBase != null ? profileBase.name : profile, - message = window.tp('coding_rules.bulk_change.warning', profileName, profileBase.language, succeeded, failed); + message = tp('coding_rules.bulk_change.warning', profileName, profileBase.language, succeeded, failed); this.ui.messagesContainer.append('
' + message + '
'); }, diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js index 7cabf7b44e2..6695943968d 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', window.t('coding_rules.filters.active_severity.inactive')); + this.$el.prop('title', 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 b43aadb3ff1..7aad57ad48c 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 window.baseUrl; + return baseUrl; }, onRender: function () { @@ -42,17 +42,17 @@ define([ prepareSearch: function () { this.$('.js-custom-value').select2({ - placeholder: window.t('search_verb'), + placeholder: t('search_verb'), minimumInputLength: 1, allowClear: false, formatNoMatches: function () { - return window.t('select2.noMatches'); + return t('select2.noMatches'); }, formatSearching: function () { - return window.t('select2.searching'); + return t('select2.searching'); }, formatInputTooShort: function () { - return window.tp('select2.tooShort', 1); + return 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 50bef351339..1a05fff7479 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', window.t('coding_rules.filters.inheritance.inactive')); + this.$el.prop('title', 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: window.t('coding_rules.filters.inheritance', key.toLowerCase()), + label: 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 1873599e3cd..478c589032c 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 window.baseUrl + '/api/languages/list'; + return 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 ae064ba3b2a..08283dc5b18 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 window.baseUrl + '/api/rules/repositories'; + return 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 2d2b6b654e8..96854e47564 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: window.t('rules.status', value.val.toLowerCase()) }); + return _.extend(value, { label: 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 3e6a064ef6c..9a5b0f21570 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 window.baseUrl + '/api/rules/tags'; + return 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 c7a289e9c29..4626acd9d02 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,8 +1,26 @@ +/* + * 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 (Marionette, ManualRuleCreationView) { +], function (ManualRuleCreationView) { return Marionette.ItemView.extend({ template: Templates['coding-rules-filters'], @@ -18,9 +36,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { - canWrite: this.options.app.canWrite - }); + return _.extend(this._super(), { 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 d2fff28e341..34f66a61a2e 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,8 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 fbc5ecdd8b0..51993df4b98 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,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { 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 39a833309e5..f1f83bcf1bd 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,7 +1,25 @@ +/* + * 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 (Backbone, Rule) { +], function (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 f1536004dff..05856342aa4 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,6 +1,23 @@ +/* + * 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', @@ -10,12 +27,9 @@ define([ './rule/manual-rule-creation-view', './rule/custom-rule-creation-view', './rule/rule-issues-view', - '../../components/common/dialogs', './templates' ], - function (Backbone, - Marionette, - Rules, + function (Rules, MetaView, DescView, ParamView, @@ -23,8 +37,7 @@ define([ CustomRulesView, ManualRuleCreationView, CustomRuleCreationView, - IssuesView, - confirmDialog) { + IssuesView) { var $ = jQuery; @@ -150,9 +163,9 @@ define([ deleteRule: function () { var that = this, ruleType = this.model.has('templateKey') ? 'custom' : 'manual'; - confirmDialog({ - title: window.t('delete'), - html: window.tp('coding_rules.delete.' + ruleType + '.confirm', this.model.get('name')), + window.confirmDialog({ + title: t('delete'), + html: 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 1ee49177642..e15a1149e69 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,9 +19,8 @@ */ define([ 'components/common/modal-form', - '../../../libs/csv', '../templates' -], function (ModalFormView, csvEscape) { +], function (ModalFormView) { var $ = jQuery; @@ -129,7 +128,7 @@ define([ }; }).get(); options.params = params.map(function (param) { - return param.key + '=' + csvEscape(param.value); + return param.key + '=' + window.csvEscape(param.value); }).join(';'); this.sendRequest(action, options); }, @@ -173,7 +172,7 @@ define([ }).fail(function (jqXHR) { if (jqXHR.status === 409) { that.existingRule = jqXHR.responseJSON.rule; - that.showErrors([], [{ msg: window.t('coding_rules.reactivate.help') }]); + that.showErrors([], [{ msg: t('coding_rules.reactivate.help') }]); that.ui.customRuleCreationCreate.addClass('hidden'); that.ui.customRuleCreationReactivate.removeClass('hidden'); } else { @@ -195,7 +194,7 @@ define([ var statuses = ['READY', 'BETA', 'DEPRECATED'].map(function (status) { return { id: status, - text: window.t('rules.status', status.toLowerCase()) + text: 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 5dc0c9ac732..e50b7c11005 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,8 +1,25 @@ +/* + * 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 (Marionette, confirmDialog) { +], function () { var $ = jQuery; @@ -20,9 +37,9 @@ define([ deleteRule: function () { var that = this; - confirmDialog({ - title: window.t('delete'), - html: window.t('are_you_sure'), + window.confirmDialog({ + title: t('delete'), + html: 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 bd51911930d..56ae2a95833 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,9 +1,27 @@ +/* + * 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 (Marionette, CustomRuleView, CustomRuleCreationView) { +], function (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 32c707f6c9a..66617fc33ed 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: window.t('coding_rules.reactivate.help') }]); + that.showErrors([], [{ msg: 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 663895b4823..87296ca2e0f 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,9 +1,26 @@ +/* + * 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 (Backbone, ModalForm, csvEscape) { +], function (ModalForm) { var $ = jQuery; @@ -11,7 +28,7 @@ define([ template: Templates['coding-rules-profile-activation'], ui: function () { - return _.extend(ModalForm.prototype.ui.apply(this, arguments), { + return _.extend(this._super(), { qualityProfileSelect: '#coding-rules-quality-profile-activation-select', qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity', qualityProfileActivate: '#coding-rules-quality-profile-activation-activate', @@ -20,13 +37,13 @@ define([ }, events: function () { - return _.extend(ModalForm.prototype.events.apply(this, arguments), { + return _.extend(this._super(), { 'click @ui.qualityProfileActivate': 'activate' }); }, onRender: function () { - ModalForm.prototype.onRender.apply(this, arguments); + this._super(); this.ui.qualityProfileSelect.select2({ width: '250px', @@ -65,7 +82,7 @@ define([ }; }).get(), paramsHash = (params.map(function (param) { - return param.key + '=' + csvEscape(param.value); + return param.key + '=' + window.csvEscape(param.value); })).join(';'); if (this.model) { @@ -129,7 +146,7 @@ define([ var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')); - return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 cd36bb7d3d9..c84213c614d 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,8 +1,25 @@ +/* + * 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 (Marionette, confirmDialog) { +], function () { return Marionette.ItemView.extend({ template: Templates['coding-rules-rule-description'], @@ -63,8 +80,8 @@ define([ removeExtendedDescription: function () { var that = this; - confirmDialog({ - html: window.t('coding_rules.remove_extended_description.confirm'), + window.confirmDialog({ + html: 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 373c4a54a45..ebbd0f62149 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 f31fbb7656e..d8565818c52 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,8 +1,26 @@ +/* + * 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 (Marionette, RuleFilterMixin) { +], function (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 d49a6adcb21..2e5a927621d 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 5701de25f80..42902e38c3c 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,10 +1,26 @@ +/* + * 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 (Backbone, Marionette, ProfileActivationView, confirmDialog) { +], function (ProfileActivationView) { return Marionette.ItemView.extend({ tagName: 'tr', @@ -49,9 +65,9 @@ define([ revert: function () { var that = this, ruleKey = this.options.rule.get('key'); - confirmDialog({ - title: window.t('coding_rules.revert_to_parent_definition'), - html: window.tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name), + window.confirmDialog({ + title: t('coding_rules.revert_to_parent_definition'), + html: tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name), yesHandler: function () { return jQuery.ajax({ type: 'POST', @@ -71,9 +87,9 @@ define([ deactivate: function () { var that = this, ruleKey = this.options.rule.get('key'); - confirmDialog({ - title: window.t('coding_rules.deactivate'), - html: window.tp('coding_rules.deactivate.confirm'), + window.confirmDialog({ + title: t('coding_rules.deactivate'), + html: 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 562f349939a..fc7662e5073 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,9 +1,27 @@ +/* + * 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 (Marionette, ProfileView, ProfileActivationView) { +], function (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 20b4f0f4b3f..2aefada2578 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,12 +1,29 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +/* + * 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 () { return Marionette.ItemView.extend({ className: 'search-navigator-no-results', template: function () { - return window.t('coding_rules.no_results'); + return 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 f3c8de7de57..1041a326de9 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,11 +1,28 @@ +/* + * 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 (Backbone, WorkspaceListItemView, ProfileActivationView, confirmDialog, RuleFilterMixin) { +], function (WorkspaceListItemView, ProfileActivationView, RuleFilterMixin) { return WorkspaceListItemView.extend(RuleFilterMixin).extend({ className: 'coding-rule', @@ -61,9 +78,9 @@ define([ var that = this, ruleKey = this.model.get('key'), activation = this.model.get('activation'); - confirmDialog({ - title: window.t('coding_rules.deactivate'), - html: window.tp('coding_rules.deactivate.confirm'), + window.confirmDialog({ + title: t('coding_rules.deactivate'), + html: 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 73ac19753ac..43e64d86b5d 100644 --- a/server/sonar-web/src/main/js/apps/computation/app.js +++ b/server/sonar-web/src/main/js/apps/computation/app.js @@ -1,6 +1,4 @@ define([ - 'backbone', - 'backbone.marionette', './router', './layout', './reports', @@ -8,7 +6,7 @@ define([ './search-view', './list-view', './list-footer-view' -], function (Backbone, Marionette, Router, Layout, Reports, HeaderView, SearchView, ListView, ListFooterView) { +], function (Router, Layout, Reports, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -49,7 +47,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + window.requestMessages().done(function () { + 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 6a36a006cbb..8e010c0eded 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 b8de14574a0..2e7edcd22bf 100644 --- a/server/sonar-web/src/main/js/apps/computation/layout.js +++ b/server/sonar-web/src/main/js/apps/computation/layout.js @@ -1,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 c6f98d9238f..5034f25a3e8 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 44e5e32dcaf..afcf2f15d3f 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 b56e64f951d..24878864d30 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,8 +1,7 @@ define([ - 'backbone.marionette', './list-item-view', './templates' -], function (Marionette, ListItemView) { +], function (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 a1895bd4d3c..2eac3f23e84 100644 --- a/server/sonar-web/src/main/js/apps/computation/report.js +++ b/server/sonar-web/src/main/js/apps/computation/report.js @@ -1,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { 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 04b6eae2eaa..9c8144333bb 100644 --- a/server/sonar-web/src/main/js/apps/computation/reports.js +++ b/server/sonar-web/src/main/js/apps/computation/reports.js @@ -1,7 +1,6 @@ define([ - 'backbone', './report' -], function (Backbone, Report) { +], function (Report) { return Backbone.Collection.extend({ model: Report, @@ -16,7 +15,7 @@ define([ fetch: function (options) { var opts = _.defaults(options || {}, { q: this.q }, { q: 'history' }); - opts.url = window.baseUrl + '/api/computation/' + opts.q; + opts.url = 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 611a685ea19..6d874801cd3 100644 --- a/server/sonar-web/src/main/js/apps/computation/router.js +++ b/server/sonar-web/src/main/js/apps/computation/router.js @@ -1,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { 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 68a0cb7dd34..75ab65c4dad 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 ad941ec3f65..de6316fb658 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,11 +1,10 @@ define([ - 'backbone.marionette', './layout', './custom-measures', './header-view', './list-view', './list-footer-view' -], function (Marionette, Layout, CustomMeasures, HeaderView, ListView, ListFooterView) { +], function (Layout, CustomMeasures, HeaderView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -17,13 +16,13 @@ define([ // Collection this.customMeasures = new CustomMeasures({ - projectId: options.component.uuid + projectId: options.projectId }); // Header View this.headerView = new HeaderView({ collection: this.customMeasures, - projectId: options.component.uuid + projectId: options.projectId }); this.layout.headerRegion.show(this.headerView); @@ -44,7 +43,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + window.requestMessages().done(function () { + 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 aaa8c2d1b66..fce8bf4fbdf 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,12 +1,10 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ idAttribute: 'id', urlRoot: function () { - return window.baseUrl + '/api/custom_measures'; + return 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 ae23b352832..2febc1ea652 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,7 +1,6 @@ define([ - 'backbone', './custom-measure' -], function (Backbone, CustomMeasure) { +], function (CustomMeasure) { return Backbone.Collection.extend({ model: CustomMeasure, @@ -11,7 +10,7 @@ define([ }, url: function () { - return window.baseUrl + '/api/custom_measures/search'; + return baseUrl + '/api/custom_measures/search'; }, parse: function (r) { @@ -25,7 +24,7 @@ define([ var opts = _.defaults(options || {}, { data: {} }); this.q = opts.data.q; opts.data.projectId = this.projectId; - return Backbone.Collection.prototype.fetch.call(this, opts); + return this._super(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 b3092fd0343..1838b83e044 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 15d9e405098..30ed30082b9 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 () { - ModalForm.prototype.onRender.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); this.$('#create-custom-measure-metric').select2({ width: '250px', @@ -23,12 +23,12 @@ define([ }, onDestroy: function () { - ModalForm.prototype.onDestroy.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); this.sendRequest(); }, @@ -42,7 +42,7 @@ define([ serializeData: function () { var metrics = this.getAvailableMetrics(), isNew = !this.model; - return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 87bc3f1d628..8b22efcec5a 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,8 +1,7 @@ define([ - 'backbone.marionette', './create-view', './templates' -], function (Marionette, CreateView) { +], function (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 bf72535e6dc..b4aa4ece791 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 6ca83eb4990..d66c27ad335 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['custom-measures-list-footer'], @@ -24,7 +23,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 b2da300354b..97d9671eb17 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,9 +1,8 @@ define([ - 'backbone.marionette', './update-view', './delete-view', './templates' -], function (Marionette, UpdateView, DeleteView) { +], function (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 b56e64f951d..24878864d30 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,8 +1,7 @@ define([ - 'backbone.marionette', './list-item-view', './templates' -], function (Marionette, ListItemView) { +], function (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 deleted file mode 100644 index 98ae2f4691f..00000000000 --- a/server/sonar-web/src/main/js/apps/dashboard/app.jsx +++ /dev/null @@ -1,10 +0,0 @@ -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 95d61812d0d..e46612c1a13 100644 --- a/server/sonar-web/src/main/js/apps/drilldown/app.js +++ b/server/sonar-web/src/main/js/apps/drilldown/app.js @@ -1,12 +1,30 @@ +/* + * 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 (Marionette, SourceViewer) { +], function (SourceViewer) { var $ = jQuery, App = new Marionette.Application(), - init = function () { - App.addRegions({ viewerRegion: '#source-viewer' }); + init = function (options) { + App.addRegions({ viewerRegion: options.el }); $('.js-drilldown-link').on('click', function (e) { e.preventDefault(); $(e.currentTarget).closest('table').find('.selected').removeClass('selected'); @@ -23,8 +41,10 @@ define([ }); }; - App.on('start', function () { - init.call(App); + App.on('start', function (options) { + window.requestMessages().done(function () { + 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 478924e9233..28dc73b7f42 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,7 +5,9 @@ const $ = jQuery; export default { start(options) { - var el = document.querySelector(options.el); - React.render(
, el); + window.requestMessages().done(() => { + var el = document.querySelector(options.el); + React.render(
, 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 950c9888a61..ef87bb94186 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 @@ -24,7 +24,7 @@ define([ template: Templates['global-permissions-groups'], onRender: function () { - Modal.prototype.onRender.apply(this, arguments); + this._super(); new window.SelectList({ el: this.$('#global-permissions-groups'), width: '100%', @@ -49,7 +49,7 @@ define([ onDestroy: function () { this.options.refresh(); - Modal.prototype.onDestroy.apply(this, arguments); + this._super(); } }); 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 8146bfef5e9..4e85024f480 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 @@ -24,7 +24,7 @@ define([ template: Templates['global-permissions-users'], onRender: function () { - Modal.prototype.onRender.apply(this, arguments); + this._super(); new window.SelectList({ el: this.$('#global-permissions-users'), width: '100%', @@ -49,7 +49,7 @@ define([ onDestroy: function () { this.options.refresh(); - Modal.prototype.onDestroy.apply(this, arguments); + this._super(); } }); 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 abd897234a5..55c6dfef534 100644 --- a/server/sonar-web/src/main/js/apps/groups/app.js +++ b/server/sonar-web/src/main/js/apps/groups/app.js @@ -1,12 +1,11 @@ define([ - 'backbone.marionette', './layout', './groups', './header-view', './search-view', './list-view', './list-footer-view' -], function (Marionette, Layout, Groups, HeaderView, SearchView, ListView, ListFooterView) { +], function (Layout, Groups, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -38,7 +37,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + window.requestMessages().done(function () { + 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 14c35a1873f..85b33a632b5 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); this.sendRequest(); }, @@ -28,10 +28,10 @@ define([ }); }, - showErrors: function () { + showErrors: function (errors, warnings) { this.$('.js-modal-text').addClass('hidden'); this.disableForm(); - ModalForm.prototype.showErrors.apply(this, arguments); + this._super(errors, warnings); } }); 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 29a654db85e..7e3c26b98ee 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 () { - ModalForm.prototype.onRender.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onDestroy: function () { - ModalForm.prototype.onDestroy.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 5d7807b51d2..aced6727b91 100644 --- a/server/sonar-web/src/main/js/apps/groups/group.js +++ b/server/sonar-web/src/main/js/apps/groups/group.js @@ -1,10 +1,8 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ urlRoot: function () { - return window.baseUrl + '/api/usergroups'; + return 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 46c46fe8078..dcfbb8c731b 100644 --- a/server/sonar-web/src/main/js/apps/groups/groups.js +++ b/server/sonar-web/src/main/js/apps/groups/groups.js @@ -1,13 +1,12 @@ define([ - 'backbone', './group' -], function (Backbone, Group) { +], function (Group) { return Backbone.Collection.extend({ model: Group, url: function () { - return window.baseUrl + '/api/usergroups/search'; + return baseUrl + '/api/usergroups/search'; }, parse: function (r) { @@ -20,7 +19,7 @@ define([ fetch: function (options) { var d = (options && options.data) || {}; this.q = d.q; - return Backbone.Collection.prototype.fetch.apply(this, arguments); + return this._super(options); }, 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 a60f0c51f34..da6f7f60919 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,8 +1,7 @@ define([ - 'backbone.marionette', './create-view', './templates' -], function (Marionette, CreateView) { +], function (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 e6cddd674ce..18f6c7738d1 100644 --- a/server/sonar-web/src/main/js/apps/groups/layout.js +++ b/server/sonar-web/src/main/js/apps/groups/layout.js @@ -1,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 ee4467b3e87..3c0fbe198c5 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['groups-list-footer'], @@ -24,7 +23,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 20a24cf3bc0..45ce8b9688a 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,10 +1,9 @@ define([ - 'backbone.marionette', './update-view', './delete-view', './users-view', './templates' -], function (Marionette, UpdateView, DeleteView, UsersView) { +], function (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 b56e64f951d..24878864d30 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,8 +1,7 @@ define([ - 'backbone.marionette', './list-item-view', './templates' -], function (Marionette, ListItemView) { +], function (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 efcd9247db8..1540d7eb36e 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 5db80139c8b..de5901fc5f1 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,8 +8,7 @@ define([ template: Templates['groups-users'], onRender: function () { - Modal.prototype.onRender.apply(this, arguments); - //noinspection Eslint + this._super(); new window.SelectList({ el: this.$('#groups-users'), width: '100%', @@ -19,9 +18,9 @@ define([ return item.name + '
' + item.login + ''; }, queryParam: 'q', - 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', + searchUrl: baseUrl + '/api/usergroups/users?ps=100&id=' + this.model.id, + selectUrl: baseUrl + '/api/usergroups/add_user', + deselectUrl: baseUrl + '/api/usergroups/remove_user', extra: { id: this.model.id }, @@ -36,7 +35,7 @@ define([ onDestroy: function () { this.model.collection.refresh(); - Modal.prototype.onDestroy.apply(this, arguments); + this._super(); } }); 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 63221207568..3d7db3aa2ef 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,6 +1,4 @@ define([ - 'backbone', - 'backbone.marionette', './models/state', './layout', './models/issues', @@ -12,19 +10,19 @@ define([ './workspace-header-view', './facets-view', './helpers/format-facet-value' -], function (Backbone, Marionette, State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, - WorkspaceHeaderView, FacetsView) { +], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView, + FacetsView) { var $ = jQuery, App = new Marionette.Application(), init = function (options) { - this.options = options; + this.config = options.config; this.state = new State({ isContext: true, - contextQuery: { componentUuids: options.component.uuid }, - contextComponentUuid: options.component.uuid, - contextComponentName: options.component.name, - contextComponentQualifier: options.component.qualifier + contextQuery: { componentUuids: options.config.resource }, + contextComponentUuid: options.config.resource, + contextComponentName: options.config.resourceName, + contextComponentQualifier: options.config.resourceQualifier }); this.updateContextFacets(); this.list = new Issues(); @@ -64,7 +62,7 @@ define([ }; App.getContextQuery = function () { - return { componentUuids: this.options.component.uuid }; + return { componentUuids: this.config.resource }; }; App.getRestrictedFacets = function () { @@ -83,13 +81,15 @@ define([ facetsFromServer = this.state.get('facetsFromServer'); return this.state.set({ facets: facets, - allFacets: _.difference(allFacets, this.getRestrictedFacets()[this.options.component.qualifier]), - facetsFromServer: _.difference(facetsFromServer, this.getRestrictedFacets()[this.options.component.qualifier]) + allFacets: _.difference(allFacets, this.getRestrictedFacets()[this.config.resourceQualifier]), + facetsFromServer: _.difference(facetsFromServer, this.getRestrictedFacets()[this.config.resourceQualifier]) }); }; App.on('start', function (options) { - init.call(App, options); + $.when(window.requestMessages()).done(function () { + 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 f07102efcf7..12e5671c5c3 100644 --- a/server/sonar-web/src/main/js/apps/issues/app.js +++ b/server/sonar-web/src/main/js/apps/issues/app.js @@ -1,6 +1,4 @@ define([ - 'backbone', - 'backbone.marionette', './models/state', './layout', './models/issues', @@ -13,8 +11,8 @@ define([ './facets-view', './filters-view', './helpers/format-facet-value' -], function (Backbone, Marionette, State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, - WorkspaceHeaderView, FacetsView, FiltersView) { +], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView, + FacetsView, FiltersView) { var $ = jQuery, App = new Marionette.Application(), @@ -63,7 +61,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + $.when(window.requestMessages()).done(function () { + 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 43b60af89e9..8792113e213 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; } - selectedIssueView.find('.js-issue-' + action).click(); + return 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 29ae5db89f3..a35311fa576 100644 --- a/server/sonar-web/src/main/js/apps/issues/controller.js +++ b/server/sonar-web/src/main/js/apps/issues/controller.js @@ -1,9 +1,8 @@ define([ - 'backbone', 'components/navigator/controller', './component-viewer/main', './workspace-home-view' -], function (Backbone, Controller, ComponentViewer, HomeView) { +], function (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 26fa0f3899c..3645b7215d6 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 window.baseUrl + '/api/users/search'; + return 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 7bf8f5e30de..ee987a3d067 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 window.baseUrl + '/api/issues/authors'; + return baseUrl + '/api/issues/authors'; }, prepareSearch: function () { @@ -13,13 +13,13 @@ define([ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return window.t('select2.noMatches'); + return t('select2.noMatches'); }, formatSearching: function () { - return window.t('select2.searching'); + return t('select2.searching'); }, formatInputTooShort: function () { - return window.tp('select2.tooShort', 2); + return 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 8cb5f444520..923e1d4e6d1 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(BaseFacet.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 0b198e1853c..11b3aebdd74 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 window.t('select2.noMatches'); + return t('select2.noMatches'); }, formatSearching: function () { - return window.t('select2.searching'); + return t('select2.searching'); }, formatInputTooShort: function () { - return window.tp('select2.tooShort', 2); + return 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 f18c712d2f6..3418158fba4 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 window.baseUrl + '/api/languages/list'; + return baseUrl + '/api/languages/list'; }, prepareSearch: function () { @@ -13,13 +13,13 @@ define([ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return window.t('select2.noMatches'); + return t('select2.noMatches'); }, formatSearching: function () { - return window.t('select2.searching'); + return t('select2.searching'); }, formatInputTooShort: function () { - return window.tp('select2.tooShort', 2); + return 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 ac81b8c3b8d..454b4e96803 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,9 +16,7 @@ define([ }, serializeData: function () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - mode: this.options.app.state.getFacetMode() - }); + return _.extend(this._super(), { 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 15e174ebf38..429d9e876c2 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 window.baseUrl + '/api/components/search'; + return baseUrl + '/api/components/search'; } else { - return window.baseUrl + '/api/resources/search?f=s2&q=TRK&display_uuid=true'; + return baseUrl + '/api/resources/search?f=s2&q=TRK&display_uuid=true'; } }, @@ -29,13 +29,13 @@ define([ minimumInputLength: 2, allowClear: false, formatNoMatches: function () { - return window.t('select2.noMatches'); + return t('select2.noMatches'); }, formatSearching: function () { - return window.t('select2.searching'); + return t('select2.searching'); }, formatInputTooShort: function () { - return window.tp('select2.tooShort', 2); + return 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 6bbb5c5e8ad..6340aefe04f 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 window.baseUrl + '/api/users/search'; + return 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 55002f35a9b..569fcf6c7de 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 = window.baseUrl + '/api/rules/search?f=name,langName', + var url = 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 window.t('select2.noMatches'); + return t('select2.noMatches'); }, formatSearching: function () { - return window.t('select2.searching'); + return t('select2.searching'); }, formatInputTooShort: function () { - return window.tp('select2.tooShort', 2); + return 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 9a70ea7a006..96a0d85729e 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 = window.baseUrl + '/api/issues/tags?ps=10', + var url = 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 window.t('select2.noMatches'); + return t('select2.noMatches'); }, formatSearching: function () { - return window.t('select2.searching'); + return 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 896a3d3abb7..d219c1e0fd4 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 c448fb1f0de..28a6a86e212 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); - ActionOptionsView.prototype.selectOption.apply(this, arguments); + this._super(e); }, serializeData: function () { - return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 3edcb430d41..5dbbcaf1139 100644 --- a/server/sonar-web/src/main/js/apps/issues/layout.js +++ b/server/sonar-web/src/main/js/apps/issues/layout.js @@ -1,8 +1,6 @@ define([ - 'backbone.marionette', - '../../components/common/jquery-isolated-scroll', './templates' -], function (Marionette) { +], function () { 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 d1cbabc4d4a..aa31f8ab267 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,10 +1,8 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ url: function () { - return window.baseUrl + '/api/issue_filters/show/' + this.id; + return 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 98c5507c645..34a46690bfe 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,7 +1,6 @@ define([ - 'backbone', './filter' -], function (Backbone, Filter) { +], function (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 2a096b4db32..6266434fa23 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)); - Issue.prototype.reset.call(this, attrs, options); + return this._super(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 7f613e0adb7..aca2e2ac2bf 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,13 +1,12 @@ define([ - 'backbone', './issue' -], function (Backbone, Issue) { +], function (Issue) { return Backbone.Collection.extend({ model: Issue, url: function () { - return window.baseUrl + '/api/issues/search'; + return 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 5fc1867969e..928b4b42c5f 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 () { - WorkspaceHeaderView.prototype.onDestroy.apply(this, arguments); + this._super(); window.onBulkIssues = this._onBulkIssues; }, @@ -51,7 +51,7 @@ define([ render: function () { if (!this._suppressUpdate) { - WorkspaceHeaderView.prototype.render.apply(this, arguments); + this._super(); } }, @@ -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(WorkspaceHeaderView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 c501d4af3cf..942e86e4ba7 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,23 +1,21 @@ define([ - 'backbone', - 'backbone.marionette', './templates' -], function (Backbone, Marionette) { +], function () { var $ = jQuery; Handlebars.registerHelper('issuesHomeLink', function (property, value) { - return window.baseUrl + '/issues/search#resolved=false|createdInLast=1w|' + + return baseUrl + '/issues/search#resolved=false|createdInLast=1w|' + property + '=' + (encodeURIComponent(value)); }); Handlebars.registerHelper('myIssuesHomeLink', function (property, value) { - return window.baseUrl + '/issues/search#resolved=false|createdInLast=1w|assignees=__me__|' + + return baseUrl + '/issues/search#resolved=false|createdInLast=1w|assignees=__me__|' + property + '=' + (encodeURIComponent(value)); }); Handlebars.registerHelper('issueFilterHomeLink', function (id) { - return window.baseUrl + '/issues/search#id=' + id; + return 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 4b85cce7b32..ada57f15a2d 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,12 +1,10 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +define(function () { return Marionette.ItemView.extend({ className: 'search-navigator-no-results', template: function () { - return window.t('issue_filter.no_issues'); + return 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 deleted file mode 100644 index c2ea47733e2..00000000000 --- a/server/sonar-web/src/main/js/apps/main/app.jsx +++ /dev/null @@ -1,171 +0,0 @@ -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/search': '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': 'project-permissions/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() { - if (window.location.pathname.indexOf('/sessions/') !== -1) { - // do not run any app on the login page - return; - } - - 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 52fc0c26e1e..cc7b016bef0 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/app.js +++ b/server/sonar-web/src/main/js/apps/maintenance/app.js @@ -1,8 +1,6 @@ define([ - 'backbone', - 'backbone.marionette', './main-view' -], function (Backbone, Marionette, MainView) { +], function (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 8f7d0eea860..47b380973da 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,8 +1,6 @@ define([ - 'backbone', - 'backbone.marionette', './templates' -], function (Backbone, Marionette) { +], function () { var $ = jQuery; @@ -17,7 +15,7 @@ define([ var that = this; this.requestOptions = { type: 'GET', - url: window.baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') + url: baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status') }; setInterval(function () { that.refresh(); @@ -57,9 +55,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { - setup: this.options.setup - }); + return _.extend(this._super(), { 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 0941401c0ad..80215acba17 100644 --- a/server/sonar-web/src/main/js/apps/markdown/app.js +++ b/server/sonar-web/src/main/js/apps/markdown/app.js @@ -1,7 +1,23 @@ -define([ - 'backbone.marionette', - './markdown-help-view' -], function (Marionette, MarkdownView) { +/* + * 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) { 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 68426edcb19..050128861bd 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,7 +1,23 @@ -define([ - 'backbone.marionette', - './templates' -], function (Marionette) { +/* + * 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 () { 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 ad43571ffec..d5f3110dbc5 100644 --- a/server/sonar-web/src/main/js/apps/measures/app.js +++ b/server/sonar-web/src/main/js/apps/measures/app.js @@ -18,7 +18,6 @@ * 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', @@ -29,7 +28,7 @@ define([ 'components/navigator/filters/string-filters', 'components/navigator/filters/metric-filters' ], - function (Marionette, FilterBar, BaseFilters, CheckboxFilterView, ChoiceFilters, AjaxSelectFilters, FavoriteFilters, + function (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 832f72bcd02..4e42d95a09d 100644 --- a/server/sonar-web/src/main/js/apps/metrics/app.js +++ b/server/sonar-web/src/main/js/apps/metrics/app.js @@ -1,11 +1,10 @@ define([ - 'backbone.marionette', './layout', './metrics', './header-view', './list-view', './list-footer-view' -], function (Marionette, Layout, Metrics, HeaderView, ListView, ListFooterView) { +], function (Layout, Metrics, HeaderView, ListView, ListFooterView) { var $ = jQuery, App = new Marionette.Application(), @@ -55,7 +54,7 @@ define([ }; App.on('start', function (options) { - $.when(App.requestDomains(), App.requestTypes()).done(function () { + $.when(window.requestMessages(), 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 2f8bd2a7222..8719b9fdb3a 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 18dbdbbf174..03e66f715b6 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; - ModalForm.prototype.onRender.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); this.$('#create-metric-domain').select2({ width: '250px', @@ -36,17 +36,17 @@ define([ }, onDestroy: function () { - ModalForm.prototype.onDestroy.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); this.sendRequest(); }, serializeData: function () { - return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 bc5f6891617..78a9b0da0d0 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,8 +1,7 @@ define([ - 'backbone.marionette', './create-view', './templates' -], function (Marionette, CreateView) { +], function (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 59ef53f5c3c..9575307d96f 100644 --- a/server/sonar-web/src/main/js/apps/metrics/layout.js +++ b/server/sonar-web/src/main/js/apps/metrics/layout.js @@ -1,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 806ddc9c863..932dfd6d35f 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['metrics-list-footer'], @@ -24,7 +23,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 c1b84f3baca..c6989e3b7b3 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,9 +1,8 @@ define([ - 'backbone.marionette', './update-view', './delete-view', './templates' -], function (Marionette, UpdateView, DeleteView) { +], function (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 8eca5ef012f..b015c65d966 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,8 +1,7 @@ define([ - 'backbone.marionette', './list-item-view', './templates' -], function (Marionette, ListItemView) { +], function (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 8a2c3e82e49..cb160c882d0 100644 --- a/server/sonar-web/src/main/js/apps/metrics/metric.js +++ b/server/sonar-web/src/main/js/apps/metrics/metric.js @@ -1,12 +1,10 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ idAttribute: 'id', urlRoot: function () { - return window.baseUrl + '/api/metrics'; + return 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 4ff94e99b29..393ebe3c2b1 100644 --- a/server/sonar-web/src/main/js/apps/metrics/metrics.js +++ b/server/sonar-web/src/main/js/apps/metrics/metrics.js @@ -1,13 +1,12 @@ define([ - 'backbone', './metric' -], function (Backbone, Metric) { +], function (Metric) { return Backbone.Collection.extend({ model: Metric, url: function () { - return window.baseUrl + '/api/metrics/search'; + return baseUrl + '/api/metrics/search'; }, parse: function (r) { @@ -21,7 +20,7 @@ define([ var opts = _.defaults(options || {}, { data: {} }); this.q = opts.data.q; opts.data.isCustom = true; - return Backbone.Collection.prototype.fetch.call(this, opts); + return this._super(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 04b0f1018fc..1362bb8976b 100644 --- a/server/sonar-web/src/main/js/apps/nav/app.jsx +++ b/server/sonar-web/src/main/js/apps/nav/app.jsx @@ -5,9 +5,11 @@ import SettingsNav from './settings/settings-nav'; export default { start(options) { - this.renderGlobalNav(options); - options.space === 'component' && this.renderComponentNav(options); - options.space === 'settings' && this.renderSettingsNav(options); + window.requestMessages().done(() => { + 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 5115a27f73b..c50cd53be52 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,10 +13,6 @@ 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 fdc8a089e69..855482981d9 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,43 +3,47 @@ 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'; -const TOP_LEVEL_QUALIFIERS = ['TRK', 'VW', 'SVW', 'DEV']; +let $ = jQuery; export default React.createClass({ + getInitialState() { + return { component: {}, conf: {} }; + }, + componentDidMount() { - this.addToHistory(); + this.loadDetails(); }, - 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()); - } + 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 || {} + }); + }); }, render() { return (
+ component={this.state.component.key} + favorite={this.state.component.isFavorite} + canBeFavorite={this.state.component.canBeFavorite}/> + breadcrumbs={this.state.component.breadcrumbs}/> + version={this.state.component.version} + snapshotDate={this.state.component.snapshotDate}/> + component={this.state.component} + conf={this.state.conf}/>
); } 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 1b945c62fcd..6249b8b11fb 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 (!this.props.user.isAdmin) { + if (!window.SS.isUserAdmin) { 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 64c913461f1..d07c9a4d201 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,6 +1,5 @@ import React from 'react'; import Avatar from 'components/shared/avatar'; -import RecentHistory from '../../../libs/recent-history'; export default React.createClass({ renderAuthenticated() { @@ -39,7 +38,9 @@ export default React.createClass({ handleLogout(e) { e.preventDefault(); - RecentHistory.clear(); + if (window.sonarRecentHistory) { + window.sonarRecentHistory.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 ccfe575526b..233a1dc5f29 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,9 +1,7 @@ define([ - 'backbone', - 'backbone.marionette', 'components/common/selectable-collection-view', '../templates' -], function (Backbone, Marionette, SelectableCollectionView) { +], function (SelectableCollectionView) { var $ = jQuery, @@ -122,7 +120,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) + window.dashboardParameters(true), + url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(f.key) + dashboardParameters(true), name: isFile ? window.collapsedDirFromPath(f.lname) + window.fileFromPath(f.lname) : f.name, icon: 'favorite' }; @@ -135,20 +133,19 @@ 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) + - window.dashboardParameters(true), + url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) + dashboardParameters(true), name: historyItem.name, q: historyItem.icon, - extra: index === 0 ? window.t('browsed_recently') : null + extra: index === 0 ? t('browsed_recently') : null }; }), favorite = _.first(this.favorite, 6).map(function (f, index) { - return _.extend(f, { extra: index === 0 ? window.t('favorite') : null }); + return _.extend(f, { extra: index === 0 ? t('favorite') : null }); }), qualifiers = this.model.get('qualifiers').map(function (q, index) { return { url: baseUrl + '/all_projects?qualifier=' + encodeURIComponent(q), - name: window.t('qualifiers.all', q), + name: t('qualifiers.all', q), extra: index === 0 ? '' : null }; }); @@ -158,7 +155,7 @@ define([ search: function (q) { if (q.length < 2) { this.resetResultsToDefault(); - return $.Deferred().resolve().promise(); + return; } var that = this, url = baseUrl + '/api/components/suggestions', @@ -170,7 +167,7 @@ define([ collection.push(_.extend(item, { q: domain.q, extra: index === 0 ? domain.name : null, - url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) + window.dashboardParameters(true) + url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) + dashboardParameters(true) })); }); }); @@ -185,22 +182,22 @@ define([ getNavigationFindings: function (q) { var DEFAULT_ITEMS = [ - { 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' } + { 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' } ], customItems = []; if (window.SS.isUserAdmin) { - customItems.push({ name: window.t('layout.settings'), url: baseUrl + '/settings' }); + customItems.push({ name: 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 = window.t('navigation'); + findings[0].extra = t('navigation'); } return _.first(findings, 6); }, @@ -214,7 +211,7 @@ define([ return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { - findings[0].extra = window.t('dashboard.global_dashboards'); + findings[0].extra = t('dashboard.global_dashboards'); } return _.first(findings, 6); }, @@ -224,7 +221,7 @@ define([ return f.name.match(new RegExp(q, 'i')); }); if (findings.length > 0) { - findings[0].extra = window.t('favorite'); + findings[0].extra = 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 4f85ebd82f1..475b1c0348f 100644 --- a/server/sonar-web/src/main/js/apps/overview/app.jsx +++ b/server/sonar-web/src/main/js/apps/overview/app.jsx @@ -6,16 +6,17 @@ const $ = jQuery; export default { start(options) { - _.extend(options, window.overview); $('html').toggleClass('dashboard-page', options.component.hasSnapshot); - const el = document.querySelector(options.el); - const inner = options.component.hasSnapshot ? ( -
- ) : ; - React.render(inner, el); + window.requestMessages().done(() => { + const el = document.querySelector(options.el); + const inner = options.component.hasSnapshot ? ( +
+ ) : ; + 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 54d4fee2fb6..28dc73b7f42 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 @@ -1,14 +1,13 @@ import React from 'react'; import Main from './main'; -import MainComponent from './main-component'; + +const $ = jQuery; export default { start(options) { - var el = document.querySelector(options.el); - if (options.component) { - React.render(, el); - } else { + window.requestMessages().done(() => { + var el = document.querySelector(options.el); React.render(
, 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 6cb593c3e9f..122a6a0ed20 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 @@ -12,7 +12,7 @@ define([ template: Templates['project-permissions-groups'], onRender: function () { - Modal.prototype.onRender.apply(this, arguments); + this._super(); new window.SelectList({ el: this.$('#project-permissions-groups'), width: '100%', @@ -39,10 +39,8 @@ define([ }, onDestroy: function () { - if (this.options.refresh) { - this.options.refresh(); - } - Modal.prototype.onDestroy.apply(this, arguments); + this.options.refresh && this.options.refresh(); + this._super(); }, 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 9da1eb9025d..5f54a1ad2a9 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 @@ -4,15 +4,11 @@ define([ './templates' ], function (Modal) { - function getSearchUrl(permission, project) { - return baseUrl + '/api/permissions/users?ps=100&permission=' + permission + '&projectId=' + project; - } - return Modal.extend({ template: Templates['project-permissions-users'], onRender: function () { - Modal.prototype.onRender.apply(this, arguments); + this._super(); new window.SelectList({ el: this.$('#project-permissions-users'), width: '100%', @@ -22,7 +18,7 @@ define([ return item.name + '
' + item.login + ''; }, queryParam: 'q', - searchUrl: getSearchUrl(this.options.permission, this.options.project), + searchUrl: baseUrl + '/api/permissions/users?ps=100&permission=' + this.options.permission + '&projectId=' + this.options.project, selectUrl: baseUrl + '/api/permissions/add_user', deselectUrl: baseUrl + '/api/permissions/remove_user', extra: { @@ -39,16 +35,14 @@ define([ }, onDestroy: function () { - if (this.options.refresh) { - this.options.refresh(); - } - Modal.prototype.onDestroy.apply(this, arguments); + this.options.refresh && this.options.refresh(); + this._super(); }, 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 01145ce4957..aa754e5ba77 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/app.js +++ b/server/sonar-web/src/main/js/apps/provisioning/app.js @@ -1,12 +1,11 @@ define([ - 'backbone.marionette', './layout', './projects', './header-view', './search-view', './list-view', './list-footer-view' -], function (Marionette, Layout, Projects, HeaderView, SearchView, ListView, ListFooterView) { +], function (Layout, Projects, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -38,7 +37,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + window.requestMessages().done(function () { + 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 af82066c0ef..731e3e163d2 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 02b8069b076..dd503c4b1a4 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 cb301b78997..bb0fc0bcef5 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 () { - ModalForm.prototype.onRender.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onDestroy: function () { - ModalForm.prototype.onDestroy.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 c98eb7a12cb..37165494eac 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,9 +1,8 @@ define([ - 'backbone.marionette', './create-view', './bulk-delete-view', './templates' -], function (Marionette, CreateView, BulkDeleteView) { +], function (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 3fa806b7a46..31b67e8b774 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/layout.js +++ b/server/sonar-web/src/main/js/apps/provisioning/layout.js @@ -1,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 76176ca4769..902b9322372 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['provisioning-list-footer'], @@ -24,7 +23,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 9940f3f0e0e..ead9b009ca3 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,8 +1,7 @@ define([ - 'backbone.marionette', './delete-view', './templates' -], function (Marionette, DeleteView) { +], function (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 b56e64f951d..24878864d30 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,8 +1,7 @@ define([ - 'backbone.marionette', './list-item-view', './templates' -], function (Marionette, ListItemView) { +], function (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 a2e13d09239..fa34df605f2 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/project.js +++ b/server/sonar-web/src/main/js/apps/provisioning/project.js @@ -1,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ idAttribute: 'uuid', @@ -10,7 +8,7 @@ define([ }, urlRoot: function () { - return window.baseUrl + '/api/projects'; + return 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 51697b78fc8..05a59f822af 100644 --- a/server/sonar-web/src/main/js/apps/provisioning/projects.js +++ b/server/sonar-web/src/main/js/apps/provisioning/projects.js @@ -1,13 +1,12 @@ define([ - 'backbone', './project' -], function (Backbone, Project) { +], function (Project) { return Backbone.Collection.extend({ model: Project, url: function () { - return window.baseUrl + '/api/projects/provisioned'; + return baseUrl + '/api/projects/provisioned'; }, parse: function (r) { @@ -20,7 +19,7 @@ define([ fetch: function (options) { var d = (options && options.data) || {}; this.q = d.q; - return Backbone.Collection.prototype.fetch.apply(this, arguments); + return this._super(options); }, 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 5f10d839e8a..55c0fafc4fb 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['provisioning-search'], @@ -91,7 +90,7 @@ define([ selectedCount = this.collection.where({ selected: true }).length, allSelected = projectsCount > 0 && projectsCount === selectedCount, someSelected = !allSelected && selectedCount > 0; - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 44013fbc930..156c7d88104 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,8 +1,7 @@ define([ - 'backbone.marionette', './create-view', './templates' -], function (Marionette, CreateView) { +], function (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 1c8f38fea0d..6f939c9aa24 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,13 +1,11 @@ define([ - 'backbone', - 'backbone.marionette', './gates', './gates-view', './actions-view', './router', './layout', './controller' -], function (Backbone, Marionette, Gates, GatesView, ActionsView, Router, Layout, Controller) { +], function (Gates, GatesView, ActionsView, Router, Layout, Controller) { var $ = jQuery, App = new Marionette.Application(); @@ -54,7 +52,7 @@ define([ }); App.on('start', function (options) { - $.when(appXHR).done(function () { + $.when(window.requestMessages(), 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 bb14f8226c0..9ca451ee5a0 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,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ @@ -9,7 +7,7 @@ define([ }, url: function () { - return window.baseUrl + '/api/qualitygates'; + return 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 08d1cb52133..49cbb23f069 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,7 +1,6 @@ define([ - 'backbone', './condition' -], function (Backbone, Condition) { +], function (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 90b1c4b0d9f..890adc1ad8b 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,9 +1,8 @@ define([ - 'backbone.marionette', './gate', './details-view', './header-view' -], function (Marionette, Gate, DetailsView, HeaderView) { +], function (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 012683d9ee8..fdd6c974cf8 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 = window.baseUrl + '/api/qualitygates/copy', + var url = 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 acb0cc5e5e3..f58863ba315 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 = window.baseUrl + '/api/qualitygates/create', + var url = 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 6451104db2c..9af1b38e65e 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,10 +1,9 @@ define([ - 'backbone.marionette', './conditions', './gate-conditions-view', './gate-projects-view', './templates' -], function (Marionette, Conditions, DetailConditionsView, ProjectsView) { +], function (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 6d696825899..9b61f400bf3 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,9 +1,8 @@ define([ - 'backbone', 'components/common/modal-form', './gate', './templates' -], function (Backbone, ModalForm, Gate) { +], function (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 7d9bbc741eb..0dfbea0ab17 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,8 +1,7 @@ define([ - 'backbone.marionette', './gate-conditions-delete-view', './templates' -], function (Marionette, DeleteConditionView) { +], function (DeleteConditionView) { return Marionette.ItemView.extend({ tagName: 'tr', @@ -91,7 +90,7 @@ define([ return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { canEdit: this.options.canEdit, periods: this.options.periods, - periodText: period ? period.text : window.t('value'), + periodText: period ? period.text : 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 eaf001b0658..c8ed23a2883 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,8 +1,7 @@ define([ - 'backbone.marionette', 'components/common/modal-form', './templates' -], function (Marionette, ModalForm) { +], function (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 5bab8c1ff29..03390ac7a89 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 5eb29360449..b0c0857cc95 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,10 +1,9 @@ define([ - 'backbone.marionette', './condition', './gate-condition-view', './gate-conditions-empty-view', './templates' -], function (Marionette, Condition, ConditionView, ConditionsEmptyView) { +], function (Condition, ConditionView, ConditionsEmptyView) { return Marionette.CompositeView.extend({ template: Templates['quality-gate-detail-conditions'], @@ -35,7 +34,7 @@ define([ this.ui.metricSelect.select2({ allowClear: false, width: '250px', - placeholder: window.t('alerts.select_metric') + placeholder: 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 5337fad8c52..c188c473be5 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,15 +1,13 @@ define([ - 'backbone.marionette', 'components/common/select-list', './templates' -], function (Marionette) { +], function () { 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%', @@ -18,23 +16,23 @@ define([ format: function (item) { return item.name; }, - searchUrl: window.baseUrl + '/api/qualitygates/search?gateId=' + this.model.id, - selectUrl: window.baseUrl + '/api/qualitygates/select', - deselectUrl: window.baseUrl + '/api/qualitygates/deselect', + searchUrl: baseUrl + '/api/qualitygates/search?gateId=' + this.model.id, + selectUrl: baseUrl + '/api/qualitygates/select', + deselectUrl: baseUrl + '/api/qualitygates/deselect', extra: { gateId: this.model.id }, selectParameter: 'projectId', selectParameterValue: 'id', labels: { - 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') + selected: t('quality_gates.projects.with'), + deselected: t('quality_gates.projects.without'), + all: t('quality_gates.projects.all'), + noResults: t('quality_gates.projects.noResults') }, tooltips: { - select: window.t('quality_gates.projects.select_hint'), - deselect: window.t('quality_gates.projects.deselect_hint') + select: t('quality_gates.projects.select_hint'), + deselect: 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 c9fdb2ba12e..30036a3c313 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 5bcda8336b1..54b4e6ce13c 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,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ @@ -9,7 +7,7 @@ define([ }, url: function () { - return window.baseUrl + '/api/qualitygates'; + return 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 2e58b9466f9..cd36c381a39 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,8 +1,7 @@ define([ - 'backbone.marionette', './gate-view', './templates' -], function (Marionette, ItemView) { +], function (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 55c6d681084..d33b35bcfe5 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,13 +1,12 @@ define([ - 'backbone', './gate' -], function (Backbone, Gate) { +], function (Gate) { return Backbone.Collection.extend({ model: Gate, url: function () { - return window.baseUrl + '/api/qualitygates/list'; + return 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 dd6bea9ee74..b86b2c9ba62 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,10 +1,9 @@ define([ - 'backbone.marionette', './rename-view', './copy-view', './delete-view', './templates' -], function (Marionette, RenameView, CopyView, DeleteView) { +], function (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 83d6b354d13..c9588a3d48f 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 bee18432f0c..db02143caa6 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,9 +1,7 @@ define([ - 'backbone.marionette', './intro-view', - '../../components/common/jquery-isolated-scroll', './templates' -], function (Marionette, IntroView) { +], function (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 29db22d6fa4..d9b5946653a 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 = window.baseUrl + '/api/qualitygates/rename', + var url = 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 35a41f33864..582c47361d5 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,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { 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 9aad03fa56b..fc107d10cef 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,10 +1,28 @@ +/* + * 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 (Marionette, CreateProfileView, RestoreProfileView, RestoreBuiltInProfilesView) { +], function (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 c506cb2a56d..cd94804cb03 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,22 +1,21 @@ define([ - 'backbone', - 'backbone.marionette', './router', './controller', './layout', './profiles', './actions-view', './profiles-view' -], function (Backbone, Marionette, Router, Controller, Layout, Profiles, ActionsView, ProfilesView) { +], function (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(); @@ -53,7 +52,7 @@ define([ }; App.on('start', function (options) { - $.when(requestExporters).done(function () { + $.when(window.requestMessages(), requestUser, 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 d694679452a..a0813a661c9 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,8 +1,26 @@ +/* + * 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 (Marionette, ModalFormView) { +], function (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 b3010cb4bd9..987cb0b3728 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,8 +1,26 @@ +/* + * 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 (Marionette, ProfileHeaderView, ProfileDetailsView) { +], function (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 cdc1ba0c142..d241c123e17 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,18 +34,16 @@ }); Handlebars.registerHelper('severityChangelog', function (severity) { - var label = ' ' + window.t('severity', severity), - message = window.tp('quality_profiles.severity_set_to_x', label); + var label = ' ' + t('severity', severity), + message = 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( - window.tp('quality_profiles.parameter_set_to_x', value, parameter)); + return new Handlebars.SafeString(tp('quality_profiles.parameter_set_to_x', value, parameter)); } else { - return new Handlebars.SafeString( - window.tp('quality_profiles.changelog.parameter_reset_to_default_value_x', parameter)); + return new Handlebars.SafeString(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 8b6172ac012..abfb416541b 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 f83319a72dc..44cafd82d32 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,9 +1,26 @@ +/* + * 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 (Marionette, IntroView) { +], function (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 0a8ab424273..28838846bba 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 9dc9894d166..d5f5ea37d4b 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 e0361b19f93..112c5b39b96 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,12 +1,30 @@ +/* + * 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 (Marionette, ChangeProfileParentView, ProfileChangelogView, ProfileComparisonView) { +], function (ChangeProfileParentView, ProfileChangelogView, ProfileComparisonView) { var $ = jQuery; @@ -69,14 +87,14 @@ define([ selectParameter: 'projectUuid', selectParameterValue: 'uuid', labels: { - 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') + selected: t('quality_gates.projects.with'), + deselected: t('quality_gates.projects.without'), + all: t('quality_gates.projects.all'), + noResults: t('quality_gates.projects.noResults') }, tooltips: { - select: window.t('quality_gates.projects.select_hint'), - deselect: window.t('quality_gates.projects.deselect_hint') + select: t('quality_gates.projects.select_hint'), + deselect: 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 2137bebae18..57a5d310736 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,10 +1,28 @@ +/* + * 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 (Marionette, ProfileCopyView, ProfileRenameView, ProfileDeleteView) { +], function (ProfileCopyView, ProfileRenameView, ProfileDeleteView) { var $ = jQuery; @@ -44,7 +62,7 @@ define([ onDeleteClick: function (e) { e.preventDefault(); - this.deleteProfile(); + this.delete(); }, copy: function () { @@ -59,7 +77,7 @@ define([ this.model.trigger('setAsDefault', this.model); }, - deleteProfile: function () { + delete: 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 1b7b8dfa471..34de0a2d0c0 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,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { 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 a9b91c3c1c2..7315821cf1c 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,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { 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 9ee9388beea..f4844bfc85f 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 42573bc63b1..677888f451c 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,9 +1,27 @@ +/* + * 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 (Marionette, ProfileView, ProfilesEmptyView) { +], function (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 a0f93dd496f..8b556ce8aa5 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,7 +1,25 @@ +/* + * 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 (Backbone, Profile) { +], function (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 2d39c14761c..bd223c261f3 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 () { + onFormSubmit: function (e) { 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 a4702143fbf..7970d6d2ea6 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,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { 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 deleted file mode 100644 index 5339644f14e..00000000000 --- a/server/sonar-web/src/main/js/apps/select-list/app.js +++ /dev/null @@ -1,11 +0,0 @@ -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 31b6047d152..1c6947db3ee 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,7 +1,6 @@ define([ - 'backbone.marionette', 'components/source-viewer/main' -], function (Marionette, SourceViewer) { +], function (SourceViewer) { var App = new Marionette.Application(), init = function (options) { @@ -9,20 +8,20 @@ define([ var viewer = new SourceViewer(); this.mainRegion.show(viewer); - viewer.open(options.component.uuid); - if (window.line) { + viewer.open(options.file.uuid); + if (typeof options.file.line === 'number') { viewer.on('loaded', function () { viewer - .highlightLine(window.line) - .scrollToLine(window.line); + .highlightLine(options.file.line) + .scrollToLine(options.file.line); }); } }; App.on('start', function (options) { - if (options.component) { + window.requestMessages().done(function () { 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 8a98b3699f6..a866a0c2879 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,6 +1,4 @@ define([ - 'backbone', - 'backbone.marionette', './layout', './header-view', './search-view', @@ -9,13 +7,13 @@ define([ './controller', './router', './plugins' -], function (Backbone, Marionette, Layout, HeaderView, SearchView, ListView, FooterView, Controller, Router, Plugins) { +], function (Layout, HeaderView, SearchView, ListView, FooterView, Controller, Router, Plugins) { var App = new Marionette.Application(), init = function (options) { // State this.state = new Backbone.Model({ - updateCenterActive: window.sonar.properties['sonar.updatecenter.activate'] + updateCenterActive: window.SS.updateCenterActive }); // Layout @@ -29,7 +27,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 }); @@ -56,7 +54,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + window.requestMessages().done(function () { + 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 5aaf9a21e94..a8f069c9dc0 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,6 +1,4 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +define(function () { 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 58cddde9754..2f83d509dc7 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['update-center-footer'], @@ -11,7 +10,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 1963823c939..99e1095ad7f 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['update-center-header'], @@ -19,7 +18,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 5db9c1e5a34..58e480d16de 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 9aab6cb612a..67750c343ec 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,9 +1,7 @@ define([ - 'backbone', - 'backbone.marionette', './plugin-changelog-view', './templates' -], function (Backbone, Marionette, PluginChangelogView) { +], function (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 eb1fe1bc495..e188597e511 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,7 +1,6 @@ define([ - 'backbone.marionette', './list-item-view' -], function (Marionette, ListItemView) { +], function (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 bf96fc5ac1b..9ece2454bb7 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,6 +1,5 @@ define([ 'components/common/popup', - '../../components/common/jquery-isolated-scroll', './templates' ], function (Popup) { @@ -8,18 +7,18 @@ define([ template: Templates['update-center-plugin-changelog'], onRender: function () { - Popup.prototype.onRender.apply(this, arguments); + this._super(); this.$('.bubble-popup-container').isolatedScroll(); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onClose: function () { - Popup.prototype.onClose.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, serializeData: function () { - return _.extend(Popup.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { // 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 623e05b6d1d..697979e4ed0 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,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { 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 d03988858f4..021e124511c 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,7 +1,6 @@ define([ - 'backbone', './plugin' -], function (Backbone, Plugin) { +], function (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 48f3df055ea..0a9af1440cc 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,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { 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 8cccae1ae57..b46cf5ce293 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['update-center-search'], @@ -78,9 +77,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { - state: this.options.state.toJSON() - }); + return _.extend(this._super(), { 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 575f2afc320..9fa9df3759a 100644 --- a/server/sonar-web/src/main/js/apps/users/app.js +++ b/server/sonar-web/src/main/js/apps/users/app.js @@ -1,12 +1,11 @@ define([ - 'backbone.marionette', './layout', './users', './header-view', './search-view', './list-view', './list-footer-view' -], function (Marionette, Layout, Users, HeaderView, SearchView, ListView, ListFooterView) { +], function (Layout, Users, HeaderView, SearchView, ListView, ListFooterView) { var App = new Marionette.Application(), init = function (options) { @@ -38,7 +37,9 @@ define([ }; App.on('start', function (options) { - init.call(App, options); + window.requestMessages().done(function () { + 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 edda928fb99..659d3012a79 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 26143c09b2e..000a350ea57 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 () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 c05f57afc09..50b18c1d237 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(ModalForm.prototype.events.apply(this, arguments), { + return _.extend(this._super(), { 'click #create-user-add-scm-account': 'onAddScmAccountClick' }); }, onRender: function () { - ModalForm.prototype.onRender.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, onDestroy: function () { - ModalForm.prototype.onDestroy.apply(this, arguments); + this._super(); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit: function () { - ModalForm.prototype.onFormSubmit.apply(this, arguments); + onFormSubmit: function (e) { + this._super(e); 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 2949f0acee6..09a127fc6fd 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,8 +9,7 @@ define([ itemTemplate: Templates['users-group'], onRender: function () { - Modal.prototype.onRender.apply(this, arguments); - //noinspection Eslint + this._super(); new window.SelectList({ el: this.$('#users-groups'), width: '100%', @@ -20,9 +19,9 @@ define([ return item.name + '
' + item.description + ''; }, queryParam: 'q', - 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', + searchUrl: baseUrl + '/api/users/groups?ps=100&login=' + this.model.id, + selectUrl: baseUrl + '/api/usergroups/add_user', + deselectUrl: 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 a07bd44e6e0..c8b76193b4c 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,8 +1,7 @@ define([ - 'backbone.marionette', './create-view', './templates' -], function (Marionette, CreateView) { +], function (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 3fb4ee142bb..9acb054bdad 100644 --- a/server/sonar-web/src/main/js/apps/users/layout.js +++ b/server/sonar-web/src/main/js/apps/users/layout.js @@ -1,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 7758d24d75b..cf802586354 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { return Marionette.ItemView.extend({ template: Templates['users-list-footer'], @@ -24,7 +23,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 b123e560225..b11e39e2766 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,11 +1,10 @@ define([ - 'backbone.marionette', './update-view', './change-password-view', './deactivate-view', './groups-view', './templates' -], function (Marionette, UpdateView, ChangePasswordView, DeactivateView, GroupsView) { +], function (UpdateView, ChangePasswordView, DeactivateView, GroupsView) { return Marionette.ItemView.extend({ tagName: 'li', @@ -102,7 +101,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(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { + return _.extend(this._super(), { 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 b56e64f951d..24878864d30 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,8 +1,7 @@ define([ - 'backbone.marionette', './list-item-view', './templates' -], function (Marionette, ListItemView) { +], function (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 295f50b0b4b..5129bf5a253 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,7 +1,6 @@ define([ - 'backbone.marionette', './templates' -], function (Marionette) { +], function () { 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 e438a4b5f22..746ffe8bdd7 100644 --- a/server/sonar-web/src/main/js/apps/users/user.js +++ b/server/sonar-web/src/main/js/apps/users/user.js @@ -1,12 +1,10 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ idAttribute: 'login', urlRoot: function () { - return window.baseUrl + '/api/users'; + return 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 1c199d05ace..9c45979a9fe 100644 --- a/server/sonar-web/src/main/js/apps/users/users.js +++ b/server/sonar-web/src/main/js/apps/users/users.js @@ -1,13 +1,12 @@ define([ - 'backbone', './user' -], function (Backbone, User) { +], function (User) { return Backbone.Collection.extend({ model: User, url: function () { - return window.baseUrl + '/api/users/search'; + return baseUrl + '/api/users/search'; }, parse: function (r) { @@ -20,7 +19,7 @@ define([ fetch: function (options) { var d = (options && options.data) || {}; this.q = d.q; - return Backbone.Collection.prototype.fetch.apply(this, arguments); + return this._super(options); }, fetchMore: function () { diff --git a/server/sonar-web/src/main/js/components/common/dialogs.js b/server/sonar-web/src/main/js/components/common/dialogs.js new file mode 100644 index 00000000000..46f8b68354c --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/dialogs.js @@ -0,0 +1,44 @@ +(function ($) { + + window.confirmDialog = function (options) { + var settings = _.extend(window.confirmDialog.defaults, options), + dialog = $('
'); + + $('[data-confirm=yes]', dialog).on('click', function () { + dialog.dialog('close'); + settings.yesHandler(); + return settings.always(); + }); + + $('[data-confirm=no]', dialog).on('click', function () { + dialog.dialog('close'); + settings.noHandler(); + return settings.always(); + }); + + return dialog.dialog({ + modal: true, + minHeight: null, + width: 540 + }); + }; + + window.confirmDialog.defaults = { + title: 'Confirmation', + html: '', + yesLabel: 'Yes', + noLabel: 'Cancel', + yesHandler: function () { + // no op + }, + noHandler: function () { + // no op + }, + always: function () { + // no op + } + }; + +})(window.jQuery); diff --git a/server/sonar-web/src/main/js/components/common/dialogs.jsx b/server/sonar-web/src/main/js/components/common/dialogs.jsx deleted file mode 100644 index f2657d2e715..00000000000 --- a/server/sonar-web/src/main/js/components/common/dialogs.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import $ from 'jquery'; -import _ from 'underscore'; - -const DEFAULTS = { - title: 'Confirmation', - html: '', - yesLabel: 'Yes', - noLabel: 'Cancel', - yesHandler: function () { - // no op - }, - noHandler: function () { - // no op - }, - always: function () { - // no op - } -}; - -export default function confirmDialog (options) { - var settings = _.extend({}, DEFAULTS, options), - dialog = $('
'); - - $('[data-confirm=yes]', dialog).on('click', function () { - dialog.dialog('close'); - settings.yesHandler(); - return settings.always(); - }); - - $('[data-confirm=no]', dialog).on('click', function () { - dialog.dialog('close'); - settings.noHandler(); - return settings.always(); - }); - - return dialog.dialog({ - modal: true, - minHeight: null, - width: 540 - }); -}; - diff --git a/server/sonar-web/src/main/js/components/common/handlebars-extensions.js b/server/sonar-web/src/main/js/components/common/handlebars-extensions.js index f9eb1b70e2f..c85329a0535 100644 --- a/server/sonar-web/src/main/js/components/common/handlebars-extensions.js +++ b/server/sonar-web/src/main/js/components/common/handlebars-extensions.js @@ -20,17 +20,16 @@ (function () { Handlebars.registerHelper('log', function () { var args = Array.prototype.slice.call(arguments, 0, -1); - /* eslint no-console: 0 */ console.log.apply(console, args); }); Handlebars.registerHelper('link', function () { var url = Array.prototype.slice.call(arguments, 0, -1).join(''); - return window.baseUrl + url; + return baseUrl + url; }); Handlebars.registerHelper('componentPermalink', function (componentKey) { - return window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(componentKey); + return baseUrl + '/dashboard/index?id=' + encodeURIComponent(componentKey); }); Handlebars.registerHelper('componentOverviewPermalink', function (componentKey) { @@ -45,7 +44,7 @@ var matchPeriod = window.location.search.match(/period=(\d+)/); if (matchPeriod) { - // If we have a match for period, check that it is not project-specific + // If we have a match for period, check that it is not project-specific var period = parseInt(matchPeriod[1], 10); if (period <= 3) { params.push({ key: 'period', value: period }); @@ -91,7 +90,7 @@ Handlebars.registerHelper('severityHelper', function (severity) { return new Handlebars.SafeString( - ' ' + window.t('severity', severity) + ' ' + t('severity', severity) ); }); @@ -102,9 +101,9 @@ }); Handlebars.registerHelper('statusHelper', function (status, resolution) { - var s = ' ' + window.t('issue.status', status); + var s = ' ' + t('issue.status', status); if (resolution != null) { - s = s + ' (' + window.t('issue.resolution', resolution) + ')'; + s = s + ' (' + t('issue.resolution', resolution) + ')'; } return new Handlebars.SafeString(s); }); @@ -199,12 +198,12 @@ }); Handlebars.registerHelper('eq', function (v1, v2, options) { - /* eslint eqeqeq: 0 */ + // use `==` instead of `===` to ignore types return v1 == v2 ? options.fn(this) : options.inverse(this); }); Handlebars.registerHelper('notEq', function (v1, v2, options) { - /* eslint eqeqeq: 0 */ + // use `==` instead of `===` to ignore types return v1 != v2 ? options.fn(this) : options.inverse(this); }); @@ -316,7 +315,7 @@ return ret; }); - Handlebars.registerHelper('sum', function () { + Handlebars.registerHelper('sum', function (a, b) { var args = Array.prototype.slice.call(arguments, 0, -1); return args.reduce(function (p, c) { return p + +c; @@ -407,7 +406,6 @@ Handlebars.registerHelper('recursive', function (children, options) { var out = ''; - /* eslint no-undefined: 0 */ if (options.fn !== undefined) { audaciousFn = options.fn; } @@ -449,13 +447,13 @@ Handlebars.registerHelper('changelog', function (diff) { var message = ''; if (diff.newValue != null) { - message = window.tp('issue.changelog.changed_to', window.t('issue.changelog.field', diff.key), diff.newValue); + message = tp('issue.changelog.changed_to', t('issue.changelog.field', diff.key), diff.newValue); } else { - message = window.tp('issue.changelog.removed', window.t('issue.changelog.field', diff.key)); + message = tp('issue.changelog.removed', t('issue.changelog.field', diff.key)); } if (diff.oldValue != null) { message += ' ('; - message += window.tp('issue.changelog.was', diff.oldValue); + message += tp('issue.changelog.was', diff.oldValue); message += ')'; } return message; @@ -567,14 +565,14 @@ }); Handlebars.registerHelper('ifShowAvatars', function (options) { - var cond = window.sonar.properties['sonar.lf.enableGravatar']; + var cond = window.SS && window.SS.lf && window.SS.lf.enableGravatar; return cond ? options.fn(this) : options.inverse(this); }); Handlebars.registerHelper('avatarHelper', function (email, size) { // double the size for high pixel density screens var emailHash = window.md5((email || '').trim()), - url = ('' + window.sonar.properties['sonar.lf.gravatarServerUrl']) + url = ('' + window.SS.lf.gravatarServerUrl) .replace('{EMAIL_MD5}', emailHash) .replace('{SIZE}', size * 2); return new Handlebars.SafeString( diff --git a/server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.js b/server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.js new file mode 100644 index 00000000000..e65a9c61541 --- /dev/null +++ b/server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.js @@ -0,0 +1,33 @@ +/* + * 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. + */ +;(function ($) { + + $.fn.isolatedScroll = function () { + this.on('wheel', function (e) { + var delta = -e.originalEvent.deltaY; + var bottomOverflow = this.scrollTop + $(this).outerHeight() - this.scrollHeight >= 0; + var topOverflow = this.scrollTop <= 0; + if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) { + e.preventDefault(); + } + }); + }; + +})(window.jQuery); diff --git a/server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.jsx b/server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.jsx deleted file mode 100644 index 3cf3086ddda..00000000000 --- a/server/sonar-web/src/main/js/components/common/jquery-isolated-scroll.jsx +++ /dev/null @@ -1,12 +0,0 @@ -import $ from 'jquery'; - -$.fn.isolatedScroll = function () { - this.on('wheel', function (e) { - var delta = -e.originalEvent.deltaY; - var bottomOverflow = this.scrollTop + $(this).outerHeight() - this.scrollHeight >= 0; - var topOverflow = this.scrollTop <= 0; - if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) { - e.preventDefault(); - } - }); -}; diff --git a/server/sonar-web/src/main/js/components/common/modals.js b/server/sonar-web/src/main/js/components/common/modals.js index e1818eb30b9..b4812096177 100644 --- a/server/sonar-web/src/main/js/components/common/modals.js +++ b/server/sonar-web/src/main/js/components/common/modals.js @@ -1,6 +1,23 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +/* + * 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 () { var $ = jQuery, EVENT_SCOPE = 'modal'; diff --git a/server/sonar-web/src/main/js/components/common/popup.js b/server/sonar-web/src/main/js/components/common/popup.js index d0dfd7c0b35..a3d15c1bbb8 100644 --- a/server/sonar-web/src/main/js/components/common/popup.js +++ b/server/sonar-web/src/main/js/components/common/popup.js @@ -1,6 +1,4 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +define(function () { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/components/common/processes.js b/server/sonar-web/src/main/js/components/common/processes.js index cdb8f43aace..a437192044e 100644 --- a/server/sonar-web/src/main/js/components/common/processes.js +++ b/server/sonar-web/src/main/js/components/common/processes.js @@ -1,9 +1,23 @@ -define([ - 'backbone', - 'backbone.marionette' -], function (Backbone, Marionette) { - - var $ = jQuery; +/* + * 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. + */ +(function ($) { var defaults = { queue: {}, @@ -32,7 +46,7 @@ define([ fail: function (message) { var that = this, - msg = message || window.t('process.fail'); + msg = message || t('process.fail'); if (msg === 'process.fail') { // no translation msg = 'An error happened, some parts of the page might not render correctly. ' + @@ -171,4 +185,4 @@ define([ }); -}); +})(window.jQuery); diff --git a/server/sonar-web/src/main/js/components/common/select-list.js b/server/sonar-web/src/main/js/components/common/select-list.js index 3f9fcd8f0fc..325add51e5a 100644 --- a/server/sonar-web/src/main/js/components/common/select-list.js +++ b/server/sonar-web/src/main/js/components/common/select-list.js @@ -1,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { var $ = jQuery, showError = null; diff --git a/server/sonar-web/src/main/js/components/common/selectable-collection-view.js b/server/sonar-web/src/main/js/components/common/selectable-collection-view.js index 70562c186b5..c7250855946 100644 --- a/server/sonar-web/src/main/js/components/common/selectable-collection-view.js +++ b/server/sonar-web/src/main/js/components/common/selectable-collection-view.js @@ -17,9 +17,7 @@ * 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' -], function (Marionette) { +define(function () { return Marionette.CollectionView.extend({ diff --git a/server/sonar-web/src/main/js/components/issue/collections/action-plans.js b/server/sonar-web/src/main/js/components/issue/collections/action-plans.js index 318cad85199..8cbef0a1a32 100644 --- a/server/sonar-web/src/main/js/components/issue/collections/action-plans.js +++ b/server/sonar-web/src/main/js/components/issue/collections/action-plans.js @@ -1,10 +1,8 @@ -define([ - 'backbone' -], function (Backbone) { +define([], function () { return Backbone.Collection.extend({ url: function () { - return window.baseUrl + '/api/action_plans/search'; + return baseUrl + '/api/action_plans/search'; }, parse: function (r) { diff --git a/server/sonar-web/src/main/js/components/issue/collections/issues.js b/server/sonar-web/src/main/js/components/issue/collections/issues.js index 18677ece228..f40f9a30246 100644 --- a/server/sonar-web/src/main/js/components/issue/collections/issues.js +++ b/server/sonar-web/src/main/js/components/issue/collections/issues.js @@ -1,13 +1,12 @@ define([ - 'backbone', '../models/issue' -], function (Backbone, Issue) { +], function (Issue) { return Backbone.Collection.extend({ model: Issue, url: function () { - return window.baseUrl + '/api/issues/search'; + return baseUrl + '/api/issues/search'; }, _injectRelational: function (issue, source, baseField, lookupField) { diff --git a/server/sonar-web/src/main/js/components/issue/issue-view.js b/server/sonar-web/src/main/js/components/issue/issue-view.js index 11019785fb8..3a48d4e3dd2 100644 --- a/server/sonar-web/src/main/js/components/issue/issue-view.js +++ b/server/sonar-web/src/main/js/components/issue/issue-view.js @@ -1,6 +1,4 @@ define([ - 'backbone', - 'backbone.marionette', './models/changelog', './views/changelog-view', './collections/action-plans', @@ -14,9 +12,8 @@ define([ './views/tags-form-view', 'components/workspace/main', './templates' -], function (Backbone,Marionette, ChangeLog, ChangeLogView, ActionPlans, IssuePopup, TransitionsFormView, - AssignFormView, CommentFormView, PlanFormView, SetSeverityFormView, MoreActionsView, TagsFormView, - Workspace) { +], function (ChangeLog, ChangeLogView, ActionPlans, IssuePopup, TransitionsFormView, AssignFormView, CommentFormView, + PlanFormView, SetSeverityFormView, MoreActionsView, TagsFormView, Workspace) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/components/issue/manual-issue-view.js b/server/sonar-web/src/main/js/components/issue/manual-issue-view.js index 5e14378e430..2f819f62f2b 100644 --- a/server/sonar-web/src/main/js/components/issue/manual-issue-view.js +++ b/server/sonar-web/src/main/js/components/issue/manual-issue-view.js @@ -1,8 +1,7 @@ define([ - 'backbone.marionette', './models/issue', './templates' -], function (Marionette, Issue) { +], function (Issue) { var $ = jQuery; @@ -17,7 +16,7 @@ define([ initialize: function () { var that = this; this.rules = []; - $.get(window.baseUrl + '/api/rules/search?repositories=manual&f=name&ps=9999999').done(function (r) { + $.get(baseUrl + '/api/rules/search?repositories=manual&f=name&ps=9999999').done(function (r) { that.rules = r.rules; that.render(); }); diff --git a/server/sonar-web/src/main/js/components/issue/models/changelog.js b/server/sonar-web/src/main/js/components/issue/models/changelog.js index c14fc82ffee..a7efe2b886a 100644 --- a/server/sonar-web/src/main/js/components/issue/models/changelog.js +++ b/server/sonar-web/src/main/js/components/issue/models/changelog.js @@ -1,10 +1,8 @@ -define([ - 'backbone' -], function (Backbone) { +define([], function () { return Backbone.Collection.extend({ url: function () { - return window.baseUrl + '/api/issues/changelog'; + return baseUrl + '/api/issues/changelog'; }, parse: function (r) { diff --git a/server/sonar-web/src/main/js/components/issue/models/issue.js b/server/sonar-web/src/main/js/components/issue/models/issue.js index 1cd13ce038e..62f74ceb507 100644 --- a/server/sonar-web/src/main/js/components/issue/models/issue.js +++ b/server/sonar-web/src/main/js/components/issue/models/issue.js @@ -1,6 +1,4 @@ -define([ - 'backbone' -], function (Backbone) { +define(function () { return Backbone.Model.extend({ idAttribute: 'key', @@ -13,11 +11,11 @@ define([ }, url: function () { - return window.baseUrl + '/api/issues'; + return baseUrl + '/api/issues'; }, urlRoot: function () { - return window.baseUrl + '/api/issues'; + return baseUrl + '/api/issues'; }, parse: function (r) { diff --git a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js index e7d8ecbac9d..c4cd0e5b0f9 100644 --- a/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/assign-form-view.js @@ -123,7 +123,7 @@ define([ if (this.assignees) { return this.assignees; } - var assignees = [{ id: '', text: window.t('unassigned') }], + var assignees = [{ id: '', text: t('unassigned') }], currentUser = window.SS.user, currentUserName = window.SS.userName; assignees.push({ id: currentUser, text: currentUserName }); diff --git a/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js b/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js index 79fccea3dc2..4c459a0a60d 100644 --- a/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js @@ -32,7 +32,7 @@ define([ }, getActionPlans: function () { - return [{ key: '', name: window.t('issue.unplanned') }].concat(this.collection.toJSON()); + return [{ key: '', name: t('issue.unplanned') }].concat(this.collection.toJSON()); }, serializeData: function () { diff --git a/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js b/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js index c0457e79ff4..6aa05af0998 100644 --- a/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js +++ b/server/sonar-web/src/main/js/components/issue/views/tags-form-view.js @@ -32,7 +32,7 @@ define([ requestTags: function (query) { var that = this; - return $.get(window.baseUrl + '/api/issues/tags', { ps: 10, q: query }).done(function (data) { + return $.get(baseUrl + '/api/issues/tags', { ps: 10, q: query }).done(function (data) { that.tags = data.tags; that.renderTags(); }); diff --git a/server/sonar-web/src/main/js/components/navigator/controller.js b/server/sonar-web/src/main/js/components/navigator/controller.js index 899cfa6f1d8..9565886da20 100644 --- a/server/sonar-web/src/main/js/components/navigator/controller.js +++ b/server/sonar-web/src/main/js/components/navigator/controller.js @@ -1,6 +1,23 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +/* + * 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 () { return Marionette.Controller.extend({ pageSize: 50, diff --git a/server/sonar-web/src/main/js/components/navigator/facets-view.js b/server/sonar-web/src/main/js/components/navigator/facets-view.js index a870a004d3d..bf881e018fa 100644 --- a/server/sonar-web/src/main/js/components/navigator/facets-view.js +++ b/server/sonar-web/src/main/js/components/navigator/facets-view.js @@ -1,7 +1,25 @@ +/* + * 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/navigator/facets/base-facet' -], function (Marionette, BaseFacet) { +], function (BaseFacet) { return Marionette.CollectionView.extend({ className: 'search-navigator-facets-list', diff --git a/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js b/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js index e949fef3760..31d78fe36d9 100644 --- a/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js +++ b/server/sonar-web/src/main/js/components/navigator/facets/base-facet.js @@ -1,6 +1,23 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +/* + * 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 () { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/components/navigator/filters/ajax-select-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/ajax-select-filters.js index 4bbe74a90bb..36c07bbe947 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/ajax-select-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/ajax-select-filters.js @@ -1,10 +1,27 @@ +/* + * 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([ - 'jquery', - 'backbone', './base-filters', './choice-filters', '../templates' -], function ($, Backbone, BaseFilters, ChoiceFilters) { +], function (BaseFilters, ChoiceFilters) { var PAGE_SIZE = 100; @@ -12,30 +29,30 @@ define([ var Suggestions = Backbone.Collection.extend({ comparator: 'text', - initialize: function () { + initialize: function() { this.more = false; this.page = 0; }, - parse: function (r) { + parse: function(r) { this.more = r.more; return r.results; }, - fetch: function (options) { + fetch: function(options) { this.data = _.extend({ - p: 1, - ps: PAGE_SIZE - }, options.data || {}); + p: 1, + ps: PAGE_SIZE + }, options.data || {}); var settings = _.extend({}, options, { data: this.data }); return Backbone.Collection.prototype.fetch.call(this, settings); }, - fetchNextPage: function (options) { + fetchNextPage: function(options) { if (this.more) { this.data.p += 1; var settings = _.extend({ remove: false }, options, { data: this.data }); @@ -47,13 +64,14 @@ define([ }); + var UserSuggestions = Suggestions.extend({ - url: function () { + url: function() { return baseUrl + '/api/users/search'; }, - parse: function (response) { + parse: function(response) { var parsedResponse = window.usersToSelect2(response); this.more = parsedResponse.more; this.results = parsedResponse.results; @@ -62,29 +80,31 @@ define([ }); + var ProjectSuggestions = Suggestions.extend({ - url: function () { + url: function() { return baseUrl + '/api/resources/search?f=s2&q=TRK&display_key=true'; } }); + var ComponentSuggestions = Suggestions.extend({ - url: function () { + url: function() { return baseUrl + '/api/resources/search?f=s2&qp=supportsGlobalDashboards&display_key=true'; }, - parse: function (r) { + parse: function(r) { this.more = r.more; // If results are divided into categories if (r.results.length > 0 && r.results[0].children) { var results = []; - _.each(r.results, function (category) { - _.each(category.children, function (child) { + _.each(r.results, function(category) { + _.each(category.children, function(child) { child.category = category.text; results.push(child); }); @@ -98,25 +118,24 @@ define([ }); + var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({ template: Templates['ajax-select-filter'], listTemplate: Templates['choice-filter-template'], searchKey: 's', - render: function () { + render: function() { ChoiceFilters.DetailsChoiceFilterView.prototype.render.apply(this, arguments); var that = this, - keyup = function (e) { + keyup = function(e) { if (e.keyCode !== 37 && e.keyCode !== 38 && e.keyCode !== 39 && e.keyCode !== 40) { that.search(); } }, debouncedKeyup = _.debounce(keyup, 250), - scroll = function () { - that.scroll(); - }, + scroll = function() { that.scroll(); }, throttledScroll = _.throttle(scroll, 1000); this.$('.navigator-filter-search input') @@ -130,7 +149,7 @@ define([ }, - search: function () { + search: function() { var that = this; this.query = this.$('.navigator-filter-search input').val(); if (this.query.length > 1) { @@ -140,11 +159,11 @@ define([ data[this.searchKey] = this.query; this.options.filterView.choices.fetch({ data: data, - success: function () { - selected.forEach(function (item) { + success: function() { + selected.forEach(function(item) { that.options.filterView.choices.unshift(item); }); - _.each(that.model.get('choices'), function (v, k) { + _.each(that.model.get('choices'), function(v, k) { if (k[0] === '!') { that.options.filterView.choices.add(new Backbone.Model({ id: k, text: v })); } @@ -153,7 +172,7 @@ define([ that.$el.removeClass('fetching'); that.$('.navigator-filter-search').removeClass('fetching-error'); }, - error: function () { + error: function() { that.showSearchError(); } }); @@ -164,44 +183,44 @@ define([ }, - showSearchError: function () { + showSearchError: function() { this.$el.removeClass('fetching'); this.$('.navigator-filter-search').addClass('fetching-error'); }, - scroll: function () { + scroll: function() { var that = this, el = this.$('.choices'), scrollBottom = el.scrollTop() >= el[0].scrollHeight - el.outerHeight(); if (scrollBottom) { - this.options.filterView.choices.fetchNextPage().done(function () { + this.options.filterView.choices.fetchNextPage().done(function() { that.updateLists(); }); } }, - keydown: function (e) { + keydown: function(e) { if (_([38, 40, 13]).indexOf(e.keyCode) !== -1) { e.preventDefault(); } }, - resetChoices: function () { + resetChoices: function() { var that = this; - this.options.filterView.choices.reset(this.options.filterView.choices.filter(function (item) { + this.options.filterView.choices.reset(this.options.filterView.choices.filter(function(item) { return item.get('checked'); })); - _.each(this.model.get('choices'), function (v, k) { + _.each(this.model.get('choices'), function(v, k) { that.options.filterView.choices.add(new Backbone.Model({ id: k, text: v })); }); }, - onShow: function () { + onShow: function() { ChoiceFilters.DetailsChoiceFilterView.prototype.onShow.apply(this, arguments); this.resetChoices(); this.render(); @@ -211,36 +230,37 @@ define([ }); + var AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({ - initialize: function (options) { + initialize: function(options) { ChoiceFilters.ChoiceFilterView.prototype.initialize.call(this, { detailsView: (options && options.detailsView) ? options.detailsView : AjaxSelectDetailsFilterView }); }, - isDefaultValue: function () { + isDefaultValue: function() { return this.getSelected().length === 0; }, - renderInput: function () { + renderInput: function() { var value = this.model.get('value') || [], - input = $('') - .prop('name', this.model.get('property')) - .prop('type', 'hidden') - .css('display', 'none') - .val(value.join()); + input = $j('') + .prop('name', this.model.get('property')) + .prop('type', 'hidden') + .css('display', 'none') + .val(value.join()); input.appendTo(this.$el); }, - restoreFromQuery: function (q) { + restoreFromQuery: function(q) { var param = _.findWhere(q, { key: this.model.get('property') }); if (this.model.get('choices')) { - _.each(this.model.get('choices'), function (v, k) { + _.each(this.model.get('choices'), function(v, k) { if (k[0] === '!') { var x = _.findWhere(q, { key: k.substr(1) }); if (x == null) { @@ -264,7 +284,7 @@ define([ }, - restore: function (value, param) { + restore: function(value, param) { var that = this; if (_.isString(value)) { value = value.split(','); @@ -273,10 +293,10 @@ define([ if (this.choices && value.length > 0) { this.model.set({ value: value, enabled: true }); - var opposite = _.filter(value, function (item) { + var opposite = _.filter(value, function(item) { return item[0] === '!'; }); - opposite.forEach(function (item) { + opposite.forEach(function(item) { that.choices.add(new Backbone.Model({ id: item, text: that.model.get('choices')[item], @@ -284,7 +304,7 @@ define([ })); }); - value = _.reject(value, function (item) { + value = _.reject(value, function(item) { return item[0] === '!'; }); if (_.isArray(param.text) && param.text.length === value.length) { @@ -298,9 +318,9 @@ define([ }, - restoreFromText: function (value, text) { + restoreFromText: function(value, text) { var that = this; - _.each(value, function (v, i) { + _.each(value, function(v, i) { that.choices.add(new Backbone.Model({ id: v, text: text[i], @@ -311,25 +331,25 @@ define([ }, - restoreByRequests: function (value) { + restoreByRequests: function(value) { var that = this, - requests = _.map(value, function (v) { + requests = _.map(value, function(v) { return that.createRequest(v); }); - $.when.apply($, requests).done(function () { + $j.when.apply($j, requests).done(function () { that.onRestore(value); }); }, - onRestore: function () { + onRestore: function() { this.detailsView.updateLists(); this.renderBase(); }, - clear: function () { + clear: function() { this.model.unset('value'); if (this.choices) { this.choices.reset([]); @@ -338,15 +358,15 @@ define([ }, - createRequest: function () { - } + createRequest: function() {} }); + var ComponentFilterView = AjaxSelectFilterView.extend({ - initialize: function () { + initialize: function() { AjaxSelectFilterView.prototype.initialize.call(this, { detailsView: AjaxSelectDetailsFilterView }); @@ -354,9 +374,9 @@ define([ }, - createRequest: function (v) { + createRequest: function(v) { var that = this; - return $ + return $j .ajax({ url: baseUrl + '/api/resources', type: 'GET', @@ -373,9 +393,10 @@ define([ }); + var ProjectFilterView = AjaxSelectFilterView.extend({ - initialize: function () { + initialize: function() { BaseFilters.BaseFilterView.prototype.initialize.call(this, { detailsView: AjaxSelectDetailsFilterView }); @@ -384,9 +405,9 @@ define([ }, - createRequest: function (v) { + createRequest: function(v) { var that = this; - return $ + return $j .ajax({ url: baseUrl + '/api/resources', type: 'GET', @@ -404,9 +425,10 @@ define([ }); + var AssigneeFilterView = AjaxSelectFilterView.extend({ - initialize: function () { + initialize: function() { BaseFilters.BaseFilterView.prototype.initialize.call(this, { detailsView: AjaxSelectDetailsFilterView }); @@ -414,9 +436,9 @@ define([ this.choices = new UserSuggestions(); }, - createRequest: function (v) { + createRequest: function(v) { var that = this; - return $ + return $j .ajax({ url: baseUrl + '/api/users/search', type: 'GET', @@ -434,9 +456,10 @@ define([ }); + var ReporterFilterView = AjaxSelectFilterView.extend({ - initialize: function () { + initialize: function() { BaseFilters.BaseFilterView.prototype.initialize.call(this, { detailsView: AjaxSelectDetailsFilterView }); @@ -446,9 +469,9 @@ define([ }, - createRequest: function (v) { + createRequest: function(v) { var that = this; - return $ + return $j .ajax({ url: baseUrl + '/api/users/search', type: 'GET', @@ -466,6 +489,7 @@ define([ }); + /* * Export public classes */ diff --git a/server/sonar-web/src/main/js/components/navigator/filters/base-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/base-filters.js index 17d6612f2b4..e4298597794 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/base-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/base-filters.js @@ -1,9 +1,25 @@ +/* + * 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([ - 'jquery', - 'backbone', - 'backbone.marionette', '../templates' -], function ($, Backbone, Marionette) { +], function () { var Filter = Backbone.Model.extend({ @@ -17,37 +33,38 @@ define([ }); + var Filters = Backbone.Collection.extend({ model: Filter }); + var DetailsFilterView = Marionette.ItemView.extend({ template: Templates['base-details-filter'], className: 'navigator-filter-details', - initialize: function () { - this.$el.on('click', function (e) { + initialize: function() { + this.$el.on('click', function(e) { e.stopPropagation(); }); this.$el.attr('id', 'filter-' + this.model.get('property')); }, - onShow: function () { - }, - onHide: function () { - } + onShow: function() {}, + onHide: function() {} }); + var BaseFilterView = Marionette.ItemView.extend({ template: Templates['base-filter'], className: 'navigator-filter', - events: function () { + events: function() { return { 'click': 'toggleDetails', 'click .navigator-filter-disable': 'disable' @@ -64,7 +81,7 @@ define([ }, - initialize: function (options) { + initialize: function(options) { Marionette.ItemView.prototype.initialize.apply(this, arguments); var detailsView = (options && options.detailsView) || DetailsFilterView; @@ -77,12 +94,12 @@ define([ }, - attachDetailsView: function () { - this.detailsView.$el.detach().appendTo($('body')); + attachDetailsView: function() { + this.detailsView.$el.detach().appendTo($j('body')); }, - render: function () { + render: function() { this.renderBase(); this.attachDetailsView(); @@ -98,7 +115,7 @@ define([ }, - renderBase: function () { + renderBase: function() { Marionette.ItemView.prototype.render.apply(this, arguments); this.renderInput(); @@ -108,16 +125,15 @@ define([ }, - renderInput: function () { - }, + renderInput: function() {}, - focus: function () { + focus: function() { this.render(); }, - toggleDetails: function (e) { + toggleDetails: function(e) { e.stopPropagation(); this.options.filterBarView.selected = this.options.filterBarView.getEnabledFilters().index(this.$el); if (this.$el.hasClass('active')) { @@ -130,7 +146,7 @@ define([ }, - showDetails: function () { + showDetails: function() { this.registerShowedDetails(); var top = this.$el.offset().top + this.$el.outerHeight() - 1, @@ -142,35 +158,35 @@ define([ }, - registerShowedDetails: function () { + registerShowedDetails: function() { this.options.filterBarView.hideDetails(); this.options.filterBarView.showedView = this; }, - hideDetails: function () { + hideDetails: function() { this.detailsView.$el.removeClass('active'); this.$el.removeClass('active'); this.detailsView.onHide(); }, - isActive: function () { + isActive: function() { return this.$el.is('.active'); }, - renderValue: function () { + renderValue: function() { return this.model.get('value') || 'unset'; }, - isDefaultValue: function () { + isDefaultValue: function() { return true; }, - restoreFromQuery: function (q) { + restoreFromQuery: function(q) { var param = _.findWhere(q, { key: this.model.get('property') }); if (param && param.value) { this.model.set('enabled', true); @@ -181,18 +197,18 @@ define([ }, - restore: function (value) { + restore: function(value) { this.model.set({ value: value }, { silent: true }); this.renderBase(); }, - clear: function () { + clear: function() { this.model.unset('value'); }, - disable: function (e) { + disable: function(e) { e.stopPropagation(); this.hideDetails(); this.options.filterBarView.hideDetails(); @@ -203,7 +219,7 @@ define([ }, - formatValue: function () { + formatValue: function() { var q = {}; if (this.model.has('property') && this.model.has('value') && this.model.get('value')) { q[this.model.get('property')] = this.model.get('value'); @@ -212,7 +228,7 @@ define([ }, - serializeData: function () { + serializeData: function() { return _.extend({}, this.model.toJSON(), { value: this.renderValue(), defaultValue: this.isDefaultValue() @@ -222,6 +238,7 @@ define([ }); + /* * Export public classes */ diff --git a/server/sonar-web/src/main/js/components/navigator/filters/checkbox-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/checkbox-filters.js index fe1e0573f68..8c837802e24 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/checkbox-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/checkbox-filters.js @@ -1,28 +1,45 @@ +/* + * 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([ - 'jquery', './base-filters', '../templates' -], function ($, BaseFilters) { +], function (BaseFilters) { return BaseFilters.BaseFilterView.extend({ template: Templates['checkbox-filter'], className: 'navigator-filter navigator-filter-inline', - events: function () { + events: function() { return { 'click .navigator-filter-disable': 'disable' }; }, - showDetails: function () { - }, + showDetails: function() {}, - renderInput: function () { + renderInput: function() { if (this.model.get('enabled')) { - $('') + $j('') .prop('name', this.model.get('property')) .prop('type', 'checkbox') .prop('value', 'true') @@ -33,17 +50,17 @@ define([ }, - renderValue: function () { + renderValue: function() { return this.model.get('value'); }, - isDefaultValue: function () { + isDefaultValue: function() { return false; }, - restore: function (value) { + restore: function(value) { this.model.set({ value: value, enabled: true diff --git a/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js index aa5970504dc..31fc08656ba 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js @@ -1,48 +1,65 @@ +/* + * 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([ - 'jquery', - 'backbone', './base-filters', '../templates' -], function ($, Backbone, BaseFilters) { +], function (BaseFilters) { var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({ template: Templates['choice-filter'], itemTemplate: Templates['choice-filter-item'], - events: function () { + events: function() { return { 'click label': 'onCheck' }; }, - render: function () { + render: function() { BaseFilters.DetailsFilterView.prototype.render.apply(this, arguments); this.updateLists(); }, - renderList: function (collection, selector) { + renderList: function(collection, selector) { var that = this, container = this.$(selector); container.empty().toggleClass('hidden', collection.length === 0); collection.each(function (item) { container.append( - that.itemTemplate(_.extend(item.toJSON(), { - multiple: that.model.get('multiple') && item.get('id')[0] !== '!' - })) + that.itemTemplate(_.extend(item.toJSON(), { + multiple: that.model.get('multiple') && item.get('id')[0] !== '!' + })) ); }); }, - updateLists: function () { - var choices = new Backbone.Collection(this.options.filterView.choices.reject(function (item) { + updateLists: function() { + var choices = new Backbone.Collection(this.options.filterView.choices.reject(function(item) { return item.get('id')[0] === '!'; })), - opposite = new Backbone.Collection(this.options.filterView.choices.filter(function (item) { + opposite = new Backbone.Collection(this.options.filterView.choices.filter(function(item) { return item.get('id')[0] === '!'; })); @@ -54,25 +71,25 @@ define([ }, - onCheck: function (e) { + onCheck: function(e) { var checkbox = jQuery(e.currentTarget), id = checkbox.data('id'), checked = checkbox.find('.icon-checkbox-checked').length > 0; if (this.model.get('multiple')) { if (checkbox.closest('.opposite').length > 0) { - this.options.filterView.choices.each(function (item) { - item.set('checked', false); - }); + this.options.filterView.choices.each(function(item) { + item.set('checked', false); + }); } else { - this.options.filterView.choices.filter(function (item) { + this.options.filterView.choices.filter(function(item) { return item.get('id')[0] === '!'; - }).forEach(function (item) { - item.set('checked', false); - }); + }).forEach(function(item) { + item.set('checked', false); + }); } } else { - this.options.filterView.choices.each(function (item) { + this.options.filterView.choices.each(function(item) { item.set('checked', false); }); } @@ -83,32 +100,32 @@ define([ }, - updateValue: function () { - this.model.set('value', this.options.filterView.getSelected().map(function (m) { + updateValue: function() { + this.model.set('value', this.options.filterView.getSelected().map(function(m) { return m.get('id'); })); }, - updateCurrent: function (index) { + updateCurrent: function(index) { this.currentChoice = index; this.$('label').removeClass('current') .eq(this.currentChoice).addClass('current'); }, - onShow: function () { + onShow: function() { this.bindedOnKeyDown = _.bind(this.onKeyDown, this); - $('body').on('keydown', this.bindedOnKeyDown); + $j('body').on('keydown', this.bindedOnKeyDown); }, - onHide: function () { - $('body').off('keydown', this.bindedOnKeyDown); + onHide: function() { + $j('body').off('keydown', this.bindedOnKeyDown); }, - onKeyDown: function (e) { + onKeyDown: function(e) { switch (e.keyCode) { case 38: e.preventDefault(); @@ -129,7 +146,7 @@ define([ }, - selectNextChoice: function () { + selectNextChoice: function() { if (this.$('label').length > this.currentChoice + 1) { this.updateCurrent(this.currentChoice + 1); this.scrollNext(); @@ -137,7 +154,7 @@ define([ }, - scrollNext: function () { + scrollNext: function() { var currentLabel = this.$('label').eq(this.currentChoice); if (currentLabel.length > 0) { var list = currentLabel.closest('ul'), @@ -151,7 +168,7 @@ define([ }, - selectPrevChoice: function () { + selectPrevChoice: function() { if (this.currentChoice > 0) { this.updateCurrent(this.currentChoice - 1); this.scrollPrev(); @@ -159,7 +176,7 @@ define([ }, - scrollPrev: function () { + scrollPrev: function() { var currentLabel = this.$('label').eq(this.currentChoice); if (currentLabel.length > 0) { var list = currentLabel.closest('ul'), @@ -172,18 +189,18 @@ define([ }, - selectCurrent: function () { + selectCurrent: function() { var cb = this.$('label').eq(this.currentChoice); cb.click(); }, - serializeData: function () { + serializeData: function() { return _.extend({}, this.model.toJSON(), { - choices: new Backbone.Collection(this.options.filterView.choices.reject(function (item) { + choices: new Backbone.Collection(this.options.filterView.choices.reject(function(item) { return item.get('id')[0] === '!'; })).toJSON(), - opposite: new Backbone.Collection(this.options.filterView.choices.filter(function (item) { + opposite: new Backbone.Collection(this.options.filterView.choices.filter(function(item) { return item.get('id')[0] === '!'; })).toJSON() }); @@ -192,9 +209,10 @@ define([ }); + var ChoiceFilterView = BaseFilters.BaseFilterView.extend({ - initialize: function (options) { + initialize: function(options) { BaseFilters.BaseFilterView.prototype.initialize.call(this, { detailsView: (options && options.detailsView) ? options.detailsView : DetailsChoiceFilterView }); @@ -203,7 +221,7 @@ define([ icons = this.model.get('choiceIcons'); this.choices = new Backbone.Collection( - _.map(this.model.get('choices'), function (value, key) { + _.map(this.model.get('choices'), function(value, key) { var model = new Backbone.Model({ id: key, text: value, @@ -221,20 +239,20 @@ define([ }, - getSelected: function () { - return this.choices.filter(function (m) { + getSelected: function() { + return this.choices.filter(function(m) { return m.get('checked'); }); }, - renderInput: function () { - var input = $('') .prop('name', this.model.get('property')) .prop('multiple', true) .css('display', 'none'); - this.choices.each(function (item) { - var option = $(''; @@ -90,7 +108,7 @@ define([ }, - onShow: function () { + onShow: function() { var select = this.$('[name=metric]'); if (this.model.get('value').metric === '') { select.select2('open'); @@ -102,9 +120,10 @@ define([ }); + return BaseFilters.BaseFilterView.extend({ - initialize: function () { + initialize: function() { BaseFilters.BaseFilterView.prototype.initialize.call(this, { detailsView: DetailsMetricFilterView }); @@ -113,7 +132,7 @@ define([ }, - groupMetrics: function () { + groupMetrics: function() { var metrics = _.map(this.model.get('metrics'), function (metric) { return metric.metric; }), @@ -133,26 +152,26 @@ define([ }, - renderValue: function () { + renderValue: function() { return this.isDefaultValue() ? window.SS.phrases.notSet : - this.model.get('value').metricText + ' ' + this.model.get('value').opText + ' ' + - this.model.get('value').valText; + this.model.get('value').metricText + ' ' + this.model.get('value').opText + ' ' + + this.model.get('value').valText; }, - renderInput: function () { + renderInput: function() { var that = this, value = this.model.get('value'); if (_.isObject(value) && value.metric && value.op && (value.val != null)) { - _.each(['metric', 'period', 'op', 'val'], function (key) { + _.each(['metric', 'period', 'op', 'val'], function(key) { var v = value[key]; if (key === 'period' && v === '0') { v = ''; } - $('') + $j('') .prop('name', that.model.get('property') + '_' + key) .prop('type', 'hidden') .css('display', 'none') @@ -163,7 +182,7 @@ define([ }, - isDefaultValue: function () { + isDefaultValue: function() { var value = this.model.get('value'); if (!_.isObject(value)) { return true; @@ -172,10 +191,10 @@ define([ }, - restoreFromQuery: function (q) { + restoreFromQuery: function(q) { var that = this, value = {}; - _.each(['metric', 'period', 'op', 'val'], function (p) { + _.each(['metric', 'period', 'op', 'val'], function(p) { var property = that.model.get('property') + '_' + p, pValue = _.findWhere(q, { key: property }); diff --git a/server/sonar-web/src/main/js/components/navigator/filters/more-criteria-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/more-criteria-filters.js index 64a7807b9b0..f2a39f9a218 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/more-criteria-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/more-criteria-filters.js @@ -1,9 +1,27 @@ +/* + * 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([ - 'jquery', './base-filters', './choice-filters', '../templates' -], function ($, BaseFilters, ChoiceFilters) { +], function (BaseFilters, ChoiceFilters) { var DetailsMoreCriteriaFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({ template: Templates['more-criteria-details-filter'], @@ -14,14 +32,14 @@ define([ }, - enableById: function (id) { + enableById: function(id) { this.model.view.options.filterBarView.enableFilter(id); this.model.view.hideDetails(); }, - enableByProperty: function (property) { - var filter = _.find(this.model.get('filters'), function (f) { + enableByProperty: function(property) { + var filter = _.find(this.model.get('filters'), function(f) { return f.get('property') === property; }); if (filter) { @@ -30,23 +48,23 @@ define([ }, - enableFilter: function (e) { - var id = $(e.target).data('id'); + enableFilter: function(e) { + var id = $j(e.target).data('id'); this.enableById(id); this.updateCurrent(0); }, - selectCurrent: function () { + selectCurrent: function() { this.$('label').eq(this.currentChoice).click(); }, - serializeData: function () { - var filters = this.model.get('filters').map(function (filter) { + serializeData: function() { + var filters = this.model.get('filters').map(function(filter) { return _.extend(filter.toJSON(), { id: filter.cid }); }), - getName = function (filter) { + getName = function(filter) { return filter.name; }, uniqueFilters = _.unique(filters, getName), @@ -57,40 +75,41 @@ define([ }); + var MoreCriteriaFilterView = ChoiceFilters.ChoiceFilterView.extend({ template: Templates['more-criteria-filter'], className: 'navigator-filter navigator-filter-more-criteria', - initialize: function () { + initialize: function() { ChoiceFilters.ChoiceFilterView.prototype.initialize.call(this, { detailsView: DetailsMoreCriteriaFilterView }); }, - renderValue: function () { + renderValue: function() { return ''; }, - renderInput: function () { - }, + renderInput: function() {}, - renderBase: function () { + renderBase: function() { ChoiceFilters.ChoiceFilterView.prototype.renderBase.call(this); this.$el.prop('title', ''); }, - isDefaultValue: function () { + isDefaultValue: function() { return false; } }); + /* * Export public classes */ diff --git a/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js index 5c8be7a5cbc..e46d15594fd 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js @@ -1,8 +1,26 @@ +/* + * 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([ - 'jquery', './base-filters', '../templates' -], function ($, BaseFilters) { +], function (BaseFilters) { var DetailsRangeFilterView = BaseFilters.DetailsFilterView.extend({ template: Templates['range-filter'], @@ -13,7 +31,7 @@ define([ }, - change: function () { + change: function() { var value = {}, valueFrom = this.$('input').eq(0).val(), valueTo = this.$('input').eq(1).val(); @@ -30,7 +48,7 @@ define([ }, - populateInputs: function () { + populateInputs: function() { var value = this.model.get('value'), propertyFrom = this.model.get('propertyFrom'), propertyTo = this.model.get('propertyTo'), @@ -42,23 +60,24 @@ define([ }, - onShow: function () { + onShow: function() { this.$(':input:first').focus(); } }); + var RangeFilterView = BaseFilters.BaseFilterView.extend({ - initialize: function () { + initialize: function() { BaseFilters.BaseFilterView.prototype.initialize.call(this, { detailsView: DetailsRangeFilterView }); }, - renderValue: function () { + renderValue: function() { if (!this.isDefaultValue()) { var value = _.values(this.model.get('value')); return value.join(' — '); @@ -68,21 +87,21 @@ define([ }, - renderInput: function () { + renderInput: function() { var value = this.model.get('value'), propertyFrom = this.model.get('propertyFrom'), propertyTo = this.model.get('propertyTo'), valueFrom = _.isObject(value) && value[propertyFrom], valueTo = _.isObject(value) && value[propertyTo]; - $('') + $j('') .prop('name', propertyFrom) .prop('type', 'hidden') .css('display', 'none') .val(valueFrom || '') .appendTo(this.$el); - $('') + $j('') .prop('name', propertyTo) .prop('type', 'hidden') .css('display', 'none') @@ -91,7 +110,7 @@ define([ }, - isDefaultValue: function () { + isDefaultValue: function() { var value = this.model.get('value'), propertyFrom = this.model.get('propertyFrom'), propertyTo = this.model.get('propertyTo'), @@ -102,7 +121,7 @@ define([ }, - restoreFromQuery: function (q) { + restoreFromQuery: function(q) { var paramFrom = _.findWhere(q, { key: this.model.get('propertyFrom') }), paramTo = _.findWhere(q, { key: this.model.get('propertyTo') }), value = {}; @@ -126,13 +145,13 @@ define([ }, - restore: function (value) { + restore: function(value) { if (this.choices && this.selection && value.length > 0) { var that = this; this.choices.add(this.selection.models); this.selection.reset([]); - _.each(value, function (v) { + _.each(value, function(v) { var cModel = that.choices.findWhere({ id: v }); if (cModel) { @@ -151,12 +170,12 @@ define([ }, - formatValue: function () { + formatValue: function() { return this.model.get('value'); }, - clear: function () { + clear: function() { this.model.unset('value'); this.detailsView.render(); } @@ -164,9 +183,10 @@ define([ }); + var DateRangeFilterView = RangeFilterView.extend({ - render: function () { + render: function() { RangeFilterView.prototype.render.apply(this, arguments); this.detailsView.$('input') .prop('placeholder', '1970-01-31') @@ -181,7 +201,7 @@ define([ }, - renderValue: function () { + renderValue: function() { if (!this.isDefaultValue()) { var value = _.values(this.model.get('value')); return value.join(' — '); @@ -193,6 +213,7 @@ define([ }); + /* * Export public classes */ diff --git a/server/sonar-web/src/main/js/components/navigator/filters/string-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/string-filters.js index 2716c4f1a59..c667ccc73e6 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/string-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/string-filters.js @@ -1,8 +1,26 @@ +/* + * 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([ - 'jquery', './base-filters', '../templates' -], function ($, BaseFilters) { +], function (BaseFilters) { var DetailsStringFilterView = BaseFilters.DetailsFilterView.extend({ template: Templates['string-filter'], @@ -13,18 +31,18 @@ define([ }, - change: function (e) { - this.model.set('value', $(e.target).val()); + change: function(e) { + this.model.set('value', $j(e.target).val()); }, - onShow: function () { + onShow: function() { BaseFilters.DetailsFilterView.prototype.onShow.apply(this, arguments); this.$(':input').focus(); }, - serializeData: function () { + serializeData: function() { return _.extend({}, this.model.toJSON(), { value: this.model.get('value') || '' }); @@ -33,22 +51,23 @@ define([ }); + return BaseFilters.BaseFilterView.extend({ - initialize: function () { + initialize: function() { BaseFilters.BaseFilterView.prototype.initialize.call(this, { detailsView: DetailsStringFilterView }); }, - renderValue: function () { + renderValue: function() { return this.isDefaultValue() ? '—' : this.model.get('value'); }, - renderInput: function () { - $('') + renderInput: function() { + $j('') .prop('name', this.model.get('property')) .prop('type', 'hidden') .css('display', 'none') @@ -57,12 +76,12 @@ define([ }, - isDefaultValue: function () { + isDefaultValue: function() { return !this.model.get('value'); }, - restore: function (value) { + restore: function(value) { this.model.set({ value: value, enabled: true @@ -70,7 +89,7 @@ define([ }, - clear: function () { + clear: function() { this.model.unset('value'); this.detailsView.render(); } diff --git a/server/sonar-web/src/main/js/components/navigator/models/facet.js b/server/sonar-web/src/main/js/components/navigator/models/facet.js index 94d0fadb8a7..d3f32792984 100644 --- a/server/sonar-web/src/main/js/components/navigator/models/facet.js +++ b/server/sonar-web/src/main/js/components/navigator/models/facet.js @@ -1,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { return Backbone.Model.extend({ idAttribute: 'property', diff --git a/server/sonar-web/src/main/js/components/navigator/models/facets.js b/server/sonar-web/src/main/js/components/navigator/models/facets.js index 88929deb8da..f022ce478e8 100644 --- a/server/sonar-web/src/main/js/components/navigator/models/facets.js +++ b/server/sonar-web/src/main/js/components/navigator/models/facets.js @@ -1,7 +1,25 @@ +/* + * 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/models/facet' -], function (Backbone, Facet) { +], function (Facet) { return Backbone.Collection.extend({ model: Facet diff --git a/server/sonar-web/src/main/js/components/navigator/models/state.js b/server/sonar-web/src/main/js/components/navigator/models/state.js index e2d284aed2e..fe53b18cf0e 100644 --- a/server/sonar-web/src/main/js/components/navigator/models/state.js +++ b/server/sonar-web/src/main/js/components/navigator/models/state.js @@ -1,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { return Backbone.Model.extend({ defaults: function () { diff --git a/server/sonar-web/src/main/js/components/navigator/router.js b/server/sonar-web/src/main/js/components/navigator/router.js index 41522b81d9f..5eb8e47487f 100644 --- a/server/sonar-web/src/main/js/components/navigator/router.js +++ b/server/sonar-web/src/main/js/components/navigator/router.js @@ -1,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { return Backbone.Router.extend({ routeSeparator: '|', diff --git a/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js b/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js index 56f5513b7f4..75e34798616 100644 --- a/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js +++ b/server/sonar-web/src/main/js/components/navigator/workspace-header-view.js @@ -1,6 +1,23 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +/* + * 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 () { return Marionette.ItemView.extend({ diff --git a/server/sonar-web/src/main/js/components/navigator/workspace-list-item-view.js b/server/sonar-web/src/main/js/components/navigator/workspace-list-item-view.js index 6736b378798..4afe491481b 100644 --- a/server/sonar-web/src/main/js/components/navigator/workspace-list-item-view.js +++ b/server/sonar-web/src/main/js/components/navigator/workspace-list-item-view.js @@ -1,6 +1,23 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +/* + * 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 () { return Marionette.ItemView.extend({ diff --git a/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js b/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js index ddf22fa6809..a9c1831c835 100644 --- a/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js +++ b/server/sonar-web/src/main/js/components/navigator/workspace-list-view.js @@ -1,6 +1,23 @@ -define([ - 'backbone.marionette' -], function (Marionette) { +/* + * 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 () { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/components/shared/avatar.jsx b/server/sonar-web/src/main/js/components/shared/avatar.jsx index 10f74ac42a9..2f596bf3a0d 100644 --- a/server/sonar-web/src/main/js/components/shared/avatar.jsx +++ b/server/sonar-web/src/main/js/components/shared/avatar.jsx @@ -7,12 +7,12 @@ export default React.createClass({ }, render() { - const shouldShowAvatar = window.sonar.properties['sonar.lf.enableGravatar']; + const shouldShowAvatar = window.SS && window.SS.lf && window.SS.lf.enableGravatar; if (!shouldShowAvatar) { return null; } const emailHash = window.md5(this.props.email || '').trim(); - const url = ('' + window.sonar.properties['sonar.lf.gravatarServerUrl']) + const url = ('' + window.SS.lf.gravatarServerUrl) .replace('{EMAIL_MD5}', emailHash) .replace('{SIZE}', this.props.size * 2); return {this.props.email}/; diff --git a/server/sonar-web/src/main/js/components/source-viewer/header.js b/server/sonar-web/src/main/js/components/source-viewer/header.js index 1cd5a625024..e241c886c09 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/header.js +++ b/server/sonar-web/src/main/js/components/source-viewer/header.js @@ -18,14 +18,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ define([ - 'backbone.marionette', './more-actions', './measures-overlay', './templates' -], function (Marionette, MoreActionsView, MeasuresOverlay) { +], function (MoreActionsView, MeasuresOverlay) { var $ = jQuery, - API_FAVORITE = window.baseUrl + '/api/favourites'; + API_FAVORITE = baseUrl + '/api/favourites'; return Marionette.ItemView.extend({ template: Templates['source-viewer-header'], diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js index 07d06086db1..fca5c86eeeb 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/main.js +++ b/server/sonar-web/src/main/js/components/source-viewer/main.js @@ -1,6 +1,23 @@ +/* + * 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', './source', 'components/issue/models/issue', 'components/issue/collections/issues', @@ -14,9 +31,7 @@ define([ './helpers/code-with-issue-locations-helper', './templates' ], - function (Backbone, - Marionette, - Source, + function (Source, Issue, Issues, IssueView, @@ -713,7 +728,7 @@ define([ $(e.currentTarget).tooltip({ container: 'body', placement: 'right', - title: window.tp('source_viewer.tooltip.new_code', this.sinceLabel), + title: tp('source_viewer.tooltip.new_code', this.sinceLabel), trigger: 'manual' }).tooltip('show'); }, diff --git a/server/sonar-web/src/main/js/components/source-viewer/more-actions.js b/server/sonar-web/src/main/js/components/source-viewer/more-actions.js index ddfbdd60dec..a1b5ff87f99 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/more-actions.js +++ b/server/sonar-web/src/main/js/components/source-viewer/more-actions.js @@ -1,8 +1,26 @@ +/* + * 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/workspace/main', './templates' -], function (Marionette, Workspace) { +], function (Workspace) { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js b/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js index f3aa57915d0..51c263819bd 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js +++ b/server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js @@ -20,7 +20,6 @@ define([ 'components/common/popup', 'components/workspace/main', - '../../../components/common/jquery-isolated-scroll', '../templates' ], function (Popup, Workspace) { diff --git a/server/sonar-web/src/main/js/components/source-viewer/popups/scm-popup.js b/server/sonar-web/src/main/js/components/source-viewer/popups/scm-popup.js index 2c92de40689..bdbaea22f0f 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/popups/scm-popup.js +++ b/server/sonar-web/src/main/js/components/source-viewer/popups/scm-popup.js @@ -19,7 +19,6 @@ */ define([ 'components/common/popup', - '../../../components/common/jquery-isolated-scroll', '../templates' ], function (Popup) { diff --git a/server/sonar-web/src/main/js/components/source-viewer/source.js b/server/sonar-web/src/main/js/components/source-viewer/source.js index b6ac7cd2ebf..168a86bb9c2 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/source.js +++ b/server/sonar-web/src/main/js/components/source-viewer/source.js @@ -1,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { return Backbone.Model.extend({ idAttribute: 'uuid', diff --git a/server/sonar-web/src/main/js/components/workspace/models/item.js b/server/sonar-web/src/main/js/components/workspace/models/item.js index 0ce21d4df0f..9bbe1db8110 100644 --- a/server/sonar-web/src/main/js/components/workspace/models/item.js +++ b/server/sonar-web/src/main/js/components/workspace/models/item.js @@ -1,6 +1,23 @@ -define([ - 'backbone' -], function (Backbone) { +/* + * 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 () { return Backbone.Model.extend({ diff --git a/server/sonar-web/src/main/js/components/workspace/models/items.js b/server/sonar-web/src/main/js/components/workspace/models/items.js index eb5b13dc4d3..2fa11670ed3 100644 --- a/server/sonar-web/src/main/js/components/workspace/models/items.js +++ b/server/sonar-web/src/main/js/components/workspace/models/items.js @@ -1,7 +1,23 @@ -define([ - 'backbone', - './item' -], function (Backbone, Item) { +/* + * 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(['./item'], function (Item) { var STORAGE_KEY = 'sonarqube-workspace'; @@ -23,9 +39,7 @@ define([ try { var parsed = JSON.parse(dump); this.reset(parsed); - } catch (err) { - // do nothing - } + } catch (err) { } } }, diff --git a/server/sonar-web/src/main/js/components/workspace/views/base-viewer-view.js b/server/sonar-web/src/main/js/components/workspace/views/base-viewer-view.js index 2562e8d0f1a..c917fbc9f65 100644 --- a/server/sonar-web/src/main/js/components/workspace/views/base-viewer-view.js +++ b/server/sonar-web/src/main/js/components/workspace/views/base-viewer-view.js @@ -1,8 +1,25 @@ +/* + * 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', - './viewer-header-view', - '../../common/jquery-isolated-scroll' -], function (Marionette, HeaderView) { + './viewer-header-view' +], function (HeaderView) { return Marionette.LayoutView.extend({ className: 'workspace-viewer', diff --git a/server/sonar-web/src/main/js/components/workspace/views/item-view.js b/server/sonar-web/src/main/js/components/workspace/views/item-view.js index d51d35debaa..17a67af8835 100644 --- a/server/sonar-web/src/main/js/components/workspace/views/item-view.js +++ b/server/sonar-web/src/main/js/components/workspace/views/item-view.js @@ -1,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { return Marionette.ItemView.extend({ tagName: 'li', diff --git a/server/sonar-web/src/main/js/components/workspace/views/items-view.js b/server/sonar-web/src/main/js/components/workspace/views/items-view.js index bbd3326ad3e..36aa5679097 100644 --- a/server/sonar-web/src/main/js/components/workspace/views/items-view.js +++ b/server/sonar-web/src/main/js/components/workspace/views/items-view.js @@ -1,8 +1,26 @@ +/* + * 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', '../templates' -], function (Marionette, ItemView) { +], function (ItemView) { return Marionette.CompositeView.extend({ className: 'workspace-nav', diff --git a/server/sonar-web/src/main/js/components/workspace/views/rule-view.js b/server/sonar-web/src/main/js/components/workspace/views/rule-view.js index f14d621b7f4..f3e427116bc 100644 --- a/server/sonar-web/src/main/js/components/workspace/views/rule-view.js +++ b/server/sonar-web/src/main/js/components/workspace/views/rule-view.js @@ -1,8 +1,26 @@ +/* + * 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', './base-viewer-view', '../templates' -], function (Marionette, BaseView) { +], function (BaseView) { return BaseView.extend({ template: Templates['workspace-rule'], diff --git a/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js b/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js index e877238ad19..6ef5b47f375 100644 --- a/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js +++ b/server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js @@ -1,7 +1,25 @@ +/* + * 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 (Marionette) { +], function () { var $ = jQuery; diff --git a/server/sonar-web/src/main/js/libs/application.js b/server/sonar-web/src/main/js/libs/application.js index 335ca996ec8..bc3fb63b444 100644 --- a/server/sonar-web/src/main/js/libs/application.js +++ b/server/sonar-web/src/main/js/libs/application.js @@ -29,9 +29,9 @@ * @param {string} message */ window.showMessage = function (id, message) { - $('#' + id + 'msg').html(message); - $('#' + id).removeClass('hidden'); - $('#messages-panel').removeClass('hidden'); + $j('#' + id + 'msg').html(message); + $j('#' + id).removeClass('hidden'); + $j('#messages-panel').removeClass('hidden'); }; /** @@ -40,8 +40,8 @@ * @returns {boolean} always false */ window.hideMessage = function (id) { - $('#' + id).addClass('hidden'); - var messagePanel = $('#messages-panel'), + $j('#' + id).addClass('hidden'); + var messagePanel = $j('#messages-panel'), isEmpty = messagePanel.children('*:not(.hidden)').length === 0; messagePanel.toggleClass('hidden', isEmpty); return false; @@ -52,7 +52,7 @@ * @param {string} message */ window.error = function (message) { - window.showMessage('error', message); + showMessage('error', message); }; /** @@ -60,7 +60,7 @@ * @param {string} message */ window.warning = function (message) { - window.showMessage('warning', message); + showMessage('warning', message); }; /** @@ -68,7 +68,7 @@ * @param {string} message */ window.info = function (message) { - window.showMessage('info', message); + showMessage('info', message); }; /** @@ -76,7 +76,7 @@ * @returns {boolean} always false */ window.hideError = function () { - return window.hideMessage('error'); + return hideMessage('error'); }; /** @@ -84,7 +84,7 @@ * @returns {boolean} always false */ window.hideWarning = function () { - return window.hideMessage('warning'); + return hideMessage('warning'); }; /** @@ -92,29 +92,30 @@ * @returns {boolean} always false */ window.hideInfo = function () { - return window.hideMessage('info'); + return hideMessage('info'); }; })(); -window.toggleFav = function (resourceId, elt) { - $.ajax({ + +function toggleFav (resourceId, elt) { + $j.ajax({ type: 'POST', dataType: 'json', url: baseUrl + '/favourites/toggle/' + resourceId, success: function (data) { - var star = $(elt); + var star = $j(elt); star.removeClass('icon-favorite icon-not-favorite'); star.addClass(data.css); star.attr('title', data.title); } }); -}; +} -window.dashboardParameters = function (urlHasSomething) { +function dashboardParameters (urlHasSomething) { var queryString = window.location.search; var parameters = []; var matchDashboard = queryString.match(/did=\d+/); - if (matchDashboard && $('#is-project-dashboard').length === 1) { + if (matchDashboard && $j('#is-project-dashboard').length === 1) { parameters.push(matchDashboard[0]); } @@ -132,15 +133,15 @@ window.dashboardParameters = function (urlHasSomething) { query = (urlHasSomething ? '&' : '?') + query; } return query; -}; +} -window.openModalWindow = function (url, options) { +function openModalWindow (url, options) { var width = (options && options.width) || 540; - var $dialog = $('#modal'); + var $dialog = $j('#modal'); if (!$dialog.length) { - $dialog = $('').appendTo('body'); + $dialog = $j('').appendTo('body'); } - $.get(url, function (html) { + $j.get(url, function (html) { $dialog.removeClass('ui-widget-overlay'); $dialog.html(html); $dialog @@ -154,7 +155,7 @@ window.openModalWindow = function (url, options) { resizable: false, title: null, close: function () { - $('#modal').remove(); + $j('#modal').remove(); } }); $dialog.dialog('open'); @@ -162,20 +163,20 @@ window.openModalWindow = function (url, options) { $dialog.removeClass('ui-widget-overlay'); }); return false; -}; +} -(function ($) { - $.fn.extend({ +(function ($j) { + $j.fn.extend({ openModal: function () { return this.each(function () { - var obj = $(this); + var obj = $j(this); var url = obj.attr('modal-url') || obj.attr('href'); - return window.openModalWindow(url, { 'width': obj.attr('modal-width') }); + return openModalWindow(url, { 'width': obj.attr('modal-width') }); }); }, modal: function () { return this.each(function () { - var obj = $(this); + var obj = $j(this); obj.unbind('click'); var $link = obj.bind('click', function () { $link.openModal(); @@ -185,10 +186,10 @@ window.openModalWindow = function (url, options) { }, modalForm: function (ajax_options) { return this.each(function () { - var obj = $(this); + var obj = $j(this); obj.submit(function () { - $('input[type=submit]', this).attr('disabled', 'disabled'); - $.ajax($.extend({ + $j('input[type=submit]', this).attr('disabled', 'disabled'); + $j.ajax($j.extend({ type: 'POST', url: obj.attr('action'), data: obj.serialize(), @@ -200,14 +201,14 @@ window.openModalWindow = function (url, options) { var errorElt = obj.find('.modal-error'); if (errorElt.length) { // Hide all loading images - $('.loading-image').addClass('hidden'); + $j('.loading-image').addClass('hidden'); // Re activate submit button - $('input[type=submit]', obj).removeAttr('disabled'); + $j('input[type=submit]', obj).removeAttr('disabled'); errorElt.show(); - errorElt.html($('
').html(xhr.responseText).text()); + errorElt.html($j('
').html(xhr.responseText).text()); } else { // otherwise replace modal window by the returned text - $('#modal').html(xhr.responseText); + $j('#modal').html(xhr.responseText); } } }, ajax_options)); @@ -218,63 +219,67 @@ window.openModalWindow = function (url, options) { }); })(jQuery); -window.closeModalWindow = function () { - $('#modal').dialog('close'); +function closeModalWindow () { + $j('#modal').dialog('close'); return false; -}; +} + /* * File Path */ -/** - * Return a collapsed path without a file name - * @example - * // returns 'src/.../js/components/navigator/app/models/' - * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') - * @param {string} path - * @returns {string|null} - */ -window.collapsedDirFromPath = function (path) { - var limit = 30; - if (typeof path === 'string') { - var tokens = _.initial(path.split('/')); - if (tokens.length > 2) { - var head = _.first(tokens), - tail = _.last(tokens), - middle = _.initial(_.rest(tokens)), - cut = false; - while (middle.join().length > limit && middle.length > 0) { - middle.shift(); - cut = true; +(function () { + /** + * Return a collapsed path without a file name + * @example + * // returns 'src/.../js/components/navigator/app/models/' + * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') + * @param {string} path + * @returns {string|null} + */ + window.collapsedDirFromPath = function (path) { + var limit = 30; + if (typeof path === 'string') { + var tokens = _.initial(path.split('/')); + if (tokens.length > 2) { + var head = _.first(tokens), + tail = _.last(tokens), + middle = _.initial(_.rest(tokens)), + cut = false; + while (middle.join().length > limit && middle.length > 0) { + middle.shift(); + cut = true; + } + var body = [].concat(head, cut ? ['...'] : [], middle, tail); + return body.join('/') + '/'; + } else { + return tokens.join('/') + '/'; } - var body = [].concat(head, cut ? ['...'] : [], middle, tail); - return body.join('/') + '/'; } else { - return tokens.join('/') + '/'; + return null; } - } else { - return null; - } -}; - -/** - * Return a file name for a given file path - * * @example - * // returns 'state.js' - * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') - * @param {string} path - * @returns {string|null} - */ -window.fileFromPath = function (path) { - if (typeof path === 'string') { - var tokens = path.split('/'); - return _.last(tokens); - } else { - return null; - } -}; + }; + + /** + * Return a file name for a given file path + * * @example + * // returns 'state.js' + * collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js') + * @param {string} path + * @returns {string|null} + */ + window.fileFromPath = function (path) { + if (typeof path === 'string') { + var tokens = path.split('/'); + return _.last(tokens); + } else { + return null; + } + }; +})(); + /* @@ -394,15 +399,15 @@ window.fileFromPath = function (path) { function formatDuration (isNegative, days, hours, minutes) { var formatted = ''; if (shouldDisplayDays(days)) { - formatted += window.tp('work_duration.x_days', isNegative ? -1 * days : days); + formatted += tp('work_duration.x_days', isNegative ? -1 * days : days); } if (shouldDisplayHours(days, hours)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); + formatted += tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); } if (shouldDisplayMinutes(days, hours, minutes)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); + formatted += tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); } return formatted; } @@ -419,18 +424,18 @@ window.fileFromPath = function (path) { var formatted = ''; if (shouldDisplayDays(days)) { var formattedDays = window.formatMeasure(isNegative ? -1 * days : days, 'SHORT_INT'); - formatted += window.tp('work_duration.x_days', formattedDays); + formatted += tp('work_duration.x_days', formattedDays); } if (shouldDisplayHoursInShortFormat(days, hours)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); + formatted += tp('work_duration.x_hours', isNegative && formatted.length === 0 ? -1 * hours : hours); } if (shouldDisplayMinutesInShortFormat(days, hours, minutes)) { formatted = addSpaceIfNeeded(formatted); - formatted += window.tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); + formatted += tp('work_duration.x_minutes', isNegative && formatted.length === 0 ? -1 * minutes : minutes); } if (shouldDisplayAbout(days, hours, minutes)) { - formatted = window.tp('work_duration.about', formatted); + formatted = tp('work_duration.about', formatted); } return formatted; } @@ -444,7 +449,7 @@ window.fileFromPath = function (path) { if (value === 0) { return '0'; } - var hoursInDay = window.sonar.properties['sonar.technicalDebt.hoursInDay'], + var hoursInDay = window.SS.hoursInDay || 8, isNegative = value < 0, absValue = Math.abs(value); var days = Math.floor(absValue / hoursInDay / 60); @@ -464,7 +469,7 @@ window.fileFromPath = function (path) { if (value === 0) { return '0'; } - var hoursInDay = window.sonar.properties['sonar.technicalDebt.hoursInDay'], + var hoursInDay = window.SS.hoursInDay || 8, isNegative = value < 0, absValue = Math.abs(value); var days = Math.floor(absValue / hoursInDay / 60); @@ -556,11 +561,12 @@ window.fileFromPath = function (path) { })(); + /* * Users */ -(function () { +(function() { /** * Convert the result of api/users/search to select2 format @@ -568,7 +574,7 @@ window.fileFromPath = function (path) { window.usersToSelect2 = function (response) { return { more: false, - results: _.map(response.users, function (user) { + results: _.map(response.users, function(user) { return { id: user.login, text: user.name + ' (' + user.login + ')' @@ -580,6 +586,7 @@ window.fileFromPath = function (path) { })(); + /* * Misc */ diff --git a/server/sonar-web/src/main/js/libs/csv.js b/server/sonar-web/src/main/js/libs/csv.js new file mode 100644 index 00000000000..d015f7c5a97 --- /dev/null +++ b/server/sonar-web/src/main/js/libs/csv.js @@ -0,0 +1,27 @@ +/* + * 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. + */ +(function() { + + window.csvEscape = function(value) { + var escaped = value.replace(/"/g, '\\"'); + return '"' + escaped + '"'; + }; + +})(); diff --git a/server/sonar-web/src/main/js/libs/csv.jsx b/server/sonar-web/src/main/js/libs/csv.jsx deleted file mode 100644 index 126bd0f82c7..00000000000 --- a/server/sonar-web/src/main/js/libs/csv.jsx +++ /dev/null @@ -1,4 +0,0 @@ -export default function csvEscape (value) { - var escaped = value.replace(/"/g, '\\"'); - return '"' + escaped + '"'; -}; diff --git a/server/sonar-web/src/main/js/libs/inputs.js b/server/sonar-web/src/main/js/libs/inputs.js index 5e92a3bc0bb..78673a5e70e 100644 --- a/server/sonar-web/src/main/js/libs/inputs.js +++ b/server/sonar-web/src/main/js/libs/inputs.js @@ -9,9 +9,9 @@ if (value === '0') { return 0; } - daysPattern = transformPattern(window.t('work_duration.x_days')); - hoursPattern = transformPattern(window.t('work_duration.x_hours')); - minutesPattern = transformPattern(window.t('work_duration.x_minutes')); + daysPattern = transformPattern(t('work_duration.x_days')); + hoursPattern = transformPattern(t('work_duration.x_hours')); + minutesPattern = transformPattern(t('work_duration.x_minutes')); days = value.match(daysPattern); hours = value.match(hoursPattern); minutes = value.match(minutesPattern); @@ -21,7 +21,7 @@ if (!value) { return value; } else { - return (days * window.sonar.properties['sonar.technicalDebt.hoursInDay'] + hours) * 60 + minutes; + return (days * window.SS.hoursInDay + hours) * 60 + minutes; } } @@ -33,18 +33,18 @@ if (!/^\d+$/.test(value)) { return value; } - days = Math.floor(value / (window.sonar.properties['sonar.technicalDebt.hoursInDay'] * 60)); - hours = Math.floor((value - days * window.sonar.properties['sonar.technicalDebt.hoursInDay'] * 60) / 60); + days = Math.floor(value / (window.SS.hoursInDay * 60)); + hours = Math.floor((value - days * window.SS.hoursInDay * 60) / 60); minutes = value % 60; result = []; if (days > 0) { - result.push(window.t('work_duration.x_days').replace('{0}', days)); + result.push(t('work_duration.x_days').replace('{0}', days)); } if (hours > 0) { - result.push(window.t('work_duration.x_hours').replace('{0}', hours)); + result.push(t('work_duration.x_hours').replace('{0}', hours)); } if (minutes > 0) { - result.push(window.t('work_duration.x_minutes').replace('{0}', minutes)); + result.push(t('work_duration.x_minutes').replace('{0}', minutes)); } return result.join(' '); } diff --git a/server/sonar-web/src/main/js/libs/recent-history.js b/server/sonar-web/src/main/js/libs/recent-history.js new file mode 100644 index 00000000000..f2c17912911 --- /dev/null +++ b/server/sonar-web/src/main/js/libs/recent-history.js @@ -0,0 +1,75 @@ +/* + * 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. + */ +window.Sonar = {}; + +window.Sonar.RecentHistory = function () { +}; + +window.Sonar.RecentHistory.prototype.getRecentHistory = function () { + var sonarHistory = localStorage.getItem('sonar_recent_history'); + if (sonarHistory == null) { + sonarHistory = []; + } else { + sonarHistory = JSON.parse(sonarHistory); + } + return sonarHistory; +}; + +window.Sonar.RecentHistory.prototype.clear = function () { + localStorage.removeItem('sonar_recent_history'); +}; + +window.Sonar.RecentHistory.prototype.add = function (resourceKey, resourceName, icon) { + var sonarHistory = this.getRecentHistory(); + + if (resourceKey !== '') { + var newEntry = {'key': resourceKey, 'name': resourceName, 'icon': icon}; + // removes the element of the array if it exists + for (var i = 0; i < sonarHistory.length; i++) { + var item = sonarHistory[i]; + if (item.key === resourceKey) { + sonarHistory.splice(i, 1); + break; + } + } + // then add it to the beginning of the array + sonarHistory.unshift(newEntry); + // and finally slice the array to keep only 10 elements + sonarHistory = sonarHistory.slice(0, 10); + + localStorage.setItem('sonar_recent_history', JSON.stringify(sonarHistory)); + } +}; + +window.Sonar.RecentHistory.prototype.populateRecentHistoryPanel = function () { + var historyLinksList = $j('#recent-history-list'); + historyLinksList.empty(); + + var recentHistory = this.getRecentHistory(); + if (recentHistory.length === 0) { + $j('#recent-history').hide(); + } else { + recentHistory.forEach(function (resource) { + historyLinksList.append('
  • ' + resource.name + '
  • '); + }); + $j('#recent-history').show(); + } +}; diff --git a/server/sonar-web/src/main/js/libs/recent-history.jsx b/server/sonar-web/src/main/js/libs/recent-history.jsx deleted file mode 100644 index 7a7bb8ef938..00000000000 --- a/server/sonar-web/src/main/js/libs/recent-history.jsx +++ /dev/null @@ -1,35 +0,0 @@ -import _ from 'underscore'; - -const MAX_ITEMS = 10; -const STORAGE_KEY = 'sonar_recent_history'; - -class RecentHistory { - static getRecentHistory () { - let sonarHistory = localStorage.getItem(STORAGE_KEY); - if (sonarHistory == null) { - sonarHistory = []; - } else { - sonarHistory = JSON.parse(sonarHistory); - } - return sonarHistory; - } - - static clear () { - localStorage.removeItem(STORAGE_KEY); - } - - static add (resourceKey, resourceName, icon) { - if (resourceKey !== '') { - let newEntry = { key: resourceKey, name: resourceName, icon: icon }; - - let newHistory = this.getRecentHistory() - .filter(item => item.key !== newEntry.key) - .slice(0, MAX_ITEMS - 1); - newHistory.unshift(newEntry); - - localStorage.setItem(STORAGE_KEY, JSON.stringify(newHistory)); - } - } -} - -export default RecentHistory; diff --git a/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js b/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js index f41d32302eb..b57d696ec65 100644 --- a/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js +++ b/server/sonar-web/src/main/js/libs/select2-jquery-ui-fix.js @@ -19,7 +19,7 @@ */ /* https://github.com/ivaynberg/select2/issues/1246 */ -(function($) { +;(function($) { $.ui.dialog.prototype._allowInteraction = function(e) { return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop').length; diff --git a/server/sonar-web/src/main/js/libs/third-party/backbone-super.js b/server/sonar-web/src/main/js/libs/third-party/backbone-super.js new file mode 100644 index 00000000000..9562638918e --- /dev/null +++ b/server/sonar-web/src/main/js/libs/third-party/backbone-super.js @@ -0,0 +1,111 @@ +// This is a plugin, constructed from parts of Backbone.js and John Resig's inheritance script. +// (See http://backbonejs.org, http://ejohn.org/blog/simple-javascript-inheritance/) +// No credit goes to me as I did absolutely nothing except patch these two together. +(function(root, factory) { + + // Set up Backbone appropriately for the environment. Start with AMD. + if (typeof define === 'function' && define.amd) { + define(['underscore', 'backbone'], function(_, Backbone) { + // Export global even in AMD case in case this script is loaded with + // others that may still expect a global Backbone. + factory( _, Backbone); + }); + + // Next for Node.js or CommonJS. + } else if (typeof exports !== 'undefined' && typeof require === 'function') { + var _ = require('underscore'), + Backbone = require('backbone'); + factory(_, Backbone); + + // Finally, as a browser global. + } else { + factory(root._, root.Backbone); + } + +}(this, function factory(_, Backbone) { + Backbone.Model.extend = Backbone.Collection.extend = Backbone.Router.extend = Backbone.View.extend = function(protoProps, classProps) { + var child = inherits(this, protoProps, classProps); + child.extend = this.extend; + return child; + }; + var unImplementedSuper = function(method){throw "Super does not implement this method: " + method;}; + + var fnTest = /\b_super\b/; + + var makeWrapper = function(parentProto, name, fn) { + var wrapper = function() { + var tmp = this._super; + + // Add a new ._super() method that is the same method + // but on the super-class + this._super = parentProto[name] || unImplementedSuper(name); + + // The method only need to be bound temporarily, so we + // remove it when we're done executing + var ret; + try { + ret = fn.apply(this, arguments); + } finally { + this._super = tmp; + } + return ret; + }; + + //we must move properties from old function to new + for (var prop in fn) { + wrapper[prop] = fn[prop]; + delete fn[prop]; + } + + return wrapper; + }; + + var ctor = function(){}, inherits = function(parent, protoProps, staticProps) { + var child, parentProto = parent.prototype; + + // The constructor function for the new subclass is either defined by you + // (the "constructor" property in your `extend` definition), or defaulted + // by us to simply call the parent's constructor. + if (protoProps && protoProps.hasOwnProperty('constructor')) { + child = protoProps.constructor; + } else { + child = function(){ return parent.apply(this, arguments); }; + } + + // Inherit class (static) properties from parent. + _.extend(child, parent, staticProps); + + // Set the prototype chain to inherit from `parent`, without calling + // `parent`'s constructor function. + ctor.prototype = parentProto; + child.prototype = new ctor(); + + // Add prototype properties (instance properties) to the subclass, + // if supplied. + if (protoProps) { + _.extend(child.prototype, protoProps); + + // Copy the properties over onto the new prototype + for (var name in protoProps) { + // Check if we're overwriting an existing function + if (typeof protoProps[name] == "function" && fnTest.test(protoProps[name])) { + child.prototype[name] = makeWrapper(parentProto, name, protoProps[name]); + } + } + } + + // Add static properties to the constructor function, if supplied. + if (staticProps) _.extend(child, staticProps); + + // Correctly set child's `prototype.constructor`. + child.prototype.constructor = child; + + // Set a convenience property in case the parent's prototype is needed later. + child.__super__ = parentProto; + + return child; + }; + + return inherits; +})); + diff --git a/server/sonar-web/src/main/js/libs/third-party/shim/backbone-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/backbone-shim.js new file mode 100644 index 00000000000..041e0eae3ef --- /dev/null +++ b/server/sonar-web/src/main/js/libs/third-party/shim/backbone-shim.js @@ -0,0 +1,3 @@ +define(function () { + return window.Backbone; +}); diff --git a/server/sonar-web/src/main/js/libs/shim/jquery-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/jquery-shim.js similarity index 100% rename from server/sonar-web/src/main/js/libs/shim/jquery-shim.js rename to server/sonar-web/src/main/js/libs/third-party/shim/jquery-shim.js diff --git a/server/sonar-web/src/main/js/libs/third-party/shim/marionette-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/marionette-shim.js new file mode 100644 index 00000000000..84220542147 --- /dev/null +++ b/server/sonar-web/src/main/js/libs/third-party/shim/marionette-shim.js @@ -0,0 +1,3 @@ +define(function () { + return window.Marionette; +}); diff --git a/server/sonar-web/src/main/js/libs/shim/underscore-shim.js b/server/sonar-web/src/main/js/libs/third-party/shim/underscore-shim.js similarity index 100% rename from server/sonar-web/src/main/js/libs/shim/underscore-shim.js rename to server/sonar-web/src/main/js/libs/third-party/shim/underscore-shim.js diff --git a/server/sonar-web/src/main/js/libs/translate.js b/server/sonar-web/src/main/js/libs/translate.js index 0f29009952d..6317c610bb6 100644 --- a/server/sonar-web/src/main/js/libs/translate.js +++ b/server/sonar-web/src/main/js/libs/translate.js @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -(function () { +(function() { window.suppressTranslationWarnings = false; - window.t = function () { + window.t = function() { if (!window.messages) { return window.translate.apply(this, arguments); } @@ -30,12 +30,12 @@ return window.messages[key] != null ? window.messages[key] : key; }; - window.tp = function () { + window.tp = function() { var args = Array.prototype.slice.call(arguments, 0), - key = args.shift(), - message = window.messages[key]; + key = args.shift(), + message = window.messages[key]; if (message) { - args.forEach(function (p, i) { + args.forEach(function(p, i) { message = message.replace('{' + i + '}', p); }); } @@ -43,9 +43,9 @@ }; - window.translate = function () { + window.translate = function() { var args = Array.prototype.slice.call(arguments, 0), - tokens = args.reduce(function (prev, current) { + tokens = args.reduce(function(prev, current) { return prev.concat(current.split('.')); }, []), key = tokens.join('.'), @@ -54,7 +54,7 @@ result = ''; if (found) { - result = tokens.reduce(function (prev, current) { + result = tokens.reduce(function(prev, current) { if (!current || !prev[current]) { found = false; } @@ -66,7 +66,7 @@ }; - window.requestMessages = function () { + window.requestMessages = function() { var currentLocale = window.pageLang, cachedLocale = localStorage.getItem('l10n.locale'); if (cachedLocale !== currentLocale) { @@ -85,12 +85,12 @@ data: params, dataType: 'json', statusCode: { - 304: function () { + 304: function() { window.messages = JSON.parse(localStorage.getItem('l10n.bundle')); } } - }).done(function (bundle, textStatus, jqXHR) { - if (bundle) { + }).done(function(bundle, textStatus, jqXHR) { + if(bundle !== undefined) { bundleTimestamp = new Date().toISOString(); bundleTimestamp = bundleTimestamp.substr(0, bundleTimestamp.indexOf('.')) + '+0000'; localStorage.setItem('l10n.timestamp', bundleTimestamp); diff --git a/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js b/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js index 274597a68e3..fc166404423 100644 --- a/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js +++ b/server/sonar-web/src/main/js/libs/widgets/bubble-chart.js @@ -1,3 +1,24 @@ +/* + * 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. + */ +/*global d3:false, baseUrl:false */ + window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; (function () { @@ -199,8 +220,8 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; sizeMetricValue = d.measures[widget.sizeMetric].fval; return '
    ' + - window.collapsedDirFromPath(d.longName) + '
    ' + - window.fileFromPath(d.longName) + '
    ' + '
    ' + + collapsedDirFromPath(d.longName) + '
    ' + + fileFromPath(d.longName) + '
    ' + '
    ' + xMetricName + ': ' + xMetricValue + '
    ' + yMetricName + ': ' + yMetricValue + '
    ' + sizeMetricName + ': ' + sizeMetricValue + diff --git a/server/sonar-web/src/main/js/libs/widgets/pie-chart.js b/server/sonar-web/src/main/js/libs/widgets/pie-chart.js index 60ac72290ee..a88f0941c55 100644 --- a/server/sonar-web/src/main/js/libs/widgets/pie-chart.js +++ b/server/sonar-web/src/main/js/libs/widgets/pie-chart.js @@ -1,3 +1,25 @@ +/* + * 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. + */ +/*global d3:false, baseUrl:false */ +/*jshint eqnull:true */ + window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; (function () { diff --git a/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js b/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js index cd2851ab8a2..d09f38b55bb 100644 --- a/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js +++ b/server/sonar-web/src/main/js/libs/widgets/tag-cloud.js @@ -64,7 +64,7 @@ TagCloud.prototype.tooltip = function (d) { var suffixKey = d.value === 1 ? 'issue' : 'issues', - suffix = window.t(suffixKey); + suffix = t(suffixKey); return (d.value + '\u00a0') + suffix; }; diff --git a/server/sonar-web/src/main/js/libs/widgets/timeline.js b/server/sonar-web/src/main/js/libs/widgets/timeline.js index 4fa9c0123ac..5b871e5994e 100644 --- a/server/sonar-web/src/main/js/libs/widgets/timeline.js +++ b/server/sonar-web/src/main/js/libs/widgets/timeline.js @@ -310,7 +310,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets; .attr('transform', function() { return trans(x, metricY); }); }); - if (metricY > -1) { + if (metricY > -1) { metricY += 17; } diff --git a/server/sonar-web/src/main/js/main.js b/server/sonar-web/src/main/js/main.js deleted file mode 100644 index 3ef8b64dd9d..00000000000 --- a/server/sonar-web/src/main/js/main.js +++ /dev/null @@ -1,22 +0,0 @@ -require.config({ - baseUrl: window.baseUrl + '/js', - urlArgs: 'v=' + window.sonar.version, - paths: { - 'react': 'libs/third-party/react-with-addons', - 'underscore': 'libs/shim/underscore-shim', - 'jquery': 'libs/shim/jquery-shim', - 'backbone': 'libs/third-party/backbone', - 'backbone.marionette': 'libs/third-party/backbone.marionette' - } -}); - -require([ - './apps/main/app', - './components/common/processes' -], function (App) { - new App({ - space: window.sonar.space, - componentKey: window.sonar.component, - lang: window.pageLang - }).start(); -}); diff --git a/server/sonar-web/src/main/js/widgets/issue-filter/widget.js b/server/sonar-web/src/main/js/widgets/issue-filter/widget.js index 8dac26d108f..97c72ca75a1 100644 --- a/server/sonar-web/src/main/js/widgets/issue-filter/widget.js +++ b/server/sonar-web/src/main/js/widgets/issue-filter/widget.js @@ -1,8 +1,23 @@ -define([ - 'backbone', - 'backbone.marionette', - './templates' -], function (Backbone, Marionette) { +/* + * 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 () { var $ = jQuery, FACET_LIMIT = 15, @@ -25,10 +40,10 @@ define([ r.facetMode = 'debt'; } if (r.componentKey != null) { - return window.baseUrl + '/component_issues/index?id=' + encodeURIComponent(r.componentKey) + + return baseUrl + '/component_issues/index?id=' + encodeURIComponent(r.componentKey) + '#' + getQuery(_.omit(r, 'componentKey')); } else { - return window.baseUrl + '/issues/search#' + getQuery(r); + return baseUrl + '/issues/search#' + getQuery(r); } }, byDistributionConf = { @@ -333,9 +348,7 @@ define([ }, serializeData: function () { - return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), { - displayMode: this.options.displayMode - }); + return _.extend(this._super(), { displayMode: this.options.displayMode }); } }); diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index 57c1c69abb5..9c084dea979 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -39,7 +39,12 @@ class DashboardController < ApplicationController if !@resource || !@snapshot redirect_if_bad_component() else - return redirect_to :controller => 'component', :action => 'index', :id => @resource.key + # display the layout of the parent without the sidebar, usually the directory, but display the file viewers + @hide_sidebar = true + @file = @resource + @project = @snapshot.parent.project + @metric=params[:metric] + render :action => 'no_dashboard' end end end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/account/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/account/index.html.erb index 8ad02c73316..b9e16dc489d 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/account/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/account/index.html.erb @@ -67,3 +67,11 @@
    + +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/api_documentation/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/api_documentation/index.html.erb index e69de29bb2d..52765748951 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/api_documentation/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/api_documentation/index.html.erb @@ -0,0 +1,7 @@ +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb index e69de29bb2d..804ed54db8f 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb @@ -0,0 +1,7 @@ +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/component/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/component/index.html.erb index c3b88785859..5f6a94409f2 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/component/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/component/index.html.erb @@ -1,3 +1,17 @@ - +<% content_for :extra_script do %> + +<% end %> + + + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/component_issues/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/component_issues/index.html.erb index 78ea03879fd..d3a46e6eeda 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/component_issues/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/component_issues/index.html.erb @@ -7,6 +7,9 @@ resourceName: '<%= escape_javascript @resource.name -%>', periodDate: <% if @period %>'<%= escape_javascript @snapshot.period_datetime(@period) -%>'<% else %>null<% end %> }; + require(['apps/issues/app-context'], function (App) { + App.start({ el: '#content', config: config }); + }); })(); <% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb index e69de29bb2d..1e7b45c9f6c 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb @@ -0,0 +1,7 @@ +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/custom_measures/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/custom_measures/index.html.erb index e69de29bb2d..54ba4fcdac4 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/custom_measures/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/custom_measures/index.html.erb @@ -0,0 +1,7 @@ +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb index 85a8007d216..3bb4a42d099 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/configure.html.erb @@ -1,7 +1,3 @@ - -
    <%= render :partial => 'header', :locals => {:back => true} %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/index.html.erb index ddc1cebe390..2f1ea47272e 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/index.html.erb @@ -1,9 +1,3 @@ - -
    <% if @resource -%> @@ -34,3 +28,8 @@
    + + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb index f3be959f778..23e483f5746 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/dashboard/no_dashboard.html.erb @@ -7,6 +7,13 @@ (function () { jQuery('.navbar-context').remove(); jQuery('.page-wrapper-context').addClass('page-wrapper-global').removeClass('page-wrapper-context'); + var file = { + uuid: '<%= @resource.uuid -%>', + key: '<%= @resource.key -%>' + }; + require(['apps/source-viewer/app'], function (App) { + App.start({ el: '#source-viewer', file: file }) + }); })(); <% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb index de10bb9a347..f5386bde638 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb @@ -132,3 +132,11 @@ <%= render :partial => 'footer' -%>
    + +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/groups/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/groups/index.html.erb index 8b137891791..ecf82ae97bb 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/groups/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/groups/index.html.erb @@ -1 +1,7 @@ - +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/issues/search.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/issues/search.html.erb index e69de29bb2d..0c105bbd322 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/issues/search.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/issues/search.html.erb @@ -0,0 +1,7 @@ +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb index 49289197059..16110d5399b 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb @@ -1,25 +1,6 @@ -<% - selected_section = nil - selected_section = controller.class::SECTION if defined?(controller.class::SECTION) - if selected_section == Navigation::SECTION_RESOURCE && !@project && !@resource - selected_section = Navigation::SECTION_HOME - end - component = @project - component = @resource unless @project || selected_section == Navigation::SECTION_HOME - - space = 'global' - if selected_section == Navigation::SECTION_RESOURCE - space = 'component' - elsif selected_section == Navigation::SECTION_CONFIGURATION - space = 'settings' - end -%> - - - - + + @@ -41,44 +22,39 @@ <%= yield :style -%> - - - - - <%= yield :script -%> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar.html.erb new file mode 100644 index 00000000000..dd25b284589 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar.html.erb @@ -0,0 +1,29 @@ +<%= render 'layouts/recent_history' -%> + +<% + selected_section = controller.class::SECTION if defined?(controller.class::SECTION) + if selected_section == Navigation::SECTION_RESOURCE && !@project && !@resource + selected_section = Navigation::SECTION_HOME + end + + @project = @resource unless @project || selected_section == Navigation::SECTION_HOME +%> + + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb index 2564fa8ee0c..e1cb44b4475 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_nolayout.html.erb @@ -1,19 +1,17 @@
    -
    - <% if @snapshot %> -

    <%= h @snapshot.project.name(true) %>

    - <% end %> - diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_recent_history.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_recent_history.html.erb new file mode 100644 index 00000000000..51b81a44d3f --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_recent_history.html.erb @@ -0,0 +1,9 @@ + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/application.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/application.html.erb index 142dc764cac..be9af4a1526 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/application.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/application.html.erb @@ -14,5 +14,6 @@ <%= render :partial => 'layouts/nolayout' %> <% else %> <%= render :partial => 'layouts/layout' %> + <%= render :partial => 'layouts/navbar' %> <% end %> <%= render :partial => 'layouts/footer' unless params[:hd]=='false' %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb index e69de29bb2d..19d88d4c4f6 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/maintenance/index.html.erb @@ -0,0 +1,8 @@ +<% content_for :extra_script do %> + +<% end %> + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb index e69de29bb2d..662ff4366d1 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/markdown/help.html.erb @@ -0,0 +1,6 @@ +
    + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb index 2f62510e72f..f731ded1dc9 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb @@ -124,4 +124,10 @@ { key: 'nameSearch', value: '<%= escape_javascript @filter.criteria['nameSearch'] -%>' } ]; + + <% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb index e69de29bb2d..a4c68b18805 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/metrics/index.html.erb @@ -0,0 +1,7 @@ +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb index c811c602121..f95b57d8e3e 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/overview/index.html.erb @@ -169,12 +169,9 @@ <% end %> }; - window.overview = { - component: component, - gate: gate, - measures: measures, - leak: leak - }; + require(['apps/overview/app'], function (App) { + App.start({ el: '#content', component: component, gate: gate, measures: measures, leak: leak }); + }); })(); <% end %> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb index b4da7d0730f..965847fcb40 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb @@ -1,3 +1,7 @@ +<% content_for :script do %> + +<% end %> +