diff --git a/studio/components/interfaces/BranchManagement/BranchManagement.tsx b/studio/components/interfaces/BranchManagement/BranchManagement.tsx index 3192f449c0d..da56682d816 100644 --- a/studio/components/interfaces/BranchManagement/BranchManagement.tsx +++ b/studio/components/interfaces/BranchManagement/BranchManagement.tsx @@ -12,6 +12,8 @@ import { useSelectedProject, useStore } from 'hooks' import { Button, IconSearch, Input } from 'ui' import { BranchHeader, BranchPanel, MainBranchPanel } from './BranchPanels' import UpdateBranchSidePanel from './UpdateBranchSidePanel' +import PullRequests from './PullRequests' +import PreviewBranches from './PreviewBranches' const BranchManagement = () => { const { ui } = useStore() @@ -59,15 +61,12 @@ const BranchManagement = () => { {isSuccess && ( <> {}} /> - - {previewBranches.map((branch) => ( - setSelectedBranchToUpdate(branch)} - onSelectDelete={() => setSelectedBranchToDelete(branch)} - /> - ))} + + )} diff --git a/studio/components/interfaces/BranchManagement/BranchPanels.tsx b/studio/components/interfaces/BranchManagement/BranchPanels.tsx index 5b23a440225..c65a293c92a 100644 --- a/studio/components/interfaces/BranchManagement/BranchPanels.tsx +++ b/studio/components/interfaces/BranchManagement/BranchPanels.tsx @@ -1,5 +1,7 @@ +import clsx from 'clsx' import dayjs from 'dayjs' -import { forwardRef, useState } from 'react' +import { noop } from 'lodash' +import { PropsWithChildren, forwardRef, useState } from 'react' import { Badge, Button, @@ -16,10 +18,9 @@ import { cn, } from 'ui' +import { useParams } from 'common' import { Markdown } from 'components/interfaces/Markdown' import { Branch } from 'data/branches/branches-query' -import { noop } from 'lodash' -import { useParams } from 'common' interface BranchPanelProps { branch?: Branch @@ -71,6 +72,22 @@ const MainBranchPanel = ({ branch, onSelectUpdate = noop }: BranchPanelProps) => ) } +const BranchContainer = ({ className, children }: PropsWithChildren<{ className?: string }>) => { + return ( +
+
+
+ {children} +
+
+ ) +} + const BranchPanel = ({ branch, onSelectUpdate = noop, @@ -85,40 +102,35 @@ const BranchPanel = ({ const formattedCreatedAt = dayjs(branch?.created_at).format('DD MMM YYYY, HH:mm:ss (ZZ)') return ( -
  • -
    -
    -
    - -

    {branch?.name}

    - {isActive && Selected} -

    - {daysFromNow > 1 - ? `Created on ${formattedCreatedAt}` - : `Created ${formattedTimeFromNow}`} -

    -
    -
    - setOpen(!open)} modal={false}> - - - - - onSelectUpdate()}> - - Edit branch - - onSelectDelete()}> - - Delete branch - - - -
    + +
    + +

    {branch?.name}

    + {isActive && Selected} +

    + {daysFromNow > 1 ? `Created on ${formattedCreatedAt}` : `Created ${formattedTimeFromNow}`} +

    -
  • +
    + setOpen(!open)} modal={false}> + + + + + onSelectUpdate()}> + + Edit branch + + onSelectDelete()}> + + Delete branch + + + +
    + ) } @@ -145,4 +157,4 @@ const BranchHeader = forwardRef( ) BranchHeader.displayName = 'BranchHeader' -export { BranchHeader, MainBranchPanel, BranchPanel } +export { BranchHeader, BranchContainer, BranchPanel, MainBranchPanel } diff --git a/studio/components/interfaces/BranchManagement/PreviewBranches.tsx b/studio/components/interfaces/BranchManagement/PreviewBranches.tsx new file mode 100644 index 00000000000..4bd7f567b27 --- /dev/null +++ b/studio/components/interfaces/BranchManagement/PreviewBranches.tsx @@ -0,0 +1,61 @@ +import { Branch } from 'data/branches/branches-query' +import { BranchContainer, BranchHeader, BranchPanel } from './BranchPanels' +import { Button, IconExternalLink, IconGitBranch } from 'ui' + +interface PreviewBranchesProps { + previewBranches: Branch[] + onSelectUpdateBranch: (branch: Branch) => void + onSelectDeleteBranch: (branch: Branch) => void +} + +const PreviewBranches = ({ + previewBranches, + onSelectUpdateBranch, + onSelectDeleteBranch, +}: PreviewBranchesProps) => { + return ( + <> + 0 ? `#### Preview branches` : undefined} /> + {previewBranches.length === 0 ? ( + +
    +

    No database preview branches

    +

    Database preview branches will be shown here

    +
    +
    +
    + +
    +

    Create a preview branch

    +

    Start developing in preview

    +
    +
    + +
    +
    +
    +

    Not sure what to do?

    +

    Browse our documentation

    +
    + +
    +
    +
    +
    + ) : ( + previewBranches.map((branch) => ( + onSelectUpdateBranch(branch)} + onSelectDelete={() => onSelectDeleteBranch(branch)} + /> + )) + )} + + ) +} + +export default PreviewBranches diff --git a/studio/components/interfaces/BranchManagement/PullRequests.tsx b/studio/components/interfaces/BranchManagement/PullRequests.tsx new file mode 100644 index 00000000000..0e1fd0aeefd --- /dev/null +++ b/studio/components/interfaces/BranchManagement/PullRequests.tsx @@ -0,0 +1,59 @@ +import { Branch } from 'data/branches/branches-query' +import { BranchContainer, BranchHeader } from './BranchPanels' +import { Button, IconExternalLink, IconGitBranch } from 'ui' + +interface PullRequestsProps { + previewBranches: Branch[] +} + +const PullRequests = ({ previewBranches }: PullRequestsProps) => { + const pullRequests = [] + + return ( + <> + 0 && previewBranches.length > 0 + ? `#### Open pull requests` + : undefined + } + /> + {previewBranches.length === 0 || pullRequests.length === 0 ? ( + +
    +

    No pull requests made yet for this repository

    +

    + Only pull requests with the ./migration directory changes will show here. +

    + {previewBranches.length > 0 && ( +
    +
    +
    + +

    Create a pull request

    +
    + +
    +
    +
    +

    Not sure what to do?

    +

    Browse our documentation

    +
    + +
    +
    + )} +
    +
    + ) : ( + State 3 + )} + + ) +} + +export default PullRequests