mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +01:00
cleanup
This commit is contained in:
@@ -31,7 +31,7 @@ import { useTranslation } from "react-i18next";
|
||||
type Props = {
|
||||
baseUrl: string;
|
||||
branch: Branch;
|
||||
onDelete: (url: string) => void;
|
||||
onDelete: (branch: Branch) => void;
|
||||
};
|
||||
|
||||
const BranchRow: FC<Props> = ({ baseUrl, branch, onDelete }) => {
|
||||
@@ -40,9 +40,8 @@ const BranchRow: FC<Props> = ({ baseUrl, branch, onDelete }) => {
|
||||
|
||||
let deleteButton;
|
||||
if ((branch?._links?.delete as Link)?.href) {
|
||||
const url = (branch._links.delete as Link).href;
|
||||
deleteButton = (
|
||||
<a className="level-item" onClick={() => onDelete(url)}>
|
||||
<a className="level-item" onClick={() => onDelete(branch)}>
|
||||
<span className="icon is-small">
|
||||
<Icon name="trash" className="fas" title={t("branch.delete.button")} />
|
||||
</span>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
import React, { FC, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import BranchRow from "./BranchRow";
|
||||
import { Branch } from "@scm-manager/ui-types";
|
||||
import { Branch, Link } from "@scm-manager/ui-types";
|
||||
import { apiClient, ConfirmAlert, ErrorNotification } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
@@ -37,21 +37,21 @@ const BranchTable: FC<Props> = ({ baseUrl, branches, fetchBranches }) => {
|
||||
const [t] = useTranslation("repos");
|
||||
const [showConfirmAlert, setShowConfirmAlert] = useState(false);
|
||||
const [error, setError] = useState<Error | undefined>();
|
||||
const [deleteBranchUrl, setDeleteBranchUrl] = useState("");
|
||||
const [branchToBeDeleted, setBranchToBeDeleted] = useState<Branch | undefined>();
|
||||
|
||||
const onDelete = (url: string) => {
|
||||
setDeleteBranchUrl(url);
|
||||
const onDelete = (branch: Branch) => {
|
||||
setBranchToBeDeleted(branch);
|
||||
setShowConfirmAlert(true);
|
||||
};
|
||||
|
||||
const abortDelete = () => {
|
||||
setDeleteBranchUrl("");
|
||||
setBranchToBeDeleted(undefined);
|
||||
setShowConfirmAlert(false);
|
||||
};
|
||||
|
||||
const deleteBranch = () => {
|
||||
apiClient
|
||||
.delete(deleteBranchUrl)
|
||||
.delete((branchToBeDeleted?._links.delete as Link).href)
|
||||
.then(() => fetchBranches())
|
||||
.catch(setError);
|
||||
};
|
||||
@@ -69,7 +69,7 @@ const BranchTable: FC<Props> = ({ baseUrl, branches, fetchBranches }) => {
|
||||
const confirmAlert = (
|
||||
<ConfirmAlert
|
||||
title={t("branch.delete.confirmAlert.title")}
|
||||
message={t("branch.delete.confirmAlert.message")}
|
||||
message={t("branch.delete.confirmAlert.message", { branch: branchToBeDeleted?.name })}
|
||||
buttons={[
|
||||
{
|
||||
className: "is-outlined",
|
||||
|
||||
@@ -52,7 +52,7 @@ const DeleteBranch: FC<Props> = ({ repository, branch }: Props) => {
|
||||
const confirmAlert = (
|
||||
<ConfirmAlert
|
||||
title={t("branch.delete.confirmAlert.title")}
|
||||
message={t("branch.delete.confirmAlert.message")}
|
||||
message={t("branch.delete.confirmAlert.message", { branch: branch.name })}
|
||||
buttons={[
|
||||
{
|
||||
className: "is-outlined",
|
||||
|
||||
Reference in New Issue
Block a user