mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +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 React, { ComponentType, FC, ReactNode } from "react";
|
||||||
import {
|
import {
|
||||||
Branch,
|
Branch,
|
||||||
|
BranchDetails,
|
||||||
Changeset,
|
Changeset,
|
||||||
ContentType,
|
ContentType,
|
||||||
File,
|
File,
|
||||||
@@ -682,12 +683,38 @@ export type GroupInformationTableBottom = RenderableExtensionPointDefinition<
|
|||||||
{ group: Group }
|
{ group: Group }
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type BranchListDetailProps = {
|
type BranchMenuDetailProps = {
|
||||||
repository: Repository;
|
repository: Repository;
|
||||||
branch: Branch;
|
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
|
* @since 2.46.0
|
||||||
* @example
|
* @example
|
||||||
* ```typescript
|
* ```typescript
|
||||||
|
|||||||
@@ -44,10 +44,9 @@ type Props = {
|
|||||||
branchesDetails?: BranchDetails[];
|
branchesDetails?: BranchDetails[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const BranchListItem: FC<Props> = ({ branch, remove, isLoading, branchesDetails, baseUrl, repository }) => {
|
const BranchListItem: FC<Props> = ({ branch, remove, isLoading, branchesDetails, baseUrl, repository }) => {
|
||||||
const [t] = useTranslation("repos");
|
const [t] = useTranslation("repos");
|
||||||
|
const branchDetails = branchesDetails?.find(({ branchName }) => branchName === branch.name);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CardList.Card
|
<CardList.Card
|
||||||
@@ -70,6 +69,14 @@ const BranchListItem: FC<Props> = ({ branch, remove, isLoading, branchesDetails,
|
|||||||
<Icon>trash</Icon>
|
<Icon>trash</Icon>
|
||||||
{t("branch.delete.button")}
|
{t("branch.delete.button")}
|
||||||
</Menu.DialogButton>
|
</Menu.DialogButton>
|
||||||
|
<ExtensionPoint<extensionPoints.BranchListMenu>
|
||||||
|
name="branches.list.menu"
|
||||||
|
props={{
|
||||||
|
repository,
|
||||||
|
branch,
|
||||||
|
}}
|
||||||
|
renderAll
|
||||||
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
) : undefined
|
) : undefined
|
||||||
}
|
}
|
||||||
@@ -102,19 +109,16 @@ const BranchListItem: FC<Props> = ({ branch, remove, isLoading, branchesDetails,
|
|||||||
<Card.Details.Detail.Label id={labelId}>
|
<Card.Details.Detail.Label id={labelId}>
|
||||||
{branch.defaultBranch ? null : t("branch.aheadBehind.label")}
|
{branch.defaultBranch ? null : t("branch.aheadBehind.label")}
|
||||||
</Card.Details.Detail.Label>
|
</Card.Details.Detail.Label>
|
||||||
<AheadBehindTag
|
<AheadBehindTag branch={branch} details={branchDetails} labelId={labelId} />
|
||||||
branch={branch}
|
|
||||||
details={branchesDetails?.find(({ branchName }) => branchName === branch.name)}
|
|
||||||
labelId={labelId}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Card.Details.Detail>
|
</Card.Details.Detail>
|
||||||
<ExtensionPoint<extensionPoints.BranchListDetail>
|
<ExtensionPoint<extensionPoints.BranchListDetail>
|
||||||
name="branches.list.detail"
|
name="branches.list.detail"
|
||||||
props={{
|
props={{
|
||||||
branch,
|
|
||||||
repository,
|
repository,
|
||||||
|
branch,
|
||||||
|
branchDetails,
|
||||||
}}
|
}}
|
||||||
renderAll
|
renderAll
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user