Files
3f3ed433fc Remove enable branching modal (#36458)
* remove enable branching modal

* re-add github linker

* abstract away enable and disable

* toggle fixes

* update logic to lean on connection status

* update form logic

* sheet layout

* gitless flag

* fix side panel size

* copy changes

* remove import

* add cost

* allow connection details on create

* Fix TS issues

* Fix TS issues

* Couple of clean ups

* Revert hardcode in useFlag

* Fix TS

* layout issues and github check

* refactor

* refactor to use new field

* cleanup

* style

* clarification with github integration

* replace branch dropdown button

* update repo picker

* remove modal

* change defaults

* disable if not gitless and no connection

* fixes

* prevent editing on child branch

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
2025-07-02 21:58:45 +10:00

79 lines
2.3 KiB
TypeScript

import { noop } from 'lodash'
import { Button } from 'ui'
import type { Branch } from 'data/branches/branches-query'
import { ChevronRight } from 'lucide-react'
import { BranchLoader, BranchManagementSection, BranchRow, BranchRowLoader } from './BranchPanels'
import { PreviewBranchesEmptyState } from './EmptyStates'
const MAX_BRANCHES_OVERVIEW = 10
interface OverviewProps {
isLoading: boolean
isSuccess: boolean
repo: string
mainBranch: Branch
previewBranches: Branch[]
onViewAllBranches: () => void
onSelectCreateBranch: () => void
onSelectDeleteBranch: (branch: Branch) => void
generateCreatePullRequestURL: (branchName?: string) => string
showProductionBranch?: boolean
}
export const Overview = ({
isLoading,
isSuccess,
repo,
mainBranch,
previewBranches,
onViewAllBranches,
onSelectCreateBranch,
onSelectDeleteBranch,
generateCreatePullRequestURL,
showProductionBranch = true,
}: OverviewProps) => {
return (
<>
{showProductionBranch && (
<BranchManagementSection header="Production branch">
{isLoading && <BranchRowLoader />}
{isSuccess && mainBranch !== undefined && (
<BranchRow isMain branch={mainBranch} repo={repo} onSelectDeleteBranch={noop} />
)}
</BranchManagementSection>
)}
<BranchManagementSection
header="Preview branches"
footer={
isSuccess && (
<div className="flex items-center justify-center">
<Button type="text" iconRight={<ChevronRight />} onClick={() => onViewAllBranches()}>
View all branches
</Button>
</div>
)
}
>
{isLoading && <BranchLoader />}
{isSuccess && previewBranches.length === 0 && (
<PreviewBranchesEmptyState onSelectCreateBranch={onSelectCreateBranch} />
)}
{isSuccess &&
previewBranches.slice(0, MAX_BRANCHES_OVERVIEW).map((branch) => {
return (
<BranchRow
key={branch.id}
repo={repo}
branch={branch}
generateCreatePullRequestURL={generateCreatePullRequestURL}
onSelectDeleteBranch={() => onSelectDeleteBranch(branch)}
/>
)
})}
</BranchManagementSection>
</>
)
}