finish delete implementation and restructure components

This commit is contained in:
Sebastian Sdorra
2018-08-06 10:08:28 +02:00
parent f0794c9d15
commit ffbfdff52e
17 changed files with 183 additions and 14 deletions

View File

@@ -3,7 +3,7 @@ import React from "react";
import { connect } from "react-redux";
import { translate } from "react-i18next";
import { Page } from "../../components/layout";
import RepositoryForm from "../components/RepositoryForm";
import RepositoryForm from "../components/form";
import type { RepositoryType } from "../types/RepositoryTypes";
import {
fetchRepositoryTypesIfNeeded,

View File

@@ -15,7 +15,7 @@ import {
} from "../modules/repos";
import { translate } from "react-i18next";
import { Page } from "../../components/layout";
import RepositoryList from "../components/RepositoryList";
import RepositoryList from "../components/list";
import Paginator from "../../components/Paginator";
import { withRouter } from "react-router-dom";
import type { History } from "history";

View File

@@ -1,6 +1,7 @@
//@flow
import React from "react";
import {
deleteRepo,
fetchRepo,
getFetchRepoFailure,
getRepository,
@@ -15,6 +16,9 @@ import ErrorPage from "../../components/ErrorPage";
import { translate } from "react-i18next";
import { Navigation, NavLink, Section } from "../../components/navigation";
import RepositoryDetails from "../components/RepositoryDetails";
import DeleteNavAction from "../components/DeleteNavAction";
import type { History } from "history";
type Props = {
namespace: string,
@@ -25,9 +29,11 @@ type Props = {
// dispatch functions
fetchRepo: (namespace: string, name: string) => void,
deleteRepo: (repository: Repository, () => void) => void,
// context props
t: string => string,
history: History,
match: any
};
@@ -49,6 +55,14 @@ class RepositoryRoot extends React.Component<Props> {
return this.stripEndingSlash(this.props.match.url);
};
deleted = () => {
this.props.history.push("/repos");
};
delete = (repository: Repository) => {
this.props.deleteRepo(repository, this.deleted);
};
render() {
const { loading, error, repository, t } = this.props;
@@ -81,6 +95,7 @@ class RepositoryRoot extends React.Component<Props> {
<div className="column">
<Navigation>
<Section label={t("repository-root.actions-label")}>
<DeleteNavAction repository={repository} delete={this.delete} />
<NavLink to="/repos" label={t("repository-root.back-label")} />
</Section>
</Navigation>
@@ -109,6 +124,9 @@ const mapDispatchToProps = dispatch => {
return {
fetchRepo: (namespace: string, name: string) => {
dispatch(fetchRepo(namespace, name));
},
deleteRepo: (repository: Repository, callback: () => void) => {
dispatch(deleteRepo(repository, callback));
}
};
};