aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/project-admin/deletion
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-07-26 16:11:54 +0200
committerGitHub <noreply@github.com>2016-07-26 16:11:54 +0200
commitfcba3fa1650b1afc794094e20764191ae8bca910 (patch)
tree3e6dfea548aa8a38212441d70746e3dcaf343dc1 /server/sonar-web/src/main/js/apps/project-admin/deletion
parent9ee9a01b05f97f024748173529689f6e6535e635 (diff)
downloadsonarqube-fcba3fa1650b1afc794094e20764191ae8bca910.tar.gz
sonarqube-fcba3fa1650b1afc794094e20764191ae8bca910.zip
SONAR-7918 Rewrite "Deletion" project page (#1116)
Diffstat (limited to 'server/sonar-web/src/main/js/apps/project-admin/deletion')
-rw-r--r--server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModal.js47
-rw-r--r--server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModalTemplate.hbs13
-rw-r--r--server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js37
-rw-r--r--server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js47
-rw-r--r--server/sonar-web/src/main/js/apps/project-admin/deletion/Header.js36
5 files changed, 180 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModal.js b/server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModal.js
new file mode 100644
index 00000000000..e5e6f712c02
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModal.js
@@ -0,0 +1,47 @@
+/*
+ * 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 ModalForm from '../../../components/common/modal-form';
+import Template from './ConfirmationModalTemplate.hbs';
+import { deleteProject } from '../../../api/components';
+
+export default ModalForm.extend({
+ template: Template,
+
+ onFormSubmit () {
+ ModalForm.prototype.onFormSubmit.apply(this, arguments);
+ this.disableForm();
+
+ deleteProject(this.options.project.key)
+ .then(() => {
+ this.trigger('done');
+ })
+ .catch(function (e) {
+ e.response.json().then(r => {
+ this.showErrors(r.errors, r.warnings);
+ this.enableForm();
+ });
+ });
+ },
+
+ serializeData () {
+ return { project: this.options.project };
+ }
+});
+
diff --git a/server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModalTemplate.hbs b/server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModalTemplate.hbs
new file mode 100644
index 00000000000..5da393e8d75
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModalTemplate.hbs
@@ -0,0 +1,13 @@
+<form id="deactivate-user-form" autocomplete="off">
+ <div class="modal-head">
+ <h2>{{t 'qualifiers.delete.TRK'}}</h2>
+ </div>
+ <div class="modal-body">
+ <div class="js-modal-messages"></div>
+ {{tp 'project_deletion.delete_resource_confirmation' project.name}}
+ </div>
+ <div class="modal-foot">
+ <button id="delete-project-confirm" class="button-red">{{t 'delete'}}</button>
+ <a href="#" class="js-modal-close">{{t 'cancel'}}</a>
+ </div>
+</form>
diff --git a/server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js b/server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js
new file mode 100644
index 00000000000..67563891ade
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js
@@ -0,0 +1,37 @@
+/*
+ * 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 React from 'react';
+import Header from './Header';
+import Form from './Form';
+
+export default class Deletion extends React.Component {
+ static propTypes = {
+ component: React.PropTypes.object.isRequired
+ };
+
+ render () {
+ return (
+ <div className="page page-limited">
+ <Header/>
+ <Form component={this.props.component}/>
+ </div>
+ );
+ }
+}
diff --git a/server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js b/server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js
new file mode 100644
index 00000000000..81d52fb3ba2
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js
@@ -0,0 +1,47 @@
+/*
+ * 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 React from 'react';
+import ConfirmationModal from './ConfirmationModal';
+import { translate } from '../../../helpers/l10n';
+
+export default class Form extends React.Component {
+ static propTypes = {
+ component: React.PropTypes.object.isRequired
+ };
+
+ handleDelete (e) {
+ e.preventDefault();
+ new ConfirmationModal({ project: this.props.component })
+ .on('done', () => {
+ window.location = window.baseUrl + '/';
+ })
+ .render();
+ }
+
+ render () {
+ return (
+ <form onSubmit={this.handleDelete.bind(this)}>
+ <button id="delete-project" className="button-red">
+ {translate('delete')}
+ </button>
+ </form>
+ );
+ }
+}
diff --git a/server/sonar-web/src/main/js/apps/project-admin/deletion/Header.js b/server/sonar-web/src/main/js/apps/project-admin/deletion/Header.js
new file mode 100644
index 00000000000..39bd303693f
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/project-admin/deletion/Header.js
@@ -0,0 +1,36 @@
+/*
+ * 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 React from 'react';
+import { translate } from '../../../helpers/l10n';
+
+export default class Header extends React.Component {
+ render () {
+ return (
+ <header className="page-header">
+ <h1 className="page-title">
+ {translate('deletion.page')}
+ </h1>
+ <div className="page-description">
+ {translate('project_deletion.page.description')}
+ </div>
+ </header>
+ );
+ }
+}