renamed navlink to simple delete

This commit is contained in:
Florian Scholdei
2019-01-23 10:08:15 +01:00
parent 904f5851a7
commit cb5e74e791
6 changed files with 38 additions and 53 deletions

View File

@@ -0,0 +1,82 @@
// @flow
import React from "react";
import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
import RepositoryForm from "../components/form";
import DeleteRepo from "../components/DeleteRepo";
import type { Repository } from "@scm-manager/ui-types";
import {
modifyRepo,
isModifyRepoPending,
getModifyRepoFailure,
modifyRepoReset
} from "../modules/repos";
import type { History } from "history";
import { ErrorNotification } from "@scm-manager/ui-components";
type Props = {
loading: boolean,
error: Error,
modifyRepo: (Repository, () => void) => void,
modifyRepoReset: Repository => void,
// context props
repository: Repository,
history: History
};
class GeneralRepo extends React.Component<Props> {
componentDidMount() {
const { modifyRepoReset, repository } = this.props;
modifyRepoReset(repository);
}
repoModified = () => {
const { history, repository } = this.props;
history.push(`/repo/${repository.namespace}/${repository.name}`);
};
render() {
const { loading, error, repository } = this.props;
return (
<div>
<ErrorNotification error={error} />
<RepositoryForm
repository={this.props.repository}
loading={loading}
submitForm={repo => {
this.props.modifyRepo(repo, this.repoModified);
}}
/>
<hr />
<DeleteRepo repository={repository} />
</div>
);
}
}
const mapStateToProps = (state, ownProps) => {
const { namespace, name } = ownProps.repository;
const loading = isModifyRepoPending(state, namespace, name);
const error = getModifyRepoFailure(state, namespace, name);
return {
loading,
error
};
};
const mapDispatchToProps = dispatch => {
return {
modifyRepo: (repo: Repository, callback: () => void) => {
dispatch(modifyRepo(repo, callback));
},
modifyRepoReset: (repo: Repository) => {
dispatch(modifyRepoReset(repo));
}
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(withRouter(GeneralRepo));