From 27c71ec6a393d2a9574c9a605dcb9315e5583d5f Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Wed, 23 Jan 2019 12:07:28 +0100 Subject: [PATCH] added deleterepo functionality --- scm-ui/src/repos/components/DeleteRepo.js | 5 ++++- scm-ui/src/repos/containers/GeneralRepo.js | 16 +++++++++++++++- scm-ui/src/users/components/DeleteUser.js | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/scm-ui/src/repos/components/DeleteRepo.js b/scm-ui/src/repos/components/DeleteRepo.js index d1908f9daf..57ee868586 100644 --- a/scm-ui/src/repos/components/DeleteRepo.js +++ b/scm-ui/src/repos/components/DeleteRepo.js @@ -8,6 +8,9 @@ type Props = { repository: Repository, confirmDialog?: boolean, + // dispatcher functions + delete: Repository => void, + // context props t: string => string }; @@ -18,7 +21,7 @@ class DeleteRepo extends React.Component { }; delete = () => { - //this.props.delete(this.props.repository); + this.props.delete(this.props.repository); }; confirmDelete = () => { diff --git a/scm-ui/src/repos/containers/GeneralRepo.js b/scm-ui/src/repos/containers/GeneralRepo.js index 70cc9f9adc..83c5d47b52 100644 --- a/scm-ui/src/repos/containers/GeneralRepo.js +++ b/scm-ui/src/repos/containers/GeneralRepo.js @@ -7,6 +7,7 @@ import DeleteRepo from "../components/DeleteRepo"; import type { Repository } from "@scm-manager/ui-types"; import { modifyRepo, + deleteRepo, isModifyRepoPending, getModifyRepoFailure, modifyRepoReset @@ -20,6 +21,7 @@ type Props = { modifyRepo: (Repository, () => void) => void, modifyRepoReset: Repository => void, + deleteRepo: (Repository, () => void) => void, // context props repository: Repository, @@ -31,11 +33,20 @@ class GeneralRepo extends React.Component { const { modifyRepoReset, repository } = this.props; modifyRepoReset(repository); } + repoModified = () => { const { history, repository } = this.props; history.push(`/repo/${repository.namespace}/${repository.name}`); }; + deleted = () => { + this.props.history.push("/repos"); + }; + + delete = (repository: Repository) => { + this.props.deleteRepo(repository, this.deleted); + }; + render() { const { loading, error, repository } = this.props; return ( @@ -49,7 +60,7 @@ class GeneralRepo extends React.Component { }} />
- + ); } @@ -72,6 +83,9 @@ const mapDispatchToProps = dispatch => { }, modifyRepoReset: (repo: Repository) => { dispatch(modifyRepoReset(repo)); + }, + deleteRepo: (repo: Repository, callback: () => void) => { + dispatch(deleteRepo(repo, callback)); } }; }; diff --git a/scm-ui/src/users/components/DeleteUser.js b/scm-ui/src/users/components/DeleteUser.js index 7932e14558..c699d23dd1 100644 --- a/scm-ui/src/users/components/DeleteUser.js +++ b/scm-ui/src/users/components/DeleteUser.js @@ -53,6 +53,7 @@ class DeleteUser extends React.Component { if (!this.isDeletable()) { return null; } + return ( <>