mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 08:06:09 +01:00
Extend BranchListItem extensionPoints
Committed-by: Konstantin Schaper <konstantin.schaper@cloudogu.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user