moved funcs from singleuser to deleteuser + renamed edit to general

This commit is contained in:
Florian Scholdei
2019-01-18 15:26:55 +01:00
parent c6b43ec460
commit b1b38276ab
4 changed files with 63 additions and 29 deletions

View File

@@ -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);