From 4136a68f480d54ffcd671086f2b7c9caddfa423a Mon Sep 17 00:00:00 2001 From: Florian Scholdei Date: Fri, 11 Aug 2023 14:12:03 +0200 Subject: [PATCH] Extend BranchListItem extensionPoints Committed-by: Konstantin Schaper --- scm-ui/ui-extensions/src/extensionPoints.tsx | 29 ++++++++++++++++++- .../branches/components/BranchListItem.tsx | 20 ++++++++----- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/scm-ui/ui-extensions/src/extensionPoints.tsx b/scm-ui/ui-extensions/src/extensionPoints.tsx index a6f7031913..7b1535cfaa 100644 --- a/scm-ui/ui-extensions/src/extensionPoints.tsx +++ b/scm-ui/ui-extensions/src/extensionPoints.tsx @@ -25,6 +25,7 @@ import React, { ComponentType, FC, ReactNode } from "react"; import { Branch, + BranchDetails, Changeset, ContentType, File, @@ -682,12 +683,38 @@ export type GroupInformationTableBottom = RenderableExtensionPointDefinition< { group: Group } >; -type BranchListDetailProps = { +type BranchMenuDetailProps = { repository: Repository; branch: Branch; }; /** + * @beta + * @since 2.46.0 + * @example + * ```typescript + * import { Menu } from "@scm-manager/ui-overlays"; + * import { Icon } from "@scm-manager/ui-buttons"; + * + * binder.bind( + * "branches.list.menu", + * + * code + * Jump to source + * + * ) + * ``` + */ +export type BranchListMenu = RenderableExtensionPointDefinition<"branches.list.menu", BranchMenuDetailProps>; + +type BranchListDetailProps = { + repository: Repository; + branch: Branch; + branchDetails?: BranchDetails; +}; + +/** + * @beta * @since 2.46.0 * @example * ```typescript diff --git a/scm-ui/ui-webapp/src/repos/branches/components/BranchListItem.tsx b/scm-ui/ui-webapp/src/repos/branches/components/BranchListItem.tsx index 2aa33c6340..5c65c0857b 100644 --- a/scm-ui/ui-webapp/src/repos/branches/components/BranchListItem.tsx +++ b/scm-ui/ui-webapp/src/repos/branches/components/BranchListItem.tsx @@ -44,10 +44,9 @@ type Props = { branchesDetails?: BranchDetails[]; }; - - const BranchListItem: FC = ({ branch, remove, isLoading, branchesDetails, baseUrl, repository }) => { const [t] = useTranslation("repos"); + const branchDetails = branchesDetails?.find(({ branchName }) => branchName === branch.name); return ( = ({ branch, remove, isLoading, branchesDetails, trash {t("branch.delete.button")} + + name="branches.list.menu" + props={{ + repository, + branch, + }} + renderAll + /> ) : undefined } @@ -102,19 +109,16 @@ const BranchListItem: FC = ({ branch, remove, isLoading, branchesDetails, {branch.defaultBranch ? null : t("branch.aheadBehind.label")} - branchName === branch.name)} - labelId={labelId} - /> + )} name="branches.list.detail" props={{ - branch, repository, + branch, + branchDetails, }} renderAll />