aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/permission-templates/create-view.js
blob: 733e970069f1cf7326590c4617b2f44561f825ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import FormView from './form-view';
import {createPermissionTemplate} from '../../api/permissions';

export default FormView.extend({
  sendRequest: function () {
    var that = this;
    this.disableForm();
    return createPermissionTemplate({
      data: {
        name: this.$('#permission-template-name').val(),
        description: this.$('#permission-template-description').val(),
        projectKeyPattern: this.$('#permission-template-project-key-pattern').val()
      },
      statusCode: {
        // do not show global error
        400: null
      }
    }).done(function () {
      that.options.refresh();
      that.destroy();
    }).fail(function (jqXHR) {
      that.enableForm();
      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
    });
  }
});