aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js85
1 files changed, 41 insertions, 44 deletions
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 246d2856bf3..9c7d29d0dbc 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
@@ -1,50 +1,47 @@
-define([
- 'components/common/modal-form',
- './profile',
- './templates'
-], function (ModalFormView, Profile) {
+import $ from 'jquery';
+import ModalFormView from 'components/common/modal-form';
+import Profile from './profile';
+import './templates';
- var $ = jQuery;
+export default ModalFormView.extend({
+ template: Templates['quality-profiles-copy-profile'],
- return ModalFormView.extend({
- template: Templates['quality-profiles-copy-profile'],
+ onFormSubmit: function () {
+ ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+ this.disableForm();
+ this.sendRequest();
+ },
- onFormSubmit: function () {
- ModalFormView.prototype.onFormSubmit.apply(this, arguments);
- this.disableForm();
- this.sendRequest();
- },
+ sendRequest: function () {
+ var that = this,
+ url = baseUrl + '/api/qualityprofiles/copy',
+ name = this.$('#copy-profile-name').val(),
+ options = {
+ fromKey: this.model.get('key'),
+ toName: name
+ };
+ return $.ajax({
+ type: 'POST',
+ url: url,
+ data: options,
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ }).done(function (r) {
+ that.addProfile(r);
+ that.destroy();
+ }).fail(function (jqXHR) {
+ that.enableForm();
+ that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+ });
+ },
- sendRequest: function () {
- var that = this,
- url = baseUrl + '/api/qualityprofiles/copy',
- name = this.$('#copy-profile-name').val(),
- options = {
- fromKey: this.model.get('key'),
- toName: name
- };
- return $.ajax({
- type: 'POST',
- url: url,
- data: options,
- statusCode: {
- // do not show global error
- 400: null
- }
- }).done(function (r) {
- that.addProfile(r);
- that.destroy();
- }).fail(function (jqXHR) {
- that.enableForm();
- that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
- });
- },
+ addProfile: function (profileData) {
+ var profile = new Profile(profileData);
+ this.model.collection.add([profile]);
+ profile.trigger('select', profile);
+ }
+});
- addProfile: function (profileData) {
- var profile = new Profile(profileData);
- this.model.collection.add([profile]);
- profile.trigger('select', profile);
- }
- });
-});