Extend BranchListItem extensionPoints

Committed-by: Konstantin Schaper <konstantin.schaper@cloudogu.com>
This commit is contained in:
Florian Scholdei
2023-08-11 14:12:03 +02:00
parent 1750eae2d1
commit 4136a68f48
2 changed files with 40 additions and 9 deletions

View File

@@ -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<extensionPoints.BranchListMenu>(
* "branches.list.menu",
* <Menu.Link to="/code/sources/etc">
* <Icon>code</Icon>
* <span>Jump to source</span>
* </Menu.Link>
* )
* ```
*/
export type BranchListMenu = RenderableExtensionPointDefinition<"branches.list.menu", BranchMenuDetailProps>;
type BranchListDetailProps = {
repository: Repository;
branch: Branch;
branchDetails?: BranchDetails;
};
/**
* @beta
* @since 2.46.0
* @example
* ```typescript

View File

@@ -44,10 +44,9 @@ type Props = {
branchesDetails?: BranchDetails[];
};
const BranchListItem: FC<Props> = ({ branch, remove, isLoading, branchesDetails, baseUrl, repository }) => {
const [t] = useTranslation("repos");
const branchDetails = branchesDetails?.find(({ branchName }) => branchName === branch.name);
return (
<CardList.Card
@@ -70,6 +69,14 @@ const BranchListItem: FC<Props> = ({ branch, remove, isLoading, branchesDetails,
<Icon>trash</Icon>
{t("branch.delete.button")}
</Menu.DialogButton>
<ExtensionPoint<extensionPoints.BranchListMenu>
name="branches.list.menu"
props={{
repository,
branch,
}}
renderAll
/>
</Menu>
) : undefined
}
@@ -102,19 +109,16 @@ const BranchListItem: FC<Props> = ({ branch, remove, isLoading, branchesDetails,
<Card.Details.Detail.Label id={labelId}>
{branch.defaultBranch ? null : t("branch.aheadBehind.label")}
</Card.Details.Detail.Label>
<AheadBehindTag
branch={branch}
details={branchesDetails?.find(({ branchName }) => branchName === branch.name)}
labelId={labelId}
/>
<AheadBehindTag branch={branch} details={branchDetails} labelId={labelId} />
</>
)}
</Card.Details.Detail>
<ExtensionPoint<extensionPoints.BranchListDetail>
name="branches.list.detail"
props={{
branch,
repository,
branch,
branchDetails,
}}
renderAll
/>