Files
supabase/apps/studio/components/interfaces/BranchManagement/Overview.tsx
T
Ivan VasilovandJoshen Lim 05a542ccea chore: Migrate all feather icons to lucide icons (#29038)
* Add lucide-react to docs (to make the autocomplete work).

* Migrate the docs app icons.

* Migrate the ui-patterns.

* Remove the old icons from ui package.

* Migrate the www app from react-feather icons.

* Migrate all of studio icons.

* Migrate the only component in design-system.

* Fix an old import in ui package. Revert an import in docs app.

* Fix some pages in www.

* Remove unneeded files used in generation of icons.

* Fix a prettier error.

* Fix more issues in www.

* Fix an issue in Log Date picker.

* Replace all string sizes with number sizes because the icons grew in some cases.

* Fix more imports in security page.

* Fix an extra import.

* Remove the size prop from all icons if they're in a button and they match the button size.

* Minor fixes for docs and www.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-09-04 19:46:21 +08:00

77 lines
2.2 KiB
TypeScript

import { noop } from 'lodash'
import { Button } from 'ui'
import type { Branch } from 'data/branches/branches-query'
import { BranchLoader, BranchManagementSection, BranchRow, BranchRowLoader } from './BranchPanels'
import { PreviewBranchesEmptyState } from './EmptyStates'
import { ChevronRight } from 'lucide-react'
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
}
const Overview = ({
isLoading,
isSuccess,
repo,
mainBranch,
previewBranches,
onViewAllBranches,
onSelectCreateBranch,
onSelectDeleteBranch,
generateCreatePullRequestURL,
}: OverviewProps) => {
return (
<>
<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>
</>
)
}
export default Overview