aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/.eslintrc4
-rw-r--r--server/sonar-web/package.json8
-rw-r--r--server/sonar-web/src/main/js/api/permissions.js30
-rw-r--r--server/sonar-web/src/main/js/apps/account/components/Nav.js4
-rw-r--r--server/sonar-web/src/main/js/apps/account/components/Notifications.js2
-rw-r--r--server/sonar-web/src/main/js/apps/account/issues-app.js85
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/action-view.js23
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/actions-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/app.js90
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/controller.js40
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/filters-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/item-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/layout.js10
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/list-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/list.js18
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/router.js4
-rw-r--r--server/sonar-web/src/main/js/apps/api-documentation/search-view.js10
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Code.js1
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/Component.js1
-rw-r--r--server/sonar-web/src/main/js/apps/code/components/ComponentName.js14
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/app.js80
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js52
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/bulk-change-popup-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js14
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/controller.js74
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js20
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js14
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js32
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js10
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js30
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js28
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js6
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js18
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js56
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js16
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js24
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js4
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js12
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js8
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js10
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/filters-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/layout.js16
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/models/rule.js20
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/models/rules.js18
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js64
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule-filter-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js94
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js38
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js80
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js16
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js30
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js24
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js64
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js36
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/workspace-header-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/workspace-list-empty-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js46
-rw-r--r--server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/component-issues/app.js90
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/app.js60
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/create-view.js16
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js6
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js24
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/delete-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/form-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/header-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/list-footer-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/list-item-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/custom-measures/update-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/dashboard/app.js68
-rw-r--r--server/sonar-web/src/main/js/apps/drilldown/app.js38
-rw-r--r--server/sonar-web/src/main/js/apps/global-permissions/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/global-permissions/groups-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/global-permissions/main.js2
-rw-r--r--server/sonar-web/src/main/js/apps/global-permissions/permission.js4
-rw-r--r--server/sonar-web/src/main/js/apps/global-permissions/users-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/groups/app.js46
-rw-r--r--server/sonar-web/src/main/js/apps/groups/create-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/groups/delete-view.js10
-rw-r--r--server/sonar-web/src/main/js/apps/groups/form-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/groups/group.js8
-rw-r--r--server/sonar-web/src/main/js/apps/groups/groups.js18
-rw-r--r--server/sonar-web/src/main/js/apps/groups/header-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/groups/list-footer-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/groups/list-item-view.js16
-rw-r--r--server/sonar-web/src/main/js/apps/groups/list-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/groups/search-view.js16
-rw-r--r--server/sonar-web/src/main/js/apps/groups/update-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/groups/users-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/issues/app.js76
-rw-r--r--server/sonar-web/src/main/js/apps/issues/component-viewer/issue-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/component-viewer/main.js92
-rw-r--r--server/sonar-web/src/main/js/apps/issues/controller.js86
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/action-plan-facet.js28
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js48
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/author-facet.js14
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/base-facet.js6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/context-facet.js2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js55
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/custom-values-facet.js30
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/file-facet.js18
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/issue-key-facet.js6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/language-facet.js28
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/mode-facet.js6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/module-facet.js14
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/project-facet.js38
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js21
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js18
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js41
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/status-facet.js4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js26
-rw-r--r--server/sonar-web/src/main/js/apps/issues/filters-view.js46
-rw-r--r--server/sonar-web/src/main/js/apps/issues/issue-filter-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/issues/layout.js18
-rw-r--r--server/sonar-web/src/main/js/apps/issues/models/filter.js4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/models/filters.js4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/models/issue.js4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/models/issues.js38
-rw-r--r--server/sonar-web/src/main/js/apps/issues/models/state.js6
-rw-r--r--server/sonar-web/src/main/js/apps/issues/router.js10
-rw-r--r--server/sonar-web/src/main/js/apps/issues/workspace-header-view.js68
-rw-r--r--server/sonar-web/src/main/js/apps/issues/workspace-list-empty-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js55
-rw-r--r--server/sonar-web/src/main/js/apps/issues/workspace-list-view.js52
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/app.js6
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/main-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/markdown/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/measures/app.js275
-rw-r--r--server/sonar-web/src/main/js/apps/measures/measures-filter-bar.js2
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/app.js58
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/create-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/delete-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/form-view.js32
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/header-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/list-footer-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/list-item-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/list-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/metric.js6
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/metrics.js18
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/update-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/overview/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/complexity-distribution.js4
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/domain-timeline.js2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/issue-measure.js2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js2
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/debt.js4
-rw-r--r--server/sonar-web/src/main/js/apps/overview/main/main.js6
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/create-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/delete-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/form-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/groups-view.js10
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/main.js4
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/permission-template.js4
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/update-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/permission-templates/users-view.js14
-rw-r--r--server/sonar-web/src/main/js/apps/project-permissions/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/project-permissions/apply-template-view.js14
-rw-r--r--server/sonar-web/src/main/js/apps/project-permissions/groups-view.js10
-rw-r--r--server/sonar-web/src/main/js/apps/project-permissions/main.js12
-rw-r--r--server/sonar-web/src/main/js/apps/project-permissions/project.js4
-rw-r--r--server/sonar-web/src/main/js/apps/project-permissions/search.js2
-rw-r--r--server/sonar-web/src/main/js/apps/project-permissions/users-view.js14
-rw-r--r--server/sonar-web/src/main/js/apps/projects/create-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/projects/delete-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/projects/form-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/projects/main.js8
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/actions-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/app.js6
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/condition.js12
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/controller.js24
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/copy-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/create-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/delete-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/details-view.js26
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/form-view.js26
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gate-condition-view.js26
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-delete-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-empty-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gate-projects-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gate-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gate.js22
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gates-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/gates.js10
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/header-view.js10
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/layout.js10
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/rename-view.js16
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/router.js6
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/actions-view.js34
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/app.js76
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/change-profile-parent-view.js36
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/controller.js54
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js24
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/create-profile-view.js24
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/delete-profile-view.js12
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/layout.js12
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profile-changelog-view.js10
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profile-comparison-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profile-details-view.js56
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profile-header-view.js22
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profile-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profile.js82
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profiles-view.js22
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/profiles.js6
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/rename-profile-view.js22
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/restore-built-in-profiles-view.js20
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/restore-profile-view.js10
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/router.js14
-rw-r--r--server/sonar-web/src/main/js/apps/source-viewer/app.js30
-rw-r--r--server/sonar-web/src/main/js/apps/system/app.js2
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/app.js70
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/controller.js10
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/footer-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/list-item-view.js38
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/plugin-changelog-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/plugin.js32
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/plugins.js112
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/router.js12
-rw-r--r--server/sonar-web/src/main/js/apps/update-center/search-view.js32
-rw-r--r--server/sonar-web/src/main/js/apps/users/app.js46
-rw-r--r--server/sonar-web/src/main/js/apps/users/change-password-view.js14
-rw-r--r--server/sonar-web/src/main/js/apps/users/create-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/users/deactivate-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/users/form-view.js18
-rw-r--r--server/sonar-web/src/main/js/apps/users/groups-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/users/header-view.js8
-rw-r--r--server/sonar-web/src/main/js/apps/users/list-footer-view.js6
-rw-r--r--server/sonar-web/src/main/js/apps/users/list-item-view.js44
-rw-r--r--server/sonar-web/src/main/js/apps/users/list-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/users/search-view.js16
-rw-r--r--server/sonar-web/src/main/js/apps/users/tokens-view.js2
-rw-r--r--server/sonar-web/src/main/js/apps/users/update-view.js4
-rw-r--r--server/sonar-web/src/main/js/apps/users/user.js22
-rw-r--r--server/sonar-web/src/main/js/apps/users/users.js18
-rw-r--r--server/sonar-web/src/main/js/components/SelectList/index.js163
-rw-r--r--server/sonar-web/src/main/js/components/charts/bar-chart.js17
-rw-r--r--server/sonar-web/src/main/js/components/charts/bubble-chart.js16
-rw-r--r--server/sonar-web/src/main/js/components/charts/treemap.js34
-rw-r--r--server/sonar-web/src/main/js/components/common/action-options-view.js32
-rw-r--r--server/sonar-web/src/main/js/components/common/file-upload.js16
-rw-r--r--server/sonar-web/src/main/js/components/common/modal-form.js26
-rw-r--r--server/sonar-web/src/main/js/components/common/modals.js24
-rw-r--r--server/sonar-web/src/main/js/components/common/popup.js8
-rw-r--r--server/sonar-web/src/main/js/components/common/selectable-collection-view.js28
-rw-r--r--server/sonar-web/src/main/js/components/issue/collections/action-plans.js4
-rw-r--r--server/sonar-web/src/main/js/components/issue/collections/issues.js26
-rw-r--r--server/sonar-web/src/main/js/components/issue/issue-view.js86
-rw-r--r--server/sonar-web/src/main/js/components/issue/manual-issue-view.js22
-rw-r--r--server/sonar-web/src/main/js/components/issue/models/changelog.js4
-rw-r--r--server/sonar-web/src/main/js/components/issue/models/issue.js100
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/assign-form-view.js50
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/changelog-view.js2
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/comment-form-view.js36
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/issue-popup.js10
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/more-actions-view.js6
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/plan-form-view.js16
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/set-severity-form-view.js12
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/tags-form-view.js66
-rw-r--r--server/sonar-web/src/main/js/components/issue/views/transitions-form-view.js8
-rw-r--r--server/sonar-web/src/main/js/components/navigator/controller.js62
-rw-r--r--server/sonar-web/src/main/js/components/navigator/facets-view.js20
-rw-r--r--server/sonar-web/src/main/js/components/navigator/facets/base-facet.js40
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/ajax-select-filters.js194
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/base-filters.js79
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/checkbox-filters.js14
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/choice-filters.js148
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/favorite-filters.js40
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/filter-bar.js52
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js108
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/more-criteria-filters.js48
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/range-filters.js92
-rw-r--r--server/sonar-web/src/main/js/components/navigator/filters/string-filters.js22
-rw-r--r--server/sonar-web/src/main/js/components/navigator/models/facet.js6
-rw-r--r--server/sonar-web/src/main/js/components/navigator/models/state.js26
-rw-r--r--server/sonar-web/src/main/js/components/navigator/router.js8
-rw-r--r--server/sonar-web/src/main/js/components/navigator/workspace-header-view.js30
-rw-r--r--server/sonar-web/src/main/js/components/navigator/workspace-list-item-view.js10
-rw-r--r--server/sonar-web/src/main/js/components/navigator/workspace-list-view.js48
-rw-r--r--server/sonar-web/src/main/js/components/select-list/controls.js (renamed from server/sonar-web/src/main/js/components/select-list/controls.jsx)26
-rw-r--r--server/sonar-web/src/main/js/components/select-list/footer.js50
-rw-r--r--server/sonar-web/src/main/js/components/select-list/footer.jsx31
-rw-r--r--server/sonar-web/src/main/js/components/select-list/item.js (renamed from server/sonar-web/src/main/js/components/select-list/item.jsx)19
-rw-r--r--server/sonar-web/src/main/js/components/select-list/list.js41
-rw-r--r--server/sonar-web/src/main/js/components/select-list/list.jsx22
-rw-r--r--server/sonar-web/src/main/js/components/select-list/main.js (renamed from server/sonar-web/src/main/js/components/select-list/main.jsx)23
-rw-r--r--server/sonar-web/src/main/js/components/shared/favorite.js2
-rw-r--r--server/sonar-web/src/main/js/components/shared/pin-icon.js1
-rw-r--r--server/sonar-web/src/main/js/components/shared/qualifier-icon.js2
-rw-r--r--server/sonar-web/src/main/js/components/shared/radio-toggle.js2
-rw-r--r--server/sonar-web/src/main/js/components/shared/severity-icon.js2
-rw-r--r--server/sonar-web/src/main/js/components/shared/status-helper.js4
-rw-r--r--server/sonar-web/src/main/js/components/shared/status-icon.js2
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/header.js28
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js24
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/main.js454
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js178
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/more-actions.js22
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/popups/coverage-popup.js36
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js36
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/popups/line-actions-popup.js24
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/popups/scm-popup.js4
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/source.js40
-rw-r--r--server/sonar-web/src/main/js/components/widgets/barchart.js67
-rw-r--r--server/sonar-web/src/main/js/components/workspace/main.js70
-rw-r--r--server/sonar-web/src/main/js/components/workspace/models/item.js8
-rw-r--r--server/sonar-web/src/main/js/components/workspace/models/items.js24
-rw-r--r--server/sonar-web/src/main/js/components/workspace/views/base-viewer-view.js10
-rw-r--r--server/sonar-web/src/main/js/components/workspace/views/item-view.js8
-rw-r--r--server/sonar-web/src/main/js/components/workspace/views/items-view.js2
-rw-r--r--server/sonar-web/src/main/js/components/workspace/views/rule-view.js6
-rw-r--r--server/sonar-web/src/main/js/components/workspace/views/viewer-header-view.js34
-rw-r--r--server/sonar-web/src/main/js/components/workspace/views/viewer-view.js10
-rw-r--r--server/sonar-web/src/main/js/helpers/csv.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/all.js10
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/any.js10
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js8
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/changelog.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js8
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/default.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js6
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/eachEven.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/empty.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/ifCanUseFilter.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/ifHasExtraActions.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/ifLength.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js10
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js6
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js6
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js10
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js6
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/joinEach.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/limitString.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/link.js3
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/log.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/numberShort.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/operators.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/pluginActions.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/recursive.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/repeat.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/show.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/sources.js4
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/sum.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/t.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/tp.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js2
-rw-r--r--server/sonar-web/src/main/js/helpers/l10n.js5
-rw-r--r--server/sonar-web/src/main/js/helpers/latinize.js10
-rw-r--r--server/sonar-web/src/main/js/helpers/measures.js42
-rw-r--r--server/sonar-web/src/main/js/helpers/path.js28
-rw-r--r--server/sonar-web/src/main/js/helpers/request.js2
-rw-r--r--server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js6
-rw-r--r--server/sonar-web/src/main/js/main/nav/component/recent-history.js8
-rw-r--r--server/sonar-web/src/main/js/main/nav/dashboard-name-mixin.js4
-rw-r--r--server/sonar-web/src/main/js/main/nav/global/global-nav-branding.js2
-rw-r--r--server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js48
-rw-r--r--server/sonar-web/src/main/js/main/nav/global/global-nav-user.js4
-rw-r--r--server/sonar-web/src/main/js/main/nav/global/search-view.js192
-rw-r--r--server/sonar-web/src/main/js/main/processes.js180
-rw-r--r--server/sonar-web/src/main/js/widgets/issue-filter/widget.js388
-rw-r--r--server/sonar-web/src/main/js/widgets/old/base.js12
-rw-r--r--server/sonar-web/src/main/js/widgets/old/bubble-chart.js127
-rw-r--r--server/sonar-web/src/main/js/widgets/old/histogram.js26
-rw-r--r--server/sonar-web/src/main/js/widgets/old/pie-chart.js192
-rw-r--r--server/sonar-web/src/main/js/widgets/old/stack-area.js112
-rw-r--r--server/sonar-web/src/main/js/widgets/old/tag-cloud.js18
-rw-r--r--server/sonar-web/src/main/js/widgets/old/timeline.js106
-rw-r--r--server/sonar-web/src/main/js/widgets/old/treemap.js80
-rw-r--r--server/sonar-web/src/main/js/widgets/old/widget.js2
-rw-r--r--server/sonar-web/src/main/js/widgets/old/word-cloud.js16
394 files changed, 5102 insertions, 5027 deletions
diff --git a/server/sonar-web/.eslintrc b/server/sonar-web/.eslintrc
index 439fd299c4c..5c514e752ed 100644
--- a/server/sonar-web/.eslintrc
+++ b/server/sonar-web/.eslintrc
@@ -47,11 +47,13 @@
"no-trailing-spaces": 1,
"no-unneeded-ternary": 1,
"object-curly-spacing": [1, "always"],
+ "no-var": 2,
+ "object-shorthand": 2,
"one-var": [1, { "let": "never", "const": "never" }],
"quotes": [1, "single", "avoid-escape"],
"prefer-const": 0,
"semi": [1, "always"],
- "space-after-keywords": [1, "always"],
+ "keyword-spacing": 1,
"react/jsx-closing-bracket-location": [1, "after-props"],
"react/jsx-handler-names": 0,
diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json
index 15abbaa30f1..662070ef3f0 100644
--- a/server/sonar-web/package.json
+++ b/server/sonar-web/package.json
@@ -8,7 +8,7 @@
"autoprefixer": "6.2.2",
"babel-cli": "6.3.17",
"babel-core": "6.3.17",
- "babel-eslint": "^5.0.0-beta10",
+ "babel-eslint": "5.0.0",
"babel-loader": "6.2.0",
"babel-polyfill": "6.3.14",
"babel-preset-es2015": "6.3.13",
@@ -25,10 +25,10 @@
"d3": "3.5.6",
"del": "2.0.2",
"enzyme": "1.2.0",
- "eslint": "1.10.3",
- "eslint-plugin-import": "0.11.0",
+ "eslint": "2.2.0",
+ "eslint-plugin-import": "^1.0.0-beta.0",
"eslint-plugin-mocha": "1.1.0",
- "eslint-plugin-react": "3.11.3",
+ "eslint-plugin-react": "4.0.0",
"event-stream": "3.3.1",
"expose-loader": "0.7.1",
"glob": "5.0.15",
diff --git a/server/sonar-web/src/main/js/api/permissions.js b/server/sonar-web/src/main/js/api/permissions.js
index 64b89276a34..4eed0a0deea 100644
--- a/server/sonar-web/src/main/js/api/permissions.js
+++ b/server/sonar-web/src/main/js/api/permissions.js
@@ -31,7 +31,7 @@ function typeError (method, message) {
export function getUsers (data) {
const url = '/api/permissions/users';
- return request({ type: 'GET', url: url, data: data });
+ return request({ type: 'GET', url, data });
}
@@ -44,11 +44,11 @@ export function grantToUser (permission, user, project) {
}
const url = '/api/permissions/add_user';
- const data = { permission: permission, login: user };
+ const data = { permission, login: user };
if (project) {
data.projectId = project;
}
- return request({ type: 'POST', url: url, data: data });
+ return request({ type: 'POST', url, data });
}
@@ -61,17 +61,17 @@ export function revokeFromUser (permission, user, project) {
}
const url = '/api/permissions/remove_user';
- const data = { permission: permission, login: user };
+ const data = { permission, login: user };
if (project) {
data.projectId = project;
}
- return request({ type: 'POST', url: url, data: data });
+ return request({ type: 'POST', url, data });
}
export function getGroups (data) {
const url = '/api/permissions/groups';
- return request({ type: 'GET', url: url, data: data });
+ return request({ type: 'GET', url, data });
}
@@ -84,11 +84,11 @@ export function grantToGroup (permission, group, project) {
}
const url = '/api/permissions/add_group';
- const data = { permission: permission, groupName: group };
+ const data = { permission, groupName: group };
if (project) {
data.projectId = project;
}
- return request({ type: 'POST', url: url, data: data });
+ return request({ type: 'POST', url, data });
}
@@ -101,11 +101,11 @@ export function revokeFromGroup (permission, group, project) {
}
const url = '/api/permissions/remove_group';
- const data = { permission: permission, groupName: group };
+ const data = { permission, groupName: group };
if (project) {
data.projectId = project;
}
- return request({ type: 'POST', url: url, data: data });
+ return request({ type: 'POST', url, data });
}
@@ -115,24 +115,24 @@ export function getPermissionTemplates (query) {
if (query) {
data.q = query;
}
- return request({ type: 'GET', url: url, data: data });
+ return request({ type: 'GET', url, data });
}
export function createPermissionTemplate (options) {
const url = '/api/permissions/create_template';
- return request(_.extend({ type: 'POST', url: url }, options));
+ return request(_.extend({ type: 'POST', url }, options));
}
export function updatePermissionTemplate (options) {
const url = '/api/permissions/update_template';
- return request(_.extend({ type: 'POST', url: url }, options));
+ return request(_.extend({ type: 'POST', url }, options));
}
export function deletePermissionTemplate (options) {
const url = '/api/permissions/delete_template';
- return request(_.extend({ type: 'POST', url: url }, options));
+ return request(_.extend({ type: 'POST', url }, options));
}
@@ -149,5 +149,5 @@ export function setDefaultPermissionTemplate (template, qualifier) {
export function applyTemplateToProject(options) {
const url = '/api/permissions/apply_template';
- return request(_.extend({ type: 'POST', url: url }, options));
+ return request(_.extend({ type: 'POST', url }, options));
}
diff --git a/server/sonar-web/src/main/js/apps/account/components/Nav.js b/server/sonar-web/src/main/js/apps/account/components/Nav.js
index a7c1df4a6db..de266f2b5da 100644
--- a/server/sonar-web/src/main/js/apps/account/components/Nav.js
+++ b/server/sonar-web/src/main/js/apps/account/components/Nav.js
@@ -36,8 +36,8 @@ const Nav = ({ user }) => (
</li>
<li>
<a
- className={window.location.pathname === `/account/issues` && 'active'}
- href={`/account/issues`}>
+ className={window.location.pathname === '/account/issues' && 'active'}
+ href="/account/issues">
{translate('issues.page')}
</a>
</li>
diff --git a/server/sonar-web/src/main/js/apps/account/components/Notifications.js b/server/sonar-web/src/main/js/apps/account/components/Notifications.js
index 9c24284a7d2..67fbbee5f78 100644
--- a/server/sonar-web/src/main/js/apps/account/components/Notifications.js
+++ b/server/sonar-web/src/main/js/apps/account/components/Notifications.js
@@ -31,7 +31,7 @@ export default function Notifications ({ globalNotifications, projectNotificatio
<p className="big-spacer-bottom">
{translate('notification.dispatcher.information')}
</p>
- <form id="notif_form" method="post" action={`/account/update_notifications`}>
+ <form id="notif_form" method="post" action="account/update_notifications">
<div className="columns columns-overflow-visible">
<div className="column-half">
<GlobalNotifications
diff --git a/server/sonar-web/src/main/js/apps/account/issues-app.js b/server/sonar-web/src/main/js/apps/account/issues-app.js
index 25c83b1b14e..63b166b74f5 100644
--- a/server/sonar-web/src/main/js/apps/account/issues-app.js
+++ b/server/sonar-web/src/main/js/apps/account/issues-app.js
@@ -32,61 +32,62 @@ import WorkspaceListView from '../issues/workspace-list-view';
import WorkspaceHeaderView from '../issues/workspace-header-view';
import FacetsView from './../issues/facets-view';
-var App = new Marionette.Application(),
- init = function (options) {
- this.config = options.config;
- this.state = new State({
- isContext: true,
- contextQuery: { assignees: '__me__' }
- });
- this.updateContextFacets();
- this.list = new Issues();
- this.facets = new Facets();
- this.filters = new Filters();
+const App = new Marionette.Application();
- this.layout = new Layout({ app: this });
- this.layout.$el.appendTo(options.el);
- this.layout.render();
- $('#footer').addClass('search-navigator-footer');
+const init = function (options) {
+ this.config = options.config;
+ this.state = new State({
+ isContext: true,
+ contextQuery: { assignees: '__me__' }
+ });
+ this.updateContextFacets();
+ this.list = new Issues();
+ this.facets = new Facets();
+ this.filters = new Filters();
- this.controller = new Controller({ app: this });
+ this.layout = new Layout({ app: this });
+ this.layout.$el.appendTo(options.el);
+ this.layout.render();
+ $('#footer').addClass('search-navigator-footer');
- this.issuesView = new WorkspaceListView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceListRegion.show(this.issuesView);
- this.issuesView.bindScrollEvents();
+ this.controller = new Controller({ app: this });
- this.workspaceHeaderView = new WorkspaceHeaderView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
+ this.issuesView = new WorkspaceListView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceListRegion.show(this.issuesView);
+ this.issuesView.bindScrollEvents();
- this.facetsView = new FacetsView({
- app: this,
- collection: this.facets
- });
- this.layout.facetsRegion.show(this.facetsView);
+ this.workspaceHeaderView = new WorkspaceHeaderView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
- this.controller.fetchFilters().done(function () {
- key.setScope('list');
- App.router = new Router({ app: App });
- Backbone.history.start();
- });
- };
+ this.facetsView = new FacetsView({
+ app: this,
+ collection: this.facets
+ });
+ this.layout.facetsRegion.show(this.facetsView);
+
+ this.controller.fetchFilters().done(function () {
+ key.setScope('list');
+ App.router = new Router({ app: App });
+ Backbone.history.start();
+ });
+};
App.getContextQuery = function () {
return { assignees: '__me__' };
};
App.updateContextFacets = function () {
- var facets = this.state.get('facets'),
- allFacets = this.state.get('allFacets'),
- facetsFromServer = this.state.get('facetsFromServer');
+ const facets = this.state.get('facets');
+ const allFacets = this.state.get('allFacets');
+ const facetsFromServer = this.state.get('facetsFromServer');
return this.state.set({
- facets: facets,
+ facets,
allFacets: _.difference(allFacets, ['assignees']),
facetsFromServer: _.difference(facetsFromServer, ['assignees'])
});
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 99896b6d850..90969fe6e5d 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
@@ -34,38 +34,37 @@ export default Marionette.ItemView.extend({
'click .js-hide-response-example': 'onHideResponseExampleClick'
},
- initialize: function () {
+ initialize () {
this.listenTo(this.options.state, 'change', this.toggleHidden);
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-web-service', this.model.get('path'));
this.$el.attr('data-action', this.model.get('key'));
this.toggleHidden();
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onShowResponseExampleClick: function (e) {
+ onShowResponseExampleClick (e) {
e.preventDefault();
this.fetchResponse();
},
- onHideResponseExampleClick: function (e) {
+ onHideResponseExampleClick (e) {
e.preventDefault();
this.model.unset('responseExample');
},
- fetchResponse: function () {
- var that = this,
- url = '/api/webservices/response_example',
- options = { controller: this.model.get('path'), action: this.model.get('key') };
- return $.get(url, options).done(function (r) {
- that.model.set({ responseExample: r.example });
+ fetchResponse () {
+ const url = '/api/webservices/response_example';
+ const options = { controller: this.model.get('path'), action: this.model.get('key') };
+ return $.get(url, options).done(r => {
+ this.model.set({ responseExample: r.example });
});
},
- toggleHidden: function () {
- var test = this.model.get('path') + '/' + this.model.get('key');
+ toggleHidden () {
+ const test = this.model.get('path') + '/' + this.model.get('key');
this.$el.toggleClass('hidden', !this.options.state.match(test, this.model.get('internal')));
}
});
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 94da383082b..c403aed7d6b 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
@@ -24,34 +24,34 @@ import ActionView from './action-view';
export default Marionette.CollectionView.extend({
childView: ActionView,
- childViewOptions: function () {
+ childViewOptions () {
return {
state: this.options.state
};
},
- scrollToTop: function () {
- var parent = this.$el.scrollParent();
+ scrollToTop () {
+ let parent = this.$el.scrollParent();
if (parent.is(document)) {
parent = $(window);
}
parent.scrollTop(0);
},
- scrollToAction: function (action) {
- var model = this.collection.findWhere({ key: action });
+ scrollToAction (action) {
+ const model = this.collection.findWhere({ key: action });
if (model != null) {
- var view = this.children.findByModel(model);
+ const view = this.children.findByModel(model);
if (view != null) {
this.scrollToView(view);
}
}
},
- scrollToView: function (view) {
- var elOffset = view.el.getBoundingClientRect();
+ scrollToView (view) {
+ const elOffset = view.el.getBoundingClientRect();
if (elOffset != null) {
- var scrollTop = elOffset.top - 70;
+ const scrollTop = elOffset.top - 70;
window.scrollTo(0, scrollTop);
}
}
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 4dc46db651c..e2b8574675d 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
@@ -28,59 +28,59 @@ import ListView from './list-view';
import FiltersView from './filters-view';
import SearchView from './search-view';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- // State
- this.state = new Backbone.Model({ internal: false });
- this.state.match = function (test, internal) {
- var pattern = new RegExp(this.get('query'), 'i');
- var internalCheck = !this.get('internal') && internal;
- return test.search(pattern) !== -1 && !internalCheck;
- };
+ // State
+ this.state = new Backbone.Model({ internal: false });
+ this.state.match = function (test, internal) {
+ const pattern = new RegExp(this.get('query'), 'i');
+ const internalCheck = !this.get('internal') && internal;
+ return test.search(pattern) !== -1 && !internalCheck;
+ };
- // Layout
- this.layout = new Layout({ el: options.el });
- this.layout.render();
- $('#footer').addClass('search-navigator-footer');
+ // Layout
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
+ $('#footer').addClass('search-navigator-footer');
- // Web Services List
- this.list = new List();
+ // Web Services List
+ this.list = new List();
- // Controller
- this.controller = new Controller({
- app: this,
- state: this.state
- });
+ // Controller
+ this.controller = new Controller({
+ app: this,
+ state: this.state
+ });
- // List View
- this.listView = new ListView({
- collection: this.list,
- state: this.state
- });
- this.layout.resultsRegion.show(this.listView);
+ // List View
+ this.listView = new ListView({
+ collection: this.list,
+ state: this.state
+ });
+ this.layout.resultsRegion.show(this.listView);
- // Filters View
- this.filtersView = new FiltersView({
- collection: this.list,
- state: this.state
- });
- this.layout.actionsRegion.show(this.filtersView);
+ // Filters View
+ this.filtersView = new FiltersView({
+ collection: this.list,
+ state: this.state
+ });
+ this.layout.actionsRegion.show(this.filtersView);
- // Search View
- this.searchView = new SearchView({
- state: this.state
- });
- this.layout.searchRegion.show(this.searchView);
+ // Search View
+ this.searchView = new SearchView({
+ state: this.state
+ });
+ this.layout.searchRegion.show(this.searchView);
- // Router
- this.router = new Router({ app: this });
- Backbone.history.start({
- pushState: true,
- root: options.urlRoot
- });
- };
+ // Router
+ this.router = new Router({ app: this });
+ Backbone.history.start({
+ pushState: true,
+ root: options.urlRoot
+ });
+};
App.on('start', function (options) {
init.call(App, options);
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 907394b8e85..db088e1d86a 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
@@ -24,16 +24,16 @@ import ActionsView from './actions-view';
import HeaderView from './header-view';
export default Marionette.Controller.extend({
- initialize: function (options) {
+ initialize (options) {
this.list = options.app.list;
this.listenTo(this.list, 'select', this.onItemSelect);
},
- show: function (path) {
- var that = this;
+ show (path) {
+ const that = this;
this.fetchList().done(function () {
if (path) {
- var item = that.list.findWhere({ path: path });
+ const item = that.list.findWhere({ path });
if (item != null) {
that.showWebService(path);
} else {
@@ -43,26 +43,26 @@ export default Marionette.Controller.extend({
});
},
- showWebService: function (path) {
- var item = this.list.findWhere({ path: path });
+ showWebService (path) {
+ const item = this.list.findWhere({ path });
if (item != null) {
item.trigger('select', item);
}
},
- showAction: function (path) {
- var webService = this.list.find(function (item) {
+ showAction (path) {
+ const webService = this.list.find(function (item) {
return path.indexOf(item.get('path')) === 0;
});
if (webService != null) {
- var action = path.substr(webService.get('path').length + 1);
- webService.trigger('select', webService, { trigger: false, action: action });
+ const action = path.substr(webService.get('path').length + 1);
+ webService.trigger('select', webService, { trigger: false, action });
}
},
- onItemSelect: function (item, options) {
- var path = item.get('path'),
- opts = _.defaults(options || {}, { trigger: true });
+ onItemSelect (item, options) {
+ const path = item.get('path');
+ const opts = _.defaults(options || {}, { trigger: true });
if (opts.trigger) {
this.options.app.router.navigate(path);
}
@@ -72,16 +72,16 @@ export default Marionette.Controller.extend({
this.options.state.set({ internal: true });
}
- var actions = new Backbone.Collection(item.get('actions')),
- actionsView = new ActionsView({
- collection: actions,
- state: this.options.state
- });
+ const actions = new Backbone.Collection(item.get('actions'));
+ const actionsView = new ActionsView({
+ collection: actions,
+ state: this.options.state
+ });
this.options.app.layout.detailsRegion.show(actionsView);
this.options.app.layout.headerRegion.show(new HeaderView({ model: item }));
if (opts.action != null) {
- var model = actions.findWhere({ key: opts.action });
+ const model = actions.findWhere({ key: opts.action });
if (model) {
if (model.get('internal')) {
this.options.state.set({ internal: true });
@@ -93,7 +93,7 @@ export default Marionette.Controller.extend({
}
},
- fetchList: function () {
+ fetchList () {
return this.list.fetch({ data: { 'include_internals': true } });
}
});
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 f4a9d1f4f87..5e835c3b462 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
@@ -28,15 +28,15 @@ export default Marionette.ItemView.extend({
'change .js-toggle-internal': 'toggleInternal'
},
- initialize: function () {
+ initialize () {
this.listenTo(this.options.state, 'change:internal', this.render);
},
- toggleInternal: function () {
+ toggleInternal () {
this.options.state.set({ internal: !this.options.state.get('internal') });
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
state: this.options.state.toJSON()
});
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 c995c3e296c..2c6e4f121af 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
@@ -34,37 +34,37 @@ export default Marionette.ItemView.extend({
'click': 'onClick'
},
- initialize: function () {
+ initialize () {
this.listenTo(this.options.state, 'change:query', this.toggleHidden);
this.listenTo(this.options.state, 'change:internal', this.toggleHidden);
},
- shouldBeHidden: function () {
- var that = this;
- var match = this.options.state.match(this.model.get('path')) ||
+ shouldBeHidden () {
+ const that = this;
+ const match = this.options.state.match(this.model.get('path')) ||
_.some(this.model.get('actions'), function (action) {
- var test = action.path + '/' + action.key;
+ const test = action.path + '/' + action.key;
return that.options.state.match(test, action.internal);
});
- var showInternal = this.options.state.get('internal'),
- hideMe = this.model.get('internal') && !showInternal;
+ const showInternal = this.options.state.get('internal');
+ const hideMe = this.model.get('internal') && !showInternal;
return !match || hideMe;
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-path', this.model.get('path'));
this.$el.toggleClass('active', this.options.highlighted);
this.toggleHidden();
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'right' });
},
- onClick: function (e) {
+ onClick (e) {
e.preventDefault();
this.model.trigger('select', this.model);
},
- toggleHidden: function () {
+ toggleHidden () {
this.$el.toggleClass('hidden', this.shouldBeHidden());
}
});
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 ec377aa0adc..51d449a989d 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
@@ -31,11 +31,11 @@ export default Marionette.LayoutView.extend({
detailsRegion: '.search-navigator-workspace-details'
},
- onRender: function () {
- var navigator = this.$('.search-navigator');
+ onRender () {
+ const navigator = this.$('.search-navigator');
navigator.addClass('sticky search-navigator-extended-view');
- var top = navigator.offset().top;
- this.$('.search-navigator-workspace-header').css({ top: top });
- this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+ const top = navigator.offset().top;
+ this.$('.search-navigator-workspace-header').css({ top });
+ this.$('.search-navigator-side').css({ top }).isolatedScroll();
}
});
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 db85ed8a40f..c6319e58236 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
@@ -24,7 +24,7 @@ export default Marionette.CollectionView.extend({
className: 'list-group',
childView: ItemView,
- childViewOptions: function (model) {
+ childViewOptions (model) {
return {
collectionView: this,
highlighted: model.get('path') === this.highlighted,
@@ -32,7 +32,7 @@ export default Marionette.CollectionView.extend({
};
},
- highlight: function (path) {
+ highlight (path) {
this.highlighted = path;
this.render();
}
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 fd9950c438d..3ecd8fda7e1 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
@@ -24,17 +24,17 @@ export default Backbone.Collection.extend({
url: '/api/webservices/list',
comparator: 'path',
- parse: function (r) {
+ parse (r) {
return r.webServices.map(function (webService) {
- var internal = _.every(webService.actions, function (action) {
- return action.internal;
- }),
- actions = webService.actions.map(function (action) {
- return _.extend(action, { path: webService.path });
- });
+ const internal = _.every(webService.actions, function (action) {
+ return action.internal;
+ });
+ const actions = webService.actions.map(function (action) {
+ return _.extend(action, { path: webService.path });
+ });
return _.extend(webService, {
- internal: internal,
- actions: actions
+ internal,
+ actions
});
});
}
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 76d6c4df9a8..45193995ad9 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
@@ -24,11 +24,11 @@ export default Backbone.Router.extend({
'*path': 'show'
},
- initialize: function (options) {
+ initialize (options) {
this.app = options.app;
},
- show: function (path) {
+ show (path) {
this.app.controller.show(path);
}
});
diff --git a/server/sonar-web/src/main/js/apps/api-documentation/search-view.js b/server/sonar-web/src/main/js/apps/api-documentation/search-view.js
index 3952e011a9e..b837e3f5f89 100644
--- a/server/sonar-web/src/main/js/apps/api-documentation/search-view.js
+++ b/server/sonar-web/src/main/js/apps/api-documentation/search-view.js
@@ -33,13 +33,13 @@ export default Marionette.ItemView.extend({
'search @ui.input': 'onChange'
},
- initialize: function () {
+ initialize () {
this.query = '';
this.debouncedFilter = _.debounce(this.filter, 250);
},
- onChange: function () {
- var query = this.ui.input.val();
+ onChange () {
+ const query = this.ui.input.val();
if (query === this.query) {
return;
}
@@ -47,7 +47,7 @@ export default Marionette.ItemView.extend({
this.debouncedFilter(query);
},
- filter: function (query) {
- this.options.state.set({ query: query });
+ filter (query) {
+ this.options.state.set({ query });
}
});
diff --git a/server/sonar-web/src/main/js/apps/code/components/Code.js b/server/sonar-web/src/main/js/apps/code/components/Code.js
index 2ac40715c93..78911ec1437 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Code.js
+++ b/server/sonar-web/src/main/js/apps/code/components/Code.js
@@ -26,7 +26,6 @@ import Breadcrumbs from './Breadcrumbs';
import SourceViewer from './SourceViewer';
import Search from './Search';
import { initComponent, browse } from '../actions';
-import { translate } from '../../../helpers/l10n';
class Code extends Component {
diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.js b/server/sonar-web/src/main/js/apps/code/components/Component.js
index ef1b1e561bb..5b87868019c 100644
--- a/server/sonar-web/src/main/js/apps/code/components/Component.js
+++ b/server/sonar-web/src/main/js/apps/code/components/Component.js
@@ -78,6 +78,7 @@ class Component extends React.Component {
}
}
+ /* eslint object-shorthand: 0 */
return (
<tr className={classNames({ 'selected': selected })}>
<td className="thin nowrap">
diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentName.js b/server/sonar-web/src/main/js/apps/code/components/ComponentName.js
index fff2478cfe3..0ad9d57031d 100644
--- a/server/sonar-web/src/main/js/apps/code/components/ComponentName.js
+++ b/server/sonar-web/src/main/js/apps/code/components/ComponentName.js
@@ -35,16 +35,16 @@ function getTooltip (component) {
}
function mostCommitPrefix (strings) {
- var sortedStrings = strings.slice(0).sort(),
- firstString = sortedStrings[0],
- firstStringLength = firstString.length,
- lastString = sortedStrings[sortedStrings.length - 1],
- i = 0;
+ const sortedStrings = strings.slice(0).sort();
+ const firstString = sortedStrings[0];
+ const firstStringLength = firstString.length;
+ const lastString = sortedStrings[sortedStrings.length - 1];
+ let i = 0;
while (i < firstStringLength && firstString.charAt(i) === lastString.charAt(i)) {
i++;
}
- var prefix = firstString.substr(0, i),
- lastPrefixPart = _.last(prefix.split(/[\s\\\/]/));
+ const prefix = firstString.substr(0, i);
+ const lastPrefixPart = _.last(prefix.split(/[\s\\\/]/));
return prefix.substr(0, prefix.length - lastPrefixPart.length);
}
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 c23aa61b3d6..5bca4881b0b 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
@@ -33,50 +33,50 @@ import FacetsView from './facets-view';
import FiltersView from './filters-view';
import { translate } from '../../helpers/l10n';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- this.layout = new Layout({ el: options.el });
- this.layout.render();
- $('#footer').addClass('search-navigator-footer');
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
+ $('#footer').addClass('search-navigator-footer');
- this.state = new State();
- this.list = new Rules();
- this.facets = new Facets();
+ this.state = new State();
+ this.list = new Rules();
+ this.facets = new Facets();
- this.controller = new Controller({ app: this });
+ this.controller = new Controller({ app: this });
- this.workspaceListView = new WorkspaceListView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceListRegion.show(this.workspaceListView);
- this.workspaceListView.bindScrollEvents();
+ this.workspaceListView = new WorkspaceListView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceListRegion.show(this.workspaceListView);
+ this.workspaceListView.bindScrollEvents();
- this.workspaceHeaderView = new WorkspaceHeaderView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
+ this.workspaceHeaderView = new WorkspaceHeaderView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
- this.facetsView = new FacetsView({
- app: this,
- collection: this.facets
- });
- this.layout.facetsRegion.show(this.facetsView);
+ this.facetsView = new FacetsView({
+ app: this,
+ collection: this.facets
+ });
+ this.layout.facetsRegion.show(this.facetsView);
- this.filtersView = new FiltersView({
- app: this
- });
- this.layout.filtersRegion.show(this.filtersView);
+ this.filtersView = new FiltersView({
+ app: this
+ });
+ this.layout.filtersRegion.show(this.filtersView);
- key.setScope('list');
- this.router = new Router({
- app: this
- });
- Backbone.history.start();
- };
+ key.setScope('list');
+ this.router = new Router({
+ app: this
+ });
+ Backbone.history.start();
+};
App.manualRepository = function () {
return {
@@ -88,15 +88,15 @@ App.manualRepository = function () {
App.getSubCharacteristicName = function (key) {
if (key != null) {
- var ch = _.findWhere(App.characteristics, { key: key }),
- parent = _.findWhere(App.characteristics, { key: ch.parent });
+ const ch = _.findWhere(App.characteristics, { key });
+ const parent = _.findWhere(App.characteristics, { key: ch.parent });
return [parent.name, ch.name].join(' > ');
} else {
return null;
}
};
-var appXHR = $.get('/api/rules/app').done(function (r) {
+const appXHR = $.get('/api/rules/app').done(function (r) {
App.canWrite = r.canWrite;
App.qualityProfiles = _.sortBy(r.qualityprofiles, ['name', 'lang']);
App.languages = _.extend(r.languages, {
@@ -109,7 +109,7 @@ var appXHR = $.get('/api/rules/app').done(function (r) {
App.repositories.push(App.manualRepository());
App.statuses = r.statuses;
App.characteristics = r.characteristics.map(function (item, index) {
- return _.extend(item, { index: index });
+ return _.extend(item, { index });
});
});
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 cf805e393d3..3e4ebc223d9 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
@@ -26,29 +26,29 @@ import { translateWithParameters } from '../../helpers/l10n';
export default ModalFormView.extend({
template: Template,
- ui: function () {
+ ui () {
return _.extend(ModalFormView.prototype.ui.apply(this, arguments), {
codingRulesSubmitBulkChange: '#coding-rules-submit-bulk-change'
});
},
- showSuccessMessage: function (profile, succeeded) {
- var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
- profileName = profileBase != null ? profileBase.name : profile,
- message = translateWithParameters('coding_rules.bulk_change.success',
- profileName, profileBase.language, succeeded);
+ showSuccessMessage (profile, succeeded) {
+ const profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile });
+ const profileName = profileBase != null ? profileBase.name : profile;
+ const message = translateWithParameters('coding_rules.bulk_change.success',
+ profileName, profileBase.language, succeeded);
this.ui.messagesContainer.append('<div class="alert alert-success">' + message + '</div>');
},
- showWarnMessage: function (profile, succeeded, failed) {
- var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
- profileName = profileBase != null ? profileBase.name : profile,
- message = translateWithParameters('coding_rules.bulk_change.warning',
- profileName, profileBase.language, succeeded, failed);
+ showWarnMessage (profile, succeeded, failed) {
+ const profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile });
+ const profileName = profileBase != null ? profileBase.name : profile;
+ const message = translateWithParameters('coding_rules.bulk_change.warning',
+ profileName, profileBase.language, succeeded, failed);
this.ui.messagesContainer.append('<div class="alert alert-warning">' + message + '</div>');
},
- onRender: function () {
+ onRender () {
ModalFormView.prototype.onRender.apply(this, arguments);
this.$('#coding-rules-bulk-change-profile').select2({
width: '250px',
@@ -57,20 +57,20 @@ export default ModalFormView.extend({
});
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
- var url = '/api/qualityprofiles/' + this.options.action + '_rules',
- options = _.extend({}, this.options.app.state.get('query'), { wsAction: this.options.action }),
- profiles = this.$('#coding-rules-bulk-change-profile').val() || [this.options.param];
+ const url = '/api/qualityprofiles/' + this.options.action + '_rules';
+ const options = _.extend({}, this.options.app.state.get('query'), { wsAction: this.options.action });
+ const profiles = this.$('#coding-rules-bulk-change-profile').val() || [this.options.param];
this.ui.messagesContainer.empty();
this.sendRequests(url, options, profiles);
},
- sendRequests: function (url, options, profiles) {
- var that = this,
- looper = $.Deferred().resolve();
+ sendRequests (url, options, profiles) {
+ const that = this;
+ let looper = $.Deferred().resolve();
profiles.forEach(function (profile) {
- var opts = _.extend({}, options, { profile_key: profile });
+ const opts = _.extend({}, options, { profile_key: profile });
looper = looper.then(function () {
return $.post(url, opts).done(function (r) {
if (r.failed) {
@@ -89,10 +89,10 @@ export default ModalFormView.extend({
});
},
- getAvailableQualityProfiles: function () {
- var queryLanguages = this.options.app.state.get('query').languages,
- languages = queryLanguages && queryLanguages.length > 0 ? queryLanguages.split(',') : [],
- profiles = this.options.app.qualityProfiles;
+ getAvailableQualityProfiles () {
+ const queryLanguages = this.options.app.state.get('query').languages;
+ const languages = queryLanguages && queryLanguages.length > 0 ? queryLanguages.split(',') : [];
+ let profiles = this.options.app.qualityProfiles;
if (languages.length > 0) {
profiles = _.filter(profiles, function (profile) {
return languages.indexOf(profile.lang) !== -1;
@@ -101,8 +101,8 @@ export default ModalFormView.extend({
return profiles;
},
- serializeData: function () {
- var profile = _.findWhere(this.options.app.qualityProfiles, { key: this.options.param });
+ serializeData () {
+ const profile = _.findWhere(this.options.app.qualityProfiles, { key: this.options.param });
return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
action: this.options.action,
state: this.options.app.state.toJSON(),
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-popup-view.js b/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-popup-view.js
index e00fb0199a2..62725a66911 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-popup-view.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/bulk-change-popup-view.js
@@ -30,21 +30,21 @@ export default PopupView.extend({
'click .js-bulk-change': 'doAction'
},
- doAction: function (e) {
- var action = $(e.currentTarget).data('action'),
- param = $(e.currentTarget).data('param');
+ doAction (e) {
+ const action = $(e.currentTarget).data('action');
+ const param = $(e.currentTarget).data('param');
new BulkChangeModalView({
app: this.options.app,
- action: action,
- param: param
+ action,
+ param
}).render();
},
- serializeData: function () {
- var query = this.options.app.state.get('query'),
- profileKey = query.qprofile,
- profile = _.findWhere(this.options.app.qualityProfiles, { key: profileKey }),
- activation = '' + query.activation;
+ serializeData () {
+ const query = this.options.app.state.get('query');
+ const profileKey = query.qprofile;
+ const profile = _.findWhere(this.options.app.qualityProfiles, { key: profileKey });
+ const activation = '' + query.activation;
return {
qualityProfile: profileKey,
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js b/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js
index 31388d56056..3325e156b5a 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/confirm-dialog.js
@@ -25,22 +25,22 @@ const DEFAULTS = {
html: '',
yesLabel: 'Yes',
noLabel: 'Cancel',
- yesHandler: function () {
+ yesHandler () {
// no op
},
- noHandler: function () {
+ noHandler () {
// no op
},
- always: function () {
+ always () {
// no op
}
};
export default function (options) {
- var settings = _.extend({}, DEFAULTS, options),
- dialog = $('<div><div class="modal-head"><h2>' + settings.title + '</h2></div><div class="modal-body">' +
- settings.html + '</div><div class="modal-foot"><button data-confirm="yes">' + settings.yesLabel +
- '</button> <a data-confirm="no" class="action">' + settings.noLabel + '</a></div></div>');
+ const settings = _.extend({}, DEFAULTS, options);
+ const dialog = $('<div><div class="modal-head"><h2>' + settings.title + '</h2></div><div class="modal-body">' +
+ settings.html + '</div><div class="modal-foot"><button data-confirm="yes">' + settings.yesLabel +
+ '</button> <a data-confirm="no" class="action">' + settings.noLabel + '</a></div></div>');
$('[data-confirm=yes]', dialog).on('click', function () {
dialog.dialog('close');
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/controller.js b/server/sonar-web/src/main/js/apps/coding-rules/controller.js
index 7b627f9e818..a657c3322e5 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/controller.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/controller.js
@@ -31,16 +31,16 @@ export default Controller.extend({
],
- _searchParameters: function () {
- var fields = this.ruleFields.slice(),
- profile = this.app.state.get('query').qprofile;
+ _searchParameters () {
+ const fields = this.ruleFields.slice();
+ const profile = this.app.state.get('query').qprofile;
if (profile != null) {
fields.push('actives');
fields.push('params');
fields.push('isTemplate');
fields.push('severity');
}
- var params = {
+ const params = {
p: this.app.state.get('page'),
ps: this.pageSize,
facets: this._facetsFromServer().join(),
@@ -52,7 +52,7 @@ export default Controller.extend({
return params;
},
- fetchList: function (firstPage) {
+ fetchList (firstPage) {
firstPage = firstPage == null ? true : firstPage;
if (firstPage) {
this.app.state.set({ selectedIndex: 0, page: 1 }, { silent: true });
@@ -60,11 +60,11 @@ export default Controller.extend({
this.hideDetails(firstPage);
- var that = this,
- url = '/api/rules/search',
- options = _.extend(this._searchParameters(), this.app.state.get('query'));
+ const that = this;
+ const url = '/api/rules/search';
+ const options = _.extend(this._searchParameters(), this.app.state.get('query'));
return $.get(url, options).done(function (r) {
- var rules = that.app.list.parseRules(r);
+ const rules = that.app.list.parseRules(r);
if (firstPage) {
that.app.list.reset(rules);
} else {
@@ -87,46 +87,46 @@ export default Controller.extend({
});
},
- isRulePermalink: function () {
- var query = this.app.state.get('query');
+ isRulePermalink () {
+ const query = this.app.state.get('query');
return query.rule_key != null && this.app.list.length === 1;
},
- requestFacet: function (id) {
- var url = '/api/rules/search',
- facet = this.app.facets.get(id),
- options = _.extend({ facets: id, ps: 1 }, this.app.state.get('query'));
+ requestFacet (id) {
+ const url = '/api/rules/search';
+ const facet = this.app.facets.get(id);
+ const options = _.extend({ facets: id, ps: 1 }, this.app.state.get('query'));
return $.get(url, options).done(function (r) {
- var facetData = _.findWhere(r.facets, { property: id });
+ const facetData = _.findWhere(r.facets, { property: id });
if (facetData) {
facet.set(facetData);
}
});
},
- parseQuery: function () {
- var q = Controller.prototype.parseQuery.apply(this, arguments);
+ parseQuery () {
+ const q = Controller.prototype.parseQuery.apply(this, arguments);
delete q.asc;
delete q.s;
return q;
},
- getRuleDetails: function (rule) {
- var that = this,
- url = '/api/rules/show',
- options = {
- key: rule.id,
- actives: true
- };
+ getRuleDetails (rule) {
+ const that = this;
+ const url = '/api/rules/show';
+ const options = {
+ key: rule.id,
+ actives: true
+ };
return $.get(url, options).done(function (data) {
rule.set(data.rule);
rule.addExtraAttributes(that.app.repositories);
});
},
- showDetails: function (rule) {
- var that = this,
- ruleModel = typeof rule === 'string' ? new Rule({ key: rule }) : rule;
+ showDetails (rule) {
+ const that = this;
+ const ruleModel = typeof rule === 'string' ? new Rule({ key: rule }) : rule;
this.app.layout.workspaceDetailsRegion.reset();
this.getRuleDetails(ruleModel).done(function (data) {
key.setScope('details');
@@ -142,12 +142,12 @@ export default Controller.extend({
});
},
- showDetailsForSelected: function () {
- var rule = this.app.list.at(this.app.state.get('selectedIndex'));
+ showDetailsForSelected () {
+ const rule = this.app.list.at(this.app.state.get('selectedIndex'));
this.showDetails(rule);
},
- hideDetails: function (firstPage) {
+ hideDetails (firstPage) {
key.setScope('list');
this.app.state.unset('rule');
this.app.layout.workspaceDetailsRegion.reset();
@@ -158,20 +158,20 @@ export default Controller.extend({
}
},
- activateCurrent: function () {
+ activateCurrent () {
if (this.app.layout.detailsShow()) {
this.app.workspaceDetailsView.$('#coding-rules-quality-profile-activate').click();
} else {
- var rule = this.app.list.at(this.app.state.get('selectedIndex'));
- var ruleView = this.app.workspaceListView.children.findByModel(rule);
+ const rule = this.app.list.at(this.app.state.get('selectedIndex'));
+ const ruleView = this.app.workspaceListView.children.findByModel(rule);
ruleView.$('.coding-rules-detail-quality-profile-activate').click();
}
},
- deactivateCurrent: function () {
+ deactivateCurrent () {
if (!this.app.layout.detailsShow()) {
- var rule = this.app.list.at(this.app.state.get('selectedIndex'));
- var ruleView = this.app.workspaceListView.children.findByModel(rule);
+ const rule = this.app.list.at(this.app.state.get('selectedIndex'));
+ const ruleView = this.app.workspaceListView.children.findByModel(rule);
ruleView.$('.coding-rules-detail-quality-profile-deactivate').click();
}
}
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js b/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js
index 5e289266505..19d288096db 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets-view.js
@@ -33,7 +33,7 @@ import InheritanceFacet from './facets/inheritance-facet';
import ActiveSeverityFacet from './facets/active-severity-facet';
import TemplateFacet from './facets/template-facet';
-var viewsMapping = {
+const viewsMapping = {
q: QueryFacet,
rule_key: KeyFacet,
languages: LanguageFacet,
@@ -51,8 +51,8 @@ var viewsMapping = {
export default FacetsView.extend({
- getChildView: function (model) {
- var view = viewsMapping[model.get('property')];
+ getChildView (model) {
+ const view = viewsMapping[model.get('property')];
return view ? view : BaseFacet;
}
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 200cc9c77ba..598f09c3a58 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js
@@ -26,36 +26,36 @@ export default BaseFacet.extend({
template: Template,
severities: ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'],
- initialize: function (options) {
+ initialize (options) {
this.listenTo(options.app.state, 'change:query', this.onQueryChange);
},
- onQueryChange: function () {
- var query = this.options.app.state.get('query'),
- isProfileSelected = query.qprofile != null,
- isActiveShown = '' + query.activation === 'true';
+ onQueryChange () {
+ const query = this.options.app.state.get('query');
+ const isProfileSelected = query.qprofile != null;
+ const isActiveShown = '' + query.activation === 'true';
if (!isProfileSelected || !isActiveShown) {
this.forbid();
}
},
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
this.onQueryChange();
},
- forbid: function () {
+ forbid () {
BaseFacet.prototype.forbid.apply(this, arguments);
this.$el.prop('title', translate('coding_rules.filters.active_severity.inactive'));
},
- allow: function () {
+ allow () {
BaseFacet.prototype.allow.apply(this, arguments);
this.$el.prop('title', null);
},
- sortValues: function (values) {
- var order = this.severities;
+ sortValues (values) {
+ const order = this.severities;
return _.sortBy(values, function (v) {
return order.indexOf(v.val);
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js
index 94b968b1fca..cb20c128832 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js
@@ -24,13 +24,13 @@ import Template from '../templates/facets/coding-rules-available-since-facet.hbs
export default BaseFacet.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
'change input': 'applyFacet'
});
},
- onRender: function () {
+ onRender () {
this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled'));
this.$el.attr('data-property', this.model.get('property'));
this.$('input').datepicker({
@@ -38,20 +38,20 @@ export default BaseFacet.extend({
changeMonth: true,
changeYear: true
});
- var value = this.options.app.state.get('query').available_since;
+ const value = this.options.app.state.get('query').available_since;
if (value) {
this.$('input').val(value);
}
},
- applyFacet: function () {
- var obj = {},
- property = this.model.get('property');
+ applyFacet () {
+ const obj = {};
+ const property = this.model.get('property');
obj[property] = this.$('input').val();
this.options.app.state.updateFilter(obj);
},
- getLabelsSource: function () {
+ getLabelsSource () {
return this.options.app.languages;
}
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js
index 864aea8cd90..8245e239174 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js
@@ -25,21 +25,21 @@ import Template from '../templates/facets/coding-rules-characteristic-facet.hbs'
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
- var value = this.options.app.state.get('query').has_debt_characteristic;
+ const value = this.options.app.state.get('query').has_debt_characteristic;
if (value != null && ('' + value === 'false')) {
this.$('.js-facet').filter('[data-empty-characteristic]').addClass('active');
}
},
- toggleFacet: function (e) {
- var noneCharacteristic = $(e.currentTarget).is('[data-empty-characteristic]'),
- property = this.model.get('property'),
- obj = {};
+ toggleFacet (e) {
+ const noneCharacteristic = $(e.currentTarget).is('[data-empty-characteristic]');
+ const property = this.model.get('property');
+ const obj = {};
$(e.currentTarget).toggleClass('active');
if (noneCharacteristic) {
- var checked = $(e.currentTarget).is('.active');
+ const checked = $(e.currentTarget).is('.active');
obj.has_debt_characteristic = checked ? 'false' : null;
obj[property] = null;
} else {
@@ -49,19 +49,19 @@ export default BaseFacet.extend({
this.options.app.state.updateFilter(obj);
},
- disable: function () {
- var property = this.model.get('property'),
- obj = {};
+ disable () {
+ const property = this.model.get('property');
+ const obj = {};
obj.has_debt_characteristic = null;
obj[property] = null;
this.options.app.state.updateFilter(obj);
},
- getValues: function () {
- var values = this.model.getValues(),
- characteristics = this.options.app.characteristics;
+ getValues () {
+ const values = this.model.getValues();
+ const characteristics = this.options.app.characteristics;
return values.map(function (value) {
- var ch = _.findWhere(characteristics, { key: value.val });
+ const ch = _.findWhere(characteristics, { key: value.val });
if (ch != null) {
_.extend(value, ch, { label: ch.name });
}
@@ -69,11 +69,11 @@ export default BaseFacet.extend({
});
},
- sortValues: function (values) {
+ sortValues (values) {
return _.sortBy(values, 'index');
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValues())
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js
index 47191f744cb..3cd599acaf8 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js
@@ -22,13 +22,13 @@ import BaseFacet from './base-facet';
export default BaseFacet.extend({
- getLabelsSource: function () {
+ getLabelsSource () {
return [];
},
- getValues: function () {
- var that = this,
- labels = that.getLabelsSource();
+ getValues () {
+ const that = this;
+ const labels = that.getLabelsSource();
return this.model.getValues().map(function (item) {
return _.extend(item, {
label: labels[item.val]
@@ -36,7 +36,7 @@ export default BaseFacet.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.getValues()
});
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 ef9417f855d..5902c89ee78 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
@@ -25,33 +25,33 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
export default BaseFacet.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
'change .js-custom-value': 'addCustomValue'
});
},
- getUrl: function () {
+ getUrl () {
return '';
},
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
this.prepareSearch();
},
- prepareSearch: function () {
+ prepareSearch () {
this.$('.js-custom-value').select2({
placeholder: translate('search_verb'),
minimumInputLength: 1,
allowClear: false,
- formatNoMatches: function () {
+ formatNoMatches () {
return translate('select2.noMatches');
},
- formatSearching: function () {
+ formatSearching () {
return translate('select2.searching');
},
- formatInputTooShort: function () {
+ formatInputTooShort () {
return translateWithParameters('select2.tooShort', 1);
},
width: '100%',
@@ -59,28 +59,28 @@ export default BaseFacet.extend({
});
},
- prepareAjaxSearch: function () {
+ prepareAjaxSearch () {
return {
quietMillis: 300,
url: this.getUrl(),
- data: function (term, page) {
+ data (term, page) {
return { s: term, p: page };
},
- results: function (data) {
+ results (data) {
return { more: data.more, results: data.results };
}
};
},
- addCustomValue: function () {
- var property = this.model.get('property'),
- customValue = this.$('.js-custom-value').select2('val'),
- value = this.getValue();
+ addCustomValue () {
+ const property = this.model.get('property');
+ const customValue = this.$('.js-custom-value').select2('val');
+ let value = this.getValue();
if (value.length > 0) {
value += ',';
}
value += customValue;
- var obj = {};
+ const obj = {};
obj[property] = value;
this.options.app.state.updateFilter(obj);
}
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 9df375e79de..bd7a3bba91c 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
@@ -26,15 +26,15 @@ import { translate } from '../../../helpers/l10n';
export default BaseFacet.extend({
template: Template,
- initialize: function (options) {
+ initialize (options) {
this.listenTo(options.app.state, 'change:query', this.onQueryChange);
},
- onQueryChange: function () {
- var query = this.options.app.state.get('query'),
- isProfileSelected = query.qprofile != null;
+ onQueryChange () {
+ const query = this.options.app.state.get('query');
+ const isProfileSelected = query.qprofile != null;
if (isProfileSelected) {
- var profile = _.findWhere(this.options.app.qualityProfiles, { key: query.qprofile });
+ const profile = _.findWhere(this.options.app.qualityProfiles, { key: query.qprofile });
if (profile != null && profile.parentKey == null) {
this.forbid();
}
@@ -43,23 +43,23 @@ export default BaseFacet.extend({
}
},
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
this.onQueryChange();
},
- forbid: function () {
+ forbid () {
BaseFacet.prototype.forbid.apply(this, arguments);
this.$el.prop('title', translate('coding_rules.filters.inheritance.inactive'));
},
- allow: function () {
+ allow () {
BaseFacet.prototype.allow.apply(this, arguments);
this.$el.prop('title', null);
},
- getValues: function () {
- var values = ['NONE', 'INHERITED', 'OVERRIDES'];
+ getValues () {
+ const values = ['NONE', 'INHERITED', 'OVERRIDES'];
return values.map(function (key) {
return {
label: translate('coding_rules.filters.inheritance', key.toLowerCase()),
@@ -68,9 +68,9 @@ export default BaseFacet.extend({
});
},
- toggleFacet: function (e) {
- var obj = {},
- property = this.model.get('property');
+ toggleFacet (e) {
+ const obj = {};
+ const property = this.model.get('property');
if ($(e.currentTarget).is('.active')) {
obj[property] = null;
} else {
@@ -79,7 +79,7 @@ export default BaseFacet.extend({
this.options.app.state.updateFilter(obj);
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.getValues()
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js
index 538c2b7f75f..62613aabed5 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js
@@ -24,15 +24,15 @@ import Template from '../templates/facets/coding-rules-key-facet.hbs';
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
this.$el.toggleClass('hidden', !this.options.app.state.get('query').rule_key);
},
- disable: function () {
+ disable () {
this.options.app.state.updateFilter({ rule_key: null });
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
key: this.options.app.state.get('query').rule_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 56703f8a0a6..05c268aeb09 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
@@ -22,18 +22,18 @@ import CustomValuesFacet from './custom-values-facet';
export default CustomValuesFacet.extend({
- getUrl: function () {
+ getUrl () {
return '/api/languages/list';
},
- prepareAjaxSearch: function () {
+ prepareAjaxSearch () {
return {
quietMillis: 300,
url: this.getUrl(),
- data: function (term) {
+ data (term) {
return { q: term, ps: 10000 };
},
- results: function (data) {
+ results (data) {
return {
more: false,
results: data.languages.map(function (lang) {
@@ -44,13 +44,13 @@ export default CustomValuesFacet.extend({
};
},
- getLabelsSource: function () {
+ getLabelsSource () {
return this.options.app.languages;
},
- getValues: function () {
- var that = this,
- labels = that.getLabelsSource();
+ getValues () {
+ const that = this;
+ const labels = that.getLabelsSource();
return this.model.getValues().map(function (item) {
return _.extend(item, {
label: labels[item.val]
@@ -58,7 +58,7 @@ export default CustomValuesFacet.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
values: this.getValues()
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js
index fd77e0863fa..b50c8bd7481 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js
@@ -25,35 +25,35 @@ import Template from '../templates/facets/coding-rules-quality-profile-facet.hbs
export default BaseFacet.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
'click .js-active': 'setActivation',
'click .js-inactive': 'unsetActivation'
});
},
- getValues: function () {
- var that = this,
- languagesQuery = this.options.app.state.get('query').languages,
- languages = languagesQuery != null ? languagesQuery.split(',') : [],
- lang = languages.length === 1 ? languages[0] : null,
- values = this.options.app.qualityProfiles
- .filter(function (profile) {
- return lang != null ? profile.lang === lang : true;
- })
- .map(function (profile) {
- return {
- label: profile.name,
- extra: that.options.app.languages[profile.lang],
- val: profile.key
- };
- });
+ getValues () {
+ const that = this;
+ const languagesQuery = this.options.app.state.get('query').languages;
+ const languages = languagesQuery != null ? languagesQuery.split(',') : [];
+ const lang = languages.length === 1 ? languages[0] : null;
+ const values = this.options.app.qualityProfiles
+ .filter(function (profile) {
+ return lang != null ? profile.lang === lang : true;
+ })
+ .map(function (profile) {
+ return {
+ label: profile.name,
+ extra: that.options.app.languages[profile.lang],
+ val: profile.key
+ };
+ });
return _.sortBy(values, 'label');
},
- toggleFacet: function (e) {
- var obj = {},
- property = this.model.get('property');
+ toggleFacet (e) {
+ const obj = {};
+ const property = this.model.get('property');
if ($(e.currentTarget).is('.active')) {
obj.activation = null;
obj[property] = null;
@@ -64,29 +64,29 @@ export default BaseFacet.extend({
this.options.app.state.updateFilter(obj);
},
- setActivation: function (e) {
+ setActivation (e) {
e.stopPropagation();
this.options.app.state.updateFilter({ activation: 'true' });
},
- unsetActivation: function (e) {
+ unsetActivation (e) {
e.stopPropagation();
this.options.app.state.updateFilter({ activation: 'false', active_severities: null });
},
- getToggled: function () {
- var activation = this.options.app.state.get('query').activation;
+ getToggled () {
+ const activation = this.options.app.state.get('query').activation;
return activation === 'true' || activation === true;
},
- disable: function () {
- var obj = { activation: null },
- property = this.model.get('property');
+ disable () {
+ const obj = { activation: null };
+ const property = this.model.get('property');
obj[property] = null;
this.options.app.state.updateFilter(obj);
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.getValues(),
toggled: this.getToggled()
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js
index e279c81648b..8192403a2f6 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js
@@ -24,29 +24,29 @@ import Template from '../templates/facets/coding-rules-query-facet.hbs';
export default BaseFacet.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
'submit form': 'onFormSubmit'
});
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-property', this.model.get('property'));
- var query = this.options.app.state.get('query'),
- value = query.q;
+ const query = this.options.app.state.get('query');
+ const value = query.q;
if (value != null) {
this.$('input').val(value);
}
},
- onFormSubmit: function (e) {
+ onFormSubmit (e) {
e.preventDefault();
this.applyFacet();
},
- applyFacet: function () {
- var obj = {},
- property = this.model.get('property');
+ applyFacet () {
+ const obj = {};
+ const property = this.model.get('property');
obj[property] = this.$('input').val();
this.options.app.state.updateFilter(obj, { force: true });
}
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 73d4b6ebcb2..3c5fea1b300 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
@@ -22,18 +22,18 @@ import CustomValuesFacet from './custom-values-facet';
export default CustomValuesFacet.extend({
- getUrl: function () {
+ getUrl () {
return '/api/rules/repositories';
},
- prepareAjaxSearch: function () {
+ prepareAjaxSearch () {
return {
quietMillis: 300,
url: this.getUrl(),
- data: function (term) {
+ data (term) {
return { q: term, ps: 10000 };
},
- results: function (data) {
+ results (data) {
return {
more: false,
results: data.repositories.map(function (repo) {
@@ -44,25 +44,25 @@ export default CustomValuesFacet.extend({
};
},
- getLabelsSource: function () {
- var repos = this.options.app.repositories;
+ getLabelsSource () {
+ const repos = this.options.app.repositories;
return _.object(_.pluck(repos, 'key'), _.pluck(repos, 'name'));
},
- getValues: function () {
- var that = this,
- labels = that.getLabelsSource();
+ getValues () {
+ const that = this;
+ const labels = that.getLabelsSource();
return this.model.getValues().map(function (value) {
- var repo = _.findWhere(that.options.app.repositories, { key: value.val });
+ const repo = _.findWhere(that.options.app.repositories, { key: value.val });
if (repo != null) {
- var langName = that.options.app.languages[repo.language];
+ const langName = that.options.app.languages[repo.language];
_.extend(value, { extra: langName });
}
return _.extend(value, { label: labels[value.val] });
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
values: this.getValues()
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js
index defdef17325..970722c318c 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js
@@ -25,8 +25,8 @@ export default BaseFacet.extend({
template: Template,
severities: ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'],
- sortValues: function (values) {
- var order = this.severities;
+ sortValues (values) {
+ const order = this.severities;
return _.sortBy(values, function (v) {
return order.indexOf(v.val);
});
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 544dcffbb05..eab8055cfe2 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
@@ -24,22 +24,22 @@ import { translate } from '../../../helpers/l10n';
export default BaseFacet.extend({
statuses: ['READY', 'DEPRECATED', 'BETA'],
- getValues: function () {
- var values = this.model.getValues();
- var x = values.map(function (value) {
+ getValues () {
+ const values = this.model.getValues();
+ const x = values.map(function (value) {
return _.extend(value, { label: translate('rules.status', value.val.toLowerCase()) });
});
return x;
},
- sortValues: function (values) {
- var order = this.statuses;
+ sortValues (values) {
+ const order = this.statuses;
return _.sortBy(values, function (v) {
return order.indexOf(v.val);
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValues())
});
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 91d3cb52624..210a73a9434 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
@@ -21,18 +21,18 @@ import CustomValuesFacet from './custom-values-facet';
export default CustomValuesFacet.extend({
- getUrl: function () {
+ getUrl () {
return '/api/rules/tags';
},
- prepareAjaxSearch: function () {
+ prepareAjaxSearch () {
return {
quietMillis: 300,
url: this.getUrl(),
- data: function (term) {
+ data (term) {
return { q: term, ps: 10000 };
},
- results: function (data) {
+ results (data) {
return {
more: false,
results: data.tags.map(function (tag) {
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js
index 7b06a5ca7e8..85f420c7bde 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js
@@ -24,18 +24,18 @@ import Template from '../templates/facets/coding-rules-template-facet.hbs';
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
- var value = this.options.app.state.get('query').is_template;
+ const value = this.options.app.state.get('query').is_template;
if (value != null) {
this.$('.js-facet').filter('[data-value="' + value + '"]').addClass('active');
}
},
- toggleFacet: function (e) {
+ toggleFacet (e) {
$(e.currentTarget).toggleClass('active');
- var property = this.model.get('property'),
- obj = {};
+ const property = this.model.get('property');
+ const obj = {};
if ($(e.currentTarget).hasClass('active')) {
obj[property] = '' + $(e.currentTarget).data('value');
} else {
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 8fd942bf7be..fb91769a46f 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
@@ -29,13 +29,13 @@ export default Marionette.ItemView.extend({
'click .js-create-manual-rule': 'createManualRule'
},
- createManualRule: function () {
+ createManualRule () {
new ManualRuleCreationView({
app: this.options.app
}).render();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/layout.js b/server/sonar-web/src/main/js/apps/coding-rules/layout.js
index 20a559ad713..9d40b1c5833 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
@@ -32,27 +32,27 @@ export default Marionette.LayoutView.extend({
workspaceDetailsRegion: '.search-navigator-workspace-details'
},
- onRender: function () {
- var navigator = this.$('.search-navigator');
- var top = navigator.offset().top;
- this.$('.search-navigator-workspace-header').css({ top: top });
- this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+ onRender () {
+ const navigator = this.$('.search-navigator');
+ const top = navigator.offset().top;
+ this.$('.search-navigator-workspace-header').css({ top });
+ this.$('.search-navigator-side').css({ top }).isolatedScroll();
},
- showDetails: function () {
+ showDetails () {
this.scroll = $(window).scrollTop();
this.$('.search-navigator').addClass('search-navigator-extended-view');
},
- hideDetails: function () {
+ hideDetails () {
this.$('.search-navigator').removeClass('search-navigator-extended-view');
if (this.scroll != null) {
$(window).scrollTop(this.scroll);
}
},
- detailsShow: function () {
+ detailsShow () {
return this.$('.search-navigator').is('.search-navigator-extended-view');
}
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 ed356e6ed24..8ceb2ec3dc8 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
@@ -23,21 +23,21 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
idAttribute: 'key',
- addExtraAttributes: function (repositories) {
- var repo = _.findWhere(repositories, { key: this.get('repo') }) || this.get('repo'),
- repoName = repo != null ? repo.name : repo,
- isManual = this.get('repo') === 'manual',
- isCustom = this.has('templateKey');
+ addExtraAttributes (repositories) {
+ const repo = _.findWhere(repositories, { key: this.get('repo') }) || this.get('repo');
+ const repoName = repo != null ? repo.name : repo;
+ const isManual = this.get('repo') === 'manual';
+ const isCustom = this.has('templateKey');
this.set({
- repoName: repoName,
- isManual: isManual,
- isCustom: isCustom
+ repoName,
+ isManual,
+ isCustom
}, { silent: true });
},
- getInactiveProfiles: function (actives, profiles) {
+ getInactiveProfiles (actives, profiles) {
return actives.map(function (profile) {
- var profileBase = _.findWhere(profiles, { key: profile.qProfile });
+ const profileBase = _.findWhere(profiles, { key: profile.qProfile });
if (profileBase != null) {
_.extend(profile, profileBase);
}
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 b68a377f575..57906ae9c7f 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
@@ -24,16 +24,16 @@ import Rule from './rule';
export default Backbone.Collection.extend({
model: Rule,
- parseRules: function (r) {
- var rules = r.rules,
- profiles = r.qProfiles || [];
+ parseRules (r) {
+ let rules = r.rules;
+ const profiles = r.qProfiles || [];
if (r.actives != null) {
rules = rules.map(function (rule) {
- var activations = (r.actives[rule.key] || []).map(function (activation) {
- var profile = profiles[activation.qProfile];
+ const activations = (r.actives[rule.key] || []).map(function (activation) {
+ const profile = profiles[activation.qProfile];
if (profile != null) {
- _.extend(activation, { profile: profile });
+ _.extend(activation, { profile });
if (profile.parent != null) {
_.extend(activation, { parentProfile: profiles[profile.parent] });
}
@@ -46,13 +46,13 @@ export default Backbone.Collection.extend({
return rules;
},
- setIndex: function () {
+ setIndex () {
this.forEach(function (rule, index) {
- rule.set({ index: index });
+ rule.set({ index });
});
},
- addExtraAttributes: function (repositories) {
+ addExtraAttributes (repositories) {
this.models.forEach(function (model) {
model.addExtraAttributes(repositories);
});
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 c13e5538ee4..ddf87c1efbe 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
@@ -53,7 +53,7 @@ export default Marionette.LayoutView.extend({
'click .js-delete': 'deleteRule'
},
- initialize: function () {
+ initialize () {
this.bindShortcuts();
this.customRules = new Rules();
if (this.model.get('isTemplate')) {
@@ -62,7 +62,7 @@ export default Marionette.LayoutView.extend({
this.listenTo(this.options.app.state, 'change:selectedIndex', this.select);
},
- onRender: function () {
+ onRender () {
this.metaRegion.show(new MetaView({
app: this.options.app,
model: this.model
@@ -92,28 +92,28 @@ export default Marionette.LayoutView.extend({
this.$el.scrollParent().scrollTop(0);
},
- onDestroy: function () {
+ onDestroy () {
this.unbindShortcuts();
},
- fetchCustomRules: function () {
- var that = this,
- url = '/api/rules/search',
- options = {
- template_key: this.model.get('key'),
- f: 'name,severity,params'
- };
+ fetchCustomRules () {
+ const that = this;
+ const url = '/api/rules/search';
+ const options = {
+ template_key: this.model.get('key'),
+ f: 'name,severity,params'
+ };
return $.get(url, options).done(function (data) {
that.customRules.reset(data.rules);
});
},
- getQualityProfiles: function () {
+ getQualityProfiles () {
return this.model.getInactiveProfiles(this.options.actives, this.options.app.qualityProfiles);
},
- bindShortcuts: function () {
- var that = this;
+ bindShortcuts () {
+ const that = this;
key('up', 'details', function () {
that.options.app.controller.selectPrev();
return false;
@@ -128,33 +128,33 @@ export default Marionette.LayoutView.extend({
});
},
- unbindShortcuts: function () {
+ unbindShortcuts () {
key.deleteScope('details');
},
- editManualRule: function () {
+ editManualRule () {
new ManualRuleCreationView({
app: this.options.app,
model: this.model
}).render();
},
- editCustomRule: function () {
+ editCustomRule () {
new CustomRuleCreationView({
app: this.options.app,
model: this.model
}).render();
},
- deleteRule: function () {
- var that = this,
- ruleType = this.model.has('templateKey') ? 'custom' : 'manual';
+ deleteRule () {
+ const that = this;
+ const ruleType = this.model.has('templateKey') ? 'custom' : 'manual';
confirmDialog({
title: translate('delete'),
html: translateWithParameters('coding_rules.delete.' + ruleType + '.confirm', this.model.get('name')),
- yesHandler: function () {
- var url = '/api/rules/delete',
- options = { key: that.model.id };
+ yesHandler () {
+ const url = '/api/rules/delete';
+ const options = { key: that.model.id };
$.post(url, options).done(function () {
that.options.app.controller.fetchList();
});
@@ -162,17 +162,17 @@ export default Marionette.LayoutView.extend({
});
},
- select: function () {
- var selected = this.options.app.state.get('selectedIndex'),
- selectedRule = this.options.app.list.at(selected);
+ select () {
+ const selected = this.options.app.state.get('selectedIndex');
+ const selectedRule = this.options.app.list.at(selected);
this.options.app.controller.showDetails(selectedRule);
},
- serializeData: function () {
- var isManual = this.model.get('isManual'),
- isCustom = this.model.has('templateKey'),
- isEditable = this.options.app.canWrite && (isManual || isCustom),
- qualityProfilesVisible = !isManual;
+ serializeData () {
+ const isManual = this.model.get('isManual');
+ const isCustom = this.model.has('templateKey');
+ const isEditable = this.options.app.canWrite && (isManual || isCustom);
+ let qualityProfilesVisible = !isManual;
if (qualityProfilesVisible) {
if (this.model.get('isTemplate')) {
@@ -184,9 +184,9 @@ export default Marionette.LayoutView.extend({
}
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- isEditable: isEditable,
+ isEditable,
canWrite: this.options.app.canWrite,
- qualityProfilesVisible: qualityProfilesVisible,
+ qualityProfilesVisible,
allTags: _.union(this.model.get('sysTags'), this.model.get('tags'))
});
}
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule-filter-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule-filter-view.js
index 7893cf5e5db..577d63af9e1 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/rule-filter-view.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/rule-filter-view.js
@@ -25,14 +25,14 @@ import Template from './templates/coding-rules-rule-filter-form.hbs';
export default ActionOptionsView.extend({
template: Template,
- selectOption: function (e) {
- var property = $(e.currentTarget).data('property'),
- value = $(e.currentTarget).data('value');
+ selectOption (e) {
+ const property = $(e.currentTarget).data('property');
+ const value = $(e.currentTarget).data('value');
this.trigger('select', property, value);
return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- serializeData: function () {
+ serializeData () {
return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), {
tags: _.union(this.model.get('sysTags'), this.model.get('tags'))
});
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 dc0ad6fb708..a76577128f9 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
@@ -28,7 +28,7 @@ import { translate } from '../../../helpers/l10n';
export default ModalFormView.extend({
template: Template,
- ui: function () {
+ ui () {
return _.extend(ModalFormView.prototype.ui.apply(this, arguments), {
customRuleCreationKey: '#coding-rules-custom-rule-creation-key',
customRuleCreationName: '#coding-rules-custom-rule-creation-name',
@@ -42,7 +42,7 @@ export default ModalFormView.extend({
});
},
- events: function () {
+ events () {
return _.extend(ModalFormView.prototype.events.apply(this, arguments), {
'input @ui.customRuleCreationName': 'generateKey',
'keydown @ui.customRuleCreationName': 'generateKey',
@@ -58,31 +58,31 @@ export default ModalFormView.extend({
});
},
- generateKey: function () {
+ generateKey () {
if (!this.keyModifiedByUser && this.ui.customRuleCreationKey) {
- var generatedKey = latinize(this.ui.customRuleCreationName.val()).replace(/[^A-Za-z0-9]/g, '_');
+ const generatedKey = latinize(this.ui.customRuleCreationName.val()).replace(/[^A-Za-z0-9]/g, '_');
this.ui.customRuleCreationKey.val(generatedKey);
}
},
- flagKey: function () {
+ flagKey () {
this.keyModifiedByUser = true;
},
- onRender: function () {
+ onRender () {
ModalFormView.prototype.onRender.apply(this, arguments);
this.keyModifiedByUser = false;
- var format = function (state) {
- if (!state.id) {
- return state.text;
- } else {
- return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
- }
- },
- severity = (this.model && this.model.get('severity')) || this.options.templateRule.get('severity'),
- status = (this.model && this.model.get('status')) || this.options.templateRule.get('status');
+ const format = function (state) {
+ if (!state.id) {
+ return state.text;
+ } else {
+ return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
+ }
+ };
+ const severity = (this.model && this.model.get('severity')) || this.options.templateRule.get('severity');
+ const status = (this.model && this.model.get('status')) || this.options.templateRule.get('status');
this.ui.customRuleCreationSeverity.val(severity);
this.ui.customRuleCreationSeverity.select2({
@@ -99,15 +99,15 @@ export default ModalFormView.extend({
});
},
- create: function (e) {
+ create (e) {
e.preventDefault();
- var action = (this.model && this.model.has('key')) ? 'update' : 'create',
- options = {
- name: this.ui.customRuleCreationName.val(),
- markdown_description: this.ui.customRuleCreationHtmlDescription.val(),
- severity: this.ui.customRuleCreationSeverity.val(),
- status: this.ui.customRuleCreationStatus.val()
- };
+ const action = (this.model && this.model.has('key')) ? 'update' : 'create';
+ const options = {
+ name: this.ui.customRuleCreationName.val(),
+ markdown_description: this.ui.customRuleCreationHtmlDescription.val(),
+ severity: this.ui.customRuleCreationSeverity.val(),
+ status: this.ui.customRuleCreationStatus.val()
+ };
if (this.model && this.model.has('key')) {
options.key = this.model.get('key');
} else {
@@ -117,15 +117,15 @@ export default ModalFormView.extend({
prevent_reactivation: true
});
}
- var params = this.ui.customRuleCreationParameters.map(function () {
- var node = $(this),
- value = node.val();
+ const params = this.ui.customRuleCreationParameters.map(function () {
+ const node = $(this);
+ let value = node.val();
if (!value && action === 'create') {
value = node.prop('placeholder') || '';
}
return {
key: node.prop('name'),
- value: value
+ value
};
}).get();
options.params = params.map(function (param) {
@@ -134,29 +134,29 @@ export default ModalFormView.extend({
this.sendRequest(action, options);
},
- reactivate: function () {
- var options = {
- name: this.existingRule.name,
- markdown_description: this.existingRule.mdDesc,
- severity: this.existingRule.severity,
- status: this.existingRule.status,
- template_key: this.existingRule.templateKey,
- custom_key: this.ui.customRuleCreationKey.val(),
- prevent_reactivation: false
- },
- params = this.existingRule.params;
+ reactivate () {
+ const options = {
+ name: this.existingRule.name,
+ markdown_description: this.existingRule.mdDesc,
+ severity: this.existingRule.severity,
+ status: this.existingRule.status,
+ template_key: this.existingRule.templateKey,
+ custom_key: this.ui.customRuleCreationKey.val(),
+ prevent_reactivation: false
+ };
+ const params = this.existingRule.params;
options.params = params.map(function (param) {
return param.key + '=' + param.defaultValue;
}).join(';');
this.sendRequest('create', options);
},
- sendRequest: function (action, options) {
+ sendRequest (action, options) {
this.$('.alert').addClass('hidden');
- var that = this,
- url = '/api/rules/' + action;
+ const that = this;
+ const url = '/api/rules/' + action;
return $.ajax({
- url: url,
+ url,
type: 'POST',
data: options,
statusCode: {
@@ -182,8 +182,8 @@ export default ModalFormView.extend({
});
},
- serializeData: function () {
- var params = {};
+ serializeData () {
+ let params = {};
if (this.options.templateRule) {
params = this.options.templateRule.get('params');
} else if (this.model && this.model.has('params')) {
@@ -192,7 +192,7 @@ export default ModalFormView.extend({
});
}
- var statuses = ['READY', 'BETA', 'DEPRECATED'].map(function (status) {
+ const statuses = ['READY', 'BETA', 'DEPRECATED'].map(function (status) {
return {
id: status,
text: translate('rules.status', status.toLowerCase())
@@ -201,9 +201,9 @@ export default ModalFormView.extend({
return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
change: this.model && this.model.has('key'),
- params: params,
+ params,
severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
- statuses: statuses
+ statuses
});
}
});
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 992d662ef31..41f9a7f5912 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
@@ -36,14 +36,14 @@ export default Marionette.ItemView.extend({
'click .js-delete-custom-rule': 'deleteRule'
},
- deleteRule: function () {
- var that = this;
+ deleteRule () {
+ const that = this;
confirmDialog({
title: translate('delete'),
html: translate('are_you_sure'),
- yesHandler: function () {
- var url = '/api/rules/delete',
- options = { key: that.model.id };
+ yesHandler () {
+ const url = '/api/rules/delete';
+ const options = { key: that.model.id };
$.post(url, options).done(function () {
that.model.collection.remove(that.model);
that.destroy();
@@ -52,7 +52,7 @@ export default Marionette.ItemView.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite,
templateRule: this.options.templateRule,
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 119a95feb8e..134dd5c057e 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
@@ -28,7 +28,7 @@ export default Marionette.CompositeView.extend({
childView: CustomRuleView,
childViewContainer: '#coding-rules-detail-custom-rules',
- childViewOptions: function () {
+ childViewOptions () {
return {
app: this.options.app,
templateRule: this.model
@@ -43,18 +43,18 @@ export default Marionette.CompositeView.extend({
'click .js-create-custom-rule': 'createCustomRule'
},
- onRender: function () {
+ onRender () {
this.$el.toggleClass('hidden', !this.model.get('isTemplate'));
},
- createCustomRule: function () {
+ createCustomRule () {
new CustomRuleCreationView({
app: this.options.app,
templateRule: this.model
}).render();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js
index 9e807573888..a34ad593ce6 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
@@ -27,7 +27,7 @@ import { translate } from '../../../helpers/l10n';
export default ModalFormView.extend({
template: Template,
- ui: function () {
+ ui () {
return _.extend(ModalFormView.prototype.ui.apply(this.arguments), {
manualRuleCreationKey: '#coding-rules-manual-rule-creation-key',
manualRuleCreationName: '#coding-rules-manual-rule-creation-name',
@@ -41,7 +41,7 @@ export default ModalFormView.extend({
});
},
- events: function () {
+ events () {
return _.extend(ModalFormView.prototype.events.apply(this.arguments), {
'input @ui.manualRuleCreationName': 'generateKey',
'keydown @ui.manualRuleCreationName': 'generateKey',
@@ -57,29 +57,29 @@ export default ModalFormView.extend({
});
},
- onRender: function () {
+ onRender () {
ModalFormView.prototype.onRender.apply(this, arguments);
this.keyModifiedByUser = false;
this.ui.manualRuleCreationReactivate.addClass('hidden');
},
- generateKey: function () {
+ generateKey () {
if (!this.keyModifiedByUser && this.ui.manualRuleCreationKey) {
- var generatedKey = latinize(this.ui.manualRuleCreationName.val()).replace(/[^A-Za-z0-9]/g, '_');
+ const generatedKey = latinize(this.ui.manualRuleCreationName.val()).replace(/[^A-Za-z0-9]/g, '_');
this.ui.manualRuleCreationKey.val(generatedKey);
}
},
- flagKey: function () {
+ flagKey () {
this.keyModifiedByUser = true;
},
- create: function () {
- var action = (this.model && this.model.has('key')) ? 'update' : 'create',
- options = {
- name: this.ui.manualRuleCreationName.val(),
- markdown_description: this.ui.manualRuleCreationHtmlDescription.val()
- };
+ create () {
+ const action = (this.model && this.model.has('key')) ? 'update' : 'create';
+ const options = {
+ name: this.ui.manualRuleCreationName.val(),
+ markdown_description: this.ui.manualRuleCreationHtmlDescription.val()
+ };
if (action === 'update') {
options.key = this.model.get('key');
} else {
@@ -89,8 +89,8 @@ export default ModalFormView.extend({
this.sendRequest(action, options);
},
- reactivate: function () {
- var options = {
+ reactivate () {
+ const options = {
name: this.existingRule.name,
markdown_description: this.existingRule.mdDesc,
manual_key: this.ui.manualRuleCreationKey.val(),
@@ -99,11 +99,11 @@ export default ModalFormView.extend({
this.sendRequest('create', options);
},
- sendRequest: function (action, options) {
- var that = this,
- url = '/api/rules/' + action;
+ sendRequest (action, options) {
+ const that = this;
+ const url = '/api/rules/' + action;
return $.ajax({
- url: url,
+ url,
type: 'POST',
data: options,
statusCode: {
@@ -128,7 +128,7 @@ export default ModalFormView.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
change: this.model && this.model.has('key')
});
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 84b4784c44d..e9f526e398e 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
@@ -27,7 +27,7 @@ import { csvEscape } from '../../../helpers/csv';
export default ModalForm.extend({
template: Template,
- ui: function () {
+ ui () {
return _.extend(ModalForm.prototype.ui.apply(this, arguments), {
qualityProfileSelect: '#coding-rules-quality-profile-activation-select',
qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity',
@@ -36,13 +36,13 @@ export default ModalForm.extend({
});
},
- events: function () {
+ events () {
return _.extend(ModalForm.prototype.events.apply(this, arguments), {
'click @ui.qualityProfileActivate': 'activate'
});
},
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.ui.qualityProfileSelect.select2({
@@ -50,15 +50,15 @@ export default ModalForm.extend({
minimumResultsForSearch: 5
});
- var that = this,
- format = function (state) {
- if (!state.id) {
- return state.text;
- } else {
- return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
- }
- },
- severity = (this.model && this.model.get('severity')) || this.options.rule.get('severity');
+ const that = this;
+ const format = function (state) {
+ if (!state.id) {
+ return state.text;
+ } else {
+ return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
+ }
+ };
+ const severity = (this.model && this.model.get('severity')) || this.options.rule.get('severity');
this.ui.qualityProfileSeverity.val(severity);
this.ui.qualityProfileSeverity.select2({
width: '250px',
@@ -71,19 +71,19 @@ export default ModalForm.extend({
}, 0);
},
- activate: function (e) {
+ activate (e) {
e.preventDefault();
- var that = this,
- profileKey = this.ui.qualityProfileSelect.val(),
- params = this.ui.qualityProfileParameters.map(function () {
- return {
- key: $(this).prop('name'),
- value: $(this).val() || $(this).prop('placeholder') || ''
- };
- }).get(),
- paramsHash = (params.map(function (param) {
- return param.key + '=' + csvEscape(param.value);
- })).join(';');
+ const that = this;
+ let profileKey = this.ui.qualityProfileSelect.val();
+ const params = this.ui.qualityProfileParameters.map(function () {
+ return {
+ key: $(this).prop('name'),
+ value: $(this).val() || $(this).prop('placeholder') || ''
+ };
+ }).get();
+ const paramsHash = (params.map(function (param) {
+ return param.key + '=' + csvEscape(param.value);
+ })).join(';');
if (this.model) {
profileKey = this.model.get('qProfile');
@@ -92,8 +92,8 @@ export default ModalForm.extend({
}
}
- var severity = this.ui.qualityProfileSeverity.val(),
- ruleKey = this.options.rule.get('key');
+ const severity = this.ui.qualityProfileSeverity.val();
+ const ruleKey = this.options.rule.get('key');
this.disableForm();
@@ -103,7 +103,7 @@ export default ModalForm.extend({
data: {
profile_key: profileKey,
rule_key: ruleKey,
- severity: severity,
+ severity,
params: paramsHash
},
statusCode: {
@@ -119,23 +119,23 @@ export default ModalForm.extend({
});
},
- getAvailableQualityProfiles: function (lang) {
- var activeQualityProfiles = this.collection || new Backbone.Collection(),
- inactiveProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
- return activeQualityProfiles.findWhere({ key: profile.key });
- });
+ getAvailableQualityProfiles (lang) {
+ const activeQualityProfiles = this.collection || new Backbone.Collection();
+ const inactiveProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
+ return activeQualityProfiles.findWhere({ key: profile.key });
+ });
return _.filter(inactiveProfiles, function (profile) {
return profile.lang === lang;
});
},
- serializeData: function () {
- var params = this.options.rule.get('params');
+ serializeData () {
+ let params = this.options.rule.get('params');
if (this.model != null) {
- var modelParams = this.model.get('params');
+ const modelParams = this.model.get('params');
if (_.isArray(modelParams)) {
params = params.map(function (p) {
- var parentParam = _.findWhere(modelParams, { key: p.key });
+ const parentParam = _.findWhere(modelParams, { key: p.key });
if (parentParam != null) {
_.extend(p, { value: parentParam.value });
}
@@ -144,14 +144,14 @@ export default ModalForm.extend({
}
}
- var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')),
- contextProfile = this.options.app.state.get('query').qprofile;
+ const availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang'));
+ const contextProfile = this.options.app.state.get('query').qprofile;
return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
change: this.model && this.model.has('severity'),
- params: params,
+ params,
qualityProfiles: availableProfiles,
- contextProfile: contextProfile,
+ contextProfile,
severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
saveEnabled: !_.isEmpty(availableProfiles) || (this.model && this.model.get('qProfile')),
isCustomRule: (this.model && this.model.has('templateKey')) || this.options.rule.has('templateKey')
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 b6d7b78f0b3..80ddf0dd6b2 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
@@ -48,19 +48,19 @@ export default Marionette.ItemView.extend({
'click @ui.extendDescriptionRemove': 'removeExtendedDescription'
},
- showExtendDescriptionForm: function () {
+ showExtendDescriptionForm () {
this.ui.descriptionExtra.addClass('hidden');
this.ui.extendDescriptionForm.removeClass('hidden');
this.ui.extendDescriptionText.focus();
},
- hideExtendDescriptionForm: function () {
+ hideExtendDescriptionForm () {
this.ui.descriptionExtra.removeClass('hidden');
this.ui.extendDescriptionForm.addClass('hidden');
},
- submitExtendDescription: function () {
- var that = this;
+ submitExtendDescription () {
+ const that = this;
this.ui.extendDescriptionForm.addClass('hidden');
return $.ajax({
type: 'POST',
@@ -81,22 +81,22 @@ export default Marionette.ItemView.extend({
});
},
- removeExtendedDescription: function () {
- var that = this;
+ removeExtendedDescription () {
+ const that = this;
confirmDialog({
html: translate('coding_rules.remove_extended_description.confirm'),
- yesHandler: function () {
+ yesHandler () {
that.ui.extendDescriptionText.val('');
that.submitExtendDescription();
}
});
},
- serializeData: function () {
- var isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
+ serializeData () {
+ const isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- isEditable: isEditable,
+ isEditable,
canWrite: this.options.app.canWrite
});
}
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js
index 5c37921d9df..2d142bda5e1 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js
@@ -21,18 +21,18 @@ import $ from 'jquery';
import RuleFilterView from '../rule-filter-view';
export default {
- onRuleFilterClick: function (e) {
+ onRuleFilterClick (e) {
e.preventDefault();
e.stopPropagation();
$('body').click();
- var that = this,
- popup = new RuleFilterView({
- triggerEl: $(e.currentTarget),
- bottomRight: true,
- model: this.model
- });
+ const that = this;
+ const popup = new RuleFilterView({
+ triggerEl: $(e.currentTarget),
+ bottomRight: true,
+ model: this.model
+ });
popup.on('select', function (property, value) {
- var obj = {};
+ const obj = {};
obj[property] = '' + value;
that.options.app.state.updateFilter(obj);
popup.destroy();
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 bcb5bd09191..afd73aa6957 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
@@ -25,8 +25,8 @@ import Template from '../templates/rule/coding-rules-rule-issues.hbs';
export default Marionette.ItemView.extend({
template: Template,
- initialize: function () {
- var that = this;
+ initialize () {
+ const that = this;
this.total = null;
this.projects = [];
this.requestIssues().done(function () {
@@ -34,20 +34,20 @@ export default Marionette.ItemView.extend({
});
},
- requestIssues: function () {
- var that = this,
- url = '/api/issues/search',
- options = {
- rules: this.model.id,
- resolved: false,
- ps: 1,
- facets: 'projectUuids'
- };
+ requestIssues () {
+ const that = this;
+ const url = '/api/issues/search';
+ const options = {
+ rules: this.model.id,
+ resolved: false,
+ ps: 1,
+ facets: 'projectUuids'
+ };
return $.get(url, options).done(function (r) {
- var projectsFacet = _.findWhere(r.facets, { property: 'projectUuids' }),
- projects = projectsFacet != null ? projectsFacet.values : [];
+ const projectsFacet = _.findWhere(r.facets, { property: 'projectUuids' });
+ let projects = projectsFacet != null ? projectsFacet.values : [];
projects = projects.map(function (project) {
- var projectBase = _.findWhere(r.components, { uuid: project.val });
+ const projectBase = _.findWhere(r.components, { uuid: project.val });
return _.extend(project, {
name: projectBase != null ? projectBase.longName : ''
});
@@ -57,7 +57,7 @@ export default Marionette.ItemView.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
total: this.total,
projects: this.projects,
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 129eb7744fb..f8a182a74a8 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
@@ -46,23 +46,23 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({
'click .js-rule-filter': 'onRuleFilterClick'
},
- onRender: function () {
+ onRender () {
this.$('[data-toggle="tooltip"]').tooltip({
container: 'body'
});
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- requestTags: function () {
- var url = '/api/rules/tags';
+ requestTags () {
+ const url = '/api/rules/tags';
return $.get(url);
},
- changeTags: function () {
- var that = this;
+ changeTags () {
+ const that = this;
this.requestTags().done(function (r) {
that.ui.tagInput.select2({
tags: _.difference(_.difference(r.tags, that.model.get('tags')), that.model.get('sysTags')),
@@ -76,7 +76,7 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({
});
},
- cancelEdit: function () {
+ cancelEdit () {
this.ui.tagsList.removeClass('hidden');
this.ui.tagsEdit.addClass('hidden');
if (this.ui.tagInput.select2) {
@@ -85,15 +85,15 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({
}
},
- editDone: function () {
- var that = this,
- tags = this.ui.tagInput.val();
+ editDone () {
+ const that = this;
+ const tags = this.ui.tagInput.val();
return $.ajax({
type: 'POST',
url: '/api/rules/update',
data: {
key: this.model.get('key'),
- tags: tags
+ tags
}
}).done(function (r) {
that.model.set('tags', r.rule.tags);
@@ -103,7 +103,7 @@ export default Marionette.ItemView.extend(RuleFilterMixin).extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite,
subCharacteristic: this.options.app.getSubCharacteristicName(this.model.get('debtSubChar')),
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 3f252636a47..89a66d8ad03 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
@@ -28,15 +28,15 @@ export default Marionette.ItemView.extend({
'change': 'render'
},
- onRender: function () {
+ onRender () {
this.$el.toggleClass('hidden', _.isEmpty(this.model.get('params')));
},
- serializeData: function () {
- var isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
+ serializeData () {
+ const isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- isEditable: isEditable,
+ isEditable,
canWrite: this.options.app.canWrite
});
}
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 22ed2b47ad5..e30ed43fd77 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
@@ -46,33 +46,33 @@ export default Marionette.ItemView.extend({
'click @ui.deactivate': 'deactivate'
},
- onRender: function () {
+ onRender () {
this.$('[data-toggle="tooltip"]').tooltip({
container: 'body'
});
},
- change: function () {
- var that = this,
- activationView = new ProfileActivationView({
- model: this.model,
- collection: this.model.collection,
- rule: this.options.rule,
- app: this.options.app
- });
+ change () {
+ const that = this;
+ const activationView = new ProfileActivationView({
+ model: this.model,
+ collection: this.model.collection,
+ rule: this.options.rule,
+ app: this.options.app
+ });
activationView.on('profileActivated', function () {
that.options.refreshActives();
});
activationView.render();
},
- revert: function () {
- var that = this,
- ruleKey = this.options.rule.get('key');
+ revert () {
+ const that = this;
+ const ruleKey = this.options.rule.get('key');
confirmDialog({
title: translate('coding_rules.revert_to_parent_definition'),
html: translateWithParameters('coding_rules.revert_to_parent_definition.confirm', this.getParent().name),
- yesHandler: function () {
+ yesHandler () {
return $.ajax({
type: 'POST',
url: '/api/qualityprofiles/activate_rule',
@@ -88,13 +88,13 @@ export default Marionette.ItemView.extend({
});
},
- deactivate: function () {
- var that = this,
- ruleKey = this.options.rule.get('key');
+ deactivate () {
+ const that = this;
+ const ruleKey = this.options.rule.get('key');
confirmDialog({
title: translate('coding_rules.deactivate'),
html: translateWithParameters('coding_rules.deactivate.confirm'),
- yesHandler: function () {
+ yesHandler () {
return $.ajax({
type: 'POST',
url: '/api/qualityprofiles/deactivate_rule',
@@ -109,34 +109,34 @@ export default Marionette.ItemView.extend({
});
},
- enableUpdate: function () {
+ enableUpdate () {
return this.ui.update.prop('disabled', false);
},
- getParent: function () {
+ getParent () {
if (!(this.model.get('inherit') && this.model.get('inherit') !== 'NONE')) {
return null;
}
- var myProfile = _.findWhere(this.options.app.qualityProfiles, {
- key: this.model.get('qProfile')
- }),
- parentKey = myProfile.parentKey,
- parent = _.extend({}, _.findWhere(this.options.app.qualityProfiles, {
- key: parentKey
- })),
- parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model();
+ const myProfile = _.findWhere(this.options.app.qualityProfiles, {
+ key: this.model.get('qProfile')
+ });
+ const parentKey = myProfile.parentKey;
+ const parent = _.extend({}, _.findWhere(this.options.app.qualityProfiles, {
+ key: parentKey
+ }));
+ const parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model();
_.extend(parent, parentActiveInfo.toJSON());
return parent;
},
- enhanceParameters: function () {
- var parent = this.getParent(),
- params = _.sortBy(this.model.get('params'), 'key');
+ enhanceParameters () {
+ const parent = this.getParent();
+ const params = _.sortBy(this.model.get('params'), 'key');
if (!parent) {
return params;
}
return params.map(function (p) {
- var parentParam = _.findWhere(parent.params, { key: p.key });
+ const parentParam = _.findWhere(parent.params, { key: p.key });
if (parentParam != null) {
return _.extend(p, {
original: _.findWhere(parent.params, { key: p.key }).value
@@ -147,7 +147,7 @@ export default Marionette.ItemView.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite,
parent: this.getParent(),
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 0d18bf216fa..2dda9a223a5 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
@@ -28,7 +28,7 @@ export default Marionette.CompositeView.extend({
childView: ProfileView,
childViewContainer: '#coding-rules-detail-quality-profiles',
- childViewOptions: function () {
+ childViewOptions () {
return {
app: this.options.app,
rule: this.model,
@@ -44,9 +44,9 @@ export default Marionette.CompositeView.extend({
'click #coding-rules-quality-profile-activate': 'activate'
},
- onRender: function () {
- var isManual = this.model.get('isManual'),
- qualityProfilesVisible = !isManual;
+ onRender () {
+ const isManual = this.model.get('isManual');
+ let qualityProfilesVisible = !isManual;
if (qualityProfilesVisible) {
if (this.model.get('isTemplate')) {
@@ -60,36 +60,36 @@ export default Marionette.CompositeView.extend({
this.$el.toggleClass('hidden', !qualityProfilesVisible);
},
- activate: function () {
- var that = this,
- activationView = new ProfileActivationView({
- rule: this.model,
- collection: this.collection,
- app: this.options.app
- });
+ activate () {
+ const that = this;
+ const activationView = new ProfileActivationView({
+ rule: this.model,
+ collection: this.collection,
+ app: this.options.app
+ });
activationView.on('profileActivated', function (severity, params, profile) {
if (that.options.app.state.get('query').qprofile === profile) {
- var activation = {
- severity: severity,
+ const activation = {
+ severity,
inherit: 'NONE',
- params: params,
+ params,
qProfile: profile
};
- that.model.set({ activation: activation });
+ that.model.set({ activation });
}
that.refreshActives();
});
activationView.render();
},
- refreshActives: function () {
- var that = this;
+ refreshActives () {
+ const that = this;
this.options.app.controller.getRuleDetails(this.model).done(function (data) {
that.collection.reset(that.model.getInactiveProfiles(data.actives, that.options.app.qualityProfiles));
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite
});
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/workspace-header-view.js b/server/sonar-web/src/main/js/apps/coding-rules/workspace-header-view.js
index df9e564de53..1e976b2cbdb 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/workspace-header-view.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/workspace-header-view.js
@@ -26,7 +26,7 @@ import Template from './templates/coding-rules-workspace-header.hbs';
export default WorkspaceHeaderView.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(WorkspaceHeaderView.prototype.events.apply(this, arguments), {
'click .js-back': 'onBackClick',
'click .js-bulk-change': 'onBulkChangeClick',
@@ -35,11 +35,11 @@ export default WorkspaceHeaderView.extend({
});
},
- onBackClick: function () {
+ onBackClick () {
this.options.app.controller.hideDetails();
},
- onBulkChangeClick: function (e) {
+ onBulkChangeClick (e) {
e.stopPropagation();
$('body').click();
new BulkChangePopup({
@@ -49,15 +49,15 @@ export default WorkspaceHeaderView.extend({
}).render();
},
- reload: function () {
+ reload () {
this.options.app.controller.fetchList(true);
},
- newSearch: function () {
+ newSearch () {
this.options.app.controller.newSearch();
},
- serializeData: function () {
+ serializeData () {
return _.extend(WorkspaceHeaderView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.app.canWrite
});
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 3048fe8925a..57df8c95027 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
@@ -23,7 +23,7 @@ import { translate } from '../../helpers/l10n';
export default Marionette.ItemView.extend({
className: 'search-navigator-no-results',
- template: function () {
+ template () {
return translate('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 8a87b4e951c..86e26521d02 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
@@ -46,45 +46,45 @@ export default WorkspaceListItemView.extend(RuleFilterMixin).extend({
'click .coding-rules-detail-quality-profile-deactivate': 'deactivate'
},
- selectCurrent: function () {
+ selectCurrent () {
this.options.app.state.set({ selectedIndex: this.model.get('index') });
},
- openRule: function () {
+ openRule () {
this.options.app.controller.showDetails(this.model);
},
- activate: function () {
- var that = this,
- selectedProfile = this.options.app.state.get('query').qprofile,
- othersQualityProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
- return profile.key === selectedProfile;
- }),
- activationView = new ProfileActivationView({
- rule: this.model,
- collection: new Backbone.Collection(othersQualityProfiles),
- app: this.options.app
- });
+ activate () {
+ const that = this;
+ const selectedProfile = this.options.app.state.get('query').qprofile;
+ const othersQualityProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
+ return profile.key === selectedProfile;
+ });
+ const activationView = new ProfileActivationView({
+ rule: this.model,
+ collection: new Backbone.Collection(othersQualityProfiles),
+ app: this.options.app
+ });
activationView.on('profileActivated', function (severity, params, profile) {
- var activation = {
- severity: severity,
+ const activation = {
+ severity,
inherit: 'NONE',
- params: params,
+ params,
qProfile: profile
};
- that.model.set({ activation: activation });
+ that.model.set({ activation });
});
activationView.render();
},
- deactivate: function () {
- var that = this,
- ruleKey = this.model.get('key'),
- activation = this.model.get('activation');
+ deactivate () {
+ const that = this;
+ const ruleKey = this.model.get('key');
+ const activation = this.model.get('activation');
confirmDialog({
title: translate('coding_rules.deactivate'),
html: translateWithParameters('coding_rules.deactivate.confirm'),
- yesHandler: function () {
+ yesHandler () {
return $.ajax({
type: 'POST',
url: '/api/qualityprofiles/deactivate_rule',
@@ -99,7 +99,7 @@ export default WorkspaceListItemView.extend(RuleFilterMixin).extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(WorkspaceListItemView.prototype.serializeData.apply(this, arguments), {
tags: _.union(this.model.get('sysTags'), this.model.get('tags')),
canWrite: this.options.app.canWrite,
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js
index 5d25dfd3ee4..ebcaada5b0d 100644
--- a/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js
+++ b/server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js
@@ -28,9 +28,9 @@ export default WorkspaceListView.extend({
childViewContainer: '.js-list',
emptyView: WorkspaceListEmptyView,
- bindShortcuts: function () {
+ bindShortcuts () {
WorkspaceListView.prototype.bindShortcuts.apply(this, arguments);
- var that = this;
+ const that = this;
key('right', 'list', function () {
that.options.app.controller.showDetailsForSelected();
return false;
diff --git a/server/sonar-web/src/main/js/apps/component-issues/app.js b/server/sonar-web/src/main/js/apps/component-issues/app.js
index 6fea2744c02..15cb81d1a55 100644
--- a/server/sonar-web/src/main/js/apps/component-issues/app.js
+++ b/server/sonar-web/src/main/js/apps/component-issues/app.js
@@ -32,54 +32,54 @@ import WorkspaceListView from '../issues/workspace-list-view';
import WorkspaceHeaderView from '../issues/workspace-header-view';
import FacetsView from './../issues/facets-view';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- this.config = options.config;
- this.state = new State({
- isContext: true,
- contextQuery: { componentUuids: options.config.resource },
- contextComponentUuid: options.config.resource,
- contextComponentName: options.config.resourceName,
- contextComponentQualifier: options.config.resourceQualifier
- });
- this.updateContextFacets();
- this.list = new Issues();
- this.facets = new Facets();
- this.filters = new Filters();
+ this.config = options.config;
+ this.state = new State({
+ isContext: true,
+ contextQuery: { componentUuids: options.config.resource },
+ contextComponentUuid: options.config.resource,
+ contextComponentName: options.config.resourceName,
+ contextComponentQualifier: options.config.resourceQualifier
+ });
+ this.updateContextFacets();
+ this.list = new Issues();
+ this.facets = new Facets();
+ this.filters = new Filters();
- this.layout = new Layout({ app: this, el: options.el });
- this.layout.render();
- $('#footer').addClass('search-navigator-footer');
+ this.layout = new Layout({ app: this, el: options.el });
+ this.layout.render();
+ $('#footer').addClass('search-navigator-footer');
- this.controller = new Controller({ app: this });
+ this.controller = new Controller({ app: this });
- this.issuesView = new WorkspaceListView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceListRegion.show(this.issuesView);
- this.issuesView.bindScrollEvents();
+ this.issuesView = new WorkspaceListView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceListRegion.show(this.issuesView);
+ this.issuesView.bindScrollEvents();
- this.workspaceHeaderView = new WorkspaceHeaderView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
+ this.workspaceHeaderView = new WorkspaceHeaderView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
- this.facetsView = new FacetsView({
- app: this,
- collection: this.facets
- });
- this.layout.facetsRegion.show(this.facetsView);
+ this.facetsView = new FacetsView({
+ app: this,
+ collection: this.facets
+ });
+ this.layout.facetsRegion.show(this.facetsView);
- this.controller.fetchFilters().done(function () {
- key.setScope('list');
- App.router = new Router({ app: App });
- Backbone.history.start();
- });
- };
+ this.controller.fetchFilters().done(function () {
+ key.setScope('list');
+ App.router = new Router({ app: App });
+ Backbone.history.start();
+ });
+};
App.getContextQuery = function () {
return { componentUuids: this.config.resource };
@@ -96,11 +96,11 @@ App.getRestrictedFacets = function () {
};
App.updateContextFacets = function () {
- var facets = this.state.get('facets'),
- allFacets = this.state.get('allFacets'),
- facetsFromServer = this.state.get('facetsFromServer');
+ const facets = this.state.get('facets');
+ const allFacets = this.state.get('allFacets');
+ const facetsFromServer = this.state.get('facetsFromServer');
return this.state.set({
- facets: facets,
+ facets,
allFacets: _.difference(allFacets, this.getRestrictedFacets()[this.config.resourceQualifier]),
facetsFromServer: _.difference(facetsFromServer, this.getRestrictedFacets()[this.config.resourceQualifier])
});
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 c13e7a94d04..531584e81d4 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
@@ -24,41 +24,41 @@ import HeaderView from './header-view';
import ListView from './list-view';
import ListFooterView from './list-footer-view';
-var App = new Marionette.Application(),
- init = function (options) {
- // Layout
- this.layout = new Layout({
- el: options.el
- });
- this.layout.render();
+const App = new Marionette.Application();
+const init = function (options) {
+ // Layout
+ this.layout = new Layout({
+ el: options.el
+ });
+ this.layout.render();
- // Collection
- this.customMeasures = new CustomMeasures({
- projectId: options.component.id
- });
+ // Collection
+ this.customMeasures = new CustomMeasures({
+ projectId: options.component.id
+ });
- // Header View
- this.headerView = new HeaderView({
- collection: this.customMeasures,
- projectId: options.component.id
- });
- this.layout.headerRegion.show(this.headerView);
+ // Header View
+ this.headerView = new HeaderView({
+ collection: this.customMeasures,
+ projectId: options.component.id
+ });
+ this.layout.headerRegion.show(this.headerView);
- // List View
- this.listView = new ListView({
- collection: this.customMeasures
- });
- this.layout.listRegion.show(this.listView);
+ // List View
+ this.listView = new ListView({
+ collection: this.customMeasures
+ });
+ this.layout.listRegion.show(this.listView);
- // List Footer View
- this.listFooterView = new ListFooterView({
- collection: this.customMeasures
- });
- this.layout.listFooterRegion.show(this.listFooterView);
+ // List Footer View
+ this.listFooterView = new ListFooterView({
+ collection: this.customMeasures
+ });
+ this.layout.listFooterRegion.show(this.listFooterView);
- // Go!
- this.customMeasures.fetch();
- };
+ // Go!
+ this.customMeasures.fetch();
+};
App.on('start', function (options) {
init.call(App, options);
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/create-view.js b/server/sonar-web/src/main/js/apps/custom-measures/create-view.js
index 9e18bb65743..d7fb10976f9 100644
--- a/server/sonar-web/src/main/js/apps/custom-measures/create-view.js
+++ b/server/sonar-web/src/main/js/apps/custom-measures/create-view.js
@@ -22,14 +22,14 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this,
- customMeasure = new CustomMeasure({
- metricId: this.$('#create-custom-measure-metric').val(),
- value: this.$('#create-custom-measure-value').val(),
- description: this.$('#create-custom-measure-description').val(),
- projectId: this.options.projectId
- });
+ sendRequest () {
+ const that = this;
+ const customMeasure = new CustomMeasure({
+ metricId: this.$('#create-custom-measure-metric').val(),
+ value: this.$('#create-custom-measure-value').val(),
+ description: this.$('#create-custom-measure-description').val(),
+ projectId: this.options.projectId
+ });
this.disableForm();
return customMeasure.save(null, {
statusCode: {
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 6576b554c8d..64524614f64 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
@@ -23,12 +23,12 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
idAttribute: 'id',
- urlRoot: function () {
+ urlRoot () {
return '/api/custom_measures';
},
- sync: function (method, model, options) {
- var opts = options || {};
+ sync (method, model, options) {
+ const opts = options || {};
if (method === 'create') {
_.defaults(opts, {
url: this.urlRoot() + '/create',
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 3afb64f5c63..7367c7fe437 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
@@ -24,43 +24,43 @@ import CustomMeasure from './custom-measure';
export default Backbone.Collection.extend({
model: CustomMeasure,
- initialize: function (options) {
+ initialize (options) {
this.projectId = options.projectId;
},
- url: function () {
+ url () {
return '/api/custom_measures/search';
},
- parse: function (r) {
+ parse (r) {
this.total = r.total;
this.p = r.p;
this.ps = r.ps;
return r.customMeasures;
},
- fetch: function (options) {
- var opts = _.defaults(options || {}, { data: {} });
+ fetch (options) {
+ const opts = _.defaults(options || {}, { data: {} });
this.q = opts.data.q;
opts.data.projectId = this.projectId;
return Backbone.Collection.prototype.fetch.call(this, opts);
},
- fetchMore: function () {
- var p = this.p + 1;
- return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps, q: this.q } });
+ fetchMore () {
+ const p = this.p + 1;
+ return this.fetch({ add: true, remove: false, data: { p, ps: this.ps, q: this.q } });
},
- refresh: function () {
+ refresh () {
return this.fetch({ reset: true, data: { q: this.q } });
},
- hasMore: function () {
+ hasMore () {
return this.total > this.p * this.ps;
},
- getTakenMetrics: function () {
- var metrics = this.map(function (model) {
+ getTakenMetrics () {
+ const metrics = this.map(function (model) {
return model.get('metric').id;
});
return _.uniq(metrics);
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 574c6fc7397..efd5f2b9a03 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
@@ -23,14 +23,14 @@ import Template from './templates/custom-measures-delete.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- collection = this.model.collection;
+ sendRequest () {
+ const that = this;
+ const collection = this.model.collection;
return this.model.destroy({
wait: true,
statusCode: {
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 3744ea00ca2..ea0c2d90aa3 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
@@ -25,13 +25,13 @@ import Template from './templates/custom-measures-form.hbs';
export default ModalForm.extend({
template: Template,
- initialize: function () {
+ initialize () {
this.metrics = new Metrics();
this.listenTo(this.metrics, 'reset', this.render);
this.metrics.fetch({ reset: true });
},
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
this.$('#create-custom-measure-metric').select2({
@@ -40,28 +40,28 @@ export default ModalForm.extend({
});
},
- onDestroy: function () {
+ onDestroy () {
ModalForm.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- getAvailableMetrics: function () {
- var takenMetrics = this.collection.getTakenMetrics();
+ getAvailableMetrics () {
+ const takenMetrics = this.collection.getTakenMetrics();
return this.metrics.toJSON().filter(function (metric) {
return takenMetrics.indexOf(metric.id) === -1;
});
},
- serializeData: function () {
- var metrics = this.getAvailableMetrics(),
- isNew = !this.model;
+ serializeData () {
+ const metrics = this.getAvailableMetrics();
+ const isNew = !this.model;
return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
- metrics: 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 373446078b5..a64585fe12d 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
@@ -28,12 +28,12 @@ export default Marionette.ItemView.extend({
'click #custom-measures-create': 'onCreateClick'
},
- onCreateClick: function (e) {
+ onCreateClick (e) {
e.preventDefault();
this.createCustomMeasure();
},
- createCustomMeasure: function () {
+ createCustomMeasure () {
new CreateView({
collection: this.collection,
projectId: this.options.projectId
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 1e643926330..38d6ed7a561 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
@@ -32,16 +32,16 @@ export default Marionette.ItemView.extend({
'click #custom-measures-fetch-more': 'onMoreClick'
},
- onMoreClick: function (e) {
+ onMoreClick (e) {
e.preventDefault();
this.fetchMore();
},
- fetchMore: function () {
+ fetchMore () {
this.collection.fetchMore();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
total: this.collection.total,
count: this.collection.length,
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 7df1628a2b5..3e21a231e02 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
@@ -31,33 +31,33 @@ export default Marionette.ItemView.extend({
'click .js-custom-measure-delete': 'onDeleteClick'
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-id', this.model.id);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onUpdateClick: function (e) {
+ onUpdateClick (e) {
e.preventDefault();
this.updateCustomMeasure();
},
- onDeleteClick: function (e) {
+ onDeleteClick (e) {
e.preventDefault();
this.deleteCustomMeasure();
},
- updateCustomMeasure: function () {
+ updateCustomMeasure () {
new UpdateView({
model: this.model,
collection: this.model.collection
}).render();
},
- deleteCustomMeasure: function () {
+ deleteCustomMeasure () {
new DeleteView({ model: this.model }).render();
}
});
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/update-view.js b/server/sonar-web/src/main/js/apps/custom-measures/update-view.js
index f18038ba96d..fde20403f4c 100644
--- a/server/sonar-web/src/main/js/apps/custom-measures/update-view.js
+++ b/server/sonar-web/src/main/js/apps/custom-measures/update-view.js
@@ -21,8 +21,8 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this;
+ sendRequest () {
+ const that = this;
this.model.set({
value: this.$('#create-custom-measure-value').val(),
description: this.$('#create-custom-measure-description').val()
diff --git a/server/sonar-web/src/main/js/apps/dashboard/app.js b/server/sonar-web/src/main/js/apps/dashboard/app.js
index 93180f502f4..bedc68831ad 100644
--- a/server/sonar-web/src/main/js/apps/dashboard/app.js
+++ b/server/sonar-web/src/main/js/apps/dashboard/app.js
@@ -26,7 +26,7 @@ window.Portal = function (options) {
window.Portal.prototype = {
- initialize: function (options) {
+ initialize (options) {
this.options = options;
if (!this.options.editorEnabled) {
return;
@@ -37,22 +37,20 @@ window.Portal.prototype = {
},
- createAllSortables: function () {
- var that = this,
- blocks = $('.' + this.options.block),
- columnHandle = $('.' + this.options.columnHandle),
- draggable,
-
- onDragLeave = function (e) {
- $(e.currentTarget).removeClass(that.options.hoverClass);
- },
-
- onDrop = function (e) {
- e.preventDefault();
- draggable.detach().insertBefore($(e.currentTarget));
- onDragLeave(e);
- that.saveDashboardsState();
- };
+ createAllSortables () {
+ const that = this;
+ const blocks = $('.' + this.options.block);
+ const columnHandle = $('.' + this.options.columnHandle);
+ let draggable;
+ const onDragLeave = function (e) {
+ $(e.currentTarget).removeClass(that.options.hoverClass);
+ };
+ const onDrop = function (e) {
+ e.preventDefault();
+ draggable.detach().insertBefore($(e.currentTarget));
+ onDragLeave(e);
+ that.saveDashboardsState();
+ };
blocks
.prop('draggable', true)
@@ -84,9 +82,9 @@ window.Portal.prototype = {
},
- highlightWidget: function (widgetId) {
- var block = $('#block_' + widgetId),
- options = this.options;
+ highlightWidget (widgetId) {
+ const block = $('#block_' + widgetId);
+ const options = this.options;
block.css('background-color', options.highlightStartColor);
setTimeout(function () {
block.css('background-color', options.highlightEndColor);
@@ -94,22 +92,22 @@ window.Portal.prototype = {
},
- saveDashboardsState: function () {
- var options = this.options,
- result = $('.' + this.options.column).map(function () {
- var blocks = $(this).find('.' + options.block);
- $(this).find('.' + options.columnHandle).toggle(blocks.length === 0);
+ saveDashboardsState () {
+ const options = this.options;
+ const result = $('.' + this.options.column).map(function () {
+ const blocks = $(this).find('.' + options.block);
+ $(this).find('.' + options.columnHandle).toggle(blocks.length === 0);
- return blocks.map(function () {
- return $(this).prop('id').substring(options.block.length + 1);
- }).get().join(',');
- }).get().join(';');
+ return blocks.map(function () {
+ return $(this).prop('id').substring(options.block.length + 1);
+ }).get().join(',');
+ }).get().join(';');
if (result === this.lastSaveString) {
return;
}
- var firstTime = this.lastSaveString === '';
+ const firstTime = this.lastSaveString === '';
this.lastSaveString = result;
if (firstTime) {
@@ -117,7 +115,7 @@ window.Portal.prototype = {
}
if (this.options.saveUrl) {
- var postBody = this.options.dashboardState + '=' + encodeURIComponent(result);
+ const postBody = this.options.dashboardState + '=' + encodeURIComponent(result);
$.ajax({
url: this.options.saveUrl,
@@ -128,7 +126,7 @@ window.Portal.prototype = {
},
- editWidget: function (widgetId) {
+ editWidget (widgetId) {
$('#widget_title_' + widgetId).hide();
$('#widget_' + widgetId).hide();
$('#widget_props_' + widgetId).show();
@@ -136,7 +134,7 @@ window.Portal.prototype = {
},
- cancelEditWidget: function (widgetId) {
+ cancelEditWidget (widgetId) {
$('widget_title_' + widgetId).show();
$('#widget_' + widgetId).show();
$('#widget_props_' + widgetId).hide();
@@ -144,7 +142,7 @@ window.Portal.prototype = {
},
- deleteWidget: function (element) {
+ deleteWidget (element) {
$(element).closest('.' + this.options.block).remove();
this.saveDashboardsState();
}
@@ -152,6 +150,6 @@ window.Portal.prototype = {
window.autoResize = function (everyMs, callback) {
- var debounce = _.debounce(callback, everyMs);
+ const debounce = _.debounce(callback, everyMs);
$(window).on('resize', debounce);
};
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 f3262566647..f11445b5e50 100644
--- a/server/sonar-web/src/main/js/apps/drilldown/app.js
+++ b/server/sonar-web/src/main/js/apps/drilldown/app.js
@@ -21,25 +21,25 @@ import $ from 'jquery';
import Marionette from 'backbone.marionette';
import SourceViewer from '../../components/source-viewer/main';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
- App.addRegions({ viewerRegion: options.el });
- $('.js-drilldown-link').on('click', function (e) {
- e.preventDefault();
- $(e.currentTarget).closest('table').find('.selected').removeClass('selected');
- $(e.currentTarget).closest('tr').addClass('selected');
- var uuid = $(e.currentTarget).data('uuid'),
- viewer = new SourceViewer();
- App.viewerRegion.show(viewer);
- viewer.open(uuid);
- if (window.drilldown.period != null) {
- viewer.on('loaded', function () {
- viewer.filterLinesByDate(window.drilldown.period, window.drilldown.periodName);
- });
- }
- }).addClass('js-ready');
- };
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
+ App.addRegions({ viewerRegion: options.el });
+ $('.js-drilldown-link').on('click', function (e) {
+ e.preventDefault();
+ $(e.currentTarget).closest('table').find('.selected').removeClass('selected');
+ $(e.currentTarget).closest('tr').addClass('selected');
+ const uuid = $(e.currentTarget).data('uuid');
+ const viewer = new SourceViewer();
+ App.viewerRegion.show(viewer);
+ viewer.open(uuid);
+ if (window.drilldown.period != null) {
+ viewer.on('loaded', function () {
+ viewer.filterLinesByDate(window.drilldown.period, window.drilldown.periodName);
+ });
+ }
+ }).addClass('js-ready');
+};
App.on('start', function (options) {
init.call(App, options);
diff --git a/server/sonar-web/src/main/js/apps/global-permissions/app.js b/server/sonar-web/src/main/js/apps/global-permissions/app.js
index db3d198d797..463b7a1cf0d 100644
--- a/server/sonar-web/src/main/js/apps/global-permissions/app.js
+++ b/server/sonar-web/src/main/js/apps/global-permissions/app.js
@@ -22,6 +22,6 @@ import ReactDOM from 'react-dom';
import Main from './main';
window.sonarqube.appStarted.then(options => {
- var el = document.querySelector(options.el);
+ const el = document.querySelector(options.el);
ReactDOM.render(<Main/>, el);
});
diff --git a/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js b/server/sonar-web/src/main/js/apps/global-permissions/groups-view.js
index c29c1eeba85..eebc1249772 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
@@ -22,7 +22,7 @@ import Template from './templates/global-permissions-groups.hbs';
import '../../components/SelectList';
function getSearchUrl (permission, project) {
- var url = '/api/permissions/groups?ps=100&permission=' + permission;
+ let url = '/api/permissions/groups?ps=100&permission=' + permission;
if (project) {
url = url + '&projectId=' + project;
}
@@ -30,7 +30,7 @@ function getSearchUrl (permission, project) {
}
function getExtra (permission, project) {
- var extra = { permission: permission };
+ const extra = { permission };
if (project) {
extra.projectId = project;
}
@@ -40,14 +40,14 @@ function getExtra (permission, project) {
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
new window.SelectList({
el: this.$('#global-permissions-groups'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name;
},
queryParam: 'q',
@@ -57,14 +57,14 @@ export default Modal.extend({
extra: getExtra(this.options.permission, this.options.project),
selectParameter: 'groupName',
selectParameterValue: 'name',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.groups;
}
});
},
- onDestroy: function () {
+ onDestroy () {
this.options.refresh();
Modal.prototype.onDestroy.apply(this, arguments);
}
diff --git a/server/sonar-web/src/main/js/apps/global-permissions/main.js b/server/sonar-web/src/main/js/apps/global-permissions/main.js
index 963713722ed..3a468aef67d 100644
--- a/server/sonar-web/src/main/js/apps/global-permissions/main.js
+++ b/server/sonar-web/src/main/js/apps/global-permissions/main.js
@@ -32,7 +32,7 @@ export default React.createClass({
},
requestPermissions() {
- const url = `/api/permissions/search_global_permissions`;
+ const url = '/api/permissions/search_global_permissions';
$.get(url).done(r => {
this.setState({ ready: true, permissions: r.permissions });
});
diff --git a/server/sonar-web/src/main/js/apps/global-permissions/permission.js b/server/sonar-web/src/main/js/apps/global-permissions/permission.js
index 32b5bb71ac0..7b6be54f353 100644
--- a/server/sonar-web/src/main/js/apps/global-permissions/permission.js
+++ b/server/sonar-web/src/main/js/apps/global-permissions/permission.js
@@ -40,7 +40,7 @@ export default React.createClass({
},
requestUsers() {
- const url = `/api/permissions/users`;
+ const url = '/api/permissions/users';
let data = { permission: this.props.permission.key, ps: MAX_ITEMS };
if (this.props.project) {
data.projectId = this.props.project;
@@ -49,7 +49,7 @@ export default React.createClass({
},
requestGroups() {
- const url = `/api/permissions/groups`;
+ const url = '/api/permissions/groups';
let data = { permission: this.props.permission.key, ps: MAX_ITEMS };
if (this.props.project) {
data.projectId = this.props.project;
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 980da17df61..9c59d065ced 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
@@ -22,7 +22,7 @@ import Template from './templates/global-permissions-users.hbs';
import '../../components/SelectList';
function getSearchUrl (permission, project) {
- var url = '/api/permissions/users?ps=100&permission=' + permission;
+ let url = '/api/permissions/users?ps=100&permission=' + permission;
if (project) {
url = url + '&projectId=' + project;
}
@@ -30,7 +30,7 @@ function getSearchUrl (permission, project) {
}
function getExtra (permission, project) {
- var extra = { permission: permission };
+ const extra = { permission };
if (project) {
extra.projectId = project;
}
@@ -40,14 +40,14 @@ function getExtra (permission, project) {
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
new window.SelectList({
el: this.$('#global-permissions-users'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name + '<br><span class="note">' + item.login + '</span>';
},
queryParam: 'q',
@@ -57,14 +57,14 @@ export default Modal.extend({
extra: getExtra(this.options.permission, this.options.project),
selectParameter: 'login',
selectParameterValue: 'login',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.users;
}
});
},
- onDestroy: function () {
+ onDestroy () {
this.options.refresh();
Modal.prototype.onDestroy.apply(this, arguments);
}
diff --git a/server/sonar-web/src/main/js/apps/groups/app.js b/server/sonar-web/src/main/js/apps/groups/app.js
index 3897fb23f66..06688e79802 100644
--- a/server/sonar-web/src/main/js/apps/groups/app.js
+++ b/server/sonar-web/src/main/js/apps/groups/app.js
@@ -25,36 +25,36 @@ import SearchView from './search-view';
import ListView from './list-view';
import ListFooterView from './list-footer-view';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- // Layout
- this.layout = new Layout({ el: options.el });
- this.layout.render();
+ // Layout
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
- // Collection
- this.groups = new Groups();
+ // Collection
+ this.groups = new Groups();
- // Header View
- this.headerView = new HeaderView({ collection: this.groups });
- this.layout.headerRegion.show(this.headerView);
+ // Header View
+ this.headerView = new HeaderView({ collection: this.groups });
+ this.layout.headerRegion.show(this.headerView);
- // Search View
- this.searchView = new SearchView({ collection: this.groups });
- this.layout.searchRegion.show(this.searchView);
+ // Search View
+ this.searchView = new SearchView({ collection: this.groups });
+ this.layout.searchRegion.show(this.searchView);
- // List View
- this.listView = new ListView({ collection: this.groups });
- this.layout.listRegion.show(this.listView);
+ // List View
+ this.listView = new ListView({ collection: this.groups });
+ this.layout.listRegion.show(this.listView);
- // List Footer View
- this.listFooterView = new ListFooterView({ collection: this.groups });
- this.layout.listFooterRegion.show(this.listFooterView);
+ // List Footer View
+ this.listFooterView = new ListFooterView({ collection: this.groups });
+ this.layout.listFooterRegion.show(this.listFooterView);
- // Go!
- this.groups.fetch();
- };
+ // Go!
+ this.groups.fetch();
+};
App.on('start', function () {
init.call(App);
diff --git a/server/sonar-web/src/main/js/apps/groups/create-view.js b/server/sonar-web/src/main/js/apps/groups/create-view.js
index 3cef0969a8d..d5c918d2a4e 100644
--- a/server/sonar-web/src/main/js/apps/groups/create-view.js
+++ b/server/sonar-web/src/main/js/apps/groups/create-view.js
@@ -22,12 +22,12 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this,
- group = new Group({
- name: this.$('#create-group-name').val(),
- description: this.$('#create-group-description').val()
- });
+ sendRequest () {
+ const that = this;
+ const group = new Group({
+ name: this.$('#create-group-name').val(),
+ description: this.$('#create-group-description').val()
+ });
this.disableForm();
return group.save(null, {
statusCode: {
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 036bc4554fd..6228cf93c2e 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
@@ -23,14 +23,14 @@ import Template from './templates/groups-delete.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- collection = this.model.collection;
+ sendRequest () {
+ const that = this;
+ const collection = this.model.collection;
return this.model.destroy({
wait: true,
statusCode: {
@@ -45,7 +45,7 @@ export default ModalForm.extend({
});
},
- showErrors: function (errors, warnings) {
+ showErrors (errors, warnings) {
this.$('.js-modal-text').addClass('hidden');
this.disableForm();
ModalForm.prototype.showErrors.call(this, 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 4f3d7a8e772..31a2f12c6a8 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
@@ -23,17 +23,17 @@ import Template from './templates/groups-form.hbs';
export default ModalForm.extend({
template: Template,
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
ModalForm.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
}
diff --git a/server/sonar-web/src/main/js/apps/groups/group.js b/server/sonar-web/src/main/js/apps/groups/group.js
index ff0c7e5a5f0..9c80986eaa1 100644
--- a/server/sonar-web/src/main/js/apps/groups/group.js
+++ b/server/sonar-web/src/main/js/apps/groups/group.js
@@ -21,12 +21,12 @@ import _ from 'underscore';
import Backbone from 'backbone';
export default Backbone.Model.extend({
- urlRoot: function () {
+ urlRoot () {
return '/api/user_groups';
},
- sync: function (method, model, options) {
- var opts = options || {};
+ sync (method, model, options) {
+ const opts = options || {};
if (method === 'create') {
_.defaults(opts, {
url: this.urlRoot() + '/create',
@@ -35,7 +35,7 @@ export default Backbone.Model.extend({
});
}
if (method === 'update') {
- var attrs = _.extend(_.pick(model.changed, 'name', 'description'), { id: model.id });
+ const attrs = _.extend(_.pick(model.changed, 'name', 'description'), { id: model.id });
_.defaults(opts, {
url: this.urlRoot() + '/update',
type: 'POST',
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 73f21163135..e3e18d3bf48 100644
--- a/server/sonar-web/src/main/js/apps/groups/groups.js
+++ b/server/sonar-web/src/main/js/apps/groups/groups.js
@@ -23,33 +23,33 @@ import Group from './group';
export default Backbone.Collection.extend({
model: Group,
- url: function () {
+ url () {
return '/api/user_groups/search';
},
- parse: function (r) {
+ parse (r) {
this.total = +r.total;
this.p = +r.p;
this.ps = +r.ps;
return r.groups;
},
- fetch: function (options) {
- var d = (options && options.data) || {};
+ fetch (options) {
+ const d = (options && options.data) || {};
this.q = d.q;
return Backbone.Collection.prototype.fetch.call(this, options);
},
- fetchMore: function () {
- var p = this.p + 1;
- return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps, q: this.q } });
+ fetchMore () {
+ const p = this.p + 1;
+ return this.fetch({ add: true, remove: false, data: { p, ps: this.ps, q: this.q } });
},
- refresh: function () {
+ refresh () {
return this.fetch({ reset: true, data: { q: this.q } });
},
- hasMore: function () {
+ hasMore () {
return this.total > this.p * this.ps;
}
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 e76d6d59e05..18c340e2a46 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
@@ -33,20 +33,20 @@ export default Marionette.ItemView.extend({
'click #groups-create': 'onCreateClick'
},
- showSpinner: function () {
+ showSpinner () {
this.$('.spinner').removeClass('hidden');
},
- hideSpinner: function () {
+ hideSpinner () {
this.$('.spinner').addClass('hidden');
},
- onCreateClick: function (e) {
+ onCreateClick (e) {
e.preventDefault();
this.createGroup();
},
- createGroup: function () {
+ createGroup () {
new CreateView({
collection: this.collection
}).render();
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 123f57e0875..7d983388829 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
@@ -32,16 +32,16 @@ export default Marionette.ItemView.extend({
'click #groups-fetch-more': 'onMoreClick'
},
- onMoreClick: function (e) {
+ onMoreClick (e) {
e.preventDefault();
this.fetchMore();
},
- fetchMore: function () {
+ fetchMore () {
this.collection.fetchMore();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
total: this.collection.total,
count: this.collection.length,
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 f89abc861cf..d559ecc599b 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
@@ -35,43 +35,43 @@ export default Marionette.ItemView.extend({
'click .js-group-users': 'onUsersClick'
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-id', this.model.id);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onUpdateClick: function (e) {
+ onUpdateClick (e) {
e.preventDefault();
this.updateGroup();
},
- onDeleteClick: function (e) {
+ onDeleteClick (e) {
e.preventDefault();
this.deleteGroup();
},
- onUsersClick: function (e) {
+ onUsersClick (e) {
e.preventDefault();
$('.tooltip').remove();
this.showUsers();
},
- updateGroup: function () {
+ updateGroup () {
new UpdateView({
model: this.model,
collection: this.model.collection
}).render();
},
- deleteGroup: function () {
+ deleteGroup () {
new DeleteView({ model: this.model }).render();
},
- showUsers: function () {
+ showUsers () {
new UsersView({ model: this.model }).render();
}
});
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 c8578ef72f0..fd3a8c81dbd 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
@@ -29,11 +29,11 @@ export default Marionette.CollectionView.extend({
'sync': 'hideLoading'
},
- showLoading: function () {
+ showLoading () {
this.$el.addClass('new-loading');
},
- hideLoading: function () {
+ hideLoading () {
this.$el.removeClass('new-loading');
}
});
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 ecf1540b712..c9d24d11f9a 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
@@ -30,22 +30,22 @@ export default Marionette.ItemView.extend({
'keyup #groups-search-query': 'debouncedOnKeyUp'
},
- initialize: function () {
+ initialize () {
this._bufferedValue = null;
this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
},
- onRender: function () {
+ onRender () {
this.delegateEvents();
},
- onFormSubmit: function (e) {
+ onFormSubmit (e) {
e.preventDefault();
this.debouncedOnKeyUp();
},
- onKeyUp: function () {
- var q = this.getQuery();
+ onKeyUp () {
+ const q = this.getQuery();
if (q === this._bufferedValue) {
return;
}
@@ -56,12 +56,12 @@ export default Marionette.ItemView.extend({
this.searchRequest = this.search(q);
},
- getQuery: function () {
+ getQuery () {
return this.$('#groups-search-query').val();
},
- search: function (q) {
- return this.collection.fetch({ reset: true, data: { q: q } });
+ search (q) {
+ return this.collection.fetch({ reset: true, data: { q } });
}
});
diff --git a/server/sonar-web/src/main/js/apps/groups/update-view.js b/server/sonar-web/src/main/js/apps/groups/update-view.js
index abd0888c06e..40ade76b45b 100644
--- a/server/sonar-web/src/main/js/apps/groups/update-view.js
+++ b/server/sonar-web/src/main/js/apps/groups/update-view.js
@@ -21,8 +21,8 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this;
+ sendRequest () {
+ const that = this;
this.model.set({
name: this.$('#create-group-name').val(),
description: this.$('#create-group-description').val()
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 8f5baa9f16d..e42827f8b1e 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
@@ -24,14 +24,14 @@ import Template from './templates/groups-users.hbs';
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
new window.SelectList({
el: this.$('#groups-users'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name + '<br><span class="note">' + item.login + '</span>';
},
queryParam: 'q',
@@ -43,14 +43,14 @@ export default Modal.extend({
},
selectParameter: 'login',
selectParameterValue: 'login',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.users;
}
});
},
- onDestroy: function () {
+ onDestroy () {
this.model.collection.refresh();
Modal.prototype.onDestroy.apply(this, arguments);
}
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 2b38d9b9226..4d20567cbd3 100644
--- a/server/sonar-web/src/main/js/apps/issues/app.js
+++ b/server/sonar-web/src/main/js/apps/issues/app.js
@@ -32,52 +32,52 @@ import WorkspaceHeaderView from './workspace-header-view';
import FacetsView from './facets-view';
import FiltersView from './filters-view';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- this.state = new State();
- this.list = new Issues();
- this.facets = new Facets();
- this.filters = new Filters();
+ this.state = new State();
+ this.list = new Issues();
+ this.facets = new Facets();
+ this.filters = new Filters();
- this.layout = new Layout({ app: this, el: options.el });
- this.layout.render();
- $('#footer').addClass('search-navigator-footer');
+ this.layout = new Layout({ app: this, el: options.el });
+ this.layout.render();
+ $('#footer').addClass('search-navigator-footer');
- this.controller = new Controller({ app: this });
+ this.controller = new Controller({ app: this });
- this.issuesView = new WorkspaceListView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceListRegion.show(this.issuesView);
- this.issuesView.bindScrollEvents();
+ this.issuesView = new WorkspaceListView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceListRegion.show(this.issuesView);
+ this.issuesView.bindScrollEvents();
- this.workspaceHeaderView = new WorkspaceHeaderView({
- app: this,
- collection: this.list
- });
- this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
+ this.workspaceHeaderView = new WorkspaceHeaderView({
+ app: this,
+ collection: this.list
+ });
+ this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
- this.facetsView = new FacetsView({
- app: this,
- collection: this.facets
- });
- this.layout.facetsRegion.show(this.facetsView);
+ this.facetsView = new FacetsView({
+ app: this,
+ collection: this.facets
+ });
+ this.layout.facetsRegion.show(this.facetsView);
- this.filtersView = new FiltersView({
- app: this,
- collection: this.filters
- });
- this.layout.filtersRegion.show(this.filtersView);
+ this.filtersView = new FiltersView({
+ app: this,
+ collection: this.filters
+ });
+ this.layout.filtersRegion.show(this.filtersView);
- this.controller.fetchFilters().done(function () {
- key.setScope('list');
- App.router = new Router({ app: App });
- Backbone.history.start();
- });
- };
+ this.controller.fetchFilters().done(function () {
+ key.setScope('list');
+ App.router = new Router({ app: App });
+ Backbone.history.start();
+ });
+};
App.on('start', function () {
init.call(App);
diff --git a/server/sonar-web/src/main/js/apps/issues/component-viewer/issue-view.js b/server/sonar-web/src/main/js/apps/issues/component-viewer/issue-view.js
index 1725f0f6d73..e21cceb7483 100644
--- a/server/sonar-web/src/main/js/apps/issues/component-viewer/issue-view.js
+++ b/server/sonar-web/src/main/js/apps/issues/component-viewer/issue-view.js
@@ -21,12 +21,12 @@ import _ from 'underscore';
import IssueView from '../workspace-list-item-view';
export default IssueView.extend({
- onRender: function () {
+ onRender () {
IssueView.prototype.onRender.apply(this, arguments);
this.$el.removeClass('issue-navigate-right issue-with-checkbox');
},
- serializeData: function () {
+ serializeData () {
return _.extend(IssueView.prototype.serializeData.apply(this, arguments), {
showComponent: false
});
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 aabe49e5b0a..a285286ce3d 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
@@ -23,19 +23,19 @@ import SourceViewer from '../../../components/source-viewer/main';
import IssueView from './issue-view';
export default SourceViewer.extend({
- events: function () {
+ events () {
return _.extend(SourceViewer.prototype.events.apply(this, arguments), {
'click .js-close-component-viewer': 'closeComponentViewer',
'click .code-issue': 'selectIssue'
});
},
- initialize: function (options) {
+ initialize (options) {
SourceViewer.prototype.initialize.apply(this, arguments);
return this.listenTo(options.app.state, 'change:selectedIndex', this.select);
},
- onLoaded: function () {
+ onLoaded () {
SourceViewer.prototype.onLoaded.apply(this, arguments);
this.bindShortcuts();
if (this.baseIssue != null) {
@@ -44,10 +44,10 @@ export default SourceViewer.extend({
}
},
- bindShortcuts: function () {
- var that = this;
- var doAction = function (action) {
- var selectedIssueView = that.getSelectedIssueEl();
+ bindShortcuts () {
+ const that = this;
+ const doAction = function (action) {
+ const selectedIssueView = that.getSelectedIssueEl();
if (!selectedIssueView) {
return;
}
@@ -85,19 +85,19 @@ export default SourceViewer.extend({
});
},
- unbindShortcuts: function () {
+ unbindShortcuts () {
return key.deleteScope('componentViewer');
},
- onDestroy: function () {
+ onDestroy () {
SourceViewer.prototype.onDestroy.apply(this, arguments);
this.unbindScrollEvents();
return this.unbindShortcuts();
},
- select: function () {
- var selected = this.options.app.state.get('selectedIndex'),
- selectedIssue = this.options.app.list.at(selected);
+ select () {
+ const selected = this.options.app.state.get('selectedIndex');
+ const selectedIssue = this.options.app.list.at(selected);
if (selectedIssue.get('component') === this.model.get('key')) {
selectedIssue.trigger('locations', selectedIssue);
return this.scrollToIssue(selectedIssue.get('key'));
@@ -107,16 +107,16 @@ export default SourceViewer.extend({
}
},
- getSelectedIssueEl: function () {
- var selected = this.options.app.state.get('selectedIndex');
+ getSelectedIssueEl () {
+ const selected = this.options.app.state.get('selectedIndex');
if (selected == null) {
return null;
}
- var selectedIssue = this.options.app.list.at(selected);
+ const selectedIssue = this.options.app.list.at(selected);
if (selectedIssue == null) {
return null;
}
- var selectedIssueView = this.$('#issue-' + (selectedIssue.get('key')));
+ const selectedIssueView = this.$('#issue-' + (selectedIssue.get('key')));
if (selectedIssueView.length > 0) {
return selectedIssueView;
} else {
@@ -124,37 +124,37 @@ export default SourceViewer.extend({
}
},
- selectIssue: function (e) {
- var key = $(e.currentTarget).data('issue-key'),
- issue = this.issues.find(function (model) {
- return model.get('key') === key;
- }),
- index = this.options.app.list.indexOf(issue);
+ selectIssue (e) {
+ const key = $(e.currentTarget).data('issue-key');
+ const issue = this.issues.find(function (model) {
+ return model.get('key') === key;
+ });
+ const index = this.options.app.list.indexOf(issue);
return this.options.app.state.set({ selectedIndex: index });
},
- scrollToIssue: function (key) {
- var el = this.$('#issue-' + key);
+ scrollToIssue (key) {
+ const el = this.$('#issue-' + key);
if (el.length > 0) {
- var line = el.closest('[data-line-number]').data('line-number');
+ const line = el.closest('[data-line-number]').data('line-number');
return this.scrollToLine(line);
} else {
this.unbindShortcuts();
- var selected = this.options.app.state.get('selectedIndex'),
- selectedIssue = this.options.app.list.at(selected);
+ const selected = this.options.app.state.get('selectedIndex');
+ const selectedIssue = this.options.app.list.at(selected);
return this.options.app.controller.showComponentViewer(selectedIssue);
}
},
- openFileByIssue: function (issue) {
+ openFileByIssue (issue) {
this.baseIssue = issue;
- var componentKey = issue.get('component'),
- componentUuid = issue.get('componentUuid');
+ const componentKey = issue.get('component');
+ const componentUuid = issue.get('componentUuid');
return this.open(componentUuid, componentKey);
},
- linesLimit: function () {
- var line = this.LINES_LIMIT / 2;
+ linesLimit () {
+ let line = this.LINES_LIMIT / 2;
if ((this.baseIssue != null) && this.baseIssue.has('line')) {
line = Math.max(line, this.baseIssue.get('line'));
}
@@ -164,9 +164,9 @@ export default SourceViewer.extend({
};
},
- limitIssues: function (issues) {
- var that = this;
- var index = this.ISSUES_LIMIT / 2;
+ limitIssues (issues) {
+ const that = this;
+ let index = this.ISSUES_LIMIT / 2;
if ((this.baseIssue != null) && this.baseIssue.has('index')) {
index = Math.max(index, this.baseIssue.get('index'));
}
@@ -175,9 +175,9 @@ export default SourceViewer.extend({
});
},
- requestIssues: function () {
- var that = this;
- var r;
+ requestIssues () {
+ const that = this;
+ let r;
if (this.options.app.list.last().get('component') === this.model.get('key')) {
r = this.options.app.controller.fetchNextPage();
} else {
@@ -192,13 +192,13 @@ export default SourceViewer.extend({
});
},
- renderIssues: function () {
+ renderIssues () {
this.issues.forEach(this.renderIssue, this);
return this.$('.source-line-issues').addClass('hidden');
},
- renderIssue: function (issue) {
- var issueView = new IssueView({
+ renderIssue (issue) {
+ const issueView = new IssueView({
el: '#issue-' + issue.get('key'),
model: issue,
app: this.options.app
@@ -207,14 +207,14 @@ export default SourceViewer.extend({
return issueView.render();
},
- scrollToLine: function (line) {
- var row = this.$('[data-line-number=' + line + ']'),
- topOffset = $(window).height() / 2 - 60,
- goal = row.length > 0 ? row.offset().top - topOffset : 0;
+ scrollToLine (line) {
+ const row = this.$('[data-line-number=' + line + ']');
+ const topOffset = $(window).height() / 2 - 60;
+ const goal = row.length > 0 ? row.offset().top - topOffset : 0;
return $(window).scrollTop(goal);
},
- closeComponentViewer: function () {
+ closeComponentViewer () {
return this.options.app.controller.closeComponentViewer();
}
});
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 5cf9f16c893..6e382be4f17 100644
--- a/server/sonar-web/src/main/js/apps/issues/controller.js
+++ b/server/sonar-web/src/main/js/apps/issues/controller.js
@@ -27,15 +27,15 @@ import HomeView from './workspace-home-view';
const FACET_DATA_FIELDS = ['components', 'users', 'rules', 'actionPlans', 'languages'];
export default Controller.extend({
- _facetsFromServer: function () {
- var facets = Controller.prototype._facetsFromServer.apply(this, arguments) || [];
+ _facetsFromServer () {
+ const facets = Controller.prototype._facetsFromServer.apply(this, arguments) || [];
if (facets.indexOf('assignees') !== -1) {
facets.push('assigned_to_me');
}
return facets;
},
- _issuesParameters: function () {
+ _issuesParameters () {
return {
p: this.options.app.state.get('page'),
ps: this.pageSize,
@@ -46,8 +46,8 @@ export default Controller.extend({
};
},
- _myIssuesFromResponse: function (r) {
- var myIssuesData = _.findWhere(r.facets, { property: 'assigned_to_me' });
+ _myIssuesFromResponse (r) {
+ const myIssuesData = _.findWhere(r.facets, { property: 'assigned_to_me' });
if ((myIssuesData != null) && _.isArray(myIssuesData.values) && myIssuesData.values.length > 0) {
return this.options.app.state.set({ myIssues: myIssuesData.values[0].count }, { silent: true });
} else {
@@ -55,8 +55,8 @@ export default Controller.extend({
}
},
- fetchList: function (firstPage) {
- var that = this;
+ fetchList (firstPage) {
+ const that = this;
if (firstPage == null) {
firstPage = true;
}
@@ -65,13 +65,13 @@ export default Controller.extend({
this.hideHomePage();
this.closeComponentViewer();
}
- var data = this._issuesParameters();
+ const data = this._issuesParameters();
_.extend(data, this.options.app.state.get('query'));
if (this.options.app.state.get('isContext')) {
_.extend(data, this.options.app.state.get('contextQuery'));
}
return $.get('/api/issues/search', data).done(function (r) {
- var issues = that.options.app.list.parseIssues(r);
+ const issues = that.options.app.list.parseIssues(r);
if (firstPage) {
that.options.app.list.reset(issues);
} else {
@@ -99,13 +99,13 @@ export default Controller.extend({
});
},
- isIssuePermalink: function () {
- var query = this.options.app.state.get('query');
+ isIssuePermalink () {
+ const query = this.options.app.state.get('query');
return (query.issues != null) && this.options.app.list.length === 1;
},
- fetchFilters: function () {
- var that = this;
+ fetchFilters () {
+ const that = this;
return $.when(
that.options.app.filters.fetch({ reset: true }),
$.get('/api/issue_filters/app', function (r) {
@@ -116,19 +116,19 @@ export default Controller.extend({
}));
},
- _mergeCollections: function (a, b) {
- var collection = new Backbone.Collection(a);
+ _mergeCollections (a, b) {
+ const collection = new Backbone.Collection(a);
collection.add(b, { merge: true });
return collection.toJSON();
},
- requestFacet: function (id) {
- var that = this;
+ requestFacet (id) {
+ const that = this;
if (id === 'assignees') {
return this.requestAssigneeFacet();
}
- var facet = this.options.app.facets.get(id),
- data = _.extend({ facets: id, ps: 1, additionalFields: '_all' }, this.options.app.state.get('query'));
+ const facet = this.options.app.facets.get(id);
+ const data = _.extend({ facets: id, ps: 1, additionalFields: '_all' }, this.options.app.state.get('query'));
if (this.options.app.state.get('isContext')) {
_.extend(data, this.options.app.state.get('contextQuery'));
}
@@ -136,18 +136,18 @@ export default Controller.extend({
FACET_DATA_FIELDS.forEach(function (field) {
that.options.app.facets[field] = that._mergeCollections(that.options.app.facets[field], r[field]);
});
- var facetData = _.findWhere(r.facets, { property: id });
+ const facetData = _.findWhere(r.facets, { property: id });
if (facetData != null) {
return facet.set(facetData);
}
});
},
- requestAssigneeFacet: function () {
- var that = this;
- var facet = this.options.app.facets.get('assignees'),
- data = _.extend({ facets: 'assignees,assigned_to_me', ps: 1, additionalFields: '_all' },
- this.options.app.state.get('query'));
+ requestAssigneeFacet () {
+ const that = this;
+ const facet = this.options.app.facets.get('assignees');
+ const data = _.extend({ facets: 'assignees,assigned_to_me', ps: 1, additionalFields: '_all' },
+ this.options.app.state.get('query'));
if (this.options.app.state.get('isContext')) {
_.extend(data, this.options.app.state.get('contextQuery'));
}
@@ -155,7 +155,7 @@ export default Controller.extend({
FACET_DATA_FIELDS.forEach(function (field) {
that.options.app.facets[field] = that._mergeCollections(that.options.app.facets[field], r[field]);
});
- var facetData = _.findWhere(r.facets, { property: 'assignees' });
+ const facetData = _.findWhere(r.facets, { property: 'assignees' });
that._myIssuesFromResponse(r);
if (facetData != null) {
return facet.set(facetData);
@@ -163,50 +163,50 @@ export default Controller.extend({
});
},
- newSearch: function () {
+ newSearch () {
this.options.app.state.unset('filter');
return this.options.app.state.setQuery({ resolved: 'false' });
},
- applyFilter: function (filter, ignoreQuery) {
+ applyFilter (filter, ignoreQuery) {
if (ignoreQuery == null) {
ignoreQuery = false;
}
if (!ignoreQuery) {
- var filterQuery = this.parseQuery(filter.get('query'));
+ const filterQuery = this.parseQuery(filter.get('query'));
this.options.app.state.setQuery(filterQuery);
}
- return this.options.app.state.set({ filter: filter, changed: false });
+ return this.options.app.state.set({ filter, changed: false });
},
- parseQuery: function () {
- var q = Controller.prototype.parseQuery.apply(this, arguments);
+ parseQuery () {
+ const q = Controller.prototype.parseQuery.apply(this, arguments);
delete q.asc;
delete q.s;
return q;
},
- getQuery: function (separator, addContext) {
+ getQuery (separator, addContext) {
if (separator == null) {
separator = '|';
}
if (addContext == null) {
addContext = false;
}
- var filter = this.options.app.state.get('query');
+ const filter = this.options.app.state.get('query');
if (addContext && this.options.app.state.get('isContext')) {
_.extend(filter, this.options.app.state.get('contextQuery'));
}
- var route = [];
+ const route = [];
_.map(filter, function (value, property) {
return route.push('' + property + '=' + encodeURIComponent(value));
});
return route.join(separator);
},
- getRoute: function () {
- var filter = this.options.app.state.get('filter'),
- query = Controller.prototype.getRoute.apply(this, arguments);
+ getRoute () {
+ const filter = this.options.app.state.get('filter');
+ let query = Controller.prototype.getRoute.apply(this, arguments);
if (filter != null) {
if (this.options.app.state.get('changed') && query.length > 0) {
query = 'id=' + filter.id + '|' + query;
@@ -217,7 +217,7 @@ export default Controller.extend({
return query;
},
- _prepareComponent: function (issue) {
+ _prepareComponent (issue) {
return {
key: issue.get('component'),
name: issue.get('componentLongName'),
@@ -229,7 +229,7 @@ export default Controller.extend({
};
},
- showComponentViewer: function (issue) {
+ showComponentViewer (issue) {
this.options.app.layout.workspaceComponentViewerRegion.reset();
key.setScope('componentViewer');
this.options.app.issuesView.unbindScrollEvents();
@@ -240,7 +240,7 @@ export default Controller.extend({
return this.options.app.componentViewer.openFileByIssue(issue);
},
- closeComponentViewer: function () {
+ closeComponentViewer () {
key.setScope('list');
$('body').click();
this.options.app.state.unset('component');
@@ -250,7 +250,7 @@ export default Controller.extend({
return this.options.app.issuesView.scrollTo();
},
- showHomePage: function () {
+ showHomePage () {
this.options.app.state.set({ query: { resolved: 'false' } }, { silent: true });
this.fetchList();
this.options.app.layout.workspaceComponentViewerRegion.reset();
@@ -264,7 +264,7 @@ export default Controller.extend({
return this.options.app.layout.showHomePage();
},
- hideHomePage: function () {
+ hideHomePage () {
this.options.app.layout.workspaceComponentViewerRegion.reset();
this.options.app.layout.workspaceHomeRegion.reset();
key.setScope('list');
diff --git a/server/sonar-web/src/main/js/apps/issues/facets-view.js b/server/sonar-web/src/main/js/apps/issues/facets-view.js
index fa4363f7cdd..87830ac6942 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets-view.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets-view.js
@@ -37,7 +37,7 @@ import IssueKeyFacet from './facets/issue-key-facet';
import ContextFacet from './facets/context-facet';
import ModeFacet from './facets/mode-facet';
-var viewsMapping = {
+const viewsMapping = {
severities: SeverityFacet,
statuses: StatusFacet,
assignees: AssigneeFacet,
@@ -58,8 +58,8 @@ var viewsMapping = {
};
export default FacetsView.extend({
- getChildView: function (model) {
- var view = viewsMapping[model.get('property')];
+ getChildView (model) {
+ const view = viewsMapping[model.get('property')];
return view ? view : BaseFacet;
}
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/action-plan-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/action-plan-facet.js
index b4d0084ad08..589329b7c27 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/action-plan-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/action-plan-facet.js
@@ -25,20 +25,20 @@ import Template from '../templates/facets/issues-action-plan-facet.hbs';
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
- var value = this.options.app.state.get('query').planned;
+ const value = this.options.app.state.get('query').planned;
if ((value != null) && (!value || value === 'false')) {
return this.$('.js-facet').filter('[data-unplanned]').addClass('active');
}
},
- toggleFacet: function (e) {
- var unplanned = $(e.currentTarget).is('[data-unplanned]');
+ toggleFacet (e) {
+ const unplanned = $(e.currentTarget).is('[data-unplanned]');
$(e.currentTarget).toggleClass('active');
if (unplanned) {
- var checked = $(e.currentTarget).is('.active'),
- value = checked ? 'false' : null;
+ const checked = $(e.currentTarget).is('.active');
+ const value = checked ? 'false' : null;
return this.options.app.state.updateFilter({
planned: value,
actionPlans: null
@@ -51,14 +51,14 @@ export default BaseFacet.extend({
}
},
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- actionPlans = this.options.app.facets.actionPlans;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const actionPlans = this.options.app.facets.actionPlans;
values.forEach(function (v) {
- var key = v.val,
- label = null;
+ const key = v.val;
+ let label = null;
if (key) {
- var actionPlan = _.findWhere(actionPlans, { key: key });
+ const actionPlan = _.findWhere(actionPlans, { key });
if (actionPlan != null) {
label = actionPlan.name;
}
@@ -68,14 +68,14 @@ export default BaseFacet.extend({
return values;
},
- disable: function () {
+ disable () {
return this.options.app.state.updateFilter({
planned: null,
actionPlans: null
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.getValuesWithLabels()
});
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 3fc1f32663f..0cfe969d2f4 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
@@ -25,35 +25,35 @@ import Template from '../templates/facets/issues-assignee-facet.hbs';
export default CustomValuesFacet.extend({
template: Template,
- getUrl: function () {
+ getUrl () {
return '/api/users/search';
},
- prepareAjaxSearch: function () {
+ prepareAjaxSearch () {
return {
quietMillis: 300,
url: this.getUrl(),
- data: function (term, page) {
+ data (term, page) {
return { q: term, p: page };
},
results: window.usersToSelect2
};
},
- onRender: function () {
+ onRender () {
CustomValuesFacet.prototype.onRender.apply(this, arguments);
- var value = this.options.app.state.get('query').assigned;
+ const value = this.options.app.state.get('query').assigned;
if ((value != null) && (!value || value === 'false')) {
return this.$('.js-facet').filter('[data-unassigned]').addClass('active');
}
},
- toggleFacet: function (e) {
- var unassigned = $(e.currentTarget).is('[data-unassigned]');
+ toggleFacet (e) {
+ const unassigned = $(e.currentTarget).is('[data-unassigned]');
$(e.currentTarget).toggleClass('active');
if (unassigned) {
- var checked = $(e.currentTarget).is('.active'),
- value = checked ? 'false' : null;
+ const checked = $(e.currentTarget).is('.active');
+ const value = checked ? 'false' : null;
return this.options.app.state.updateFilter({
assigned: value,
assignees: null
@@ -66,14 +66,14 @@ export default CustomValuesFacet.extend({
}
},
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- users = this.options.app.facets.users;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const users = this.options.app.facets.users;
values.forEach(function (v) {
- var login = v.val,
- name = '';
+ const login = v.val;
+ let name = '';
if (login) {
- var user = _.findWhere(users, { login: login });
+ const user = _.findWhere(users, { login });
if (user != null) {
name = user.name;
}
@@ -83,38 +83,38 @@ export default CustomValuesFacet.extend({
return values;
},
- disable: function () {
+ disable () {
return this.options.app.state.updateFilter({
assigned: null,
assignees: null
});
},
- addCustomValue: function () {
- var property = this.model.get('property'),
- customValue = this.$('.js-custom-value').select2('val'),
- value = this.getValue();
+ addCustomValue () {
+ const property = this.model.get('property');
+ const customValue = this.$('.js-custom-value').select2('val');
+ let value = this.getValue();
if (value.length > 0) {
value += ',';
}
value += customValue;
- var obj = {};
+ const obj = {};
obj[property] = value;
obj.assigned = null;
return this.options.app.state.updateFilter(obj);
},
- sortValues: function (values) {
+ sortValues (values) {
return _.sortBy(values, function (v) {
return v.val === '' ? -999999 : -v.count;
});
},
- getNumberOfMyIssues: function () {
+ getNumberOfMyIssues () {
return this.options.app.state.get('myIssues');
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
myIssues: this.getNumberOfMyIssues(),
values: this.sortValues(this.getValuesWithLabels())
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 d252a6e75a3..aec9e84f270 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
@@ -21,32 +21,32 @@ import CustomValuesFacet from './custom-values-facet';
import { translate, translateWithParameters } from '../../../helpers/l10n';
export default CustomValuesFacet.extend({
- getUrl: function () {
+ getUrl () {
return '/api/issues/authors';
},
- prepareSearch: function () {
+ prepareSearch () {
return this.$('.js-custom-value').select2({
placeholder: 'Search...',
minimumInputLength: 2,
allowClear: false,
- formatNoMatches: function () {
+ formatNoMatches () {
return translate('select2.noMatches');
},
- formatSearching: function () {
+ formatSearching () {
return translate('select2.searching');
},
- formatInputTooShort: function () {
+ formatInputTooShort () {
return translateWithParameters('select2.tooShort', 2);
},
width: '100%',
ajax: {
quietMillis: 300,
url: this.getUrl(),
- data: function (term) {
+ data (term) {
return { q: term, ps: 25 };
},
- results: function (data) {
+ results (data) {
return {
more: false,
results: data.authors.map(function (author) {
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 7f602870ecc..32409d01743 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
@@ -24,16 +24,16 @@ import Template from '../templates/facets/issues-base-facet.hbs';
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
return this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
},
- onDestroy: function () {
+ onDestroy () {
return this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
state: this.options.app.state.toJSON()
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/context-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/context-facet.js
index d138ade8f66..0a2a30e00a0 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/context-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/context-facet.js
@@ -24,7 +24,7 @@ import Template from '../templates/facets/issues-context-facet.hbs';
export default BaseFacet.extend({
template: Template,
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
state: this.options.app.state.toJSON()
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js
index dba6566fa84..76c62d7cc1a 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js
@@ -28,7 +28,7 @@ import { formatMeasure } from '../../../helpers/measures';
export default BaseFacet.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
'change input': 'applyFacet',
'click .js-select-period-start': 'selectPeriodStart',
@@ -41,25 +41,25 @@ export default BaseFacet.extend({
});
},
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled'));
this.$('input').datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true
});
- var props = ['createdAfter', 'createdBefore', 'createdAt'],
- query = this.options.app.state.get('query');
+ const props = ['createdAfter', 'createdBefore', 'createdAt'];
+ const query = this.options.app.state.get('query');
props.forEach(function (prop) {
- var value = query[prop];
+ const value = query[prop];
if (value != null) {
return that.$('input[name=' + prop + ']').val(value);
}
});
- var values = this.model.getValues();
+ let values = this.model.getValues();
if (!(_.isArray(values) && values.length > 0)) {
- var date = moment();
+ let date = moment();
values = [];
_.times(10, function () {
values.push({ count: 0, val: date.toDate().toString() });
@@ -68,33 +68,32 @@ export default BaseFacet.extend({
values.reverse();
}
values = values.map(function (v) {
- var format = that.options.app.state.getFacetMode() === 'count' ? 'SHORT_INT' : 'SHORT_WORK_DUR';
- var text = formatMeasure(v.count, format);
- return _.extend(v, { text: text });
+ const format = that.options.app.state.getFacetMode() === 'count' ? 'SHORT_INT' : 'SHORT_WORK_DUR';
+ const text = formatMeasure(v.count, format);
+ return _.extend(v, { text });
});
return this.$('.js-barchart').barchart(values);
},
- selectPeriodStart: function () {
+ selectPeriodStart () {
return this.$('.js-period-start').datepicker('show');
},
- selectPeriodEnd: function () {
+ selectPeriodEnd () {
return this.$('.js-period-end').datepicker('show');
},
- applyFacet: function () {
- var obj = { createdAt: null, createdInLast: null };
+ applyFacet () {
+ const obj = { createdAt: null, createdInLast: null };
this.$('input').each(function () {
- var property, value;
- property = $(this).prop('name');
- value = $(this).val();
+ const property = $(this).prop('name');
+ const value = $(this).val();
obj[property] = value;
});
return this.options.app.state.updateFilter(obj);
},
- disable: function () {
+ disable () {
return this.options.app.state.updateFilter({
createdAfter: null,
createdBefore: null,
@@ -103,9 +102,9 @@ export default BaseFacet.extend({
});
},
- selectBar: function (e) {
- var periodStart = $(e.currentTarget).data('period-start'),
- periodEnd = $(e.currentTarget).data('period-end');
+ selectBar (e) {
+ const periodStart = $(e.currentTarget).data('period-start');
+ const periodEnd = $(e.currentTarget).data('period-end');
return this.options.app.state.updateFilter({
createdAfter: periodStart,
createdBefore: periodEnd,
@@ -114,7 +113,7 @@ export default BaseFacet.extend({
});
},
- selectPeriod: function (period) {
+ selectPeriod (period) {
return this.options.app.state.updateFilter({
createdAfter: null,
createdBefore: null,
@@ -123,26 +122,26 @@ export default BaseFacet.extend({
});
},
- onAllClick: function () {
+ onAllClick () {
return this.disable();
},
- onLastWeekClick: function (e) {
+ onLastWeekClick (e) {
e.preventDefault();
return this.selectPeriod('1w');
},
- onLastMonthClick: function (e) {
+ onLastMonthClick (e) {
e.preventDefault();
return this.selectPeriod('1m');
},
- onLastYearClick: function (e) {
+ onLastYearClick (e) {
e.preventDefault();
return this.selectPeriod('1y');
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
periodStart: this.options.app.state.get('query').createdAfter,
periodEnd: this.options.app.state.get('query').createdBefore,
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 aef3ae25719..170d96111fa 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
@@ -25,33 +25,33 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
export default BaseFacet.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
'change .js-custom-value': 'addCustomValue'
});
},
- getUrl: function () {
+ getUrl () {
},
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
return this.prepareSearch();
},
- prepareSearch: function () {
+ prepareSearch () {
return this.$('.js-custom-value').select2({
placeholder: 'Search...',
minimumInputLength: 2,
allowClear: false,
- formatNoMatches: function () {
+ formatNoMatches () {
return translate('select2.noMatches');
},
- formatSearching: function () {
+ formatSearching () {
return translate('select2.searching');
},
- formatInputTooShort: function () {
+ formatInputTooShort () {
return translateWithParameters('select2.tooShort', 2);
},
width: '100%',
@@ -59,28 +59,28 @@ export default BaseFacet.extend({
});
},
- prepareAjaxSearch: function () {
+ prepareAjaxSearch () {
return {
quietMillis: 300,
url: this.getUrl(),
- data: function (term, page) {
+ data (term, page) {
return { s: term, p: page };
},
- results: function (data) {
+ results (data) {
return { more: data.more, results: data.results };
}
};
},
- addCustomValue: function () {
- var property = this.model.get('property'),
- customValue = this.$('.js-custom-value').select2('val'),
- value = this.getValue();
+ addCustomValue () {
+ const property = this.model.get('property');
+ const customValue = this.$('.js-custom-value').select2('val');
+ let value = this.getValue();
if (value.length > 0) {
value += ',';
}
value += customValue;
- var obj = {};
+ const obj = {};
obj[property] = value;
return this.options.app.state.updateFilter(obj);
}
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js
index e3a7c978645..e7d4ad7d1e5 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/file-facet.js
@@ -25,22 +25,22 @@ import Template from '../templates/facets/issues-file-facet.hbs';
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
- var maxValueWidth = _.max(this.$('.facet-stat').map(function () {
+ const maxValueWidth = _.max(this.$('.facet-stat').map(function () {
return $(this).outerWidth();
}).get());
return this.$('.facet-name').css('padding-right', maxValueWidth);
},
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- source = this.options.app.facets.components;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const source = this.options.app.facets.components;
values.forEach(function (v) {
- var key = v.val,
- label = null;
+ const key = v.val;
+ let label = null;
if (key) {
- var item = _.findWhere(source, { uuid: key });
+ const item = _.findWhere(source, { uuid: key });
if (item != null) {
label = item.longName;
}
@@ -50,7 +50,7 @@ export default BaseFacet.extend({
return values;
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValuesWithLabels())
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/issue-key-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/issue-key-facet.js
index f0d8c21ac3f..08d3a4369c1 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/issue-key-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/issue-key-facet.js
@@ -24,15 +24,15 @@ import Template from '../templates/facets/issues-issue-key-facet.hbs';
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
return this.$el.toggleClass('hidden', !this.options.app.state.get('query').issues);
},
- disable: function () {
+ disable () {
return this.options.app.state.updateFilter({ issues: null });
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
issues: this.options.app.state.get('query').issues
});
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 af92bd84037..2c1d2e0ba8f 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
@@ -22,32 +22,32 @@ import CustomValuesFacet from './custom-values-facet';
import { translate, translateWithParameters } from '../../../helpers/l10n';
export default CustomValuesFacet.extend({
- getUrl: function () {
+ getUrl () {
return '/api/languages/list';
},
- prepareSearch: function () {
+ prepareSearch () {
return this.$('.js-custom-value').select2({
placeholder: 'Search...',
minimumInputLength: 2,
allowClear: false,
- formatNoMatches: function () {
+ formatNoMatches () {
return translate('select2.noMatches');
},
- formatSearching: function () {
+ formatSearching () {
return translate('select2.searching');
},
- formatInputTooShort: function () {
+ formatInputTooShort () {
return translateWithParameters('select2.tooShort', 2);
},
width: '100%',
ajax: {
quietMillis: 300,
url: this.getUrl(),
- data: function (term) {
+ data (term) {
return { q: term, ps: 0 };
},
- results: function (data) {
+ results (data) {
return {
more: false,
results: data.languages.map(function (lang) {
@@ -59,14 +59,14 @@ export default CustomValuesFacet.extend({
});
},
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- source = this.options.app.facets.languages;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const source = this.options.app.facets.languages;
values.forEach(function (v) {
- var key = v.val,
- label = null;
+ const key = v.val;
+ let label = null;
if (key) {
- var item = _.findWhere(source, { key: key });
+ const item = _.findWhere(source, { key });
if (item != null) {
label = item.name;
}
@@ -76,7 +76,7 @@ export default CustomValuesFacet.extend({
return values;
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValuesWithLabels())
});
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 e4a3ca195e6..b1887ccd548 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
@@ -28,12 +28,12 @@ export default BaseFacet.extend({
'change [name="issues-page-mode"]': 'onModeChange'
},
- onModeChange: function () {
- var mode = this.$('[name="issues-page-mode"]:checked').val();
+ onModeChange () {
+ const mode = this.$('[name="issues-page-mode"]:checked').val();
this.options.app.state.updateFilter({ facetMode: mode });
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
mode: this.options.app.state.getFacetMode()
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js
index 25b5e5506b8..24f4f792964 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/module-facet.js
@@ -21,14 +21,14 @@ import _ from 'underscore';
import BaseFacet from './base-facet';
export default BaseFacet.extend({
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- components = this.options.app.facets.components;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const components = this.options.app.facets.components;
values.forEach(function (v) {
- var uuid = v.val,
- label = uuid;
+ const uuid = v.val;
+ let label = uuid;
if (uuid) {
- var component = _.findWhere(components, { uuid: uuid });
+ const component = _.findWhere(components, { uuid });
if (component != null) {
label = component.longName;
}
@@ -38,7 +38,7 @@ export default BaseFacet.extend({
return values;
},
- serializeData: function () {
+ serializeData () {
return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValuesWithLabels())
});
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 363c83c0e40..ffbc7772b2d 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
@@ -23,8 +23,8 @@ import { translate, translateWithParameters } from '../../../helpers/l10n';
export default CustomValuesFacet.extend({
- getUrl: function () {
- var q = this.options.app.state.get('contextComponentQualifier');
+ getUrl () {
+ const q = this.options.app.state.get('contextComponentQualifier');
if (q === 'VW' || q === 'SVW') {
return '/api/components/search_view_components';
} else {
@@ -32,8 +32,8 @@ export default CustomValuesFacet.extend({
}
},
- prepareSearch: function () {
- var q = this.options.app.state.get('contextComponentQualifier');
+ prepareSearch () {
+ const q = this.options.app.state.get('contextComponentQualifier');
if (q === 'VW' || q === 'SVW') {
return this.prepareSearchForViews();
} else {
@@ -41,29 +41,29 @@ export default CustomValuesFacet.extend({
}
},
- prepareSearchForViews: function () {
- var componentId = this.options.app.state.get('contextComponentUuid');
+ prepareSearchForViews () {
+ const componentId = this.options.app.state.get('contextComponentUuid');
return this.$('.js-custom-value').select2({
placeholder: 'Search...',
minimumInputLength: 2,
allowClear: false,
- formatNoMatches: function () {
+ formatNoMatches () {
return translate('select2.noMatches');
},
- formatSearching: function () {
+ formatSearching () {
return translate('select2.searching');
},
- formatInputTooShort: function () {
+ formatInputTooShort () {
return translateWithParameters('select2.tooShort', 2);
},
width: '100%',
ajax: {
quietMillis: 300,
url: this.getUrl(),
- data: function (term, page) {
- return { q: term, componentId: componentId, p: page, ps: 25 };
+ data (term, page) {
+ return { q: term, componentId, p: page, ps: 25 };
},
- results: function (data) {
+ results (data) {
return {
more: data.p * data.ps < data.total,
results: data.components.map(function (c) {
@@ -75,14 +75,14 @@ export default CustomValuesFacet.extend({
});
},
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- projects = this.options.app.facets.components;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const projects = this.options.app.facets.components;
values.forEach(function (v) {
- var uuid = v.val,
- label = '';
+ const uuid = v.val;
+ let label = '';
if (uuid) {
- var project = _.findWhere(projects, { uuid: uuid });
+ const project = _.findWhere(projects, { uuid });
if (project != null) {
label = project.longName;
}
@@ -92,7 +92,7 @@ export default CustomValuesFacet.extend({
return values;
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValuesWithLabels())
});
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 ac03ba3341c..d043039b66c 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
@@ -21,30 +21,29 @@ import _ from 'underscore';
import CustomValuesFacet from './custom-values-facet';
export default CustomValuesFacet.extend({
- getUrl: function () {
+ getUrl () {
return '/api/users/search';
},
- prepareAjaxSearch: function () {
+ prepareAjaxSearch () {
return {
quietMillis: 300,
url: this.getUrl(),
- data: function (term, page) {
+ data (term, page) {
return { q: term, p: page };
},
results: window.usersToSelect2
};
},
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- source = this.options.app.facets.users;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const source = this.options.app.facets.users;
values.forEach(function (v) {
- var item, key, label;
- key = v.val;
- label = null;
+ const key = v.val;
+ let label = null;
if (key) {
- item = _.findWhere(source, { login: key });
+ const item = _.findWhere(source, { login: key });
if (item != null) {
label = item.name;
}
@@ -54,7 +53,7 @@ export default CustomValuesFacet.extend({
return values;
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValuesWithLabels())
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js
index f5814c00bb6..9cdba459c61 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js
@@ -25,20 +25,20 @@ import Template from '../templates/facets/issues-resolution-facet.hbs';
export default BaseFacet.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseFacet.prototype.onRender.apply(this, arguments);
- var value = this.options.app.state.get('query').resolved;
+ const value = this.options.app.state.get('query').resolved;
if ((value != null) && (!value || value === 'false')) {
return this.$('.js-facet').filter('[data-unresolved]').addClass('active');
}
},
- toggleFacet: function (e) {
- var unresolved = $(e.currentTarget).is('[data-unresolved]');
+ toggleFacet (e) {
+ const unresolved = $(e.currentTarget).is('[data-unresolved]');
$(e.currentTarget).toggleClass('active');
if (unresolved) {
- var checked = $(e.currentTarget).is('.active'),
- value = checked ? 'false' : null;
+ const checked = $(e.currentTarget).is('.active');
+ const value = checked ? 'false' : null;
return this.options.app.state.updateFilter({
resolved: value,
resolutions: null
@@ -51,15 +51,15 @@ export default BaseFacet.extend({
}
},
- disable: function () {
+ disable () {
return this.options.app.state.updateFilter({
resolved: null,
resolutions: null
});
},
- sortValues: function (values) {
- var order = ['', 'FIXED', 'FALSE-POSITIVE', 'WONTFIX', 'REMOVED'];
+ sortValues (values) {
+ const order = ['', 'FIXED', 'FALSE-POSITIVE', 'WONTFIX', 'REMOVED'];
return _.sortBy(values, function (v) {
return order.indexOf(v.val);
});
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 a9cf5cd0187..99be8cb6dbd 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
@@ -22,9 +22,9 @@ import CustomValuesFacet from './custom-values-facet';
import { translate, translateWithParameters } from '../../../helpers/l10n';
export default CustomValuesFacet.extend({
- prepareSearch: function () {
- var url = '/api/rules/search?f=name,langName',
- languages = this.options.app.state.get('query').languages;
+ prepareSearch () {
+ let url = '/api/rules/search?f=name,langName';
+ const languages = this.options.app.state.get('query').languages;
if (languages != null) {
url += '&languages=' + languages;
}
@@ -32,26 +32,25 @@ export default CustomValuesFacet.extend({
placeholder: 'Search...',
minimumInputLength: 2,
allowClear: false,
- formatNoMatches: function () {
+ formatNoMatches () {
return translate('select2.noMatches');
},
- formatSearching: function () {
+ formatSearching () {
return translate('select2.searching');
},
- formatInputTooShort: function () {
+ formatInputTooShort () {
return translateWithParameters('select2.tooShort', 2);
},
width: '100%',
ajax: {
quietMillis: 300,
- url: url,
- data: function (term, page) {
+ url,
+ data (term, page) {
return { q: term, p: page };
},
- results: function (data) {
- var results;
- results = data.rules.map(function (rule) {
- var lang = rule.langName || translate('manual');
+ results (data) {
+ const results = data.rules.map(function (rule) {
+ const lang = rule.langName || translate('manual');
return {
id: rule.key,
text: '(' + lang + ') ' + rule.name
@@ -59,22 +58,22 @@ export default CustomValuesFacet.extend({
});
return {
more: data.p * data.ps < data.total,
- results: results
+ results
};
}
}
});
},
- getValuesWithLabels: function () {
- var values = this.model.getValues(),
- rules = this.options.app.facets.rules;
+ getValuesWithLabels () {
+ const values = this.model.getValues();
+ const rules = this.options.app.facets.rules;
values.forEach(function (v) {
- var key = v.val,
- label = '',
- extra = '';
+ const key = v.val;
+ let label = '';
+ let extra = '';
if (key) {
- var rule = _.findWhere(rules, { key: key });
+ const rule = _.findWhere(rules, { key });
if (rule != null) {
label = rule.name;
}
@@ -88,7 +87,7 @@ export default CustomValuesFacet.extend({
return values;
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValuesWithLabels())
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js
index b3ee8dcb5ec..a1021362b55 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js
@@ -24,8 +24,8 @@ import Template from '../templates/facets/issues-severity-facet.hbs';
export default BaseFacet.extend({
template: Template,
- sortValues: function (values) {
- var order = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'];
+ sortValues (values) {
+ const order = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'];
return _.sortBy(values, function (v) {
return order.indexOf(v.val);
});
diff --git a/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js b/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js
index 60097692c1f..d3190fc9c21 100644
--- a/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js
+++ b/server/sonar-web/src/main/js/apps/issues/facets/status-facet.js
@@ -24,8 +24,8 @@ import Template from '../templates/facets/issues-status-facet.hbs';
export default BaseFacet.extend({
template: Template,
- sortValues: function (values) {
- var order = ['OPEN', 'RESOLVED', 'REOPENED', 'CLOSED', 'CONFIRMED'];
+ sortValues (values) {
+ const order = ['OPEN', 'RESOLVED', 'REOPENED', 'CLOSED', 'CONFIRMED'];
return _.sortBy(values, function (v) {
return order.indexOf(v.val);
});
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 13be00166fd..c383ac36624 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
@@ -22,9 +22,9 @@ import CustomValuesFacet from './custom-values-facet';
import { translate } from '../../../helpers/l10n';
export default CustomValuesFacet.extend({
- prepareSearch: function () {
- var url = '/api/issues/tags?ps=10',
- tags = this.options.app.state.get('query').tags;
+ prepareSearch () {
+ let url = '/api/issues/tags?ps=10';
+ const tags = this.options.app.state.get('query').tags;
if (tags != null) {
url += '&tags=' + tags;
}
@@ -32,31 +32,31 @@ export default CustomValuesFacet.extend({
placeholder: 'Search...',
minimumInputLength: 0,
allowClear: false,
- formatNoMatches: function () {
+ formatNoMatches () {
return translate('select2.noMatches');
},
- formatSearching: function () {
+ formatSearching () {
return translate('select2.searching');
},
width: '100%',
ajax: {
quietMillis: 300,
- url: url,
- data: function (term) {
+ url,
+ data (term) {
return { q: term, ps: 10 };
},
- results: function (data) {
- var results = data.tags.map(function (tag) {
+ results (data) {
+ const results = data.tags.map(function (tag) {
return { id: tag, text: tag };
});
- return { more: false, results: results };
+ return { more: false, results };
}
}
});
},
- getValuesWithLabels: function () {
- var values = this.model.getValues();
+ getValuesWithLabels () {
+ const values = this.model.getValues();
values.forEach(function (v) {
v.label = v.val;
v.extra = '';
@@ -64,7 +64,7 @@ export default CustomValuesFacet.extend({
return values;
},
- serializeData: function () {
+ serializeData () {
return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.getValuesWithLabels())
});
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 2deb3b6710c..303c567fe5a 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
@@ -34,8 +34,8 @@ export default Marionette.ItemView.extend({
'click .js-filter-edit': 'edit'
},
- initialize: function (options) {
- var that = this;
+ initialize (options) {
+ const that = this;
this.listenTo(options.app.state, 'change:filter', this.render);
this.listenTo(options.app.state, 'change:changed', this.render);
this.listenTo(options.app.state, 'change:canManageFilters', this.render);
@@ -43,7 +43,7 @@ export default Marionette.ItemView.extend({
window.onSaveAs = window.onCopy = window.onEdit = function (id) {
$('#modal').dialog('close');
return that.options.app.controller.fetchFilters().done(function () {
- var filter = that.collection.get(id);
+ const filter = that.collection.get(id);
return filter.fetch().done(function () {
return that.options.app.controller.applyFilter(filter);
});
@@ -51,12 +51,12 @@ export default Marionette.ItemView.extend({
};
},
- onRender: function () {
+ onRender () {
this.$el.toggleClass('search-navigator-filters-selected', this.options.app.state.has('filter'));
},
- toggleFilters: function (e) {
- var that = this;
+ toggleFilters (e) {
+ const that = this;
e.stopPropagation();
this.$('.search-navigator-filters-list').toggle();
return $('body').on('click.issues-filters', function () {
@@ -65,41 +65,41 @@ export default Marionette.ItemView.extend({
});
},
- applyFilter: function (e) {
- var that = this;
- var id = $(e.currentTarget).data('id'),
- filter = this.collection.get(id);
+ applyFilter (e) {
+ const that = this;
+ const id = $(e.currentTarget).data('id');
+ const filter = this.collection.get(id);
return that.options.app.controller.applyFilter(filter);
},
- saveAs: function () {
- var query = this.options.app.controller.getQuery('&'),
- url = '/issues/save_as_form?' + query;
+ saveAs () {
+ const query = this.options.app.controller.getQuery('&');
+ const url = '/issues/save_as_form?' + query;
window.openModalWindow(url, {});
},
- save: function () {
- var that = this;
- var query = this.options.app.controller.getQuery('&'),
- url = '/issues/save/' + (this.options.app.state.get('filter').id) + '?' + query;
+ save () {
+ const that = this;
+ const query = this.options.app.controller.getQuery('&');
+ const url = '/issues/save/' + (this.options.app.state.get('filter').id) + '?' + query;
return $.post(url).done(function () {
return that.options.app.state.set({ changed: false });
});
},
- copy: function () {
- var url = '/issues/copy_form/' + (this.options.app.state.get('filter').id);
+ copy () {
+ const url = '/issues/copy_form/' + (this.options.app.state.get('filter').id);
window.openModalWindow(url, {});
},
- edit: function () {
- var url = '/issues/edit_form/' + (this.options.app.state.get('filter').id);
+ edit () {
+ const url = '/issues/edit_form/' + (this.options.app.state.get('filter').id);
window.openModalWindow(url, {});
},
- serializeData: function () {
- var filter = this.options.app.state.get('filter');
+ serializeData () {
+ const filter = this.options.app.state.get('filter');
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
state: this.options.app.state.toJSON(),
filter: filter != null ? filter.toJSON() : null,
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 5187bd29b58..78690a109a0 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
@@ -25,14 +25,14 @@ import Template from './templates/issues-issue-filter-form.hbs';
export default ActionOptionsView.extend({
template: Template,
- selectOption: function (e) {
- var property = $(e.currentTarget).data('property'),
- value = $(e.currentTarget).data('value');
+ selectOption (e) {
+ const property = $(e.currentTarget).data('property');
+ const value = $(e.currentTarget).data('value');
this.trigger('select', property, value);
ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- serializeData: function () {
+ serializeData () {
return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), {
s: this.model.get('severity')
});
diff --git a/server/sonar-web/src/main/js/apps/issues/layout.js b/server/sonar-web/src/main/js/apps/issues/layout.js
index f69ad5c8dfe..14bd310f0ff 100644
--- a/server/sonar-web/src/main/js/apps/issues/layout.js
+++ b/server/sonar-web/src/main/js/apps/issues/layout.js
@@ -34,39 +34,39 @@ export default Marionette.LayoutView.extend({
workspaceHomeRegion: '.issues-workspace-home'
},
- onRender: function () {
+ onRender () {
if (this.options.app.state.get('isContext')) {
this.$(this.filtersRegion.el).addClass('hidden');
}
this.$('.search-navigator').addClass('sticky');
- var top = this.$('.search-navigator').offset().top;
- this.$('.search-navigator-workspace-header').css({ top: top });
- this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+ const top = this.$('.search-navigator').offset().top;
+ this.$('.search-navigator-workspace-header').css({ top });
+ this.$('.search-navigator-side').css({ top }).isolatedScroll();
},
- showSpinner: function (region) {
+ showSpinner (region) {
return this[region].show(new Marionette.ItemView({
template: _.template('<i class="spinner"></i>')
}));
},
- showComponentViewer: function () {
+ showComponentViewer () {
this.scroll = $(window).scrollTop();
this.$('.issues').addClass('issues-extended-view');
},
- hideComponentViewer: function () {
+ hideComponentViewer () {
this.$('.issues').removeClass('issues-extended-view');
if (this.scroll != null) {
$(window).scrollTop(this.scroll);
}
},
- showHomePage: function () {
+ showHomePage () {
this.$('.issues').addClass('issues-home-view');
},
- hideHomePage: function () {
+ hideHomePage () {
this.$('.issues').removeClass('issues-home-view');
}
});
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 c43bd88fa73..2110e307d45 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
@@ -20,11 +20,11 @@
import Backbone from 'backbone';
export default Backbone.Model.extend({
- url: function () {
+ url () {
return '/api/issue_filters/show/' + this.id;
},
- parse: function (r) {
+ parse (r) {
if (r.filter != null) {
return r.filter;
} else {
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 ba3e50c684f..479817bddfb 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
@@ -23,11 +23,11 @@ import Filter from './filter';
export default Backbone.Collection.extend({
model: Filter,
- url: function () {
+ url () {
return '/api/issue_filters/search';
},
- parse: function (r) {
+ parse (r) {
return r.issueFilters;
}
});
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 7909ed67fe5..0209e59e7cc 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
@@ -20,8 +20,8 @@
import Issue from '../../../components/issue/models/issue';
export default Issue.extend({
- reset: function (attrs, options) {
- var keepFields = ['index', 'selected', 'comments'];
+ reset (attrs, options) {
+ const keepFields = ['index', 'selected', 'comments'];
keepFields.forEach(function (field) {
attrs[field] = this.get(field);
}.bind(this));
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 7911332865d..bf64834b6a7 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
@@ -24,19 +24,19 @@ import Issue from './issue';
export default Backbone.Collection.extend({
model: Issue,
- url: function () {
+ url () {
return '/api/issues/search';
},
- _injectRelational: function (issue, source, baseField, lookupField) {
- var baseValue = issue[baseField];
+ _injectRelational (issue, source, baseField, lookupField) {
+ const baseValue = issue[baseField];
if (baseValue != null && _.size(source)) {
- var lookupValue = _.find(source, function (candidate) {
+ const lookupValue = _.find(source, function (candidate) {
return candidate[lookupField] === baseValue;
});
if (lookupValue != null) {
Object.keys(lookupValue).forEach(function (key) {
- var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
+ const newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
issue[newKey] = lookupValue[key];
});
}
@@ -44,11 +44,11 @@ export default Backbone.Collection.extend({
return issue;
},
- _injectCommentsRelational: function (issue, users) {
+ _injectCommentsRelational (issue, users) {
if (issue.comments) {
- var that = this;
- var newComments = issue.comments.map(function (comment) {
- var newComment = _.extend({}, comment, { author: comment.login });
+ const that = this;
+ const newComments = issue.comments.map(function (comment) {
+ let newComment = _.extend({}, comment, { author: comment.login });
delete newComment.login;
newComment = that._injectRelational(newComment, users, 'author', 'login');
return newComment;
@@ -58,7 +58,7 @@ export default Backbone.Collection.extend({
return issue;
},
- _prepareClosed: function (issue) {
+ _prepareClosed (issue) {
if (issue.status === 'CLOSED') {
issue.flows = [];
delete issue.textRange;
@@ -66,7 +66,7 @@ export default Backbone.Collection.extend({
return issue;
},
- ensureTextRange: function (issue) {
+ ensureTextRange (issue) {
if (issue.line && !issue.textRange) {
// FIXME 999999
issue.textRange = {
@@ -79,10 +79,10 @@ export default Backbone.Collection.extend({
return issue;
},
- parseIssues: function (r) {
- var that = this;
+ parseIssues (r) {
+ const that = this;
return r.issues.map(function (issue, index) {
- _.extend(issue, { index: index });
+ _.extend(issue, { index });
issue = that._injectRelational(issue, r.components, 'component', 'key');
issue = that._injectRelational(issue, r.components, 'project', 'key');
issue = that._injectRelational(issue, r.components, 'subProject', 'key');
@@ -97,16 +97,16 @@ export default Backbone.Collection.extend({
});
},
- setIndex: function () {
+ setIndex () {
return this.forEach(function (issue, index) {
- return issue.set({ index: index });
+ return issue.set({ index });
});
},
- selectByKeys: function (keys) {
- var that = this;
+ selectByKeys (keys) {
+ const that = this;
keys.forEach(function (key) {
- var issue = that.get(key);
+ const issue = that.get(key);
if (issue) {
issue.set({ selected: true });
}
diff --git a/server/sonar-web/src/main/js/apps/issues/models/state.js b/server/sonar-web/src/main/js/apps/issues/models/state.js
index 3591f8bc50e..cb0a76b4830 100644
--- a/server/sonar-web/src/main/js/apps/issues/models/state.js
+++ b/server/sonar-web/src/main/js/apps/issues/models/state.js
@@ -73,12 +73,12 @@ export default State.extend({
}
},
- getFacetMode: function () {
- var query = this.get('query');
+ getFacetMode () {
+ const query = this.get('query');
return query.facetMode || 'count';
},
- toJSON: function () {
+ toJSON () {
return _.extend({ facetMode: this.getFacetMode() }, this.attributes);
}
});
diff --git a/server/sonar-web/src/main/js/apps/issues/router.js b/server/sonar-web/src/main/js/apps/issues/router.js
index a41d134dabf..f5d7ac57d93 100644
--- a/server/sonar-web/src/main/js/apps/issues/router.js
+++ b/server/sonar-web/src/main/js/apps/issues/router.js
@@ -25,12 +25,12 @@ export default Router.extend({
':query': 'index'
},
- initialize: function (options) {
+ initialize (options) {
Router.prototype.initialize.apply(this, arguments);
this.listenTo(options.app.state, 'change:filter', this.updateRoute);
},
- home: function () {
+ home () {
if (this.options.app.state.get('isContext')) {
return this.navigate('resolved=false', { trigger: true, replace: true });
} else {
@@ -38,11 +38,11 @@ export default Router.extend({
}
},
- index: function (query) {
- var that = this;
+ index (query) {
+ const that = this;
query = this.options.app.controller.parseQuery(query);
if (query.id != null) {
- var filter = this.options.app.filters.get(query.id);
+ const filter = this.options.app.filters.get(query.id);
delete query.id;
if (Object.keys(query).length > 0) {
that.options.app.controller.applyFilter(filter, true);
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 7d533fe555e..d6ba4728cb2 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
@@ -25,7 +25,7 @@ import Template from './templates/issues-workspace-header.hbs';
export default WorkspaceHeaderView.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(WorkspaceHeaderView.prototype.events.apply(this, arguments), {
'click .js-selection': 'onSelectionClick',
'click .js-back': 'returnToList',
@@ -34,52 +34,52 @@ export default WorkspaceHeaderView.extend({
});
},
- initialize: function () {
+ initialize () {
WorkspaceHeaderView.prototype.initialize.apply(this, arguments);
this._onBulkIssues = window.onBulkIssues;
window.onBulkIssues = _.bind(this.afterBulkChange, this);
},
- onDestroy: function () {
+ onDestroy () {
WorkspaceHeaderView.prototype.onDestroy.apply(this, arguments);
window.onBulkIssues = this._onBulkIssues;
},
- onSelectionClick: function (e) {
+ onSelectionClick (e) {
e.preventDefault();
this.toggleSelection();
},
- onBulkChangeSelectedClick: function (e) {
+ onBulkChangeSelectedClick (e) {
e.preventDefault();
this.bulkChangeSelected();
},
- afterBulkChange: function () {
- var that = this;
+ afterBulkChange () {
+ const that = this;
$('#modal').dialog('close');
- var selectedIndex = this.options.app.state.get('selectedIndex');
- var selectedKeys = _.pluck(this.options.app.list.where({ selected: true }), 'id');
+ const selectedIndex = this.options.app.state.get('selectedIndex');
+ const selectedKeys = _.pluck(this.options.app.list.where({ selected: true }), 'id');
this.options.app.controller.fetchList().done(function () {
- that.options.app.state.set({ selectedIndex: selectedIndex });
+ that.options.app.state.set({ selectedIndex });
that.options.app.list.selectByKeys(selectedKeys);
});
},
- render: function () {
+ render () {
if (!this._suppressUpdate) {
WorkspaceHeaderView.prototype.render.apply(this, arguments);
}
},
- toggleSelection: function () {
+ toggleSelection () {
this._suppressUpdate = true;
- var selectedCount = this.options.app.list.where({ selected: true }).length,
- someSelected = selectedCount > 0;
+ const selectedCount = this.options.app.list.where({ selected: true }).length;
+ const someSelected = selectedCount > 0;
return someSelected ? this.selectNone() : this.selectAll();
},
- selectNone: function () {
+ selectNone () {
this.options.app.list.where({ selected: true }).forEach(function (issue) {
issue.set({ selected: false });
});
@@ -87,7 +87,7 @@ export default WorkspaceHeaderView.extend({
this.render();
},
- selectAll: function () {
+ selectAll () {
this.options.app.list.forEach(function (issue) {
issue.set({ selected: true });
});
@@ -95,37 +95,37 @@ export default WorkspaceHeaderView.extend({
this.render();
},
- returnToList: function () {
+ returnToList () {
this.options.app.controller.closeComponentViewer();
},
- newSearch: function () {
+ newSearch () {
this.options.app.controller.newSearch();
},
- bulkChange: function () {
- var query = this.options.app.controller.getQuery('&', true),
- url = '/issues/bulk_change_form?' + query;
+ bulkChange () {
+ const query = this.options.app.controller.getQuery('&', true);
+ const url = '/issues/bulk_change_form?' + query;
window.openModalWindow(url, {});
},
- bulkChangeSelected: function () {
- var selected = this.options.app.list.where({ selected: true }),
- selectedKeys = _.first(_.pluck(selected, 'id'), 200),
- query = 'issues=' + selectedKeys.join(),
- url = '/issues/bulk_change_form?' + query;
+ bulkChangeSelected () {
+ const selected = this.options.app.list.where({ selected: true });
+ const selectedKeys = _.first(_.pluck(selected, 'id'), 200);
+ const query = 'issues=' + selectedKeys.join();
+ const url = '/issues/bulk_change_form?' + query;
window.openModalWindow(url, {});
},
- serializeData: function () {
- var issuesCount = this.options.app.list.length,
- selectedCount = this.options.app.list.where({ selected: true }).length,
- allSelected = issuesCount > 0 && issuesCount === selectedCount,
- someSelected = !allSelected && selectedCount > 0;
+ serializeData () {
+ const issuesCount = this.options.app.list.length;
+ const selectedCount = this.options.app.list.where({ selected: true }).length;
+ const allSelected = issuesCount > 0 && issuesCount === selectedCount;
+ const someSelected = !allSelected && selectedCount > 0;
return _.extend(WorkspaceHeaderView.prototype.serializeData.apply(this, arguments), {
- selectedCount: selectedCount,
- allSelected: allSelected,
- someSelected: someSelected
+ selectedCount,
+ allSelected,
+ someSelected
});
}
});
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 11fd1f23795..c310b32c0d4 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
@@ -23,7 +23,7 @@ import { translate } from '../../helpers/l10n';
export default Marionette.ItemView.extend({
className: 'search-navigator-no-results',
- template: function () {
+ template () {
return translate('issue_filter.no_issues');
}
});
diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js
index 91b64130246..ff9a75d095f 100644
--- a/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js
+++ b/server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js
@@ -24,7 +24,7 @@ import IssueFilterView from './issue-filter-view';
import CheckboxTemplate from './templates/issues-issue-checkbox.hbs';
import FilterTemplate from './templates/issues-issue-filter.hbs';
-var SHOULD_NULL = {
+const SHOULD_NULL = {
any: ['issues'],
resolutions: ['resolved'],
resolved: ['resolutions'],
@@ -38,7 +38,7 @@ export default IssueView.extend({
checkboxTemplate: CheckboxTemplate,
filterTemplate: FilterTemplate,
- events: function () {
+ events () {
return _.extend(IssueView.prototype.events.apply(this, arguments), {
'click': 'selectCurrent',
'dblclick': 'openComponentViewer',
@@ -48,12 +48,12 @@ export default IssueView.extend({
});
},
- initialize: function (options) {
+ initialize (options) {
IssueView.prototype.initialize.apply(this, arguments);
this.listenTo(options.app.state, 'change:selectedIndex', this.select);
},
- onRender: function () {
+ onRender () {
IssueView.prototype.onRender.apply(this, arguments);
this.select();
this.addFilterSelect();
@@ -64,8 +64,8 @@ export default IssueView.extend({
}
},
- onIssueFilterClick: function (e) {
- var that = this;
+ onIssueFilterClick (e) {
+ const that = this;
e.preventDefault();
e.stopPropagation();
$('body').click();
@@ -75,8 +75,7 @@ export default IssueView.extend({
model: this.model
});
this.popup.on('select', function (property, value) {
- var obj;
- obj = {};
+ const obj = {};
obj[property] = '' + value;
SHOULD_NULL.any.forEach(function (p) {
obj[p] = null;
@@ -92,50 +91,50 @@ export default IssueView.extend({
this.popup.render();
},
- onIssueToggle: function (e) {
+ onIssueToggle (e) {
e.preventDefault();
this.model.set({ selected: !this.model.get('selected') });
- var selected = this.model.collection.where({ selected: true }).length;
- this.options.app.state.set({ selected: selected });
+ const selected = this.model.collection.where({ selected: true }).length;
+ this.options.app.state.set({ selected });
},
- addFilterSelect: function () {
+ addFilterSelect () {
this.$('.issue-table-meta-cell-first')
.find('.issue-meta-list')
.append(this.filterTemplate(this.model.toJSON()));
},
- addCheckbox: function () {
+ addCheckbox () {
this.$el.append(this.checkboxTemplate(this.model.toJSON()));
},
- select: function () {
- var selected = this.model.get('index') === this.options.app.state.get('selectedIndex');
+ select () {
+ const selected = this.model.get('index') === this.options.app.state.get('selectedIndex');
this.$el.toggleClass('selected', selected);
},
- selectCurrent: function () {
+ selectCurrent () {
this.options.app.state.set({ selectedIndex: this.model.get('index') });
},
- resetIssue: function (options) {
- var that = this;
- var key = this.model.get('key'),
- componentUuid = this.model.get('componentUuid'),
- index = this.model.get('index'),
- selected = this.model.get('selected');
+ resetIssue (options) {
+ const that = this;
+ const key = this.model.get('key');
+ const componentUuid = this.model.get('componentUuid');
+ const index = this.model.get('index');
+ const selected = this.model.get('selected');
this.model.reset({
- key: key,
- componentUuid: componentUuid,
- index: index,
- selected: selected
+ key,
+ componentUuid,
+ index,
+ selected
}, { silent: true });
return this.model.fetch(options).done(function () {
return that.trigger('reset');
});
},
- openComponentViewer: function () {
+ openComponentViewer () {
this.options.app.state.set({ selectedIndex: this.model.get('index') });
if (this.options.app.state.has('component')) {
return this.options.app.controller.closeComponentViewer();
@@ -144,7 +143,7 @@ export default IssueView.extend({
}
},
- serializeData: function () {
+ serializeData () {
return _.extend(IssueView.prototype.serializeData.apply(this, arguments), {
showComponent: true
});
diff --git a/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js b/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js
index 6e471a45d12..00e1f4cb558 100644
--- a/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js
+++ b/server/sonar-web/src/main/js/apps/issues/workspace-list-view.js
@@ -24,8 +24,8 @@ import EmptyView from './workspace-list-empty-view';
import Template from './templates/issues-workspace-list.hbs';
import ComponentTemplate from './templates/issues-workspace-list-component.hbs';
-var COMPONENT_HEIGHT = 29,
- BOTTOM_OFFSET = 60;
+const COMPONENT_HEIGHT = 29;
+const BOTTOM_OFFSET = 60;
export default WorkspaceListView.extend({
template: Template,
@@ -34,24 +34,24 @@ export default WorkspaceListView.extend({
childViewContainer: '.js-list',
emptyView: EmptyView,
- bindShortcuts: function () {
- var that = this;
- var doAction = function (action) {
- var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
+ bindShortcuts () {
+ const that = this;
+ const doAction = function (action) {
+ const selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
if (selectedIssue == null) {
return;
}
- var selectedIssueView = that.children.findByModel(selectedIssue);
+ const selectedIssueView = that.children.findByModel(selectedIssue);
selectedIssueView.$('.js-issue-' + action).click();
};
WorkspaceListView.prototype.bindShortcuts.apply(this, arguments);
key('right', 'list', function () {
- var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
+ const selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
that.options.app.controller.showComponentViewer(selectedIssue);
return false;
});
key('space', 'list', function () {
- var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
+ const selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
selectedIssue.set({ selected: !selectedIssue.get('selected') });
return false;
});
@@ -78,7 +78,7 @@ export default WorkspaceListView.extend({
});
},
- unbindShortcuts: function () {
+ unbindShortcuts () {
WorkspaceListView.prototype.unbindShortcuts.apply(this, arguments);
key.unbind('right', 'list');
key.unbind('space', 'list');
@@ -91,20 +91,20 @@ export default WorkspaceListView.extend({
key.unbind('t', 'list');
},
- scrollTo: function () {
- var selectedIssue = this.collection.at(this.options.app.state.get('selectedIndex'));
+ scrollTo () {
+ const selectedIssue = this.collection.at(this.options.app.state.get('selectedIndex'));
if (selectedIssue == null) {
return;
}
- var selectedIssueView = this.children.findByModel(selectedIssue),
- parentTopOffset = this.$el.offset().top,
- viewTop = selectedIssueView.$el.offset().top - parentTopOffset;
+ const selectedIssueView = this.children.findByModel(selectedIssue);
+ const parentTopOffset = this.$el.offset().top;
+ let viewTop = selectedIssueView.$el.offset().top - parentTopOffset;
if (selectedIssueView.$el.prev().is('.issues-workspace-list-component')) {
viewTop -= COMPONENT_HEIGHT;
}
- var viewBottom = selectedIssueView.$el.offset().top + selectedIssueView.$el.outerHeight() + BOTTOM_OFFSET,
- windowTop = $(window).scrollTop(),
- windowBottom = windowTop + $(window).height();
+ const viewBottom = selectedIssueView.$el.offset().top + selectedIssueView.$el.outerHeight() + BOTTOM_OFFSET;
+ const windowTop = $(window).scrollTop();
+ const windowBottom = windowTop + $(window).height();
if (viewTop < windowTop) {
$(window).scrollTop(viewTop);
}
@@ -113,15 +113,15 @@ export default WorkspaceListView.extend({
}
},
- attachHtml: function (compositeView, childView, index) {
- var $container = this.getChildViewContainer(compositeView),
- model = this.collection.at(index);
+ attachHtml (compositeView, childView, index) {
+ const $container = this.getChildViewContainer(compositeView);
+ const model = this.collection.at(index);
if (model != null) {
- var prev = index > 0 && this.collection.at(index - 1),
- putComponent = !prev;
+ const prev = index > 0 && this.collection.at(index - 1);
+ let putComponent = !prev;
if (prev) {
- var fullComponent = [model.get('project'), model.get('component')].join(' '),
- fullPrevComponent = [prev.get('project'), prev.get('component')].join(' ');
+ const fullComponent = [model.get('project'), model.get('component')].join(' ');
+ const fullPrevComponent = [prev.get('project'), prev.get('component')].join(' ');
if (fullComponent !== fullPrevComponent) {
putComponent = true;
}
@@ -133,7 +133,7 @@ export default WorkspaceListView.extend({
$container.append(childView.el);
},
- destroyChildren: function () {
+ destroyChildren () {
WorkspaceListView.prototype.destroyChildren.apply(this, arguments);
this.$('.issues-workspace-list-component').remove();
}
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 b184e907091..77f9db94568 100644
--- a/server/sonar-web/src/main/js/apps/maintenance/app.js
+++ b/server/sonar-web/src/main/js/apps/maintenance/app.js
@@ -22,15 +22,15 @@ import Backbone from 'backbone';
import Marionette from 'backbone.marionette';
import MainView from './main-view';
-var App = new Marionette.Application();
+const App = new Marionette.Application();
App.on('start', function () {
let options = window.sonarqube;
- var viewOptions = _.extend(options, {
+ const viewOptions = _.extend(options, {
model: new Backbone.Model()
});
- var mainView = new MainView(viewOptions);
+ const mainView = new MainView(viewOptions);
mainView.render().refresh();
});
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 a7bfdac0cc6..d083fdb7be4 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
@@ -30,8 +30,8 @@ export default Marionette.ItemView.extend({
'click #start-migration': 'startMigration'
},
- initialize: function () {
- var that = this;
+ initialize () {
+ const that = this;
this.requestOptions = {
type: 'GET',
url: '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status')
@@ -41,8 +41,8 @@ export default Marionette.ItemView.extend({
}, 5000);
},
- refresh: function () {
- var that = this;
+ refresh () {
+ const that = this;
return Backbone.ajax(this.requestOptions).done(function (r) {
that.model.set(r);
that.render();
@@ -55,12 +55,12 @@ export default Marionette.ItemView.extend({
});
},
- stopPolling: function () {
+ stopPolling () {
clearInterval(this.pollingInternal);
},
- startMigration: function () {
- var that = this;
+ startMigration () {
+ const that = this;
Backbone.ajax({
url: '/api/system/migrate_db',
type: 'POST'
@@ -70,17 +70,17 @@ export default Marionette.ItemView.extend({
});
},
- onRender: function () {
+ onRender () {
$('.page-simple').toggleClass('panel-warning', this.model.get('state') === 'MIGRATION_REQUIRED');
},
- goHome: function () {
+ goHome () {
setInterval(function () {
window.location = '/';
}, 2500);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
setup: this.options.setup
});
diff --git a/server/sonar-web/src/main/js/apps/markdown/app.js b/server/sonar-web/src/main/js/apps/markdown/app.js
index d2debd49111..7fb723f89da 100644
--- a/server/sonar-web/src/main/js/apps/markdown/app.js
+++ b/server/sonar-web/src/main/js/apps/markdown/app.js
@@ -20,7 +20,7 @@
import Marionette from 'backbone.marionette';
import MarkdownView from './markdown-help-view';
-var App = new Marionette.Application();
+const App = new Marionette.Application();
App.on('start', function () {
let options = window.sonarqube;
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 deaf13a6472..6492108fa92 100644
--- a/server/sonar-web/src/main/js/apps/measures/app.js
+++ b/server/sonar-web/src/main/js/apps/measures/app.js
@@ -30,146 +30,141 @@ import StringFilterView from '../../components/navigator/filters/string-filters'
import MetricFilterView from '../../components/navigator/filters/metric-filters';
import { translate } from '../../helpers/l10n';
-var NavigatorApp = new Marionette.Application(),
-
- newLastAnalysisFilter = function () {
- return new BaseFilters.Filter({
- name: translate('measure_filter.criteria.last_analysis'),
- propertyFrom: 'ageMinDays',
- propertyTo: 'ageMaxDays',
- type: RangeFilters.RangeFilterView,
- placeholder: translate('measure_filter.criteria.age.days'),
- enabled: false,
- optional: true
- });
- },
-
- newMetricFilter = function (property) {
- return new BaseFilters.Filter({
- name: translate('measure_filter.criteria.metric'),
- property: property,
- type: MetricFilterView,
- metrics: window.SS.metrics,
- periods: window.SS.metricPeriods,
- operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
- enabled: false,
- optional: true
- });
- },
-
- newNameFilter = function () {
- return new BaseFilters.Filter({
- name: translate('measure_filter.name_contains'),
- property: 'nameSearch',
- type: StringFilterView,
- enabled: false,
- optional: true
- });
- },
-
- newAlertFilter = function () {
- return new BaseFilters.Filter({
- name: translate('measure_filter.criteria.alert'),
- property: 'alertLevels[]',
- type: ChoiceFilters.ChoiceFilterView,
- enabled: false,
- optional: true,
- choices: {
- 'error': translate('measure_filter.criteria.alert.error'),
- 'warn': translate('measure_filter.criteria.alert.warn'),
- 'ok': translate('measure_filter.criteria.alert.ok')
- }
- });
- },
-
- init = function () {
- NavigatorApp.addRegions({ filtersRegion: '.navigator-filters' });
-
- this.filters = new BaseFilters.Filters();
-
- if (_.isObject(window.SS.favorites)) {
- this.filters.add([
- new BaseFilters.Filter({
- type: FavoriteFilters.FavoriteFilterView,
- enabled: true,
- optional: false,
- choices: window.SS.favorites,
- favoriteUrl: '/measures/filter',
- manageUrl: '/measures/manage'
- })
- ]);
- }
-
- this.filters.add([
- new BaseFilters.Filter({
- name: translate('measure_filter.criteria.components'),
- property: 'qualifiers[]',
- type: ChoiceFilters.ChoiceFilterView,
- enabled: true,
- optional: false,
- choices: window.SS.qualifiers,
- defaultValue: translate('any')
- }),
-
- new BaseFilters.Filter({
- name: translate('measure_filter.criteria.components_of'),
- property: 'base',
- type: AjaxSelectFilters.ComponentFilterView,
- multiple: false,
- enabled: false,
- optional: true
- }),
-
- new BaseFilters.Filter({
- name: translate('measure_filter.criteria.only_favorites'),
- property: 'onFavourites',
- type: CheckboxFilterView,
- enabled: false,
- optional: true
- }),
-
- new BaseFilters.Filter({
- name: translate('measure_filter.criteria.date'),
- propertyFrom: 'fromDate',
- propertyTo: 'toDate',
- type: RangeFilters.DateRangeFilterView,
- enabled: false,
- optional: true
- }),
-
- new BaseFilters.Filter({
- name: translate('measure_filter.criteria.key_contains'),
- property: 'keySearch',
- type: StringFilterView,
- enabled: false,
- optional: true
- })
- ]);
-
- this.filters.add([
- newLastAnalysisFilter(),
- newMetricFilter('c3'),
- newMetricFilter('c2'),
- newMetricFilter('c1'),
- newNameFilter(),
- newAlertFilter()
- ]);
-
- this.filterBarView = new FilterBar({
- collection: this.filters,
- extra: {
- sort: '',
- asc: false
- }
- });
-
- this.filtersRegion.show(this.filterBarView);
-
- if (window.queryParams) {
- NavigatorApp.filterBarView.restoreFromQuery(window.queryParams);
- }
- key.setScope('list');
- };
+const NavigatorApp = new Marionette.Application();
+const newLastAnalysisFilter = function () {
+ return new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.last_analysis'),
+ propertyFrom: 'ageMinDays',
+ propertyTo: 'ageMaxDays',
+ type: RangeFilters.RangeFilterView,
+ placeholder: translate('measure_filter.criteria.age.days'),
+ enabled: false,
+ optional: true
+ });
+};
+const newMetricFilter = function (property) {
+ return new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.metric'),
+ property,
+ type: MetricFilterView,
+ metrics: window.SS.metrics,
+ periods: window.SS.metricPeriods,
+ operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+ enabled: false,
+ optional: true
+ });
+};
+const newNameFilter = function () {
+ return new BaseFilters.Filter({
+ name: translate('measure_filter.name_contains'),
+ property: 'nameSearch',
+ type: StringFilterView,
+ enabled: false,
+ optional: true
+ });
+};
+const newAlertFilter = function () {
+ return new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.alert'),
+ property: 'alertLevels[]',
+ type: ChoiceFilters.ChoiceFilterView,
+ enabled: false,
+ optional: true,
+ choices: {
+ 'error': translate('measure_filter.criteria.alert.error'),
+ 'warn': translate('measure_filter.criteria.alert.warn'),
+ 'ok': translate('measure_filter.criteria.alert.ok')
+ }
+ });
+};
+const init = function () {
+ NavigatorApp.addRegions({ filtersRegion: '.navigator-filters' });
+
+ this.filters = new BaseFilters.Filters();
+
+ if (_.isObject(window.SS.favorites)) {
+ this.filters.add([
+ new BaseFilters.Filter({
+ type: FavoriteFilters.FavoriteFilterView,
+ enabled: true,
+ optional: false,
+ choices: window.SS.favorites,
+ favoriteUrl: '/measures/filter',
+ manageUrl: '/measures/manage'
+ })
+ ]);
+ }
+
+ this.filters.add([
+ new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.components'),
+ property: 'qualifiers[]',
+ type: ChoiceFilters.ChoiceFilterView,
+ enabled: true,
+ optional: false,
+ choices: window.SS.qualifiers,
+ defaultValue: translate('any')
+ }),
+
+ new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.components_of'),
+ property: 'base',
+ type: AjaxSelectFilters.ComponentFilterView,
+ multiple: false,
+ enabled: false,
+ optional: true
+ }),
+
+ new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.only_favorites'),
+ property: 'onFavourites',
+ type: CheckboxFilterView,
+ enabled: false,
+ optional: true
+ }),
+
+ new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.date'),
+ propertyFrom: 'fromDate',
+ propertyTo: 'toDate',
+ type: RangeFilters.DateRangeFilterView,
+ enabled: false,
+ optional: true
+ }),
+
+ new BaseFilters.Filter({
+ name: translate('measure_filter.criteria.key_contains'),
+ property: 'keySearch',
+ type: StringFilterView,
+ enabled: false,
+ optional: true
+ })
+ ]);
+
+ this.filters.add([
+ newLastAnalysisFilter(),
+ newMetricFilter('c3'),
+ newMetricFilter('c2'),
+ newMetricFilter('c1'),
+ newNameFilter(),
+ newAlertFilter()
+ ]);
+
+ this.filterBarView = new FilterBar({
+ collection: this.filters,
+ extra: {
+ sort: '',
+ asc: false
+ }
+ });
+
+ this.filtersRegion.show(this.filterBarView);
+
+ if (window.queryParams) {
+ NavigatorApp.filterBarView.restoreFromQuery(window.queryParams);
+ }
+ key.setScope('list');
+};
NavigatorApp.on('start', function () {
init.call(NavigatorApp);
diff --git a/server/sonar-web/src/main/js/apps/measures/measures-filter-bar.js b/server/sonar-web/src/main/js/apps/measures/measures-filter-bar.js
index db813fd607d..bec20727db8 100644
--- a/server/sonar-web/src/main/js/apps/measures/measures-filter-bar.js
+++ b/server/sonar-web/src/main/js/apps/measures/measures-filter-bar.js
@@ -21,7 +21,7 @@ import $ from 'jquery';
import FilterBarView from '../../components/navigator/filters/filter-bar';
export default FilterBarView.extend({
- template: function () {
+ template () {
return $('#filter-bar-template').html();
}
});
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 d6318adaef2..eafe6ec33e0 100644
--- a/server/sonar-web/src/main/js/apps/metrics/app.js
+++ b/server/sonar-web/src/main/js/apps/metrics/app.js
@@ -25,41 +25,41 @@ import HeaderView from './header-view';
import ListView from './list-view';
import ListFooterView from './list-footer-view';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- // Layout
- this.layout = new Layout({ el: options.el });
- this.layout.render();
+ // Layout
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
- // Collection
- this.metrics = new Metrics();
+ // Collection
+ this.metrics = new Metrics();
- // Header View
- this.headerView = new HeaderView({
- collection: this.metrics,
- domains: this.domains,
- types: this.types,
- app: App
- });
- this.layout.headerRegion.show(this.headerView);
+ // Header View
+ this.headerView = new HeaderView({
+ collection: this.metrics,
+ domains: this.domains,
+ types: this.types,
+ app: App
+ });
+ this.layout.headerRegion.show(this.headerView);
- // List View
- this.listView = new ListView({
- collection: this.metrics,
- domains: this.domains,
- types: this.types
- });
- this.layout.listRegion.show(this.listView);
+ // List View
+ this.listView = new ListView({
+ collection: this.metrics,
+ domains: this.domains,
+ types: this.types
+ });
+ this.layout.listRegion.show(this.listView);
- // List Footer View
- this.listFooterView = new ListFooterView({ collection: this.metrics });
- this.layout.listFooterRegion.show(this.listFooterView);
+ // List Footer View
+ this.listFooterView = new ListFooterView({ collection: this.metrics });
+ this.layout.listFooterRegion.show(this.listFooterView);
- // Go!
- this.metrics.fetch();
- };
+ // Go!
+ this.metrics.fetch();
+};
App.requestDomains = function () {
diff --git a/server/sonar-web/src/main/js/apps/metrics/create-view.js b/server/sonar-web/src/main/js/apps/metrics/create-view.js
index d34d8fd6eb7..382146c12ec 100644
--- a/server/sonar-web/src/main/js/apps/metrics/create-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/create-view.js
@@ -22,15 +22,15 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this,
- metric = new Metric({
- key: this.$('#create-metric-key').val(),
- name: this.$('#create-metric-name').val(),
- description: this.$('#create-metric-description').val(),
- domain: this.$('#create-metric-domain').val(),
- type: this.$('#create-metric-type').val()
- });
+ sendRequest () {
+ const that = this;
+ const metric = new Metric({
+ key: this.$('#create-metric-key').val(),
+ name: this.$('#create-metric-name').val(),
+ description: this.$('#create-metric-description').val(),
+ domain: this.$('#create-metric-domain').val(),
+ type: this.$('#create-metric-type').val()
+ });
this.disableForm();
return metric.save(null, {
statusCode: {
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 9ea492b9b4d..a63999b2e6a 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
@@ -23,14 +23,14 @@ import Template from './templates/metrics-delete.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- collection = this.model.collection;
+ sendRequest () {
+ const that = this;
+ const collection = this.model.collection;
return this.model.destroy({
wait: true,
statusCode: {
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 6451e5e2b72..56b40d9eca2 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
@@ -25,44 +25,44 @@ import Template from './templates/metrics-form.hbs';
export default ModalForm.extend({
template: Template,
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
ModalForm.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
this.$('#create-metric-domain').select2({
width: '250px',
- createSearchChoice: function (term) {
+ createSearchChoice (term) {
return { id: term, text: '+' + term };
},
createSearchChoicePosition: 'top',
- initSelection: function (element, callback) {
- var value = $(element).val();
+ initSelection (element, callback) {
+ const value = $(element).val();
callback({ id: value, text: value });
},
- query: function (options) {
- var items = that.options.domains.filter(function (d) {
- return d.toLowerCase().indexOf(options.term.toLowerCase()) !== -1;
- }),
- results = items.map(function (item) {
- return { id: item, text: item };
- });
- options.callback({ results: results, more: false });
+ query (options) {
+ const items = that.options.domains.filter(function (d) {
+ return d.toLowerCase().indexOf(options.term.toLowerCase()) !== -1;
+ });
+ const results = items.map(function (item) {
+ return { id: item, text: item };
+ });
+ options.callback({ results, more: false });
}
}).select2('val', this.model && this.model.get('domain'));
this.$('#create-metric-type').select2({ width: '250px' });
},
- onDestroy: function () {
+ onDestroy () {
ModalForm.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- serializeData: function () {
+ serializeData () {
return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
domains: this.options.domains,
types: this.options.types
diff --git a/server/sonar-web/src/main/js/apps/metrics/header-view.js b/server/sonar-web/src/main/js/apps/metrics/header-view.js
index a5b92942521..a319ad9791e 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
@@ -28,12 +28,12 @@ export default Marionette.ItemView.extend({
'click #metrics-create': 'onCreateClick'
},
- onCreateClick: function (e) {
+ onCreateClick (e) {
e.preventDefault();
this.createMetric();
},
- createMetric: function () {
+ createMetric () {
new CreateView({
collection: this.collection,
domains: this.options.domains,
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 000da6d3186..b2e1cd2bdc2 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
@@ -32,16 +32,16 @@ export default Marionette.ItemView.extend({
'click #metrics-fetch-more': 'onMoreClick'
},
- onMoreClick: function (e) {
+ onMoreClick (e) {
e.preventDefault();
this.fetchMore();
},
- fetchMore: function () {
+ fetchMore () {
this.collection.fetchMore();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
total: this.collection.total,
count: this.collection.length,
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 b238595302e..497922782c1 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
@@ -32,28 +32,28 @@ export default Marionette.ItemView.extend({
'click .js-metric-delete': 'onDeleteClick'
},
- onRender: function () {
+ onRender () {
this.$el
.attr('data-id', this.model.id)
.attr('data-key', this.model.get('key'));
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onUpdateClick: function (e) {
+ onUpdateClick (e) {
e.preventDefault();
this.updateMetric();
},
- onDeleteClick: function (e) {
+ onDeleteClick (e) {
e.preventDefault();
this.deleteMetric();
},
- updateMetric: function () {
+ updateMetric () {
new UpdateView({
model: this.model,
collection: this.model.collection,
@@ -62,7 +62,7 @@ export default Marionette.ItemView.extend({
}).render();
},
- deleteMetric: function () {
+ deleteMetric () {
new DeleteView({ model: this.model }).render();
}
});
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 c527a5aa916..77ab1dbff4f 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
@@ -24,7 +24,7 @@ export default Marionette.CollectionView.extend({
tagName: 'ul',
childView: ListItemView,
- childViewOptions: function () {
+ childViewOptions () {
return {
types: this.options.types,
domains: this.options.domains
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 395778d8b94..ee8bc9b473e 100644
--- a/server/sonar-web/src/main/js/apps/metrics/metric.js
+++ b/server/sonar-web/src/main/js/apps/metrics/metric.js
@@ -23,12 +23,12 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
idAttribute: 'id',
- urlRoot: function () {
+ urlRoot () {
return '/api/metrics';
},
- sync: function (method, model, options) {
- var opts = options || {};
+ sync (method, model, options) {
+ const opts = options || {};
if (method === 'create') {
_.defaults(opts, {
url: this.urlRoot() + '/create',
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 31613599f30..51e041ad120 100644
--- a/server/sonar-web/src/main/js/apps/metrics/metrics.js
+++ b/server/sonar-web/src/main/js/apps/metrics/metrics.js
@@ -24,34 +24,34 @@ import Metric from './metric';
export default Backbone.Collection.extend({
model: Metric,
- url: function () {
+ url () {
return '/api/metrics/search';
},
- parse: function (r) {
+ parse (r) {
this.total = r.total;
this.p = r.p;
this.ps = r.ps;
return r.metrics;
},
- fetch: function (options) {
- var opts = _.defaults(options || {}, { data: {} });
+ fetch (options) {
+ const opts = _.defaults(options || {}, { data: {} });
this.q = opts.data.q;
opts.data.isCustom = true;
return Backbone.Collection.prototype.fetch.call(this, opts);
},
- fetchMore: function () {
- var p = this.p + 1;
- return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps, q: this.q } });
+ fetchMore () {
+ const p = this.p + 1;
+ return this.fetch({ add: true, remove: false, data: { p, ps: this.ps, q: this.q } });
},
- refresh: function () {
+ refresh () {
return this.fetch({ reset: true, data: { q: this.q } });
},
- hasMore: function () {
+ hasMore () {
return this.total > this.p * this.ps;
}
diff --git a/server/sonar-web/src/main/js/apps/metrics/update-view.js b/server/sonar-web/src/main/js/apps/metrics/update-view.js
index fe09aa5592f..915e2f8a23d 100644
--- a/server/sonar-web/src/main/js/apps/metrics/update-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/update-view.js
@@ -21,8 +21,8 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this;
+ sendRequest () {
+ const that = this;
this.model.set({
key: this.$('#create-metric-key').val(),
name: this.$('#create-metric-name').val(),
diff --git a/server/sonar-web/src/main/js/apps/overview/app.js b/server/sonar-web/src/main/js/apps/overview/app.js
index 53ea76de36a..bc8f6322409 100644
--- a/server/sonar-web/src/main/js/apps/overview/app.js
+++ b/server/sonar-web/src/main/js/apps/overview/app.js
@@ -40,7 +40,7 @@ class App {
if (opts.component.hasSnapshot) {
ReactDOM.render(<Overview {...opts} leakPeriodIndex={LEAK_PERIOD}/>, el);
} else {
- ReactDOM.render(<EmptyOverview {...opts}/>, el);
+ ReactDOM.render(<EmptyOverview {...opts}/>, el);
}
}
}
diff --git a/server/sonar-web/src/main/js/apps/overview/components/complexity-distribution.js b/server/sonar-web/src/main/js/apps/overview/components/complexity-distribution.js
index daa9b8141bd..2aa2d4c03f0 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/complexity-distribution.js
+++ b/server/sonar-web/src/main/js/apps/overview/components/complexity-distribution.js
@@ -40,8 +40,8 @@ export const ComplexityDistribution = React.createClass({
let value = parseInt(tokens[0], 10);
return {
x: index,
- y: y,
- value: value,
+ y,
+ value,
tooltip: translateWithParameters(`overview.complexity_tooltip.${this.props.of}`, y, value)
};
});
diff --git a/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js b/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js
index 6554987adf6..05f4a7a15ca 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js
+++ b/server/sonar-web/src/main/js/apps/overview/components/domain-bubble-chart.js
@@ -70,7 +70,7 @@ export class DomainBubbleChart extends React.Component {
});
this.setState({
loading: false,
- files: files,
+ files,
total: files.length
});
});
diff --git a/server/sonar-web/src/main/js/apps/overview/components/domain-timeline.js b/server/sonar-web/src/main/js/apps/overview/components/domain-timeline.js
index 269389b22d2..d53b2d09cea 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/domain-timeline.js
+++ b/server/sonar-web/src/main/js/apps/overview/components/domain-timeline.js
@@ -94,7 +94,7 @@ export const DomainTimeline = React.createClass({
comparisonMetric = '';
}
this.requestTimeMachineData(newMetric, comparisonMetric).then(snapshots => {
- this.setState({ currentMetric: newMetric, comparisonMetric: comparisonMetric, snapshots });
+ this.setState({ currentMetric: newMetric, comparisonMetric, snapshots });
});
},
diff --git a/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js b/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js
index e172ee00102..ab06c2c243f 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js
+++ b/server/sonar-web/src/main/js/apps/overview/components/issue-measure.js
@@ -257,7 +257,7 @@ export const SeverityMeasure = React.createClass({
<small className="flex-1 text-left text-ellipsis">{translate('overview.added')}</small>
<IssuesLink className="text-danger"
component={this.props.component.key}
- params={{ resolved: 'false', severities: this.props.severity, createdAfter: createdAfter }}>
+ params={{ resolved: 'false', severities: this.props.severity, createdAfter }}>
<span className="overview-detailed-measure-value">
{formatMeasure(added, 'SHORT_INT')}
</span>
diff --git a/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js b/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js
index dfe8cff2dbc..88d8f2be593 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js
+++ b/server/sonar-web/src/main/js/apps/overview/components/ncloc-distribution.js
@@ -79,7 +79,7 @@ export const NclocDistribution = React.createClass({
x: component.measures[METRIC] ? parseInt(component.measures[METRIC], 10) : 0,
y: index,
value: component.name,
- component: component
+ component
};
});
diff --git a/server/sonar-web/src/main/js/apps/overview/main/debt.js b/server/sonar-web/src/main/js/apps/overview/main/debt.js
index e378d08a818..51f4c810bd1 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/debt.js
+++ b/server/sonar-web/src/main/js/apps/overview/main/debt.js
@@ -59,13 +59,13 @@ export const GeneralDebt = React.createClass({
<MeasuresList>
<Measure label={getMetricName('new_debt')}>
<IssuesLink component={this.props.component.key}
- params={{ resolved: 'false', createdAfter: createdAfter, facetMode: 'debt' }}>
+ params={{ resolved: 'false', createdAfter, facetMode: 'debt' }}>
{formatMeasure(this.props.leak.debt, 'SHORT_WORK_DUR')}
</IssuesLink>
</Measure>
<Measure label={getMetricName('new_issues')}>
<IssuesLink component={this.props.component.key}
- params={{ resolved: 'false', createdAfter: createdAfter }}>
+ params={{ resolved: 'false', createdAfter }}>
{formatMeasure(this.props.leak.issues, 'SHORT_INT')}
</IssuesLink>
</Measure>
diff --git a/server/sonar-web/src/main/js/apps/overview/main/main.js b/server/sonar-web/src/main/js/apps/overview/main/main.js
index b30234371c5..c9d01b4b87c 100644
--- a/server/sonar-web/src/main/js/apps/overview/main/main.js
+++ b/server/sonar-web/src/main/js/apps/overview/main/main.js
@@ -89,8 +89,8 @@ export default React.createClass({
this.setState({
ready: true,
- measures: measures,
- leak: leak,
+ measures,
+ leak,
coverageMetricPrefix: this.getCoverageMetricPrefix(measures)
}, this.requestHistory);
});
@@ -130,7 +130,7 @@ export default React.createClass({
// FIXME requesting severities facet only to get debtTotal
return getIssuesCount({
componentUuids: this.props.component.id,
- createdAfter: createdAfter,
+ createdAfter,
resolved: 'false',
facets: 'severities'
});
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/app.js b/server/sonar-web/src/main/js/apps/permission-templates/app.js
index 42af280ee9d..f257ec4a95c 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/app.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/app.js
@@ -22,6 +22,6 @@ import ReactDOM from 'react-dom';
import Main from './main';
window.sonarqube.appStarted.then(options => {
- var el = document.querySelector(options.el);
+ const el = document.querySelector(options.el);
ReactDOM.render(<Main topQualifiers={options.rootQualifiers}/>, el);
});
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/create-view.js b/server/sonar-web/src/main/js/apps/permission-templates/create-view.js
index 988afc970e3..9e35862878f 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/create-view.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/create-view.js
@@ -21,8 +21,8 @@ import FormView from './form-view';
import { createPermissionTemplate } from '../../api/permissions';
export default FormView.extend({
- sendRequest: function () {
- var that = this;
+ sendRequest () {
+ const that = this;
this.disableForm();
return createPermissionTemplate({
data: {
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/delete-view.js b/server/sonar-web/src/main/js/apps/permission-templates/delete-view.js
index 1a122486216..7c7dfac5593 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/delete-view.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/delete-view.js
@@ -24,13 +24,13 @@ import Template from './templates/permission-templates-delete.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
- var that = this;
+ sendRequest () {
+ const that = this;
return deletePermissionTemplate({
data: { templateId: this.model.id },
statusCode: {
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/form-view.js b/server/sonar-web/src/main/js/apps/permission-templates/form-view.js
index 6cb8154d318..a94290e1604 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/form-view.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/form-view.js
@@ -23,7 +23,7 @@ import Template from './templates/permission-templates-form.hbs';
export default ModalForm.extend({
template: Template,
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
this.$('#create-custom-measure-metric').select2({
@@ -32,12 +32,12 @@ export default ModalForm.extend({
});
},
- onDestroy: function () {
+ onDestroy () {
ModalForm.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
}
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js b/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js
index e140e5bafe4..e62c37d5db6 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/groups-view.js
@@ -30,14 +30,14 @@ function getSearchUrl (permission, permissionTemplate) {
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
new window.SelectList({
el: this.$('#permission-templates-groups'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name;
},
queryParam: 'q',
@@ -50,21 +50,21 @@ export default Modal.extend({
},
selectParameter: 'groupName',
selectParameterValue: 'name',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.groups;
}
});
},
- onDestroy: function () {
+ onDestroy () {
if (this.options.refresh) {
this.options.refresh();
}
Modal.prototype.onDestroy.apply(this, arguments);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
permissionName: this.options.permission.name,
permissionTemplateName: this.options.permissionTemplate.name
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/main.js b/server/sonar-web/src/main/js/apps/permission-templates/main.js
index f1e4dd463e4..daee510ca17 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/main.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/main.js
@@ -50,7 +50,7 @@ export default React.createClass({
let projectPermission = _.findWhere(permissionTemplate.permissions, { key: basePermission.key });
return _.extend({ usersCount: 0, groupsCount: 0 }, basePermission, projectPermission);
});
- return _.extend({}, permissionTemplate, { permissions: permissions });
+ return _.extend({}, permissionTemplate, { permissions });
});
},
@@ -74,7 +74,7 @@ export default React.createClass({
this.setState({
ready: true,
permissionTemplates: permissionTemplatesWithDefaults,
- permissions: permissions
+ permissions
});
});
},
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/permission-template.js b/server/sonar-web/src/main/js/apps/permission-templates/permission-template.js
index dd747070554..d606e626005 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/permission-template.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/permission-template.js
@@ -37,7 +37,7 @@ export default React.createClass({
showGroups(permission, e) {
e.preventDefault();
new GroupsView({
- permission: permission,
+ permission,
permissionTemplate: this.props.permissionTemplate,
refresh: this.props.refresh
}).render();
@@ -46,7 +46,7 @@ export default React.createClass({
showUsers(permission, e) {
e.preventDefault();
new UsersView({
- permission: permission,
+ permission,
permissionTemplate: this.props.permissionTemplate,
refresh: this.props.refresh
}).render();
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/update-view.js b/server/sonar-web/src/main/js/apps/permission-templates/update-view.js
index 572c26bad1f..d738e9286e2 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/update-view.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/update-view.js
@@ -21,8 +21,8 @@ import FormView from './form-view';
import { updatePermissionTemplate } from '../../api/permissions';
export default FormView.extend({
- sendRequest: function () {
- var that = this;
+ sendRequest () {
+ const that = this;
this.disableForm();
return updatePermissionTemplate({
data: {
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/users-view.js b/server/sonar-web/src/main/js/apps/permission-templates/users-view.js
index 6348a1ad9c4..9e2d42ececd 100644
--- a/server/sonar-web/src/main/js/apps/permission-templates/users-view.js
+++ b/server/sonar-web/src/main/js/apps/permission-templates/users-view.js
@@ -25,20 +25,20 @@ import Template from './templates/permission-templates-users.hbs';
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
- var searchUrl = '/api/permissions/template_users?ps=100&permission=' + this.options.permission.key +
+ const searchUrl = '/api/permissions/template_users?ps=100&permission=' + this.options.permission.key +
'&templateId=' + this.options.permissionTemplate.id;
new window.SelectList({
el: this.$('#permission-templates-users'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name + '<br><span class="note">' + item.login + '</span>';
},
queryParam: 'q',
- searchUrl: searchUrl,
+ searchUrl,
selectUrl: '/api/permissions/add_user_to_template',
deselectUrl: '/api/permissions/remove_user_from_template',
extra: {
@@ -47,21 +47,21 @@ export default Modal.extend({
},
selectParameter: 'login',
selectParameterValue: 'login',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.users;
}
});
},
- onDestroy: function () {
+ onDestroy () {
if (this.options.refresh) {
this.options.refresh();
}
Modal.prototype.onDestroy.apply(this, arguments);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
permissionName: this.options.permission.name,
permissionTemplateName: this.options.permissionTemplate.name
diff --git a/server/sonar-web/src/main/js/apps/project-permissions/app.js b/server/sonar-web/src/main/js/apps/project-permissions/app.js
index 6e00dcce72f..c4630bdd744 100644
--- a/server/sonar-web/src/main/js/apps/project-permissions/app.js
+++ b/server/sonar-web/src/main/js/apps/project-permissions/app.js
@@ -28,7 +28,7 @@ function requestPermissionTemplates () {
window.sonarqube.appStarted.then(options => {
requestPermissionTemplates().done(r => {
- var el = document.querySelector(options.el);
+ const el = document.querySelector(options.el);
ReactDOM.render(<Main permissionTemplates={r.permissionTemplates}
componentId={window.sonarqube.componentId}
rootQualifiers={options.rootQualifiers}/>, el);
diff --git a/server/sonar-web/src/main/js/apps/project-permissions/apply-template-view.js b/server/sonar-web/src/main/js/apps/project-permissions/apply-template-view.js
index d974347eab2..e831fef39d1 100644
--- a/server/sonar-web/src/main/js/apps/project-permissions/apply-template-view.js
+++ b/server/sonar-web/src/main/js/apps/project-permissions/apply-template-view.js
@@ -26,7 +26,7 @@ import Template from './templates/project-permissions-apply-template.hbs';
export default ModalForm.extend({
template: Template,
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.$('#project-permissions-template').select2({
width: '250px',
@@ -34,14 +34,14 @@ export default ModalForm.extend({
});
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
- var that = this;
+ const that = this;
this.disableForm();
- var projects = this.options.project ? [this.options.project] : this.options.projects,
- permissionTemplate = this.$('#project-permissions-template').val(),
- looper = $.Deferred().resolve();
+ const projects = this.options.project ? [this.options.project] : this.options.projects;
+ const permissionTemplate = this.$('#project-permissions-template').val();
+ let looper = $.Deferred().resolve();
projects.forEach(function (project) {
looper = looper.then(function () {
@@ -60,7 +60,7 @@ export default ModalForm.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
permissionTemplates: this.options.permissionTemplates,
project: this.options.project,
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 1a4658b68ff..e869fc85394 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
@@ -29,14 +29,14 @@ function getSearchUrl (permission, project) {
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
new window.SelectList({
el: this.$('#project-permissions-groups'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name;
},
queryParam: 'q',
@@ -49,21 +49,21 @@ export default Modal.extend({
},
selectParameter: 'groupName',
selectParameterValue: 'name',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.groups;
}
});
},
- onDestroy: function () {
+ onDestroy () {
if (this.options.refresh) {
this.options.refresh();
}
Modal.prototype.onDestroy.apply(this, arguments);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
projectName: this.options.projectName
});
diff --git a/server/sonar-web/src/main/js/apps/project-permissions/main.js b/server/sonar-web/src/main/js/apps/project-permissions/main.js
index 61d838a8bec..b3545d43eb8 100644
--- a/server/sonar-web/src/main/js/apps/project-permissions/main.js
+++ b/server/sonar-web/src/main/js/apps/project-permissions/main.js
@@ -55,12 +55,12 @@ export default React.createClass({
let projectPermission = _.findWhere(project.permissions, { key: basePermission.key });
return _.extend({ usersCount: 0, groupsCount: 0 }, basePermission, projectPermission);
});
- return _.extend({}, project, { permissions: permissions });
+ return _.extend({}, project, { permissions });
});
},
requestPermissions(page = 1, query = '', filter = this.state.filter) {
- let url = `/api/permissions/search_project_permissions`;
+ let url = '/api/permissions/search_project_permissions';
let data = { p: page, q: query };
if (filter !== '__ALL__') {
data.qualifier = filter;
@@ -77,12 +77,12 @@ export default React.createClass({
}
this.setState({
ready: true,
- projects: projects,
- permissions: permissions,
+ projects,
+ permissions,
total: r.paging.total,
page: r.paging.pageIndex,
- query: query,
- filter: filter
+ query,
+ filter
});
});
});
diff --git a/server/sonar-web/src/main/js/apps/project-permissions/project.js b/server/sonar-web/src/main/js/apps/project-permissions/project.js
index 3aae000f119..16420f56ab1 100644
--- a/server/sonar-web/src/main/js/apps/project-permissions/project.js
+++ b/server/sonar-web/src/main/js/apps/project-permissions/project.js
@@ -34,7 +34,7 @@ export default React.createClass({
showGroups(permission, e) {
e.preventDefault();
new GroupsView({
- permission: permission,
+ permission,
project: this.props.project.id,
projectName: this.props.project.name,
refresh: this.props.refresh
@@ -44,7 +44,7 @@ export default React.createClass({
showUsers(permission, e) {
e.preventDefault();
new UsersView({
- permission: permission,
+ permission,
project: this.props.project.id,
projectName: this.props.project.name,
refresh: this.props.refresh
diff --git a/server/sonar-web/src/main/js/apps/project-permissions/search.js b/server/sonar-web/src/main/js/apps/project-permissions/search.js
index 66cb3b99c75..b07a0a1f526 100644
--- a/server/sonar-web/src/main/js/apps/project-permissions/search.js
+++ b/server/sonar-web/src/main/js/apps/project-permissions/search.js
@@ -28,7 +28,7 @@ export default React.createClass({
search: React.PropTypes.func.isRequired
},
- componentWillMount: function () {
+ componentWillMount () {
this.search = _.debounce(this.search, 250);
},
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 1c19f08bf30..691da91d8d4 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
@@ -25,20 +25,20 @@ import Template from './templates/project-permissions-users.hbs';
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
- var searchUrl = '/api/permissions/users?ps=100&permission=' + this.options.permission +
+ const searchUrl = '/api/permissions/users?ps=100&permission=' + this.options.permission +
'&projectId=' + this.options.project;
new window.SelectList({
el: this.$('#project-permissions-users'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name + '<br><span class="note">' + item.login + '</span>';
},
queryParam: 'q',
- searchUrl: searchUrl,
+ searchUrl,
selectUrl: '/api/permissions/add_user',
deselectUrl: '/api/permissions/remove_user',
extra: {
@@ -47,21 +47,21 @@ export default Modal.extend({
},
selectParameter: 'login',
selectParameterValue: 'login',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.users;
}
});
},
- onDestroy: function () {
+ onDestroy () {
if (this.options.refresh) {
this.options.refresh();
}
Modal.prototype.onDestroy.apply(this, arguments);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
projectName: this.options.projectName
});
diff --git a/server/sonar-web/src/main/js/apps/projects/create-view.js b/server/sonar-web/src/main/js/apps/projects/create-view.js
index fbc52a1dd41..4bff6436515 100644
--- a/server/sonar-web/src/main/js/apps/projects/create-view.js
+++ b/server/sonar-web/src/main/js/apps/projects/create-view.js
@@ -25,22 +25,22 @@ import Template from './templates/projects-create-form.hbs';
export default ModalForm.extend({
template: Template,
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
ModalForm.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
+ sendRequest () {
let data = {
name: this.$('#create-project-name').val(),
branch: this.$('#create-project-branch').val(),
diff --git a/server/sonar-web/src/main/js/apps/projects/delete-view.js b/server/sonar-web/src/main/js/apps/projects/delete-view.js
index 30b4b762830..a39823d42a5 100644
--- a/server/sonar-web/src/main/js/apps/projects/delete-view.js
+++ b/server/sonar-web/src/main/js/apps/projects/delete-view.js
@@ -23,7 +23,7 @@ import Template from './templates/projects-delete.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.options.deleteProjects();
this.destroy();
diff --git a/server/sonar-web/src/main/js/apps/projects/form-view.js b/server/sonar-web/src/main/js/apps/projects/form-view.js
index 52f33738244..7b96a150358 100644
--- a/server/sonar-web/src/main/js/apps/projects/form-view.js
+++ b/server/sonar-web/src/main/js/apps/projects/form-view.js
@@ -21,17 +21,17 @@ import ModalForm from '../../components/common/modal-form';
export default ModalForm.extend({
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
ModalForm.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
}
diff --git a/server/sonar-web/src/main/js/apps/projects/main.js b/server/sonar-web/src/main/js/apps/projects/main.js
index f634319880a..ae005a9165e 100644
--- a/server/sonar-web/src/main/js/apps/projects/main.js
+++ b/server/sonar-web/src/main/js/apps/projects/main.js
@@ -45,7 +45,7 @@ export default React.createClass({
};
},
- componentWillMount: function () {
+ componentWillMount () {
this.requestProjects = _.debounce(this.requestProjects, 250);
},
@@ -89,7 +89,7 @@ export default React.createClass({
if (this.state.page > 1) {
projects = [].concat(this.state.projects, projects);
}
- this.setState({ ready: true, projects: projects, total: r.total });
+ this.setState({ ready: true, projects, total: r.total });
});
},
@@ -102,7 +102,7 @@ export default React.createClass({
if (this.state.page > 1) {
projects = [].concat(this.state.projects, projects);
}
- this.setState({ ready: true, projects: projects, total: r.total });
+ this.setState({ ready: true, projects, total: r.total });
});
},
@@ -114,7 +114,7 @@ export default React.createClass({
if (this.state.page > 1) {
projects = [].concat(this.state.projects, projects);
}
- this.setState({ ready: true, projects: projects, total: r.paging.total });
+ this.setState({ ready: true, projects, total: r.paging.total });
});
},
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 3e8f89e51e6..8e22e0b9b8c 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
@@ -29,14 +29,14 @@ export default Marionette.ItemView.extend({
'click #quality-gate-add': 'add'
},
- add: function (e) {
+ add (e) {
e.preventDefault();
new CreateView({
collection: this.collection
}).render();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canEdit: this.options.canEdit
});
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 9212527eae6..4d09615366d 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
@@ -27,9 +27,9 @@ import Router from './router';
import Layout from './layout';
import Controller from './controller';
-var App = new Marionette.Application();
+const App = new Marionette.Application();
-var init = function () {
+const init = function () {
let options = window.sonarqube;
// Layout
this.layout = new Layout({ el: options.el });
@@ -64,7 +64,7 @@ var init = function () {
});
};
-var appXHR = $.get('/api/qualitygates/app')
+const appXHR = $.get('/api/qualitygates/app')
.done(function (r) {
App.canEdit = r.edit;
App.periods = r.periods;
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 8e8f42e0076..65bce51a82b 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
@@ -25,24 +25,24 @@ export default Backbone.Model.extend({
period: 0
},
- url: function () {
+ url () {
return '/api/qualitygates';
},
- createUrl: function () {
+ createUrl () {
return this.url() + '/create_condition';
},
- updateUrl: function () {
+ updateUrl () {
return this.url() + '/update_condition';
},
- deleteUrl: function () {
+ deleteUrl () {
return this.url() + '/delete_condition';
},
- sync: function (method, model, options) {
- var opts = options || {};
+ sync (method, model, options) {
+ const opts = options || {};
opts.type = 'POST';
if (method === 'create') {
opts.url = this.createUrl();
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 c5a7756f5ef..826b5d57cca 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
@@ -24,43 +24,43 @@ import HeaderView from './header-view';
export default Marionette.Controller.extend({
- initialize: function (options) {
+ initialize (options) {
this.app = options.app;
this.canEdit = this.app.canEdit;
this.listenTo(this.app.gates, 'select', this.onSelect);
this.listenTo(this.app.gates, 'destroy', this.onDestroy);
},
- index: function () {
+ index () {
this.app.gates.fetch();
},
- show: function (id) {
- var that = this;
+ show (id) {
+ const that = this;
this.app.gates.fetch().done(function () {
- var gate = that.app.gates.get(id);
+ const gate = that.app.gates.get(id);
if (gate != null) {
gate.trigger('select', gate, { trigger: false });
}
});
},
- onSelect: function (gate, options) {
- var that = this,
- route = 'show/' + gate.id,
- opts = _.defaults(options || {}, { trigger: true });
+ onSelect (gate, options) {
+ const that = this;
+ const route = 'show/' + gate.id;
+ const opts = _.defaults(options || {}, { trigger: true });
if (opts.trigger) {
this.app.router.navigate(route);
}
this.app.gatesView.highlight(gate.id);
gate.fetch().done(function () {
- var headerView = new HeaderView({
+ const headerView = new HeaderView({
model: gate,
canEdit: that.canEdit
});
that.app.layout.headerRegion.show(headerView);
- var detailsView = new DetailsView({
+ const detailsView = new DetailsView({
model: gate,
canEdit: that.canEdit,
metrics: that.app.metrics,
@@ -70,7 +70,7 @@ export default Marionette.Controller.extend({
});
},
- onDestroy: function () {
+ onDestroy () {
this.app.router.navigate('');
this.app.layout.headerRegion.reset();
this.app.layout.detailsRegion.reset();
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 9973df8a975..638ca97eacc 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
@@ -22,17 +22,17 @@ import FormView from './form-view';
export default FormView.extend({
method: 'copy',
- prepareRequest: function () {
- var that = this;
- var url = '/api/qualitygates/copy',
- name = this.$('#quality-gate-form-name').val(),
- options = {
- url: url,
- data: { id: this.model.id, name: name }
- };
+ prepareRequest () {
+ const that = this;
+ const url = '/api/qualitygates/copy';
+ const name = this.$('#quality-gate-form-name').val();
+ const options = {
+ url,
+ data: { id: this.model.id, name }
+ };
return this.sendRequest(options)
.done(function (r) {
- var gate = that.addGate(r);
+ const gate = that.addGate(r);
gate.trigger('select', gate);
});
}
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 9fd9b2e5d11..468b6711f81 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
@@ -22,17 +22,17 @@ import FormView from './form-view';
export default FormView.extend({
method: 'create',
- prepareRequest: function () {
- var that = this;
- var url = '/api/qualitygates/create',
- name = this.$('#quality-gate-form-name').val(),
- options = {
- url: url,
- data: { name: name }
- };
+ prepareRequest () {
+ const that = this;
+ const url = '/api/qualitygates/create';
+ const name = this.$('#quality-gate-form-name').val();
+ const options = {
+ url,
+ data: { name }
+ };
return this.sendRequest(options)
.done(function (r) {
- var gate = that.addGate(r);
+ const gate = that.addGate(r);
gate.trigger('select', gate);
});
}
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/delete-view.js b/server/sonar-web/src/main/js/apps/quality-gates/delete-view.js
index c7603b631e7..7efa270d9c1 100644
--- a/server/sonar-web/src/main/js/apps/quality-gates/delete-view.js
+++ b/server/sonar-web/src/main/js/apps/quality-gates/delete-view.js
@@ -23,20 +23,20 @@ import Template from './templates/quality-gates-delete.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.disableForm();
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- options = {
- statusCode: {
- // do not show global error
- 400: null
- }
- };
+ sendRequest () {
+ const that = this;
+ const options = {
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ };
return this.model.destroy(options)
.done(function () {
that.destroy();
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 ef3821a949b..b0cc63fb0f6 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
@@ -36,32 +36,32 @@ export default Marionette.LayoutView.extend({
'change': 'render'
},
- onRender: function () {
+ onRender () {
this.showConditions();
this.showProjects();
},
- orderByName: function (conditions) {
+ orderByName (conditions) {
let metrics = this.options.metrics;
return _.sortBy(conditions, (condition) => {
return _.findWhere(metrics, { key: condition.metric }).name;
});
},
- showConditions: function () {
- var conditions = new Conditions(this.orderByName(this.model.get('conditions'))),
- view = new DetailConditionsView({
- canEdit: this.options.canEdit,
- collection: conditions,
- model: this.model,
- metrics: this.options.metrics,
- periods: this.options.periods
- });
+ showConditions () {
+ const conditions = new Conditions(this.orderByName(this.model.get('conditions')));
+ const view = new DetailConditionsView({
+ canEdit: this.options.canEdit,
+ collection: conditions,
+ model: this.model,
+ metrics: this.options.metrics,
+ periods: this.options.periods
+ });
this.conditionsRegion.show(view);
},
- showProjects: function () {
- var view = new ProjectsView({
+ showProjects () {
+ const view = new ProjectsView({
canEdit: this.options.canEdit,
model: this.model
});
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 1d9f71267de..d82e605c7b0 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
@@ -26,21 +26,21 @@ import Template from './templates/quality-gate-form.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.disableForm();
this.prepareRequest();
},
- sendRequest: function (options) {
- var that = this,
- opts = _.defaults(options || {}, {
- type: 'POST',
- statusCode: {
- // do not show global error
- 400: null
- }
- });
+ sendRequest (options) {
+ const that = this;
+ const opts = _.defaults(options || {}, {
+ type: 'POST',
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ });
return Backbone.ajax(opts)
.done(function () {
that.destroy();
@@ -50,13 +50,13 @@ export default ModalForm.extend({
});
},
- addGate: function (attrs) {
- var gate = new Gate(attrs);
+ addGate (attrs) {
+ const gate = new Gate(attrs);
this.collection.add(gate, { merge: true });
return gate;
},
- serializeData: function () {
+ serializeData () {
return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
method: this.method
});
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 31408c4a8eb..dab1a79e834 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
@@ -50,7 +50,7 @@ export default Marionette.ItemView.extend({
'change :input': 'enableUpdate'
},
- onRender: function () {
+ onRender () {
this.ui.warningInput.val(this.model.get('warning'));
this.ui.errorInput.val(this.model.get('error'));
@@ -69,8 +69,8 @@ export default Marionette.ItemView.extend({
}
},
- saveCondition: function () {
- var attrs = {
+ saveCondition () {
+ const attrs = {
gateId: this.model.isNew() ? this.options.gate.id : void 0,
period: this.ui.periodSelect.val(),
op: this.ui.operatorSelect.val(),
@@ -80,33 +80,33 @@ export default Marionette.ItemView.extend({
this.model.save(attrs, { wait: true });
},
- deleteCondition: function () {
+ deleteCondition () {
new DeleteConditionView({
model: this.model,
metric: this.getMetric()
}).render();
},
- cancelAddCondition: function () {
+ cancelAddCondition () {
this.destroy();
},
- enableUpdate: function () {
+ enableUpdate () {
this.ui.updateButton.prop('disabled', false);
},
- getMetric: function () {
- var key = this.model.get('metric');
- return _.findWhere(this.options.metrics, { key: key });
+ getMetric () {
+ const key = this.model.get('metric');
+ return _.findWhere(this.options.metrics, { key });
},
- isDiffMetric: function () {
- var key = this.model.get('metric');
+ isDiffMetric () {
+ const key = this.model.get('metric');
return key.indexOf('new_') === 0;
},
- serializeData: function () {
- var period = _.findWhere(this.options.periods, { key: this.model.get('period') });
+ serializeData () {
+ const period = _.findWhere(this.options.periods, { key: this.model.get('period') });
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canEdit: this.options.canEdit,
periods: this.options.periods,
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 ccbaa79c6d3..fb8fad5c333 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
@@ -25,20 +25,20 @@ import Template from './templates/quality-gates-condition-delete.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.disableForm();
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- options = {
- statusCode: {
- // do not show global error
- 400: null
- }
- };
+ sendRequest () {
+ const that = this;
+ const options = {
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ };
return this.model.destroy(options)
.done(function () {
that.destroy();
@@ -48,7 +48,7 @@ export default ModalForm.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
metric: this.options.metric
});
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 ce090b5e57c..ee1e772273c 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
@@ -25,7 +25,7 @@ export default Marionette.ItemView.extend({
tagName: 'tr',
template: Template,
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canEdit: this.options.canEdit
});
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 c4f6bf7a905..5d2396b3453 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
@@ -40,7 +40,7 @@ export default Marionette.CompositeView.extend({
'change @ui.metricSelect': 'addCondition'
},
- childViewOptions: function () {
+ childViewOptions () {
return {
canEdit: this.options.canEdit,
gate: this.model,
@@ -50,7 +50,7 @@ export default Marionette.CompositeView.extend({
};
},
- onRender: function () {
+ onRender () {
this.ui.metricSelect.select2({
allowClear: false,
width: '250px',
@@ -58,33 +58,33 @@ export default Marionette.CompositeView.extend({
});
},
- showMoreIntroduction: function () {
+ showMoreIntroduction () {
this.$('.js-show-more').addClass('hidden');
this.$('.js-more').removeClass('hidden');
},
- addCondition: function () {
- var metric = this.ui.metricSelect.val();
+ addCondition () {
+ const metric = this.ui.metricSelect.val();
this.ui.metricSelect.select2('val', '');
- var condition = new Condition({ metric: metric });
+ const condition = new Condition({ metric });
this.collection.add(condition);
},
- groupedMetrics: function () {
- var metrics = this.options.metrics.filter(function (metric) {
+ groupedMetrics () {
+ let metrics = this.options.metrics.filter(function (metric) {
return !metric.hidden;
});
metrics = _.groupBy(metrics, 'domain');
metrics = _.map(metrics, function (list, domain) {
return {
- domain: domain,
+ domain,
metrics: _.sortBy(list, 'short_name')
};
});
return _.sortBy(metrics, 'domain');
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.CompositeView.prototype.serializeData.apply(this, arguments), {
canEdit: this.options.canEdit,
metricGroups: this.groupedMetrics()
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 939face75f0..a8a7909351b 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
@@ -26,14 +26,14 @@ import { translate } from '../../helpers/l10n';
export default Marionette.ItemView.extend({
template: Template,
- onRender: function () {
+ onRender () {
if (!this.model.isDefault()) {
new window.SelectList({
el: this.$('#select-list-projects'),
width: '100%',
readOnly: !this.options.canEdit,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name;
},
searchUrl: '/api/qualitygates/search?gateId=' + this.model.id,
@@ -58,7 +58,7 @@ export default Marionette.ItemView.extend({
}
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canEdit: this.options.canEdit
});
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 7dde0ab7b6b..85f709cc324 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
@@ -33,12 +33,12 @@ export default Marionette.ItemView.extend({
'click': 'onClick'
},
- onRender: function () {
+ onRender () {
this.$el.toggleClass('active', this.options.highlighted);
this.$el.attr('data-id', this.model.id);
},
- onClick: function (e) {
+ onClick (e) {
e.preventDefault();
this.model.trigger('select', this.model);
}
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 31c046b62bd..00ff3718d44 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
@@ -21,29 +21,29 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
- isDefault: function () {
+ isDefault () {
return this.get('isDefault');
},
- url: function () {
+ url () {
return '/api/qualitygates';
},
- showUrl: function () {
+ showUrl () {
return this.url() + '/show';
},
- deleteUrl: function () {
+ deleteUrl () {
return this.url() + '/destroy';
},
- toggleDefaultUrl: function () {
- var method = this.isDefault() ? 'unset_default' : 'set_as_default';
+ toggleDefaultUrl () {
+ const method = this.isDefault() ? 'unset_default' : 'set_as_default';
return this.url() + '/' + method;
},
- sync: function (method, model, options) {
- var opts = options || {};
+ sync (method, model, options) {
+ const opts = options || {};
opts.data = opts.data || {};
opts.data.id = model.id;
if (method === 'read') {
@@ -56,9 +56,9 @@ export default Backbone.Model.extend({
return Backbone.ajax(opts);
},
- toggleDefault: function () {
- var that = this;
- var opts = {
+ toggleDefault () {
+ const that = this;
+ const opts = {
type: 'POST',
url: this.toggleDefaultUrl(),
data: { id: this.id }
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 fc2257cf155..0df6623ff16 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
@@ -27,14 +27,14 @@ export default Marionette.CompositeView.extend({
childView: ItemView,
childViewContainer: '.js-list',
- childViewOptions: function (model) {
+ childViewOptions (model) {
return {
collectionView: this,
highlighted: model.id === this.highlighted
};
},
- highlight: function (id) {
+ highlight (id) {
this.highlighted = id;
this.render();
}
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 2b4a300bb4c..df7d2493c08 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
@@ -24,22 +24,22 @@ import Gate from './gate';
export default Backbone.Collection.extend({
model: Gate,
- url: function () {
+ url () {
return '/api/qualitygates/list';
},
- parse: function (r) {
+ parse (r) {
return r.qualitygates.map(function (gate) {
return _.extend(gate, { isDefault: gate.id === r.default });
});
},
- comparator: function (item) {
+ comparator (item) {
return item.get('name').toLowerCase();
},
- toggleDefault: function (gate) {
- var isDefault = gate.isDefault();
+ toggleDefault (gate) {
+ const isDefault = gate.isDefault();
this.forEach(function (model) {
model.set({ isDefault: gate.id === model.id ? !isDefault : false });
});
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 7fb3cd427f4..e01e161c9df 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
@@ -38,30 +38,30 @@ export default Marionette.ItemView.extend({
'click #quality-gate-toggle-default': 'toggleDefault'
},
- renameQualityGate: function () {
+ renameQualityGate () {
new RenameView({
model: this.model
}).render();
},
- copyQualityGate: function () {
+ copyQualityGate () {
new CopyView({
model: this.model,
collection: this.model.collection
}).render();
},
- deleteQualityGate: function () {
+ deleteQualityGate () {
new DeleteView({
model: this.model
}).render();
},
- toggleDefault: function () {
+ toggleDefault () {
this.model.toggleDefault();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canEdit: this.options.canEdit
});
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 1d02e572ce8..351ca9ae43c 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
@@ -31,14 +31,14 @@ export default Marionette.LayoutView.extend({
detailsRegion: '.search-navigator-workspace-details'
},
- onRender: function () {
- var top = this.$('.search-navigator').offset().top;
- this.$('.search-navigator-workspace-header').css({ top: top });
- this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+ onRender () {
+ const top = this.$('.search-navigator').offset().top;
+ this.$('.search-navigator-workspace-header').css({ top });
+ this.$('.search-navigator-side').css({ top }).isolatedScroll();
this.renderIntro();
},
- renderIntro: function () {
+ renderIntro () {
this.detailsRegion.show(new IntroView());
}
});
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 c84ff73422a..9c5d5b901b9 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
@@ -22,14 +22,14 @@ import FormView from './form-view';
export default FormView.extend({
method: 'rename',
- prepareRequest: function () {
- var that = this;
- var url = '/api/qualitygates/rename',
- name = this.$('#quality-gate-form-name').val(),
- options = {
- url: url,
- data: { id: this.model.id, name: name }
- };
+ prepareRequest () {
+ const that = this;
+ const url = '/api/qualitygates/rename';
+ const name = this.$('#quality-gate-form-name').val();
+ const options = {
+ url,
+ data: { id: this.model.id, name }
+ };
return this.sendRequest(options)
.done(function (r) {
that.model.set(r);
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 698e370ec73..bfe973a5811 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
@@ -25,15 +25,15 @@ export default Backbone.Router.extend({
'show/:id': 'show'
},
- initialize: function (options) {
+ initialize (options) {
this.app = options.app;
},
- index: function () {
+ index () {
this.app.controller.index();
},
- show: function (id) {
+ show (id) {
this.app.controller.show(id);
}
});
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 ee8b267313d..11d014ae1c1 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
@@ -36,29 +36,29 @@ export default Marionette.ItemView.extend({
'click .js-filter-by-language': 'onLanguageClick'
},
- onCreateClick: function (e) {
+ onCreateClick (e) {
e.preventDefault();
this.create();
},
- onRestoreClick: function (e) {
+ onRestoreClick (e) {
e.preventDefault();
this.restore();
},
- onRestoreBuiltInClick: function (e) {
+ onRestoreBuiltInClick (e) {
e.preventDefault();
this.restoreBuiltIn();
},
- onLanguageClick: function (e) {
+ onLanguageClick (e) {
e.preventDefault();
- var language = $(e.currentTarget).data('language');
+ const language = $(e.currentTarget).data('language');
this.filterByLanguage(language);
},
- create: function () {
- var that = this;
+ create () {
+ const that = this;
this.requestImporters().done(function () {
new CreateProfileView({
collection: that.collection,
@@ -68,42 +68,42 @@ export default Marionette.ItemView.extend({
});
},
- restore: function () {
+ restore () {
new RestoreProfileView({
collection: this.collection
}).render();
},
- restoreBuiltIn: function () {
+ restoreBuiltIn () {
new RestoreBuiltInProfilesView({
collection: this.collection,
languages: this.languages
}).render();
},
- requestLanguages: function () {
- var that = this,
- url = '/api/languages/list';
+ requestLanguages () {
+ const that = this;
+ const url = '/api/languages/list';
return $.get(url).done(function (r) {
that.languages = r.languages;
});
},
- requestImporters: function () {
- var that = this,
- url = '/api/qualityprofiles/importers';
+ requestImporters () {
+ const that = this;
+ const url = '/api/qualityprofiles/importers';
return $.get(url).done(function (r) {
that.importers = r.importers;
});
},
- filterByLanguage: function (language) {
+ filterByLanguage (language) {
this.selectedLanguage = _.findWhere(this.languages, { key: language });
this.render();
this.collection.trigger('filter', language);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
canWrite: this.options.canWrite,
languages: this.languages,
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 1d77201f20b..cb120af030a 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
@@ -27,50 +27,50 @@ import Profiles from './profiles';
import ActionsView from './actions-view';
import ProfilesView from './profiles-view';
-var App = new Marionette.Application(),
- requestUser = $.get('/api/users/current').done(function (r) {
- App.canWrite = r.permissions.global.indexOf('profileadmin') !== -1;
- }),
- requestExporters = $.get('/api/qualityprofiles/exporters').done(function (r) {
- App.exporters = r.exporters;
- }),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const requestUser = $.get('/api/users/current').done(function (r) {
+ App.canWrite = r.permissions.global.indexOf('profileadmin') !== -1;
+});
+const requestExporters = $.get('/api/qualityprofiles/exporters').done(function (r) {
+ App.exporters = r.exporters;
+});
+const init = function () {
+ let options = window.sonarqube;
- // Layout
- this.layout = new Layout({ el: options.el });
- this.layout.render();
- $('#footer').addClass('search-navigator-footer');
+ // Layout
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
+ $('#footer').addClass('search-navigator-footer');
- // Profiles List
- this.profiles = new Profiles();
+ // Profiles List
+ this.profiles = new Profiles();
- // Controller
- this.controller = new Controller({ app: this });
+ // Controller
+ this.controller = new Controller({ app: this });
- // Actions View
- this.actionsView = new ActionsView({
- collection: this.profiles,
- canWrite: this.canWrite
- });
- this.actionsView.requestLanguages().done(function () {
- App.layout.actionsRegion.show(App.actionsView);
- });
+ // Actions View
+ this.actionsView = new ActionsView({
+ collection: this.profiles,
+ canWrite: this.canWrite
+ });
+ this.actionsView.requestLanguages().done(function () {
+ App.layout.actionsRegion.show(App.actionsView);
+ });
- // Profiles View
- this.profilesView = new ProfilesView({
- collection: this.profiles,
- canWrite: this.canWrite
- });
- this.layout.resultsRegion.show(this.profilesView);
+ // Profiles View
+ this.profilesView = new ProfilesView({
+ collection: this.profiles,
+ canWrite: this.canWrite
+ });
+ this.layout.resultsRegion.show(this.profilesView);
- // Router
- this.router = new Router({ app: this });
- Backbone.history.start({
- pushState: true,
- root: options.urlRoot
- });
- };
+ // Router
+ this.router = new Router({ app: this });
+ Backbone.history.start({
+ pushState: true,
+ root: options.urlRoot
+ });
+};
App.on('start', function () {
$.when(requestUser, requestExporters).done(function () {
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 681098f20cb..183877eba76 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
@@ -26,7 +26,7 @@ import Template from './templates/quality-profiles-change-profile-parent.hbs';
export default ModalFormView.extend({
template: Template,
- onRender: function () {
+ onRender () {
ModalFormView.prototype.onRender.apply(this, arguments);
this.$('select').select2({
width: '250px',
@@ -34,23 +34,23 @@ export default ModalFormView.extend({
});
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
this.disableForm();
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- url = '/api/qualityprofiles/change_parent',
- parent = this.$('#change-profile-parent').val(),
- options = {
- profileKey: this.model.get('key'),
- parentKey: parent
- };
+ sendRequest () {
+ const that = this;
+ const url = '/api/qualityprofiles/change_parent';
+ const parent = this.$('#change-profile-parent').val();
+ const options = {
+ profileKey: this.model.get('key'),
+ parentKey: parent
+ };
return $.ajax({
type: 'POST',
- url: url,
+ url,
data: options,
statusCode: {
// do not show global error
@@ -66,14 +66,14 @@ export default ModalFormView.extend({
});
},
- serializeData: function () {
- var that = this,
- profilesData = this.model.collection.toJSON(),
- profiles = _.filter(profilesData, function (profile) {
- return profile.language === that.model.get('language') && profile.key !== that.model.id;
- });
+ serializeData () {
+ const that = this;
+ const profilesData = this.model.collection.toJSON();
+ const profiles = _.filter(profilesData, function (profile) {
+ return profile.language === that.model.get('language') && profile.key !== that.model.id;
+ });
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- profiles: profiles
+ profiles
});
}
});
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 68046423c39..5bd378dee83 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
@@ -25,43 +25,43 @@ import ProfileDetailsView from './profile-details-view';
export default Marionette.Controller.extend({
- initialize: function () {
+ initialize () {
this.listenTo(this.options.app.profiles, 'select', this.onProfileSelect);
this.listenTo(this.options.app.profiles, 'setAsDefault', this.onProfileSetAsDefault);
this.listenTo(this.options.app.profiles, 'destroy', this.onProfileDestroy);
},
- index: function () {
+ index () {
this.fetchProfiles();
},
- show: function (key) {
- var that = this;
+ show (key) {
+ const that = this;
this.fetchProfiles().done(function () {
- var profile = that.options.app.profiles.findWhere({ key: key });
+ const profile = that.options.app.profiles.findWhere({ key });
if (profile != null) {
profile.trigger('select', profile, { trigger: false });
}
});
},
- changelog: function (key, since, to) {
- var that = this;
+ changelog (key, since, to) {
+ const that = this;
this.anchor = 'changelog';
this.fetchProfiles().done(function () {
- var profile = that.options.app.profiles.findWhere({ key: key });
+ const profile = that.options.app.profiles.findWhere({ key });
if (profile != null) {
profile.trigger('select', profile, { trigger: false });
- profile.fetchChangelog({ since: since, to: to });
+ profile.fetchChangelog({ since, to });
}
});
},
- compare: function (key, withKey) {
- var that = this;
+ compare (key, withKey) {
+ const that = this;
this.anchor = 'comparison';
this.fetchProfiles().done(function () {
- var profile = that.options.app.profiles.findWhere({ key: key });
+ const profile = that.options.app.profiles.findWhere({ key });
if (profile != null) {
profile.trigger('select', profile, { trigger: false });
profile.compareWith(withKey);
@@ -69,23 +69,23 @@ export default Marionette.Controller.extend({
});
},
- onProfileSelect: function (profile, options) {
- var that = this,
- key = profile.get('key'),
- route = 'show?key=' + encodeURIComponent(key),
- opts = _.defaults(options || {}, { trigger: true });
+ onProfileSelect (profile, options) {
+ const that = this;
+ const key = profile.get('key');
+ const route = 'show?key=' + encodeURIComponent(key);
+ const opts = _.defaults(options || {}, { trigger: true });
if (opts.trigger) {
this.options.app.router.navigate(route);
}
this.options.app.profilesView.highlight(key);
this.fetchProfile(profile).done(function () {
- var profileHeaderView = new ProfileHeaderView({
+ const profileHeaderView = new ProfileHeaderView({
model: profile,
canWrite: that.options.app.canWrite
});
that.options.app.layout.headerRegion.show(profileHeaderView);
- var profileDetailsView = new ProfileDetailsView({
+ const profileDetailsView = new ProfileDetailsView({
model: profile,
canWrite: that.options.app.canWrite,
exporters: that.options.app.exporters,
@@ -97,18 +97,18 @@ export default Marionette.Controller.extend({
});
},
- onProfileSetAsDefault: function (profile) {
- var that = this,
- url = '/api/qualityprofiles/set_default',
- key = profile.get('key'),
- options = { profileKey: key };
+ onProfileSetAsDefault (profile) {
+ const that = this;
+ const url = '/api/qualityprofiles/set_default';
+ const key = profile.get('key');
+ const options = { profileKey: key };
return $.post(url, options).done(function () {
profile.set({ isDefault: true });
that.fetchProfiles();
});
},
- onProfileDestroy: function () {
+ onProfileDestroy () {
this.options.app.router.navigate('');
this.options.app.layout.headerRegion.reset();
this.options.app.layout.detailsRegion.reset();
@@ -116,11 +116,11 @@ export default Marionette.Controller.extend({
this.options.app.profilesView.highlight(null);
},
- fetchProfiles: function () {
+ fetchProfiles () {
return this.options.app.profiles.fetch({ reset: true });
},
- fetchProfile: function (profile) {
+ fetchProfile (profile) {
return profile.fetch();
}
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js
index d17be22b774..ad5950a7764 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js
@@ -25,23 +25,23 @@ import Template from './templates/quality-profiles-copy-profile.hbs';
export default ModalFormView.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
this.disableForm();
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- url = '/api/qualityprofiles/copy',
- name = this.$('#copy-profile-name').val(),
- options = {
- fromKey: this.model.get('key'),
- toName: name
- };
+ sendRequest () {
+ const that = this;
+ const url = '/api/qualityprofiles/copy';
+ const name = this.$('#copy-profile-name').val();
+ const options = {
+ fromKey: this.model.get('key'),
+ toName: name
+ };
return $.ajax({
type: 'POST',
- url: url,
+ url,
data: options,
statusCode: {
// do not show global error
@@ -56,8 +56,8 @@ export default ModalFormView.extend({
});
},
- addProfile: function (profileData) {
- var profile = new Profile(profileData);
+ addProfile (profileData) {
+ const profile = new Profile(profileData);
this.model.collection.add([profile]);
profile.trigger('select', profile);
}
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/create-profile-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/create-profile-view.js
index 6200c1140f4..7744ae10d6c 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/create-profile-view.js
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/create-profile-view.js
@@ -27,13 +27,13 @@ import { createQualityProfile } from '../../api/quality-profiles';
export default ModalFormView.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(ModalFormView.prototype.events.apply(this, arguments), {
'change #create-profile-language': 'onLanguageChange'
});
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
const form = this.$('form')[0];
@@ -49,7 +49,7 @@ export default ModalFormView.extend({
});
},
- onRender: function () {
+ onRender () {
ModalFormView.prototype.onRender.apply(this, arguments);
this.$('select').select2({
width: '250px',
@@ -58,10 +58,10 @@ export default ModalFormView.extend({
this.onLanguageChange();
},
- onLanguageChange: function () {
- var that = this;
- var language = this.$('#create-profile-language').val();
- var importers = this.getImportersForLanguages(language);
+ onLanguageChange () {
+ const that = this;
+ const language = this.$('#create-profile-language').val();
+ const importers = this.getImportersForLanguages(language);
this.$('.js-importer').each(function () {
that.emptyInput($(this));
$(this).addClass('hidden');
@@ -71,18 +71,18 @@ export default ModalFormView.extend({
});
},
- emptyInput: function (e) {
+ emptyInput (e) {
e.wrap('<form>').closest('form').get(0).reset();
e.unwrap();
},
- addProfile: function (profileData) {
- var profile = new Profile(profileData);
+ addProfile (profileData) {
+ const profile = new Profile(profileData);
this.collection.add([profile]);
profile.trigger('select', profile);
},
- getImportersForLanguages: function (language) {
+ getImportersForLanguages (language) {
if (language != null) {
return this.options.importers.filter(function (importer) {
return importer.languages.indexOf(language) !== -1;
@@ -92,7 +92,7 @@ export default ModalFormView.extend({
}
},
- serializeData: function () {
+ serializeData () {
return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
languages: this.options.languages,
importers: this.options.importers
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/delete-profile-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/delete-profile-view.js
index 7b9e6889f4c..79d24d47ced 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/delete-profile-view.js
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/delete-profile-view.js
@@ -28,19 +28,19 @@ export default ModalFormView.extend({
'destroy': 'destroy'
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
this.disableForm();
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- url = '/api/qualityprofiles/delete',
- options = { profileKey: this.model.get('key') };
+ sendRequest () {
+ const that = this;
+ const url = '/api/qualityprofiles/delete';
+ const options = { profileKey: this.model.get('key') };
return $.ajax({
type: 'POST',
- url: url,
+ url,
data: options,
statusCode: {
// do not show global error
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 68050b14b8f..2e91bc49328 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
@@ -31,16 +31,16 @@ export default Marionette.LayoutView.extend({
detailsRegion: '.search-navigator-workspace-details'
},
- onRender: function () {
- var navigator = this.$('.search-navigator');
+ onRender () {
+ const navigator = this.$('.search-navigator');
navigator.addClass('sticky search-navigator-extended-view');
- var top = navigator.offset().top;
- this.$('.search-navigator-workspace-header').css({ top: top });
- this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+ const top = navigator.offset().top;
+ this.$('.search-navigator-workspace-header').css({ top });
+ this.$('.search-navigator-side').css({ top }).isolatedScroll();
this.renderIntro();
},
- renderIntro: function () {
+ renderIntro () {
this.detailsRegion.show(new IntroView());
}
});
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 ed751be1e8b..255d6e3311e 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
@@ -29,23 +29,23 @@ export default Marionette.ItemView.extend({
'click .js-hide-changelog': 'onHideChangelogClick'
},
- onFormSubmit: function (e) {
+ onFormSubmit (e) {
e.preventDefault();
this.model.fetchChangelog(this.getSearchParameters());
},
- onShowMoreChangelogClick: function (e) {
+ onShowMoreChangelogClick (e) {
e.preventDefault();
this.model.fetchMoreChangelog();
},
- onHideChangelogClick: function (e) {
+ onHideChangelogClick (e) {
e.preventDefault();
this.model.resetChangelog();
},
- getSearchParameters: function () {
- var form = this.$('#quality-profile-changelog-form');
+ getSearchParameters () {
+ const form = this.$('#quality-profile-changelog-form');
return {
since: form.find('[name="since"]').val(),
to: form.find('[name="to"]').val()
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 62e2b0543dd..9564c1ce3bd 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
@@ -29,34 +29,34 @@ export default Marionette.ItemView.extend({
'click .js-hide-comparison': 'onHideComparisonClick'
},
- onRender: function () {
+ onRender () {
this.$('select').select2({
width: '250px',
minimumResultsForSearch: 50
});
},
- onFormSubmit: function (e) {
+ onFormSubmit (e) {
e.preventDefault();
- var withKey = this.$('#quality-profile-comparison-with-key').val();
+ const withKey = this.$('#quality-profile-comparison-with-key').val();
this.model.compareWith(withKey);
},
- onHideComparisonClick: function (e) {
+ onHideComparisonClick (e) {
e.preventDefault();
this.model.resetComparison();
},
- getProfilesForComparison: function () {
- var profiles = this.model.collection.toJSON(),
- key = this.model.id,
- language = this.model.get('language');
+ getProfilesForComparison () {
+ const profiles = this.model.collection.toJSON();
+ const key = this.model.id;
+ const language = this.model.get('language');
return profiles.filter(function (profile) {
return profile.language === language && key !== profile.key;
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
profiles: this.getProfilesForComparison()
});
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 6fbdea721f2..c6b4cecb7dd 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
@@ -45,7 +45,7 @@ export default Marionette.LayoutView.extend({
'click #quality-profile-change-parent': 'onChangeParentClick'
},
- onRender: function () {
+ onRender () {
if (!this.model.get('isDefault')) {
this.initProjectsSelect();
}
@@ -66,22 +66,22 @@ export default Marionette.LayoutView.extend({
});
},
- onChange: function () {
- var changed = Object.keys(this.model.changedAttributes());
+ onChange () {
+ const changed = Object.keys(this.model.changedAttributes());
if (!(changed.length === 1 && changed[0] === 'projectCount')) {
this.render();
}
},
- initProjectsSelect: function () {
- var key = this.model.get('key');
+ initProjectsSelect () {
+ const key = this.model.get('key');
this.projectsSelectList = new window.SelectList({
el: this.$('#quality-profile-projects-list'),
width: '100%',
height: 200,
readOnly: !this.options.canWrite,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name;
},
searchUrl: '/api/qualityprofiles/projects?key=' + encodeURIComponent(key),
@@ -106,72 +106,72 @@ export default Marionette.LayoutView.extend({
this.listenTo(this.projectsSelectList.collection, 'change:selected', this.onProjectsChange);
},
- onProfileClick: function (e) {
- var key = $(e.currentTarget).data('key'),
- profile = this.model.collection.get(key);
+ onProfileClick (e) {
+ const key = $(e.currentTarget).data('key');
+ const profile = this.model.collection.get(key);
if (profile != null) {
e.preventDefault();
this.model.collection.trigger('select', profile);
}
},
- onChangeParentClick: function (e) {
+ onChangeParentClick (e) {
e.preventDefault();
this.changeParent();
},
- onProjectsChange: function () {
+ onProjectsChange () {
this.model.collection.updateForLanguage(this.model.get('language'));
},
- changeParent: function () {
+ changeParent () {
new ChangeProfileParentView({
model: this.model
}).render();
},
- scrollTo: function (selector) {
- var el = this.$(selector),
- parent = el.scrollParent();
- var elOffset = el.offset(),
- parentOffset = parent.offset();
+ scrollTo (selector) {
+ const el = this.$(selector);
+ const parent = el.scrollParent();
+ const elOffset = el.offset();
+ let parentOffset = parent.offset();
if (parent.is(document)) {
parentOffset = { top: 0 };
}
if (elOffset != null && parentOffset != null) {
- var scrollTop = elOffset.top - parentOffset.top - 53;
+ const scrollTop = elOffset.top - parentOffset.top - 53;
parent.scrollTop(scrollTop);
}
},
- scrollToChangelog: function () {
+ scrollToChangelog () {
this.scrollTo('#quality-profile-changelog');
},
- scrollToComparison: function () {
+ scrollToComparison () {
this.scrollTo('#quality-profile-comparison');
},
- getExporters: function () {
- var language = this.model.get('language');
+ getExporters () {
+ const language = this.model.get('language');
return this.options.exporters.filter(function (exporter) {
return exporter.languages.indexOf(language) !== -1;
});
},
- flashChangelog: function () {
- var changelogEl = this.$(this.changelogRegion.el);
+ flashChangelog () {
+ const changelogEl = this.$(this.changelogRegion.el);
changelogEl.addClass('flash in');
setTimeout(function () {
changelogEl.removeClass('in');
}, 2000);
},
- serializeData: function () {
- var key = this.model.get('key'),
- rulesSearchUrl = '/coding_rules#qprofile=' + encodeURIComponent(key) + '|activation=true';
+ serializeData () {
+ const key = this.model.get('key');
+ const rulesSearchUrl = '/coding_rules#qprofile=' + encodeURIComponent(key) + '|activation=true';
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- rulesSearchUrl: rulesSearchUrl,
+ rulesSearchUrl,
canWrite: this.options.canWrite,
exporters: this.getExporters()
});
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 7d3008d9eb7..629b7043a50 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
@@ -40,48 +40,48 @@ export default Marionette.ItemView.extend({
'click #quality-profile-delete': 'onDeleteClick'
},
- onBackupClick: function (e) {
+ onBackupClick (e) {
$(e.currentTarget).blur();
},
- onCopyClick: function (e) {
+ onCopyClick (e) {
e.preventDefault();
this.copy();
},
- onRenameClick: function (e) {
+ onRenameClick (e) {
e.preventDefault();
this.rename();
},
- onDefaultClick: function (e) {
+ onDefaultClick (e) {
e.preventDefault();
this.setAsDefault();
},
- onDeleteClick: function (e) {
+ onDeleteClick (e) {
e.preventDefault();
this.delete();
},
- copy: function () {
+ copy () {
new ProfileCopyView({ model: this.model }).render();
},
- rename: function () {
+ rename () {
new ProfileRenameView({ model: this.model }).render();
},
- setAsDefault: function () {
+ setAsDefault () {
this.model.trigger('setAsDefault', this.model);
},
- delete: function () {
+ delete () {
new ProfileDeleteView({ model: this.model }).render();
},
- serializeData: function () {
- var key = this.model.get('key');
+ serializeData () {
+ const key = this.model.get('key');
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
encodedKey: encodeURIComponent(key),
canWrite: this.options.canWrite
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 6266932fa57..c57ba6c29de 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
@@ -36,23 +36,23 @@ export default Marionette.ItemView.extend({
'click': 'onClick'
},
- onRender: function () {
+ onRender () {
this.$el.toggleClass('active', this.options.highlighted);
this.$el.attr('data-key', this.model.id);
this.$el.attr('data-language', this.model.get('language'));
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onClick: function (e) {
+ onClick (e) {
e.preventDefault();
this.model.trigger('select', this.model);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
projectCountFormatted: formatMeasure(this.model.get('projectCount'), 'INT')
});
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 04018894b05..9508cd7c00d 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
@@ -29,8 +29,8 @@ export default Backbone.Model.extend({
projectCount: 0
},
- fetch: function () {
- var that = this;
+ fetch () {
+ const that = this;
this.fetchChanged = {};
return $.when(
this.fetchProfileRules(),
@@ -40,33 +40,33 @@ export default Backbone.Model.extend({
});
},
- fetchProfileRules: function () {
- var that = this,
- url = '/api/rules/search',
- key = this.id,
- options = {
- ps: 1,
- facets: 'active_severities',
- qprofile: key,
- activation: 'true'
- };
+ fetchProfileRules () {
+ const that = this;
+ const url = '/api/rules/search';
+ const key = this.id;
+ const options = {
+ ps: 1,
+ facets: 'active_severities',
+ qprofile: key,
+ activation: 'true'
+ };
return $.get(url, options).done(function (r) {
- var severityFacet = _.findWhere(r.facets, { property: 'active_severities' });
+ const severityFacet = _.findWhere(r.facets, { property: 'active_severities' });
if (severityFacet != null) {
- var severities = severityFacet.values,
- severityComparator = function (s) {
- return window.severityColumnsComparator(s.val);
- },
- sortedSeverities = _.sortBy(severities, severityComparator);
+ const severities = severityFacet.values;
+ const severityComparator = function (s) {
+ return window.severityColumnsComparator(s.val);
+ };
+ const sortedSeverities = _.sortBy(severities, severityComparator);
_.extend(that.fetchChanged, { rulesSeverities: sortedSeverities });
}
});
},
- fetchInheritance: function () {
- var that = this,
- url = '/api/qualityprofiles/inheritance',
- options = { profileKey: this.id };
+ fetchInheritance () {
+ const that = this;
+ const url = '/api/qualityprofiles/inheritance';
+ const options = { profileKey: this.id };
return $.get(url, options).done(function (r) {
_.extend(that.fetchChanged, r.profile, {
ancestors: r.ancestors,
@@ -75,10 +75,10 @@ export default Backbone.Model.extend({
});
},
- fetchChangelog: function (options) {
- var that = this,
- url = '/api/qualityprofiles/changelog',
- opts = _.extend({}, options, { profileKey: this.id });
+ fetchChangelog (options) {
+ const that = this;
+ const url = '/api/qualityprofiles/changelog';
+ const opts = _.extend({}, options, { profileKey: this.id });
return $.get(url, opts).done(function (r) {
that.set({
events: r.events,
@@ -89,14 +89,14 @@ export default Backbone.Model.extend({
});
},
- fetchMoreChangelog: function () {
- var that = this,
- url = '/api/qualityprofiles/changelog',
- page = this.get('eventsPage') || 0,
- parameters = this.get('eventsParameters') || {},
- opts = _.extend({}, parameters, { profileKey: this.id, p: page + 1 });
+ fetchMoreChangelog () {
+ const that = this;
+ const url = '/api/qualityprofiles/changelog';
+ const page = this.get('eventsPage') || 0;
+ const parameters = this.get('eventsParameters') || {};
+ const opts = _.extend({}, parameters, { profileKey: this.id, p: page + 1 });
return $.get(url, opts).done(function (r) {
- var events = that.get('events') || [];
+ const events = that.get('events') || [];
that.set({
events: [].concat(events, r.events),
eventsPage: r.p,
@@ -105,30 +105,30 @@ export default Backbone.Model.extend({
});
},
- resetChangelog: function () {
+ resetChangelog () {
this.unset('events', { silent: true });
this.unset('eventsPage', { silent: true });
this.unset('totalEvents');
},
- compareWith: function (withKey) {
- var that = this,
- url = '/api/qualityprofiles/compare',
- options = { leftKey: this.id, rightKey: withKey };
+ compareWith (withKey) {
+ const that = this;
+ const url = '/api/qualityprofiles/compare';
+ const options = { leftKey: this.id, rightKey: withKey };
return $.get(url, options).done(function (r) {
- var comparison = _.extend(r, {
+ const comparison = _.extend(r, {
inLeftSize: _.size(r.inLeft),
inRightSize: _.size(r.inRight),
modifiedSize: _.size(r.modified)
});
that.set({
- comparison: comparison,
+ comparison,
comparedWith: withKey
});
});
},
- resetComparison: function () {
+ resetComparison () {
this.unset('comparedWith', { silent: true });
this.unset('comparison');
}
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 7ece0ed72c3..7ded221819f 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
@@ -35,27 +35,27 @@ export default Marionette.CompositeView.extend({
'filter': 'filterByLanguage'
},
- childViewOptions: function (model) {
+ childViewOptions (model) {
return {
collectionView: this,
highlighted: model.get('key') === this.highlighted
};
},
- highlight: function (key) {
+ highlight (key) {
this.highlighted = key;
this.render();
},
- attachHtml: function (compositeView, childView, index) {
- var $container = this.getChildViewContainer(compositeView),
- model = this.collection.at(index);
+ attachHtml (compositeView, childView, index) {
+ const $container = this.getChildViewContainer(compositeView);
+ const model = this.collection.at(index);
if (model != null) {
- var prev = this.collection.at(index - 1),
- putLanguage = prev == null;
+ const prev = this.collection.at(index - 1);
+ let putLanguage = prev == null;
if (prev != null) {
- var lang = model.get('language'),
- prevLang = prev.get('language');
+ const lang = model.get('language');
+ const prevLang = prev.get('language');
if (lang !== prevLang) {
putLanguage = true;
}
@@ -67,12 +67,12 @@ export default Marionette.CompositeView.extend({
compositeView._insertAfter(childView);
},
- destroyChildren: function () {
+ destroyChildren () {
Marionette.CompositeView.prototype.destroyChildren.apply(this, arguments);
this.$('.js-list-language').remove();
},
- filterByLanguage: function (language) {
+ filterByLanguage (language) {
if (language) {
this.$('[data-language]').addClass('hidden');
this.$('[data-language="' + language + '"]').removeClass('hidden');
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 01f9440868f..a170c4f334e 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
@@ -25,14 +25,14 @@ export default Backbone.Collection.extend({
url: '/api/qualityprofiles/search',
comparator: 'key',
- parse: function (r) {
+ parse (r) {
return r.profiles;
},
- updateForLanguage: function (language) {
+ updateForLanguage (language) {
this.fetch({
data: {
- language: language
+ language
},
merge: true,
reset: false,
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/rename-profile-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/rename-profile-view.js
index 4093cf3ff60..4e15d54fc6b 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/rename-profile-view.js
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/rename-profile-view.js
@@ -24,29 +24,29 @@ import Template from './templates/quality-profiles-rename-profile.hbs';
export default ModalFormView.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- url = '/api/qualityprofiles/rename',
- name = this.$('#rename-profile-name').val(),
- options = {
- key: this.model.get('key'),
- name: name
- };
+ sendRequest () {
+ const that = this;
+ const url = '/api/qualityprofiles/rename';
+ const name = this.$('#rename-profile-name').val();
+ const options = {
+ key: this.model.get('key'),
+ name
+ };
return $.ajax({
+ url,
type: 'POST',
- url: url,
data: options,
statusCode: {
// do not show global error
400: null
}
}).done(function () {
- that.model.set({ name: name });
+ that.model.set({ name });
that.destroy();
}).fail(function (jqXHR) {
that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
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 3386cfe6a75..2115422bf38 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,17 +27,17 @@ export default ModalFormView.extend({
template: Template,
successTemplate: TemplateSuccess,
- getTemplate: function () {
+ getTemplate () {
return this.selectedLanguage ? this.successTemplate : this.template;
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
this.disableForm();
this.sendRequest();
},
- onRender: function () {
+ onRender () {
ModalFormView.prototype.onRender.apply(this, arguments);
this.$('select').select2({
width: '250px',
@@ -45,15 +45,15 @@ export default ModalFormView.extend({
});
},
- sendRequest: function () {
- var that = this,
- url = '/api/qualityprofiles/restore_built_in',
- lang = this.$('#restore-built-in-profiles-language').val(),
- options = { language: lang };
+ sendRequest () {
+ const that = this;
+ const url = '/api/qualityprofiles/restore_built_in';
+ const lang = this.$('#restore-built-in-profiles-language').val();
+ const options = { language: lang };
this.selectedLanguage = _.findWhere(this.options.languages, { key: lang }).name;
return $.ajax({
type: 'POST',
- url: url,
+ url,
data: options,
statusCode: {
// do not show global error
@@ -69,7 +69,7 @@ export default ModalFormView.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
languages: this.options.languages,
selectedLanguage: this.selectedLanguage
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/restore-profile-view.js b/server/sonar-web/src/main/js/apps/quality-profiles/restore-profile-view.js
index 7eb44173f00..ca291aa302a 100644
--- a/server/sonar-web/src/main/js/apps/quality-profiles/restore-profile-view.js
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/restore-profile-view.js
@@ -27,8 +27,8 @@ import Template from './templates/quality-profiles-restore-profile.hbs';
export default ModalFormView.extend({
template: Template,
- onFormSubmit: function (e) {
- var that = this;
+ onFormSubmit (e) {
+ const that = this;
ModalFormView.prototype.onFormSubmit.apply(this, arguments);
uploader({ form: $(e.currentTarget) }).done(function (r) {
if (_.isArray(r.errors) || _.isArray(r.warnings)) {
@@ -40,10 +40,10 @@ export default ModalFormView.extend({
});
},
- addProfile: function (profileData) {
- var profile = new Profile(profileData);
+ addProfile (profileData) {
+ const profile = new Profile(profileData);
this.collection.add([profile], { merge: true });
- var addedProfile = this.collection.get(profile.id);
+ const addedProfile = this.collection.get(profile.id);
if (addedProfile != null) {
addedProfile.trigger('select', addedProfile);
}
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 9dd0288cb11..2bab1758015 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
@@ -28,25 +28,25 @@ export default Backbone.Router.extend({
'compare*': 'compare'
},
- initialize: function (options) {
+ initialize (options) {
this.app = options.app;
},
- index: function () {
+ index () {
this.app.controller.index();
},
- show: function (key) {
+ show (key) {
this.app.controller.show(key);
},
- changelog: function () {
- var params = window.getQueryParams();
+ changelog () {
+ const params = window.getQueryParams();
this.app.controller.changelog(params.key, params.since, params.to);
},
- compare: function () {
- var params = window.getQueryParams();
+ compare () {
+ const params = window.getQueryParams();
if (params.key && params.withKey) {
this.app.controller.compare(params.key, params.withKey);
}
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 7f23ec9bbb5..1be6f211f36 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
@@ -20,23 +20,23 @@
import Marionette from 'backbone.marionette';
import SourceViewer from '../../components/source-viewer/main';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- this.addRegions({ mainRegion: options.el });
+ this.addRegions({ mainRegion: options.el });
- var viewer = new SourceViewer();
- this.mainRegion.show(viewer);
- viewer.open(options.file.uuid);
- if (typeof options.file.line === 'number') {
- viewer.on('loaded', function () {
- viewer
- .highlightLine(options.file.line)
- .scrollToLine(options.file.line);
- });
- }
- };
+ const viewer = new SourceViewer();
+ this.mainRegion.show(viewer);
+ viewer.open(options.file.uuid);
+ if (typeof options.file.line === 'number') {
+ viewer.on('loaded', function () {
+ viewer
+ .highlightLine(options.file.line)
+ .scrollToLine(options.file.line);
+ });
+ }
+};
App.on('start', function () {
init.call(App);
diff --git a/server/sonar-web/src/main/js/apps/system/app.js b/server/sonar-web/src/main/js/apps/system/app.js
index 1710ccfb4b5..1aec0d92665 100644
--- a/server/sonar-web/src/main/js/apps/system/app.js
+++ b/server/sonar-web/src/main/js/apps/system/app.js
@@ -22,7 +22,7 @@ import ReactDOM from 'react-dom';
import Main from './main';
window.sonarqube.appStarted.then(options => {
- var el = document.querySelector(options.el);
+ const el = document.querySelector(options.el);
ReactDOM.render(<Main/>, el);
});
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 0ab694232fc..63c125c2740 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
@@ -28,51 +28,51 @@ import Controller from './controller';
import Router from './router';
import Plugins from './plugins';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- // State
- this.state = new Backbone.Model({
- updateCenterActive: window.SS.updateCenterActive
- });
+ // State
+ this.state = new Backbone.Model({
+ updateCenterActive: window.SS.updateCenterActive
+ });
- // Layout
- this.layout = new Layout({ el: options.el });
- this.layout.render();
+ // Layout
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
- // Plugins
- this.plugins = new Plugins();
+ // Plugins
+ this.plugins = new Plugins();
- // Controller
- this.controller = new Controller({ collection: this.plugins, state: this.state });
+ // Controller
+ this.controller = new Controller({ collection: this.plugins, state: this.state });
- // Router
- this.router = new Router({ controller: this.controller });
+ // Router
+ this.router = new Router({ controller: this.controller });
- // Header
- this.headerView = new HeaderView({ collection: this.plugins });
- this.layout.headerRegion.show(this.headerView);
+ // Header
+ this.headerView = new HeaderView({ collection: this.plugins });
+ this.layout.headerRegion.show(this.headerView);
- // Search
- this.searchView = new SearchView({ collection: this.plugins, router: this.router, state: this.state });
- this.layout.searchRegion.show(this.searchView);
- this.searchView.focusSearch();
+ // Search
+ this.searchView = new SearchView({ collection: this.plugins, router: this.router, state: this.state });
+ this.layout.searchRegion.show(this.searchView);
+ this.searchView.focusSearch();
- // List
- this.listView = new ListView({ collection: this.plugins });
- this.layout.listRegion.show(this.listView);
+ // List
+ this.listView = new ListView({ collection: this.plugins });
+ this.layout.listRegion.show(this.listView);
- // Footer
- this.footerView = new FooterView({ collection: this.plugins });
- this.layout.footerRegion.show(this.footerView);
+ // Footer
+ this.footerView = new FooterView({ collection: this.plugins });
+ this.layout.footerRegion.show(this.footerView);
- // Go
- Backbone.history.start({
- pushState: true,
- root: options.urlRoot
- });
- };
+ // Go
+ Backbone.history.start({
+ pushState: true,
+ root: options.urlRoot
+ });
+};
App.on('start', function () {
init.call(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 ebc932de346..e7e091be69e 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
@@ -20,27 +20,27 @@
import Marionette from 'backbone.marionette';
export default Marionette.Controller.extend({
- initialize: function (options) {
+ initialize (options) {
this.collection = options.collection;
this.state = options.state;
},
- showInstalled: function () {
+ showInstalled () {
this.state.set({ section: 'installed' });
this.collection.fetchInstalled();
},
- showUpdates: function () {
+ showUpdates () {
this.state.set({ section: 'updates' });
this.collection.fetchUpdates();
},
- showAvailable: function () {
+ showAvailable () {
this.state.set({ section: 'available' });
this.collection.fetchAvailable();
},
- showSystemUpgrades: function () {
+ showSystemUpgrades () {
this.state.set({ section: 'system' });
this.collection.fetchSystemUpgrades();
}
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 0f9f814597d..a96d7201040 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
@@ -28,7 +28,7 @@ export default Marionette.ItemView.extend({
'all': 'render'
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
total: this.collection.where({ _hidden: false }).length
});
diff --git a/server/sonar-web/src/main/js/apps/update-center/list-item-view.js b/server/sonar-web/src/main/js/apps/update-center/list-item-view.js
index 2287e41e615..b264732859c 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
@@ -45,11 +45,11 @@ export default Marionette.ItemView.extend({
'click .js-plugin-category': 'onCategoryClick'
},
- getTemplate: function () {
+ getTemplate () {
return this.model.get('_system') ? this.systemTemplate : this.template;
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-id', this.model.id);
if (this.model.get('_system')) {
this.$el.attr('data-system', '');
@@ -57,58 +57,58 @@ export default Marionette.ItemView.extend({
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onModelChange: function () {
+ onModelChange () {
if (!this.model.hasChanged('_hidden')) {
this.render();
}
},
- onChangelogClick: function (e) {
+ onChangelogClick (e) {
e.preventDefault();
e.stopPropagation();
$('body').click();
- var index = $(e.currentTarget).data('idx'),
+ const index = $(e.currentTarget).data('idx');
// if show changelog of update, show details of this update
// otherwise show changelog of the available release
- update = this.model.has('release') ? this.model.toJSON() : this.model.get('updates')[index],
- popup = new PluginChangelogView({
- triggerEl: $(e.currentTarget),
- model: new Backbone.Model(update)
- });
+ const update = this.model.has('release') ? this.model.toJSON() : this.model.get('updates')[index];
+ const popup = new PluginChangelogView({
+ triggerEl: $(e.currentTarget),
+ model: new Backbone.Model(update)
+ });
popup.render();
},
- onRequest: function () {
+ onRequest () {
this.$('.js-actions').addClass('hidden');
this.$('.js-spinner').removeClass('hidden');
},
- toggleDisplay: function () {
+ toggleDisplay () {
this.$el.toggleClass('hidden', this.model.get('_hidden'));
},
- install: function () {
+ install () {
this.model.install();
},
- update: function () {
+ update () {
this.model.update();
},
- uninstall: function () {
+ uninstall () {
this.model.uninstall();
},
- onTermsChange: function () {
- var isAccepted = this.$('.js-terms').is(':checked');
+ onTermsChange () {
+ const isAccepted = this.$('.js-terms').is(':checked');
this.$('.js-install').prop('disabled', !isAccepted);
},
- onCategoryClick: function (e) {
+ onCategoryClick (e) {
e.preventDefault();
this.model.trigger('filter', this.model);
}
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 86ee00f3441..fd8e6c63306 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
@@ -24,18 +24,18 @@ import Template from './templates/update-center-plugin-changelog.hbs';
export default Popup.extend({
template: Template,
- onRender: function () {
+ onRender () {
Popup.prototype.onRender.apply(this, arguments);
this.$('.bubble-popup-container').isolatedScroll();
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
Popup.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- serializeData: function () {
+ serializeData () {
return _.extend(Popup.prototype.serializeData.apply(this, arguments), {
// if there is no status, this is a new plugin
// => force COMPATIBLE status
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 6e6807e2a06..959ee5eb378 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
@@ -28,59 +28,59 @@ export default Backbone.Model.extend({
_system: false
},
- _matchAttribute: function (attr, query) {
- var value = this.get(attr) || '';
+ _matchAttribute (attr, query) {
+ const value = this.get(attr) || '';
return value.search(new RegExp(query, 'i')) !== -1;
},
- match: function (query) {
+ match (query) {
return this._matchAttribute('name', query) ||
this._matchAttribute('category', query) ||
this._matchAttribute('description', query);
},
- _action: function (options) {
- var that = this;
- var opts = _.extend({}, options, {
+ _action (options) {
+ const that = this;
+ const opts = _.extend({}, options, {
type: 'POST',
data: { key: this.id },
- beforeSend: function () {
+ beforeSend () {
// disable global ajax notifications
},
- success: function () {
+ success () {
options.success(that);
},
- error: function (jqXHR) {
+ error (jqXHR) {
that.set({ _status: 'failed', _errors: jqXHR.responseJSON.errors });
}
});
- var xhr = Backbone.ajax(opts);
+ const xhr = Backbone.ajax(opts);
this.trigger('request', this, xhr);
return xhr;
},
- install: function () {
+ install () {
return this._action({
url: '/api/plugins/install',
- success: function (model) {
+ success (model) {
model.set({ _status: 'installing' });
}
});
},
- update: function () {
+ update () {
return this._action({
url: '/api/plugins/update',
- success: function (model) {
+ success (model) {
model.set({ _status: 'installing' });
}
});
},
- uninstall: function () {
+ uninstall () {
return this._action({
url: '/api/plugins/uninstall',
- success: function (model) {
+ success (model) {
model.set({ _status: 'uninstalling' });
}
});
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 537a1d38c33..fee5a59fb0b 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
@@ -22,23 +22,23 @@ import _ from 'underscore';
import Backbone from 'backbone';
import Plugin from './plugin';
-var Plugins = Backbone.Collection.extend({
+const Plugins = Backbone.Collection.extend({
model: Plugin,
- comparator: function (model) {
+ comparator (model) {
return model.get('name') || '';
},
- initialize: function () {
+ initialize () {
this._installedCount = 0;
this._uninstalledCount = 0;
this.listenTo(this, 'change:_status', this.onStatusChange);
},
- parse: function (r) {
- var that = this;
+ parse (r) {
+ const that = this;
return r.plugins.map(function (plugin) {
- var updates = [
+ let updates = [
that._getLastWithStatus(plugin.updates, 'COMPATIBLE'),
that._getLastWithStatus(plugin.updates, 'REQUIRES_SYSTEM_UPGRADE'),
that._getLastWithStatus(plugin.updates, 'DEPS_REQUIRE_SYSTEM_UPGRADE')
@@ -46,80 +46,80 @@ var Plugins = Backbone.Collection.extend({
updates = updates.map(function (update) {
return that._extendChangelog(plugin.updates, update);
});
- return _.extend(plugin, { updates: updates });
+ return _.extend(plugin, { updates });
});
},
- _getLastWithStatus: function (updates, status) {
- var index = _.findLastIndex(updates, function (update) {
+ _getLastWithStatus (updates, status) {
+ const index = _.findLastIndex(updates, function (update) {
return update.status === status;
});
return index !== -1 ? updates[index] : null;
},
- _extendChangelog: function (updates, update) {
- var index = updates.indexOf(update);
- var previousUpdates = index > 0 ? updates.slice(0, index) : [];
- return _.extend(update, { previousUpdates: previousUpdates });
+ _extendChangelog (updates, update) {
+ const index = updates.indexOf(update);
+ const previousUpdates = index > 0 ? updates.slice(0, index) : [];
+ return _.extend(update, { previousUpdates });
},
- _fetchInstalled: function () {
+ _fetchInstalled () {
if (this._installed) {
return $.Deferred().resolve().promise();
}
- var that = this;
- var opts = {
+ const that = this;
+ const opts = {
type: 'GET',
url: '/api/plugins/installed',
- success: function (r) {
+ success (r) {
that._installed = that.parse(r);
}
};
return Backbone.ajax(opts);
},
- _fetchUpdates: function () {
+ _fetchUpdates () {
if (this._updates) {
return $.Deferred().resolve().promise();
}
- var that = this;
- var opts = {
+ const that = this;
+ const opts = {
type: 'GET',
url: '/api/plugins/updates',
- success: function (r) {
+ success (r) {
that._updates = that.parse(r);
}
};
return Backbone.ajax(opts);
},
- _fetchAvailable: function () {
+ _fetchAvailable () {
if (this._available) {
return $.Deferred().resolve().promise();
}
- var that = this;
- var opts = {
+ const that = this;
+ const opts = {
type: 'GET',
url: '/api/plugins/available',
- success: function (r) {
+ success (r) {
that._available = that.parse(r);
}
};
return Backbone.ajax(opts);
},
- _fetchPending: function () {
- var that = this;
- var opts = {
+ _fetchPending () {
+ const that = this;
+ const opts = {
type: 'GET',
url: '/api/plugins/pending',
- success: function (r) {
- var installing = r.installing.map(function (plugin) {
- return { key: plugin.key, _status: 'installing' };
- }),
- uninstalling = r.removing.map(function (plugin) {
- return { key: plugin.key, _status: 'uninstalling' };
- });
+ success (r) {
+ const installing = r.installing.map(function (plugin) {
+ return { key: plugin.key, _status: 'installing' };
+ });
+ const uninstalling = r.removing.map(function (plugin) {
+ return { key: plugin.key, _status: 'uninstalling' };
+ });
that._installedCount = installing.length;
that._uninstalledCount = uninstalling.length;
that._pending = new Plugins([].concat(installing, uninstalling)).models;
@@ -128,15 +128,15 @@ var Plugins = Backbone.Collection.extend({
return Backbone.ajax(opts);
},
- _fetchSystemUpgrades: function () {
+ _fetchSystemUpgrades () {
if (this._systemUpdates) {
return $.Deferred().resolve().promise();
}
- var that = this;
- var opts = {
+ const that = this;
+ const opts = {
type: 'GET',
url: '/api/system/upgrades',
- success: function (r) {
+ success (r) {
that._systemUpdates = r.upgrades.map(function (update) {
return _.extend(update, { _system: true });
});
@@ -145,10 +145,10 @@ var Plugins = Backbone.Collection.extend({
return Backbone.ajax(opts);
},
- fetchInstalled: function () {
- var that = this;
+ fetchInstalled () {
+ const that = this;
return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending()).done(function () {
- var plugins = new Plugins();
+ const plugins = new Plugins();
plugins.set(that._installed);
plugins.set(that._updates, { remove: false });
plugins.set(that._pending, { add: false, remove: false });
@@ -156,11 +156,11 @@ var Plugins = Backbone.Collection.extend({
});
},
- fetchUpdates: function () {
- var that = this;
+ fetchUpdates () {
+ const that = this;
return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending())
.done(function () {
- var plugins = new Plugins();
+ const plugins = new Plugins();
plugins.set(that._installed);
plugins.set(that._updates, { remove: true });
plugins.set(that._pending, { add: false, remove: false });
@@ -168,35 +168,35 @@ var Plugins = Backbone.Collection.extend({
});
},
- fetchAvailable: function () {
- var that = this;
+ fetchAvailable () {
+ const that = this;
return $.when(this._fetchAvailable(), this._fetchPending()).done(function () {
- var plugins = new Plugins();
+ const plugins = new Plugins();
plugins.set(that._available);
plugins.set(that._pending, { add: false, remove: false });
that.reset(plugins.models);
});
},
- fetchSystemUpgrades: function () {
- var that = this;
+ fetchSystemUpgrades () {
+ const that = this;
return $.when(this._fetchSystemUpgrades()).done(function () {
that.reset(that._systemUpdates);
});
},
- search: function (query) {
+ search (query) {
this.filter(function (model) {
model.set({ _hidden: !model.match(query) });
});
},
- cancelAll: function () {
- var that = this;
- var opts = {
+ cancelAll () {
+ const that = this;
+ const opts = {
type: 'POST',
url: '/api/plugins/cancel_all',
- success: function () {
+ success () {
that._installedCount = 0;
that._uninstalledCount = 0;
that.forEach(function (model) {
@@ -208,7 +208,7 @@ var Plugins = Backbone.Collection.extend({
return Backbone.ajax(opts);
},
- onStatusChange: function (model, status) {
+ onStatusChange (model, status) {
if (status === 'installing') {
this._installedCount++;
}
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 624f73c7943..211f90e2b4b 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
@@ -28,27 +28,27 @@ export default Backbone.Router.extend({
'system': 'showSystemUpgrades'
},
- initialize: function (options) {
+ initialize (options) {
this.controller = options.controller;
},
- index: function () {
+ index () {
this.navigate('installed', { trigger: true, replace: true });
},
- showInstalled: function () {
+ showInstalled () {
this.controller.showInstalled();
},
- showUpdates: function () {
+ showUpdates () {
this.controller.showUpdates();
},
- showAvailable: function () {
+ showAvailable () {
this.controller.showAvailable();
},
- showSystemUpgrades: function () {
+ showSystemUpgrades () {
this.controller.showSystemUpgrades();
}
});
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 a3893d1baae..90cfa892ce9 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
@@ -37,36 +37,36 @@ export default Marionette.ItemView.extend({
'filter': 'onFilter'
},
- initialize: function () {
+ initialize () {
this._bufferedValue = null;
this.search = _.debounce(this.search, 50);
this.listenTo(this.options.state, 'change', this.render);
},
- onRender: function () {
+ onRender () {
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFilterChange: function () {
- var value = this.$('[name="update-center-filter"]:checked').val();
+ onFilterChange () {
+ const value = this.$('[name="update-center-filter"]:checked').val();
this.filter(value);
},
- filter: function (value) {
+ filter (value) {
this.options.router.navigate(value, { trigger: true });
},
- onFormSubmit: function (e) {
+ onFormSubmit (e) {
e.preventDefault();
this.debouncedOnKeyUp();
},
- onKeyUp: function () {
- var q = this.getQuery();
+ onKeyUp () {
+ const q = this.getQuery();
if (q === this._bufferedValue) {
return;
}
@@ -74,28 +74,28 @@ export default Marionette.ItemView.extend({
this.search(q);
},
- getQuery: function () {
+ getQuery () {
return this.$('#update-center-search-query').val();
},
- search: function (q) {
+ search (q) {
this.collection.search(q);
},
- focusSearch: function () {
- var that = this;
+ focusSearch () {
+ const that = this;
setTimeout(function () {
that.$('#update-center-search-query').focus();
}, 0);
},
- onFilter: function (model) {
- var q = model.get('category');
+ onFilter (model) {
+ const q = model.get('category');
this.$('#update-center-search-query').val(q);
this.search(q);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
state: this.options.state.toJSON()
});
diff --git a/server/sonar-web/src/main/js/apps/users/app.js b/server/sonar-web/src/main/js/apps/users/app.js
index df15aef9726..c2890dabf8d 100644
--- a/server/sonar-web/src/main/js/apps/users/app.js
+++ b/server/sonar-web/src/main/js/apps/users/app.js
@@ -25,36 +25,36 @@ import SearchView from './search-view';
import ListView from './list-view';
import ListFooterView from './list-footer-view';
-var App = new Marionette.Application(),
- init = function () {
- let options = window.sonarqube;
+const App = new Marionette.Application();
+const init = function () {
+ let options = window.sonarqube;
- // Layout
- this.layout = new Layout({ el: options.el });
- this.layout.render();
+ // Layout
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
- // Collection
- this.users = new Users();
+ // Collection
+ this.users = new Users();
- // Header View
- this.headerView = new HeaderView({ collection: this.users });
- this.layout.headerRegion.show(this.headerView);
+ // Header View
+ this.headerView = new HeaderView({ collection: this.users });
+ this.layout.headerRegion.show(this.headerView);
- // Search View
- this.searchView = new SearchView({ collection: this.users });
- this.layout.searchRegion.show(this.searchView);
+ // Search View
+ this.searchView = new SearchView({ collection: this.users });
+ this.layout.searchRegion.show(this.searchView);
- // List View
- this.listView = new ListView({ collection: this.users });
- this.layout.listRegion.show(this.listView);
+ // List View
+ this.listView = new ListView({ collection: this.users });
+ this.layout.listRegion.show(this.listView);
- // List Footer View
- this.listFooterView = new ListFooterView({ collection: this.users });
- this.layout.listFooterRegion.show(this.listFooterView);
+ // List Footer View
+ this.listFooterView = new ListFooterView({ collection: this.users });
+ this.layout.listFooterRegion.show(this.listFooterView);
- // Go!
- this.users.fetch();
- };
+ // Go!
+ this.users.fetch();
+};
App.on('start', function () {
init.call(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 19c2176aa8b..29178ba33f2 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
@@ -23,16 +23,16 @@ import Template from './templates/users-change-password.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- oldPassword = this.$('#change-user-password-old-password').val(),
- password = this.$('#change-user-password-password').val(),
- confirmation = this.$('#change-user-password-password-confirmation').val();
+ sendRequest () {
+ const that = this;
+ const oldPassword = this.$('#change-user-password-old-password').val();
+ const password = this.$('#change-user-password-password').val();
+ const confirmation = this.$('#change-user-password-password-confirmation').val();
if (password !== confirmation) {
that.showErrors([{ msg: 'New password and its confirmation do not match' }]);
return;
@@ -51,7 +51,7 @@ export default ModalForm.extend({
});
},
- serializeData: function () {
+ serializeData () {
return Object.assign({}, ModalForm.prototype.serializeData.apply(this, arguments), {
isOwnPassword: window.SS.user === this.model.id
});
diff --git a/server/sonar-web/src/main/js/apps/users/create-view.js b/server/sonar-web/src/main/js/apps/users/create-view.js
index 50b026707f4..58adadd3360 100644
--- a/server/sonar-web/src/main/js/apps/users/create-view.js
+++ b/server/sonar-web/src/main/js/apps/users/create-view.js
@@ -22,15 +22,15 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this,
- user = new User({
- login: this.$('#create-user-login').val(),
- name: this.$('#create-user-name').val(),
- email: this.$('#create-user-email').val(),
- password: this.$('#create-user-password').val(),
- scmAccounts: this.getScmAccounts()
- });
+ sendRequest () {
+ const that = this;
+ const user = new User({
+ login: this.$('#create-user-login').val(),
+ name: this.$('#create-user-name').val(),
+ email: this.$('#create-user-email').val(),
+ password: this.$('#create-user-password').val(),
+ scmAccounts: this.getScmAccounts()
+ });
this.disableForm();
return user.save(null, {
statusCode: {
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 a707df30123..073e3a9b6fa 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
@@ -23,14 +23,14 @@ import Template from './templates/users-deactivate.hbs';
export default ModalForm.extend({
template: Template,
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- sendRequest: function () {
- var that = this,
- collection = this.model.collection;
+ sendRequest () {
+ const that = this;
+ const collection = this.model.collection;
return this.model.destroy({
wait: true,
statusCode: {
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 6435b509ccf..2f5b93ea492 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
@@ -25,34 +25,34 @@ import Template from './templates/users-form.hbs';
export default ModalForm.extend({
template: Template,
- events: function () {
+ events () {
return _.extend(ModalForm.prototype.events.apply(this, arguments), {
'click #create-user-add-scm-account': 'onAddScmAccountClick'
});
},
- onRender: function () {
+ onRender () {
ModalForm.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
ModalForm.prototype.onDestroy.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onFormSubmit: function () {
+ onFormSubmit () {
ModalForm.prototype.onFormSubmit.apply(this, arguments);
this.sendRequest();
},
- onAddScmAccountClick: function (e) {
+ onAddScmAccountClick (e) {
e.preventDefault();
this.addScmAccount();
},
- getScmAccounts: function () {
- var scmAccounts = this.$('[name="scmAccounts"]').map(function () {
+ getScmAccounts () {
+ const scmAccounts = this.$('[name="scmAccounts"]').map(function () {
return $(this).val();
}).toArray();
return scmAccounts.filter(function (value) {
@@ -60,8 +60,8 @@ export default ModalForm.extend({
});
},
- addScmAccount: function () {
- var fields = this.$('[name="scmAccounts"]');
+ addScmAccount () {
+ const fields = this.$('[name="scmAccounts"]');
fields.first().clone().val('').insertAfter(fields.last());
}
});
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 30fdb22fc44..d8af44fb4f7 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
@@ -24,14 +24,14 @@ import Template from './templates/users-groups.hbs';
export default Modal.extend({
template: Template,
- onRender: function () {
+ onRender () {
Modal.prototype.onRender.apply(this, arguments);
new window.SelectList({
el: this.$('#users-groups'),
width: '100%',
readOnly: false,
focusSearch: false,
- format: function (item) {
+ format (item) {
return item.name + '<br><span class="note">' + item.description + '</span>';
},
queryParam: 'q',
@@ -43,14 +43,14 @@ export default Modal.extend({
},
selectParameter: 'id',
selectParameterValue: 'id',
- parse: function (r) {
+ parse (r) {
this.more = false;
return r.groups;
}
});
},
- onDestroy: function () {
+ onDestroy () {
this.model.collection.refresh();
Modal.prototype.onDestroy.apply(this, arguments);
}
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 38cb287eb08..3b5a06a3da7 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
@@ -33,20 +33,20 @@ export default Marionette.ItemView.extend({
'click #users-create': 'onCreateClick'
},
- showSpinner: function () {
+ showSpinner () {
this.$('.spinner').removeClass('hidden');
},
- hideSpinner: function () {
+ hideSpinner () {
this.$('.spinner').addClass('hidden');
},
- onCreateClick: function (e) {
+ onCreateClick (e) {
e.preventDefault();
this.createUser();
},
- createUser: function () {
+ createUser () {
new CreateView({
collection: this.collection
}).render();
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 9bc186f7de5..817fcd380e1 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
@@ -32,16 +32,16 @@ export default Marionette.ItemView.extend({
'click #users-fetch-more': 'onMoreClick'
},
- onMoreClick: function (e) {
+ onMoreClick (e) {
e.preventDefault();
this.fetchMore();
},
- fetchMore: function () {
+ fetchMore () {
this.collection.fetchMore();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
total: this.collection.total,
count: this.collection.length,
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 c1fe4faea70..6e06fd37557 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
@@ -40,96 +40,96 @@ export default Marionette.ItemView.extend({
'click .js-user-tokens': 'onTokensClick'
},
- initialize: function () {
+ initialize () {
this.scmLimit = 3;
this.groupsLimit = 3;
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-login', this.model.id);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onMoreScmClick: function (e) {
+ onMoreScmClick (e) {
e.preventDefault();
this.showMoreScm();
},
- onMoreGroupsClick: function (e) {
+ onMoreGroupsClick (e) {
e.preventDefault();
this.showMoreGroups();
},
- onUpdateClick: function (e) {
+ onUpdateClick (e) {
e.preventDefault();
this.updateUser();
},
- onChangePasswordClick: function (e) {
+ onChangePasswordClick (e) {
e.preventDefault();
this.changePassword();
},
- onDeactivateClick: function (e) {
+ onDeactivateClick (e) {
e.preventDefault();
this.deactivateUser();
},
- onGroupsClick: function (e) {
+ onGroupsClick (e) {
e.preventDefault();
this.showGroups();
},
- onTokensClick: function (e) {
+ onTokensClick (e) {
e.preventDefault();
this.showTokens();
},
- showMoreScm: function () {
+ showMoreScm () {
this.scmLimit = 10000;
this.render();
},
- showMoreGroups: function () {
+ showMoreGroups () {
this.groupsLimit = 10000;
this.render();
},
- updateUser: function () {
+ updateUser () {
new UpdateView({
model: this.model,
collection: this.model.collection
}).render();
},
- changePassword: function () {
+ changePassword () {
new ChangePasswordView({
model: this.model,
collection: this.model.collection
}).render();
},
- deactivateUser: function () {
+ deactivateUser () {
new DeactivateView({ model: this.model }).render();
},
- showGroups: function () {
+ showGroups () {
new GroupsView({ model: this.model }).render();
},
- showTokens: function () {
+ showTokens () {
new TokensView({ model: this.model }).render();
},
- serializeData: function () {
- var scmAccounts = this.model.get('scmAccounts'),
- 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;
+ serializeData () {
+ const scmAccounts = this.model.get('scmAccounts');
+ const scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit;
+ const groups = this.model.get('groups');
+ const groupsLimit = groups.length > this.groupsLimit ? this.groupsLimit - 1 : this.groupsLimit;
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
firstScmAccounts: _.first(scmAccounts, scmAccountsLimit),
moreScmAccountsCount: scmAccounts.length - scmAccountsLimit,
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 e03b424b461..90f212af173 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
@@ -33,11 +33,11 @@ export default Marionette.CompositeView.extend({
'sync': 'hideLoading'
},
- showLoading: function () {
+ showLoading () {
this.$el.addClass('new-loading');
},
- hideLoading: function () {
+ hideLoading () {
this.$el.removeClass('new-loading');
}
});
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 abc63a611b9..c8c0df459ff 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
@@ -30,22 +30,22 @@ export default Marionette.ItemView.extend({
'keyup #users-search-query': 'debouncedOnKeyUp'
},
- initialize: function () {
+ initialize () {
this._bufferedValue = null;
this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
},
- onRender: function () {
+ onRender () {
this.delegateEvents();
},
- onFormSubmit: function (e) {
+ onFormSubmit (e) {
e.preventDefault();
this.debouncedOnKeyUp();
},
- onKeyUp: function () {
- var q = this.getQuery();
+ onKeyUp () {
+ const q = this.getQuery();
if (q === this._bufferedValue) {
return;
}
@@ -56,12 +56,12 @@ export default Marionette.ItemView.extend({
this.searchRequest = this.search(q);
},
- getQuery: function () {
+ getQuery () {
return this.$('#users-search-query').val();
},
- search: function (q) {
- return this.collection.fetch({ reset: true, data: { q: q } });
+ search (q) {
+ return this.collection.fetch({ reset: true, data: { q } });
}
});
diff --git a/server/sonar-web/src/main/js/apps/users/tokens-view.js b/server/sonar-web/src/main/js/apps/users/tokens-view.js
index 12989a52a52..a88d92a7f29 100644
--- a/server/sonar-web/src/main/js/apps/users/tokens-view.js
+++ b/server/sonar-web/src/main/js/apps/users/tokens-view.js
@@ -96,7 +96,7 @@ export default Modal.extend({
this.newToken = null;
},
- onDestroy: function () {
+ onDestroy () {
this.model.collection.refresh();
Modal.prototype.onDestroy.apply(this, arguments);
},
diff --git a/server/sonar-web/src/main/js/apps/users/update-view.js b/server/sonar-web/src/main/js/apps/users/update-view.js
index b3eb3dc2bc3..7dc44aeff96 100644
--- a/server/sonar-web/src/main/js/apps/users/update-view.js
+++ b/server/sonar-web/src/main/js/apps/users/update-view.js
@@ -21,8 +21,8 @@ import FormView from './form-view';
export default FormView.extend({
- sendRequest: function () {
- var that = this;
+ sendRequest () {
+ const that = this;
this.model.set({
name: this.$('#create-user-name').val(),
email: this.$('#create-user-email').val(),
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 86fc8870f5a..84e7728dc2a 100644
--- a/server/sonar-web/src/main/js/apps/users/user.js
+++ b/server/sonar-web/src/main/js/apps/users/user.js
@@ -23,19 +23,19 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
idAttribute: 'login',
- urlRoot: function () {
+ urlRoot () {
return '/api/users';
},
- defaults: function () {
+ defaults () {
return {
groups: [],
scmAccounts: []
};
},
- toQuery: function () {
- var q = this.toJSON();
+ toQuery () {
+ const q = this.toJSON();
_.each(q, function (value, key) {
if (_.isArray(value)) {
q[key] = value.join(',');
@@ -44,13 +44,13 @@ export default Backbone.Model.extend({
return q;
},
- isNew: function () {
+ isNew () {
// server never sends a password
return this.has('password');
},
- sync: function (method, model, options) {
- var opts = options || {};
+ sync (method, model, options) {
+ const opts = options || {};
if (method === 'create') {
_.defaults(opts, {
url: this.urlRoot() + '/create',
@@ -75,18 +75,18 @@ export default Backbone.Model.extend({
return Backbone.ajax(opts);
},
- changePassword: function (oldPassword, password, options) {
+ changePassword (oldPassword, password, options) {
const data = {
login: this.id,
- password: password
+ password
};
if (oldPassword != null) {
data.previousPassword = oldPassword;
}
- var opts = _.defaults(options || {}, {
+ const opts = _.defaults(options || {}, {
url: this.urlRoot() + '/change_password',
type: 'POST',
- data: data
+ data
});
return Backbone.ajax(opts);
}
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 e9140fc39bb..8759d700c5a 100644
--- a/server/sonar-web/src/main/js/apps/users/users.js
+++ b/server/sonar-web/src/main/js/apps/users/users.js
@@ -23,33 +23,33 @@ import User from './user';
export default Backbone.Collection.extend({
model: User,
- url: function () {
+ url () {
return '/api/users/search';
},
- parse: function (r) {
+ parse (r) {
this.total = +r.total;
this.p = +r.p;
this.ps = +r.ps;
return r.users;
},
- fetch: function (options) {
- var d = (options && options.data) || {};
+ fetch (options) {
+ const d = (options && options.data) || {};
this.q = d.q;
return Backbone.Collection.prototype.fetch.call(this, options);
},
- fetchMore: function () {
- var p = this.p + 1;
- return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps, q: this.q } });
+ fetchMore () {
+ const p = this.p + 1;
+ return this.fetch({ add: true, remove: false, data: { p, ps: this.ps, q: this.q } });
},
- refresh: function () {
+ refresh () {
return this.fetch({ reset: true, data: { q: this.q } });
},
- hasMore: function () {
+ hasMore () {
return this.total > this.p * this.ps;
}
diff --git a/server/sonar-web/src/main/js/components/SelectList/index.js b/server/sonar-web/src/main/js/components/SelectList/index.js
index b02014c4015..6c668832d43 100644
--- a/server/sonar-web/src/main/js/components/SelectList/index.js
+++ b/server/sonar-web/src/main/js/components/SelectList/index.js
@@ -24,41 +24,41 @@ import { translate } from '../../helpers/l10n';
import ItemTemplate from './templates/item.hbs';
import ListTemplate from './templates/list.hbs';
-var showError = null;
+let showError = null;
/*
* SelectList Collection
*/
-var SelectListCollection = Backbone.Collection.extend({
+const SelectListCollection = Backbone.Collection.extend({
- initialize: function (options) {
+ initialize (options) {
this.options = options;
},
- parse: function (r) {
+ parse (r) {
return this.options.parse.call(this, r);
},
- fetch: function (options) {
- var data = $.extend({
- page: 1,
- pageSize: 100
- }, options.data || {}),
- settings = $.extend({}, options, { data: data });
+ fetch (options) {
+ const data = $.extend({
+ page: 1,
+ pageSize: 100
+ }, options.data || {});
+ const settings = $.extend({}, options, { data });
this.settings = {
url: settings.url,
- data: data
+ data
};
Backbone.Collection.prototype.fetch.call(this, settings);
},
- fetchNextPage: function (options) {
+ fetchNextPage (options) {
if (this.more) {
- var nextPage = this.settings.data.page + 1,
- settings = $.extend(this.settings, options);
+ const nextPage = this.settings.data.page + 1;
+ const settings = $.extend(this.settings, options);
settings.data.page = nextPage;
settings.remove = false;
@@ -75,7 +75,7 @@ var SelectListCollection = Backbone.Collection.extend({
* SelectList Item View
*/
-var SelectListItemView = Backbone.View.extend({
+const SelectListItemView = Backbone.View.extend({
tagName: 'li',
template: ItemTemplate,
@@ -83,12 +83,12 @@ var SelectListItemView = Backbone.View.extend({
'change .select-list-list-checkbox': 'toggle'
},
- initialize: function (options) {
+ initialize (options) {
this.listenTo(this.model, 'change', this.render);
this.settings = options.settings;
},
- render: function () {
+ render () {
this.$el.html(this.template(this.settings.format(this.model.toJSON())));
this.$('input').prop('name', this.model.get('name'));
this.$el.toggleClass('selected', this.model.get('selected'));
@@ -104,9 +104,9 @@ var SelectListItemView = Backbone.View.extend({
}
},
- remove: function (postpone) {
+ remove (postpone) {
if (postpone) {
- var that = this;
+ const that = this;
that.$el.addClass(this.model.get('selected') ? 'added' : 'removed');
setTimeout(function () {
Backbone.View.prototype.remove.call(that, arguments);
@@ -116,37 +116,34 @@ var SelectListItemView = Backbone.View.extend({
}
},
- toggle: function () {
- var selected = this.model.get('selected'),
- that = this,
- url = selected ? this.settings.deselectUrl : this.settings.selectUrl,
- data = $.extend({}, this.settings.extra || {});
+ toggle () {
+ const selected = this.model.get('selected');
+ const that = this;
+ const url = selected ? this.settings.deselectUrl : this.settings.selectUrl;
+ const data = $.extend({}, this.settings.extra || {});
data[this.settings.selectParameter] = this.model.get(this.settings.selectParameterValue);
that.$el.addClass('progress');
$.ajax({
- url: url,
- type: 'POST',
- data: data,
- statusCode: {
- // do not show global error
- 400: null,
- 401: null,
- 403: null,
- 500: null
- }
- })
- .done(function () {
- that.model.set('selected', !selected);
- })
- .fail(function (jqXHR) {
- that.render();
- showError(jqXHR);
- })
- .always(function () {
- that.$el.removeClass('progress');
- });
+ url,
+ data,
+ type: 'POST',
+ statusCode: {
+ // do not show global error
+ 400: null,
+ 401: null,
+ 403: null,
+ 500: null
+ }
+ }).done(function () {
+ that.model.set('selected', !selected);
+ }).fail(function (jqXHR) {
+ that.render();
+ showError(jqXHR);
+ }).always(function () {
+ that.$el.removeClass('progress');
+ });
}
});
@@ -155,7 +152,7 @@ var SelectListItemView = Backbone.View.extend({
* SelectList View
*/
-var SelectListView = Backbone.View.extend({
+const SelectListView = Backbone.View.extend({
template: ListTemplate,
events: {
@@ -164,14 +161,14 @@ var SelectListView = Backbone.View.extend({
'click .select-list-control-button[name=all]': 'showAll'
},
- initialize: function (options) {
+ initialize (options) {
this.listenTo(this.collection, 'add', this.renderListItem);
this.listenTo(this.collection, 'reset', this.renderList);
this.listenTo(this.collection, 'remove', this.removeModel);
this.listenTo(this.collection, 'change:selected', this.confirmFilter);
this.settings = options.settings;
- var that = this;
+ const that = this;
this.showFetchSpinner = function () {
that.$listContainer.addClass('loading');
};
@@ -179,14 +176,14 @@ var SelectListView = Backbone.View.extend({
that.$listContainer.removeClass('loading');
};
- var onScroll = function () {
+ const onScroll = function () {
that.showFetchSpinner();
that.collection.fetchNextPage({
- success: function () {
+ success () {
that.hideFetchSpinner();
},
- error: function () {
+ error () {
that.hideFetchSpinner();
}
});
@@ -194,11 +191,11 @@ var SelectListView = Backbone.View.extend({
this.onScroll = _.throttle(onScroll, 1000);
},
- render: function () {
- var that = this,
- keyup = function () {
- that.search();
- };
+ render () {
+ const that = this;
+ const keyup = function () {
+ that.search();
+ };
this.$el.html(this.template(this.settings.labels))
.width(this.settings.width);
@@ -217,7 +214,7 @@ var SelectListView = Backbone.View.extend({
this.$list = this.$('.select-list-list');
- var searchInput = this.$('.select-list-search-control input')
+ const searchInput = this.$('.select-list-search-control input')
.on('keyup', _.debounce(keyup, 250))
.on('search', _.debounce(keyup, 250));
@@ -230,7 +227,7 @@ var SelectListView = Backbone.View.extend({
this.listItemViews = [];
showError = function (jqXHR) {
- var message = translate('default_error_message');
+ let message = translate('default_error_message');
if (jqXHR != null && jqXHR.responseJSON != null && jqXHR.responseJSON.errors != null) {
message = _.pluck(jqXHR.responseJSON.errors, 'msg').join('. ');
}
@@ -246,7 +243,7 @@ var SelectListView = Backbone.View.extend({
}
},
- renderList: function () {
+ renderList () {
this.listItemViews.forEach(function (view) {
view.remove();
});
@@ -261,8 +258,8 @@ var SelectListView = Backbone.View.extend({
this.$listContainer.scrollTop(0);
},
- renderListItem: function (item) {
- var itemView = new SelectListItemView({
+ renderListItem (item) {
+ const itemView = new SelectListItemView({
model: item,
settings: this.settings
});
@@ -271,23 +268,23 @@ var SelectListView = Backbone.View.extend({
itemView.render();
},
- renderEmpty: function () {
+ renderEmpty () {
this.$list.append('<li class="empty-message">' + this.settings.labels.noResults + '</li>');
},
- confirmFilter: function (model) {
+ confirmFilter (model) {
if (this.currentFilter !== 'all') {
this.collection.remove(model);
}
},
- removeModel: function (model, collection, options) {
+ removeModel (model, collection, options) {
this.listItemViews[options.index].remove(true);
this.listItemViews.splice(options.index, 1);
},
- filterBySelection: function (filter) {
- var that = this;
+ filterBySelection (filter) {
+ const that = this;
filter = this.currentFilter = filter || this.currentFilter;
if (filter != null) {
@@ -304,7 +301,7 @@ var SelectListView = Backbone.View.extend({
url: this.settings.searchUrl,
reset: true,
data: { selected: filter },
- success: function () {
+ success () {
that.hideFetchSpinner();
},
error: showError
@@ -312,23 +309,23 @@ var SelectListView = Backbone.View.extend({
}
},
- showSelected: function () {
+ showSelected () {
this.filterBySelection('selected');
},
- showDeselected: function () {
+ showDeselected () {
this.filterBySelection('deselected');
},
- showAll: function () {
+ showAll () {
this.filterBySelection('all');
},
- search: function () {
- var query = this.$('.select-list-search-control input').val(),
- hasQuery = query.length > 0,
- that = this,
- data = {};
+ search () {
+ const query = this.$('.select-list-search-control input').val();
+ const hasQuery = query.length > 0;
+ const that = this;
+ const data = {};
this.$('.select-list-check-control').toggleClass('disabled', hasQuery);
this.$('.select-list-search-control').toggleClass('disabled', !hasQuery);
@@ -342,8 +339,8 @@ var SelectListView = Backbone.View.extend({
this.collection.fetch({
url: this.settings.searchUrl,
reset: true,
- data: data,
- success: function () {
+ data,
+ success () {
that.hideFetchSpinner();
},
error: showError
@@ -353,17 +350,17 @@ var SelectListView = Backbone.View.extend({
}
},
- searchByQuery: function (query) {
+ searchByQuery (query) {
this.$('.select-list-search-control input').val(query);
this.search();
},
- clearSearch: function () {
+ clearSearch () {
this.filterBySelection();
},
- scroll: function () {
- var scrollBottom = this.$listContainer.scrollTop() >=
+ scroll () {
+ const scrollBottom = this.$listContainer.scrollTop() >=
this.$list[0].scrollHeight - this.$listContainer.outerHeight();
if (scrollBottom && this.collection.more) {
@@ -423,11 +420,11 @@ window.SelectList.defaults = {
readOnly: false,
focusSearch: true,
- format: function (item) {
+ format (item) {
return item.value;
},
- parse: function (r) {
+ parse (r) {
this.more = r.more;
return r.results;
},
diff --git a/server/sonar-web/src/main/js/components/charts/bar-chart.js b/server/sonar-web/src/main/js/components/charts/bar-chart.js
index a2345491bc0..a2448a60cd5 100644
--- a/server/sonar-web/src/main/js/components/charts/bar-chart.js
+++ b/server/sonar-web/src/main/js/components/charts/bar-chart.js
@@ -73,7 +73,7 @@ export const BarChart = React.createClass({
dy="1.5em"
onClick={this.props.onBarClick && this.handleClick.bind(this, point)}
style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }}
- {...tooltipAtts}>{tick}</text>;
+ {...tooltipAtts}>{tick}</text>;
});
return <g>{ticks}</g>;
},
@@ -99,7 +99,7 @@ export const BarChart = React.createClass({
dy="-1em"
onClick={this.props.onBarClick && this.handleClick.bind(this, point)}
style={{ cursor: this.props.onBarClick ? 'pointer' : 'default' }}
- {...tooltipAtts}>{value}</text>;
+ {...tooltipAtts}>{value}</text>;
});
return <g>{ticks}</g>;
},
@@ -117,7 +117,7 @@ export const BarChart = React.createClass({
}
return <rect key={index}
className="bar-chart-bar"
- {...tooltipAtts}
+ {...tooltipAtts}
x={x}
y={y}
width={this.props.barsWidth}
@@ -136,16 +136,17 @@ export const BarChart = React.createClass({
let availableWidth = this.state.width - this.props.padding[1] - this.props.padding[3];
let availableHeight = this.state.height - this.props.padding[0] - this.props.padding[2];
- const innerPadding = (availableWidth - this.props.barsWidth * this.props.data.length) / (this.props.data.length - 1);
+ const innerPadding = (availableWidth - this.props.barsWidth * this.props.data.length) /
+ (this.props.data.length - 1);
const relativeInnerPadding = innerPadding / (innerPadding + this.props.barsWidth);
let maxY = d3.max(this.props.data, d => d.y);
let xScale = d3.scale.ordinal()
- .domain(this.props.data.map(d => d.x))
- .rangeBands([0, availableWidth], relativeInnerPadding, 0);
+ .domain(this.props.data.map(d => d.x))
+ .rangeBands([0, availableWidth], relativeInnerPadding, 0);
let yScale = d3.scale.linear()
- .domain([0, maxY])
- .range([availableHeight, 0]);
+ .domain([0, maxY])
+ .range([availableHeight, 0]);
return <svg className="bar-chart" width={this.state.width} height={this.state.height}>
<g transform={`translate(${this.props.padding[3]}, ${this.props.padding[0]})`}>
diff --git a/server/sonar-web/src/main/js/components/charts/bubble-chart.js b/server/sonar-web/src/main/js/components/charts/bubble-chart.js
index f5c5e5242d7..c6e3ab0a165 100644
--- a/server/sonar-web/src/main/js/components/charts/bubble-chart.js
+++ b/server/sonar-web/src/main/js/components/charts/bubble-chart.js
@@ -93,18 +93,18 @@ export const BubbleChart = React.createClass({
},
getXRange (xScale, sizeScale, availableWidth) {
- var minX = d3.min(this.props.items, d => xScale(d.x) - sizeScale(d.size)),
- maxX = d3.max(this.props.items, d => xScale(d.x) + sizeScale(d.size)),
- dMinX = minX < 0 ? xScale.range()[0] - minX : xScale.range()[0],
- dMaxX = maxX > xScale.range()[1] ? maxX - xScale.range()[1] : 0;
+ const minX = d3.min(this.props.items, d => xScale(d.x) - sizeScale(d.size));
+ const maxX = d3.max(this.props.items, d => xScale(d.x) + sizeScale(d.size));
+ const dMinX = minX < 0 ? xScale.range()[0] - minX : xScale.range()[0];
+ const dMaxX = maxX > xScale.range()[1] ? maxX - xScale.range()[1] : 0;
return [dMinX, availableWidth - dMaxX];
},
getYRange (yScale, sizeScale, availableHeight) {
- var minY = d3.min(this.props.items, d => yScale(d.y) - sizeScale(d.size)),
- maxY = d3.max(this.props.items, d => yScale(d.y) + sizeScale(d.size)),
- dMinY = minY < 0 ? yScale.range()[1] - minY : yScale.range()[1],
- dMaxY = maxY > yScale.range()[0] ? maxY - yScale.range()[0] : 0;
+ const minY = d3.min(this.props.items, d => yScale(d.y) - sizeScale(d.size));
+ const maxY = d3.max(this.props.items, d => yScale(d.y) + sizeScale(d.size));
+ const dMinY = minY < 0 ? yScale.range()[1] - minY : yScale.range()[1];
+ const dMaxY = maxY > yScale.range()[0] ? maxY - yScale.range()[0] : 0;
return [availableHeight - dMaxY, dMinY];
},
diff --git a/server/sonar-web/src/main/js/components/charts/treemap.js b/server/sonar-web/src/main/js/components/charts/treemap.js
index d1b7c4645b5..25966512e4d 100644
--- a/server/sonar-web/src/main/js/components/charts/treemap.js
+++ b/server/sonar-web/src/main/js/components/charts/treemap.js
@@ -28,22 +28,22 @@ import { translate } from '../../helpers/l10n';
const SIZE_SCALE = d3.scale.linear()
- .domain([3, 15])
- .range([11, 18])
- .clamp(true);
+ .domain([3, 15])
+ .range([11, 18])
+ .clamp(true);
function mostCommitPrefix (strings) {
- var sortedStrings = strings.slice(0).sort(),
- firstString = sortedStrings[0],
- firstStringLength = firstString.length,
- lastString = sortedStrings[sortedStrings.length - 1],
- i = 0;
+ const sortedStrings = strings.slice(0).sort();
+ const firstString = sortedStrings[0];
+ const firstStringLength = firstString.length;
+ const lastString = sortedStrings[sortedStrings.length - 1];
+ let i = 0;
while (i < firstStringLength && firstString.charAt(i) === lastString.charAt(i)) {
i++;
}
- var prefix = firstString.substr(0, i),
- lastPrefixPart = _.last(prefix.split(/[\s\\\/]/));
+ const prefix = firstString.substr(0, i);
+ const lastPrefixPart = _.last(prefix.split(/[\s\\\/]/));
return prefix.substr(0, prefix.length - lastPrefixPart.length);
}
@@ -72,7 +72,9 @@ export const TreemapRect = React.createClass({
return <a onClick={e => e.stopPropagation()}
className="treemap-link"
href={this.props.link}
- style={{ fontSize: 12 }}><span className="icon-link"/></a>;
+ style={{ fontSize: 12 }}>
+ <span className="icon-link"/>
+ </a>;
},
render () {
@@ -95,7 +97,7 @@ export const TreemapRect = React.createClass({
};
let isTextVisible = this.props.width >= 40 && this.props.height >= 40;
return <div className="treemap-cell"
- {...tooltipAttrs}
+ {...tooltipAttrs}
style={cellStyles}
onClick={this.props.onClick}>
<div className="treemap-inner" dangerouslySetInnerHTML={{ __html: this.props.label }}
@@ -138,10 +140,10 @@ export const Treemap = React.createClass({
}
let treemap = d3.layout.treemap()
- .round(true)
- .value(d => d.size)
- .sort((a, b) => a.value - b.value)
- .size([this.state.width, this.state.height]);
+ .round(true)
+ .value(d => d.size)
+ .sort((a, b) => a.value - b.value)
+ .size([this.state.width, this.state.height]);
let nodes = treemap
.nodes({ children: this.props.items })
.filter(d => !d.children)
diff --git a/server/sonar-web/src/main/js/components/common/action-options-view.js b/server/sonar-web/src/main/js/components/common/action-options-view.js
index d32149057d6..3151a4bbcab 100644
--- a/server/sonar-web/src/main/js/components/common/action-options-view.js
+++ b/server/sonar-web/src/main/js/components/common/action-options-view.js
@@ -28,57 +28,57 @@ export default PopupView.extend({
options: '.menu > li > a'
},
- events: function () {
+ events () {
return {
'click @ui.options': 'selectOption',
'mouseenter @ui.options': 'activateOptionByPointer'
};
},
- initialize: function () {
+ initialize () {
this.bindShortcuts();
},
- onRender: function () {
+ onRender () {
PopupView.prototype.onRender.apply(this, arguments);
this.selectInitialOption();
},
- getOptions: function () {
+ getOptions () {
return this.$('.menu > li > a');
},
- getActiveOption: function () {
+ getActiveOption () {
return this.getOptions().filter('.active');
},
- makeActive: function (option) {
+ makeActive (option) {
if (option.length > 0) {
this.getOptions().removeClass('active').tooltip('hide');
option.addClass('active').tooltip('show');
}
},
- selectInitialOption: function () {
+ selectInitialOption () {
this.makeActive(this.getOptions().first());
},
- selectNextOption: function () {
+ selectNextOption () {
this.makeActive(this.getActiveOption().parent().nextAll('li:not(.divider)').first().children('a'));
return false;
},
- selectPreviousOption: function () {
+ selectPreviousOption () {
this.makeActive(this.getActiveOption().parent().prevAll('li:not(.divider)').first().children('a'));
return false;
},
- activateOptionByPointer: function (e) {
+ activateOptionByPointer (e) {
this.makeActive($(e.currentTarget));
},
- bindShortcuts: function () {
- var that = this;
+ bindShortcuts () {
+ const that = this;
this.currentKeyScope = key.getScope();
key.setScope(this.keyScope);
key('down', this.keyScope, function () {
@@ -101,7 +101,7 @@ export default PopupView.extend({
});
},
- unbindShortcuts: function () {
+ unbindShortcuts () {
key.unbind('down', this.keyScope);
key.unbind('up', this.keyScope);
key.unbind('return', this.keyScope);
@@ -112,19 +112,19 @@ export default PopupView.extend({
key.setScope(this.currentKeyScope);
},
- onDestroy: function () {
+ onDestroy () {
PopupView.prototype.onDestroy.apply(this, arguments);
this.unbindShortcuts();
this.$('[data-toggle="tooltip"]').tooltip('destroy');
$('.tooltip').remove();
},
- selectOption: function (e) {
+ selectOption (e) {
e.preventDefault();
this.destroy();
},
- selectActiveOption: function () {
+ selectActiveOption () {
this.getActiveOption().click();
}
});
diff --git a/server/sonar-web/src/main/js/components/common/file-upload.js b/server/sonar-web/src/main/js/components/common/file-upload.js
index c2d20b726b2..5d5e52ab0ab 100644
--- a/server/sonar-web/src/main/js/components/common/file-upload.js
+++ b/server/sonar-web/src/main/js/components/common/file-upload.js
@@ -21,7 +21,7 @@ import $ from 'jquery';
import _ from 'underscore';
function createFrame () {
- var uuid = _.uniqueId('upload-form-');
+ const uuid = _.uniqueId('upload-form-');
return $('<iframe></iframe>')
.prop('frameborder', 0)
.prop('width', 0)
@@ -32,11 +32,11 @@ function createFrame () {
}
export default function (options) {
- var deferred = new $.Deferred(),
- body = $('body'),
- frame = createFrame(),
- parent = options.form.parent(),
- clonedForm = options.form.detach();
+ const deferred = new $.Deferred();
+ const body = $('body');
+ const frame = createFrame();
+ const parent = options.form.parent();
+ const clonedForm = options.form.detach();
clonedForm
.prop('target', frame.prop('id'))
@@ -45,9 +45,9 @@ export default function (options) {
frame.appendTo(body);
frame.on('load', function () {
- var result = this.contentWindow.document.body.textContent;
+ const result = this.contentWindow.document.body.textContent;
try {
- var js = JSON.parse(result);
+ const js = JSON.parse(result);
deferred.resolve(js);
} catch (e) {
deferred.resolve(result);
diff --git a/server/sonar-web/src/main/js/components/common/modal-form.js b/server/sonar-web/src/main/js/components/common/modal-form.js
index df34b29440a..b2c697f29dd 100644
--- a/server/sonar-web/src/main/js/components/common/modal-form.js
+++ b/server/sonar-web/src/main/js/components/common/modal-form.js
@@ -22,62 +22,62 @@ import ModalView from './modals';
export default ModalView.extend({
- ui: function () {
+ ui () {
return {
messagesContainer: '.js-modal-messages'
};
},
- events: function () {
+ events () {
return _.extend(ModalView.prototype.events.apply(this, arguments), {
'keydown input,textarea,select': 'onInputKeydown',
'submit form': 'onFormSubmit'
});
},
- onRender: function () {
+ onRender () {
ModalView.prototype.onRender.apply(this, arguments);
- var that = this;
+ const that = this;
setTimeout(function () {
that.$(':tabbable').first().focus();
}, 0);
},
- onInputKeydown: function (e) {
+ onInputKeydown (e) {
if (e.keyCode === 27) {
// escape
this.destroy();
}
},
- onFormSubmit: function (e) {
+ onFormSubmit (e) {
e.preventDefault();
},
- showErrors: function (errors, warnings) {
- var container = this.ui.messagesContainer.empty();
+ showErrors (errors, warnings) {
+ const container = this.ui.messagesContainer.empty();
if (_.isArray(errors)) {
errors.forEach(function (error) {
- var html = '<div class="alert alert-danger">' + error.msg + '</div>';
+ const html = '<div class="alert alert-danger">' + error.msg + '</div>';
container.append(html);
});
}
if (_.isArray(warnings)) {
warnings.forEach(function (warn) {
- var html = '<div class="alert alert-warning">' + warn.msg + '</div>';
+ const html = '<div class="alert alert-warning">' + warn.msg + '</div>';
container.append(html);
});
}
this.ui.messagesContainer.scrollParent().scrollTop(0);
},
- disableForm: function () {
- var form = this.$('form');
+ disableForm () {
+ const form = this.$('form');
this.disabledFields = form.find(':input:not(:disabled)');
this.disabledFields.prop('disabled', true);
},
- enableForm: function () {
+ enableForm () {
if (this.disabledFields != null) {
this.disabledFields.prop('disabled', false);
}
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 d5f87da85fb..264b547bb12 100644
--- a/server/sonar-web/src/main/js/components/common/modals.js
+++ b/server/sonar-web/src/main/js/components/common/modals.js
@@ -27,14 +27,14 @@ export default Marionette.ItemView.extend({
overlayClassName: 'modal-overlay',
htmlClassName: 'modal-open',
- events: function () {
+ events () {
return {
'click .js-modal-close': 'onCloseClick'
};
},
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
this.$el.detach().appendTo($('body'));
$('html').addClass(this.htmlClassName);
this.renderOverlay();
@@ -50,39 +50,39 @@ export default Marionette.ItemView.extend({
}
},
- show: function () {
- var that = this;
+ show () {
+ const that = this;
setTimeout(function () {
that.$el.addClass('in');
$('.' + that.overlayClassName).addClass('in');
}, 0);
},
- onDestroy: function () {
+ onDestroy () {
$('html').removeClass(this.htmlClassName);
this.removeOverlay();
key.deleteScope('modal');
key.setScope(this.keyScope);
},
- onCloseClick: function (e) {
+ onCloseClick (e) {
e.preventDefault();
this.destroy();
},
- renderOverlay: function () {
- var overlay = $('.' + this.overlayClassName);
+ renderOverlay () {
+ const overlay = $('.' + this.overlayClassName);
if (overlay.length === 0) {
$('<div class="' + this.overlayClassName + '"></div>').appendTo($('body'));
}
},
- removeOverlay: function () {
+ removeOverlay () {
$('.' + this.overlayClassName).remove();
},
- attachCloseEvents: function () {
- var that = this;
+ attachCloseEvents () {
+ const that = this;
$('body').on('click.' + EVENT_SCOPE, function () {
$('body').off('click.' + EVENT_SCOPE);
that.destroy();
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 d6c44d997f0..ac5586209d8 100644
--- a/server/sonar-web/src/main/js/components/common/popup.js
+++ b/server/sonar-web/src/main/js/components/common/popup.js
@@ -23,7 +23,7 @@ import Marionette from 'backbone.marionette';
export default Marionette.ItemView.extend({
className: 'bubble-popup',
- onRender: function () {
+ onRender () {
this.$el.detach().appendTo($('body'));
if (this.options.bottom) {
this.$el.addClass('bubble-popup-bottom');
@@ -46,8 +46,8 @@ export default Marionette.ItemView.extend({
this.attachCloseEvents();
},
- attachCloseEvents: function () {
- var that = this;
+ attachCloseEvents () {
+ const that = this;
key('escape', function () {
that.destroy();
});
@@ -62,7 +62,7 @@ export default Marionette.ItemView.extend({
});
},
- onDestroy: function () {
+ onDestroy () {
$('body').off('click.bubble-popup');
this.options.triggerEl.off('click.bubble-popup');
}
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 d9e61651491..3c4a48906ab 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
@@ -21,35 +21,35 @@ import Marionette from 'backbone.marionette';
export default Marionette.CollectionView.extend({
- initialize: function () {
+ initialize () {
this.resetSelectedIndex();
this.listenTo(this.collection, 'reset', this.resetSelectedIndex);
},
- childViewOptions: function (model, index) {
- return { index: index };
+ childViewOptions (model, index) {
+ return { index };
},
- resetSelectedIndex: function () {
+ resetSelectedIndex () {
this.selectedIndex = 0;
},
- onRender: function () {
+ onRender () {
this.selectCurrent();
},
- submitCurrent: function () {
- var view = this.children.findByIndex(this.selectedIndex);
+ submitCurrent () {
+ const view = this.children.findByIndex(this.selectedIndex);
if (view != null) {
view.submit();
}
},
- selectCurrent: function () {
+ selectCurrent () {
this.selectItem(this.selectedIndex);
},
- selectNext: function () {
+ selectNext () {
if (this.selectedIndex < this.collection.length - 1) {
this.deselectItem(this.selectedIndex);
this.selectedIndex++;
@@ -57,7 +57,7 @@ export default Marionette.CollectionView.extend({
}
},
- selectPrev: function () {
+ selectPrev () {
if (this.selectedIndex > 0) {
this.deselectItem(this.selectedIndex);
this.selectedIndex--;
@@ -65,17 +65,17 @@ export default Marionette.CollectionView.extend({
}
},
- selectItem: function (index) {
+ selectItem (index) {
if (index >= 0 && index < this.collection.length) {
- var view = this.children.findByIndex(index);
+ const view = this.children.findByIndex(index);
if (view != null) {
view.select();
}
}
},
- deselectItem: function (index) {
- var view = this.children.findByIndex(index);
+ deselectItem (index) {
+ const view = this.children.findByIndex(index);
if (view != null) {
view.deselect();
}
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 e8fa3358fb4..5218f57e711 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
@@ -20,11 +20,11 @@
import Backbone from 'backbone';
export default Backbone.Collection.extend({
- url: function () {
+ url () {
return '/api/action_plans/search';
},
- parse: function (r) {
+ parse (r) {
return r.actionPlans;
}
});
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 d6bb99f394e..d8223896252 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
@@ -24,19 +24,19 @@ import Issue from '../models/issue';
export default Backbone.Collection.extend({
model: Issue,
- url: function () {
+ url () {
return '/api/issues/search';
},
- _injectRelational: function (issue, source, baseField, lookupField) {
- var baseValue = issue[baseField];
+ _injectRelational (issue, source, baseField, lookupField) {
+ const baseValue = issue[baseField];
if (baseValue != null && _.size(source)) {
- var lookupValue = _.find(source, function (candidate) {
+ const lookupValue = _.find(source, function (candidate) {
return candidate[lookupField] === baseValue;
});
if (lookupValue != null) {
Object.keys(lookupValue).forEach(function (key) {
- var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
+ const newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
issue[newKey] = lookupValue[key];
});
}
@@ -44,11 +44,11 @@ export default Backbone.Collection.extend({
return issue;
},
- _injectCommentsRelational: function (issue, users) {
+ _injectCommentsRelational (issue, users) {
if (issue.comments) {
- var that = this;
- var newComments = issue.comments.map(function (comment) {
- var newComment = _.extend({}, comment, { author: comment.login });
+ const that = this;
+ const newComments = issue.comments.map(function (comment) {
+ let newComment = _.extend({}, comment, { author: comment.login });
delete newComment.login;
newComment = that._injectRelational(newComment, users, 'author', 'login');
return newComment;
@@ -58,7 +58,7 @@ export default Backbone.Collection.extend({
return issue;
},
- _prepareClosed: function (issue) {
+ _prepareClosed (issue) {
if (issue.status === 'CLOSED') {
issue.flows = [];
delete issue.textRange;
@@ -66,7 +66,7 @@ export default Backbone.Collection.extend({
return issue;
},
- ensureTextRange: function (issue) {
+ ensureTextRange (issue) {
if (issue.line && !issue.textRange) {
// FIXME 999999
issue.textRange = {
@@ -79,8 +79,8 @@ export default Backbone.Collection.extend({
return issue;
},
- parse: function (r) {
- var that = this;
+ parse (r) {
+ const that = this;
this.paging = {
p: r.p,
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 88cc57e1e00..1d41d63b46d 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
@@ -43,7 +43,7 @@ export default Marionette.ItemView.extend({
'transition': 'onTransition'
},
- events: function () {
+ events () {
return {
'click .js-issue-comment': 'onComment',
'click .js-issue-comment-edit': 'editComment',
@@ -61,32 +61,32 @@ export default Marionette.ItemView.extend({
};
},
- onRender: function () {
+ onRender () {
this.$el.attr('data-key', this.model.get('key'));
},
- disableControls: function () {
+ disableControls () {
this.$(':input').prop('disabled', true);
},
- enableControls: function () {
+ enableControls () {
this.$(':input').prop('disabled', false);
},
- resetIssue: function (options) {
- var that = this;
- var key = this.model.get('key'),
- componentUuid = this.model.get('componentUuid');
- this.model.reset({ key: key, componentUuid: componentUuid }, { silent: true });
+ resetIssue (options) {
+ const that = this;
+ const key = this.model.get('key');
+ const componentUuid = this.model.get('componentUuid');
+ this.model.reset({ key, componentUuid }, { silent: true });
return this.model.fetch(options).done(function () {
return that.trigger('reset');
});
},
- showChangeLog: function (e) {
- var that = this;
- var t = $(e.currentTarget),
- changeLog = new ChangeLog();
+ showChangeLog (e) {
+ const that = this;
+ const t = $(e.currentTarget);
+ const changeLog = new ChangeLog();
return changeLog.fetch({
data: { issue: this.model.get('key') }
}).done(function () {
@@ -103,7 +103,7 @@ export default Marionette.ItemView.extend({
});
},
- updateAfterAction: function (fetch) {
+ updateAfterAction (fetch) {
if (this.popup) {
this.popup.destroy();
}
@@ -112,12 +112,12 @@ export default Marionette.ItemView.extend({
}
},
- onComment: function (e) {
+ onComment (e) {
e.stopPropagation();
this.comment();
},
- comment: function (options) {
+ comment (options) {
$('body').click();
this.popup = new CommentFormView({
triggerEl: this.$('.js-issue-comment'),
@@ -129,12 +129,12 @@ export default Marionette.ItemView.extend({
this.popup.render();
},
- editComment: function (e) {
+ editComment (e) {
e.stopPropagation();
$('body').click();
- var commentEl = $(e.currentTarget).closest('.issue-comment'),
- commentKey = commentEl.data('comment-key'),
- comment = _.findWhere(this.model.get('comments'), { key: commentKey });
+ const commentEl = $(e.currentTarget).closest('.issue-comment');
+ const commentKey = commentEl.data('comment-key');
+ const comment = _.findWhere(this.model.get('comments'), { key: commentKey });
this.popup = new CommentFormView({
triggerEl: $(e.currentTarget),
bottomRight: true,
@@ -145,10 +145,10 @@ export default Marionette.ItemView.extend({
this.popup.render();
},
- deleteComment: function (e) {
- var that = this;
- var commentKey = $(e.target).closest('[data-comment-key]').data('comment-key'),
- confirmMsg = $(e.target).data('confirm-msg');
+ deleteComment (e) {
+ const that = this;
+ const commentKey = $(e.target).closest('[data-comment-key]').data('comment-key');
+ const confirmMsg = $(e.target).data('confirm-msg');
if (confirm(confirmMsg)) {
this.disableControls();
return $.ajax({
@@ -160,7 +160,7 @@ export default Marionette.ItemView.extend({
}
},
- transition: function (e) {
+ transition (e) {
e.stopPropagation();
$('body').click();
this.popup = new TransitionsFormView({
@@ -172,7 +172,7 @@ export default Marionette.ItemView.extend({
this.popup.render();
},
- setSeverity: function (e) {
+ setSeverity (e) {
e.stopPropagation();
$('body').click();
this.popup = new SetSeverityFormView({
@@ -183,7 +183,7 @@ export default Marionette.ItemView.extend({
this.popup.render();
},
- assign: function (e) {
+ assign (e) {
e.stopPropagation();
$('body').click();
this.popup = new AssignFormView({
@@ -194,8 +194,8 @@ export default Marionette.ItemView.extend({
this.popup.render();
},
- assignToMe: function () {
- var view = new AssignFormView({
+ assignToMe () {
+ const view = new AssignFormView({
model: this.model,
triggerEl: $('body')
});
@@ -203,10 +203,10 @@ export default Marionette.ItemView.extend({
view.destroy();
},
- plan: function (e) {
- var that = this;
- var t = $(e.currentTarget),
- actionPlans = new ActionPlans();
+ plan (e) {
+ const that = this;
+ const t = $(e.currentTarget);
+ const actionPlans = new ActionPlans();
return actionPlans.fetch({
reset: true,
data: { project: this.model.get('project') }
@@ -223,12 +223,12 @@ export default Marionette.ItemView.extend({
});
},
- showRule: function () {
- var ruleKey = this.model.get('rule');
+ showRule () {
+ const ruleKey = this.model.get('rule');
Workspace.openRule({ key: ruleKey });
},
- showMoreActions: function (e) {
+ showMoreActions (e) {
e.stopPropagation();
$('body').click();
this.popup = new MoreActionsView({
@@ -240,8 +240,8 @@ export default Marionette.ItemView.extend({
this.popup.render();
},
- action: function (action) {
- var that = this;
+ action (action) {
+ const that = this;
this.disableControls();
return this.model.customAction(action)
.done(function () {
@@ -252,7 +252,7 @@ export default Marionette.ItemView.extend({
});
},
- editTags: function (e) {
+ editTags (e) {
e.stopPropagation();
$('body').click();
this.popup = new TagsFormView({
@@ -263,18 +263,18 @@ export default Marionette.ItemView.extend({
this.popup.render();
},
- showLocations: function () {
+ showLocations () {
this.model.trigger('locations', this.model);
},
- onTransition: function (transition) {
+ onTransition (transition) {
if (transition === 'falsepositive' || transition === 'wontfix') {
this.comment({ fromTransition: true });
}
},
- serializeData: function () {
- var issueKey = encodeURIComponent(this.model.get('key'));
+ serializeData () {
+ const issueKey = encodeURIComponent(this.model.get('key'));
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
permalink: '/issues/search#issues=' + issueKey,
hasSecondaryLocations: this.model.get('flows').length
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 12444226e14..bd971c2222a 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
@@ -31,8 +31,8 @@ export default Marionette.ItemView.extend({
'click .js-cancel': 'cancel'
},
- initialize: function () {
- var that = this;
+ initialize () {
+ const that = this;
this.rules = [];
$.get('/api/rules/search?repositories=manual&f=name&ps=9999999').done(function (r) {
that.rules = r.rules;
@@ -40,7 +40,7 @@ export default Marionette.ItemView.extend({
});
},
- onRender: function () {
+ onRender () {
this.delegateEvents();
this.$('[name=rule]').select2({
width: '250px',
@@ -55,16 +55,16 @@ export default Marionette.ItemView.extend({
}
},
- onDestroy: function () {
+ onDestroy () {
if (key != null && this.key != null) {
key.setScope(this.key);
}
},
- formSubmit: function (e) {
- var that = this;
+ formSubmit (e) {
+ const that = this;
e.preventDefault();
- var issue = new Issue({
+ const issue = new Issue({
component: this.options.component,
line: this.options.line,
message: this.$('[name="message"]').val(),
@@ -75,20 +75,20 @@ export default Marionette.ItemView.extend({
});
},
- addIssue: function (issue) {
- var that = this;
+ addIssue (issue) {
+ const that = this;
return issue.fetch().done(function () {
that.trigger('add', issue);
that.destroy();
});
},
- cancel: function (e) {
+ cancel (e) {
e.preventDefault();
this.destroy();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
rules: _.sortBy(this.rules, 'name')
});
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 c6d99b86069..dc27c3ff8b9 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
@@ -20,11 +20,11 @@
import Backbone from 'backbone';
export default Backbone.Collection.extend({
- url: function () {
+ url () {
return '/api/issues/changelog';
},
- parse: function (r) {
+ parse (r) {
return r.changelog;
}
});
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 25bc16ff662..354ca31d93d 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
@@ -23,22 +23,22 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
idAttribute: 'key',
- defaults: function () {
+ defaults () {
return {
flows: []
};
},
- url: function () {
+ url () {
return '/api/issues';
},
- urlRoot: function () {
+ urlRoot () {
return '/api/issues';
},
- parse: function (r) {
- var issue = _.size(r.issues) > 0 ? r.issues[0] : r.issue;
+ parse (r) {
+ let issue = _.size(r.issues) > 0 ? r.issues[0] : r.issue;
if (issue) {
issue = this._injectRelational(issue, r.components, 'component', 'key');
issue = this._injectRelational(issue, r.components, 'project', 'key');
@@ -56,15 +56,15 @@ export default Backbone.Model.extend({
}
},
- _injectRelational: function (issue, source, baseField, lookupField) {
- var baseValue = issue[baseField];
+ _injectRelational (issue, source, baseField, lookupField) {
+ const baseValue = issue[baseField];
if (baseValue != null && _.size(source)) {
- var lookupValue = _.find(source, function (candidate) {
+ const lookupValue = _.find(source, function (candidate) {
return candidate[lookupField] === baseValue;
});
if (lookupValue != null) {
Object.keys(lookupValue).forEach(function (key) {
- var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
+ const newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
issue[newKey] = lookupValue[key];
});
}
@@ -72,11 +72,11 @@ export default Backbone.Model.extend({
return issue;
},
- _injectCommentsRelational: function (issue, users) {
+ _injectCommentsRelational (issue, users) {
if (issue.comments) {
- var that = this;
- var newComments = issue.comments.map(function (comment) {
- var newComment = _.extend({}, comment, { author: comment.login });
+ const that = this;
+ const newComments = issue.comments.map(function (comment) {
+ let newComment = _.extend({}, comment, { author: comment.login });
delete newComment.login;
newComment = that._injectRelational(newComment, users, 'author', 'login');
return newComment;
@@ -86,7 +86,7 @@ export default Backbone.Model.extend({
return issue;
},
- _prepareClosed: function (issue) {
+ _prepareClosed (issue) {
if (issue.status === 'CLOSED') {
issue.flows = [];
delete issue.textRange;
@@ -94,7 +94,7 @@ export default Backbone.Model.extend({
return issue;
},
- ensureTextRange: function (issue) {
+ ensureTextRange (issue) {
if (issue.line && !issue.textRange) {
// FIXME 999999
issue.textRange = {
@@ -107,8 +107,8 @@ export default Backbone.Model.extend({
return issue;
},
- sync: function (method, model, options) {
- var opts = options || {};
+ sync (method, model, options) {
+ const opts = options || {};
opts.contentType = 'application/x-www-form-urlencoded';
if (method === 'read') {
_.extend(opts, {
@@ -133,7 +133,7 @@ export default Backbone.Model.extend({
}
});
}
- var xhr = options.xhr = Backbone.ajax(opts);
+ const xhr = options.xhr = Backbone.ajax(opts);
model.trigger('request', model, xhr, opts);
return xhr;
},
@@ -144,8 +144,8 @@ export default Backbone.Model.extend({
* @param options
* @returns {Object}
*/
- reset: function (attrs, options) {
- for (var key in this.attributes) {
+ reset (attrs, options) {
+ for (let key in this.attributes) {
if (this.attributes.hasOwnProperty(key) && !(key in attrs)) {
attrs[key] = void 0;
}
@@ -159,17 +159,17 @@ export default Backbone.Model.extend({
* @returns {jqXHR}
* @private
*/
- _action: function (options) {
- var model = this;
- var success = function (r) {
- var attrs = model.parse(r);
+ _action (options) {
+ const model = this;
+ const success = function (r) {
+ const attrs = model.parse(r);
model.reset(attrs);
if (options.success) {
options.success(model, r, options);
}
};
- var opts = _.extend({ type: 'POST' }, options, { success: success });
- var xhr = options.xhr = Backbone.ajax(opts);
+ const opts = _.extend({ type: 'POST' }, options, { success });
+ const xhr = options.xhr = Backbone.ajax(opts);
model.trigger('request', model, xhr, opts);
return xhr;
},
@@ -180,10 +180,10 @@ export default Backbone.Model.extend({
* @param {Object|null} options Options for jQuery ajax
* @returns {jqXHR}
*/
- assign: function (assignee, options) {
- var opts = _.extend({
+ assign (assignee, options) {
+ const opts = _.extend({
url: this.urlRoot() + '/assign',
- data: { issue: this.id, assignee: assignee }
+ data: { issue: this.id, assignee }
}, options);
return this._action(opts);
},
@@ -194,10 +194,10 @@ export default Backbone.Model.extend({
* @param {Object|null} options Options for jQuery ajax
* @returns {jqXHR}
*/
- plan: function (plan, options) {
- var opts = _.extend({
+ plan (plan, options) {
+ const opts = _.extend({
url: this.urlRoot() + '/plan',
- data: { issue: this.id, plan: plan }
+ data: { issue: this.id, plan }
}, options);
return this._action(opts);
},
@@ -208,10 +208,10 @@ export default Backbone.Model.extend({
* @param {Object|null} options Options for jQuery ajax
* @returns {jqXHR}
*/
- setSeverity: function (severity, options) {
- var opts = _.extend({
+ setSeverity (severity, options) {
+ const opts = _.extend({
url: this.urlRoot() + '/set_severity',
- data: { issue: this.id, severity: severity }
+ data: { issue: this.id, severity }
}, options);
return this._action(opts);
},
@@ -222,11 +222,11 @@ export default Backbone.Model.extend({
* @param {Object|null} options Options for jQuery ajax
* @returns {jqXHR}
*/
- transition: function (transition, options) {
- var that = this;
- var opts = _.extend({
+ transition (transition, options) {
+ const that = this;
+ const opts = _.extend({
url: this.urlRoot() + '/do_transition',
- data: { issue: this.id, transition: transition }
+ data: { issue: this.id, transition }
}, options);
return this._action(opts).done(function () {
that.trigger('transition', transition);
@@ -240,28 +240,28 @@ export default Backbone.Model.extend({
* @param {Object|null} options Options for jQuery ajax
* @returns {jqXHR}
*/
- customAction: function (actionKey, options) {
- var opts = _.extend({
+ customAction (actionKey, options) {
+ const opts = _.extend({
type: 'POST',
url: this.urlRoot() + '/do_action',
- data: { issue: this.id, actionKey: actionKey }
+ data: { issue: this.id, actionKey }
}, options);
- var xhr = Backbone.ajax(opts);
+ const xhr = Backbone.ajax(opts);
this.trigger('request', this, xhr, opts);
return xhr;
},
- getLinearLocations: function () {
- var textRange = this.get('textRange');
+ getLinearLocations () {
+ const textRange = this.get('textRange');
if (!textRange) {
return [];
}
- var locations = [];
- for (var line = textRange.startLine; line <= textRange.endLine; line++) {
+ const locations = [];
+ for (let line = textRange.startLine; line <= textRange.endLine; line++) {
// TODO fix 999999
- var from = line === textRange.startLine ? textRange.startOffset : 0,
- to = line === textRange.endLine ? textRange.endOffset : 999999;
- locations.push({ line: line, from: from, to: to });
+ const from = line === textRange.startLine ? textRange.startOffset : 0;
+ const to = line === textRange.endLine ? textRange.endOffset : 999999;
+ locations.push({ line, from, to });
}
return locations;
}
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 25d1f9eeec5..5fba121bf5c 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
@@ -28,7 +28,7 @@ export default ActionOptionsView.extend({
template: Template,
optionTemplate: OptionTemplate,
- events: function () {
+ events () {
return _.extend(ActionOptionsView.prototype.events.apply(this, arguments), {
'click input': 'onInputClick',
'keydown input': 'onInputKeydown',
@@ -36,22 +36,22 @@ export default ActionOptionsView.extend({
});
},
- initialize: function () {
+ initialize () {
ActionOptionsView.prototype.initialize.apply(this, arguments);
this.assignees = null;
this.debouncedSearch = _.debounce(this.search, 250);
},
- getAssignee: function () {
+ getAssignee () {
return this.model.get('assignee');
},
- getAssigneeName: function () {
+ getAssigneeName () {
return this.model.get('assigneeName');
},
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
ActionOptionsView.prototype.onRender.apply(this, arguments);
this.renderTags();
setTimeout(function () {
@@ -59,34 +59,34 @@ export default ActionOptionsView.extend({
}, 100);
},
- renderTags: function () {
+ renderTags () {
this.$('.menu').empty();
this.getAssignees().forEach(this.renderAssignee, this);
this.bindUIElements();
this.selectInitialOption();
},
- renderAssignee: function (assignee) {
- var html = this.optionTemplate(assignee);
+ renderAssignee (assignee) {
+ const html = this.optionTemplate(assignee);
this.$('.menu').append(html);
},
- selectOption: function (e) {
- var assignee = $(e.currentTarget).data('value'),
- assigneeName = $(e.currentTarget).data('text');
+ selectOption (e) {
+ const assignee = $(e.currentTarget).data('value');
+ const assigneeName = $(e.currentTarget).data('text');
this.submit(assignee, assigneeName);
return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- submit: function (assignee) {
+ submit (assignee) {
return this.model.assign(assignee);
},
- onInputClick: function (e) {
+ onInputClick (e) {
e.stopPropagation();
},
- onInputKeydown: function (e) {
+ onInputKeydown (e) {
this.query = this.$('input').val();
if (e.keyCode === 38) {
this.selectPreviousOption();
@@ -105,8 +105,8 @@ export default ActionOptionsView.extend({
}
},
- onInputKeyup: function () {
- var query = this.$('input').val();
+ onInputKeyup () {
+ let query = this.$('input').val();
if (query !== this.query) {
if (query.length < 2) {
query = '';
@@ -116,8 +116,8 @@ export default ActionOptionsView.extend({
}
},
- search: function (query) {
- var that = this;
+ search (query) {
+ const that = this;
if (query.length > 1) {
$.get('/api/users/search', { q: query }).done(function (data) {
that.resetAssignees(data.users);
@@ -127,7 +127,7 @@ export default ActionOptionsView.extend({
}
},
- resetAssignees: function (users) {
+ resetAssignees (users) {
if (users) {
this.assignees = users.map(function (user) {
return { id: user.login, text: user.name };
@@ -138,13 +138,13 @@ export default ActionOptionsView.extend({
this.renderTags();
},
- getAssignees: function () {
+ getAssignees () {
if (this.assignees) {
return this.assignees;
}
- var assignees = [{ id: '', text: translate('unassigned') }],
- currentUser = window.SS.user,
- currentUserName = window.SS.userName;
+ const assignees = [{ id: '', text: translate('unassigned') }];
+ const currentUser = window.SS.user;
+ const currentUserName = window.SS.userName;
assignees.push({ id: currentUser, text: currentUserName });
if (this.getAssignee()) {
assignees.push({ id: this.getAssignee(), text: this.getAssigneeName() });
@@ -152,7 +152,7 @@ export default ActionOptionsView.extend({
return this.makeUnique(assignees);
},
- makeUnique: function (assignees) {
+ makeUnique (assignees) {
return _.uniq(assignees, false, function (assignee) {
return assignee.id;
});
diff --git a/server/sonar-web/src/main/js/components/issue/views/changelog-view.js b/server/sonar-web/src/main/js/components/issue/views/changelog-view.js
index f94bf921126..412ae881f4e 100644
--- a/server/sonar-web/src/main/js/components/issue/views/changelog-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/changelog-view.js
@@ -28,7 +28,7 @@ export default PopupView.extend({
'sync': 'render'
},
- serializeData: function () {
+ serializeData () {
return _.extend(PopupView.prototype.serializeData.apply(this, arguments), {
issue: this.options.issue.toJSON()
});
diff --git a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js
index 6f72ac4964a..4e4ac129b09 100644
--- a/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/comment-form-view.js
@@ -40,23 +40,23 @@ export default PopupView.extend({
'click @ui.submitButton': 'submit'
},
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
PopupView.prototype.onRender.apply(this, arguments);
setTimeout(function () {
that.ui.textarea.focus();
}, 100);
},
- toggleSubmit: function () {
+ toggleSubmit () {
this.ui.submitButton.prop('disabled', this.ui.textarea.val().length === 0);
},
- onClick: function (e) {
+ onClick (e) {
e.stopPropagation();
},
- onKeydown: function (e) {
+ onKeydown (e) {
if (e.keyCode === 27) {
this.destroy();
}
@@ -65,25 +65,25 @@ export default PopupView.extend({
}
},
- cancel: function () {
+ cancel () {
this.options.detailView.updateAfterAction(false);
},
- disableForm: function () {
+ disableForm () {
this.$(':input').prop('disabled', true);
},
- enableForm: function () {
+ enableForm () {
this.$(':input').prop('disabled', false);
},
- submit: function () {
- var that = this;
- var text = this.ui.textarea.val(),
- update = this.model && this.model.has('key'),
- method = update ? 'edit_comment' : 'add_comment',
- url = '/api/issues/' + method,
- data = { text: text };
+ submit () {
+ const that = this;
+ const text = this.ui.textarea.val();
+ const update = this.model && this.model.has('key');
+ const method = update ? 'edit_comment' : 'add_comment';
+ const url = '/api/issues/' + method;
+ const data = { text };
if (update) {
data.key = this.model.get('key');
} else {
@@ -100,10 +100,10 @@ export default PopupView.extend({
});
},
- serializeData: function () {
- var options = _.defaults(this.options.additionalOptions, { fromTransition: false });
+ serializeData () {
+ const options = _.defaults(this.options.additionalOptions, { fromTransition: false });
return _.extend(PopupView.prototype.serializeData.apply(this, arguments), {
- options: options
+ options
});
}
});
diff --git a/server/sonar-web/src/main/js/components/issue/views/issue-popup.js b/server/sonar-web/src/main/js/components/issue/views/issue-popup.js
index 00f2a829227..970c350f1fc 100644
--- a/server/sonar-web/src/main/js/components/issue/views/issue-popup.js
+++ b/server/sonar-web/src/main/js/components/issue/views/issue-popup.js
@@ -22,27 +22,27 @@ import PopupView from '../../common/popup';
export default PopupView.extend({
className: 'bubble-popup issue-bubble-popup',
- template: function () {
+ template () {
return '<div class="bubble-popup-arrow"></div>';
},
- events: function () {
+ events () {
return {
'click .js-issue-form-cancel': 'destroy'
};
},
- onRender: function () {
+ onRender () {
PopupView.prototype.onRender.apply(this, arguments);
this.options.view.$el.appendTo(this.$el);
this.options.view.render();
},
- onDestroy: function () {
+ onDestroy () {
this.options.view.destroy();
},
- attachCloseEvents: function () {
+ attachCloseEvents () {
}
});
diff --git a/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js b/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js
index 3637f2f6d4f..9865c54bddf 100644
--- a/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/more-actions-view.js
@@ -24,13 +24,13 @@ import Template from '../templates/issue-more-actions.hbs';
export default ActionOptionsView.extend({
template: Template,
- selectOption: function (e) {
- var action = $(e.currentTarget).data('action');
+ selectOption (e) {
+ const action = $(e.currentTarget).data('action');
this.submit(action);
return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- submit: function (actionKey) {
+ submit (actionKey) {
return this.options.detailView.action(actionKey);
}
});
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 aef110a8c8f..3ffb071be22 100644
--- a/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js
@@ -26,30 +26,30 @@ import { translate } from '../../../helpers/l10n';
export default ActionOptionsView.extend({
template: Template,
- getActionPlan: function () {
+ getActionPlan () {
return this.model.get('actionPlan') || '';
},
- selectInitialOption: function () {
+ selectInitialOption () {
this.makeActive(this.getOptions().filter('[data-value="' + this.getActionPlan() + '"]'));
},
- selectOption: function (e) {
- var actionPlan = $(e.currentTarget).data('value'),
- actionPlanName = $(e.currentTarget).data('text');
+ selectOption (e) {
+ const actionPlan = $(e.currentTarget).data('value');
+ const actionPlanName = $(e.currentTarget).data('text');
this.submit(actionPlan, actionPlanName);
return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- submit: function (actionPlan) {
+ submit (actionPlan) {
return this.model.plan(actionPlan);
},
- getActionPlans: function () {
+ getActionPlans () {
return [{ key: '', name: translate('issue.unplanned') }].concat(this.collection.toJSON());
},
- serializeData: function () {
+ serializeData () {
return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), {
items: this.getActionPlans()
});
diff --git a/server/sonar-web/src/main/js/components/issue/views/set-severity-form-view.js b/server/sonar-web/src/main/js/components/issue/views/set-severity-form-view.js
index e7d9a901792..33f3b77de50 100644
--- a/server/sonar-web/src/main/js/components/issue/views/set-severity-form-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/set-severity-form-view.js
@@ -25,25 +25,25 @@ import Template from '../templates/issue-set-severity-form.hbs';
export default ActionOptionsView.extend({
template: Template,
- getTransition: function () {
+ getTransition () {
return this.model.get('severity');
},
- selectInitialOption: function () {
+ selectInitialOption () {
return this.makeActive(this.getOptions().filter('[data-value="' + this.getTransition() + '"]'));
},
- selectOption: function (e) {
- var severity = $(e.currentTarget).data('value');
+ selectOption (e) {
+ const severity = $(e.currentTarget).data('value');
this.submit(severity);
return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- submit: function (severity) {
+ submit (severity) {
return this.model.setSeverity(severity);
},
- serializeData: function () {
+ serializeData () {
return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), {
items: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
});
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 32f60128284..8465005d70a 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
@@ -31,7 +31,7 @@ export default ActionOptionsView.extend({
'change:tags': 'renderTags'
},
- events: function () {
+ events () {
return _.extend(ActionOptionsView.prototype.events.apply(this, arguments), {
'click input': 'onInputClick',
'keydown input': 'onInputKeydown',
@@ -39,7 +39,7 @@ export default ActionOptionsView.extend({
});
},
- initialize: function () {
+ initialize () {
ActionOptionsView.prototype.initialize.apply(this, arguments);
this.query = '';
this.tags = [];
@@ -48,16 +48,16 @@ export default ActionOptionsView.extend({
this.requestTags();
},
- requestTags: function (query) {
- var that = this;
+ requestTags (query) {
+ const that = this;
return $.get('/api/issues/tags', { ps: 10, q: query }).done(function (data) {
that.tags = data.tags;
that.renderTags();
});
},
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
ActionOptionsView.prototype.onRender.apply(this, arguments);
this.renderTags();
setTimeout(function () {
@@ -65,19 +65,19 @@ export default ActionOptionsView.extend({
}, 100);
},
- selectInitialOption: function () {
+ selectInitialOption () {
this.selected = Math.max(Math.min(this.selected, this.getOptions().length - 1), 0);
this.makeActive(this.getOptions().eq(this.selected));
},
- filterTags: function (tags) {
- var that = this;
+ filterTags (tags) {
+ const that = this;
return _.filter(tags, function (tag) {
return tag.indexOf(that.query) !== -1;
});
},
- renderTags: function () {
+ renderTags () {
this.$('.menu').empty();
this.filterTags(this.getTags()).forEach(this.renderSelectedTag, this);
this.filterTags(_.difference(this.tags, this.getTags())).forEach(this.renderTag, this);
@@ -87,38 +87,38 @@ export default ActionOptionsView.extend({
this.selectInitialOption();
},
- renderSelectedTag: function (tag) {
- var html = this.optionTemplate({
- tag: tag,
+ renderSelectedTag (tag) {
+ const html = this.optionTemplate({
+ tag,
selected: true,
custom: false
});
return this.$('.menu').append(html);
},
- renderTag: function (tag) {
- var html = this.optionTemplate({
- tag: tag,
+ renderTag (tag) {
+ const html = this.optionTemplate({
+ tag,
selected: false,
custom: false
});
return this.$('.menu').append(html);
},
- renderCustomTag: function (tag) {
- var html = this.optionTemplate({
- tag: tag,
+ renderCustomTag (tag) {
+ const html = this.optionTemplate({
+ tag,
selected: false,
custom: true
});
return this.$('.menu').append(html);
},
- selectOption: function (e) {
+ selectOption (e) {
e.preventDefault();
e.stopPropagation();
- var tags = this.getTags().slice(),
- tag = $(e.currentTarget).data('value');
+ let tags = this.getTags().slice();
+ const tag = $(e.currentTarget).data('value');
if ($(e.currentTarget).data('selected') != null) {
tags = _.without(tags, tag);
} else {
@@ -128,10 +128,10 @@ export default ActionOptionsView.extend({
return this.submit(tags);
},
- submit: function (tags) {
- var that = this;
- var _tags = this.getTags();
- this.model.set({ tags: tags });
+ submit (tags) {
+ const that = this;
+ const _tags = this.getTags();
+ this.model.set({ tags });
return $.ajax({
type: 'POST',
url: '/api/issues/set_tags',
@@ -144,11 +144,11 @@ export default ActionOptionsView.extend({
});
},
- onInputClick: function (e) {
+ onInputClick (e) {
e.stopPropagation();
},
- onInputKeydown: function (e) {
+ onInputKeydown (e) {
this.query = this.$('input').val();
if (e.keyCode === 38) {
this.selectPreviousOption();
@@ -167,27 +167,27 @@ export default ActionOptionsView.extend({
}
},
- onInputKeyup: function () {
- var query = this.$('input').val();
+ onInputKeyup () {
+ const query = this.$('input').val();
if (query !== this.query) {
this.query = query;
this.debouncedSearch(query);
}
},
- search: function (query) {
+ search (query) {
this.query = query;
return this.requestTags(query);
},
- resetAssignees: function (users) {
+ resetAssignees (users) {
this.assignees = users.map(function (user) {
return { id: user.login, text: user.name };
});
this.renderTags();
},
- getTags: function () {
+ getTags () {
return this.model.get('tags') || [];
}
});
diff --git a/server/sonar-web/src/main/js/components/issue/views/transitions-form-view.js b/server/sonar-web/src/main/js/components/issue/views/transitions-form-view.js
index b1e1be786d1..34e5d6c1cdd 100644
--- a/server/sonar-web/src/main/js/components/issue/views/transitions-form-view.js
+++ b/server/sonar-web/src/main/js/components/issue/views/transitions-form-view.js
@@ -24,17 +24,17 @@ import Template from '../templates/issue-transitions-form.hbs';
export default ActionOptionsView.extend({
template: Template,
- selectInitialOption: function () {
+ selectInitialOption () {
this.makeActive(this.getOptions().first());
},
- selectOption: function (e) {
- var transition = $(e.currentTarget).data('value');
+ selectOption (e) {
+ const transition = $(e.currentTarget).data('value');
this.submit(transition);
return ActionOptionsView.prototype.selectOption.apply(this, arguments);
},
- submit: function (transition) {
+ submit (transition) {
return this.model.transition(transition);
}
});
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 28dbfad8d01..ca5c72798ed 100644
--- a/server/sonar-web/src/main/js/components/navigator/controller.js
+++ b/server/sonar-web/src/main/js/components/navigator/controller.js
@@ -23,21 +23,21 @@ import Marionette from 'backbone.marionette';
export default Marionette.Controller.extend({
pageSize: 50,
- initialize: function (options) {
+ initialize (options) {
this.app = options.app;
this.listenTo(options.app.state, 'change:query', this.fetchList);
},
- _allFacets: function () {
+ _allFacets () {
return this.options.app.state.get('allFacets').map(function (facet) {
return { property: facet };
});
},
- _enabledFacets: function () {
- var that = this,
- facets = this.options.app.state.get('facets'),
- criteria = Object.keys(this.options.app.state.get('query'));
+ _enabledFacets () {
+ const that = this;
+ let facets = this.options.app.state.get('facets');
+ const criteria = Object.keys(this.options.app.state.get('query'));
facets = facets.concat(criteria);
facets = facets.map(function (facet) {
return that.options.app.state.get('transform')[facet] != null ?
@@ -49,25 +49,25 @@ export default Marionette.Controller.extend({
});
},
- _facetsFromServer: function () {
- var that = this,
- facets = this._enabledFacets();
+ _facetsFromServer () {
+ const that = this;
+ const facets = this._enabledFacets();
return facets.filter(function (facet) {
return that.options.app.state.get('facetsFromServer').indexOf(facet) !== -1;
});
},
- fetchList: function () {
+ fetchList () {
},
- fetchNextPage: function () {
+ fetchNextPage () {
this.options.app.state.nextPage();
return this.fetchList(false);
},
- enableFacet: function (id) {
- var facet = this.options.app.facets.get(id);
+ enableFacet (id) {
+ const facet = this.options.app.facets.get(id);
if (facet.has('values') || this.options.app.state.get('facetsFromServer').indexOf(id) === -1) {
facet.set({ enabled: true });
} else {
@@ -78,14 +78,14 @@ export default Marionette.Controller.extend({
}
},
- disableFacet: function (id) {
- var facet = this.options.app.facets.get(id);
+ disableFacet (id) {
+ const facet = this.options.app.facets.get(id);
facet.set({ enabled: false });
this.options.app.facetsView.children.findByModel(facet).disable();
},
- toggleFacet: function (id) {
- var facet = this.options.app.facets.get(id);
+ toggleFacet (id) {
+ const facet = this.options.app.facets.get(id);
if (facet.get('enabled')) {
this.disableFacet(id);
} else {
@@ -93,19 +93,19 @@ export default Marionette.Controller.extend({
}
},
- enableFacets: function (facets) {
+ enableFacets (facets) {
facets.forEach(this.enableFacet, this);
},
- newSearch: function () {
+ newSearch () {
this.options.app.state.setQuery({});
},
- parseQuery: function (query, separator) {
+ parseQuery (query, separator) {
separator = separator || '|';
- var q = {};
+ const q = {};
(query || '').split(separator).forEach(function (t) {
- var tokens = t.split('=');
+ const tokens = t.split('=');
if (tokens[0] && tokens[1] != null) {
q[tokens[0]] = decodeURIComponent(tokens[1]);
}
@@ -113,28 +113,28 @@ export default Marionette.Controller.extend({
return q;
},
- getQuery: function (separator) {
+ getQuery (separator) {
separator = separator || '|';
- var filter = this.options.app.state.get('query'),
- route = [];
+ const filter = this.options.app.state.get('query');
+ const route = [];
_.map(filter, function (value, property) {
route.push('' + property + '=' + encodeURIComponent(value));
});
return route.join(separator);
},
- getRoute: function (separator) {
+ getRoute (separator) {
separator = separator || '|';
return this.getQuery(separator);
},
- selectNext: function () {
- var index = this.options.app.state.get('selectedIndex') + 1;
+ selectNext () {
+ const index = this.options.app.state.get('selectedIndex') + 1;
if (index < this.options.app.list.length) {
this.options.app.state.set({ selectedIndex: index });
} else {
if (!this.options.app.state.get('maxResultsReached')) {
- var that = this;
+ const that = this;
this.fetchNextPage().done(function () {
that.options.app.state.set({ selectedIndex: index });
});
@@ -144,8 +144,8 @@ export default Marionette.Controller.extend({
}
},
- selectPrev: function () {
- var index = this.options.app.state.get('selectedIndex') - 1;
+ selectPrev () {
+ const index = this.options.app.state.get('selectedIndex') - 1;
if (index >= 0) {
this.options.app.state.set({ selectedIndex: index });
} else {
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 9209791da8e..b7a67411a61 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
@@ -23,29 +23,29 @@ import BaseFacet from './facets/base-facet';
export default Marionette.CollectionView.extend({
className: 'search-navigator-facets-list',
- childViewOptions: function () {
+ childViewOptions () {
return {
app: this.options.app
};
},
- getChildView: function () {
+ getChildView () {
return BaseFacet;
},
- collectionEvents: function () {
+ collectionEvents () {
return {
'change:enabled': 'updateState'
};
},
- updateState: function () {
- var enabledFacets = this.collection.filter(function (model) {
- return model.get('enabled');
- }),
- enabledFacetIds = enabledFacets.map(function (model) {
- return model.id;
- });
+ updateState () {
+ const enabledFacets = this.collection.filter(function (model) {
+ return model.get('enabled');
+ });
+ const enabledFacetIds = enabledFacets.map(function (model) {
+ return model.id;
+ });
this.options.app.state.set({ facets: enabledFacetIds });
}
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 f79c02f6a6a..ce9e3deec08 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
@@ -25,28 +25,28 @@ export default Marionette.ItemView.extend({
className: 'search-navigator-facet-box',
forbiddenClassName: 'search-navigator-facet-box-forbidden',
- modelEvents: function () {
+ modelEvents () {
return {
'change': 'render'
};
},
- events: function () {
+ events () {
return {
'click .js-facet-toggle': 'toggle',
'click .js-facet': 'toggleFacet'
};
},
- onRender: function () {
+ onRender () {
this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled'));
this.$el.attr('data-property', this.model.get('property'));
- var that = this,
- property = this.model.get('property'),
- value = this.options.app.state.get('query')[property];
+ const that = this;
+ const property = this.model.get('property');
+ const value = this.options.app.state.get('query')[property];
if (typeof value === 'string') {
value.split(',').forEach(function (s) {
- var facet = that.$('.js-facet').filter('[data-value="' + s + '"]');
+ const facet = that.$('.js-facet').filter('[data-value="' + s + '"]');
if (facet.length > 0) {
facet.addClass('active');
}
@@ -54,47 +54,47 @@ export default Marionette.ItemView.extend({
}
},
- toggle: function () {
+ toggle () {
if (!this.isForbidden()) {
this.options.app.controller.toggleFacet(this.model.id);
}
},
- getValue: function () {
+ getValue () {
return this.$('.js-facet.active').map(function () {
return $(this).data('value');
}).get().join();
},
- toggleFacet: function (e) {
+ toggleFacet (e) {
$(e.currentTarget).toggleClass('active');
- var property = this.model.get('property'),
- obj = {};
+ const property = this.model.get('property');
+ const obj = {};
obj[property] = this.getValue();
this.options.app.state.updateFilter(obj);
},
- disable: function () {
- var property = this.model.get('property'),
- obj = {};
+ disable () {
+ const property = this.model.get('property');
+ const obj = {};
obj[property] = null;
this.options.app.state.updateFilter(obj);
},
- forbid: function () {
+ forbid () {
this.options.app.controller.disableFacet(this.model.id);
this.$el.addClass(this.forbiddenClassName);
},
- allow: function () {
+ allow () {
this.$el.removeClass(this.forbiddenClassName);
},
- isForbidden: function () {
+ isForbidden () {
return this.$el.hasClass(this.forbiddenClassName);
},
- sortValues: function (values) {
+ sortValues (values) {
return values.slice().sort(function (left, right) {
if (left.count !== right.count) {
return right.count - left.count;
@@ -111,7 +111,7 @@ export default Marionette.ItemView.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
values: this.sortValues(this.model.getValues())
});
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 8e3750d78ef..2d77c5d8849 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
@@ -25,39 +25,39 @@ import ChoiceFilters from './choice-filters';
import Template from '../templates/ajax-select-filter.hbs';
import ListTemplate from '../templates/choice-filter-item.hbs';
-var PAGE_SIZE = 100;
+const PAGE_SIZE = 100;
-var Suggestions = Backbone.Collection.extend({
+const Suggestions = Backbone.Collection.extend({
comparator: 'text',
- initialize: function () {
+ initialize () {
this.more = false;
this.page = 0;
},
- parse: function (r) {
+ parse (r) {
this.more = r.more;
return r.results;
},
- fetch: function (options) {
+ fetch (options) {
this.data = _.extend({
p: 1,
ps: PAGE_SIZE
}, options.data || {});
- var settings = _.extend({}, options, { data: this.data });
+ const settings = _.extend({}, options, { data: this.data });
return Backbone.Collection.prototype.fetch.call(this, settings);
},
- fetchNextPage: function (options) {
+ fetchNextPage (options) {
if (this.more) {
this.data.p += 1;
- var settings = _.extend({ remove: false }, options, { data: this.data });
+ const settings = _.extend({ remove: false }, options, { data: this.data });
return this.fetch(settings);
}
return false;
@@ -66,14 +66,14 @@ var Suggestions = Backbone.Collection.extend({
});
-var UserSuggestions = Suggestions.extend({
+const UserSuggestions = Suggestions.extend({
- url: function () {
+ url () {
return '/api/users/search';
},
- parse: function (response) {
- var parsedResponse = window.usersToSelect2(response);
+ parse (response) {
+ const parsedResponse = window.usersToSelect2(response);
this.more = parsedResponse.more;
this.results = parsedResponse.results;
}
@@ -81,27 +81,27 @@ var UserSuggestions = Suggestions.extend({
});
-var ProjectSuggestions = Suggestions.extend({
+const ProjectSuggestions = Suggestions.extend({
- url: function () {
+ url () {
return '/api/resources/search?f=s2&q=TRK&display_key=true';
}
});
-var ComponentSuggestions = Suggestions.extend({
+const ComponentSuggestions = Suggestions.extend({
- url: function () {
+ url () {
return '/api/resources/search?f=s2&qp=supportsGlobalDashboards&display_key=true';
},
- parse: function (r) {
+ parse (r) {
this.more = r.more;
// If results are divided into categories
if (r.results.length > 0 && r.results[0].children) {
- var results = [];
+ const results = [];
_.each(r.results, function (category) {
_.each(category.children, function (child) {
child.category = category.text;
@@ -117,26 +117,26 @@ var ComponentSuggestions = Suggestions.extend({
});
-var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
+const AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
template: Template,
listTemplate: ListTemplate,
searchKey: 's',
- render: function () {
+ render () {
ChoiceFilters.DetailsChoiceFilterView.prototype.render.apply(this, arguments);
- var that = this,
- 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();
- },
- throttledScroll = _.throttle(scroll, 1000);
+ const that = this;
+ const keyup = function (e) {
+ if (e.keyCode !== 37 && e.keyCode !== 38 && e.keyCode !== 39 && e.keyCode !== 40) {
+ that.search();
+ }
+ };
+ const debouncedKeyup = _.debounce(keyup, 250);
+ const scroll = function () {
+ that.scroll();
+ };
+ const throttledScroll = _.throttle(scroll, 1000);
this.$('.navigator-filter-search input')
.off('keyup keydown')
@@ -149,17 +149,17 @@ var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
},
- search: function () {
- var that = this;
+ search () {
+ const that = this;
this.query = this.$('.navigator-filter-search input').val();
if (this.query.length > 1) {
this.$el.addClass('fetching');
- var selected = that.options.filterView.getSelected(),
- data = { ps: PAGE_SIZE };
+ const selected = that.options.filterView.getSelected();
+ const data = { ps: PAGE_SIZE };
data[this.searchKey] = this.query;
this.options.filterView.choices.fetch({
- data: data,
- success: function () {
+ data,
+ success () {
selected.forEach(function (item) {
that.options.filterView.choices.unshift(item);
});
@@ -172,7 +172,7 @@ var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
that.$el.removeClass('fetching');
that.$('.navigator-filter-search').removeClass('fetching-error');
},
- error: function () {
+ error () {
that.showSearchError();
}
});
@@ -183,16 +183,16 @@ var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
},
- showSearchError: function () {
+ showSearchError () {
this.$el.removeClass('fetching');
this.$('.navigator-filter-search').addClass('fetching-error');
},
- scroll: function () {
- var that = this,
- el = this.$('.choices'),
- scrollBottom = el.scrollTop() >= el[0].scrollHeight - el.outerHeight();
+ scroll () {
+ const that = this;
+ const el = this.$('.choices');
+ const scrollBottom = el.scrollTop() >= el[0].scrollHeight - el.outerHeight();
if (scrollBottom) {
this.options.filterView.choices.fetchNextPage().done(function () {
@@ -202,15 +202,15 @@ var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
},
- keydown: function (e) {
+ keydown (e) {
if (_([38, 40, 13]).indexOf(e.keyCode) !== -1) {
e.preventDefault();
}
},
- resetChoices: function () {
- var that = this;
+ resetChoices () {
+ const that = this;
this.options.filterView.choices.reset(this.options.filterView.choices.filter(function (item) {
return item.get('checked');
}));
@@ -220,7 +220,7 @@ var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
},
- onShow: function () {
+ onShow () {
ChoiceFilters.DetailsChoiceFilterView.prototype.onShow.apply(this, arguments);
this.resetChoices();
this.render();
@@ -230,38 +230,38 @@ var AjaxSelectDetailsFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
});
-var AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
+const AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
- initialize: function (options) {
+ initialize (options) {
ChoiceFilters.ChoiceFilterView.prototype.initialize.call(this, {
detailsView: (options && options.detailsView) ? options.detailsView : AjaxSelectDetailsFilterView
});
},
- isDefaultValue: function () {
+ isDefaultValue () {
return this.getSelected().length === 0;
},
- renderInput: function () {
- var value = this.model.get('value') || [],
- input = $('<input>')
- .prop('name', this.model.get('property'))
- .prop('type', 'hidden')
- .css('display', 'none')
- .val(value.join());
+ renderInput () {
+ const value = this.model.get('value') || [];
+ const input = $('<input>')
+ .prop('name', this.model.get('property'))
+ .prop('type', 'hidden')
+ .css('display', 'none')
+ .val(value.join());
input.appendTo(this.$el);
},
- restoreFromQuery: function (q) {
- var param = _.findWhere(q, { key: this.model.get('property') });
+ restoreFromQuery (q) {
+ let param = _.findWhere(q, { key: this.model.get('property') });
if (this.model.get('choices')) {
_.each(this.model.get('choices'), function (v, k) {
if (k[0] === '!') {
- var x = _.findWhere(q, { key: k.substr(1) });
+ const x = _.findWhere(q, { key: k.substr(1) });
if (x == null) {
return;
}
@@ -283,16 +283,16 @@ var AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
},
- restore: function (value, param) {
- var that = this;
+ restore (value, param) {
+ const that = this;
if (_.isString(value)) {
value = value.split(',');
}
if (this.choices && value.length > 0) {
- this.model.set({ value: value, enabled: true });
+ this.model.set({ value, enabled: true });
- var opposite = _.filter(value, function (item) {
+ const opposite = _.filter(value, function (item) {
return item[0] === '!';
});
opposite.forEach(function (item) {
@@ -317,8 +317,8 @@ var AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
},
- restoreFromText: function (value, text) {
- var that = this;
+ restoreFromText (value, text) {
+ const that = this;
_.each(value, function (v, i) {
that.choices.add(new Backbone.Model({
id: v,
@@ -330,11 +330,11 @@ var AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
},
- restoreByRequests: function (value) {
- var that = this,
- requests = _.map(value, function (v) {
- return that.createRequest(v);
- });
+ restoreByRequests (value) {
+ const that = this;
+ const requests = _.map(value, function (v) {
+ return that.createRequest(v);
+ });
$.when.apply($, requests).done(function () {
that.onRestore(value);
@@ -342,13 +342,13 @@ var AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
},
- onRestore: function () {
+ onRestore () {
this.detailsView.updateLists();
this.renderBase();
},
- clear: function () {
+ clear () {
this.model.unset('value');
if (this.choices) {
this.choices.reset([]);
@@ -357,15 +357,15 @@ var AjaxSelectFilterView = ChoiceFilters.ChoiceFilterView.extend({
},
- createRequest: function () {
+ createRequest () {
}
});
-var ComponentFilterView = AjaxSelectFilterView.extend({
+const ComponentFilterView = AjaxSelectFilterView.extend({
- initialize: function () {
+ initialize () {
AjaxSelectFilterView.prototype.initialize.call(this, {
detailsView: AjaxSelectDetailsFilterView
});
@@ -373,8 +373,8 @@ var ComponentFilterView = AjaxSelectFilterView.extend({
},
- createRequest: function (v) {
- var that = this;
+ createRequest (v) {
+ const that = this;
return $
.ajax({
url: '/api/resources',
@@ -392,9 +392,9 @@ var ComponentFilterView = AjaxSelectFilterView.extend({
});
-var ProjectFilterView = AjaxSelectFilterView.extend({
+const ProjectFilterView = AjaxSelectFilterView.extend({
- initialize: function () {
+ initialize () {
BaseFilters.BaseFilterView.prototype.initialize.call(this, {
detailsView: AjaxSelectDetailsFilterView
});
@@ -403,8 +403,8 @@ var ProjectFilterView = AjaxSelectFilterView.extend({
},
- createRequest: function (v) {
- var that = this;
+ createRequest (v) {
+ const that = this;
return $
.ajax({
url: '/api/resources',
@@ -423,9 +423,9 @@ var ProjectFilterView = AjaxSelectFilterView.extend({
});
-var AssigneeFilterView = AjaxSelectFilterView.extend({
+const AssigneeFilterView = AjaxSelectFilterView.extend({
- initialize: function () {
+ initialize () {
BaseFilters.BaseFilterView.prototype.initialize.call(this, {
detailsView: AjaxSelectDetailsFilterView
});
@@ -433,8 +433,8 @@ var AssigneeFilterView = AjaxSelectFilterView.extend({
this.choices = new UserSuggestions();
},
- createRequest: function (v) {
- var that = this;
+ createRequest (v) {
+ const that = this;
return $
.ajax({
url: '/api/users/search',
@@ -453,9 +453,9 @@ var AssigneeFilterView = AjaxSelectFilterView.extend({
});
-var ReporterFilterView = AjaxSelectFilterView.extend({
+const ReporterFilterView = AjaxSelectFilterView.extend({
- initialize: function () {
+ initialize () {
BaseFilters.BaseFilterView.prototype.initialize.call(this, {
detailsView: AjaxSelectDetailsFilterView
});
@@ -465,8 +465,8 @@ var ReporterFilterView = AjaxSelectFilterView.extend({
},
- createRequest: function (v) {
- var that = this;
+ createRequest (v) {
+ const that = this;
return $
.ajax({
url: '/api/users/search',
@@ -490,13 +490,13 @@ var ReporterFilterView = AjaxSelectFilterView.extend({
*/
export default {
- Suggestions: Suggestions,
- AjaxSelectDetailsFilterView: AjaxSelectDetailsFilterView,
- AjaxSelectFilterView: AjaxSelectFilterView,
- ProjectFilterView: ProjectFilterView,
- ComponentFilterView: ComponentFilterView,
- AssigneeFilterView: AssigneeFilterView,
- ReporterFilterView: ReporterFilterView
+ Suggestions,
+ AjaxSelectDetailsFilterView,
+ AjaxSelectFilterView,
+ ProjectFilterView,
+ ComponentFilterView,
+ AssigneeFilterView,
+ ReporterFilterView
};
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 b2356303547..3918ef0dc09 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
@@ -24,7 +24,7 @@ import Marionette from 'backbone.marionette';
import Template from '../templates/base-filter.hbs';
import DetailsTemplate from '../templates/base-details-filter.hbs';
-var Filter = Backbone.Model.extend({
+const Filter = Backbone.Model.extend({
defaults: {
enabled: true,
@@ -36,17 +36,17 @@ var Filter = Backbone.Model.extend({
});
-var Filters = Backbone.Collection.extend({
+const Filters = Backbone.Collection.extend({
model: Filter
});
-var DetailsFilterView = Marionette.ItemView.extend({
+const DetailsFilterView = Marionette.ItemView.extend({
template: DetailsTemplate,
className: 'navigator-filter-details',
- initialize: function () {
+ initialize () {
this.$el.on('click', function (e) {
e.stopPropagation();
});
@@ -54,19 +54,20 @@ var DetailsFilterView = Marionette.ItemView.extend({
},
- onShow: function () {
+ onShow () {
},
- onHide: function () {
+
+ onHide () {
}
});
-var BaseFilterView = Marionette.ItemView.extend({
+const BaseFilterView = Marionette.ItemView.extend({
template: Template,
className: 'navigator-filter',
- events: function () {
+ events () {
return {
'click': 'toggleDetails',
'click .navigator-filter-disable': 'disable'
@@ -83,10 +84,10 @@ var BaseFilterView = Marionette.ItemView.extend({
},
- initialize: function (options) {
+ initialize (options) {
Marionette.ItemView.prototype.initialize.apply(this, arguments);
- var detailsView = (options && options.detailsView) || DetailsFilterView;
+ const detailsView = (options && options.detailsView) || DetailsFilterView;
this.detailsView = new detailsView({
model: this.model,
filterView: this
@@ -96,12 +97,12 @@ var BaseFilterView = Marionette.ItemView.extend({
},
- attachDetailsView: function () {
+ attachDetailsView () {
this.detailsView.$el.detach().appendTo($('body'));
},
- render: function () {
+ render () {
this.renderBase();
this.attachDetailsView();
@@ -117,26 +118,26 @@ var BaseFilterView = Marionette.ItemView.extend({
},
- renderBase: function () {
+ renderBase () {
Marionette.ItemView.prototype.render.apply(this, arguments);
this.renderInput();
- var title = this.model.get('name') + ': ' + this.renderValue();
+ const title = this.model.get('name') + ': ' + this.renderValue();
this.$el.prop('title', title);
this.$el.attr('data-property', this.model.get('property'));
},
- renderInput: function () {
+ renderInput () {
},
- focus: function () {
+ focus () {
this.render();
},
- toggleDetails: function (e) {
+ toggleDetails (e) {
e.stopPropagation();
this.options.filterBarView.selected = this.options.filterBarView.getEnabledFilters().index(this.$el);
if (this.$el.hasClass('active')) {
@@ -149,48 +150,48 @@ var BaseFilterView = Marionette.ItemView.extend({
},
- showDetails: function () {
+ showDetails () {
this.registerShowedDetails();
- var top = this.$el.offset().top + this.$el.outerHeight() - 1,
- left = this.$el.offset().left;
+ const top = this.$el.offset().top + this.$el.outerHeight() - 1;
+ const left = this.$el.offset().left;
- this.detailsView.$el.css({ top: top, left: left }).addClass('active');
+ this.detailsView.$el.css({ top, left }).addClass('active');
this.$el.addClass('active');
this.detailsView.onShow();
},
- registerShowedDetails: function () {
+ registerShowedDetails () {
this.options.filterBarView.hideDetails();
this.options.filterBarView.showedView = this;
},
- hideDetails: function () {
+ hideDetails () {
this.detailsView.$el.removeClass('active');
this.$el.removeClass('active');
this.detailsView.onHide();
},
- isActive: function () {
+ isActive () {
return this.$el.is('.active');
},
- renderValue: function () {
+ renderValue () {
return this.model.get('value') || 'unset';
},
- isDefaultValue: function () {
+ isDefaultValue () {
return true;
},
- restoreFromQuery: function (q) {
- var param = _.findWhere(q, { key: this.model.get('property') });
+ restoreFromQuery (q) {
+ const param = _.findWhere(q, { key: this.model.get('property') });
if (param && param.value) {
this.model.set('enabled', true);
this.restore(param.value, param);
@@ -200,18 +201,18 @@ var BaseFilterView = Marionette.ItemView.extend({
},
- restore: function (value) {
- this.model.set({ value: value }, { silent: true });
+ restore (value) {
+ this.model.set({ value }, { silent: true });
this.renderBase();
},
- clear: function () {
+ clear () {
this.model.unset('value');
},
- disable: function (e) {
+ disable (e) {
e.stopPropagation();
this.hideDetails();
this.options.filterBarView.hideDetails();
@@ -222,8 +223,8 @@ var BaseFilterView = Marionette.ItemView.extend({
},
- formatValue: function () {
- var q = {};
+ formatValue () {
+ const q = {};
if (this.model.has('property') && this.model.has('value') && this.model.get('value')) {
q[this.model.get('property')] = this.model.get('value');
}
@@ -231,7 +232,7 @@ var BaseFilterView = Marionette.ItemView.extend({
},
- serializeData: function () {
+ serializeData () {
return _.extend({}, this.model.toJSON(), {
value: this.renderValue(),
defaultValue: this.isDefaultValue()
@@ -246,10 +247,10 @@ var BaseFilterView = Marionette.ItemView.extend({
*/
export default {
- Filter: Filter,
- Filters: Filters,
- BaseFilterView: BaseFilterView,
- DetailsFilterView: DetailsFilterView
+ Filter,
+ Filters,
+ BaseFilterView,
+ DetailsFilterView
};
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 3c3cea72f62..f337e0ee9a2 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
@@ -26,18 +26,18 @@ export default BaseFilters.BaseFilterView.extend({
className: 'navigator-filter navigator-filter-inline',
- events: function () {
+ events () {
return {
'click .navigator-filter-disable': 'disable'
};
},
- showDetails: function () {
+ showDetails () {
},
- renderInput: function () {
+ renderInput () {
if (this.model.get('enabled')) {
$('<input>')
.prop('name', this.model.get('property'))
@@ -50,19 +50,19 @@ export default BaseFilters.BaseFilterView.extend({
},
- renderValue: function () {
+ renderValue () {
return this.model.get('value');
},
- isDefaultValue: function () {
+ isDefaultValue () {
return false;
},
- restore: function (value) {
+ restore (value) {
this.model.set({
- value: 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 b6bb7a1e16d..6a43959e55e 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
@@ -25,27 +25,27 @@ import Template from '../templates/choice-filter.hbs';
import ItemTemplate from '../templates/choice-filter-item.hbs';
import { translate } from '../../../helpers/l10n';
-var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
+const DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
template: Template,
itemTemplate: ItemTemplate,
- events: function () {
+ events () {
return {
'click label': 'onCheck'
};
},
- render: function () {
+ render () {
BaseFilters.DetailsFilterView.prototype.render.apply(this, arguments);
this.updateLists();
},
- renderList: function (collection, selector) {
- var that = this,
- container = this.$(selector);
+ renderList (collection, selector) {
+ const that = this;
+ const container = this.$(selector);
container.empty().toggleClass('hidden', collection.length === 0);
collection.each(function (item) {
@@ -58,26 +58,26 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
},
- 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) {
- return item.get('id')[0] === '!';
- }));
+ updateLists () {
+ const choices = new Backbone.Collection(this.options.filterView.choices.reject(function (item) {
+ return item.get('id')[0] === '!';
+ }));
+ const opposite = new Backbone.Collection(this.options.filterView.choices.filter(function (item) {
+ return item.get('id')[0] === '!';
+ }));
this.renderList(choices, '.choices');
this.renderList(opposite, '.opposite');
- var current = this.currentChoice || 0;
+ const current = this.currentChoice || 0;
this.updateCurrent(current);
},
- onCheck: function (e) {
- var checkbox = $(e.currentTarget),
- id = checkbox.data('id'),
- checked = checkbox.find('.icon-checkbox-checked').length > 0;
+ onCheck (e) {
+ const checkbox = $(e.currentTarget);
+ const id = checkbox.data('id');
+ const checked = checkbox.find('.icon-checkbox-checked').length > 0;
if (this.model.get('multiple')) {
if (checkbox.closest('.opposite').length > 0) {
@@ -103,32 +103,32 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
},
- updateValue: function () {
+ updateValue () {
this.model.set('value', this.options.filterView.getSelected().map(function (m) {
return m.get('id');
}));
},
- updateCurrent: function (index) {
+ updateCurrent (index) {
this.currentChoice = index;
this.$('label').removeClass('current')
.eq(this.currentChoice).addClass('current');
},
- onShow: function () {
+ onShow () {
this.bindedOnKeyDown = _.bind(this.onKeyDown, this);
$('body').on('keydown', this.bindedOnKeyDown);
},
- onHide: function () {
+ onHide () {
$('body').off('keydown', this.bindedOnKeyDown);
},
- onKeyDown: function (e) {
+ onKeyDown (e) {
switch (e.keyCode) {
case 38:
e.preventDefault();
@@ -149,7 +149,7 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
},
- selectNextChoice: function () {
+ selectNextChoice () {
if (this.$('label').length > this.currentChoice + 1) {
this.updateCurrent(this.currentChoice + 1);
this.scrollNext();
@@ -157,12 +157,12 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
},
- scrollNext: function () {
- var currentLabel = this.$('label').eq(this.currentChoice);
+ scrollNext () {
+ const currentLabel = this.$('label').eq(this.currentChoice);
if (currentLabel.length > 0) {
- var list = currentLabel.closest('ul'),
- labelPos = currentLabel.offset().top - list.offset().top + list.scrollTop(),
- deltaScroll = labelPos - list.height() + currentLabel.outerHeight();
+ const list = currentLabel.closest('ul');
+ const labelPos = currentLabel.offset().top - list.offset().top + list.scrollTop();
+ const deltaScroll = labelPos - list.height() + currentLabel.outerHeight();
if (deltaScroll > 0) {
list.scrollTop(deltaScroll);
@@ -171,7 +171,7 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
},
- selectPrevChoice: function () {
+ selectPrevChoice () {
if (this.currentChoice > 0) {
this.updateCurrent(this.currentChoice - 1);
this.scrollPrev();
@@ -179,11 +179,11 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
},
- scrollPrev: function () {
- var currentLabel = this.$('label').eq(this.currentChoice);
+ scrollPrev () {
+ const currentLabel = this.$('label').eq(this.currentChoice);
if (currentLabel.length > 0) {
- var list = currentLabel.closest('ul'),
- labelPos = currentLabel.offset().top - list.offset().top;
+ const list = currentLabel.closest('ul');
+ const labelPos = currentLabel.offset().top - list.offset().top;
if (labelPos < 0) {
list.scrollTop(list.scrollTop() + labelPos);
@@ -192,13 +192,13 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
},
- selectCurrent: function () {
- var cb = this.$('label').eq(this.currentChoice);
+ selectCurrent () {
+ const cb = this.$('label').eq(this.currentChoice);
cb.click();
},
- serializeData: function () {
+ serializeData () {
return _.extend({}, this.model.toJSON(), {
choices: new Backbone.Collection(this.options.filterView.choices.reject(function (item) {
return item.get('id')[0] === '!';
@@ -212,19 +212,19 @@ var DetailsChoiceFilterView = BaseFilters.DetailsFilterView.extend({
});
-var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
+const ChoiceFilterView = BaseFilters.BaseFilterView.extend({
- initialize: function (options) {
+ initialize (options) {
BaseFilters.BaseFilterView.prototype.initialize.call(this, {
detailsView: (options && options.detailsView) ? options.detailsView : DetailsChoiceFilterView
});
- var index = 0,
- icons = this.model.get('choiceIcons');
+ let index = 0;
+ const icons = this.model.get('choiceIcons');
this.choices = new Backbone.Collection(
_.map(this.model.get('choices'), function (value, key) {
- var model = new Backbone.Model({
+ const model = new Backbone.Model({
id: key,
text: value,
checked: false,
@@ -241,20 +241,20 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
},
- getSelected: function () {
+ getSelected () {
return this.choices.filter(function (m) {
return m.get('checked');
});
},
- renderInput: function () {
- var input = $('<select>')
+ renderInput () {
+ const input = $('<select>')
.prop('name', this.model.get('property'))
.prop('multiple', true)
.css('display', 'none');
this.choices.each(function (item) {
- var option = $('<option>')
+ const option = $('<option>')
.prop('value', item.get('id'))
.prop('selected', item.get('checked'))
.text(item.get('text'));
@@ -264,25 +264,25 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
},
- renderValue: function () {
- var value = this.getSelected().map(function (item) {
- return item.get('text');
- }),
- defaultValue = this.model.has('defaultValue') ?
- this.model.get('defaultValue') :
- this.model.get('multiple') ? translate('all') : translate('any');
+ renderValue () {
+ const value = this.getSelected().map(function (item) {
+ return item.get('text');
+ });
+ const defaultValue = this.model.has('defaultValue') ?
+ this.model.get('defaultValue') :
+ this.model.get('multiple') ? translate('all') : translate('any');
return this.isDefaultValue() ? defaultValue : value.join(', ');
},
- isDefaultValue: function () {
- var selected = this.getSelected();
+ isDefaultValue () {
+ const selected = this.getSelected();
return selected.length === 0;
},
- disable: function () {
+ disable () {
this.choices.each(function (item) {
item.set('checked', false);
});
@@ -290,17 +290,17 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
},
- restoreFromQuery: function (q) {
- var param = _.findWhere(q, { key: this.model.get('property') });
+ restoreFromQuery (q) {
+ let param = _.findWhere(q, { key: this.model.get('property') });
if (this.choices) {
this.choices.forEach(function (item) {
if (item.get('id')[0] === '!') {
- var x = _.findWhere(q, { key: item.get('id').substr(1) });
+ let x = _.findWhere(q, { key: item.get('id').substr(1) });
if (item.get('id').indexOf('=') >= 0) {
- var key = item.get('id').split('=')[0].substr(1);
- var value = item.get('id').split('=')[1];
- x = _.findWhere(q, { key: key, value: value });
+ const key = item.get('id').split('=')[0].substr(1);
+ const value = item.get('id').split('=')[1];
+ x = _.findWhere(q, { key, value });
}
if (x == null) {
return;
@@ -323,22 +323,22 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
},
- restore: function (value) {
+ restore (value) {
if (_.isString(value)) {
value = value.split(',');
}
if (this.choices && value.length > 0) {
- var that = this;
+ const that = this;
that.choices.each(function (item) {
item.set('checked', false);
});
- var unknownValues = [];
+ const unknownValues = [];
_.each(value, function (v) {
- var cModel = that.choices.findWhere({ id: v });
+ const cModel = that.choices.findWhere({ id: v });
if (cModel) {
cModel.set('checked', true);
} else {
@@ -349,7 +349,7 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
value = _.difference(value, unknownValues);
this.model.set({
- value: value,
+ value,
enabled: true
});
@@ -360,7 +360,7 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
},
- clear: function () {
+ clear () {
if (this.choices) {
this.choices.each(function (item) {
item.set('checked', false);
@@ -374,16 +374,16 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
},
- formatValue: function () {
- var q = {};
+ formatValue () {
+ const q = {};
if (this.model.has('property') && this.model.has('value') && this.model.get('value').length > 0) {
- var opposite = _.filter(this.model.get('value'), function (item) {
+ const opposite = _.filter(this.model.get('value'), function (item) {
return item[0] === '!';
});
if (opposite.length > 0) {
opposite.forEach(function (item) {
if (item.indexOf('=') >= 0) {
- var paramValue = item.split('=');
+ const paramValue = item.split('=');
q[paramValue[0].substr(1)] = paramValue[1];
} else {
q[item.substr(1)] = false;
@@ -404,6 +404,6 @@ var ChoiceFilterView = BaseFilters.BaseFilterView.extend({
*/
export default {
- DetailsChoiceFilterView: DetailsChoiceFilterView,
- ChoiceFilterView: ChoiceFilterView
+ DetailsChoiceFilterView,
+ ChoiceFilterView
};
diff --git a/server/sonar-web/src/main/js/components/navigator/filters/favorite-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/favorite-filters.js
index 6b9734e3263..3852d32983e 100644
--- a/server/sonar-web/src/main/js/components/navigator/filters/favorite-filters.js
+++ b/server/sonar-web/src/main/js/components/navigator/filters/favorite-filters.js
@@ -24,7 +24,7 @@ import ChoiceFilters from './choice-filters';
import Template from '../templates/favorite-filter.hbs';
import DetailsTemplate from '../templates/favorite-details-filter.hbs';
-var DetailsFavoriteFilterView = BaseFilters.DetailsFilterView.extend({
+const DetailsFavoriteFilterView = BaseFilters.DetailsFilterView.extend({
template: DetailsTemplate,
@@ -34,56 +34,56 @@ var DetailsFavoriteFilterView = BaseFilters.DetailsFilterView.extend({
},
- applyFavorite: function (e) {
- var id = $(e.target).data('id');
+ applyFavorite (e) {
+ const id = $(e.target).data('id');
window.location = this.model.get('favoriteUrl') + '/' + id;
},
- manage: function () {
+ manage () {
window.location = this.model.get('manageUrl');
},
- serializeData: function () {
- var choices = this.model.get('choices'),
- choicesArray =
- _.sortBy(
- _.map(choices, function (v, k) {
- return { v: v, k: k };
- }),
- 'v');
+ serializeData () {
+ const choices = this.model.get('choices');
+ const choicesArray =
+ _.sortBy(
+ _.map(choices, function (v, k) {
+ return { v, k };
+ }),
+ 'v');
return _.extend({}, this.model.toJSON(), {
- choicesArray: choicesArray
+ choicesArray
});
}
});
-var FavoriteFilterView = ChoiceFilters.ChoiceFilterView.extend({
+const FavoriteFilterView = ChoiceFilters.ChoiceFilterView.extend({
template: Template,
className: 'navigator-filter navigator-filter-favorite',
- initialize: function () {
+ initialize () {
ChoiceFilters.ChoiceFilterView.prototype.initialize.call(this, {
detailsView: DetailsFavoriteFilterView
});
},
- renderValue: function () {
+ renderValue () {
return '';
},
- renderInput: function () {
+ renderInput () {
},
- isDefaultValue: function () {
+ isDefaultValue () {
return false;
}
@@ -95,8 +95,8 @@ var FavoriteFilterView = ChoiceFilters.ChoiceFilterView.extend({
*/
export default {
- DetailsFavoriteFilterView: DetailsFavoriteFilterView,
- FavoriteFilterView: FavoriteFilterView
+ DetailsFavoriteFilterView,
+ FavoriteFilterView
};
diff --git a/server/sonar-web/src/main/js/components/navigator/filters/filter-bar.js b/server/sonar-web/src/main/js/components/navigator/filters/filter-bar.js
index 787579d9e1b..843ac9184ad 100644
--- a/server/sonar-web/src/main/js/components/navigator/filters/filter-bar.js
+++ b/server/sonar-web/src/main/js/components/navigator/filters/filter-bar.js
@@ -32,12 +32,12 @@ export default Marionette.CompositeView.extend({
},
- getChildView: function (item) {
+ getChildView (item) {
return item.get('type') || BaseFilters.BaseFilterView;
},
- childViewOptions: function () {
+ childViewOptions () {
return {
filterBarView: this,
app: this.options.app
@@ -45,22 +45,22 @@ export default Marionette.CompositeView.extend({
},
- initialize: function () {
+ initialize () {
Marionette.CompositeView.prototype.initialize.apply(this, arguments);
- var that = this;
+ const that = this;
$('body').on('click', function () {
that.hideDetails();
});
this.addMoreCriteriaFilter();
key.filter = function (e) {
- var r = true,
- el = $(e.target),
- box = el.closest('.navigator-filter-details-inner'),
- tabbableSet = box.find(':tabbable'),
- isElFocusable = el.is(':input') || el.is('a'),
- isInsideDialog = el.closest('.ui-dialog').length > 0;
+ let r = true;
+ const el = $(e.target);
+ const box = el.closest('.navigator-filter-details-inner');
+ const tabbableSet = box.find(':tabbable');
+ const isElFocusable = el.is(':input') || el.is('a');
+ const isInsideDialog = el.closest('.ui-dialog').length > 0;
if (isElFocusable) {
if (!isInsideDialog && (e.keyCode === 9 || e.keyCode === 27)) {
r = tabbableSet.index(el) >= tabbableSet.length - 1;
@@ -91,7 +91,7 @@ export default Marionette.CompositeView.extend({
},
- getEnabledFilters: function () {
+ getEnabledFilters () {
return this.$(this.childViewContainer).children()
.not('.navigator-filter-disabled')
.not('.navigator-filter-inactive')
@@ -99,14 +99,14 @@ export default Marionette.CompositeView.extend({
},
- selectFirst: function () {
+ selectFirst () {
this.selected = -1;
this.selectNext();
},
- selectPrev: function () {
- var filters = this.getEnabledFilters();
+ selectPrev () {
+ const filters = this.getEnabledFilters();
if (this.selected > 0) {
filters.eq(this.selected).blur();
this.selected--;
@@ -116,8 +116,8 @@ export default Marionette.CompositeView.extend({
},
- selectNext: function () {
- var filters = this.getEnabledFilters();
+ selectNext () {
+ const filters = this.getEnabledFilters();
if (this.selected < filters.length - 1) {
filters.eq(this.selected).blur();
this.selected++;
@@ -130,8 +130,8 @@ export default Marionette.CompositeView.extend({
},
- addMoreCriteriaFilter: function () {
- var disabledFilters = this.collection.where({ enabled: false });
+ addMoreCriteriaFilter () {
+ const disabledFilters = this.collection.where({ enabled: false });
if (disabledFilters.length > 0) {
this.moreCriteriaFilter = new BaseFilters.Filter({
type: MoreCriteriaFilters.MoreCriteriaFilterView,
@@ -144,14 +144,14 @@ export default Marionette.CompositeView.extend({
},
- onAddChild: function (childView) {
+ onAddChild (childView) {
if (childView.model.get('type') === MoreCriteriaFilters.FavoriteFilterView) {
$('.navigator-header').addClass('navigator-header-favorite');
}
},
- restoreFromQuery: function (q) {
+ restoreFromQuery (q) {
this.collection.each(function (item) {
item.set('enabled', !item.get('optional'));
item.view.clear();
@@ -160,16 +160,16 @@ export default Marionette.CompositeView.extend({
},
- hideDetails: function () {
+ hideDetails () {
if (_.isObject(this.showedView)) {
this.showedView.hideDetails();
}
},
- enableFilter: function (id) {
- var filter = this.collection.get(id),
- filterView = filter.view;
+ enableFilter (id) {
+ const filter = this.collection.get(id);
+ const filterView = filter.view;
filterView.$el.detach().insertBefore(this.$('.navigator-filter-more-criteria'));
filter.set('enabled', true);
@@ -177,8 +177,8 @@ export default Marionette.CompositeView.extend({
},
- changeEnabled: function () {
- var disabledFilters = _.reject(this.collection.where({ enabled: false }), function (filter) {
+ changeEnabled () {
+ const disabledFilters = _.reject(this.collection.where({ enabled: false }), function (filter) {
return filter.get('type') === MoreCriteriaFilters.MoreCriteriaFilterView;
});
diff --git a/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js
index 4bb91af5bda..f460810eee6 100644
--- a/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js
+++ b/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js
@@ -23,7 +23,7 @@ import BaseFilters from './base-filters';
import Template from '../templates/metric-filter.hbs';
import { translate } from '../../../helpers/l10n';
-var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
+const DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
template: Template,
@@ -32,22 +32,22 @@ var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
},
- inputChanged: function () {
- var metric = this.$('[name=metric]').val(),
- isDifferentialMetric = metric.indexOf('new_') === 0,
- periodSelect = this.$('[name=period]'),
- period = periodSelect.val(),
- optionZero = periodSelect.children('[value="0"]'),
- value = {
- metric: metric,
- metricText: this.$('[name=metric] option:selected').text(),
- period: period,
- periodText: this.$('[name=period] option:selected').text(),
- op: this.$('[name=op]').val(),
- opText: this.$('[name=op] option:selected').text(),
- val: this.$('[name=val]').val(),
- valText: this.$('[name=val]').originalVal()
- };
+ inputChanged () {
+ const metric = this.$('[name=metric]').val();
+ const isDifferentialMetric = metric.indexOf('new_') === 0;
+ const periodSelect = this.$('[name=period]');
+ let period = periodSelect.val();
+ const optionZero = periodSelect.children('[value="0"]');
+ const value = {
+ metric,
+ period,
+ metricText: this.$('[name=metric] option:selected').text(),
+ periodText: this.$('[name=period] option:selected').text(),
+ op: this.$('[name=op]').val(),
+ opText: this.$('[name=op] option:selected').text(),
+ val: this.$('[name=val]').val(),
+ valText: this.$('[name=val]').originalVal()
+ };
if (isDifferentialMetric) {
optionZero.remove();
@@ -69,8 +69,8 @@ var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
},
- updateDataType: function (value) {
- var metric = _.find(window.SS.metrics, function (m) {
+ updateDataType (value) {
+ const metric = _.find(window.SS.metrics, function (m) {
return m.metric.name === value.metric;
});
if (metric) {
@@ -85,11 +85,11 @@ var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
},
- onRender: function () {
- var periodZeroLabel = this.$('[name=period]').children('[value="0"]').html();
+ onRender () {
+ const periodZeroLabel = this.$('[name=period]').children('[value="0"]').html();
this.periodZeroOption = '<option value="0">' + periodZeroLabel + '</option>';
- var value = this.model.get('value') || {};
+ const value = this.model.get('value') || {};
this.$('[name=metric]').val(value.metric).select2({
width: '100%',
placeholder: translate('measure_filter.criteria.metric')
@@ -109,8 +109,8 @@ var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
},
- onShow: function () {
- var select = this.$('[name=metric]');
+ onShow () {
+ const select = this.$('[name=metric]');
if (this.model.get('value').metric === '') {
select.select2('open');
} else {
@@ -123,7 +123,7 @@ var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({
export default BaseFilters.BaseFilterView.extend({
- initialize: function () {
+ initialize () {
BaseFilters.BaseFilterView.prototype.initialize.call(this, {
detailsView: DetailsMetricFilterView
});
@@ -132,27 +132,27 @@ export default BaseFilters.BaseFilterView.extend({
},
- groupMetrics: function () {
- var metrics = _.map(this.model.get('metrics'), function (metric) {
- return metric.metric;
- }),
- groupedMetrics =
- _.sortBy(
- _.map(
- _.groupBy(metrics, 'domain'),
- function (metricList, domain) {
- return {
- domain: domain,
- metrics: _.sortBy(metricList, 'short_name')
- };
- }),
- 'domain'
- );
+ groupMetrics () {
+ const metrics = _.map(this.model.get('metrics'), function (metric) {
+ return metric.metric;
+ });
+ const groupedMetrics =
+ _.sortBy(
+ _.map(
+ _.groupBy(metrics, 'domain'),
+ function (metricList, domain) {
+ return {
+ domain,
+ metrics: _.sortBy(metricList, 'short_name')
+ };
+ }),
+ 'domain'
+ );
this.model.set('groupedMetrics', groupedMetrics);
},
- renderValue: function () {
+ renderValue () {
return this.isDefaultValue() ?
translate('measure_filter.criteria.metric.not_set') :
this.model.get('value').metricText + ' ' + this.model.get('value').opText + ' ' +
@@ -160,13 +160,13 @@ export default BaseFilters.BaseFilterView.extend({
},
- renderInput: function () {
- var that = this,
- value = this.model.get('value');
+ renderInput () {
+ const that = this;
+ const value = this.model.get('value');
if (_.isObject(value) && value.metric && value.op && (value.val != null)) {
_.each(['metric', 'period', 'op', 'val'], function (key) {
- var v = value[key];
+ let v = value[key];
if (key === 'period' && v === '0') {
v = '';
}
@@ -182,8 +182,8 @@ export default BaseFilters.BaseFilterView.extend({
},
- isDefaultValue: function () {
- var value = this.model.get('value');
+ isDefaultValue () {
+ const value = this.model.get('value');
if (!_.isObject(value)) {
return true;
}
@@ -191,12 +191,12 @@ export default BaseFilters.BaseFilterView.extend({
},
- restoreFromQuery: function (q) {
- var that = this,
- value = {};
+ restoreFromQuery (q) {
+ const that = this;
+ const value = {};
_.each(['metric', 'period', 'op', 'val'], function (p) {
- var property = that.model.get('property') + '_' + p,
- pValue = _.findWhere(q, { key: property });
+ const property = that.model.get('property') + '_' + p;
+ const pValue = _.findWhere(q, { key: property });
if (pValue && pValue.value) {
value[p] = pValue.value;
@@ -205,7 +205,7 @@ export default BaseFilters.BaseFilterView.extend({
if (value && value.metric && value.op && (value.val != null)) {
this.model.set({
- value: value,
+ value,
enabled: true
});
}
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 40c0af94d60..327f9f4d89c 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
@@ -23,7 +23,7 @@ import ChoiceFilters from './choice-filters';
import Template from '../templates/more-criteria-filter.hbs';
import DetailsTemplate from '../templates/more-criteria-details-filter.hbs';
-var DetailsMoreCriteriaFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
+const DetailsMoreCriteriaFilterView = ChoiceFilters.DetailsChoiceFilterView.extend({
template: DetailsTemplate,
@@ -32,14 +32,14 @@ var DetailsMoreCriteriaFilterView = ChoiceFilters.DetailsChoiceFilterView.extend
},
- enableById: function (id) {
+ enableById (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 (property) {
+ const filter = _.find(this.model.get('filters'), function (f) {
return f.get('property') === property;
});
if (filter) {
@@ -48,61 +48,61 @@ var DetailsMoreCriteriaFilterView = ChoiceFilters.DetailsChoiceFilterView.extend
},
- enableFilter: function (e) {
- var id = $(e.target).data('id');
+ enableFilter (e) {
+ const id = $(e.target).data('id');
this.enableById(id);
this.updateCurrent(0);
},
- selectCurrent: function () {
+ selectCurrent () {
this.$('label').eq(this.currentChoice).click();
},
- serializeData: function () {
- var filters = this.model.get('filters').map(function (filter) {
- return _.extend(filter.toJSON(), { id: filter.cid });
- }),
- getName = function (filter) {
- return filter.name;
- },
- uniqueFilters = _.unique(filters, getName),
- sortedFilters = _.sortBy(uniqueFilters, getName);
+ serializeData () {
+ const filters = this.model.get('filters').map(function (filter) {
+ return _.extend(filter.toJSON(), { id: filter.cid });
+ });
+ const getName = function (filter) {
+ return filter.name;
+ };
+ const uniqueFilters = _.unique(filters, getName);
+ const sortedFilters = _.sortBy(uniqueFilters, getName);
return _.extend(this.model.toJSON(), { filters: sortedFilters });
}
});
-var MoreCriteriaFilterView = ChoiceFilters.ChoiceFilterView.extend({
+const MoreCriteriaFilterView = ChoiceFilters.ChoiceFilterView.extend({
template: Template,
className: 'navigator-filter navigator-filter-more-criteria',
- initialize: function () {
+ initialize () {
ChoiceFilters.ChoiceFilterView.prototype.initialize.call(this, {
detailsView: DetailsMoreCriteriaFilterView
});
},
- renderValue: function () {
+ renderValue () {
return '';
},
- renderInput: function () {
+ renderInput () {
},
- renderBase: function () {
+ renderBase () {
ChoiceFilters.ChoiceFilterView.prototype.renderBase.call(this);
this.$el.prop('title', '');
},
- isDefaultValue: function () {
+ isDefaultValue () {
return false;
}
@@ -114,8 +114,8 @@ var MoreCriteriaFilterView = ChoiceFilters.ChoiceFilterView.extend({
*/
export default {
- DetailsMoreCriteriaFilterView: DetailsMoreCriteriaFilterView,
- MoreCriteriaFilterView: MoreCriteriaFilterView
+ DetailsMoreCriteriaFilterView,
+ MoreCriteriaFilterView
};
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 a5057a7d740..3fc177c1a0a 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
@@ -23,7 +23,7 @@ import BaseFilters from './base-filters';
import Template from '../templates/range-filter.hbs';
import { translate } from '../../../helpers/l10n';
-var DetailsRangeFilterView = BaseFilters.DetailsFilterView.extend({
+const DetailsRangeFilterView = BaseFilters.DetailsFilterView.extend({
template: Template,
@@ -32,10 +32,10 @@ var DetailsRangeFilterView = BaseFilters.DetailsFilterView.extend({
},
- change: function () {
- var value = {},
- valueFrom = this.$('input').eq(0).val(),
- valueTo = this.$('input').eq(1).val();
+ change () {
+ const value = {};
+ const valueFrom = this.$('input').eq(0).val();
+ const valueTo = this.$('input').eq(1).val();
if (valueFrom.length > 0) {
value[this.model.get('propertyFrom')] = valueFrom;
@@ -49,37 +49,37 @@ var DetailsRangeFilterView = BaseFilters.DetailsFilterView.extend({
},
- populateInputs: 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];
+ populateInputs () {
+ const value = this.model.get('value');
+ const propertyFrom = this.model.get('propertyFrom');
+ const propertyTo = this.model.get('propertyTo');
+ const valueFrom = _.isObject(value) && value[propertyFrom];
+ const valueTo = _.isObject(value) && value[propertyTo];
this.$('input').eq(0).val(valueFrom || '');
this.$('input').eq(1).val(valueTo || '');
},
- onShow: function () {
+ onShow () {
this.$(':input:first').focus();
}
});
-var RangeFilterView = BaseFilters.BaseFilterView.extend({
+const RangeFilterView = BaseFilters.BaseFilterView.extend({
- initialize: function () {
+ initialize () {
BaseFilters.BaseFilterView.prototype.initialize.call(this, {
detailsView: DetailsRangeFilterView
});
},
- renderValue: function () {
+ renderValue () {
if (!this.isDefaultValue()) {
- var value = _.values(this.model.get('value'));
+ const value = _.values(this.model.get('value'));
return value.join(' — ');
} else {
return translate('any');
@@ -87,12 +87,12 @@ var RangeFilterView = BaseFilters.BaseFilterView.extend({
},
- 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];
+ renderInput () {
+ const value = this.model.get('value');
+ const propertyFrom = this.model.get('propertyFrom');
+ const propertyTo = this.model.get('propertyTo');
+ const valueFrom = _.isObject(value) && value[propertyFrom];
+ const valueTo = _.isObject(value) && value[propertyTo];
$('<input>')
.prop('name', propertyFrom)
@@ -110,21 +110,21 @@ var RangeFilterView = BaseFilters.BaseFilterView.extend({
},
- isDefaultValue: 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];
+ isDefaultValue () {
+ const value = this.model.get('value');
+ const propertyFrom = this.model.get('propertyFrom');
+ const propertyTo = this.model.get('propertyTo');
+ const valueFrom = _.isObject(value) && value[propertyFrom];
+ const valueTo = _.isObject(value) && value[propertyTo];
return !valueFrom && !valueTo;
},
- restoreFromQuery: function (q) {
- var paramFrom = _.findWhere(q, { key: this.model.get('propertyFrom') }),
- paramTo = _.findWhere(q, { key: this.model.get('propertyTo') }),
- value = {};
+ restoreFromQuery (q) {
+ const paramFrom = _.findWhere(q, { key: this.model.get('propertyFrom') });
+ const paramTo = _.findWhere(q, { key: this.model.get('propertyTo') });
+ const value = {};
if ((paramFrom && paramFrom.value) || (paramTo && paramTo.value)) {
if (paramFrom && paramFrom.value) {
@@ -136,7 +136,7 @@ var RangeFilterView = BaseFilters.BaseFilterView.extend({
}
this.model.set({
- value: value,
+ value,
enabled: true
});
@@ -145,14 +145,14 @@ var RangeFilterView = BaseFilters.BaseFilterView.extend({
},
- restore: function (value) {
+ restore (value) {
if (this.choices && this.selection && value.length > 0) {
- var that = this;
+ const that = this;
this.choices.add(this.selection.models);
this.selection.reset([]);
_.each(value, function (v) {
- var cModel = that.choices.findWhere({ id: v });
+ const cModel = that.choices.findWhere({ id: v });
if (cModel) {
that.selection.add(cModel);
@@ -163,19 +163,19 @@ var RangeFilterView = BaseFilters.BaseFilterView.extend({
this.detailsView.updateLists();
this.model.set({
- value: value,
+ value,
enabled: true
});
}
},
- formatValue: function () {
+ formatValue () {
return this.model.get('value');
},
- clear: function () {
+ clear () {
this.model.unset('value');
this.detailsView.render();
}
@@ -183,9 +183,9 @@ var RangeFilterView = BaseFilters.BaseFilterView.extend({
});
-var DateRangeFilterView = RangeFilterView.extend({
+const DateRangeFilterView = RangeFilterView.extend({
- render: function () {
+ render () {
RangeFilterView.prototype.render.apply(this, arguments);
this.detailsView.$('input')
.prop('placeholder', '1970-01-31')
@@ -200,12 +200,12 @@ var DateRangeFilterView = RangeFilterView.extend({
},
- renderValue: function () {
+ renderValue () {
if (!this.isDefaultValue()) {
- var value = _.values(this.model.get('value'));
+ const value = _.values(this.model.get('value'));
return value.join(' — ');
} else {
- return translate('anytime')
+ return translate('anytime');
}
}
@@ -217,8 +217,8 @@ var DateRangeFilterView = RangeFilterView.extend({
*/
export default {
- RangeFilterView: RangeFilterView,
- DateRangeFilterView: DateRangeFilterView
+ RangeFilterView,
+ DateRangeFilterView
};
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 fc9a781f789..5a1d11b11da 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
@@ -22,7 +22,7 @@ import _ from 'underscore';
import BaseFilters from './base-filters';
import Template from '../templates/string-filter.hbs';
-var DetailsStringFilterView = BaseFilters.DetailsFilterView.extend({
+const DetailsStringFilterView = BaseFilters.DetailsFilterView.extend({
template: Template,
@@ -31,18 +31,18 @@ var DetailsStringFilterView = BaseFilters.DetailsFilterView.extend({
},
- change: function (e) {
+ change (e) {
this.model.set('value', $(e.target).val());
},
- onShow: function () {
+ onShow () {
BaseFilters.DetailsFilterView.prototype.onShow.apply(this, arguments);
this.$(':input').focus();
},
- serializeData: function () {
+ serializeData () {
return _.extend({}, this.model.toJSON(), {
value: this.model.get('value') || ''
});
@@ -53,19 +53,19 @@ var DetailsStringFilterView = BaseFilters.DetailsFilterView.extend({
export default BaseFilters.BaseFilterView.extend({
- initialize: function () {
+ initialize () {
BaseFilters.BaseFilterView.prototype.initialize.call(this, {
detailsView: DetailsStringFilterView
});
},
- renderValue: function () {
+ renderValue () {
return this.isDefaultValue() ? '—' : this.model.get('value');
},
- renderInput: function () {
+ renderInput () {
$('<input>')
.prop('name', this.model.get('property'))
.prop('type', 'hidden')
@@ -75,20 +75,20 @@ export default BaseFilters.BaseFilterView.extend({
},
- isDefaultValue: function () {
+ isDefaultValue () {
return !this.model.get('value');
},
- restore: function (value) {
+ restore (value) {
this.model.set({
- value: value,
+ value,
enabled: true
});
},
- clear: function () {
+ clear () {
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 5fee42f84c5..0013e2ad525 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
@@ -26,12 +26,12 @@ export default Backbone.Model.extend({
enabled: false
},
- getValues: function () {
+ getValues () {
return this.get('values') || [];
},
- toggle: function () {
- var enabled = this.get('enabled');
+ toggle () {
+ const enabled = this.get('enabled');
this.set({ enabled: !enabled });
}
});
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 8a597147ad7..a0aa949a522 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
@@ -21,7 +21,7 @@ import _ from 'underscore';
import Backbone from 'backbone';
export default Backbone.Model.extend({
- defaults: function () {
+ defaults () {
return {
page: 1,
maxResultsReached: false,
@@ -30,13 +30,13 @@ export default Backbone.Model.extend({
};
},
- nextPage: function () {
- var page = this.get('page');
+ nextPage () {
+ const page = this.get('page');
this.set({ page: page + 1 });
},
- clearQuery: function (query) {
- var q = {};
+ clearQuery (query) {
+ const q = {};
Object.keys(query).forEach(function (key) {
if (query[key]) {
q[key] = query[key];
@@ -45,26 +45,26 @@ export default Backbone.Model.extend({
return q;
},
- _areQueriesEqual: function (a, b) {
- var equal = Object.keys(a).length === Object.keys(b).length;
+ _areQueriesEqual (a, b) {
+ let equal = Object.keys(a).length === Object.keys(b).length;
Object.keys(a).forEach(function (key) {
equal = equal && a[key] === b[key];
});
return equal;
},
- updateFilter: function (obj, options) {
- var oldQuery = this.get('query'),
- query = _.extend({}, oldQuery, obj),
- opts = _.defaults(options || {}, { force: false });
+ updateFilter (obj, options) {
+ const oldQuery = this.get('query');
+ let query = _.extend({}, oldQuery, obj);
+ const opts = _.defaults(options || {}, { force: false });
query = this.clearQuery(query);
if (opts.force || !this._areQueriesEqual(oldQuery, query)) {
this.setQuery(query);
}
},
- setQuery: function (query) {
- this.set({ query: query }, { silent: true });
+ setQuery (query) {
+ this.set({ query }, { silent: true });
this.set({ changed: true });
this.trigger('change:query');
}
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 7a8b40ffacf..1a60a737968 100644
--- a/server/sonar-web/src/main/js/components/navigator/router.js
+++ b/server/sonar-web/src/main/js/components/navigator/router.js
@@ -27,18 +27,18 @@ export default Backbone.Router.extend({
':query': 'index'
},
- initialize: function (options) {
+ initialize (options) {
this.options = options;
this.listenTo(this.options.app.state, 'change:query', this.updateRoute);
},
- index: function (query) {
+ index (query) {
query = this.options.app.controller.parseQuery(query);
this.options.app.state.setQuery(query);
},
- updateRoute: function () {
- var route = this.options.app.controller.getRoute();
+ updateRoute () {
+ const route = this.options.app.controller.getRoute();
this.navigate(route);
}
});
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 c6d2a94381b..775f94b50f1 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
@@ -22,14 +22,14 @@ import Marionette from 'backbone.marionette';
export default Marionette.ItemView.extend({
- collectionEvents: function () {
+ collectionEvents () {
return {
'all': 'shouldRender',
'limitReached': 'flashPagination'
};
},
- events: function () {
+ events () {
return {
'click .js-bulk-change': 'onBulkChangeClick',
'click .js-reload': 'reload',
@@ -38,58 +38,58 @@ export default Marionette.ItemView.extend({
};
},
- initialize: function (options) {
+ initialize (options) {
this.listenTo(options.app.state, 'change', this.render);
},
- onRender: function () {
+ onRender () {
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
},
- onBeforeRender: function () {
+ onBeforeRender () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onBulkChangeClick: function (e) {
+ onBulkChangeClick (e) {
e.preventDefault();
this.bulkChange();
},
- bulkChange: function () {
+ bulkChange () {
},
- shouldRender: function (event) {
+ shouldRender (event) {
if (event !== 'limitReached') {
this.render();
}
},
- reload: function () {
+ reload () {
this.options.app.controller.fetchList();
},
- selectNext: function () {
+ selectNext () {
this.options.app.controller.selectNext();
},
- selectPrev: function () {
+ selectPrev () {
this.options.app.controller.selectPrev();
},
- flashPagination: function () {
- var flashElement = this.$('.search-navigator-header-pagination');
+ flashPagination () {
+ const flashElement = this.$('.search-navigator-header-pagination');
flashElement.addClass('in');
setTimeout(function () {
flashElement.removeClass('in');
}, 2000);
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
state: this.options.app.state.toJSON()
});
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 b8c928bf9ae..d5d6b97c80f 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
@@ -21,20 +21,20 @@ import Marionette from 'backbone.marionette';
export default Marionette.ItemView.extend({
- initialize: function (options) {
+ initialize (options) {
this.listenTo(options.app.state, 'change:selectedIndex', this.select);
},
- onRender: function () {
+ onRender () {
this.select();
},
- select: function () {
- var selected = this.model.get('index') === this.options.app.state.get('selectedIndex');
+ select () {
+ const selected = this.model.get('index') === this.options.app.state.get('selectedIndex');
this.$el.toggleClass('selected', selected);
},
- selectCurrent: function () {
+ selectCurrent () {
this.options.app.state.set({ selectedIndex: this.model.get('index') });
}
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 5069792da09..cba0d33701a 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
@@ -30,7 +30,7 @@ export default Marionette.CompositeView.extend({
lastElementReached: '.js-last-element-reached'
},
- childViewOptions: function () {
+ childViewOptions () {
return {
app: this.options.app
};
@@ -40,41 +40,41 @@ export default Marionette.CompositeView.extend({
'reset': 'scrollToTop'
},
- initialize: function (options) {
+ initialize (options) {
this.loadMoreThrottled = _.throttle(this.loadMore, 1000, { trailing: false });
this.listenTo(options.app.state, 'change:maxResultsReached', this.toggleLoadMore);
this.listenTo(options.app.state, 'change:selectedIndex', this.scrollTo);
this.bindShortcuts();
},
- onDestroy: function () {
+ onDestroy () {
this.unbindScrollEvents();
this.unbindShortcuts();
},
- onRender: function () {
+ onRender () {
this.toggleLoadMore();
},
- toggleLoadMore: function () {
- var maxResultsReached = this.options.app.state.get('maxResultsReached');
+ toggleLoadMore () {
+ const maxResultsReached = this.options.app.state.get('maxResultsReached');
this.ui.loadMore.toggle(!maxResultsReached);
this.ui.lastElementReached.toggle(maxResultsReached);
},
- bindScrollEvents: function () {
- var that = this;
+ bindScrollEvents () {
+ const that = this;
$(window).on('scroll.workspace-list-view', function () {
that.onScroll();
});
},
- unbindScrollEvents: function () {
+ unbindScrollEvents () {
$(window).off('scroll.workspace-list-view');
},
- bindShortcuts: function () {
- var that = this;
+ bindShortcuts () {
+ const that = this;
key('up', 'list', function () {
that.options.app.controller.selectPrev();
return false;
@@ -86,14 +86,14 @@ export default Marionette.CompositeView.extend({
});
},
- unbindShortcuts: function () {
+ unbindShortcuts () {
key.unbind('up', 'list');
key.unbind('down', 'list');
},
- loadMore: function () {
+ loadMore () {
if (!this.options.app.state.get('maxResultsReached')) {
- var that = this;
+ const that = this;
this.unbindScrollEvents();
this.options.app.controller.fetchNextPage().done(function () {
that.bindScrollEvents();
@@ -101,27 +101,27 @@ export default Marionette.CompositeView.extend({
}
},
- onScroll: function () {
+ onScroll () {
if ($(window).scrollTop() + $(window).height() >= this.ui.loadMore.offset().top) {
this.loadMoreThrottled();
}
},
- scrollToTop: function () {
+ scrollToTop () {
this.$el.scrollParent().scrollTop(0);
},
- scrollTo: function () {
- var selected = this.collection.at(this.options.app.state.get('selectedIndex'));
+ scrollTo () {
+ const selected = this.collection.at(this.options.app.state.get('selectedIndex'));
if (selected == null) {
return;
}
- var selectedView = this.children.findByModel(selected),
- parentTopOffset = this.$el.offset().top,
- viewTop = selectedView.$el.offset().top - parentTopOffset,
- viewBottom = selectedView.$el.offset().top + selectedView.$el.outerHeight() + BOTTOM_OFFSET,
- windowTop = $(window).scrollTop(),
- windowBottom = windowTop + $(window).height();
+ const selectedView = this.children.findByModel(selected);
+ const parentTopOffset = this.$el.offset().top;
+ const viewTop = selectedView.$el.offset().top - parentTopOffset;
+ const viewBottom = selectedView.$el.offset().top + selectedView.$el.outerHeight() + BOTTOM_OFFSET;
+ const windowTop = $(window).scrollTop();
+ const windowBottom = windowTop + $(window).height();
if (viewTop < windowTop) {
$(window).scrollTop(viewTop);
}
diff --git a/server/sonar-web/src/main/js/components/select-list/controls.jsx b/server/sonar-web/src/main/js/components/select-list/controls.js
index 3165c9d5cca..92241acfb80 100644
--- a/server/sonar-web/src/main/js/components/select-list/controls.jsx
+++ b/server/sonar-web/src/main/js/components/select-list/controls.js
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
import _ from 'underscore';
import React from 'react';
import RadioToggle from '../shared/radio-toggle';
@@ -45,7 +64,12 @@ export default React.createClass({
disabled={selectionDisabled}/>
</div>
<div className="pull-right">
- <input onChange={this.search} ref="search" type="search" placeholder="Search" initialValue={this.props.query}/>
+ <input
+ onChange={this.search}
+ ref="search"
+ type="search"
+ placeholder="Search"
+ initialValue={this.props.query}/>
</div>
</div>
);
diff --git a/server/sonar-web/src/main/js/components/select-list/footer.js b/server/sonar-web/src/main/js/components/select-list/footer.js
new file mode 100644
index 00000000000..9b74e516342
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/select-list/footer.js
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+import React from 'react';
+
+export default React.createClass({
+ propTypes: {
+ count: React.PropTypes.number.isRequired,
+ total: React.PropTypes.number.isRequired,
+ loadMore: React.PropTypes.func.isRequired
+ },
+
+ loadMore(e) {
+ e.preventDefault();
+ this.props.loadMore();
+ },
+
+ renderLoadMoreLink() {
+ let hasMore = this.props.total > this.props.count;
+ if (!hasMore) {
+ return null;
+ }
+ return <a onClick={this.loadMore} className="spacer-left" href="#">show more</a>;
+ },
+
+ render() {
+ return (
+ <footer className="spacer-top note text-center">
+ {this.props.count}/{this.props.total} shown
+ {this.renderLoadMoreLink()}
+ </footer>
+ );
+ }
+});
diff --git a/server/sonar-web/src/main/js/components/select-list/footer.jsx b/server/sonar-web/src/main/js/components/select-list/footer.jsx
deleted file mode 100644
index b1efeb4086a..00000000000
--- a/server/sonar-web/src/main/js/components/select-list/footer.jsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import React from 'react';
-
-export default React.createClass({
- propTypes: {
- count: React.PropTypes.number.isRequired,
- total: React.PropTypes.number.isRequired,
- loadMore: React.PropTypes.func.isRequired
- },
-
- loadMore(e) {
- e.preventDefault();
- this.props.loadMore();
- },
-
- renderLoadMoreLink() {
- let hasMore = this.props.total > this.props.count;
- if (!hasMore) {
- return null;
- }
- return <a onClick={this.loadMore} className="spacer-left" href="#">show more</a>;
- },
-
- render() {
- return (
- <footer className="spacer-top note text-center">
- {this.props.count}/{this.props.total} shown
- {this.renderLoadMoreLink()}
- </footer>
- );
- }
-});
diff --git a/server/sonar-web/src/main/js/components/select-list/item.jsx b/server/sonar-web/src/main/js/components/select-list/item.js
index 5e7ed129de1..dcf2e53e119 100644
--- a/server/sonar-web/src/main/js/components/select-list/item.jsx
+++ b/server/sonar-web/src/main/js/components/select-list/item.js
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
import React from 'react';
import Checkbox from '../shared/checkbox';
diff --git a/server/sonar-web/src/main/js/components/select-list/list.js b/server/sonar-web/src/main/js/components/select-list/list.js
new file mode 100644
index 00000000000..7d606247194
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/select-list/list.js
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+import React from 'react';
+import Item from './item';
+
+export default React.createClass({
+ propTypes: {
+ items: React.PropTypes.array.isRequired,
+ renderItem: React.PropTypes.func.isRequired,
+ getItemKey: React.PropTypes.func.isRequired,
+ selectItem: React.PropTypes.func.isRequired,
+ deselectItem: React.PropTypes.func.isRequired
+ },
+
+ render() {
+ let renderedItems = this.props.items.map(item => {
+ let key = this.props.getItemKey(item);
+ return <Item key={key} {...this.props} item={item} />;
+ });
+ return (
+ <ul>{renderedItems}</ul>
+ );
+ }
+});
diff --git a/server/sonar-web/src/main/js/components/select-list/list.jsx b/server/sonar-web/src/main/js/components/select-list/list.jsx
deleted file mode 100644
index f8182f5c7aa..00000000000
--- a/server/sonar-web/src/main/js/components/select-list/list.jsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import React from 'react';
-import Item from './item';
-
-export default React.createClass({
- propTypes: {
- items: React.PropTypes.array.isRequired,
- renderItem: React.PropTypes.func.isRequired,
- getItemKey: React.PropTypes.func.isRequired,
- selectItem: React.PropTypes.func.isRequired,
- deselectItem: React.PropTypes.func.isRequired
- },
-
- render() {
- let renderedItems = this.props.items.map(item => {
- let key = this.props.getItemKey(item);
- return <Item key={key} {...this.props} item={item} />;
- });
- return (
- <ul>{renderedItems}</ul>
- );
- }
-});
diff --git a/server/sonar-web/src/main/js/components/select-list/main.jsx b/server/sonar-web/src/main/js/components/select-list/main.js
index bc043a8e0e9..e17fca31a0d 100644
--- a/server/sonar-web/src/main/js/components/select-list/main.jsx
+++ b/server/sonar-web/src/main/js/components/select-list/main.js
@@ -1,3 +1,22 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
import React from 'react';
import Controls from './controls';
import List from './list';
@@ -28,7 +47,7 @@ export default React.createClass({
page: 1
};
this.props.loadItems(options, (items, paging) => {
- this.setState({ items: items, total: paging.total, page: paging.pageIndex });
+ this.setState({ items, total: paging.total, page: paging.pageIndex });
});
},
@@ -57,7 +76,7 @@ export default React.createClass({
},
search(query) {
- this.setState({ query: query }, this.loadItems);
+ this.setState({ query }, this.loadItems);
},
render() {
diff --git a/server/sonar-web/src/main/js/components/shared/favorite.js b/server/sonar-web/src/main/js/components/shared/favorite.js
index c8c13d95973..b742e31b0eb 100644
--- a/server/sonar-web/src/main/js/components/shared/favorite.js
+++ b/server/sonar-web/src/main/js/components/shared/favorite.js
@@ -40,7 +40,7 @@ export default React.createClass({
},
addFavorite() {
- const url = `/api/favourites`;
+ const url = '/api/favourites';
const data = { key: this.props.component };
$.ajax({ type: 'POST', url, data }).done(() => this.setState({ favorite: true }));
},
diff --git a/server/sonar-web/src/main/js/components/shared/pin-icon.js b/server/sonar-web/src/main/js/components/shared/pin-icon.js
index 428a317ec14..49c57355992 100644
--- a/server/sonar-web/src/main/js/components/shared/pin-icon.js
+++ b/server/sonar-web/src/main/js/components/shared/pin-icon.js
@@ -17,6 +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.
*/
+/* eslint max-len: 0 */
import React from 'react';
const PinIcon = () => (
diff --git a/server/sonar-web/src/main/js/components/shared/qualifier-icon.js b/server/sonar-web/src/main/js/components/shared/qualifier-icon.js
index 3a258083c1d..3e6bbd643a5 100644
--- a/server/sonar-web/src/main/js/components/shared/qualifier-icon.js
+++ b/server/sonar-web/src/main/js/components/shared/qualifier-icon.js
@@ -24,7 +24,7 @@ export default React.createClass({
if (!this.props.qualifier) {
return null;
}
- var className = 'icon-qualifier-' + this.props.qualifier.toLowerCase();
+ const className = 'icon-qualifier-' + this.props.qualifier.toLowerCase();
return <i className={className}/>;
}
});
diff --git a/server/sonar-web/src/main/js/components/shared/radio-toggle.js b/server/sonar-web/src/main/js/components/shared/radio-toggle.js
index 7a894049054..7866cf71753 100644
--- a/server/sonar-web/src/main/js/components/shared/radio-toggle.js
+++ b/server/sonar-web/src/main/js/components/shared/radio-toggle.js
@@ -27,7 +27,7 @@ export default React.createClass({
onCheck: React.PropTypes.func.isRequired
},
- getDefaultProps: function () {
+ getDefaultProps () {
return { disabled: false, value: null };
},
diff --git a/server/sonar-web/src/main/js/components/shared/severity-icon.js b/server/sonar-web/src/main/js/components/shared/severity-icon.js
index e8227ef69db..08c08746709 100644
--- a/server/sonar-web/src/main/js/components/shared/severity-icon.js
+++ b/server/sonar-web/src/main/js/components/shared/severity-icon.js
@@ -24,7 +24,7 @@ export default React.createClass({
if (!this.props.severity) {
return null;
}
- var className = 'icon-severity-' + this.props.severity.toLowerCase();
+ const className = 'icon-severity-' + this.props.severity.toLowerCase();
return <i className={className}></i>;
}
});
diff --git a/server/sonar-web/src/main/js/components/shared/status-helper.js b/server/sonar-web/src/main/js/components/shared/status-helper.js
index 88e168009a5..c3766f1c808 100644
--- a/server/sonar-web/src/main/js/components/shared/status-helper.js
+++ b/server/sonar-web/src/main/js/components/shared/status-helper.js
@@ -22,11 +22,11 @@ import StatusIcon from './status-icon';
import { translate } from '../../helpers/l10n';
export default React.createClass({
- render: function () {
+ render () {
if (!this.props.status) {
return null;
}
- var resolution;
+ let resolution;
if (this.props.resolution) {
resolution = ' (' + translate('issue.resolution', this.props.resolution) + ')';
}
diff --git a/server/sonar-web/src/main/js/components/shared/status-icon.js b/server/sonar-web/src/main/js/components/shared/status-icon.js
index b3e5992d57c..2baec2cb5da 100644
--- a/server/sonar-web/src/main/js/components/shared/status-icon.js
+++ b/server/sonar-web/src/main/js/components/shared/status-icon.js
@@ -24,7 +24,7 @@ export default React.createClass({
if (!this.props.status) {
return null;
}
- var className = 'icon-status-' + this.props.status.toLowerCase();
+ const className = 'icon-status-' + this.props.status.toLowerCase();
return <i className={className}></i>;
}
});
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 353da24b89d..14b995d2127 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
@@ -24,12 +24,12 @@ import MoreActionsView from './more-actions';
import MeasuresOverlay from './measures-overlay';
import Template from './templates/source-viewer-header.hbs';
-var API_FAVORITE = '/api/favourites';
+const API_FAVORITE = '/api/favourites';
export default Marionette.ItemView.extend({
template: Template,
- events: function () {
+ events () {
return {
'click .js-favorite': 'toggleFavorite',
'click .js-actions': 'showMoreActions',
@@ -37,8 +37,8 @@ export default Marionette.ItemView.extend({
};
},
- toggleFavorite: function () {
- var that = this;
+ toggleFavorite () {
+ const that = this;
if (this.model.get('fav')) {
$.ajax({
url: API_FAVORITE + '/' + this.model.get('key'),
@@ -62,36 +62,36 @@ export default Marionette.ItemView.extend({
}
},
- showMoreActions: function (e) {
+ showMoreActions (e) {
e.stopPropagation();
$('body').click();
- var view = new MoreActionsView({ parent: this });
+ const view = new MoreActionsView({ parent: this });
view.render().$el.appendTo(this.$el);
},
- getPermalink: function () {
- var query = 'id=' + encodeURIComponent(this.model.get('key')),
- windowParams = 'resizable=1,scrollbars=1,status=1';
+ getPermalink () {
+ let query = 'id=' + encodeURIComponent(this.model.get('key'));
+ const windowParams = 'resizable=1,scrollbars=1,status=1';
if (this.options.viewer.highlightedLine) {
query = query + '&line=' + this.options.viewer.highlightedLine;
}
window.open('/component/index?' + query, this.model.get('name'), windowParams);
},
- showRawSources: function () {
- var url = '/api/sources/raw?key=' + encodeURIComponent(this.model.get('key')),
- windowParams = 'resizable=1,scrollbars=1,status=1';
+ showRawSources () {
+ const url = '/api/sources/raw?key=' + encodeURIComponent(this.model.get('key'));
+ const windowParams = 'resizable=1,scrollbars=1,status=1';
window.open(url, this.model.get('name'), windowParams);
},
- showMeasures: function () {
+ showMeasures () {
new MeasuresOverlay({
model: this.model,
large: true
}).render();
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
path: this.model.get('path') || this.model.get('longName')
});
diff --git a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js
index 056da7121ed..69e077cb622 100644
--- a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js
+++ b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js
@@ -52,8 +52,8 @@ function part (str, from, to, acc) {
* @returns {Array}
*/
function splitByTokens (code) {
- var container = document.createElement('div'),
- tokens = [];
+ const container = document.createElement('div');
+ const tokens = [];
container.innerHTML = code;
[].forEach.call(container.childNodes, function (node) {
if (node.nodeType === 1) {
@@ -78,18 +78,18 @@ function splitByTokens (code) {
*/
function highlightIssueLocations (tokens, issueLocations, className) {
issueLocations.forEach(function (location) {
- var nextTokens = [],
- acc = 0;
+ const nextTokens = [];
+ let acc = 0;
tokens.forEach(function (token) {
- var x = intersect(acc, acc + token.text.length, location.from, location.to);
- var p1 = part(token.text, acc, x.from, acc),
- p2 = part(token.text, x.from, x.to, acc),
- p3 = part(token.text, x.to, acc + token.text.length, acc);
+ const x = intersect(acc, acc + token.text.length, location.from, location.to);
+ const p1 = part(token.text, acc, x.from, acc);
+ const p2 = part(token.text, x.from, x.to, acc);
+ const p3 = part(token.text, x.to, acc + token.text.length, acc);
if (p1.length) {
nextTokens.push({ className: token.className, text: p1 });
}
if (p2.length) {
- var newClassName = token.className.indexOf(className) === -1 ?
+ const newClassName = token.className.indexOf(className) === -1 ?
[token.className, className].join(' ') : token.className;
nextTokens.push({ className: newClassName, text: p2 });
}
@@ -125,9 +125,9 @@ function generateHTML (tokens) {
* @returns {string}
*/
function doTheStuff (code, issueLocations, optionalClassName) {
- var _code = code || '&nbsp;';
- var _issueLocations = issueLocations || [];
- var _className = optionalClassName ? optionalClassName : 'source-line-code-issue';
+ const _code = code || '&nbsp;';
+ const _issueLocations = issueLocations || [];
+ const _className = optionalClassName ? optionalClassName : 'source-line-code-issue';
return generateHTML(highlightIssueLocations(splitByTokens(_code), _issueLocations, _className));
}
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 7447fbc6d9d..84533248323 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
@@ -35,7 +35,7 @@ import Template from './templates/source-viewer.hbs';
import IssueLocationTemplate from './templates/source-viewer-issue-location.hbs';
import { translateWithParameters } from '../../helpers/l10n';
-var HIGHLIGHTED_ROW_CLASS = 'source-line-highlighted';
+const HIGHLIGHTED_ROW_CLASS = 'source-line-highlighted';
export default Marionette.LayoutView.extend({
className: 'source-viewer',
@@ -56,7 +56,7 @@ export default Marionette.LayoutView.extend({
sourceAfterSpinner: '.js-component-viewer-source-after'
},
- events: function () {
+ events () {
return {
'click .sym': 'highlightUsages',
'click .source-line-scm': 'showSCMPopup',
@@ -72,7 +72,7 @@ export default Marionette.LayoutView.extend({
};
},
- initialize: function () {
+ initialize () {
if (this.model == null) {
this.model = new Source();
}
@@ -86,14 +86,14 @@ export default Marionette.LayoutView.extend({
this.listenTo(this, 'loaded', this.onLoaded);
},
- renderHeader: function () {
+ renderHeader () {
this.headerRegion.show(new HeaderView({
viewer: this,
model: this.model
}));
},
- onRender: function () {
+ onRender () {
this.renderHeader();
this.renderIssues();
if (this.model.has('filterLinesFunc')) {
@@ -102,7 +102,7 @@ export default Marionette.LayoutView.extend({
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
},
- onDestroy: function () {
+ onDestroy () {
this.issueViews.forEach(function (view) {
return view.destroy();
});
@@ -110,23 +110,23 @@ export default Marionette.LayoutView.extend({
this.clearTooltips();
},
- clearTooltips: function () {
+ clearTooltips () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- onLoaded: function () {
+ onLoaded () {
this.bindScrollEvents();
},
- open: function (id, options) {
- var that = this,
- opts = typeof options === 'object' ? options : {},
- finalize = function () {
- that.requestIssues().done(function () {
- that.render();
- that.trigger('loaded');
- });
- };
+ open (id, options) {
+ const that = this;
+ const opts = typeof options === 'object' ? options : {};
+ const finalize = function () {
+ that.requestIssues().done(function () {
+ that.render();
+ that.trigger('loaded');
+ });
+ };
_.extend(this.options, _.defaults(opts, { workspace: false }));
this.model
.clear()
@@ -147,16 +147,16 @@ export default Marionette.LayoutView.extend({
return this;
},
- requestComponent: function () {
- var that = this,
- url = '/api/components/app',
- data = { uuid: this.model.id };
+ requestComponent () {
+ const that = this;
+ const url = '/api/components/app';
+ const data = { uuid: this.model.id };
return $.ajax({
type: 'GET',
- url: url,
- data: data,
+ url,
+ data,
statusCode: {
- 404: function () {
+ 404 () {
that.model.set({ exist: false });
that.render();
that.trigger('loaded');
@@ -168,15 +168,15 @@ export default Marionette.LayoutView.extend({
});
},
- linesLimit: function () {
+ linesLimit () {
return {
from: 1,
to: this.LINES_LIMIT
};
},
- getUTCoverageStatus: function (row) {
- var status = null;
+ getUTCoverageStatus (row) {
+ let status = null;
if (row.utLineHits > 0) {
status = 'partially-covered';
}
@@ -189,8 +189,8 @@ export default Marionette.LayoutView.extend({
return status;
},
- getItCoverageStatus: function (row) {
- var status = null;
+ getItCoverageStatus (row) {
+ let status = null;
if (row.itLineHits > 0) {
status = 'partially-covered';
}
@@ -203,12 +203,12 @@ export default Marionette.LayoutView.extend({
return status;
},
- requestSource: function () {
- var that = this,
- url = '/api/sources/lines',
- options = _.extend({ uuid: this.model.id }, this.linesLimit());
+ requestSource () {
+ const that = this;
+ const url = '/api/sources/lines';
+ const options = _.extend({ uuid: this.model.id }, this.linesLimit());
return $.get(url, options).done(function (data) {
- var source = (data.sources || []).slice(0);
+ let source = (data.sources || []).slice(0);
if (source.length === 0 || (source.length > 0 && _.first(source).line === 1)) {
source.unshift({ line: 0 });
}
@@ -218,10 +218,10 @@ export default Marionette.LayoutView.extend({
itCoverageStatus: that.getItCoverageStatus(row)
});
});
- var firstLine = _.first(source).line,
- linesRequested = options.to - options.from + 1;
+ const firstLine = _.first(source).line;
+ const linesRequested = options.to - options.from + 1;
that.model.set({
- source: source,
+ source,
hasUTCoverage: that.model.hasUTCoverage(source),
hasITCoverage: that.model.hasITCoverage(source),
hasSourceBefore: firstLine > 1,
@@ -240,21 +240,21 @@ export default Marionette.LayoutView.extend({
});
},
- requestDuplications: function () {
- var that = this,
- url = '/api/duplications/show',
- options = { uuid: this.model.id };
+ requestDuplications () {
+ const that = this;
+ const url = '/api/duplications/show';
+ const options = { uuid: this.model.id };
return $.get(url, options, function (data) {
- var hasDuplications = (data != null) && (data.duplications != null),
- duplications = [];
+ const hasDuplications = (data != null) && (data.duplications != null);
+ let duplications = [];
if (hasDuplications) {
duplications = {};
data.duplications.forEach(function (d) {
d.blocks.forEach(function (b) {
if (b._ref === '1') {
- var lineFrom = b.from,
- lineTo = b.from + b.size - 1;
- for (var j = lineFrom; j <= lineTo; j++) {
+ const lineFrom = b.from;
+ const lineTo = b.from + b.size - 1;
+ for (let j = lineFrom; j <= lineTo; j++) {
duplications[j] = true;
}
}
@@ -277,44 +277,44 @@ export default Marionette.LayoutView.extend({
});
},
- requestIssues: function () {
- var that = this,
- options = {
- data: {
- componentUuids: this.model.id,
- f: 'component,componentId,project,subProject,rule,status,resolution,author,reporter,assignee,debt,' +
- 'line,message,severity,actionPlan,creationDate,updateDate,closeDate,tags,comments,attr,actions,' +
- 'transitions,actionPlanName',
- additionalFields: '_all',
- resolved: false,
- s: 'FILE_LINE',
- asc: true,
- ps: this.ISSUES_LIMIT
- }
- };
+ requestIssues () {
+ const that = this;
+ const options = {
+ data: {
+ componentUuids: this.model.id,
+ f: 'component,componentId,project,subProject,rule,status,resolution,author,reporter,assignee,debt,' +
+ 'line,message,severity,actionPlan,creationDate,updateDate,closeDate,tags,comments,attr,actions,' +
+ 'transitions,actionPlanName',
+ additionalFields: '_all',
+ resolved: false,
+ s: 'FILE_LINE',
+ asc: true,
+ ps: this.ISSUES_LIMIT
+ }
+ };
return this.issues.fetch(options).done(function () {
that.addIssuesPerLineMeta(that.issues);
});
},
- _sortBySeverity: function (issues) {
- var order = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'];
+ _sortBySeverity (issues) {
+ const order = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'];
return _.sortBy(issues, function (issue) {
return order.indexOf(issue.severity);
});
},
- addIssuesPerLineMeta: function (issues) {
- var that = this,
- lines = {};
+ addIssuesPerLineMeta (issues) {
+ const that = this;
+ const lines = {};
issues.forEach(function (issue) {
- var line = issue.get('line') || 0;
+ const line = issue.get('line') || 0;
if (!_.isArray(lines[line])) {
lines[line] = [];
}
lines[line].push(issue.toJSON());
});
- var issuesPerLine = _.pairs(lines).map(function (line) {
+ const issuesPerLine = _.pairs(lines).map(function (line) {
return {
line: +line[0],
issues: that._sortBySeverity(line[1])
@@ -324,11 +324,11 @@ export default Marionette.LayoutView.extend({
this.addIssueLocationsMeta(issues);
},
- addIssueLocationsMeta: function (issues) {
- var issueLocations = [];
+ addIssueLocationsMeta (issues) {
+ const issueLocations = [];
issues.forEach(function (issue) {
issue.getLinearLocations().forEach(function (location) {
- var record = _.findWhere(issueLocations, { line: location.line });
+ const record = _.findWhere(issueLocations, { line: location.line });
if (record) {
record.issueLocations.push({ from: location.from, to: location.to });
} else {
@@ -342,12 +342,12 @@ export default Marionette.LayoutView.extend({
this.model.addMeta(issueLocations);
},
- renderIssues: function () {
+ renderIssues () {
this.$('.issue-list').addClass('hidden');
},
- renderIssue: function (issue) {
- var issueView = new IssueView({
+ renderIssue (issue) {
+ const issueView = new IssueView({
el: '#issue-' + issue.get('key'),
model: issue
});
@@ -355,12 +355,12 @@ export default Marionette.LayoutView.extend({
issueView.render();
},
- addIssue: function (issue) {
- var line = issue.get('line') || 0,
- code = this.$('.source-line-code[data-line-number=' + line + ']'),
- issueBox = '<div class="issue" id="issue-' + issue.get('key') + '" data-key="' + issue.get('key') + '">';
+ addIssue (issue) {
+ const line = issue.get('line') || 0;
+ const code = this.$('.source-line-code[data-line-number=' + line + ']');
+ const issueBox = '<div class="issue" id="issue-' + issue.get('key') + '" data-key="' + issue.get('key') + '">';
code.addClass('has-issues');
- var issueList = code.find('.issue-list');
+ let issueList = code.find('.issue-list');
if (issueList.length === 0) {
code.append('<div class="issue-list"></div>');
issueList = code.find('.issue-list');
@@ -371,62 +371,62 @@ export default Marionette.LayoutView.extend({
this.renderIssue(issue);
},
- showIssuesForLine: function (line) {
+ showIssuesForLine (line) {
this.$('.source-line-code[data-line-number="' + line + '"]').find('.issue-list').removeClass('hidden');
- var issues = this.issues.filter(function (issue) {
+ const issues = this.issues.filter(function (issue) {
return (issue.get('line') === line) || (!issue.get('line') && !line);
});
issues.forEach(this.renderIssue, this);
},
- onIssuesSeverityChange: function () {
- var that = this;
+ onIssuesSeverityChange () {
+ const that = this;
this.addIssuesPerLineMeta(this.issues);
this.$('.source-line-with-issues').each(function () {
- var line = +$(this).data('line-number'),
- row = _.findWhere(that.model.get('source'), { line: line }),
- issue = _.first(row.issues);
+ const line = +$(this).data('line-number');
+ const row = _.findWhere(that.model.get('source'), { line });
+ const issue = _.first(row.issues);
$(this).html('<i class="icon-severity-' + issue.severity.toLowerCase() + '"></i>');
});
},
- highlightUsages: function (e) {
- var highlighted = $(e.currentTarget).is('.highlighted'),
- key = e.currentTarget.className.split(/\s+/)[0];
+ highlightUsages (e) {
+ const highlighted = $(e.currentTarget).is('.highlighted');
+ const key = e.currentTarget.className.split(/\s+/)[0];
this.$('.sym.highlighted').removeClass('highlighted');
if (!highlighted) {
this.$('.sym.' + key).addClass('highlighted');
}
},
- showSCMPopup: function (e) {
+ showSCMPopup (e) {
e.stopPropagation();
$('body').click();
- var line = +$(e.currentTarget).data('line-number'),
- row = _.findWhere(this.model.get('source'), { line: line }),
- popup = new SCMPopupView({
- triggerEl: $(e.currentTarget),
- model: new Backbone.Model(row)
- });
+ const line = +$(e.currentTarget).data('line-number');
+ const row = _.findWhere(this.model.get('source'), { line });
+ const popup = new SCMPopupView({
+ triggerEl: $(e.currentTarget),
+ model: new Backbone.Model(row)
+ });
popup.render();
},
- showCoveragePopup: function (e) {
+ showCoveragePopup (e) {
e.stopPropagation();
$('body').click();
this.clearTooltips();
- var line = $(e.currentTarget).data('line-number'),
- row = _.findWhere(this.model.get('source'), { line: line }),
- url = '/api/tests/list',
- options = {
- sourceFileId: this.model.id,
- sourceFileLineNumber: line,
- ps: 1000
- };
+ const line = $(e.currentTarget).data('line-number');
+ const row = _.findWhere(this.model.get('source'), { line });
+ const url = '/api/tests/list';
+ const options = {
+ sourceFileId: this.model.id,
+ sourceFileLineNumber: line,
+ ps: 1000
+ };
return $.get(url, options).done(function (data) {
- var popup = new CoveragePopupView({
+ const popup = new CoveragePopupView({
collection: new Backbone.Collection(data.tests),
- row: row,
+ row,
tests: $(e.currentTarget).data('tests'),
triggerEl: $(e.currentTarget)
});
@@ -434,9 +434,9 @@ export default Marionette.LayoutView.extend({
});
},
- showDuplications: function (e) {
- var that = this,
- lineNumber = $(e.currentTarget).closest('.source-line').data('line-number');
+ showDuplications (e) {
+ const that = this;
+ const lineNumber = $(e.currentTarget).closest('.source-line').data('line-number');
this.clearTooltips();
this.requestDuplications().done(function () {
that.render();
@@ -444,48 +444,48 @@ export default Marionette.LayoutView.extend({
// immediately show dropdown popup if there is only one duplicated block
if (that.model.get('duplications').length === 1) {
- var dupsBlock = that.$('.source-line[data-line-number=' + lineNumber + ']')
+ const dupsBlock = that.$('.source-line[data-line-number=' + lineNumber + ']')
.find('.source-line-duplications-extra');
dupsBlock.click();
}
});
},
- showDuplicationPopup: function (e) {
+ showDuplicationPopup (e) {
e.stopPropagation();
$('body').click();
this.clearTooltips();
- var index = $(e.currentTarget).data('index'),
- line = $(e.currentTarget).data('line-number'),
- blocks = this.model.get('duplications')[index - 1].blocks,
- inRemovedComponent = _.some(blocks, function (b) {
- return b._ref == null;
- }),
- foundOne = false;
+ const index = $(e.currentTarget).data('index');
+ const line = $(e.currentTarget).data('line-number');
+ let blocks = this.model.get('duplications')[index - 1].blocks;
+ const inRemovedComponent = _.some(blocks, function (b) {
+ return b._ref == null;
+ });
+ let foundOne = false;
blocks = _.filter(blocks, function (b) {
- var outOfBounds = b.from > line || b.from + b.size < line,
- currentFile = b._ref === '1',
- shouldDisplayForCurrentFile = outOfBounds || foundOne,
- shouldDisplay = !currentFile || (currentFile && shouldDisplayForCurrentFile),
- isOk = (b._ref != null) && shouldDisplay;
+ const outOfBounds = b.from > line || b.from + b.size < line;
+ const currentFile = b._ref === '1';
+ const shouldDisplayForCurrentFile = outOfBounds || foundOne;
+ const shouldDisplay = !currentFile || (currentFile && shouldDisplayForCurrentFile);
+ const isOk = (b._ref != null) && shouldDisplay;
if (b._ref === '1' && !outOfBounds) {
foundOne = true;
}
return isOk;
});
- var popup = new DuplicationPopupView({
+ const popup = new DuplicationPopupView({
triggerEl: $(e.currentTarget),
model: this.model,
- inRemovedComponent: inRemovedComponent,
+ inRemovedComponent,
collection: new Backbone.Collection(blocks)
});
popup.render();
},
- onLineIssuesClick: function (e) {
- var line = $(e.currentTarget).data('line-number'),
- issuesList = $(e.currentTarget).parent().find('.issue-list'),
- areIssuesRendered = issuesList.find('.issue-inner').length > 0;
+ onLineIssuesClick (e) {
+ const line = $(e.currentTarget).data('line-number');
+ const issuesList = $(e.currentTarget).parent().find('.issue-list');
+ const areIssuesRendered = issuesList.find('.issue-inner').length > 0;
if (issuesList.is('.hidden')) {
if (areIssuesRendered) {
issuesList.removeClass('hidden');
@@ -497,27 +497,27 @@ export default Marionette.LayoutView.extend({
}
},
- showLineActionsPopup: function (e) {
+ showLineActionsPopup (e) {
e.stopPropagation();
$('body').click();
- var that = this,
- line = $(e.currentTarget).data('line-number'),
- popup = new LineActionsPopupView({
- triggerEl: $(e.currentTarget),
- model: this.model,
- line: line,
- row: $(e.currentTarget).closest('.source-line')
- });
+ const that = this;
+ const line = $(e.currentTarget).data('line-number');
+ const popup = new LineActionsPopupView({
+ triggerEl: $(e.currentTarget),
+ model: this.model,
+ line,
+ row: $(e.currentTarget).closest('.source-line')
+ });
popup.on('onManualIssueAdded', function (issue) {
that.addIssue(issue);
});
popup.render();
},
- onLineNumberClick: function (e) {
- var row = $(e.currentTarget).closest('.source-line'),
- line = row.data('line-number'),
- highlighted = row.is('.' + HIGHLIGHTED_ROW_CLASS);
+ onLineNumberClick (e) {
+ const row = $(e.currentTarget).closest('.source-line');
+ const line = row.data('line-number');
+ const highlighted = row.is('.' + HIGHLIGHTED_ROW_CLASS);
if (!highlighted) {
this.highlightLine(line);
this.showLineActionsPopup(e);
@@ -526,34 +526,34 @@ export default Marionette.LayoutView.extend({
}
},
- removeHighlighting: function () {
+ removeHighlighting () {
this.highlightedLine = null;
this.$('.' + HIGHLIGHTED_ROW_CLASS).removeClass(HIGHLIGHTED_ROW_CLASS);
},
- highlightLine: function (line) {
- var row = this.$('.source-line[data-line-number=' + line + ']');
+ highlightLine (line) {
+ const row = this.$('.source-line[data-line-number=' + line + ']');
this.removeHighlighting();
this.highlightedLine = line;
row.addClass(HIGHLIGHTED_ROW_CLASS);
return this;
},
- bindScrollEvents: function () {
- var that = this;
+ bindScrollEvents () {
+ const that = this;
$(window).on('scroll.source-viewer', function () {
that.onScroll();
});
},
- unbindScrollEvents: function () {
+ unbindScrollEvents () {
$(window).off('scroll.source-viewer');
},
- onScroll: function () {
- var p = $(window);
- var pTopOffset = p.offset() != null ? p.offset().top : 0,
- pPosition = p.scrollTop() + pTopOffset;
+ onScroll () {
+ const p = $(window);
+ const pTopOffset = p.offset() != null ? p.offset().top : 0;
+ const pPosition = p.scrollTop() + pTopOffset;
if (this.model.get('hasSourceBefore') && (pPosition <= this.ui.sourceBeforeSpinner.offset().top)) {
this.loadSourceBeforeThrottled();
}
@@ -562,55 +562,55 @@ export default Marionette.LayoutView.extend({
}
},
- scrollToLine: function (line) {
- var row = this.$('.source-line[data-line-number=' + line + ']');
+ scrollToLine (line) {
+ const row = this.$('.source-line[data-line-number=' + line + ']');
if (row.length > 0) {
- var p = $(window);
- var pTopOffset = p.offset() != null ? p.offset().top : 0,
- pHeight = p.height(),
- goal = row.offset().top - pHeight / 3 - pTopOffset;
+ const p = $(window);
+ const pTopOffset = p.offset() != null ? p.offset().top : 0;
+ const pHeight = p.height();
+ const goal = row.offset().top - pHeight / 3 - pTopOffset;
p.scrollTop(goal);
}
return this;
},
- scrollToFirstLine: function (line) {
- var row = this.$('.source-line[data-line-number=' + line + ']');
+ scrollToFirstLine (line) {
+ const row = this.$('.source-line[data-line-number=' + line + ']');
if (row.length > 0) {
- var p = $(window);
- var pTopOffset = p.offset() != null ? p.offset().top : 0,
- goal = row.offset().top - pTopOffset;
+ const p = $(window);
+ const pTopOffset = p.offset() != null ? p.offset().top : 0;
+ const goal = row.offset().top - pTopOffset;
p.scrollTop(goal);
}
return this;
},
- scrollToLastLine: function (line) {
- var row = this.$('.source-line[data-line-number=' + line + ']');
+ scrollToLastLine (line) {
+ const row = this.$('.source-line[data-line-number=' + line + ']');
if (row.length > 0) {
- var p = $(window);
+ let p = $(window);
if (p.is(document)) {
p = $(window);
}
- var pTopOffset = p.offset() != null ? p.offset().top : 0,
- pHeight = p.height(),
- goal = row.offset().top - pTopOffset - pHeight + row.height();
+ const pTopOffset = p.offset() != null ? p.offset().top : 0;
+ const pHeight = p.height();
+ const goal = row.offset().top - pTopOffset - pHeight + row.height();
p.scrollTop(goal);
}
return this;
},
- loadSourceBefore: function () {
+ loadSourceBefore () {
this.unbindScrollEvents();
- var that = this,
- source = this.model.get('source'),
- firstLine = _.first(source).line,
- url = '/api/sources/lines',
- options = {
- uuid: this.model.id,
- from: firstLine - this.LINES_AROUND,
- to: firstLine - 1
- };
+ const that = this;
+ let source = this.model.get('source');
+ const firstLine = _.first(source).line;
+ const url = '/api/sources/lines';
+ const options = {
+ uuid: this.model.id,
+ from: firstLine - this.LINES_AROUND,
+ to: firstLine - 1
+ };
return $.get(url, options).done(function (data) {
source = (data.sources || []).concat(source);
if (source.length > that.TOTAL_LINES_LIMIT + 1) {
@@ -627,7 +627,7 @@ export default Marionette.LayoutView.extend({
});
});
that.model.set({
- source: source,
+ source,
hasUTCoverage: that.model.hasUTCoverage(source),
hasITCoverage: that.model.hasITCoverage(source),
hasSourceBefore: (data.sources.length === that.LINES_AROUND) && (_.first(source).line > 0)
@@ -646,17 +646,17 @@ export default Marionette.LayoutView.extend({
});
},
- loadSourceAfter: function () {
+ loadSourceAfter () {
this.unbindScrollEvents();
- var that = this,
- source = this.model.get('source'),
- lastLine = _.last(source).line,
- url = '/api/sources/lines',
- options = {
- uuid: this.model.id,
- from: lastLine + 1,
- to: lastLine + this.LINES_AROUND
- };
+ const that = this;
+ let source = this.model.get('source');
+ const lastLine = _.last(source).line;
+ const url = '/api/sources/lines';
+ const options = {
+ uuid: this.model.id,
+ from: lastLine + 1,
+ to: lastLine + this.LINES_AROUND
+ };
return $.get(url, options).done(function (data) {
source = source.concat(data.sources);
if (source.length > that.TOTAL_LINES_LIMIT + 1) {
@@ -670,7 +670,7 @@ export default Marionette.LayoutView.extend({
});
});
that.model.set({
- source: source,
+ source,
hasUTCoverage: that.model.hasUTCoverage(source),
hasITCoverage: that.model.hasITCoverage(source),
hasSourceAfter: data.sources.length === that.LINES_AROUND
@@ -697,28 +697,28 @@ export default Marionette.LayoutView.extend({
});
},
- filterLines: function (func) {
- var lines = this.model.get('source'),
- $lines = this.$('.source-line');
+ filterLines (func) {
+ const lines = this.model.get('source');
+ const $lines = this.$('.source-line');
this.model.set('filterLinesFunc', func);
lines.forEach(function (line, idx) {
- var $line = $($lines[idx]),
- filtered = func(line) && line.line > 0;
+ const $line = $($lines[idx]);
+ const filtered = func(line) && line.line > 0;
$line.toggleClass('source-line-shadowed', !filtered);
$line.toggleClass('source-line-filtered', filtered);
});
},
- filterLinesByDate: function (date, label) {
- var sinceDate = moment(date).toDate();
+ filterLinesByDate (date, label) {
+ const sinceDate = moment(date).toDate();
this.sinceLabel = label;
this.filterLines(function (line) {
- var scmDate = moment(line.scmDate).toDate();
+ const scmDate = moment(line.scmDate).toDate();
return scmDate >= sinceDate;
});
},
- showFilteredTooltip: function (e) {
+ showFilteredTooltip (e) {
$(e.currentTarget).tooltip({
container: 'body',
placement: 'right',
@@ -727,11 +727,11 @@ export default Marionette.LayoutView.extend({
}).tooltip('show');
},
- hideFilteredTooltip: function (e) {
+ hideFilteredTooltip (e) {
$(e.currentTarget).tooltip('destroy');
},
- toggleIssueLocations: function (issue) {
+ toggleIssueLocations (issue) {
if (this.locationsShowFor === issue) {
this.hideIssueLocations();
} else {
@@ -740,17 +740,17 @@ export default Marionette.LayoutView.extend({
}
},
- showIssueLocations: function (issue) {
+ showIssueLocations (issue) {
this.locationsShowFor = issue;
- var primaryLocation = {
- msg: issue.get('message'),
- textRange: issue.get('textRange')
- },
- _locations = [primaryLocation];
+ const primaryLocation = {
+ msg: issue.get('message'),
+ textRange: issue.get('textRange')
+ };
+ let _locations = [primaryLocation];
issue.get('flows').forEach(function (flow) {
- var flowLocationsCount = _.size(flow.locations);
- var flowLocations = flow.locations.map(function (location, index) {
- var _location = _.extend({}, location);
+ const flowLocationsCount = _.size(flow.locations);
+ const flowLocations = flow.locations.map(function (location, index) {
+ const _location = _.extend({}, location);
if (flowLocationsCount > 1) {
_.extend(_location, { index: flowLocationsCount - index });
}
@@ -761,16 +761,16 @@ export default Marionette.LayoutView.extend({
_locations.forEach(this.showIssueLocation, this);
},
- showIssueLocation: function (location, index) {
+ showIssueLocation (location, index) {
if (location && location.textRange) {
- var line = location.textRange.startLine,
- row = this.$('.source-line-code[data-line-number="' + line + '"]');
+ const line = location.textRange.startLine;
+ const row = this.$('.source-line-code[data-line-number="' + line + '"]');
if (index > 0 && _.size(location.msg)) {
// render location marker only for
// secondary locations and execution flows
// and only if message is not empty
- var renderedFlowLocation = this.renderIssueLocation(location);
+ const renderedFlowLocation = this.renderIssueLocation(location);
row.find('.source-line-issue-locations').prepend(renderedFlowLocation);
}
@@ -778,29 +778,29 @@ export default Marionette.LayoutView.extend({
}
},
- renderIssueLocation: function (location) {
+ renderIssueLocation (location) {
location.msg = location.msg ? location.msg : ' ';
return this.issueLocationTemplate(location);
},
- highlightIssueLocationInCode: function (location) {
- for (var line = location.textRange.startLine; line <= location.textRange.endLine; line++) {
- var row = this.$('.source-line-code[data-line-number="' + line + '"]');
+ highlightIssueLocationInCode (location) {
+ for (let line = location.textRange.startLine; line <= location.textRange.endLine; line++) {
+ const row = this.$('.source-line-code[data-line-number="' + line + '"]');
// get location for the current line
- var from = line === location.textRange.startLine ? location.textRange.startOffset : 0,
- to = line === location.textRange.endLine ? location.textRange.endOffset : 999999,
- _location = { from: from, to: to };
+ const from = line === location.textRange.startLine ? location.textRange.startOffset : 0;
+ const to = line === location.textRange.endLine ? location.textRange.endOffset : 999999;
+ const _location = { from, to };
// mark issue location in the source code
- var codeEl = row.find('.source-line-code-inner > pre'),
- code = codeEl.html(),
- newCode = highlightLocations(code, [_location], 'source-line-code-secondary-issue');
+ const codeEl = row.find('.source-line-code-inner > pre');
+ const code = codeEl.html();
+ const newCode = highlightLocations(code, [_location], 'source-line-code-secondary-issue');
codeEl.html(newCode);
}
},
- hideIssueLocations: function () {
+ hideIssueLocations () {
this.locationsShowFor = null;
this.$('.source-line-issue-locations').empty();
this.$('.source-line-code-secondary-issue').removeClass('source-line-code-secondary-issue');
diff --git a/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js b/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js
index 254b4d36b81..5cb86419f15 100644
--- a/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js
+++ b/server/sonar-web/src/main/js/components/source-viewer/measures-overlay.js
@@ -27,9 +27,9 @@ export default ModalView.extend({
template: Template,
testsOrder: ['ERROR', 'FAILURE', 'OK', 'SKIPPED'],
- initialize: function () {
- var that = this,
- requests = [this.requestMeasures(), this.requestIssues()];
+ initialize () {
+ const that = this;
+ const requests = [this.requestMeasures(), this.requestIssues()];
if (this.model.get('isUnitTest')) {
requests.push(this.requestTests());
}
@@ -39,7 +39,7 @@ export default ModalView.extend({
});
},
- events: function () {
+ events () {
return _.extend(ModalView.prototype.events.apply(this, arguments), {
'click .js-sort-tests-by-duration': 'sortTestsByDuration',
'click .js-sort-tests-by-name': 'sortTestsByName',
@@ -49,12 +49,12 @@ export default ModalView.extend({
});
},
- initPieChart: function () {
- var trans = function (left, top) {
+ initPieChart () {
+ const trans = function (left, top) {
return 'translate(' + left + ', ' + top + ')';
};
- var defaults = {
+ const defaults = {
size: 40,
thickness: 8,
color: '#1f77b4',
@@ -62,32 +62,32 @@ export default ModalView.extend({
};
this.$('.js-pie-chart').each(function () {
- var data = [
- $(this).data('value'),
- $(this).data('max') - $(this).data('value')
- ],
- options = _.defaults($(this).data(), defaults),
- radius = options.size / 2;
+ const data = [
+ $(this).data('value'),
+ $(this).data('max') - $(this).data('value')
+ ];
+ const options = _.defaults($(this).data(), defaults);
+ const radius = options.size / 2;
- var container = d3.select(this),
- svg = container.append('svg')
- .attr('width', options.size)
- .attr('height', options.size),
- plot = svg.append('g')
- .attr('transform', trans(radius, radius)),
- arc = d3.svg.arc()
- .innerRadius(radius - options.thickness)
- .outerRadius(radius),
- pie = d3.layout.pie()
- .sort(null)
- .value(function (d) {
- return d;
- }),
- colors = function (i) {
- return i === 0 ? options.color : options.baseColor;
- },
- sectors = plot.selectAll('path')
- .data(pie(data));
+ const container = d3.select(this);
+ const svg = container.append('svg')
+ .attr('width', options.size)
+ .attr('height', options.size);
+ const plot = svg.append('g')
+ .attr('transform', trans(radius, radius));
+ const arc = d3.svg.arc()
+ .innerRadius(radius - options.thickness)
+ .outerRadius(radius);
+ const pie = d3.layout.pie()
+ .sort(null)
+ .value(function (d) {
+ return d;
+ });
+ const colors = function (i) {
+ return i === 0 ? options.color : options.baseColor;
+ };
+ const sectors = plot.selectAll('path')
+ .data(pie(data));
sectors.enter()
.append('path')
@@ -98,17 +98,17 @@ export default ModalView.extend({
});
},
- onRender: function () {
+ onRender () {
ModalView.prototype.onRender.apply(this, arguments);
this.initPieChart();
this.$('.js-test-list').scrollTop(this.testsScroll);
},
- getMetrics: function () {
- var metrics = '',
- url = '/api/metrics/search';
+ getMetrics () {
+ let metrics = '';
+ const url = '/api/metrics/search';
$.ajax({
- url: url,
+ url,
async: false,
data: { ps: 9999 }
}).done(function (data) {
@@ -121,7 +121,7 @@ export default ModalView.extend({
},
- calcAdditionalMeasures: function (measures) {
+ calcAdditionalMeasures (measures) {
if (measures.lines_to_cover && measures.uncovered_lines) {
measures.covered_lines = measures.lines_to_cover - measures.uncovered_lines;
}
@@ -138,7 +138,7 @@ export default ModalView.extend({
},
- prepareMetrics: function (metrics) {
+ prepareMetrics (metrics) {
metrics = _.filter(metrics, function (metric) {
return metric.value != null;
});
@@ -154,68 +154,68 @@ export default ModalView.extend({
},
- requestMeasures: function () {
- var that = this,
- url = '/api/resources',
- metrics = this.getMetrics(),
- options = {
- resource: this.model.key(),
- metrics: _.pluck(metrics, 'key').join()
- };
+ requestMeasures () {
+ const that = this;
+ const url = '/api/resources';
+ const metrics = this.getMetrics();
+ const options = {
+ resource: this.model.key(),
+ metrics: _.pluck(metrics, 'key').join()
+ };
return $.get(url, options).done(function (data) {
- var measuresList = data[0].msr || [],
- measures = that.model.get('measures') || {};
+ const measuresList = data[0].msr || [];
+ let measures = that.model.get('measures') || {};
measuresList.forEach(function (m) {
- var metric = _.findWhere(metrics, { key: m.key });
+ const metric = _.findWhere(metrics, { key: m.key });
metric.value = m.frmt_val || m.data;
measures[m.key] = m.frmt_val || m.data;
measures[m.key + '_raw'] = m.val;
});
measures = that.calcAdditionalMeasures(measures);
that.model.set({
- measures: measures,
+ measures,
measuresToDisplay: that.prepareMetrics(metrics)
});
});
},
- requestIssues: function () {
- var that = this,
- url = '/api/issues/search',
- options = {
- componentUuids: this.model.id,
- resolved: false,
- ps: 1,
- facets: 'severities,tags'
- };
+ requestIssues () {
+ const that = this;
+ const url = '/api/issues/search';
+ const options = {
+ componentUuids: this.model.id,
+ resolved: false,
+ ps: 1,
+ facets: 'severities,tags'
+ };
return $.get(url, options).done(function (data) {
- var issuesFacets = {};
+ const issuesFacets = {};
data.facets.forEach(function (facet) {
issuesFacets[facet.property] = facet.values;
});
- var severityOrder = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
- maxCountBySeverity = _.max(issuesFacets.severities, function (s) {
- return s.count;
- }).count,
- maxCountByTag = _.max(issuesFacets.tags, function (s) {
- return s.count;
- }).count;
+ const severityOrder = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'];
+ const maxCountBySeverity = _.max(issuesFacets.severities, function (s) {
+ return s.count;
+ }).count;
+ const maxCountByTag = _.max(issuesFacets.tags, function (s) {
+ return s.count;
+ }).count;
issuesFacets.severities = _.sortBy(issuesFacets.severities, function (s) {
return severityOrder.indexOf(s.val);
});
that.model.set({
- issuesFacets: issuesFacets,
+ issuesFacets,
issuesCount: data.total,
- maxCountBySeverity: maxCountBySeverity,
- maxCountByTag: maxCountByTag
+ maxCountBySeverity,
+ maxCountByTag
});
});
},
- requestTests: function () {
- var that = this,
- url = '/api/tests/list',
- options = { testFileId: this.model.id };
+ requestTests () {
+ const that = this;
+ const url = '/api/tests/list';
+ const options = { testFileId: this.model.id };
return $.get(url, options).done(function (data) {
that.model.set({ tests: data.tests });
that.testSorting = 'status';
@@ -226,18 +226,18 @@ export default ModalView.extend({
});
},
- sortTests: function (condition) {
- var tests = this.model.get('tests');
+ sortTests (condition) {
+ let tests = this.model.get('tests');
if (_.isArray(tests)) {
tests = _.sortBy(tests, condition);
if (!this.testAsc) {
tests.reverse();
}
- this.model.set({ tests: tests });
+ this.model.set({ tests });
}
},
- sortTestsByDuration: function () {
+ sortTestsByDuration () {
if (this.testSorting === 'duration') {
this.testAsc = !this.testAsc;
}
@@ -246,7 +246,7 @@ export default ModalView.extend({
this.render();
},
- sortTestsByName: function () {
+ sortTestsByName () {
if (this.testSorting === 'name') {
this.testAsc = !this.testAsc;
}
@@ -255,8 +255,8 @@ export default ModalView.extend({
this.render();
},
- sortTestsByStatus: function () {
- var that = this;
+ sortTestsByStatus () {
+ const that = this;
if (this.testSorting === 'status') {
this.testAsc = !this.testAsc;
}
@@ -267,11 +267,11 @@ export default ModalView.extend({
this.render();
},
- showTest: function (e) {
- var that = this,
- testId = $(e.currentTarget).data('id'),
- url = '/api/tests/covered_files',
- options = { testId: testId };
+ showTest (e) {
+ const that = this;
+ const testId = $(e.currentTarget).data('id');
+ const url = '/api/tests/covered_files';
+ const options = { testId };
this.testsScroll = $(e.currentTarget).scrollParent().scrollTop();
return $.get(url, options).done(function (data) {
that.coveredFiles = data.files;
@@ -280,12 +280,12 @@ export default ModalView.extend({
});
},
- showAllMeasures: function () {
+ showAllMeasures () {
this.$('.js-all-measures').removeClass('hidden');
this.$('.js-show-all-measures').remove();
},
- serializeData: function () {
+ serializeData () {
return _.extend(ModalView.prototype.serializeData.apply(this, arguments), {
testSorting: this.testSorting,
selectedTest: this.selectedTest,
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 c5c35ff90f7..2eb43571996 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
@@ -34,35 +34,35 @@ export default Marionette.ItemView.extend({
'click .js-raw-source': 'showRawSource'
},
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
$('body').on('click.component-viewer-more-actions', function () {
$('body').off('click.component-viewer-more-actions');
that.destroy();
});
},
- showMeasures: function () {
+ showMeasures () {
this.options.parent.showMeasures();
},
- openNewWindow: function () {
+ openNewWindow () {
this.options.parent.getPermalink();
},
- openInWorkspace: function () {
- var uuid = this.options.parent.model.id;
- Workspace.openComponent({ uuid: uuid });
+ openInWorkspace () {
+ const uuid = this.options.parent.model.id;
+ Workspace.openComponent({ uuid });
},
- showRawSource: function () {
+ showRawSource () {
this.options.parent.showRawSources();
},
- serializeData: function () {
- var options = this.options.parent.options.viewer.options;
+ serializeData () {
+ const options = this.options.parent.options.viewer.options;
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- options: options
+ options
});
}
});
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 bb9e773a236..81d3a175c9a 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
@@ -30,39 +30,39 @@ export default Popup.extend({
'click a[data-id]': 'goToFile'
},
- onRender: function () {
+ onRender () {
Popup.prototype.onRender.apply(this, arguments);
this.$('.bubble-popup-container').isolatedScroll();
},
- goToFile: function (e) {
+ goToFile (e) {
e.stopPropagation();
- var id = $(e.currentTarget).data('id');
+ const id = $(e.currentTarget).data('id');
Workspace.openComponent({ uuid: id });
},
- serializeData: function () {
- var row = this.options.row || {},
- tests = _.groupBy(this.collection.toJSON(), 'fileId'),
- testFiles = _.map(tests, function (testSet) {
- var test = testSet[0];
- return {
- file: {
- id: test.fileId,
- longName: test.fileLongName
- },
- tests: testSet
- };
- });
+ serializeData () {
+ const row = this.options.row || {};
+ const tests = _.groupBy(this.collection.toJSON(), 'fileId');
+ const testFiles = _.map(tests, function (testSet) {
+ const test = testSet[0];
+ return {
+ file: {
+ id: test.fileId,
+ longName: test.fileLongName
+ },
+ tests: testSet
+ };
+ });
_.extend(row, {
lineHits: row[this.options.tests + 'LineHits'],
conditions: row[this.options.tests + 'Conditions'],
coveredConditions: row[this.options.tests + 'CoveredConditions']
});
return {
- testFiles: testFiles,
+ testFiles,
tests: this.options.tests,
- row: row
+ row
};
}
});
diff --git a/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js b/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js
index cca5f856195..43a3a29b475 100644
--- a/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js
+++ b/server/sonar-web/src/main/js/components/source-viewer/popups/duplication-popup.js
@@ -30,32 +30,32 @@ export default Popup.extend({
'click a[data-uuid]': 'goToFile'
},
- goToFile: function (e) {
+ goToFile (e) {
e.stopPropagation();
- var uuid = $(e.currentTarget).data('uuid'),
- line = $(e.currentTarget).data('line');
- Workspace.openComponent({ uuid: uuid, line: line });
+ const uuid = $(e.currentTarget).data('uuid');
+ const line = $(e.currentTarget).data('line');
+ Workspace.openComponent({ uuid, line });
},
- serializeData: function () {
- var that = this,
- files = this.model.get('duplicationFiles'),
- groupedBlocks = _.groupBy(this.collection.toJSON(), '_ref'),
- duplications = _.map(groupedBlocks, function (blocks, fileRef) {
- return {
- blocks: blocks,
- file: files[fileRef]
- };
- });
+ serializeData () {
+ const that = this;
+ const files = this.model.get('duplicationFiles');
+ const groupedBlocks = _.groupBy(this.collection.toJSON(), '_ref');
+ let duplications = _.map(groupedBlocks, function (blocks, fileRef) {
+ return {
+ blocks,
+ file: files[fileRef]
+ };
+ });
duplications = _.sortBy(duplications, function (d) {
- var a = d.file.projectName !== that.model.get('projectName'),
- b = d.file.subProjectName !== that.model.get('subProjectName'),
- c = d.file.key !== that.model.get('key');
+ const a = d.file.projectName !== that.model.get('projectName');
+ const b = d.file.subProjectName !== that.model.get('subProjectName');
+ const c = d.file.key !== that.model.get('key');
return '' + a + b + c;
});
return {
component: this.model.toJSON(),
- duplications: duplications,
+ duplications,
inRemovedComponent: this.options.inRemovedComponent
};
}
diff --git a/server/sonar-web/src/main/js/components/source-viewer/popups/line-actions-popup.js b/server/sonar-web/src/main/js/components/source-viewer/popups/line-actions-popup.js
index 6e7d84f75a8..cc519035255 100644
--- a/server/sonar-web/src/main/js/components/source-viewer/popups/line-actions-popup.js
+++ b/server/sonar-web/src/main/js/components/source-viewer/popups/line-actions-popup.js
@@ -29,23 +29,23 @@ export default Popup.extend({
'click .js-add-manual-issue': 'addManualIssue'
},
- getPermalink: function (e) {
+ getPermalink (e) {
e.preventDefault();
- var url = '/component/index?id=' +
- (encodeURIComponent(this.model.key())) + '&line=' + this.options.line,
- windowParams = 'resizable=1,scrollbars=1,status=1';
+ const url = '/component/index?id=' +
+ (encodeURIComponent(this.model.key())) + '&line=' + this.options.line;
+ const windowParams = 'resizable=1,scrollbars=1,status=1';
window.open(url, this.model.get('name'), windowParams);
},
- addManualIssue: function (e) {
+ addManualIssue (e) {
e.preventDefault();
- var that = this,
- line = this.options.line,
- component = this.model.key(),
- manualIssueView = new ManualIssueView({
- line: line,
- component: component
- });
+ const that = this;
+ const line = this.options.line;
+ const component = this.model.key();
+ const manualIssueView = new ManualIssueView({
+ line,
+ component
+ });
manualIssueView.render().$el.appendTo(this.options.row.find('.source-line-code'));
manualIssueView.on('add', function (issue) {
that.trigger('onManualIssueAdded', issue);
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 89793770972..36f8e7da93d 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
@@ -27,12 +27,12 @@ export default Popup.extend({
'click': 'onClick'
},
- onRender: function () {
+ onRender () {
Popup.prototype.onRender.apply(this, arguments);
this.$('.bubble-popup-container').isolatedScroll();
},
- onClick: function (e) {
+ onClick (e) {
e.stopPropagation();
}
});
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 bd9eadf08e4..47e11177646 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
@@ -23,7 +23,7 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
idAttribute: 'uuid',
- defaults: function () {
+ defaults () {
return {
exist: true,
@@ -37,14 +37,14 @@ export default Backbone.Model.extend({
};
},
- key: function () {
+ key () {
return this.get('key');
},
- addMeta: function (meta) {
- var source = this.get('source'),
- metaIdx = 0,
- metaLine = meta[metaIdx];
+ addMeta (meta) {
+ const source = this.get('source');
+ let metaIdx = 0;
+ let metaLine = meta[metaIdx];
source.forEach(function (line) {
while (metaLine != null && line.line > metaLine.line) {
metaLine = meta[++metaIdx];
@@ -54,20 +54,20 @@ export default Backbone.Model.extend({
metaLine = meta[++metaIdx];
}
});
- this.set({ source: source });
+ this.set({ source });
},
- addDuplications: function (duplications) {
- var source = this.get('source');
+ addDuplications (duplications) {
+ const source = this.get('source');
if (source != null) {
source.forEach(function (line) {
- var lineDuplications = [];
+ const lineDuplications = [];
duplications.forEach(function (d, i) {
- var duplicated = false;
+ let duplicated = false;
d.blocks.forEach(function (b) {
if (b._ref === '1') {
- var lineFrom = b.from,
- lineTo = b.from + b.size - 1;
+ const lineFrom = b.from;
+ const lineTo = b.from + b.size - 1;
if (line.line >= lineFrom && line.line <= lineTo) {
duplicated = true;
}
@@ -78,12 +78,12 @@ export default Backbone.Model.extend({
line.duplications = lineDuplications;
});
}
- this.set({ source: source });
+ this.set({ source });
},
- checkIfHasDuplications: function () {
- var hasDuplications = false,
- source = this.get('source');
+ checkIfHasDuplications () {
+ const source = this.get('source');
+ let hasDuplications = false;
if (source != null) {
source.forEach(function (line) {
if (line.duplicated) {
@@ -91,16 +91,16 @@ export default Backbone.Model.extend({
}
});
}
- this.set({ hasDuplications: hasDuplications });
+ this.set({ hasDuplications });
},
- hasUTCoverage: function (source) {
+ hasUTCoverage (source) {
return _.some(source, function (line) {
return line.utCoverageStatus != null;
});
},
- hasITCoverage: function (source) {
+ hasITCoverage (source) {
return _.some(source, function (line) {
return line.itCoverageStatus != null;
});
diff --git a/server/sonar-web/src/main/js/components/widgets/barchart.js b/server/sonar-web/src/main/js/components/widgets/barchart.js
index 06cb53ab1b9..0a71514502b 100644
--- a/server/sonar-web/src/main/js/components/widgets/barchart.js
+++ b/server/sonar-web/src/main/js/components/widgets/barchart.js
@@ -26,7 +26,7 @@ function trans (left, top) {
return 'translate(' + left + ', ' + top + ')';
}
-var defaults = function () {
+const defaults = function () {
return {
height: 140,
color: '#1f77b4',
@@ -49,31 +49,28 @@ var defaults = function () {
$.fn.barchart = function (data) {
$(this).each(function () {
- var options = _.defaults($(this).data(), defaults());
+ const options = _.defaults($(this).data(), defaults());
_.extend(options, {
width: options.width || $(this).width(),
endDate: moment(options.endDate)
});
- var container = d3.select(this),
- svg = container.append('svg')
- .attr('width', options.width + 2)
- .attr('height', options.height + 2)
- .classed('sonar-d3', true),
-
- plot = svg.append('g')
- .classed('plot', true),
-
- xScale = d3.scale.ordinal()
- .domain(data.map(function (d, i) {
- return i;
- })),
-
- yScaleMax = d3.max(data, function (d) {
- return d.count;
- }),
- yScale = d3.scale.linear()
- .domain([0, yScaleMax]);
+ const container = d3.select(this);
+ const svg = container.append('svg')
+ .attr('width', options.width + 2)
+ .attr('height', options.height + 2)
+ .classed('sonar-d3', true);
+ const plot = svg.append('g')
+ .classed('plot', true);
+ const xScale = d3.scale.ordinal()
+ .domain(data.map(function (d, i) {
+ return i;
+ }));
+ const yScaleMax = d3.max(data, function (d) {
+ return d.count;
+ });
+ const yScale = d3.scale.linear()
+ .domain([0, yScaleMax]);
_.extend(options, {
availableWidth: options.width - options.marginLeft - options.marginRight,
@@ -84,11 +81,11 @@ $.fn.barchart = function (data) {
xScale.rangeRoundBands([0, options.availableWidth], 0.05, 0);
yScale.range([3, options.availableHeight]);
- var barWidth = xScale.rangeBand(),
- bars = plot.selectAll('g').data(data);
+ const barWidth = xScale.rangeBand();
+ const bars = plot.selectAll('g').data(data);
if (barWidth > 0) {
- var barsEnter = bars.enter()
+ const barsEnter = bars.enter()
.append('g')
.attr('transform', function (d, i) {
return trans(xScale(i), Math.ceil(options.availableHeight - yScale(d.count)));
@@ -105,34 +102,34 @@ $.fn.barchart = function (data) {
return moment(d.val).format('YYYY-MM-DD');
})
.attr('data-period-end', function (d, i) {
- var beginning = moment(d.val),
- ending = i < data.length - 1 ? moment(data[i + 1].val).subtract(1, 'days') : options.endDate,
- isSameDay = ending.diff(beginning, 'days') <= 1;
+ const beginning = moment(d.val);
+ const ending = i < data.length - 1 ? moment(data[i + 1].val).subtract(1, 'days') : options.endDate;
+ const isSameDay = ending.diff(beginning, 'days') <= 1;
if (isSameDay) {
ending.add(1, 'days');
}
return ending.format('YYYY-MM-DD');
})
.attr('title', function (d, i) {
- var beginning = moment(d.val),
- ending = i < data.length - 1 ? moment(data[i + 1].val).subtract(1, 'days') : options.endDate,
- isSameDay = ending.diff(beginning, 'days') <= 1;
+ const beginning = moment(d.val);
+ const ending = i < data.length - 1 ? moment(data[i + 1].val).subtract(1, 'days') : options.endDate;
+ const isSameDay = ending.diff(beginning, 'days') <= 1;
return d.text + '<br>' + beginning.format('LL') + (isSameDay ? '' : (' – ' + ending.format('LL')));
})
.attr('data-placement', 'bottom')
.attr('data-toggle', 'tooltip');
- var maxValue = d3.max(data, function (d) {
- return d.count;
- }),
- isValueShown = false;
+ const maxValue = d3.max(data, function (d) {
+ return d.count;
+ });
+ let isValueShown = false;
barsEnter.append('text')
.classed('subtitle', true)
.attr('transform', trans(barWidth / 2, -4))
.style('text-anchor', 'middle')
.text(function (d) {
- var text = !isValueShown && d.count === maxValue ? d.text : '';
+ const text = !isValueShown && d.count === maxValue ? d.text : '';
isValueShown = d.count === maxValue;
return text;
});
diff --git a/server/sonar-web/src/main/js/components/workspace/main.js b/server/sonar-web/src/main/js/components/workspace/main.js
index 462a11bdee6..b3f94c3e6d1 100644
--- a/server/sonar-web/src/main/js/components/workspace/main.js
+++ b/server/sonar-web/src/main/js/components/workspace/main.js
@@ -26,18 +26,17 @@ import ViewerView from './views/viewer-view';
import RuleView from './views/rule-view';
-var instance = null,
-
- Workspace = function () {
- if (instance != null) {
- throw new Error('Cannot instantiate more than one Workspace, use Workspace.getInstance()');
- }
- this.initialize();
- };
+let instance = null;
+const Workspace = function () {
+ if (instance != null) {
+ throw new Error('Cannot instantiate more than one Workspace, use Workspace.getInstance()');
+ }
+ this.initialize();
+};
Workspace.prototype = {
- initialize: function () {
- var that = this;
+ initialize () {
+ const that = this;
this.items = new Items();
this.items.load();
@@ -52,22 +51,22 @@ Workspace.prototype = {
});
},
- save: function () {
+ save () {
this.items.save();
},
- addComponent: function (model) {
- var m = this.items.add2(model);
+ addComponent (model) {
+ const m = this.items.add2(model);
this.save();
return m;
},
- open: function (options) {
- var model = typeof options.toJSON === 'function' ? options : new Item(options);
+ open (options) {
+ const model = typeof options.toJSON === 'function' ? options : new Item(options);
if (!model.isValid()) {
throw new Error(model.validationError);
}
- var m = this.addComponent(model);
+ const m = this.addComponent(model);
if (m.isComponent()) {
this.showComponentViewer(m);
}
@@ -76,23 +75,23 @@ Workspace.prototype = {
}
},
- openComponent: function (options) {
+ openComponent (options) {
return this.open(_.extend(options, { type: 'component' }));
},
- openRule: function (options) {
+ openRule (options) {
return this.open(_.extend(options, { type: 'rule' }));
},
- showViewer: function (Viewer, model) {
- var that = this;
+ showViewer (Viewer, model) {
+ const that = this;
if (this.viewerView != null) {
this.viewerView.model.trigger('hideViewer');
this.viewerView.destroy();
}
$('html').addClass('with-workspace');
model.trigger('showViewer');
- this.viewerView = new Viewer({ model: model });
+ this.viewerView = new Viewer({ model });
this.viewerView
.on('viewerMinimize', function () {
model.trigger('hideViewer');
@@ -105,32 +104,31 @@ Workspace.prototype = {
this.viewerView.render().$el.appendTo(document.body);
},
- showComponentViewer: function (model) {
+ showComponentViewer (model) {
this.showViewer(ViewerView, model);
},
- closeComponentViewer: function () {
+ closeComponentViewer () {
if (this.viewerView != null) {
this.viewerView.destroy();
$('.with-workspace').removeClass('with-workspace');
}
},
- showRule: function (model) {
- var that = this;
- this.fetchRule(model)
- .done(function () {
- model.set({ exist: true });
- that.showViewer(RuleView, model);
- }).fail(function () {
- model.set({ exist: false });
- that.showViewer(RuleView, model);
- });
+ showRule (model) {
+ const that = this;
+ this.fetchRule(model).done(function () {
+ model.set({ exist: true });
+ that.showViewer(RuleView, model);
+ }).fail(function () {
+ model.set({ exist: false });
+ that.showViewer(RuleView, model);
+ });
},
- fetchRule: function (model) {
- var url = '/api/rules/show',
- options = { key: model.get('key') };
+ fetchRule (model) {
+ const url = '/api/rules/show';
+ const options = { key: model.get('key') };
return $.get(url, options).done(function (r) {
model.set(r.rule);
});
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 694c1e05056..10c26d02b9f 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
@@ -21,7 +21,7 @@ import Backbone from 'backbone';
export default Backbone.Model.extend({
- validate: function () {
+ validate () {
if (!this.has('type')) {
return 'type is missing';
}
@@ -33,15 +33,15 @@ export default Backbone.Model.extend({
}
},
- isComponent: function () {
+ isComponent () {
return this.get('type') === 'component';
},
- isRule: function () {
+ isRule () {
return this.get('type') === 'rule';
},
- destroy: function (options) {
+ destroy (options) {
this.stopListening();
this.trigger('destroy', this, this.collection, options);
}
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 f923a7f77aa..4ba5ea6e48e 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
@@ -20,25 +20,25 @@
import Backbone from 'backbone';
import Item from './item';
-var STORAGE_KEY = 'sonarqube-workspace';
+const STORAGE_KEY = 'sonarqube-workspace';
export default Backbone.Collection.extend({
model: Item,
- initialize: function () {
+ initialize () {
this.on('remove', this.save);
},
- save: function () {
- var dump = JSON.stringify(this.toJSON());
+ save () {
+ const dump = JSON.stringify(this.toJSON());
window.localStorage.setItem(STORAGE_KEY, dump);
},
- load: function () {
- var dump = window.localStorage.getItem(STORAGE_KEY);
+ load () {
+ const dump = window.localStorage.getItem(STORAGE_KEY);
if (dump != null) {
try {
- var parsed = JSON.parse(dump);
+ const parsed = JSON.parse(dump);
this.reset(parsed);
} catch (err) {
// fail silently
@@ -46,14 +46,14 @@ export default Backbone.Collection.extend({
}
},
- has: function (model) {
- var forComponent = model.isComponent() && this.findWhere({ uuid: model.get('uuid') }) != null,
- forRule = model.isRule() && this.findWhere({ key: model.get('key') }) != null;
+ has (model) {
+ const forComponent = model.isComponent() && this.findWhere({ uuid: model.get('uuid') }) != null;
+ const forRule = model.isRule() && this.findWhere({ key: model.get('key') }) != null;
return forComponent || forRule;
},
- add2: function (model) {
- var tryModel = model.isComponent() ?
+ add2 (model) {
+ const tryModel = model.isComponent() ?
this.findWhere({ uuid: model.get('uuid') }) :
this.findWhere({ key: model.get('key') });
return tryModel != null ? tryModel : this.add(model);
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 36b28e10c47..2135c13e036 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
@@ -32,21 +32,21 @@ export default Marionette.LayoutView.extend({
viewerRegion: '.workspace-viewer-container'
},
- onRender: function () {
+ onRender () {
this.showHeader();
this.$('.workspace-viewer-container').isolatedScroll();
},
- onViewerMinimize: function () {
+ onViewerMinimize () {
this.trigger('viewerMinimize');
},
- onViewerClose: function () {
+ onViewerClose () {
this.trigger('viewerClose', this.model);
},
- showHeader: function () {
- var headerView = new HeaderView({ model: this.model });
+ showHeader () {
+ const headerView = new HeaderView({ model: this.model });
this.listenTo(headerView, 'viewerMinimize', this.onViewerMinimize);
this.listenTo(headerView, 'viewerClose', this.onViewerClose);
this.headerRegion.show(headerView);
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 78478ff7a22..803b8bb5c0f 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
@@ -36,22 +36,22 @@ export default Marionette.ItemView.extend({
'click .js-close': 'onCloseClick'
},
- onClick: function (e) {
+ onClick (e) {
e.preventDefault();
this.options.collectionView.trigger('click', this.model);
},
- onCloseClick: function (e) {
+ onCloseClick (e) {
e.preventDefault();
e.stopPropagation();
this.model.destroy();
},
- onViewerShow: function () {
+ onViewerShow () {
this.$el.addClass('hidden');
},
- onViewerHide: function () {
+ onViewerHide () {
this.$el.removeClass('hidden');
}
});
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 578cb5d932f..6a755bef25a 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
@@ -27,7 +27,7 @@ export default Marionette.CompositeView.extend({
childViewContainer: '.workspace-nav-list',
childView: ItemView,
- childViewOptions: function () {
+ childViewOptions () {
return { collectionView: this };
}
});
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 26033d042cc..749784c54df 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
@@ -25,16 +25,16 @@ import Template from '../templates/workspace-rule.hbs';
export default BaseView.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseView.prototype.onRender.apply(this, arguments);
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.LayoutView.prototype.serializeData.apply(this, arguments), {
allTags: _.union(this.model.get('sysTags'), this.model.get('tags'))
});
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 969315b5b1a..dbd02a8bac9 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
@@ -38,72 +38,72 @@ export default Marionette.ItemView.extend({
'click .js-close': 'onCloseClick'
},
- onRender: function () {
+ onRender () {
this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
this.$('.js-normal-size').addClass('hidden');
},
- onDestroy: function () {
+ onDestroy () {
this.$('[data-toggle="tooltip"]').tooltip('destroy');
$('.tooltip').remove();
},
- onResizeClick: function (e) {
+ onResizeClick (e) {
e.preventDefault();
this.startResizing(e);
},
- onMinimizeClick: function (e) {
+ onMinimizeClick (e) {
e.preventDefault();
this.trigger('viewerMinimize');
},
- onFullScreenClick: function (e) {
+ onFullScreenClick (e) {
e.preventDefault();
this.toFullScreen();
},
- onNormalSizeClick: function (e) {
+ onNormalSizeClick (e) {
e.preventDefault();
this.toNormalSize();
},
- onCloseClick: function (e) {
+ onCloseClick (e) {
e.preventDefault();
this.trigger('viewerClose');
},
- startResizing: function (e) {
+ startResizing (e) {
this.initialResizePosition = e.clientY;
this.initialResizeHeight = $('.workspace-viewer-container').height();
- var processResizing = _.bind(this.processResizing, this),
- stopResizing = _.bind(this.stopResizing, this);
+ const processResizing = _.bind(this.processResizing, this);
+ const stopResizing = _.bind(this.stopResizing, this);
$('body')
.on('mousemove.workspace', processResizing)
.on('mouseup.workspace', stopResizing);
},
- processResizing: function (e) {
- var currentResizePosition = e.clientY,
- resizeDelta = this.initialResizePosition - currentResizePosition,
- height = this.initialResizeHeight + resizeDelta;
+ processResizing (e) {
+ const currentResizePosition = e.clientY;
+ const resizeDelta = this.initialResizePosition - currentResizePosition;
+ const height = this.initialResizeHeight + resizeDelta;
$('.workspace-viewer-container').height(height);
},
- stopResizing: function () {
+ stopResizing () {
$('body')
.off('mousemove.workspace')
.off('mouseup.workspace');
},
- toFullScreen: function () {
+ toFullScreen () {
this.$('.js-normal-size').removeClass('hidden');
this.$('.js-full-screen').addClass('hidden');
this.initialResizeHeight = $('.workspace-viewer-container').height();
$('.workspace-viewer-container').height('9999px');
},
- toNormalSize: function () {
+ toNormalSize () {
this.$('.js-normal-size').addClass('hidden');
this.$('.js-full-screen').removeClass('hidden');
$('.workspace-viewer-container').height(this.initialResizeHeight);
diff --git a/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js b/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js
index 97417d4ff2c..5e1146162bd 100644
--- a/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js
+++ b/server/sonar-web/src/main/js/components/workspace/views/viewer-view.js
@@ -24,15 +24,15 @@ import Template from '../templates/workspace-viewer.hbs';
export default BaseView.extend({
template: Template,
- onRender: function () {
+ onRender () {
BaseView.prototype.onRender.apply(this, arguments);
this.showViewer();
},
- showViewer: function () {
- var that = this,
- viewer = new SourceViewer(),
- options = this.model.toJSON();
+ showViewer () {
+ const that = this;
+ const viewer = new SourceViewer();
+ const options = this.model.toJSON();
viewer.open(this.model.get('uuid'), { workspace: true });
viewer.on('loaded', function () {
that.model.set({
diff --git a/server/sonar-web/src/main/js/helpers/csv.js b/server/sonar-web/src/main/js/helpers/csv.js
index ff1d208e635..d64e00f7c94 100644
--- a/server/sonar-web/src/main/js/helpers/csv.js
+++ b/server/sonar-web/src/main/js/helpers/csv.js
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
export function csvEscape (value) {
- var escaped = value.replace(/"/g, '\\"');
+ const escaped = value.replace(/"/g, '\\"');
return '"' + escaped + '"';
}
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/all.js b/server/sonar-web/src/main/js/helpers/handlebars/all.js
index ac5e4191da9..5318772ef49 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/all.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/all.js
@@ -18,10 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1),
- options = arguments[arguments.length - 1],
- all = args.reduce(function (prev, current) {
- return prev && current;
- }, true);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
+ const options = arguments[arguments.length - 1];
+ const all = args.reduce(function (prev, current) {
+ return prev && current;
+ }, true);
return all ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/any.js b/server/sonar-web/src/main/js/helpers/handlebars/any.js
index d0ee0a714b1..1d81a679d85 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/any.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/any.js
@@ -18,10 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1),
- options = arguments[arguments.length - 1],
- any = args.reduce(function (prev, current) {
- return prev || current;
- }, false);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
+ const options = arguments[arguments.length - 1];
+ const any = args.reduce(function (prev, current) {
+ return prev || current;
+ }, false);
return any ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js b/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js
index 2908465e30f..d6a00952ddf 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js
@@ -22,10 +22,10 @@ import Handlebars from 'handlebars/runtime';
module.exports = function (email, size) {
// double the size for high pixel density screens
- var emailHash = md5.md5((email || '').trim()),
- url = ('' + window.SS.lf.gravatarServerUrl)
- .replace('{EMAIL_MD5}', emailHash)
- .replace('{SIZE}', size * 2);
+ const emailHash = md5.md5((email || '').trim());
+ const url = ('' + window.SS.lf.gravatarServerUrl)
+ .replace('{EMAIL_MD5}', emailHash)
+ .replace('{SIZE}', size * 2);
return new Handlebars.default.SafeString(
'<img class="rounded" src="' + url + '" width="' + size + '" height="' + size + '" alt="' + email + '">'
);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/changelog.js b/server/sonar-web/src/main/js/helpers/handlebars/changelog.js
index 6d579aa03af..b6bc94694da 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/changelog.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/changelog.js
@@ -20,7 +20,7 @@
import { translate, translateWithParameters } from '../../helpers/l10n';
module.exports = function (diff) {
- var message = '';
+ let message = '';
if (diff.newValue != null) {
message = translateWithParameters('issue.changelog.changed_to',
translate('issue.changelog.field', diff.key), diff.newValue);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js b/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js
index 5068d9a391c..6dbd1e36d05 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js
@@ -18,21 +18,21 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (componentKey, dashboardKey) {
- var params = [
+ const params = [
{ key: 'id', value: componentKey },
{ key: 'did', value: dashboardKey }
];
- var matchPeriod = window.location.search.match(/period=(\d+)/);
+ const matchPeriod = window.location.search.match(/period=(\d+)/);
if (matchPeriod) {
// If we have a match for period, check that it is not project-specific
- var period = parseInt(matchPeriod[1], 10);
+ const period = parseInt(matchPeriod[1], 10);
if (period <= 3) {
params.push({ key: 'period', value: period });
}
}
- var query = params.map(function (p) {
+ const query = params.map(function (p) {
return p.key + '=' + encodeURIComponent(p.value);
}).join('&');
return '/dashboard/index?' + query;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js b/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js
index fe2ae4e7ec2..bfee7ad7e88 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js
@@ -20,8 +20,8 @@
import { translate } from '../../helpers/l10n';
module.exports = function (dashboardName) {
- var l10nKey = 'dashboard.' + dashboardName + '.name';
- var l10nLabel = translate(l10nKey);
+ const l10nKey = 'dashboard.' + dashboardName + '.name';
+ const l10nLabel = translate(l10nKey);
if (l10nLabel !== l10nKey) {
return l10nLabel;
} else {
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js b/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js
index 2cc7ffe22f4..618f65b651c 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (componentKey, componentQualifier) {
- var url = '/dashboard/index?id=' + encodeURIComponent(componentKey);
+ let url = '/dashboard/index?id=' + encodeURIComponent(componentKey);
if (componentQualifier === 'FIL' || componentQualifier === 'CLA') {
url += '&metric=sqale_index';
}
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/default.js b/server/sonar-web/src/main/js/helpers/handlebars/default.js
index cca87547d20..9e16c7e76ae 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/default.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/default.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
return args.reduce(function (prev, current) {
return prev != null ? prev : current;
}, null);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js b/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js
index ff0205e3bab..0f9c2bc045a 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js
@@ -21,7 +21,7 @@ import _ from 'underscore';
module.exports = function (path) {
if (typeof path === 'string') {
- var tokens = path.split('/');
+ const tokens = path.split('/');
return tokens.length > 1 ? _.initial(tokens).join('/') + '/' : '';
} else {
return null;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js b/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js
index 513167dc354..9c415b1dfca 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js
@@ -20,10 +20,10 @@
import _ from 'underscore';
module.exports = function (context, property, options) {
- var ret = '';
+ let ret = '';
context.forEach(function (d, i) {
- var changed = i > 0 ? d[property] !== context[i - 1][property] : true,
- c = _.extend({ changed: changed }, d);
+ const changed = i > 0 ? d[property] !== context[i - 1][property] : true;
+ const c = _.extend({ changed }, d);
ret += options.fn(c);
});
return ret;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js b/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js
index 6873ebddb9f..ca20b14eaad 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (context, options) {
- var ret = '';
+ let ret = '';
context.forEach(function (d, i) {
if (i % 2 === 0) {
ret += options.fn(d);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js b/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js
index 3d87f6d2c80..37eb85e2301 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js
@@ -20,9 +20,9 @@
import _ from 'underscore';
module.exports = function (context, options) {
- var ret = '';
+ let ret = '';
context.forEach(function (d, i) {
- var c = _.extend({ index: i }, d);
+ const c = _.extend({ index: i }, d);
ret += options.fn(c);
});
return ret;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js b/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js
index ccf43f804b8..ea74fd6ddeb 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (context, options) {
- var ret = '';
+ let ret = '';
context.forEach(function (d, i) {
if (i % 2 === 1) {
ret += options.fn(d);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js b/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js
index 1527b2ce0f0..0af425e2b4f 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js
@@ -18,10 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (array, options) {
- var ret = '';
+ let ret = '';
if (array && array.length > 0) {
- for (var i = array.length - 1; i >= 0; i--) {
+ for (let i = array.length - 1; i >= 0; i--) {
ret += options.fn(array[i]);
}
} else {
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/empty.js b/server/sonar-web/src/main/js/helpers/handlebars/empty.js
index 153167f1fb8..2ea8f259047 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/empty.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/empty.js
@@ -20,6 +20,6 @@
import _ from 'underscore';
module.exports = function (array, options) {
- var cond = _.isArray(array) && array.length > 0;
+ const cond = _.isArray(array) && array.length > 0;
return cond ? options.inverse(this) : options.fn(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js b/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js
index 6f8c45a616c..e6ae5f09caf 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (a, b, options) {
- var notEq = a && b && ((a.project !== b.project) || (a.subProject !== b.subProject));
+ const notEq = a && b && ((a.project !== b.project) || (a.subProject !== b.subProject));
return notEq ? options.inverse(this) : options.fn(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js b/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js
index 0e48bd612fe..dca3e991b69 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (profile, exporterKey) {
- var url = '/api/qualityprofiles/export';
+ let url = '/api/qualityprofiles/export';
url += '?language=' + encodeURIComponent(profile.language);
url += '&name=' + encodeURIComponent(profile.name);
if (exporterKey != null) {
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js b/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js
index 499028917d0..1f69a00d6d8 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js
@@ -20,7 +20,7 @@
import { formatMeasure } from '../measures';
module.exports = function (value, facetMode) {
- var formatter = facetMode === 'debt' ? 'SHORT_WORK_DUR' : 'SHORT_INT';
+ const formatter = facetMode === 'debt' ? 'SHORT_WORK_DUR' : 'SHORT_INT';
return formatMeasure(value, formatter);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifCanUseFilter.js b/server/sonar-web/src/main/js/helpers/handlebars/ifCanUseFilter.js
index 0dcda06c647..ee8ed1691ad 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/ifCanUseFilter.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/ifCanUseFilter.js
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (query, options) {
- var cond = window.SS.user || query.indexOf('__me__') === -1;
+ const cond = window.SS.user || query.indexOf('__me__') === -1;
return cond ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifHasExtraActions.js b/server/sonar-web/src/main/js/helpers/handlebars/ifHasExtraActions.js
index 80b50959101..fd81abe6dba 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/ifHasExtraActions.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/ifHasExtraActions.js
@@ -22,7 +22,7 @@ import _ from 'underscore';
const DEFAULT_ACTIONS = ['comment', 'assign', 'assign_to_me', 'plan', 'set_severity', 'set_tags'];
module.exports = function (actions, options) {
- var actionsLeft = _.difference(actions, DEFAULT_ACTIONS);
+ const actionsLeft = _.difference(actions, DEFAULT_ACTIONS);
if (actionsLeft.length > 0) {
return options.fn(this);
} else {
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifLength.js b/server/sonar-web/src/main/js/helpers/handlebars/ifLength.js
index 190d2f22c71..1758f384198 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/ifLength.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/ifLength.js
@@ -20,6 +20,6 @@
import _ from 'underscore';
module.exports = function (array, len, options) {
- var cond = _.isArray(array) && array.length === +len;
+ const cond = _.isArray(array) && array.length === +len;
return cond ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js b/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js
index 56324f88f76..a6c314a607e 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js
@@ -18,10 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1),
- options = arguments[arguments.length - 1],
- notEmpty = args.reduce(function (prev, current) {
- return prev || (current && current.length > 0);
- }, false);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
+ const options = arguments[arguments.length - 1];
+ const notEmpty = args.reduce(function (prev, current) {
+ return prev || (current && current.length > 0);
+ }, false);
return notEmpty ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js
index 9aed4d1d2c1..e0ca6980e8b 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js
@@ -20,9 +20,9 @@
import _ from 'underscore';
module.exports = function (source, line, options) {
- var currentLine = _.findWhere(source, { lineNumber: line }),
- prevLine = _.findWhere(source, { lineNumber: line - 1 }),
- changed = true;
+ const currentLine = _.findWhere(source, { lineNumber: line });
+ const prevLine = _.findWhere(source, { lineNumber: line - 1 });
+ let changed = true;
if (currentLine && prevLine && currentLine.scm && prevLine.scm) {
changed = (currentLine.scm.author !== prevLine.scm.author) ||
(currentLine.scm.date !== prevLine.scm.date) || (!prevLine.show);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js
index 21826ac7adb..f2129bad5d7 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js
@@ -20,9 +20,9 @@
import _ from 'underscore';
module.exports = function (source, line, options) {
- var currentLine = _.findWhere(source, { line: line }),
- prevLine = _.findWhere(source, { line: line - 1 }),
- changed = true;
+ const currentLine = _.findWhere(source, { line });
+ const prevLine = _.findWhere(source, { line: line - 1 });
+ let changed = true;
if (currentLine && prevLine && currentLine.scmAuthor && prevLine.scmAuthor) {
changed = (currentLine.scmAuthor !== prevLine.scmAuthor) || (currentLine.scmDate !== prevLine.scmDate);
}
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js b/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js
index 654b2c3bf54..0290074792f 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (options) {
- var cond = window.SS && window.SS.lf && window.SS.lf.enableGravatar;
+ const cond = window.SS && window.SS.lf && window.SS.lf.enableGravatar;
return cond ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js b/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js
index 1f820a9ab5a..242f90f53f8 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js
@@ -18,10 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1),
- options = arguments[arguments.length - 1],
- prefix = args.join(''),
- path = window.location.pathname,
- match = path.indexOf(prefix) === 0;
+ const args = Array.prototype.slice.call(arguments, 0, -1);
+ const options = arguments[arguments.length - 1];
+ const prefix = args.join('');
+ const path = window.location.pathname;
+ const match = path.indexOf(prefix) === 0;
return match ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js
index acbd15cf30b..a1825b04421 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterItemLink.js
@@ -21,7 +21,7 @@ import _ from 'underscore';
function getQuery (query, separator) {
separator = separator || '|';
- var route = [];
+ const route = [];
_.forEach(query, function (value, property) {
route.push('' + property + '=' + encodeURIComponent(value));
});
@@ -29,9 +29,9 @@ function getQuery (query, separator) {
}
module.exports = function (query, property, value, mode) {
- var criterion = {};
+ const criterion = {};
criterion[property] = value;
- var r = _.extend({}, query, criterion);
+ const r = _.extend({}, query, criterion);
if (mode === 'debt') {
r.facetMode = 'debt';
}
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js
index 3cc8b101f64..b900a9407e9 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterTotalLink.js
@@ -21,7 +21,7 @@ import _ from 'underscore';
function getQuery (query, separator) {
separator = separator || '|';
- var route = [];
+ const route = [];
_.forEach(query, function (value, property) {
route.push('' + property + '=' + encodeURIComponent(value));
});
@@ -29,7 +29,7 @@ function getQuery (query, separator) {
}
module.exports = function (query, mode) {
- var r = _.extend({}, query);
+ const r = _.extend({}, query);
if (mode === 'debt') {
r.facetMode = 'debt';
}
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js
index f09effea38c..dc5ea72598e 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js
@@ -20,6 +20,6 @@
import { formatMeasure } from '../measures';
module.exports = function (value, mode) {
- var formatter = mode === 'debt' ? 'SHORT_WORK_DUR' : 'SHORT_INT';
+ const formatter = mode === 'debt' ? 'SHORT_WORK_DUR' : 'SHORT_INT';
return formatMeasure(value, formatter);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/joinEach.js b/server/sonar-web/src/main/js/helpers/handlebars/joinEach.js
index a77a3fe5c92..4bc816b288c 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/joinEach.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/joinEach.js
@@ -18,10 +18,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (array, separator, options) {
- var ret = '';
+ let ret = '';
if (array && array.length > 0) {
- for (var i = 0, n = array.length; i < n; i++) {
+ for (let i = 0, n = array.length; i < n; i++) {
ret += options.fn(array[i]);
if (i < n - 1) {
ret += separator;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/limitString.js b/server/sonar-web/src/main/js/helpers/handlebars/limitString.js
index 2c318870b40..90d226a8609 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/limitString.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/limitString.js
@@ -19,7 +19,7 @@
*/
module.exports = function (str) {
if (typeof str === 'string') {
- var LIMIT = 30;
+ const LIMIT = 30;
return str.length > LIMIT ? str.substr(0, LIMIT) + '...' : str;
}
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/link.js b/server/sonar-web/src/main/js/helpers/handlebars/link.js
index 8f6eb587e97..faabd509205 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/link.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/link.js
@@ -18,6 +18,5 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var url = Array.prototype.slice.call(arguments, 0, -1).join('');
- return url;
+ return Array.prototype.slice.call(arguments, 0, -1).join('');
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/log.js b/server/sonar-web/src/main/js/helpers/handlebars/log.js
index 4045d4e2cd6..1e07f8f0c7f 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/log.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/log.js
@@ -19,6 +19,6 @@
*/
module.exports = function () {
/* eslint no-console: 0 */
- var args = Array.prototype.slice.call(arguments, 0, -1);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
console.log.apply(console, args);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js b/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js
index 2bd6baa7a2f..454ecbc0ea6 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js
@@ -20,6 +20,6 @@
import _ from 'underscore';
module.exports = function (array, options) {
- var cond = _.isArray(array) && array.length > 0;
+ const cond = _.isArray(array) && array.length > 0;
return cond ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js b/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js
index 78352208a05..dde65cef48e 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (a, b, options) {
- var notEq = a && b && ((a.project !== b.project) || (a.subProject !== b.subProject));
+ const notEq = a && b && ((a.project !== b.project) || (a.subProject !== b.subProject));
return notEq ? options.fn(this) : options.inverse(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js b/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js
index 39cfbe77401..3c3ee929654 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js
@@ -20,7 +20,7 @@
import numeral from 'numeral';
module.exports = function (number) {
- var format = '0,0';
+ let format = '0,0';
if (number >= 10000) {
format = '0.[0]a';
}
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/operators.js b/server/sonar-web/src/main/js/helpers/handlebars/operators.js
index 1676a58416a..7d7625ee5bd 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/operators.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/operators.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (options) {
- var ops = ['LT', 'GT', 'EQ', 'NE'];
+ const ops = ['LT', 'GT', 'EQ', 'NE'];
return ops.reduce(function (prev, current) {
return prev + options.fn(current);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/pluginActions.js b/server/sonar-web/src/main/js/helpers/handlebars/pluginActions.js
index d1482c545a2..06c6e05bd81 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/pluginActions.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/pluginActions.js
@@ -22,7 +22,7 @@ import _ from 'underscore';
const DEFAULT_ACTIONS = ['comment', 'assign', 'assign_to_me', 'plan', 'set_severity', 'set_tags'];
module.exports = function (actions, options) {
- var pluginActions = _.difference(actions, DEFAULT_ACTIONS);
+ const pluginActions = _.difference(actions, DEFAULT_ACTIONS);
return pluginActions.reduce(function (prev, current) {
return prev + options.fn(current);
}, '');
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/recursive.js b/server/sonar-web/src/main/js/helpers/handlebars/recursive.js
index 098ff4821d5..b6153cad05b 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/recursive.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/recursive.js
@@ -20,7 +20,7 @@
let audaciousFn;
module.exports = function (children, options) {
- var out = '';
+ let out = '';
if (options.fn !== undefined) {
audaciousFn = options.fn;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/repeat.js b/server/sonar-web/src/main/js/helpers/handlebars/repeat.js
index dc48c2fb2c7..14a39220148 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/repeat.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/repeat.js
@@ -18,8 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function (number, options) {
- var ret = '';
- for (var i = 0; i < number; i++) {
+ let ret = '';
+ for (let i = 0; i < number; i++) {
ret += options.fn(this);
}
return ret;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js b/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js
index 0ee7b402fdf..effea6826ea 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js
@@ -21,7 +21,7 @@ import Handlebars from 'handlebars/runtime';
import { translate, translateWithParameters } from '../../helpers/l10n';
module.exports = function (severity) {
- var label = '<i class="icon-severity-' + severity.toLowerCase() + '"></i>&nbsp;' + translate('severity', severity),
- message = translateWithParameters('quality_profiles.severity_set_to_x', label);
+ const label = '<i class="icon-severity-' + severity.toLowerCase() + '"></i>&nbsp;' + translate('severity', severity);
+ const message = translateWithParameters('quality_profiles.severity_set_to_x', label);
return new Handlebars.default.SafeString(message);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/show.js b/server/sonar-web/src/main/js/helpers/handlebars/show.js
index 562439a255e..c889de770e6 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/show.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/show.js
@@ -18,8 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments),
- ret = null;
+ const args = Array.prototype.slice.call(arguments);
+ let ret = null;
args.forEach(function (arg) {
if (typeof arg === 'string' && ret == null) {
ret = arg;
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/sources.js b/server/sonar-web/src/main/js/helpers/handlebars/sources.js
index 14f9cb34122..b76d12978b8 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/sources.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/sources.js
@@ -25,10 +25,10 @@ module.exports = function (source, scm, options) {
scm = null;
}
- var sources = _.map(source, function (code, line) {
+ const sources = _.map(source, function (code, line) {
return {
+ code,
lineNumber: line,
- code: code,
scm: (scm && scm[line]) ? { author: scm[line][0], date: scm[line][1] } : undefined
};
});
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js b/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js
index 429c84e44fa..93f45817637 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js
@@ -21,7 +21,7 @@ import Handlebars from 'handlebars/runtime';
import { translate } from '../../helpers/l10n';
module.exports = function (status, resolution) {
- var s = '<i class="icon-status-' + status.toLowerCase() + '"></i>&nbsp;' + translate('issue.status', status);
+ let s = '<i class="icon-status-' + status.toLowerCase() + '"></i>&nbsp;' + translate('issue.status', status);
if (resolution != null) {
s = s + '&nbsp;(' + translate('issue.resolution', resolution) + ')';
}
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/sum.js b/server/sonar-web/src/main/js/helpers/handlebars/sum.js
index c26d64f6399..be7b330a915 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/sum.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/sum.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
return args.reduce(function (p, c) {
return p + +c;
}, 0);
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/t.js b/server/sonar-web/src/main/js/helpers/handlebars/t.js
index dbc83d7fac0..f69bdc1c9bf 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/t.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/t.js
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
return window.t.apply(this, args);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/tp.js b/server/sonar-web/src/main/js/helpers/handlebars/tp.js
index 03fec3c4717..9d4851f7a50 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/tp.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/tp.js
@@ -18,6 +18,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
module.exports = function () {
- var args = Array.prototype.slice.call(arguments, 0, -1);
+ const args = Array.prototype.slice.call(arguments, 0, -1);
return window.tp.apply(this, args);
};
diff --git a/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js b/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js
index bb057984bd4..121823cf608 100644
--- a/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js
+++ b/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js
@@ -20,6 +20,6 @@
import _ from 'underscore';
module.exports = function (array, len, options) {
- var cond = _.isArray(array) && array.length === +len;
+ const cond = _.isArray(array) && array.length === +len;
return cond ? options.inverse(this) : options.fn(this);
};
diff --git a/server/sonar-web/src/main/js/helpers/l10n.js b/server/sonar-web/src/main/js/helpers/l10n.js
index 7428c4b1c5b..f8eaa296131 100644
--- a/server/sonar-web/src/main/js/helpers/l10n.js
+++ b/server/sonar-web/src/main/js/helpers/l10n.js
@@ -19,7 +19,6 @@
*/
import { stringify } from 'querystring';
import moment from 'moment';
-import _ from 'underscore';
let messages = {};
@@ -94,7 +93,7 @@ export function installGlobal () {
}
export function getLocalizedDashboardName (baseName) {
- var l10nKey = 'dashboard.' + baseName + '.name';
- var l10nLabel = translate(l10nKey);
+ const l10nKey = 'dashboard.' + baseName + '.name';
+ const l10nLabel = translate(l10nKey);
return l10nLabel !== l10nKey ? l10nLabel : baseName;
}
diff --git a/server/sonar-web/src/main/js/helpers/latinize.js b/server/sonar-web/src/main/js/helpers/latinize.js
index 56e7fbce18c..60f6e978ca3 100644
--- a/server/sonar-web/src/main/js/helpers/latinize.js
+++ b/server/sonar-web/src/main/js/helpers/latinize.js
@@ -22,7 +22,7 @@
* From http://stackoverflow.com/questions/990904/javascript-remove-accents-in-strings
*/
/* eslint max-len: 0 */
-var defaultDiacriticsRemovalap = [
+const defaultDiacriticsRemovalap = [
{
'base': 'A',
'letters': '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F'
@@ -369,10 +369,10 @@ var defaultDiacriticsRemovalap = [
}
];
-var diacriticsMap = {};
-for (var i = 0; i < defaultDiacriticsRemovalap.length; i++) {
- var letters = defaultDiacriticsRemovalap[i].letters.split('');
- for (var j = 0; j < letters.length; j++) {
+const diacriticsMap = {};
+for (let i = 0; i < defaultDiacriticsRemovalap.length; i++) {
+ const letters = defaultDiacriticsRemovalap[i].letters.split('');
+ for (let j = 0; j < letters.length; j++) {
diacriticsMap[letters[j]] = defaultDiacriticsRemovalap[i].base;
}
}
diff --git a/server/sonar-web/src/main/js/helpers/measures.js b/server/sonar-web/src/main/js/helpers/measures.js
index 6c91d75974e..518abbdd008 100644
--- a/server/sonar-web/src/main/js/helpers/measures.js
+++ b/server/sonar-web/src/main/js/helpers/measures.js
@@ -63,7 +63,7 @@ export function groupByDomain (metrics) {
let groupedMetrics = _.groupBy(metrics, 'domain');
let domains = _.map(groupedMetrics, (metricList, domain) => {
return {
- domain: domain,
+ domain,
metrics: _.sortBy(metricList, 'name')
};
});
@@ -129,7 +129,7 @@ function intVariationFormatter (value) {
}
function shortIntFormatter (value) {
- var format = '0,0';
+ let format = '0,0';
if (value >= 1000) {
format = '0.[0]a';
}
@@ -168,8 +168,8 @@ function ratingFormatter (value) {
}
function levelFormatter (value) {
- var l10nKey = 'metric.level.' + value,
- result = translate(l10nKey);
+ const l10nKey = 'metric.level.' + value;
+ const result = translate(l10nKey);
// if couldn't translate, return the initial value
return l10nKey !== result ? result : value;
}
@@ -224,7 +224,7 @@ function addSpaceIfNeeded (value) {
}
function formatDuration (isNegative, days, hours, minutes) {
- var formatted = '';
+ let formatted = '';
if (shouldDisplayDays(days)) {
formatted += translateWithParameters('work_duration.x_days', isNegative ? -1 * days : days);
}
@@ -242,9 +242,9 @@ function formatDuration (isNegative, days, hours, minutes) {
}
function formatDurationShort (isNegative, days, hours, minutes) {
- var formatted = '';
+ let formatted = '';
if (shouldDisplayDays(days)) {
- var formattedDays = formatMeasure(isNegative ? -1 * days : days, 'SHORT_INT');
+ const formattedDays = formatMeasure(isNegative ? -1 * days : days, 'SHORT_INT');
formatted += translateWithParameters('work_duration.x_days', formattedDays);
}
if (shouldDisplayHoursInShortFormat(days, hours)) {
@@ -264,12 +264,12 @@ function durationFormatter (value) {
if (value === 0) {
return '0';
}
- var hoursInDay = window.SS.hoursInDay,
- isNegative = value < 0,
- absValue = Math.abs(value);
- var days = Math.floor(absValue / hoursInDay / 60);
- var remainingValue = absValue - days * hoursInDay * 60;
- var hours = Math.floor(remainingValue / 60);
+ const hoursInDay = window.SS.hoursInDay;
+ const isNegative = value < 0;
+ const absValue = Math.abs(value);
+ const days = Math.floor(absValue / hoursInDay / 60);
+ let remainingValue = absValue - days * hoursInDay * 60;
+ const hours = Math.floor(remainingValue / 60);
remainingValue -= hours * 60;
return formatDuration(isNegative, days, hours, remainingValue);
}
@@ -279,12 +279,12 @@ function shortDurationFormatter (value) {
if (value === 0) {
return '0';
}
- var hoursInDay = window.SS.hoursInDay,
- isNegative = value < 0,
- absValue = Math.abs(value);
- var days = Math.floor(absValue / hoursInDay / 60);
- var remainingValue = absValue - days * hoursInDay * 60;
- var hours = Math.floor(remainingValue / 60);
+ const hoursInDay = window.SS.hoursInDay;
+ const isNegative = value < 0;
+ const absValue = Math.abs(value);
+ const days = Math.floor(absValue / hoursInDay / 60);
+ let remainingValue = absValue - days * hoursInDay * 60;
+ const hours = Math.floor(remainingValue / 60);
remainingValue -= hours * 60;
return formatDurationShort(isNegative, days, hours, remainingValue);
}
@@ -293,7 +293,7 @@ function durationVariationFormatter (value) {
if (value === 0) {
return '0';
}
- var formatted = durationFormatter(value);
+ const formatted = durationFormatter(value);
return formatted[0] !== '-' ? '+' + formatted : formatted;
}
@@ -301,6 +301,6 @@ function shortDurationVariationFormatter (value) {
if (value === 0) {
return '+0';
}
- var formatted = shortDurationFormatter(value);
+ const formatted = shortDurationFormatter(value);
return formatted[0] !== '-' ? '+' + formatted : formatted;
}
diff --git a/server/sonar-web/src/main/js/helpers/path.js b/server/sonar-web/src/main/js/helpers/path.js
index ce2c599f042..c0a16a4ea9e 100644
--- a/server/sonar-web/src/main/js/helpers/path.js
+++ b/server/sonar-web/src/main/js/helpers/path.js
@@ -25,23 +25,23 @@ export function collapsePath (path, limit = 30) {
return '';
}
- var tokens = path.split('/');
+ const tokens = path.split('/');
if (tokens.length <= 2) {
return path;
}
- var head = _.first(tokens),
- tail = _.last(tokens),
- middle = _.initial(_.rest(tokens)),
- cut = false;
+ const head = _.first(tokens);
+ const tail = _.last(tokens);
+ const middle = _.initial(_.rest(tokens));
+ let cut = false;
while (middle.join().length > limit && middle.length > 0) {
middle.shift();
cut = true;
}
- var body = [].concat(head, cut ? ['...'] : [], middle, tail);
+ const body = [].concat(head, cut ? ['...'] : [], middle, tail);
return body.join('/');
}
@@ -55,19 +55,19 @@ export function collapsePath (path, limit = 30) {
* @returns {string|null}
*/
export function collapsedDirFromPath (path) {
- var limit = 30;
+ const limit = 30;
if (typeof path === 'string') {
- var tokens = _.initial(path.split('/'));
+ const tokens = _.initial(path.split('/'));
if (tokens.length > 2) {
- var head = _.first(tokens),
- tail = _.last(tokens),
- middle = _.initial(_.rest(tokens)),
- cut = false;
+ const head = _.first(tokens);
+ const tail = _.last(tokens);
+ const middle = _.initial(_.rest(tokens));
+ let cut = false;
while (middle.join().length > limit && middle.length > 0) {
middle.shift();
cut = true;
}
- var body = [].concat(head, cut ? ['...'] : [], middle, tail);
+ const body = [].concat(head, cut ? ['...'] : [], middle, tail);
return body.join('/') + '/';
} else {
return tokens.join('/') + '/';
@@ -88,7 +88,7 @@ export function collapsedDirFromPath (path) {
*/
export function fileFromPath (path) {
if (typeof path === 'string') {
- var tokens = path.split('/');
+ const tokens = path.split('/');
return _.last(tokens);
} else {
return null;
diff --git a/server/sonar-web/src/main/js/helpers/request.js b/server/sonar-web/src/main/js/helpers/request.js
index ea0479c2495..99988db287d 100644
--- a/server/sonar-web/src/main/js/helpers/request.js
+++ b/server/sonar-web/src/main/js/helpers/request.js
@@ -108,7 +108,7 @@ export function checkStatus (response) {
if (response.status >= 200 && response.status < 300) {
return response;
} else {
- var error = new Error(response.status);
+ const error = new Error(response.status);
error.response = response;
throw error;
}
diff --git a/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js b/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js
index 44987766da3..b7bc2bae782 100644
--- a/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js
+++ b/server/sonar-web/src/main/js/main/nav/component/component-nav-menu.js
@@ -85,7 +85,7 @@ export default React.createClass({
isCustomDashboardActive(customDashboard) {
let path = window.location.pathname;
let params = qs.parse(window.location.search.substr(1));
- return path.indexOf(`/dashboard`) === 0 && params['did'] === `${customDashboard.key}`;
+ return path.indexOf('/dashboard') === 0 && params['did'] === `${customDashboard.key}`;
},
isCustomDashboardsActive () {
@@ -97,12 +97,12 @@ export default React.createClass({
isDefaultDeveloperDashboardActive() {
let path = window.location.pathname;
- return this.isDeveloper() && path.indexOf(`/dashboard`) === 0;
+ return this.isDeveloper() && path.indexOf('/dashboard') === 0;
},
isDashboardManagementActive () {
let path = window.location.pathname;
- return path.indexOf(`/dashboards`) === 0;
+ return path.indexOf('/dashboards') === 0;
},
renderFixedDashboards() {
diff --git a/server/sonar-web/src/main/js/main/nav/component/recent-history.js b/server/sonar-web/src/main/js/main/nav/component/recent-history.js
index b279dc81f24..12fa283cf93 100644
--- a/server/sonar-web/src/main/js/main/nav/component/recent-history.js
+++ b/server/sonar-web/src/main/js/main/nav/component/recent-history.js
@@ -24,7 +24,7 @@ const HISTORY_LIMIT = 10;
export default class RecentHistory {
static get () {
- var history = localStorage.getItem(STORAGE_KEY);
+ let history = localStorage.getItem(STORAGE_KEY);
if (history == null) {
history = [];
} else {
@@ -47,11 +47,11 @@ export default class RecentHistory {
}
static add (componentKey, componentName, icon) {
- var sonarHistory = RecentHistory.get();
+ const sonarHistory = RecentHistory.get();
if (componentKey) {
- var newEntry = { key: componentKey, name: componentName, icon: icon };
- var newHistory = _.reject(sonarHistory, entry => entry.key === newEntry.key);
+ const newEntry = { key: componentKey, name: componentName, icon };
+ let newHistory = _.reject(sonarHistory, entry => entry.key === newEntry.key);
newHistory.unshift(newEntry);
newHistory = _.first(newHistory, HISTORY_LIMIT);
RecentHistory.set(newHistory);
diff --git a/server/sonar-web/src/main/js/main/nav/dashboard-name-mixin.js b/server/sonar-web/src/main/js/main/nav/dashboard-name-mixin.js
index 4b1a287d8be..09861d46f14 100644
--- a/server/sonar-web/src/main/js/main/nav/dashboard-name-mixin.js
+++ b/server/sonar-web/src/main/js/main/nav/dashboard-name-mixin.js
@@ -21,8 +21,8 @@ import { translate } from '../../helpers/l10n';
export default {
getLocalizedDashboardName(baseName) {
- var l10nKey = 'dashboard.' + baseName + '.name';
- var l10nLabel = translate(l10nKey);
+ const l10nKey = 'dashboard.' + baseName + '.name';
+ const l10nLabel = translate(l10nKey);
if (l10nLabel !== l10nKey) {
return l10nLabel;
} else {
diff --git a/server/sonar-web/src/main/js/main/nav/global/global-nav-branding.js b/server/sonar-web/src/main/js/main/nav/global/global-nav-branding.js
index 298a83bd8ee..b572ad97ce6 100644
--- a/server/sonar-web/src/main/js/main/nav/global/global-nav-branding.js
+++ b/server/sonar-web/src/main/js/main/nav/global/global-nav-branding.js
@@ -22,7 +22,7 @@ import { translate } from '../../../helpers/l10n';
export default React.createClass({
renderLogo() {
- let url = this.props.logoUrl || `/images/logo.svg`;
+ let url = this.props.logoUrl || '/images/logo.svg';
let width = this.props.logoWidth || 100;
let height = 30;
let title = translate('layout.sonar.slogan');
diff --git a/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js b/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js
index 3bce14a4b5c..e3d0bc158c9 100644
--- a/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js
+++ b/server/sonar-web/src/main/js/main/nav/global/global-nav-menu.js
@@ -25,11 +25,11 @@ import { translate } from '../../../helpers/l10n';
export default React.createClass({
mixins: [DashboardNameMixin, LinksMixin],
- getDefaultProps: function () {
+ getDefaultProps () {
return { globalDashboards: [], globalPages: [] };
},
- renderDashboardLink(dashboard) {
+ renderDashboardLink (dashboard) {
const url = `/dashboard/index?did=${encodeURIComponent(dashboard.key)}`;
const name = this.getLocalizedDashboardName(dashboard.name);
return (
@@ -39,8 +39,8 @@ export default React.createClass({
);
},
- renderDashboardsManagementLink() {
- const url = `/dashboards`;
+ renderDashboardsManagementLink () {
+ const url = '/dashboards';
return (
<li>
<a href={url}>{translate('dashboard.manage_dashboards')}</a>
@@ -48,13 +48,14 @@ export default React.createClass({
);
},
- renderDashboards() {
+ renderDashboards () {
const dashboards = this.props.globalDashboards.map(this.renderDashboardLink);
const canManageDashboards = !!window.SS.user;
return (
<li className="dropdown">
<a className="dropdown-toggle" data-toggle="dropdown" href="#">
- {translate('layout.dashboards')}&nbsp;<span className="icon-dropdown"/>
+ {translate('layout.dashboards')}&nbsp;
+ <span className="icon-dropdown"/>
</a>
<ul className="dropdown-menu">
{dashboards}
@@ -65,8 +66,8 @@ export default React.createClass({
);
},
- renderIssuesLink() {
- const url = `/issues/search`;
+ renderIssuesLink () {
+ const url = '/issues/search';
return (
<li className={this.activeLink('/issues')}>
<a href={url}>{translate('issues.page')}</a>
@@ -74,8 +75,8 @@ export default React.createClass({
);
},
- renderMeasuresLink() {
- const url = `/measures/search?qualifiers[]=TRK`;
+ renderMeasuresLink () {
+ const url = '/measures/search?qualifiers[]=TRK';
return (
<li className={this.activeLink('/measures')}>
<a href={url}>{translate('layout.measures')}</a>
@@ -83,8 +84,8 @@ export default React.createClass({
);
},
- renderRulesLink() {
- const url = `/coding_rules`;
+ renderRulesLink () {
+ const url = '/coding_rules';
return (
<li className={this.activeLink('/coding_rules')}>
<a href={url}>{translate('coding_rules.page')}</a>
@@ -93,7 +94,7 @@ export default React.createClass({
},
renderProfilesLink() {
- const url = `/profiles`;
+ const url = '/profiles';
return (
<li className={this.activeLink('/profiles')}>
<a href={url}>{translate('quality_profiles.page')}</a>
@@ -101,8 +102,8 @@ export default React.createClass({
);
},
- renderQualityGatesLink() {
- const url = `/quality_gates`;
+ renderQualityGatesLink () {
+ const url = '/quality_gates';
return (
<li className={this.activeLink('/quality_gates')}>
<a href={url}>{translate('quality_gates.page')}</a>
@@ -110,11 +111,11 @@ export default React.createClass({
);
},
- renderAdministrationLink() {
+ renderAdministrationLink () {
if (!window.SS.isUserAdmin) {
return null;
}
- const url = `/settings`;
+ const url = '/settings';
return (
<li className={this.activeLink('/settings')}>
<a className="navbar-admin-link" href={url}>{translate('layout.settings')}</a>
@@ -122,8 +123,8 @@ export default React.createClass({
);
},
- renderComparisonLink() {
- const url = `/comparison`;
+ renderComparisonLink () {
+ const url = '/comparison';
return (
<li className={this.activeLink('/comparison')}>
<a href={url}>{translate('comparison_global.page')}</a>
@@ -131,7 +132,7 @@ export default React.createClass({
);
},
- renderGlobalPageLink(globalPage, index) {
+ renderGlobalPageLink (globalPage, index) {
const url = globalPage.url;
return (
<li key={index}>
@@ -140,12 +141,13 @@ export default React.createClass({
);
},
- renderMore() {
+ renderMore () {
const globalPages = this.props.globalPages.map(this.renderGlobalPageLink);
return (
<li className="dropdown">
<a className="dropdown-toggle" data-toggle="dropdown" href="#">
- {translate('more')}&nbsp;<span className="icon-dropdown"/>
+ {translate('more')}&nbsp;
+ <span className="icon-dropdown"/>
</a>
<ul className="dropdown-menu">
{this.renderComparisonLink()}
@@ -155,7 +157,7 @@ export default React.createClass({
);
},
- render() {
+ render () {
return (
<ul className="nav navbar-nav">
{this.renderDashboards()}
diff --git a/server/sonar-web/src/main/js/main/nav/global/global-nav-user.js b/server/sonar-web/src/main/js/main/nav/global/global-nav-user.js
index b7bb0f78eca..0d10bbbe045 100644
--- a/server/sonar-web/src/main/js/main/nav/global/global-nav-user.js
+++ b/server/sonar-web/src/main/js/main/nav/global/global-nav-user.js
@@ -32,7 +32,7 @@ export default React.createClass({
</a>
<ul className="dropdown-menu dropdown-menu-right">
<li>
- <a href={`/account/`}>{translate('my_account.page')}</a>
+ <a href="/account/">{translate('my_account.page')}</a>
</li>
<li>
<a onClick={this.handleLogout} href="#">{translate('layout.logout')}</a>
@@ -59,7 +59,7 @@ export default React.createClass({
handleLogout(e) {
e.preventDefault();
RecentHistory.clear();
- window.location = `/sessions/logout`;
+ window.location = '/sessions/logout';
},
render() {
diff --git a/server/sonar-web/src/main/js/main/nav/global/search-view.js b/server/sonar-web/src/main/js/main/nav/global/search-view.js
index b46a11b2985..0af5fef914b 100644
--- a/server/sonar-web/src/main/js/main/nav/global/search-view.js
+++ b/server/sonar-web/src/main/js/main/nav/global/search-view.js
@@ -29,53 +29,53 @@ import RecentHistory from '../component/recent-history';
import { translate } from '../../../helpers/l10n';
import { collapsedDirFromPath, fileFromPath } from '../../../helpers/path';
-var SearchItemView = Marionette.ItemView.extend({
- tagName: 'li',
- template: SearchItemTemplate,
+const SearchItemView = Marionette.ItemView.extend({
+ tagName: 'li',
+ template: SearchItemTemplate,
- select: function () {
- this.$el.addClass('active');
- },
+ select () {
+ this.$el.addClass('active');
+ },
- deselect: function () {
- this.$el.removeClass('active');
- },
+ deselect () {
+ this.$el.removeClass('active');
+ },
- submit: function () {
- this.$('a')[0].click();
- },
+ submit () {
+ this.$('a')[0].click();
+ },
- onRender: function () {
- this.$('[data-toggle="tooltip"]').tooltip({
- container: 'body',
- html: true,
- placement: 'left',
- delay: { show: 500, hide: 0 }
- });
- },
+ onRender () {
+ this.$('[data-toggle="tooltip"]').tooltip({
+ container: 'body',
+ html: true,
+ placement: 'left',
+ delay: { show: 500, hide: 0 }
+ });
+ },
- onDestroy: function () {
- this.$('[data-toggle="tooltip"]').tooltip('destroy');
- },
+ onDestroy () {
+ this.$('[data-toggle="tooltip"]').tooltip('destroy');
+ },
- serializeData: function () {
- return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
- index: this.options.index
- });
- }
- }),
+ serializeData () {
+ return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+ index: this.options.index
+ });
+ }
+});
- SearchEmptyView = Marionette.ItemView.extend({
- tagName: 'li',
- template: EmptySearchTemplate
- }),
+const SearchEmptyView = Marionette.ItemView.extend({
+ tagName: 'li',
+ template: EmptySearchTemplate
+});
- SearchResultsView = SelectableCollectionView.extend({
- className: 'menu',
- tagName: 'ul',
- childView: SearchItemView,
- emptyView: SearchEmptyView
- });
+const SearchResultsView = SelectableCollectionView.extend({
+ className: 'menu',
+ tagName: 'ul',
+ childView: SearchItemView,
+ emptyView: SearchEmptyView
+});
export default Marionette.LayoutView.extend({
className: 'navbar-search',
@@ -92,8 +92,8 @@ export default Marionette.LayoutView.extend({
'keyup .js-search-input': 'onKeyUp'
},
- initialize: function () {
- var that = this;
+ initialize () {
+ const that = this;
this.results = new Backbone.Collection();
this.favorite = [];
if (window.SS.user) {
@@ -108,15 +108,15 @@ export default Marionette.LayoutView.extend({
this._bufferedValue = '';
},
- onRender: function () {
- var that = this;
+ onRender () {
+ const that = this;
this.resultsRegion.show(this.resultsView);
setTimeout(function () {
that.$('.js-search-input').focus();
}, 0);
},
- onKeyDown: function (e) {
+ onKeyDown (e) {
if (e.keyCode === 38) {
this.resultsView.selectPrev();
return false;
@@ -136,8 +136,8 @@ export default Marionette.LayoutView.extend({
}
},
- onKeyUp: function () {
- var value = this.$('.js-search-input').val();
+ onKeyUp () {
+ const value = this.$('.js-search-input').val();
if (value === this._bufferedValue) {
return;
}
@@ -148,15 +148,15 @@ export default Marionette.LayoutView.extend({
this.searchRequest = this.debouncedSearch(value);
},
- onSubmit: function () {
+ onSubmit () {
return false;
},
- fetchFavorite: function () {
- var that = this;
+ fetchFavorite () {
+ const that = this;
return $.get('/api/favourites').done(function (r) {
that.favorite = r.map(function (f) {
- var isFile = ['FIL', 'UTS'].indexOf(f.qualifier) !== -1;
+ const isFile = ['FIL', 'UTS'].indexOf(f.qualifier) !== -1;
return {
url: '/dashboard/index?id=' + encodeURIComponent(f.key) + window.dashboardParameters(true),
name: isFile ? collapsedDirFromPath(f.lname) + fileFromPath(f.lname) : f.name,
@@ -167,41 +167,41 @@ export default Marionette.LayoutView.extend({
});
},
- resetResultsToDefault: function () {
- var recentHistory = RecentHistory.get(),
- history = recentHistory.map(function (historyItem, index) {
- var url = '/dashboard/index?id=' + encodeURIComponent(historyItem.key) +
- window.dashboardParameters(true);
- return {
- url: url,
- name: historyItem.name,
- q: historyItem.icon,
- extra: index === 0 ? translate('browsed_recently') : null
- };
- }),
- favorite = _.first(this.favorite, 6).map(function (f, index) {
- return _.extend(f, { extra: index === 0 ? translate('favorite') : null });
- }),
- qualifiers = this.model.get('qualifiers').map(function (q, index) {
- return {
- url: '/all_projects?qualifier=' + encodeURIComponent(q),
- name: translate('qualifiers.all', q),
- extra: index === 0 ? '' : null
- };
- });
+ resetResultsToDefault () {
+ const recentHistory = RecentHistory.get();
+ const history = recentHistory.map(function (historyItem, index) {
+ const url = '/dashboard/index?id=' + encodeURIComponent(historyItem.key) +
+ window.dashboardParameters(true);
+ return {
+ url,
+ name: historyItem.name,
+ q: historyItem.icon,
+ extra: index === 0 ? translate('browsed_recently') : null
+ };
+ });
+ const favorite = _.first(this.favorite, 6).map(function (f, index) {
+ return _.extend(f, { extra: index === 0 ? translate('favorite') : null });
+ });
+ const qualifiers = this.model.get('qualifiers').map(function (q, index) {
+ return {
+ url: '/all_projects?qualifier=' + encodeURIComponent(q),
+ name: translate('qualifiers.all', q),
+ extra: index === 0 ? '' : null
+ };
+ });
this.results.reset([].concat(history, favorite, qualifiers));
},
- search: function (q) {
+ search (q) {
if (q.length < 2) {
this.resetResultsToDefault();
return;
}
- var that = this,
- url = '/api/components/suggestions',
- options = { s: q };
+ const that = this;
+ const url = '/api/components/suggestions';
+ const options = { s: q };
return $.get(url, options).done(function (r) {
- var collection = [];
+ const collection = [];
r.results.forEach(function (domain) {
domain.items.forEach(function (item, index) {
collection.push(_.extend(item, {
@@ -220,20 +220,20 @@ export default Marionette.LayoutView.extend({
});
},
- getNavigationFindings: function (q) {
- var DEFAULT_ITEMS = [
- { name: translate('issues.page'), url: '/issues/search' },
- { name: translate('layout.measures'), url: '/measures/search?qualifiers[]=TRK' },
- { name: translate('coding_rules.page'), url: '/coding_rules' },
- { name: translate('quality_profiles.page'), url: '/profiles' },
- { name: translate('quality_gates.page'), url: '/quality_gates' },
- { name: translate('comparison_global.page'), url: '/comparison' }
- ],
- customItems = [];
+ getNavigationFindings (q) {
+ const DEFAULT_ITEMS = [
+ { name: translate('issues.page'), url: '/issues/search' },
+ { name: translate('layout.measures'), url: '/measures/search?qualifiers[]=TRK' },
+ { name: translate('coding_rules.page'), url: '/coding_rules' },
+ { name: translate('quality_profiles.page'), url: '/profiles' },
+ { name: translate('quality_gates.page'), url: '/quality_gates' },
+ { name: translate('comparison_global.page'), url: '/comparison' }
+ ];
+ const customItems = [];
if (window.SS.isUserAdmin) {
customItems.push({ name: translate('layout.settings'), url: '/settings' });
}
- var findings = [].concat(DEFAULT_ITEMS, customItems).filter(function (f) {
+ const findings = [].concat(DEFAULT_ITEMS, customItems).filter(function (f) {
return f.name.match(new RegExp(q, 'i'));
});
if (findings.length > 0) {
@@ -242,12 +242,12 @@ export default Marionette.LayoutView.extend({
return _.first(findings, 6);
},
- getGlobalDashboardFindings: function (q) {
- var dashboards = this.model.get('globalDashboards') || [],
- items = dashboards.map(function (d) {
- return { name: d.name, url: '/dashboard/index?did=' + encodeURIComponent(d.key) };
- });
- var findings = items.filter(function (f) {
+ getGlobalDashboardFindings (q) {
+ const dashboards = this.model.get('globalDashboards') || [];
+ const items = dashboards.map(function (d) {
+ return { name: d.name, url: '/dashboard/index?did=' + encodeURIComponent(d.key) };
+ });
+ const findings = items.filter(function (f) {
return f.name.match(new RegExp(q, 'i'));
});
if (findings.length > 0) {
@@ -256,8 +256,8 @@ export default Marionette.LayoutView.extend({
return _.first(findings, 6);
},
- getFavoriteFindings: function (q) {
- var findings = this.favorite.filter(function (f) {
+ getFavoriteFindings (q) {
+ const findings = this.favorite.filter(function (f) {
return f.name.match(new RegExp(q, 'i'));
});
if (findings.length > 0) {
diff --git a/server/sonar-web/src/main/js/main/processes.js b/server/sonar-web/src/main/js/main/processes.js
index c83f4645a25..17a4d6551b0 100644
--- a/server/sonar-web/src/main/js/main/processes.js
+++ b/server/sonar-web/src/main/js/main/processes.js
@@ -23,106 +23,106 @@ import Backbone from 'backbone';
import Marionette from 'backbone.marionette';
import { translate } from '../helpers/l10n';
-var defaults = {
+const defaults = {
queue: {},
timeout: 300,
fadeTimeout: 100
};
-var Process = Backbone.Model.extend({
- defaults: {
- state: 'ok'
- },
-
- timeout: function () {
- this.set({
- state: 'timeout',
- message: 'Still Working...'
- });
- },
-
- finish: function (options) {
- options = _.defaults(options || {}, { force: false });
- if (this.get('state') !== 'failed' || !!options.force) {
- this.trigger('destroy', this, this.collection, options);
- }
- },
-
- fail: function (message) {
- var that = this,
- msg = message || translate('process.fail');
- if (msg === 'process.fail') {
- // no translation
- msg = 'An error happened, some parts of the page might not render correctly. ' +
- 'Please contact the administrator if you keep on experiencing this error.';
- }
- clearInterval(this.get('timer'));
- this.set({
- state: 'failed',
- message: msg
- });
- this.set('state', 'failed');
- setTimeout(function () {
- that.finish({ force: true });
- }, 5000);
- }
- }),
-
- Processes = Backbone.Collection.extend({
- model: Process
- }),
-
- ProcessesView = Marionette.ItemView.extend({
- tagName: 'ul',
- className: 'processes-container',
-
- collectionEvents: {
- 'all': 'render'
- },
-
- render: function () {
- var failed = this.collection.findWhere({ state: 'failed' }),
- timeout = this.collection.findWhere({ state: 'timeout' }),
- el;
- this.$el.empty();
- if (failed != null) {
- el = $('<li></li>')
- .html(failed.get('message'))
- .addClass('process-spinner process-spinner-failed shown');
- var close = $('<button></button>').html('<i class="icon-close"></i>').addClass('process-spinner-close');
- close.appendTo(el);
- close.on('click', function () {
- failed.finish({ force: true });
- });
- el.appendTo(this.$el);
- } else if (timeout != null) {
- el = $('<li></li>')
- .html(timeout.get('message'))
- .addClass('process-spinner shown');
- el.appendTo(this.$el);
- }
- return this;
- }
+const Process = Backbone.Model.extend({
+ defaults: {
+ state: 'ok'
+ },
+
+ timeout () {
+ this.set({
+ state: 'timeout',
+ message: 'Still Working...'
});
+ },
+ finish (options) {
+ options = _.defaults(options || {}, { force: false });
+ if (this.get('state') !== 'failed' || !!options.force) {
+ this.trigger('destroy', this, this.collection, options);
+ }
+ },
-var processes = new Processes(),
- processesView = new ProcessesView({
- collection: processes
+ fail (message) {
+ const that = this;
+ let msg = message || translate('process.fail');
+ if (msg === 'process.fail') {
+ // no translation
+ msg = 'An error happened, some parts of the page might not render correctly. ' +
+ 'Please contact the administrator if you keep on experiencing this error.';
+ }
+ clearInterval(this.get('timer'));
+ this.set({
+ state: 'failed',
+ message: msg
});
+ this.set('state', 'failed');
+ setTimeout(function () {
+ that.finish({ force: true });
+ }, 5000);
+ }
+});
+
+const Processes = Backbone.Collection.extend({
+ model: Process
+});
+
+const ProcessesView = Marionette.ItemView.extend({
+ tagName: 'ul',
+ className: 'processes-container',
+
+ collectionEvents: {
+ 'all': 'render'
+ },
+
+ render () {
+ const failed = this.collection.findWhere({ state: 'failed' });
+ const timeout = this.collection.findWhere({ state: 'timeout' });
+ let el;
+ this.$el.empty();
+ if (failed != null) {
+ el = $('<li></li>')
+ .html(failed.get('message'))
+ .addClass('process-spinner process-spinner-failed shown');
+ const close = $('<button></button>').html('<i class="icon-close"></i>').addClass('process-spinner-close');
+ close.appendTo(el);
+ close.on('click', function () {
+ failed.finish({ force: true });
+ });
+ el.appendTo(this.$el);
+ } else if (timeout != null) {
+ el = $('<li></li>')
+ .html(timeout.get('message'))
+ .addClass('process-spinner shown');
+ el.appendTo(this.$el);
+ }
+ return this;
+ }
+});
+
+
+const processes = new Processes();
+const processesView = new ProcessesView({
+ collection: processes
+});
/**
* Add background process
* @returns {number}
*/
function addBackgroundProcess () {
- var uid = _.uniqueId('process'),
- process = new Process({
- id: uid,
- timer: setTimeout(function () {
- process.timeout();
- }, defaults.timeout)
- });
+ const uid = _.uniqueId('process');
+ const process = new Process({
+ id: uid,
+ timer: setTimeout(function () {
+ process.timeout();
+ }, defaults.timeout)
+ });
processes.add(process);
return uid;
}
@@ -132,7 +132,7 @@ function addBackgroundProcess () {
* @param {number} uid
*/
function finishBackgroundProcess (uid) {
- var process = processes.get(uid);
+ const process = processes.get(uid);
if (process != null) {
process.finish();
}
@@ -144,7 +144,7 @@ function finishBackgroundProcess (uid) {
* @param {string} message
*/
function failBackgroundProcess (uid, message) {
- var process = processes.get(uid);
+ const process = processes.get(uid);
if (process != null) {
process.fail(message);
}
@@ -156,7 +156,7 @@ function failBackgroundProcess (uid, message) {
*/
function handleAjaxError (jqXHR) {
if (jqXHR.processId != null) {
- var message = null;
+ let message = null;
if (jqXHR != null && jqXHR.responseJSON != null && jqXHR.responseJSON.errors != null) {
message = _.pluck(jqXHR.responseJSON.errors, 'msg').join('. ');
}
@@ -166,10 +166,10 @@ function handleAjaxError (jqXHR) {
$.ajaxSetup({
- beforeSend: function (jqXHR) {
+ beforeSend (jqXHR) {
jqXHR.processId = addBackgroundProcess();
},
- complete: function (jqXHR) {
+ complete (jqXHR) {
if (jqXHR.processId != null) {
finishBackgroundProcess(jqXHR.processId);
}
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 ade9eab0151..ef4375060fb 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
@@ -31,22 +31,165 @@ import SeveritiesTemplate from './templates/widget-issue-filter-severities.hbs';
import StatusesTemplate from './templates/widget-issue-filter-statuses.hbs';
-var FACET_LIMIT = 15,
- defaultComparator = function (item) {
- return -item.count;
+const FACET_LIMIT = 15;
+const defaultComparator = function (item) {
+ return -item.count;
+};
+const defaultFilter = function (item) {
+ const items = this.query[this.property];
+ return items == null ||
+ (items != null && items.split(',').indexOf(item.val) !== -1);
+};
+const defaultLabel = function (item) {
+ return item.val;
+};
+const defaultLink = function (item, property, query, index, items, mode) {
+ const criterion = {};
+ criterion[property] = item.val;
+ const r = _.extend({}, query, criterion);
+ if (mode === 'debt') {
+ r.facetMode = 'debt';
+ }
+ if (r.componentKey != null) {
+ return '/component_issues/index?id=' + encodeURIComponent(r.componentKey) +
+ '#' + getQuery(_.omit(r, 'componentKey'));
+ } else {
+ return '/issues/search#' + getQuery(r);
+ }
+};
+const byDistributionConf = {
+ 'severities': {
+ template: SeveritiesTemplate,
+ comparator (item) {
+ const order = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'];
+ return order.indexOf(item.val);
+ }
+ },
+ 'statuses': {
+ template: StatusesTemplate,
+ comparator (item) {
+ const order = ['OPEN', 'REOPENED', 'CONFIRMED', 'RESOLVED', 'CLOSED'];
+ return order.indexOf(item.val);
+ },
+ filter (item) {
+ const unresolvedQuery = '' + this.query.resolved === 'false';
+ const resolvedStatus = item.val === 'RESOLVED' || item.val === 'CLOSED';
+ return !(unresolvedQuery && resolvedStatus);
+ }
+ },
+ 'resolutions': {
+ template: ResolutionsTemplate,
+ comparator (item) {
+ const order = ['', 'FALSE-POSITIVE', 'WONTFIX', 'FIXED', 'REMOVED'];
+ return order.indexOf(item.val);
+ },
+ filter (item) {
+ if ('' + this.query.resolved === 'false') {
+ return item.val === '';
+ } else {
+ return defaultFilter.call(this, item);
+ }
+ }
+ },
+ 'rules': {
+ label (item, r) {
+ if (_.isArray(r.rules)) {
+ const rule = _.findWhere(r.rules, { key: item.val });
+ if (rule != null) {
+ return rule.name;
+ }
+ }
+ }
+ },
+ 'projectUuids': {
+ label (item, r) {
+ if (_.isArray(r.projects)) {
+ const project = _.findWhere(r.projects, { uuid: item.val });
+ if (project != null) {
+ return project.name;
+ }
+ }
+ }
+ },
+ 'assignees': {
+ template: AssigneesTemplate,
+ label (item, r) {
+ if (_.isArray(r.users)) {
+ const user = _.findWhere(r.users, { login: item.val });
+ if (user != null) {
+ return user.name;
+ }
+ }
+ },
+ filter (item) {
+ if ('' + this.query.assigned === 'false') {
+ return item.val === '';
+ } else {
+ return defaultFilter.call(this, item);
+ }
+ }
+ },
+ 'languages': {
+ label (item, r) {
+ if (_.isArray(r.languages)) {
+ const lang = _.findWhere(r.languages, { key: item.val });
+ if (lang != null) {
+ return lang.name;
+ }
+ }
+ }
+ },
+ 'reporters': {
+ label (item, r) {
+ if (_.isArray(r.users)) {
+ const reporter = _.findWhere(r.users, { login: item.val });
+ if (reporter != null) {
+ return reporter.name;
+ }
+ }
+ }
+ },
+ 'actionPlans': {
+ template: ActionPlansTemplate,
+ label (item, r) {
+ if (_.isArray(r.actionPlans)) {
+ const actionPlan = _.findWhere(r.actionPlans, { key: item.val });
+ if (actionPlan != null) {
+ return actionPlan.name;
+ }
+ }
},
- defaultFilter = function (item) {
- var items = this.query[this.property];
- return items == null ||
- (items != null && items.split(',').indexOf(item.val) !== -1);
+ filter (item) {
+ if ('' + this.query.planned === 'false') {
+ return item.val === '';
+ } else {
+ return defaultFilter.call(this, item);
+ }
+ }
+ },
+ 'createdAt': {
+ comparator (item) {
+ return -moment(item.val).unix();
},
- defaultLabel = function (item) {
- return item.val;
+ label (item, r, items, index, query) {
+ const beginning = moment(item.val);
+ const endDate = query.createdBefore != null ? moment(query.createdBefore) : moment();
+ const ending = index < items.length - 1 ? moment(items[index + 1].val).subtract(1, 'days') : endDate;
+ const isSameDay = ending.diff(beginning, 'days') <= 1;
+ return beginning.format('LL') + (isSameDay ? '' : (' – ' + ending.format('LL')));
},
- defaultLink = function (item, property, query, index, items, mode) {
- var criterion = {};
- criterion[property] = item.val;
- var r = _.extend({}, query, criterion);
+ link (item, property, query, index, items, mode) {
+ const createdAfter = moment(item.val);
+ const endDate = query.createdBefore != null ? moment(query.createdBefore) : moment();
+ const createdBefore = index < items.length - 1 ? moment(items[index + 1].val).subtract(1, 'days') : endDate;
+ const isSameDay = createdBefore.diff(createdAfter, 'days') <= 1;
+ if (isSameDay) {
+ createdBefore.add(1, 'days');
+ }
+ const r = _.extend({}, query, {
+ createdAfter: createdAfter.format('YYYY-MM-DD'),
+ createdBefore: createdBefore.format('YYYY-MM-DD')
+ });
if (mode === 'debt') {
r.facetMode = 'debt';
}
@@ -56,156 +199,13 @@ var FACET_LIMIT = 15,
} else {
return '/issues/search#' + getQuery(r);
}
- },
- byDistributionConf = {
- 'severities': {
- template: SeveritiesTemplate,
- comparator: function (item) {
- var order = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'];
- return order.indexOf(item.val);
- }
- },
- 'statuses': {
- template: StatusesTemplate,
- comparator: function (item) {
- var order = ['OPEN', 'REOPENED', 'CONFIRMED', 'RESOLVED', 'CLOSED'];
- return order.indexOf(item.val);
- },
- filter: function (item) {
- var unresolvedQuery = '' + this.query.resolved === 'false',
- resolvedStatus = item.val === 'RESOLVED' || item.val === 'CLOSED';
- return !(unresolvedQuery && resolvedStatus);
- }
- },
- 'resolutions': {
- template: ResolutionsTemplate,
- comparator: function (item) {
- var order = ['', 'FALSE-POSITIVE', 'WONTFIX', 'FIXED', 'REMOVED'];
- return order.indexOf(item.val);
- },
- filter: function (item) {
- if ('' + this.query.resolved === 'false') {
- return item.val === '';
- } else {
- return defaultFilter.call(this, item);
- }
- }
- },
- 'rules': {
- label: function (item, r) {
- if (_.isArray(r.rules)) {
- var rule = _.findWhere(r.rules, { key: item.val });
- if (rule != null) {
- return rule.name;
- }
- }
- }
- },
- 'projectUuids': {
- label: function (item, r) {
- if (_.isArray(r.projects)) {
- var project = _.findWhere(r.projects, { uuid: item.val });
- if (project != null) {
- return project.name;
- }
- }
- }
- },
- 'assignees': {
- template: AssigneesTemplate,
- label: function (item, r) {
- if (_.isArray(r.users)) {
- var user = _.findWhere(r.users, { login: item.val });
- if (user != null) {
- return user.name;
- }
- }
- },
- filter: function (item) {
- if ('' + this.query.assigned === 'false') {
- return item.val === '';
- } else {
- return defaultFilter.call(this, item);
- }
- }
- },
- 'languages': {
- label: function (item, r) {
- if (_.isArray(r.languages)) {
- var lang = _.findWhere(r.languages, { key: item.val });
- if (lang != null) {
- return lang.name;
- }
- }
- }
- },
- 'reporters': {
- label: function (item, r) {
- if (_.isArray(r.users)) {
- var reporter = _.findWhere(r.users, { login: item.val });
- if (reporter != null) {
- return reporter.name;
- }
- }
- }
- },
- 'actionPlans': {
- template: ActionPlansTemplate,
- label: function (item, r) {
- if (_.isArray(r.actionPlans)) {
- var actionPlan = _.findWhere(r.actionPlans, { key: item.val });
- if (actionPlan != null) {
- return actionPlan.name;
- }
- }
- },
- filter: function (item) {
- if ('' + this.query.planned === 'false') {
- return item.val === '';
- } else {
- return defaultFilter.call(this, item);
- }
- }
- },
- 'createdAt': {
- comparator: function (item) {
- return -moment(item.val).unix();
- },
- label: function (item, r, items, index, query) {
- var beginning = moment(item.val),
- endDate = query.createdBefore != null ? moment(query.createdBefore) : moment(),
- ending = index < items.length - 1 ? moment(items[index + 1].val).subtract(1, 'days') : endDate,
- isSameDay = ending.diff(beginning, 'days') <= 1;
- return beginning.format('LL') + (isSameDay ? '' : (' – ' + ending.format('LL')));
- },
- link: function (item, property, query, index, items, mode) {
- var createdAfter = moment(item.val),
- endDate = query.createdBefore != null ? moment(query.createdBefore) : moment(),
- createdBefore = index < items.length - 1 ? moment(items[index + 1].val).subtract(1, 'days') : endDate,
- isSameDay = createdBefore.diff(createdAfter, 'days') <= 1;
- if (isSameDay) {
- createdBefore.add(1, 'days');
- }
- var r = _.extend({}, query, {
- createdAfter: createdAfter.format('YYYY-MM-DD'),
- createdBefore: createdBefore.format('YYYY-MM-DD')
- });
- if (mode === 'debt') {
- r.facetMode = 'debt';
- }
- if (r.componentKey != null) {
- return '/component_issues/index?id=' + encodeURIComponent(r.componentKey) +
- '#' + getQuery(_.omit(r, 'componentKey'));
- } else {
- return '/issues/search#' + getQuery(r);
- }
- }
- }
- };
+ }
+ }
+};
function getQuery (query, separator) {
separator = separator || '|';
- var route = [];
+ const route = [];
_.forEach(query, function (value, property) {
route.push('' + property + '=' + encodeURIComponent(value));
});
@@ -214,12 +214,12 @@ function getQuery (query, separator) {
export default Marionette.ItemView.extend({
- getTemplate: function () {
+ getTemplate () {
return this.conf != null && this.conf.template != null ?
this.conf.template : Template;
},
- initialize: function () {
+ initialize () {
this.shouldIgnorePeriod = false;
this.model = new Backbone.Model({
query: this.options.query,
@@ -239,11 +239,11 @@ export default Marionette.ItemView.extend({
this.requestIssues();
},
- getParsedQuery: function () {
- var queryString = this.options.query || '',
- query = {};
+ getParsedQuery () {
+ const queryString = this.options.query || '';
+ const query = {};
queryString.split('|').forEach(function (criterionString) {
- var criterion = criterionString.split('=');
+ const criterion = criterionString.split('=');
if (criterion.length === 2) {
query[criterion[0]] = criterion[1];
}
@@ -259,52 +259,52 @@ export default Marionette.ItemView.extend({
return query;
},
- hasDateFilter: function (query) {
- var q = query || this.model.get('parsedQuery');
+ hasDateFilter (query) {
+ const q = query || this.model.get('parsedQuery');
return _.some(['createdAt', 'createdBefore', 'createdAfter', 'createdInLast'], function (p) {
return q[p] != null;
});
},
- sortItems: function (items) {
- var comparator = this.conf != null && this.conf.comparator != null ? this.conf.comparator : defaultComparator;
+ sortItems (items) {
+ const comparator = this.conf != null && this.conf.comparator != null ? this.conf.comparator : defaultComparator;
return _.sortBy(items, comparator);
},
- filterItems: function (items) {
- var filter = this.conf != null && this.conf.filter != null ? this.conf.filter : defaultFilter;
+ filterItems (items) {
+ const filter = this.conf != null && this.conf.filter != null ? this.conf.filter : defaultFilter;
return _.filter(items, filter, { query: this.query, property: this.options.distributionAxis });
},
- withLink: function (items) {
- var link = this.conf != null && this.conf.link != null ? this.conf.link : defaultLink,
- property = this.options.distributionAxis,
- mode = this.options.displayMode,
- query = this.model.get('parsedQuery');
+ withLink (items) {
+ const link = this.conf != null && this.conf.link != null ? this.conf.link : defaultLink;
+ const property = this.options.distributionAxis;
+ const mode = this.options.displayMode;
+ const query = this.model.get('parsedQuery');
return items.map(function (item, index) {
return _.extend(item, { searchLink: link(item, property, query, index, items, mode) });
});
},
- withLabels: function (items) {
- var label = this.conf != null && this.conf.label != null ? this.conf.label : defaultLabel,
- r = this.model.get('rawResponse'),
- query = this.model.get('parsedQuery');
+ withLabels (items) {
+ const label = this.conf != null && this.conf.label != null ? this.conf.label : defaultLabel;
+ const r = this.model.get('rawResponse');
+ const query = this.model.get('parsedQuery');
return items.map(function (item, index) {
return _.extend(item, { label: label(item, r, items, index, query) });
});
},
- requestIssues: function () {
- var that = this,
- facetMode = this.options.displayMode,
- url = '/api/issues/search',
- options = _.extend({}, this.query, {
- ps: 1,
- facets: this.options.distributionAxis,
- facetMode: facetMode,
- additionalFields: '_all'
- });
+ requestIssues () {
+ const that = this;
+ const facetMode = this.options.displayMode;
+ const url = '/api/issues/search';
+ const options = _.extend({}, this.query, {
+ ps: 1,
+ facets: this.options.distributionAxis,
+ facetMode,
+ additionalFields: '_all'
+ });
if (this.options.componentUuid != null) {
_.extend(options, { componentUuids: this.options.componentUuid });
}
@@ -315,9 +315,9 @@ export default Marionette.ItemView.extend({
if (_.isArray(r.facets) && r.facets.length === 1) {
// save response object, but do not trigger repaint
that.model.set({ rawResponse: r }, { silent: true });
- var items = that.sortItems(that.withLabels(that.withLink(that.filterItems(r.facets[0].values))));
+ const items = that.sortItems(that.withLabels(that.withLink(that.filterItems(r.facets[0].values))));
that.model.set({
- items: items,
+ items,
maxResultsReached: items.length >= FACET_LIMIT,
maxResults: items.length,
total: facetMode === 'debt' ? r.debtTotal : r.total
@@ -326,7 +326,7 @@ export default Marionette.ItemView.extend({
});
},
- serializeData: function () {
+ serializeData () {
return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
displayMode: this.options.displayMode
});
diff --git a/server/sonar-web/src/main/js/widgets/old/base.js b/server/sonar-web/src/main/js/widgets/old/base.js
index 4dfcf5f9434..caae96c917c 100644
--- a/server/sonar-web/src/main/js/widgets/old/base.js
+++ b/server/sonar-web/src/main/js/widgets/old/base.js
@@ -42,7 +42,7 @@ import _ from 'underscore';
BaseWidget.prototype.addField = function (name, defaultValue) {
- var privateName = '_' + name;
+ const privateName = '_' + name;
this[privateName] = defaultValue;
this[name] = function (d) {
return this.param.call(this, privateName, d);
@@ -59,10 +59,10 @@ import _ from 'underscore';
};
BaseWidget.prototype.addMetric = function (property, index) {
- var key = this.metricsPriority()[index];
+ const key = this.metricsPriority()[index];
this[property] = _.extend(this.metrics()[key], {
- key: key,
- value: function (d) {
+ key,
+ value (d) {
if (d.measures[key] != null) {
if (d.measures[key].text != null) {
return d.measures[key].text;
@@ -73,7 +73,7 @@ import _ from 'underscore';
}
}
},
- formattedValue: function (d) {
+ formattedValue (d) {
if (d.measures[key] != null) {
if (d.measures[key].text != null) {
return d.measures[key].text;
@@ -101,7 +101,7 @@ import _ from 'underscore';
BaseWidget.prototype.tooltip = function (d) {
/* jshint nonbsp: false */
- var title = d.longName;
+ let title = d.longName;
if (this.colorMetric && (this.colorMetric.value(d) != null)) {
title += '\n' + this.colorMetric.name + ': ' + (this.colorMetric.formattedValue(d));
}
diff --git a/server/sonar-web/src/main/js/widgets/old/bubble-chart.js b/server/sonar-web/src/main/js/widgets/old/bubble-chart.js
index a282c49e5eb..9e9d4ac1a33 100644
--- a/server/sonar-web/src/main/js/widgets/old/bubble-chart.js
+++ b/server/sonar-web/src/main/js/widgets/old/bubble-chart.js
@@ -86,18 +86,18 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.hasValidData = function () {
- var widget = this,
- noInvalidEntry = true,
- atLeastOneValueOnX = false,
- atLeastOneValueOnY = false;
- this.components().forEach(function(component) {
+ const widget = this;
+ let noInvalidEntry = true;
+ let atLeastOneValueOnX = false;
+ let atLeastOneValueOnY = false;
+ this.components().forEach(function (component) {
noInvalidEntry = noInvalidEntry &&
- !!component.measures[widget.metricsPriority()[0]] &&
- !!component.measures[widget.metricsPriority()[1]];
+ !!component.measures[widget.metricsPriority()[0]] &&
+ !!component.measures[widget.metricsPriority()[1]];
atLeastOneValueOnX = atLeastOneValueOnX ||
- (component.measures[widget.metricsPriority()[0]] || {}).fval !== '-';
+ (component.measures[widget.metricsPriority()[0]] || {}).fval !== '-';
atLeastOneValueOnY = atLeastOneValueOnY ||
- (component.measures[widget.metricsPriority()[1]] || {}).fval !== '-';
+ (component.measures[widget.metricsPriority()[1]] || {}).fval !== '-';
});
return !!noInvalidEntry && !!atLeastOneValueOnX && !!atLeastOneValueOnY;
};
@@ -128,27 +128,27 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.initMetrics = function () {
- var widget = this;
+ const widget = this;
this.xMetric = this.metricsPriority()[0];
- this.getXMetric = function(d) {
+ this.getXMetric = function (d) {
return d.measures[widget.xMetric].val;
};
this.yMetric = this.metricsPriority()[1];
- this.getYMetric = function(d) {
+ this.getYMetric = function (d) {
return d.measures[widget.yMetric].val;
};
this.sizeMetric = this.metricsPriority()[2];
- this.getSizeMetric = function(d) {
+ this.getSizeMetric = function (d) {
return d.measures[widget.sizeMetric] ? d.measures[widget.sizeMetric].val : 0;
};
};
window.SonarWidgets.BubbleChart.prototype.initScales = function () {
- var widget = this;
+ const widget = this;
this
.xLog(this.options().xLog)
.yLog(this.options().yLog);
@@ -172,10 +172,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
return widget.getSizeMetric(d);
}));
} else {
- var singleComponent = this.components()[0],
- xm = this.getXMetric(singleComponent),
- ym = this.getYMetric(singleComponent),
- sm = this.getSizeMetric(singleComponent);
+ const singleComponent = this.components()[0];
+ const xm = this.getXMetric(singleComponent);
+ const ym = this.getYMetric(singleComponent);
+ const sm = this.getSizeMetric(singleComponent);
this.x.domain([xm * 0.8, xm * 1.2]);
this.y.domain([ym * 0.8, ym * 1.2]);
this.size.domain([sm * 0.8, sm * 1.2]);
@@ -184,7 +184,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.initBubbles = function () {
- var widget = this;
+ const widget = this;
// Create bubbles
this.items = this.plotWrap.selectAll('.item')
@@ -212,13 +212,12 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.style('transition', 'all 0.2s ease')
.attr('title', function (d) {
- var xMetricName = widget.metrics()[widget.xMetric].name,
- yMetricName = widget.metrics()[widget.yMetric].name,
- sizeMetricName = widget.metrics()[widget.sizeMetric].name,
-
- xMetricValue = d.measures[widget.xMetric].fval,
- yMetricValue = d.measures[widget.yMetric].fval,
- sizeMetricValue = d.measures[widget.sizeMetric].fval;
+ const xMetricName = widget.metrics()[widget.xMetric].name;
+ const yMetricName = widget.metrics()[widget.yMetric].name;
+ const sizeMetricName = widget.metrics()[widget.sizeMetric].name;
+ const xMetricValue = d.measures[widget.xMetric].fval;
+ const yMetricValue = d.measures[widget.yMetric].fval;
+ const sizeMetricValue = d.measures[widget.sizeMetric].fval;
return '<div class="text-left">' +
collapsedDirFromPath(d.longName) + '<br>' +
@@ -240,7 +239,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.initBubbleEvents = function () {
- var widget = this;
+ const widget = this;
this.items
.on('click', function (d) {
window.location = widget.options().baseUrl + '?id=' + encodeURIComponent(d.key);
@@ -296,7 +295,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.render = function (container) {
- var containerS = container;
+ const containerS = container;
container = d3.select(container);
@@ -321,27 +320,27 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.adjustScalesAfterUpdate = function () {
- var widget = this;
+ const widget = this;
// X
- var minX = d3.min(this.components(), function (d) {
- return widget.x(widget.getXMetric(d)) - widget.size(widget.getSizeMetric(d));
- }),
- maxX = d3.max(this.components(), function (d) {
- return widget.x(widget.getXMetric(d)) + widget.size(widget.getSizeMetric(d));
- }),
- dMinX = minX < 0 ? this.x.range()[0] - minX : this.x.range()[0],
- dMaxX = maxX > this.x.range()[1] ? maxX - this.x.range()[1] : 0;
+ const minX = d3.min(this.components(), function (d) {
+ return widget.x(widget.getXMetric(d)) - widget.size(widget.getSizeMetric(d));
+ });
+ const maxX = d3.max(this.components(), function (d) {
+ return widget.x(widget.getXMetric(d)) + widget.size(widget.getSizeMetric(d));
+ });
+ const dMinX = minX < 0 ? this.x.range()[0] - minX : this.x.range()[0];
+ const dMaxX = maxX > this.x.range()[1] ? maxX - this.x.range()[1] : 0;
this.x.range([dMinX, this.availableWidth - dMaxX]);
// Y
- var minY = d3.min(this.components(), function (d) {
- return widget.y(widget.getYMetric(d)) - widget.size(widget.getSizeMetric(d));
- }),
- maxY = d3.max(this.components(), function (d) {
- return widget.y(widget.getYMetric(d)) + widget.size(widget.getSizeMetric(d));
- }),
- dMinY = minY < 0 ? this.y.range()[1] - minY: this.y.range()[1],
- dMaxY = maxY > this.y.range()[0] ? maxY - this.y.range()[0] : 0;
+ const minY = d3.min(this.components(), function (d) {
+ return widget.y(widget.getYMetric(d)) - widget.size(widget.getSizeMetric(d));
+ });
+ const maxY = d3.max(this.components(), function (d) {
+ return widget.y(widget.getYMetric(d)) + widget.size(widget.getSizeMetric(d));
+ });
+ const dMinY = minY < 0 ? this.y.range()[1] - minY : this.y.range()[1];
+ const dMaxY = maxY > this.y.range()[0] ? maxY - this.y.range()[0] : 0;
this.y.range([this.availableHeight - dMaxY, dMinY]);
@@ -349,7 +348,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// X
if (this.xLog()) {
this.xAxis.tickFormat(function (d) {
- var ticksCount = widget.availableWidth / 50;
+ const ticksCount = widget.availableWidth / 50;
return widget.x.tickFormat(ticksCount, d3.format(',d'))(d);
});
}
@@ -357,7 +356,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Y
if (this.yLog()) {
this.yAxis.tickFormat(function (d) {
- var ticksCount = widget.availableHeight / 30;
+ const ticksCount = widget.availableHeight / 30;
return widget.y.tickFormat(ticksCount, d3.format(',d'))(d);
});
}
@@ -369,7 +368,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.updateScales = function () {
- var widget = this;
+ const widget = this;
this.x.range([0, this.availableWidth]);
this.y.range([this.availableHeight, 0]);
@@ -381,10 +380,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
return widget.getYMetric(d);
}));
} else {
- var singleComponent = this.components()[0],
- xm = this.getXMetric(singleComponent),
- ym = this.getYMetric(singleComponent),
- sm = this.getSizeMetric(singleComponent);
+ const singleComponent = this.components()[0];
+ const xm = this.getXMetric(singleComponent);
+ const ym = this.getYMetric(singleComponent);
+ const sm = this.getSizeMetric(singleComponent);
this.x.domain([xm * 0.8, xm * 1.2]);
this.y.domain([ym * 0.8, ym * 1.2]);
this.size.domain([sm * 0.8, sm * 1.2]);
@@ -399,14 +398,14 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Avoid zero values when using log scale
if (this.xLog) {
- var xDomain = this.x.domain();
+ const xDomain = this.x.domain();
this.x
.domain([xDomain[0] > 0 ? xDomain[0] : 0.1, xDomain[1]])
.clamp(true);
}
if (this.yLog) {
- var yDomain = this.y.domain();
+ const yDomain = this.y.domain();
this.y
.domain([yDomain[0] > 0 ? yDomain[0] : 0.1, yDomain[1]])
.clamp(true);
@@ -415,7 +414,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.updateBubbles = function () {
- var widget = this;
+ const widget = this;
this.items
.transition()
.attr('transform', function (d) {
@@ -456,14 +455,14 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.updateGrid = function () {
- var widget = this;
+ const widget = this;
this.gxGridLines
.transition()
.attr({
- x1: function (d) {
+ x1 (d) {
return widget.x(d);
},
- x2: function (d) {
+ x2 (d) {
return widget.x(d);
},
y1: widget.y.range()[0],
@@ -475,10 +474,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.attr({
x1: widget.x.range()[0],
x2: widget.x.range()[1],
- y1: function (d) {
+ y1 (d) {
return widget.y(d);
},
- y2: function (d) {
+ y2 (d) {
return widget.y(d);
}
});
@@ -488,7 +487,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.BubbleChart.prototype.update = function (container) {
container = d3.select(container);
- var width = container.property('offsetWidth');
+ const width = container.property('offsetWidth');
this.width(width > 100 ? width : 100);
@@ -509,7 +508,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
window.SonarWidgets.BubbleChart.defaults = {
width: 350,
height: 150,
@@ -521,11 +519,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
// Some helper functions
// Gets or sets parameter
- function param(name, value) {
+ function param (name, value) {
if (value == null) {
return this[name];
} else {
@@ -535,7 +532,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
}
// Helper for create the translate(x, y) string
- function trans(left, top) {
+ function trans (left, top) {
return 'translate(' + left + ', ' + top + ')';
}
diff --git a/server/sonar-web/src/main/js/widgets/old/histogram.js b/server/sonar-web/src/main/js/widgets/old/histogram.js
index 5af5dae98a4..9829f8c2537 100644
--- a/server/sonar-web/src/main/js/widgets/old/histogram.js
+++ b/server/sonar-web/src/main/js/widgets/old/histogram.js
@@ -35,26 +35,26 @@
Histogram.prototype.barFill = '#1f77b4';
Histogram.prototype.isDataValid = function () {
- var that = this;
+ const that = this;
return this.components().reduce(function (p, c) {
return p && !!c.measures[that.mainMetric.key];
}, true);
};
Histogram.prototype.truncate = function (text, type) {
- var maxLength = 40;
+ const maxLength = 40;
+ const n = text.length;
+
switch (type) {
case 'FIL':
case 'CLA':
- var n = text.length;
if (n > maxLength) {
- var shortText = text.substr(n - maxLength + 2, n - 1),
- dotIndex = shortText.indexOf('.');
+ const shortText = text.substr(n - maxLength + 2, n - 1);
+ const dotIndex = shortText.indexOf('.');
return '...' + shortText.substr(dotIndex + 1);
} else {
return text;
}
- break;
default:
if (text.length > maxLength) {
return text.substr(0, maxLength - 3) + '...';
@@ -65,7 +65,7 @@
};
Histogram.prototype.render = function (container) {
- var box = d3.select(container);
+ const box = d3.select(container);
this.addMetric('mainMetric', 0);
if (!this.isDataValid()) {
box.text(this.options().noMainMetric);
@@ -88,19 +88,19 @@
};
Histogram.prototype.update = function (container) {
- var that = this;
- var box = d3.select(container);
+ const that = this;
+ const box = d3.select(container);
this.width(box.property('offsetWidth'));
- var availableWidth = this.width() - this.margin().left - this.margin().right - this.legendWidth(),
- availableHeight = this.barHeight * this.components().length + this.lineHeight,
- totalHeight = availableHeight + this.margin().top + this.margin().bottom;
+ const availableWidth = this.width() - this.margin().left - this.margin().right - this.legendWidth();
+ const availableHeight = this.barHeight * this.components().length + this.lineHeight;
+ let totalHeight = availableHeight + this.margin().top + this.margin().bottom;
if (this.maxResultsReached()) {
totalHeight += this.lineHeight;
}
this.height(totalHeight);
this.svg.attr('width', this.width()).attr('height', this.height());
this.plotWrap.attr('transform', this.trans(0, this.lineHeight));
- var xDomain = d3.extent(this.components(), function (d) {
+ let xDomain = d3.extent(this.components(), function (d) {
return that.mainMetric.value(d);
});
if (!this.options().relativeScale) {
diff --git a/server/sonar-web/src/main/js/widgets/old/pie-chart.js b/server/sonar-web/src/main/js/widgets/old/pie-chart.js
index 43bcabfff95..0508af5152a 100644
--- a/server/sonar-web/src/main/js/widgets/old/pie-chart.js
+++ b/server/sonar-web/src/main/js/widgets/old/pie-chart.js
@@ -83,13 +83,13 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
window.SonarWidgets.PieChart.prototype.render = function (container) {
- var widget = this,
- containerS = container;
+ const widget = this;
+ const containerS = container;
container = d3.select(container);
- var validData = this.components().reduce(function(p, c) {
+ const validData = this.components().reduce(function (p, c) {
return p && !!c.measures[widget.metricsPriority()[0]];
}, true);
@@ -114,7 +114,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Configure metrics
this.mainMetric = this.metricsPriority()[0];
- this.getMainMetric = function(d) {
+ this.getMainMetric = function (d) {
return d.measures[widget.mainMetric].val;
};
@@ -131,7 +131,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Configure pie
this.pie = d3.layout.pie()
.sort(null)
- .value(function(d) { return widget.getMainMetric(d); });
+ .value(function (d) { return widget.getMainMetric(d); });
// Configure legend
@@ -172,7 +172,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.PieChart.prototype.updateLegend = function () {
- var widget = this;
+ const widget = this;
this.legendWrap
.attr('transform', trans(
this.legendMargin() + 2 * this.radius,
@@ -185,12 +185,12 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this.legendsEnter = this.legends.enter()
.append('g')
.classed('legend pie-legend', true)
- .attr('transform', function(d, i) { return trans(0, 10 + i * widget._lineHeight); });
+ .attr('transform', function (d, i) { return trans(0, 10 + i * widget._lineHeight); });
this.legendsEnter.append('circle')
.attr('class', 'legend-bullet')
.attr('r', 4)
- .style('fill', function(d, i) { return widget.color(i); });
+ .style('fill', function (d, i) { return widget.color(i); });
this.legendsEnter.append('text')
.attr('class', 'legend-text')
@@ -198,14 +198,14 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.attr('transform', trans(10, 3));
this.legends.selectAll('text')
- .text(function(d) {
+ .text(function (d) {
return d.name.length > widget._legendSymbols ? d.name.substr(0, widget._legendSymbols) + '...' : d.name;
});
};
window.SonarWidgets.PieChart.prototype.updateDetails = function () {
- var widget = this;
+ const widget = this;
this.detailsWrap
.attr('width', this.legendWidth())
.attr('transform', trans(
@@ -216,7 +216,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.transition()
.style('font-size', (this.radius / 6) + 'px');
- var fz = Math.min(
+ const fz = Math.min(
12,
this.radius / 10,
1.5 * this.radius / this.metrics()[this.mainMetric].name.length
@@ -228,110 +228,106 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.PieChart.prototype.configureEvents = function () {
- var widget = this;
- var updateMetrics = function(metrics) {
- widget.detailsMetrics = widget.detailsWrap.selectAll('.details-metric')
- .data(metrics);
-
- widget.detailsMetrics.enter().append('text')
- .classed('details-metric', true)
- .classed('details-metric-main', function(d, i) { return i === 0; })
- .attr('transform', function(d, i) { return trans(10, i * widget._lineHeight); })
- .attr('dy', '1.2em');
-
- widget.detailsMetrics
- .text(function(d) { return d.name + (d.value ? ': ' + d.value : ''); })
- .style('opacity', 1);
-
- widget.detailsMetrics.exit().remove();
- },
- enterHandler = function(sector, d, i, showDetails) {
- if (showDetails) {
- var metrics = widget.metricsPriority().map(function(m) {
- return {
- name: widget.metrics()[m].name,
- value: (d.measures[m] ? d.measures[m].fval : '–')
- };
- });
- metrics.unshift({
- name: (d.name.length > widget._legendSymbols ? d.name.substr(0, widget._legendSymbols) + '...' : d.name)
- });
- updateMetrics(metrics);
-
- widget.legendWrap
- .style('opacity', 0);
-
- widget.detailsColorIndicator
- .style('opacity', 1)
- .style('fill', widget.color(i));
-
- widget.detailsWrap
- .style('display', 'block');
- }
- widget.donutLabel
- .style('opacity', 1)
- .text(d.measures[widget.mainMetric].fval);
- widget.donutLabel
- .style('opacity', 1);
- widget.plotWrap
- .classed('hover', true);
- sector.
- classed('hover', true);
- },
-
- leaveHandler = function(sector) {
- widget.legendWrap
- .style('opacity', 1);
- widget.detailsColorIndicator
- .style('opacity', 0);
- if (widget.detailsMetrics) {
- widget.detailsMetrics
- .style('opacity', 0);
- }
- widget.donutLabel
- .style('opacity', 0)
- .text('');
- widget.plotWrap
- .classed('hover', false);
- sector.
- classed('hover', false);
- widget.detailsWrap
- .style('display', 'none');
- },
-
- clickHandler = function(d) {
- window.location = widget.options().baseUrl + '?id=' + encodeURIComponent(d.key);
- };
+ const widget = this;
+ const updateMetrics = function (metrics) {
+ widget.detailsMetrics = widget.detailsWrap.selectAll('.details-metric')
+ .data(metrics);
+
+ widget.detailsMetrics.enter().append('text')
+ .classed('details-metric', true)
+ .classed('details-metric-main', function (d, i) { return i === 0; })
+ .attr('transform', function (d, i) { return trans(10, i * widget._lineHeight); })
+ .attr('dy', '1.2em');
+
+ widget.detailsMetrics
+ .text(function (d) { return d.name + (d.value ? ': ' + d.value : ''); })
+ .style('opacity', 1);
+
+ widget.detailsMetrics.exit().remove();
+ };
+ const enterHandler = function (sector, d, i, showDetails) {
+ if (showDetails) {
+ const metrics = widget.metricsPriority().map(function (m) {
+ return {
+ name: widget.metrics()[m].name,
+ value: (d.measures[m] ? d.measures[m].fval : '–')
+ };
+ });
+ metrics.unshift({
+ name: (d.name.length > widget._legendSymbols ? d.name.substr(0, widget._legendSymbols) + '...' : d.name)
+ });
+ updateMetrics(metrics);
+
+ widget.legendWrap
+ .style('opacity', 0);
+
+ widget.detailsColorIndicator
+ .style('opacity', 1)
+ .style('fill', widget.color(i));
+
+ widget.detailsWrap
+ .style('display', 'block');
+ }
+ widget.donutLabel
+ .style('opacity', 1)
+ .text(d.measures[widget.mainMetric].fval);
+ widget.donutLabel
+ .style('opacity', 1);
+ widget.plotWrap
+ .classed('hover', true);
+ sector.classed('hover', true);
+ };
+ const leaveHandler = function (sector) {
+ widget.legendWrap
+ .style('opacity', 1);
+ widget.detailsColorIndicator
+ .style('opacity', 0);
+ if (widget.detailsMetrics) {
+ widget.detailsMetrics
+ .style('opacity', 0);
+ }
+ widget.donutLabel
+ .style('opacity', 0)
+ .text('');
+ widget.plotWrap
+ .classed('hover', false);
+ sector.classed('hover', false);
+ widget.detailsWrap
+ .style('display', 'none');
+ };
+ const clickHandler = function (d) {
+ window.location = widget.options().baseUrl + '?id=' + encodeURIComponent(d.key);
+ };
this.sectors
- .on('mouseenter', function(d, i) {
+ .on('mouseenter', function (d, i) {
return enterHandler(d3.select(this), d.data, i, true);
})
- .on('mouseleave', function() {
+ .on('mouseleave', function () {
return leaveHandler(d3.select(this));
})
- .on('click', function(d) {
+ .on('click', function (d) {
return clickHandler(d.data);
});
this.legends
- .on('mouseenter', function(d, i) {
+ .on('mouseenter', function (d, i) {
return enterHandler(d3.select(widget.sectors[0][i]), d, i, false);
})
- .on('mouseleave', function(d, i) {
+ .on('mouseleave', function (d, i) {
return leaveHandler(d3.select(widget.sectors[0][i]));
})
- .on('click', function(d) {
+ .on('click', function (d) {
return clickHandler(d);
});
};
- window.SonarWidgets.PieChart.prototype.update = function(container) {
+ window.SonarWidgets.PieChart.prototype.update = function (container) {
container = d3.select(container);
- var widget = this,
- width = container.property('offsetWidth');
+ const widget = this;
+ const width = container.property('offsetWidth');
this.width(width > 100 ? width : 100);
@@ -370,7 +366,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.enter()
.append('path')
.classed('arc', true)
- .style('fill', function(d, i) { return widget.color(i); });
+ .style('fill', function (d, i) { return widget.color(i); });
this.sectors
.transition()
@@ -386,7 +382,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
window.SonarWidgets.PieChart.defaults = {
width: 350,
height: 300,
@@ -396,11 +391,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
// Some helper functions
// Gets or sets parameter
- function param(name, value) {
+ function param (name, value) {
if (value == null) {
return this[name];
} else {
@@ -410,7 +404,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
}
// Helper for create the translate(x, y) string
- function trans(left, top) {
+ function trans (left, top) {
return 'translate(' + left + ', ' + top + ')';
}
diff --git a/server/sonar-web/src/main/js/widgets/old/stack-area.js b/server/sonar-web/src/main/js/widgets/old/stack-area.js
index 5ed66cb01db..f8f9fb61327 100644
--- a/server/sonar-web/src/main/js/widgets/old/stack-area.js
+++ b/server/sonar-web/src/main/js/widgets/old/stack-area.js
@@ -74,34 +74,34 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
- window.SonarWidgets.StackArea.prototype.initScales = function() {
- var widget = this,
- colorsLength = widget.colors().length;
- var timeDomain = this.data()
- .map(function(_) {
- return d3.extent(_, function(d) {
+ window.SonarWidgets.StackArea.prototype.initScales = function () {
+ const widget = this;
+ const colorsLength = widget.colors().length;
+ const timeDomain = this.data()
+ .map(function (_) {
+ return d3.extent(_, function (d) {
return d.x;
});
})
- .reduce(function(p, c) {
+ .reduce(function (p, c) {
return p.concat(c);
}, []);
this.time = d3.time.scale().domain(d3.extent(timeDomain));
this.y = d3.scale.linear()
- .domain([0, d3.max(this.stackDataTop, function(d) {
+ .domain([0, d3.max(this.stackDataTop, function (d) {
return d.y0 + d.y;
})])
.nice();
- this.color = function(i) {
+ this.color = function (i) {
return widget.colors()[i % colorsLength][0];
};
};
- window.SonarWidgets.StackArea.prototype.initAxis = function() {
+ window.SonarWidgets.StackArea.prototype.initAxis = function () {
this.timeAxis = d3.svg.axis()
.scale(this.time)
.orient('bottom')
@@ -109,21 +109,21 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
- window.SonarWidgets.StackArea.prototype.initArea = function() {
- var widget = this;
+ window.SonarWidgets.StackArea.prototype.initArea = function () {
+ const widget = this;
this.area = d3.svg.area()
- .x(function(d) { return widget.time(d.x); })
- .y0(function(d) { return widget.y(d.y0); })
- .y1(function(d) { return widget.y(d.y0 + d.y); });
+ .x(function (d) { return widget.time(d.x); })
+ .y0(function (d) { return widget.y(d.y0); })
+ .y1(function (d) { return widget.y(d.y0 + d.y); });
this.areaLine = d3.svg.line()
- .x(function(d) { return widget.time(d.x); })
- .y(function(d) { return widget.y(d.y0 + d.y); });
+ .x(function (d) { return widget.time(d.x); })
+ .y(function (d) { return widget.y(d.y0 + d.y); });
};
- window.SonarWidgets.StackArea.prototype.initInfo = function() {
- var widget = this;
+ window.SonarWidgets.StackArea.prototype.initInfo = function () {
+ const widget = this;
this.infoWrap
.attr('class', 'info')
.attr('transform', trans(0, -60));
@@ -141,11 +141,11 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.attr('transform', trans(0, 54));
this.infoMetrics = [];
- var prevX = 120;
- this.metrics().forEach(function(d, i) {
- var infoMetric = widget.infoWrap.append('g');
+ let prevX = 120;
+ this.metrics().forEach(function (d, i) {
+ const infoMetric = widget.infoWrap.append('g');
- var infoMetricText = infoMetric.append('text')
+ const infoMetricText = infoMetric.append('text')
.attr('class', 'info-text-small')
.attr('transform', trans(10, 0))
.text(widget.metrics()[i]);
@@ -153,11 +153,11 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
infoMetric.append('circle')
.attr('transform', trans(0, -4))
.attr('r', 4)
- .style('fill', function() { return widget.color(i); });
+ .style('fill', function () { return widget.color(i); });
// Align metric labels
infoMetric
- .attr('transform', function() {
+ .attr('transform', function () {
return trans(prevX, -1 + (i % 3) * 18);
});
@@ -170,10 +170,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
- window.SonarWidgets.StackArea.prototype.initEvents = function() {
- var widget = this;
+ window.SonarWidgets.StackArea.prototype.initEvents = function () {
+ const widget = this;
this.events = widget.snapshots()
- .filter(function(d) { return d.e.length > 0; });
+ .filter(function (d) { return d.e.length > 0; });
this.gevents = this.gWrap.append('g')
.attr('class', 'axis events')
@@ -185,11 +185,11 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.attr('y2', -8);
- this.selectSnapshot = function(cl) {
- var dataX = widget.data()[0][cl].x,
- sx = widget.time(dataX),
- snapshotIndex = null,
- eventIndex = null;
+ this.selectSnapshot = function (cl) {
+ const dataX = widget.data()[0][cl].x;
+ const sx = widget.time(dataX);
+ let snapshotIndex = null;
+ let eventIndex = null;
// Update scanner position
widget.scanner
@@ -198,18 +198,18 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Update metric labels
- var metricsLines = widget.data().map(function(d, i) {
- var value = d[cl].fy || d[cl].y;
+ const metricsLines = widget.data().map(function (d, i) {
+ const value = d[cl].fy || d[cl].y;
return widget.metrics()[i] + ': ' + value;
});
- metricsLines.forEach(function(d, i) {
+ metricsLines.forEach(function (d, i) {
widget.infoMetrics[i].select('text').text(d);
});
// Update snapshot info
- this.snapshots().forEach(function(d, i) {
+ this.snapshots().forEach(function (d, i) {
if (d.d - dataX === 0) {
snapshotIndex = i;
}
@@ -225,14 +225,14 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
widget.infoDate
.text(moment(widget.data()[0][cl].x).format('LL'));
- var snapshotValue = this.snapshots()[snapshotIndex].fy,
- totalValue = snapshotValue || (widget.stackDataTop[cl].y0 + widget.stackDataTop[cl].y);
+ const snapshotValue = this.snapshots()[snapshotIndex].fy;
+ const totalValue = snapshotValue || (widget.stackDataTop[cl].y0 + widget.stackDataTop[cl].y);
widget.infoTotal
.text('Total: ' + totalValue);
// Update event
- this.events.forEach(function(d, i) {
+ this.events.forEach(function (d, i) {
if (d.d - dataX === 0) {
eventIndex = i;
}
@@ -244,9 +244,9 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Set event listeners
- this.svg.on('mousemove', function() {
- var mx = d3.mouse(widget.plotWrap.node())[0],
- cl = closest(widget.data()[0], mx, function(d) { return widget.time(d.x); });
+ this.svg.on('mousemove', function () {
+ const mx = d3.mouse(widget.plotWrap.node())[0];
+ const cl = closest(widget.data()[0], mx, function (d) { return widget.time(d.x); });
widget.selectSnapshot(cl);
});
};
@@ -296,9 +296,9 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
- window.SonarWidgets.StackArea.prototype.update = function() {
- var widget = this,
- width = this.container.property('offsetWidth');
+ window.SonarWidgets.StackArea.prototype.update = function () {
+ const widget = this;
+ const width = this.container.property('offsetWidth');
this.width(width > 100 ? width : 100);
@@ -330,15 +330,15 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.enter()
.insert('path', ':first-child')
.attr('class', 'area')
- .attr('d', function(d) { return widget.area(d); })
- .style('fill', function(d, i) { return widget.color(i); });
+ .attr('d', function (d) { return widget.area(d); })
+ .style('fill', function (d, i) { return widget.color(i); });
this.gareaLine = this.plotWrap.selectAll('.area-line')
.data(this.stackData)
.enter()
.insert('path')
.attr('class', 'area-line')
- .attr('d', function(d) { return widget.areaLine(d); })
+ .attr('d', function (d) { return widget.areaLine(d); })
.style('fill', 'none')
.style('stroke', '#808080');
@@ -350,7 +350,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Update events
this.gevents
.transition()
- .attr('transform', function(d) {
+ .attr('transform', function (d) {
return trans(widget.time(d.d), widget.availableHeight + 10);
});
@@ -365,7 +365,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
window.SonarWidgets.StackArea.defaults = {
width: 350,
height: 150,
@@ -373,11 +372,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
// Some helper functions
// Gets or sets parameter
- function param(name, value) {
+ function param (name, value) {
if (value == null) {
return this[name];
} else {
@@ -387,14 +385,14 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
}
// Helper for create the translate(x, y) string
- function trans(left, top) {
+ function trans (left, top) {
return 'translate(' + left + ', ' + top + ')';
}
// Helper for find the closest number in array
- function closest(array, number, getter) {
- var cl = null;
- array.forEach(function(value, i) {
+ function closest (array, number, getter) {
+ let cl = null;
+ array.forEach(function (value, i) {
if (cl == null ||
Math.abs(getter(value) - number) < Math.abs(getter(array[cl]) - number)) {
cl = i;
diff --git a/server/sonar-web/src/main/js/widgets/old/tag-cloud.js b/server/sonar-web/src/main/js/widgets/old/tag-cloud.js
index 3103adc2e94..8a389ae6ba2 100644
--- a/server/sonar-web/src/main/js/widgets/old/tag-cloud.js
+++ b/server/sonar-web/src/main/js/widgets/old/tag-cloud.js
@@ -36,15 +36,15 @@ import { translate } from '../../helpers/l10n';
TagCloud.prototype.sizeLow = 10;
TagCloud.prototype.renderWords = function () {
- var that = this;
+ const that = this;
return window.sonarqube.appStarted.then(function () {
- var words = that.wordContainer.selectAll('.cloud-word').data(that.tags()),
- wordsEnter = words.enter().append('a').classed('cloud-word', true);
+ const words = that.wordContainer.selectAll('.cloud-word').data(that.tags());
+ const wordsEnter = words.enter().append('a').classed('cloud-word', true);
wordsEnter.text(function (d) {
return d.key;
});
wordsEnter.attr('href', function (d) {
- var url = that.options().baseUrl + '|tags=' + d.key;
+ let url = that.options().baseUrl + '|tags=' + d.key;
if (that.options().createdAfter) {
url += '|createdAfter=' + that.options().createdAfter;
}
@@ -67,16 +67,16 @@ import { translate } from '../../helpers/l10n';
};
TagCloud.prototype.render = function (container) {
- var box = d3.select(container).append('div');
+ const box = d3.select(container).append('div');
box.classed('sonar-d3', true);
box.classed('cloud-widget', true);
this.wordContainer = box.append('div');
- var sizeDomain = d3.extent(this.tags(), function (d) {
+ const sizeDomain = d3.extent(this.tags(), function (d) {
return d.value;
});
this.size = d3.scale.linear().domain(sizeDomain).range([this.sizeLow, this.sizeHigh]);
if (this.maxResultsReached()) {
- var maxResultsReachedLabel = box.append('div').text(this.options().maxItemsReachedMessage);
+ const maxResultsReachedLabel = box.append('div').text(this.options().maxItemsReachedMessage);
maxResultsReachedLabel.classed('max-results-reached-message', true);
}
this.renderWords();
@@ -84,8 +84,8 @@ import { translate } from '../../helpers/l10n';
};
TagCloud.prototype.tooltip = function (d) {
- var suffixKey = d.value === 1 ? 'issue' : 'issues',
- suffix = translate(suffixKey);
+ const suffixKey = d.value === 1 ? 'issue' : 'issues';
+ const suffix = translate(suffixKey);
return (d.value + '\u00a0') + suffix;
};
diff --git a/server/sonar-web/src/main/js/widgets/old/timeline.js b/server/sonar-web/src/main/js/widgets/old/timeline.js
index d718ed0ff1d..c41af66c976 100644
--- a/server/sonar-web/src/main/js/widgets/old/timeline.js
+++ b/server/sonar-web/src/main/js/widgets/old/timeline.js
@@ -75,21 +75,21 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.Timeline.prototype.initScalesAndAxis = function () {
// Configure scales
- var timeDomain = this.data()
- .map(function(_) {
- return d3.extent(_, function(d) {
+ const timeDomain = this.data()
+ .map(function (_) {
+ return d3.extent(_, function (d) {
return d.x;
});
})
- .reduce(function(p, c) {
+ .reduce(function (p, c) {
return p.concat(c);
}, []);
this.time = d3.time.scale().domain(d3.extent(timeDomain));
- this.y = this.data().map(function(_) {
+ this.y = this.data().map(function (_) {
return d3.scale.linear()
- .domain(d3.extent(_, function(d) { return d.y; }));
+ .domain(d3.extent(_, function (d) { return d.y; }));
});
this.color = d3.scale.category10();
@@ -103,7 +103,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.Timeline.prototype.initEvents = function () {
- var widget = this;
+ const widget = this;
this.events(this.events().filter(function (event) {
return event.d >= widget.time.domain()[0];
}));
@@ -120,10 +120,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this.gevents.exit().remove();
- this.selectSnapshot = function(cl) {
- var sx = widget.time(widget.data()[0][cl].x);
+ this.selectSnapshot = function (cl) {
+ const sx = widget.time(widget.data()[0][cl].x);
- widget.markers.forEach(function(marker) {
+ widget.markers.forEach(function (marker) {
marker.style('opacity', 0);
d3.select(marker[0][cl]).style('opacity', 1);
});
@@ -135,23 +135,23 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
widget.infoDate
.text(moment(widget.data()[0][cl].x).format('LL'));
- var metricsLines = widget.data().map(function(d, i) {
+ const metricsLines = widget.data().map(function (d, i) {
return widget.metrics()[i] + ': ' + d[cl].yl;
});
- metricsLines.forEach(function(d, i) {
+ metricsLines.forEach(function (d, i) {
widget.infoMetrics[i].select('text').text(d);
});
widget.gevents.attr('y2', -8);
widget.infoEvent.text('');
- widget.events().forEach(function(d, i) {
+ widget.events().forEach(function (d, i) {
if (d.d - widget.data()[0][cl].x === 0) {
d3.select(widget.gevents[0][i]).attr('y2', -12);
widget.infoEvent
.text(widget.events()[i].l
- .map(function(e) { return e.n; })
+ .map(function (e) { return e.n; })
.join(', '));
}
});
@@ -159,16 +159,16 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Set event listeners
- this.svg.on('mousemove', function() {
- var mx = d3.mouse(widget.plotWrap.node())[0],
- cl = closest(widget.data()[0], mx, function(d) { return widget.time(d.x); });
+ this.svg.on('mousemove', function () {
+ const mx = d3.mouse(widget.plotWrap.node())[0];
+ const cl = closest(widget.data()[0], mx, function (d) { return widget.time(d.x); });
widget.selectSnapshot(cl);
});
};
window.SonarWidgets.Timeline.prototype.render = function () {
- var widget = this;
+ const widget = this;
this.svg = this.container.append('svg')
.attr('class', 'sonar-d3');
@@ -202,24 +202,24 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this.lines = [];
this.glines = [];
this.markers = [];
- this.data().forEach(function(_, i) {
- var line = d3.svg.line()
- .x(function(d) { return widget.time(d.x); })
- .y(function(d) { return widget.y[i](d.y); })
+ this.data().forEach(function (_, i) {
+ const line = d3.svg.line()
+ .x(function (d) { return widget.time(d.x); })
+ .y(function (d) { return widget.y[i](d.y); })
.interpolate('linear');
- var gline = widget.plotWrap.append('path')
+ const gline = widget.plotWrap.append('path')
.attr('class', 'line')
- .style('stroke', function() { return widget.color(i); });
+ .style('stroke', function () { return widget.color(i); });
widget.lines.push(line);
widget.glines.push(gline);
- var marker = widget.plotWrap.selectAll('.marker').data(_);
+ const marker = widget.plotWrap.selectAll('.marker').data(_);
marker.enter().append('circle')
.attr('class', 'line-marker')
.attr('r', 3)
- .style('stroke', function() { return widget.color(i); });
+ .style('stroke', function () { return widget.color(i); });
marker.exit().remove();
widget.markers.push(marker);
@@ -240,10 +240,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.attr('transform', trans(0, 0));
this.infoMetrics = [];
- this.metrics().forEach(function(d, i) {
- var infoMetric = widget.infoWrap.append('g')
+ this.metrics().forEach(function (d, i) {
+ const infoMetric = widget.infoWrap.append('g')
.attr('class', 'metric-legend')
- .attr('transform', function() { return trans(110 + i * 150, -1); });
+ .attr('transform', function () { return trans(110 + i * 150, -1); });
infoMetric.append('text')
.attr('class', 'info-text-small')
@@ -253,7 +253,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
.attr('class', 'metric-legend-line')
.attr('transform', trans(0, -4))
.attr('r', 4)
- .style('fill', function() { return widget.color(i); });
+ .style('fill', function () { return widget.color(i); });
widget.infoMetrics.push(infoMetric);
});
@@ -266,20 +266,20 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.Timeline.prototype.showLimitHistoryMessage = function () {
- var minEvent = d3.min(this.events(), function (d) {
- return d.d;
- }),
- minData = this.time.domain()[0];
+ const minEvent = d3.min(this.events(), function (d) {
+ return d.d;
+ });
+ const minData = this.time.domain()[0];
if (minEvent < minData) {
- var maxResultsReachedLabel = this.container.append('div').text(this.limitedHistoricalData);
+ const maxResultsReachedLabel = this.container.append('div').text(this.limitedHistoricalData);
maxResultsReachedLabel.classed('max-results-reached-message', true);
}
};
- window.SonarWidgets.Timeline.prototype.update = function() {
- var widget = this,
- width = this.container.property('offsetWidth');
+ window.SonarWidgets.Timeline.prototype.update = function () {
+ const widget = this;
+ const width = this.container.property('offsetWidth');
this.width(width > 100 ? width : 100);
@@ -295,10 +295,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Update metric lines
- var metricY = -1;
- this.infoMetrics.forEach(function(metric, i) {
- var x = 120 + i * 170,
- x2 = x + 170;
+ let metricY = -1;
+ this.infoMetrics.forEach(function (metric, i) {
+ let x = 120 + i * 170;
+ const x2 = x + 170;
if (x2 > widget.availableWidth) {
metricY += 18;
@@ -307,7 +307,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
metric
.transition()
- .attr('transform', function() { return trans(x, metricY); });
+ .attr('transform', function () { return trans(x, metricY); });
});
if (metricY > -1) {
@@ -322,7 +322,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this.time
.range([0, this.availableWidth]);
- this.y.forEach(function(scale) {
+ this.y.forEach(function (scale) {
scale.range([widget.availableHeight, 0]);
});
@@ -340,7 +340,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
// Update lines and points
- this.data().forEach(function(_, i) {
+ this.data().forEach(function (_, i) {
widget.glines[i]
.transition()
.attr('d', widget.lines[i](_));
@@ -348,7 +348,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
widget.markers[i]
.data(_)
.transition()
- .attr('transform', function(d) { return trans(widget.time(d.x), widget.y[i](d.y)); });
+ .attr('transform', function (d) { return trans(widget.time(d.x), widget.y[i](d.y)); });
});
@@ -363,7 +363,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
this.gevents
.transition()
- .attr('transform', function(d) { return trans(widget.time(d.d), widget.availableHeight + 10 + metricY); });
+ .attr('transform', function (d) { return trans(widget.time(d.d), widget.availableHeight + 10 + metricY); });
// Select latest values if this it the first update
@@ -376,7 +376,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
window.SonarWidgets.Timeline.defaults = {
width: 350,
height: 150,
@@ -384,11 +383,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
};
-
// Some helper functions
// Gets or sets parameter
- function param(name, value) {
+ function param (name, value) {
if (value == null) {
return this[name];
} else {
@@ -398,14 +396,14 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
}
// Helper for create the translate(x, y) string
- function trans(left, top) {
+ function trans (left, top) {
return 'translate(' + left + ', ' + top + ')';
}
// Helper for find the closest number in array
- function closest(array, number, getter) {
- var cl = null;
- array.forEach(function(value, i) {
+ function closest (array, number, getter) {
+ let cl = null;
+ array.forEach(function (value, i) {
if (cl == null ||
Math.abs(getter(value) - number) < Math.abs(getter(array[cl]) - number)) {
cl = i;
diff --git a/server/sonar-web/src/main/js/widgets/old/treemap.js b/server/sonar-web/src/main/js/widgets/old/treemap.js
index e9cde9c8368..8ee32b8397d 100644
--- a/server/sonar-web/src/main/js/widgets/old/treemap.js
+++ b/server/sonar-web/src/main/js/widgets/old/treemap.js
@@ -37,10 +37,10 @@ import { translate } from '../../helpers/l10n';
Treemap.prototype.sizeHigh = 18;
Treemap.prototype.filterComponents = function () {
- var that = this,
- components = this.components().filter(function (d) {
- return that.sizeMetric.value(d) != null;
- });
+ const that = this;
+ const components = this.components().filter(function (d) {
+ return that.sizeMetric.value(d) != null;
+ });
this.components(components);
};
@@ -53,7 +53,7 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.renderTreemap = function () {
- var that = this;
+ const that = this;
this.filterComponents();
if (!this.components().length) {
this.maxResultsReachedLabel
@@ -61,11 +61,11 @@ import { translate } from '../../helpers/l10n';
.style('display', 'block');
return;
}
- var nodes = this.getNodes();
+ const nodes = this.getNodes();
this.color = that.getColorScale();
this.cells = this.box.selectAll('.treemap-cell').data(nodes);
this.cells.exit().remove();
- var cellsEnter = this.cells.enter().append('div');
+ const cellsEnter = this.cells.enter().append('div');
cellsEnter.classed('treemap-cell', true);
cellsEnter.append('div').classed('treemap-inner', true);
cellsEnter.append('a').classed('treemap-link', true);
@@ -82,8 +82,8 @@ import { translate } from '../../helpers/l10n';
this.cells.classed('treemap-cell-drilldown', function (d) {
return (d.qualifier != null) && d.qualifier !== 'FIL' && d.qualifier !== 'CLA';
});
- var prefix = this.mostCommonPrefix(_.pluck(this.components(), 'longName')),
- prefixLength = prefix.length;
+ const prefix = this.mostCommonPrefix(_.pluck(this.components(), 'longName'));
+ const prefixLength = prefix.length;
this.cellsInner = this.box.selectAll('.treemap-inner').data(nodes);
this.cellsInner.html(function (d) {
if (prefixLength > 0) {
@@ -109,14 +109,14 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.attachEvents = function (cells) {
- var that = this;
+ const that = this;
return cells.on('click', function (d) {
return that.requestChildren(d);
});
};
Treemap.prototype.positionCells = function () {
- var that = this;
+ const that = this;
this.cells.style('left', function (d) {
return d.x + 'px';
});
@@ -164,7 +164,7 @@ import { translate } from '../../helpers/l10n';
Treemap.prototype.renderBreadcrumbs = function (box) {
this.breadcrumbsBox = box.append('div').classed('treemap-breadcrumbs', true);
this.breadcrumbs = [];
- var d = {
+ const d = {
name: '<i class="icon-home"></i>',
components: this.components(),
maxResultsReached: this.maxResultsReached()
@@ -173,10 +173,10 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.updateBreadcrumbs = function () {
- var that = this;
- var breadcrumbs = this.breadcrumbsBox.selectAll('.treemap-breadcrumbs-item').data(this.breadcrumbs);
+ const that = this;
+ const breadcrumbs = this.breadcrumbsBox.selectAll('.treemap-breadcrumbs-item').data(this.breadcrumbs);
breadcrumbs.exit().remove();
- var breadcrumbsEnter = breadcrumbs.enter().append('span').classed('treemap-breadcrumbs-item', true);
+ const breadcrumbsEnter = breadcrumbs.enter().append('span').classed('treemap-breadcrumbs-item', true);
breadcrumbsEnter.attr('title', function (d) {
if (d.longName != null) {
return d.longName;
@@ -200,7 +200,7 @@ import { translate } from '../../helpers/l10n';
return '';
}
});
- var breadcrumbsEnterLinks = breadcrumbsEnter.append('a');
+ const breadcrumbsEnterLinks = breadcrumbsEnter.append('a');
breadcrumbsEnterLinks.html(function (d) {
return d.name;
});
@@ -217,7 +217,7 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.cutBreadcrumbs = function (lastElement) {
- var index = null;
+ let index = null;
this.breadcrumbs.forEach(function (d, i) {
if (d.key === lastElement.key) {
index = i;
@@ -240,15 +240,15 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.getPercentColorScale = function () {
- var color = d3.scale.linear().domain([0, 25, 50, 75, 100]);
+ const color = d3.scale.linear().domain([0, 25, 50, 75, 100]);
color.range(this.colorMetric.direction === 1 ? this.colors5 : this.colors5r);
return color;
};
Treemap.prototype.getRatingColorScale = function () {
- var domain = [1, 2, 3, 4, 5];
+ let domain = [1, 2, 3, 4, 5];
if (this.components().length > 0) {
- var colorMetricSample = this.colorMetric.value(_.first(this.components()));
+ const colorMetricSample = this.colorMetric.value(_.first(this.components()));
if (typeof colorMetricSample === 'string') {
domain = ['A', 'B', 'C', 'D', 'E'];
}
@@ -261,8 +261,8 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.render = function (container) {
- var that = this;
- var box = d3.select(container).append('div');
+ const that = this;
+ const box = d3.select(container).append('div');
box.classed('sonar-d3', true);
this.box = box.append('div').classed('treemap-container', true);
this.addMetric('colorMetric', 0);
@@ -297,9 +297,9 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.formatComponents = function (data) {
- var that = this;
- var components = _.filter(data, function (component) {
- var hasSizeMetric = function () {
+ const that = this;
+ const components = _.filter(data, function (component) {
+ const hasSizeMetric = function () {
return _.findWhere(component.msr, {
key: that.sizeMetric.key
});
@@ -308,7 +308,7 @@ import { translate } from '../../helpers/l10n';
});
if (_.isArray(components) && components.length > 0) {
return components.map(function (component) {
- var measures = {};
+ const measures = {};
component.msr.forEach(function (measure) {
measures[measure.key] = {
val: measure.val,
@@ -322,22 +322,22 @@ import { translate } from '../../helpers/l10n';
name: component.name,
longName: component.lname,
qualifier: component.qualifier,
- measures: measures
+ measures
};
});
}
};
Treemap.prototype.requestChildren = function (d) {
- var that = this;
- var metrics = this.metricsPriority().join(','),
- RESOURCES_URL = '/api/resources/index';
+ const that = this;
+ const metrics = this.metricsPriority().join(',');
+ const RESOURCES_URL = '/api/resources/index';
return $.get(RESOURCES_URL, {
resource: d.key,
depth: 1,
- metrics: metrics
+ metrics
}).done(function (r) {
- var components = that.formatComponents(r);
+ let components = that.formatComponents(r);
if (components != null) {
components = _.sortBy(components, function (component) {
return -that.sizeMetric.value(component);
@@ -345,7 +345,7 @@ import { translate } from '../../helpers/l10n';
components = _.initial(components, components.length - that.options().maxItems - 1);
that.updateTreemap(components, components.length > that.options().maxItems);
return that.addToBreadcrumbs(_.extend(d, {
- components: components,
+ components,
maxResultsReached: that.maxResultsReached()
}));
}
@@ -353,16 +353,16 @@ import { translate } from '../../helpers/l10n';
};
Treemap.prototype.mostCommonPrefix = function (strings) {
- var sortedStrings = strings.slice(0).sort(),
- firstString = sortedStrings[0],
- firstStringLength = firstString.length,
- lastString = sortedStrings[sortedStrings.length - 1],
- i = 0;
+ const sortedStrings = strings.slice(0).sort();
+ const firstString = sortedStrings[0];
+ const firstStringLength = firstString.length;
+ const lastString = sortedStrings[sortedStrings.length - 1];
+ let i = 0;
while (i < firstStringLength && firstString.charAt(i) === lastString.charAt(i)) {
i++;
}
- var prefix = firstString.substr(0, i),
- lastPrefixPart = _.last(prefix.split(/[\s\\\/]/));
+ const prefix = firstString.substr(0, i);
+ const lastPrefixPart = _.last(prefix.split(/[\s\\\/]/));
return prefix.substr(0, prefix.length - lastPrefixPart.length);
};
diff --git a/server/sonar-web/src/main/js/widgets/old/widget.js b/server/sonar-web/src/main/js/widgets/old/widget.js
index 7f29ec599f9..661f371b2c9 100644
--- a/server/sonar-web/src/main/js/widgets/old/widget.js
+++ b/server/sonar-web/src/main/js/widgets/old/widget.js
@@ -57,7 +57,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
window.SonarWidgets.Widget.prototype.render = function(container) {
- var that = this;
+ const that = this;
this.showSpinner(container);
d3.json(this.source(), function(error, response) {
diff --git a/server/sonar-web/src/main/js/widgets/old/word-cloud.js b/server/sonar-web/src/main/js/widgets/old/word-cloud.js
index 46505075f48..b79d7feb664 100644
--- a/server/sonar-web/src/main/js/widgets/old/word-cloud.js
+++ b/server/sonar-web/src/main/js/widgets/old/word-cloud.js
@@ -33,7 +33,7 @@
WordCloud.prototype.sizeLow = 10;
WordCloud.prototype.formatDirectory = function (path) {
- var dirs = path.split('/');
+ const dirs = path.split('/');
if (dirs.length > 2) {
return '.../' + dirs[dirs.length - 1];
} else {
@@ -42,9 +42,9 @@
};
WordCloud.prototype.renderWords = function () {
- var that = this;
- var words = this.wordContainer.selectAll('.cloud-word').data(this.components()),
- wordsEnter = words.enter().append('a').classed('cloud-word', true);
+ const that = this;
+ const words = this.wordContainer.selectAll('.cloud-word').data(this.components());
+ const wordsEnter = words.enter().append('a').classed('cloud-word', true);
wordsEnter.text(function (d) {
return d.qualifier === 'DIR' ? that.formatDirectory(d.name) : d.name;
});
@@ -74,8 +74,8 @@
};
WordCloud.prototype.render = function (container) {
- var that = this;
- var box = d3.select(container).append('div');
+ const that = this;
+ const box = d3.select(container).append('div');
box.classed('sonar-d3', true);
box.classed('cloud-widget', true);
this.wordContainer = box.append('div');
@@ -87,12 +87,12 @@
} else {
this.color.range(this.colors4r);
}
- var sizeDomain = d3.extent(this.components(), function (d) {
+ const sizeDomain = d3.extent(this.components(), function (d) {
return that.sizeMetric.value(d);
});
this.size = d3.scale.linear().domain(sizeDomain).range([this.sizeLow, this.sizeHigh]);
if (this.maxResultsReached()) {
- var maxResultsReachedLabel = box.append('div').text(this.options().maxItemsReachedMessage);
+ const maxResultsReachedLabel = box.append('div').text(this.options().maxItemsReachedMessage);
maxResultsReachedLabel.classed('max-results-reached-message', true);
}
this.renderWords();