File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
src/features/repo-explorer/components Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,14 @@ import "./index.scss";
77type Props = {
88 repo : RepoIdentity ;
99 branches ?: Array < BranchIdentity > ;
10+ onVisibleChange ?: ( flag : boolean ) => void ;
1011} ;
1112
12- const BranchesMenu = ( { repo, branches } : Props ) => {
13+ const BranchesMenu = ( { repo, branches, onVisibleChange } : Props ) => {
1314 return (
14- < Menu className = "branches-menu" onClick = { ( ) => { } } >
15+ < Menu className = "branches-menu" >
1516 { branches ?. map ( ( branch , index ) => (
16- < Menu . Item key = { index } >
17+ < Menu . Item key = { index } onClick = { ( ) => onVisibleChange ?. ( false ) } >
1718 < Link to = { `/${ repo . owner } /${ repo . name } /tree/${ branch . name } ` } >
1819 { branch . name }
1920 </ Link >
Original file line number Diff line number Diff line change 11import { Button , Dropdown , Popover } from "antd" ;
2- import React from "react" ;
2+ import React , { useState } from "react" ;
33import { RepoIdentity , BranchIdentity } from "models" ;
44import BranchesMenu from "../branches-menu" ;
55import CloneMenu from "./clone-menu" ;
@@ -12,12 +12,21 @@ type Props = {
1212} ;
1313
1414const RepoToolbar = ( { repo, branches, activeBranch } : Props ) => {
15+ const [ isBranchDropdownVisible , setBranchDropdownVisible ] = useState ( false ) ;
1516 return (
1617 < div className = "flex justify-between" >
1718 < Dropdown
18- overlay = { < BranchesMenu branches = { branches } repo = { repo } /> }
19+ overlay = {
20+ < BranchesMenu
21+ branches = { branches }
22+ repo = { repo }
23+ onVisibleChange = { setBranchDropdownVisible }
24+ />
25+ }
1926 placement = "bottomLeft"
2027 arrow
28+ visible = { isBranchDropdownVisible }
29+ onVisibleChange = { setBranchDropdownVisible }
2130 trigger = { [ "click" ] }
2231 >
2332 < Button className = "branch-dropdown" > { activeBranch } </ Button >
You can’t perform that action at this time.
0 commit comments