mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 09:25:43 +01:00
moved funcs from singleuser to deleteuser + renamed edit to general
This commit is contained in:
@@ -3,15 +3,37 @@ import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import type { User } from "@scm-manager/ui-types";
|
||||
import { DeleteButton, confirmAlert } from "@scm-manager/ui-components";
|
||||
import {connect} from "react-redux";
|
||||
import {
|
||||
deleteUser, fetchUserByName,
|
||||
getDeleteUserFailure,
|
||||
getUserByName,
|
||||
isDeleteUserPending,
|
||||
} from "../modules/users";
|
||||
import type {History} from "history";
|
||||
|
||||
type Props = {
|
||||
user: User,
|
||||
confirmDialog?: boolean,
|
||||
|
||||
// dispatcher functions
|
||||
fetchUserByName: (string, string) => void,
|
||||
deleteUser: (user: User, callback?: () => void) => void,
|
||||
|
||||
// context objects
|
||||
t: string => string,
|
||||
deleteUser: (user: User) => void
|
||||
history: History
|
||||
};
|
||||
|
||||
class DeleteUser extends React.Component<Props> {
|
||||
userDeleted = () => {
|
||||
this.props.history.push("/users");
|
||||
};
|
||||
|
||||
deleteUser = (user: User) => {
|
||||
this.props.deleteUser(user, this.userDeleted);
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
confirmDialog: true
|
||||
};
|
||||
@@ -53,4 +75,34 @@ class DeleteUser extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const name = ownProps.match.params.name;
|
||||
const user = getUserByName(state, name);
|
||||
const loading = isDeleteUserPending(state, name);
|
||||
const error = getDeleteUserFailure(state, name);
|
||||
return {
|
||||
name,
|
||||
user,
|
||||
loading,
|
||||
error
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
fetchUserByName: (link: string, name: string) => {
|
||||
dispatch(fetchUserByName(link, name));
|
||||
},
|
||||
deleteUser: (user: User, callback?: () => void) => {
|
||||
dispatch(deleteUser(user, callback));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(translate("users")(DeleteUser));
|
||||
*/
|
||||
export default translate("users")(DeleteUser);
|
||||
|
||||
Reference in New Issue
Block a user