diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-03-17 09:10:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-17 09:10:48 +0100 |
commit | de4365079bad2df3bdee2133576dc913ffbf1ab2 (patch) | |
tree | a522ccb952f0d37f454e8188e13b3dec3f731912 /server/sonar-web/src/main/js/apps/custom-measures | |
parent | 6a03df65cc0c91a26150ea172a2c480e07326ea1 (diff) | |
download | sonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.tar.gz sonarqube-de4365079bad2df3bdee2133576dc913ffbf1ab2.zip |
format code using prettier (#1774)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/custom-measures')
14 files changed, 83 insertions, 91 deletions
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js b/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js index 0e87f4e8fc3..f632095516c 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/components/CustomMeasuresAppContainer.js @@ -23,12 +23,12 @@ import init from '../init'; import { getComponent } from '../../../store/rootReducer'; class CustomMeasuresAppContainer extends React.Component { - componentDidMount () { + componentDidMount() { init(this.refs.container, this.props.component); } - render () { - return <div ref="container"/>; + render() { + return <div ref="container" />; } } 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 43fa7396176..2c1363b237b 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 @@ -21,8 +21,7 @@ import CustomMeasure from './custom-measure'; import FormView from './form-view'; export default FormView.extend({ - - sendRequest () { + sendRequest() { const that = this; const customMeasure = new CustomMeasure({ metricId: this.$('#create-custom-measure-metric').val(), @@ -31,18 +30,20 @@ export default FormView.extend({ projectId: this.options.projectId }); this.disableForm(); - return customMeasure.save(null, { - statusCode: { - // do not show global error - 400: null - } - }).done(() => { - that.collection.refresh(); - that.destroy(); - }).fail(jqXHR => { - that.enableForm(); - that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); - }); + return customMeasure + .save(null, { + statusCode: { + // do not show global error + 400: null + } + }) + .done(() => { + that.collection.refresh(); + that.destroy(); + }) + .fail(jqXHR => { + that.enableForm(); + that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); + }); } }); - 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 3d3a550a877..1338212736a 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 @@ -24,11 +24,11 @@ import Backbone from 'backbone'; export default Backbone.Model.extend({ idAttribute: 'id', - urlRoot () { + urlRoot() { return window.baseUrl + '/api/custom_measures'; }, - sync (method, model, options) { + sync(method, model, options) { const opts = options || {}; if (method === 'create') { defaults(opts, { @@ -54,4 +54,3 @@ export default Backbone.Model.extend({ return Backbone.ajax(opts); } }); - 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 2d2e132d494..512b11d279a 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,45 +24,43 @@ import CustomMeasure from './custom-measure'; export default Backbone.Collection.extend({ model: CustomMeasure, - initialize (options) { + initialize(options) { this.projectId = options.projectId; }, - url () { + url() { return window.baseUrl + '/api/custom_measures/search'; }, - parse (r) { + parse(r) { this.total = r.total; this.p = r.p; this.ps = r.ps; return r.customMeasures; }, - fetch (options) { + fetch(options) { const opts = { data: {}, ...options }; this.q = opts.data.q; opts.data.projectId = this.projectId; return Backbone.Collection.prototype.fetch.call(this, opts); }, - fetchMore () { + fetchMore() { const p = this.p + 1; return this.fetch({ add: true, remove: false, data: { p, ps: this.ps, q: this.q } }); }, - refresh () { + refresh() { return this.fetch({ reset: true, data: { q: this.q } }); }, - hasMore () { + hasMore() { return this.total > this.p * this.ps; }, - getTakenMetrics () { + getTakenMetrics() { const metrics = this.map(model => 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 93ac4755a16..42c129e4427 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,26 +23,28 @@ import Template from './templates/custom-measures-delete.hbs'; export default ModalForm.extend({ template: Template, - onFormSubmit () { + onFormSubmit() { ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, - sendRequest () { + sendRequest() { const that = this; const collection = this.model.collection; - return this.model.destroy({ - wait: true, - statusCode: { - // do not show global error - 400: null - } - }).done(() => { - collection.refresh(); - that.destroy(); - }).fail(jqXHR => { - that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); - }); + return this.model + .destroy({ + wait: true, + statusCode: { + // do not show global error + 400: null + } + }) + .done(() => { + collection.refresh(); + that.destroy(); + }) + .fail(jqXHR => { + that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); + }); } }); - 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 39b7d8b3c79..d89fa0e800b 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 @@ -24,13 +24,13 @@ import Template from './templates/custom-measures-form.hbs'; export default ModalForm.extend({ template: Template, - initialize () { + initialize() { this.metrics = new Metrics(); this.listenTo(this.metrics, 'reset', this.render); this.metrics.fetch({ reset: true }); }, - onRender () { + onRender() { ModalForm.prototype.onRender.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); this.$('#create-custom-measure-metric').select2({ @@ -39,22 +39,22 @@ export default ModalForm.extend({ }); }, - onDestroy () { + onDestroy() { ModalForm.prototype.onDestroy.apply(this, arguments); this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onFormSubmit () { + onFormSubmit() { ModalForm.prototype.onFormSubmit.apply(this, arguments); this.sendRequest(); }, - getAvailableMetrics () { + getAvailableMetrics() { const takenMetrics = this.collection.getTakenMetrics(); return this.metrics.toJSON().filter(metric => takenMetrics.indexOf(metric.id) === -1); }, - serializeData () { + serializeData() { const metrics = this.getAvailableMetrics(); const isNew = !this.model; return { @@ -64,4 +64,3 @@ export default ModalForm.extend({ }; } }); - 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 d9a61f1ae63..0c47f4e51ad 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,16 +28,15 @@ export default Marionette.ItemView.extend({ 'click #custom-measures-create': 'onCreateClick' }, - onCreateClick (e) { + onCreateClick(e) { e.preventDefault(); this.createCustomMeasure(); }, - createCustomMeasure () { + createCustomMeasure() { new CreateView({ collection: this.collection, projectId: this.options.projectId }).render(); } }); - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/init.js b/server/sonar-web/src/main/js/apps/custom-measures/init.js index a63ed638edb..debdadb157e 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/init.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/init.js @@ -25,7 +25,7 @@ import ListView from './list-view'; import ListFooterView from './list-footer-view'; const App = new Marionette.Application(); -const init = function (el, component) { +const init = function(el, component) { // Layout this.layout = new Layout({ el }); this.layout.render(); @@ -62,7 +62,6 @@ App.on('start', options => { init.call(App, options.el, options.component); }); -export default function (el, component) { +export default function(el, component) { App.start({ el, component }); } - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/layout.js b/server/sonar-web/src/main/js/apps/custom-measures/layout.js index 4cc3d7f652a..6630457663c 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/layout.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/layout.js @@ -29,4 +29,3 @@ export default Marionette.LayoutView.extend({ listFooterRegion: '#custom-measures-list-footer' } }); - 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 a3df6fbd751..0830708a052 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 @@ -24,23 +24,23 @@ export default Marionette.ItemView.extend({ template: Template, collectionEvents: { - 'all': 'render' + all: 'render' }, events: { 'click #custom-measures-fetch-more': 'onMoreClick' }, - onMoreClick (e) { + onMoreClick(e) { e.preventDefault(); this.fetchMore(); }, - fetchMore () { + fetchMore() { this.collection.fetchMore(); }, - serializeData () { + serializeData() { return { ...Marionette.ItemView.prototype.serializeData.apply(this, arguments), total: this.collection.total, @@ -49,4 +49,3 @@ export default Marionette.ItemView.extend({ }; } }); - 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 f0cf82e916f..374909f56b4 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,34 +31,33 @@ export default Marionette.ItemView.extend({ 'click .js-custom-measure-delete': 'onDeleteClick' }, - onRender () { + onRender() { this.$el.attr('data-id', this.model.id); this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' }); }, - onDestroy () { + onDestroy() { this.$('[data-toggle="tooltip"]').tooltip('destroy'); }, - onUpdateClick (e) { + onUpdateClick(e) { e.preventDefault(); this.updateCustomMeasure(); }, - onDeleteClick (e) { + onDeleteClick(e) { e.preventDefault(); this.deleteCustomMeasure(); }, - updateCustomMeasure () { + updateCustomMeasure() { new UpdateView({ model: this.model, collection: this.model.collection }).render(); }, - deleteCustomMeasure () { + deleteCustomMeasure() { new DeleteView({ model: this.model }).render(); } }); - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/list-view.js b/server/sonar-web/src/main/js/apps/custom-measures/list-view.js index 9d8af661b95..8a530bbb392 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/list-view.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/list-view.js @@ -26,4 +26,3 @@ export default Marionette.CompositeView.extend({ childView: ListItemView, childViewContainer: 'tbody' }); - diff --git a/server/sonar-web/src/main/js/apps/custom-measures/routes.js b/server/sonar-web/src/main/js/apps/custom-measures/routes.js index 57d44965c6d..cef57a1375d 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/routes.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/routes.js @@ -21,6 +21,4 @@ import React from 'react'; import { IndexRoute } from 'react-router'; import CustomMeasuresAppContainer from './components/CustomMeasuresAppContainer'; -export default ( - <IndexRoute component={CustomMeasuresAppContainer}/> -); +export default <IndexRoute component={CustomMeasuresAppContainer} />; 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 24376d7c848..70ff5dbcc65 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 @@ -20,26 +20,27 @@ import FormView from './form-view'; export default FormView.extend({ - - sendRequest () { + sendRequest() { const that = this; this.model.set({ value: this.$('#create-custom-measure-value').val(), description: this.$('#create-custom-measure-description').val() }); this.disableForm(); - return this.model.save(null, { - statusCode: { - // do not show global error - 400: null - } - }).done(() => { - that.collection.refresh(); - that.destroy(); - }).fail(jqXHR => { - that.enableForm(); - that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); - }); + return this.model + .save(null, { + statusCode: { + // do not show global error + 400: null + } + }) + .done(() => { + that.collection.refresh(); + that.destroy(); + }) + .fail(jqXHR => { + that.enableForm(); + that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings); + }); } }); - |