From a52cd625b87fb7250d4b4b5c67a29cc956ab0a92 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Fri, 17 May 2019 08:50:32 +0200 Subject: [PATCH 1/4] add DeleteRepositoryRole --- scm-ui/public/locales/en/config.json | 10 ++ .../roles/containers/DeleteRepositoryRole.js | 113 ++++++++++++++++++ .../roles/containers/EditRepositoryRole.js | 3 + 3 files changed, 126 insertions(+) create mode 100644 scm-ui/src/config/roles/containers/DeleteRepositoryRole.js diff --git a/scm-ui/public/locales/en/config.json b/scm-ui/public/locales/en/config.json index bdb245544a..44da3c1be2 100644 --- a/scm-ui/public/locales/en/config.json +++ b/scm-ui/public/locales/en/config.json @@ -33,6 +33,16 @@ "name": "Name", "system": "System" }, + "deleteRole" : { + "button": "Delete", + "subtitle": "Delete Permission Role", + "confirmAlert": { + "title": "Delete Permission Role", + "message": "Do you really want to delete this permission role? All users who own this role will lose their permissions.", + "submit": "Yes", + "cancel": "No" + } + }, "config-form": { "submit": "Submit", "submit-success-notification": "Configuration changed successfully!", diff --git a/scm-ui/src/config/roles/containers/DeleteRepositoryRole.js b/scm-ui/src/config/roles/containers/DeleteRepositoryRole.js new file mode 100644 index 0000000000..a00cc21840 --- /dev/null +++ b/scm-ui/src/config/roles/containers/DeleteRepositoryRole.js @@ -0,0 +1,113 @@ +// @flow +import React from "react"; +import { translate } from "react-i18next"; +import type { RepositoryRole } from "@scm-manager/ui-types"; +import { + Subtitle, + DeleteButton, + confirmAlert, + ErrorNotification +} from "@scm-manager/ui-components"; +import { connect } from "react-redux"; +import { withRouter } from "react-router-dom"; +import type { History } from "history"; +import { + deleteRole, + getDeleteRoleFailure, + isDeleteRolePending +} from "../modules/roles"; + +type Props = { + loading: boolean, + error: Error, + role: RepositoryRole, + confirmDialog?: boolean, + deleteRole: (role: RepositoryRole, callback?: () => void) => void, + + // context props + history: History, + t: string => string +}; + +class DeleteRepositoryRole extends React.Component { + static defaultProps = { + confirmDialog: true + }; + + roleDeleted = () => { + this.props.history.push("/config/roles/"); + }; + + deleteRole = () => { + this.props.deleteRole(this.props.role, this.roleDeleted); + }; + + confirmDelete = () => { + const { t } = this.props; + confirmAlert({ + title: t("deleteRole.confirmAlert.title"), + message: t("deleteRole.confirmAlert.message"), + buttons: [ + { + label: t("deleteRole.confirmAlert.submit"), + onClick: () => this.deleteRole() + }, + { + label: t("deleteRole.confirmAlert.cancel"), + onClick: () => null + } + ] + }); + }; + + isDeletable = () => { + return this.props.role._links.delete; + }; + + render() { + const { loading, error, confirmDialog, t } = this.props; + const action = confirmDialog ? this.confirmDelete : this.deleteRole; + + if (!this.isDeletable()) { + return null; + } + + return ( + <> + +
+
+ + +
+
+ + ); + } +} + +const mapStateToProps = (state, ownProps) => { + const loading = isDeleteRolePending(state, ownProps.role.name); + const error = getDeleteRoleFailure(state, ownProps.role.name); + return { + loading, + error + }; +}; + +const mapDispatchToProps = dispatch => { + return { + deleteRole: (role: RepositoryRole, callback?: () => void) => { + dispatch(deleteRole(role, callback)); + } + }; +}; + +export default connect( + mapStateToProps, + mapDispatchToProps +)(withRouter(translate("config")(DeleteRepositoryRole))); diff --git a/scm-ui/src/config/roles/containers/EditRepositoryRole.js b/scm-ui/src/config/roles/containers/EditRepositoryRole.js index deb0a77583..f63a2f3e50 100644 --- a/scm-ui/src/config/roles/containers/EditRepositoryRole.js +++ b/scm-ui/src/config/roles/containers/EditRepositoryRole.js @@ -10,6 +10,7 @@ import { } from "../modules/roles"; import { ErrorNotification } from "@scm-manager/ui-components"; import type { RepositoryRole } from "@scm-manager/ui-types"; +import DeleteRepositoryRole from "./DeleteRepositoryRole"; type Props = { disabled: boolean, @@ -49,6 +50,8 @@ class EditRepositoryRole extends React.Component { role={this.props.role} submitForm={role => this.updateRepositoryRole(role)} /> +
+ ); } From f5ded2f28da9d48bc501b430a76ebda2b3d51b53 Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Fri, 17 May 2019 09:03:49 +0200 Subject: [PATCH 2/4] add German Translations for DeleteRepositoryRole --- scm-ui/public/locales/de/config.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scm-ui/public/locales/de/config.json b/scm-ui/public/locales/de/config.json index 71ab66ff22..341fc978a5 100644 --- a/scm-ui/public/locales/de/config.json +++ b/scm-ui/public/locales/de/config.json @@ -33,6 +33,16 @@ "name": "Name", "system": "System" }, + "deleteRole" : { + "button": "Löschen", + "subtitle": "Berechtigungsrolle löschen", + "confirmAlert": { + "title": "Berechtigungsrolle löschen", + "message": "Soll die Berechtigungsrolle wirklich gelöscht werden? Alle Nutzer dieser Rolle verlieren Ihre Berechtigungen.", + "submit": "Ja", + "cancel": "Nein" + } + }, "config-form": { "submit": "Speichern", "submit-success-notification": "Einstellungen wurden erfolgreich geändert!", From c60ecea807597b54aec10d5cccdc78ff7951b4bd Mon Sep 17 00:00:00 2001 From: Eduard Heimbuch Date: Fri, 17 May 2019 11:24:37 +0200 Subject: [PATCH 3/4] rename verbs to permissions --- scm-ui/public/locales/de/config.json | 2 +- scm-ui/public/locales/en/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scm-ui/public/locales/de/config.json b/scm-ui/public/locales/de/config.json index 341fc978a5..d26552c30d 100644 --- a/scm-ui/public/locales/de/config.json +++ b/scm-ui/public/locales/de/config.json @@ -14,7 +14,7 @@ "createButton": "Berechtigungsrolle erstellen", "name": "Name", "type": "Typ", - "verbs": "Verben", + "verbs": "Berechtigungen", "button": { "edit": "Bearbeiten" }, diff --git a/scm-ui/public/locales/en/config.json b/scm-ui/public/locales/en/config.json index 44da3c1be2..b2f6e77e0d 100644 --- a/scm-ui/public/locales/en/config.json +++ b/scm-ui/public/locales/en/config.json @@ -14,7 +14,7 @@ "createButton": "Create Permission Role", "name": "Name", "type": "Type", - "verbs": "Verbs", + "verbs": "Permissions", "edit": "Edit Permission Role", "button": { "edit": "Edit" From 406fdac7095d161d61f9fee74b87adf94a3cb2fc Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Fri, 17 May 2019 13:56:14 +0000 Subject: [PATCH 4/4] Close branch feature/custom_roles_overview