From fcba3fa1650b1afc794094e20764191ae8bca910 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 26 Jul 2016 16:11:54 +0200 Subject: SONAR-7918 Rewrite "Deletion" project page (#1116) --- .../project-admin/deletion/ConfirmationModal.js | 47 ++++++++++++++++++++++ .../deletion/ConfirmationModalTemplate.hbs | 13 ++++++ .../js/apps/project-admin/deletion/Deletion.js | 37 +++++++++++++++++ .../main/js/apps/project-admin/deletion/Form.js | 47 ++++++++++++++++++++++ .../main/js/apps/project-admin/deletion/Header.js | 36 +++++++++++++++++ 5 files changed, 180 insertions(+) create mode 100644 server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModal.js create mode 100644 server/sonar-web/src/main/js/apps/project-admin/deletion/ConfirmationModalTemplate.hbs create mode 100644 server/sonar-web/src/main/js/apps/project-admin/deletion/Deletion.js create mode 100644 server/sonar-web/src/main/js/apps/project-admin/deletion/Form.js create mode 100644 server/sonar-web/src/main/js/apps/project-admin/deletion/Header.js (limited to 'server/sonar-web/src/main/js/apps/project-admin/deletion') 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 @@ +
+ + + +
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 ( +
+
+
+
+ ); + } +} 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 ( + + + + ); + } +} 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 ( +
+

+ {translate('deletion.page')} +

+
+ {translate('project_deletion.page.description')} +
+
+ ); + } +} -- cgit v1.2.3