aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js95
1 files changed, 0 insertions, 95 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js b/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js
deleted file mode 100644
index fb74811ec69..00000000000
--- a/server/sonar-web/src/main/js/apps/quality-profiles/views/CreateProfileView.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-// @flow
-import $ from 'jquery';
-import ModalFormView from '../../../components/common/modal-form';
-import Template from '../templates/quality-profiles-create-profile.hbs';
-import { createQualityProfile } from '../../../api/quality-profiles';
-
-export default ModalFormView.extend({
- template: Template,
-
- events() {
- return {
- ...ModalFormView.prototype.events.apply(this, arguments),
- 'change #create-profile-language': 'onLanguageChange'
- };
- },
-
- onFormSubmit() {
- ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-
- const form = this.$('form')[0];
- const data = new FormData(form);
-
- createQualityProfile(data)
- .then(r => {
- this.trigger('done', r.profile);
- this.destroy();
- })
- .catch(e => {
- e.response.json().then(r => this.showErrors(r.errors, r.warnings));
- });
- },
-
- onRender() {
- ModalFormView.prototype.onRender.apply(this, arguments);
- this.$('select').select2({
- width: '250px',
- minimumResultsForSearch: 50
- });
- this.onLanguageChange();
- },
-
- 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');
- });
- importers.forEach(importer => {
- that.$(`.js-importer[data-key="${importer.key}"]`).removeClass('hidden');
- });
- },
-
- emptyInput(e) {
- e.wrap('<form>').closest('form').get(0).reset();
- e.unwrap();
- },
-
- getImportersForLanguages(language) {
- if (language != null) {
- return this.options.importers.filter(importer => importer.languages.indexOf(language) !== -1);
- } else {
- return [];
- }
- },
-
- serializeData() {
- return {
- ...ModalFormView.prototype.serializeData.apply(this, arguments),
- languages: this.options.languages,
- importers: this.options.importers,
- organization: this.options.organization
- };
- }
-});