fixes remotes

pull/5370/head
bunsenstraat 4 months ago committed by Aniket
parent 6d995435e5
commit dcb92761c4
  1. 1
      libs/remix-ui/git/src/components/branchHeader.tsx
  2. 10
      libs/remix-ui/git/src/components/navigation/branchedetails.tsx
  3. 2
      libs/remix-ui/git/src/components/panels/branches.tsx
  4. 2
      libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx
  5. 5
      libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx
  6. 9
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  7. 2
      libs/remix-ui/git/src/components/panels/remoteselect.tsx

@ -66,6 +66,7 @@ export const BranchHeader = () => {
{getName() ? ( {getName() ? (
<span className={`text-truncate overflow-hidden whitespace-nowrap w-100`}> <span className={`text-truncate overflow-hidden whitespace-nowrap w-100`}>
{getName() ?? ''} {getName() ?? ''}
{context.currentBranch && context.currentBranch.remote && context.currentBranch.remote.name ? ` on ${context.currentBranch.remote.name}` : ''}
</span> </span>
) : null ) : null
} }

@ -13,10 +13,11 @@ interface BrancheDetailsNavigationProps {
callback: (eventKey: string) => void; callback: (eventKey: string) => void;
branch: branch; branch: branch;
checkout: (branch: branch) => void; checkout: (branch: branch) => void;
allowCheckout: boolean;
} }
export const BrancheDetailsNavigation = (props: BrancheDetailsNavigationProps) => { export const BrancheDetailsNavigation = (props: BrancheDetailsNavigationProps) => {
const { eventKey, activePanel, callback, branch, checkout } = props; const { eventKey, activePanel, callback, branch, checkout, allowCheckout } = props;
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
const actions = React.useContext(gitActionsContext) const actions = React.useContext(gitActionsContext)
const handleClick = () => { const handleClick = () => {
@ -64,10 +65,11 @@ export const BrancheDetailsNavigation = (props: BrancheDetailsNavigationProps) =
activePanel === eventKey ? <FontAwesomeIcon className='' icon={faCaretDown}></FontAwesomeIcon> : <FontAwesomeIcon className='' icon={faCaretRight}></FontAwesomeIcon> activePanel === eventKey ? <FontAwesomeIcon className='' icon={faCaretDown}></FontAwesomeIcon> : <FontAwesomeIcon className='' icon={faCaretRight}></FontAwesomeIcon>
} }
<i className="fa fa-code-branch ml-1"></i> <i className="fa fa-code-branch ml-1"></i>
<div className={`ml-1 ${context.currentBranch.name === branch.name ? 'text-success' : ''}`}>{branch.name} {branch.remote ? `on ${branch.remote.name}` : ''}</div> <div className={`ml-1 ${context.currentBranch.name === branch.name && allowCheckout ? 'text-success' : ''}`}>{branch.name} {branch.remote ? `on ${branch.remote.name}` : ''}</div>
</div> </div>
{context.currentBranch && context.currentBranch.name === branch.name ? {allowCheckout ?
context.currentBranch && context.currentBranch.name === branch.name ?
<GitUIButton data-id={`branches-toggle-current-branch-${branch.name}`} className="btn btn-sm p-0 mr-1" onClick={() => { }}> <GitUIButton data-id={`branches-toggle-current-branch-${branch.name}`} className="btn btn-sm p-0 mr-1" onClick={() => { }}>
<FontAwesomeIcon className='pointer text-success' icon={faToggleOff} ></FontAwesomeIcon> <FontAwesomeIcon className='pointer text-success' icon={faToggleOff} ></FontAwesomeIcon>
</GitUIButton> </GitUIButton>
@ -75,7 +77,7 @@ export const BrancheDetailsNavigation = (props: BrancheDetailsNavigationProps) =
<GitUIButton tooltip="checkout branch" data-id={`branches-toggle-branch-${branch.name}`} className="btn btn-sm p-0 mr-1" onClick={() => checkout(branch)}> <GitUIButton tooltip="checkout branch" data-id={`branches-toggle-branch-${branch.name}`} className="btn btn-sm p-0 mr-1" onClick={() => checkout(branch)}>
<FontAwesomeIcon icon={faToggleOn}></FontAwesomeIcon> <FontAwesomeIcon icon={faToggleOn}></FontAwesomeIcon>
</GitUIButton> </GitUIButton>
} : null}
{!branch.remote && canFetch() && <> {!branch.remote && canFetch() && <>
<GitUIButton tooltip="fetch branch" className="btn btn-sm p-0 mr-1 text-muted" onClick={() => fetchBranch()}><FontAwesomeIcon icon={faSync} ></FontAwesomeIcon></GitUIButton> <GitUIButton tooltip="fetch branch" className="btn btn-sm p-0 mr-1 text-muted" onClick={() => fetchBranch()}><FontAwesomeIcon icon={faSync} ></FontAwesomeIcon></GitUIButton>
<GitUIButton tooltip="open on remote" className="btn btn-sm p-0 mr-1 text-muted" onClick={() => openRemote()}><FontAwesomeIcon icon={faGlobe} ></FontAwesomeIcon></GitUIButton> <GitUIButton tooltip="open on remote" className="btn btn-sm p-0 mr-1 text-muted" onClick={() => openRemote()}><FontAwesomeIcon icon={faGlobe} ></FontAwesomeIcon></GitUIButton>

@ -35,7 +35,7 @@ export const Branches = () => {
<label className="text-uppercase">remote branches on {context.upstream ? context.upstream.name : null}</label> <label className="text-uppercase">remote branches on {context.upstream ? context.upstream.name : null}</label>
{context.branches && context.branches.filter((branch, index) => branch.remote && branch.remote.name === context.upstream.name).map((branch, index) => { {context.branches && context.branches.filter((branch, index) => branch.remote && branch.remote.name === context.upstream.name).map((branch, index) => {
return ( return (
<RemoteBranchDetails key={index} branch={branch}></RemoteBranchDetails> <RemoteBranchDetails allowCheckout={true} key={index} branch={branch}></RemoteBranchDetails>
); );
})} })}
<GitUIButton data-id={`remote-sync-${context.upstream.name}`} className="btn btn-sm" onClick={async () => { <GitUIButton data-id={`remote-sync-${context.upstream.name}`} className="btn btn-sm" onClick={async () => {

@ -63,7 +63,7 @@ export const LocalBranchDetails = (props: BrancheDetailsProps) => {
} }
return (<Accordion activeKey={activePanel} defaultActiveKey=""> return (<Accordion activeKey={activePanel} defaultActiveKey="">
<BrancheDetailsNavigation checkout={checkout} branch={branch} eventKey="0" activePanel={activePanel} callback={setActivePanel} /> <BrancheDetailsNavigation allowCheckout={true} checkout={checkout} branch={branch} eventKey="0" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className="pl-2 border-left ml-1" eventKey="0"> <Accordion.Collapse className="pl-2 border-left ml-1" eventKey="0">
<> <>
<div className="ml-1"> <div className="ml-1">

@ -12,10 +12,11 @@ import GitUIButton from "../../buttons/gituibutton";
export interface BrancheDetailsProps { export interface BrancheDetailsProps {
branch: branch; branch: branch;
allowCheckout: boolean
} }
export const RemoteBranchDetails = (props: BrancheDetailsProps) => { export const RemoteBranchDetails = (props: BrancheDetailsProps) => {
const { branch } = props; const { branch, allowCheckout } = props;
const actions = React.useContext(gitActionsContext) const actions = React.useContext(gitActionsContext)
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
const [activePanel, setActivePanel] = useState<string>(""); const [activePanel, setActivePanel] = useState<string>("");
@ -89,7 +90,7 @@ export const RemoteBranchDetails = (props: BrancheDetailsProps) => {
} }
return (<Accordion activeKey={activePanel} defaultActiveKey=""> return (<Accordion activeKey={activePanel} defaultActiveKey="">
<BrancheDetailsNavigation checkout={checkout} branch={branch} eventKey="0" activePanel={activePanel} callback={setActivePanel} /> <BrancheDetailsNavigation allowCheckout={allowCheckout} checkout={checkout} branch={branch} eventKey="0" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className="pl-2 border-left ml-1" eventKey="0"> <Accordion.Collapse className="pl-2 border-left ml-1" eventKey="0">
<> <>
<div data-id={`remote-branch-commits-${branch && branch.name}`} className="ml-1"> <div data-id={`remote-branch-commits-${branch && branch.name}`} className="ml-1">

@ -58,6 +58,7 @@ export const PushPull = () => {
const remote: remote = context.remotes.find(r => r.name === value) const remote: remote = context.remotes.find(r => r.name === value)
if (remote) { if (remote) {
actions.setUpstreamRemote(remote) actions.setUpstreamRemote(remote)
actions.setDefaultRemote(remote)
} }
} }
@ -119,15 +120,19 @@ export const PushPull = () => {
}) })
setLocalBranchOptions(localBranches) setLocalBranchOptions(localBranches)
if(!context.upstream){
setRemoteBranchOptions([])
return
}
const remoteBranches = context.branches && context.branches.length > 0 && context.branches const remoteBranches = context.branches && context.branches.length > 0 && context.branches
.filter(branch => branch.remote) .filter(branch => branch.remote && branch.remote.name === context.upstream.name)
.map(repo => { .map(repo => {
return { value: repo.name, label: repo.name } return { value: repo.name, label: repo.name }
} }
) )
setRemoteBranchOptions(remoteBranches) setRemoteBranchOptions(remoteBranches)
}, [context.branches]) }, [context.branches, context.upstream])
useEffect(() => { useEffect(() => {

@ -34,7 +34,7 @@ export const Remoteselect = (props: RemoteSelectProps) => {
<> <>
{context.branches && context.branches.filter((branch, index) => branch.remote && branch.remote.name === remote.name).map((branch, index) => { {context.branches && context.branches.filter((branch, index) => branch.remote && branch.remote.name === remote.name).map((branch, index) => {
return ( return (
<RemoteBranchDetails key={index} branch={branch}></RemoteBranchDetails> <RemoteBranchDetails allowCheckout={false} key={index} branch={branch}></RemoteBranchDetails>
); );
})} })}
<GitUIButton data-id={`remote-sync-${remote.name}`} className="btn btn-sm" onClick={async () => { <GitUIButton data-id={`remote-sync-${remote.name}`} className="btn btn-sm" onClick={async () => {

Loading…
Cancel
Save