diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-02-22 10:39:30 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-02-22 11:17:19 +0100 |
commit | ef39ea00c5822b114d728f73d92eed6635437b98 (patch) | |
tree | 14cc3591232af48f70ab6d440fc116e0bd05e739 /server/sonar-web/src/main/js/apps | |
parent | a8b9c87ee38ab2458bd0293b1ee099266b7789ab (diff) | |
download | sonarqube-ef39ea00c5822b114d728f73d92eed6635437b98.tar.gz sonarqube-ef39ea00c5822b114d728f73d92eed6635437b98.zip |
improve code quality
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
240 files changed, 2559 insertions, 2570 deletions
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; } |