mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 02:06:18 +01:00
Distinct between active and stale branches
This commit is contained in:
@@ -30,10 +30,11 @@ import { apiClient, ConfirmAlert, ErrorNotification } from "@scm-manager/ui-comp
|
||||
type Props = {
|
||||
baseUrl: string;
|
||||
branches: Branch[];
|
||||
type: string;
|
||||
fetchBranches: () => void;
|
||||
};
|
||||
|
||||
const BranchTable: FC<Props> = ({ baseUrl, branches, fetchBranches }) => {
|
||||
const BranchTable: FC<Props> = ({ baseUrl, branches, type, fetchBranches }) => {
|
||||
const [t] = useTranslation("repos");
|
||||
const [showConfirmAlert, setShowConfirmAlert] = useState(false);
|
||||
const [error, setError] = useState<Error | undefined>();
|
||||
@@ -92,7 +93,7 @@ const BranchTable: FC<Props> = ({ baseUrl, branches, fetchBranches }) => {
|
||||
<table className="card-table table is-hoverable is-fullwidth is-word-break">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("branches.table.branches")}</th>
|
||||
<th>{t(`branches.table.branches.${type}`)}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderRow()}</tbody>
|
||||
|
||||
@@ -84,7 +84,28 @@ class BranchesOverview extends React.Component<Props> {
|
||||
const { baseUrl, branches, repository, fetchBranches, t } = this.props;
|
||||
if (branches && branches.length > 0) {
|
||||
orderBranches(branches);
|
||||
return <BranchTable baseUrl={baseUrl} branches={branches} fetchBranches={() => fetchBranches(repository)} />;
|
||||
const staleBranches = branches.filter(b => b.stale);
|
||||
const activeBranches = branches.filter(b => !b.stale);
|
||||
return (
|
||||
<>
|
||||
{activeBranches.length > 0 && (
|
||||
<BranchTable
|
||||
baseUrl={baseUrl}
|
||||
type={"active"}
|
||||
branches={activeBranches}
|
||||
fetchBranches={() => fetchBranches(repository)}
|
||||
/>
|
||||
)}
|
||||
{staleBranches.length > 0 && (
|
||||
<BranchTable
|
||||
baseUrl={baseUrl}
|
||||
type={"stale"}
|
||||
branches={staleBranches}
|
||||
fetchBranches={() => fetchBranches(repository)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
return <Notification type="info">{t("branches.overview.noBranches")}</Notification>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user