mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-04 11:20:53 +01:00
merge
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
"createButton": "Berechtigungsrolle erstellen",
|
||||
"name": "Name",
|
||||
"type": "Typ",
|
||||
"verbs": "Verben",
|
||||
"verbs": "Berechtigungen",
|
||||
"button": {
|
||||
"edit": "Bearbeiten"
|
||||
},
|
||||
@@ -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!",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
"name": "Name",
|
||||
"type": "Type",
|
||||
"verbs": "Verbs",
|
||||
"verbs": "Permissions",
|
||||
"system": "System",
|
||||
"form": {
|
||||
"name": "Name",
|
||||
@@ -31,6 +31,16 @@
|
||||
"submit": "Save"
|
||||
}
|
||||
},
|
||||
"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!",
|
||||
|
||||
113
scm-ui/src/config/roles/containers/DeleteRepositoryRole.js
Normal file
113
scm-ui/src/config/roles/containers/DeleteRepositoryRole.js
Normal file
@@ -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<Props> {
|
||||
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 (
|
||||
<>
|
||||
<Subtitle subtitle={t("deleteRole.subtitle")} />
|
||||
<div className="columns">
|
||||
<div className="column">
|
||||
<ErrorNotification error={error} />
|
||||
<DeleteButton
|
||||
label={t("deleteRole.button")}
|
||||
action={action}
|
||||
loading={loading}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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)));
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { ErrorNotification, Subtitle } from "@scm-manager/ui-components";
|
||||
import type { RepositoryRole } from "@scm-manager/ui-types";
|
||||
import type { History } from "history";
|
||||
import DeleteRepositoryRole from "./DeleteRepositoryRole";
|
||||
|
||||
type Props = {
|
||||
disabled: boolean,
|
||||
@@ -49,6 +50,8 @@ class EditRepositoryRole extends React.Component<Props> {
|
||||
role={this.props.role}
|
||||
submitForm={role => this.updateRepositoryRole(role)}
|
||||
/>
|
||||
<hr/>
|
||||
<DeleteRepositoryRole role={this.props.role}/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user