aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-profiles/views/DeleteProfileView.js
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-06-27 16:08:44 +0200
committerGitHub <noreply@github.com>2016-06-27 16:08:44 +0200
commit4ecb6fc3ec08ee37a1bb5c19d8ca44e2b832b5a7 (patch)
tree763ce4b5a9d7b37982ab54fc64a0597167c2bc3d /server/sonar-web/src/main/js/apps/quality-profiles/views/DeleteProfileView.js
parentc467e84eed1a60bbe8c0fe800e2cada2bb26bb4c (diff)
downloadsonarqube-4ecb6fc3ec08ee37a1bb5c19d8ca44e2b832b5a7.tar.gz
sonarqube-4ecb6fc3ec08ee37a1bb5c19d8ca44e2b832b5a7.zip
refactor quality profiles page (#1056)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-profiles/views/DeleteProfileView.js')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-profiles/views/DeleteProfileView.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/views/DeleteProfileView.js b/server/sonar-web/src/main/js/apps/quality-profiles/views/DeleteProfileView.js
new file mode 100644
index 00000000000..b9bb6023c71
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/quality-profiles/views/DeleteProfileView.js
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.
+ */
+import ModalFormView from '../../../components/common/modal-form';
+import Template from '../templates/quality-profiles-delete-profile.hbs';
+import { deleteProfile } from '../../../api/quality-profiles';
+
+export default ModalFormView.extend({
+ template: Template,
+
+ modelEvents: {
+ 'destroy': 'destroy'
+ },
+
+ onFormSubmit () {
+ ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+ this.disableForm();
+ this.sendRequest();
+ },
+
+ sendRequest () {
+ deleteProfile(this.options.profile.key)
+ .then(() => {
+ this.destroy();
+ this.trigger('done');
+ })
+ .catch(e => {
+ if (e.response.status === 400) {
+ this.enableForm();
+ e.response.json().then(r => this.showErrors(r.errors, r.warnings));
+ }
+ });
+ },
+
+ serializeData () {
+ return this.options.profile;
+ }
+});
+