fix sourcecontrol buttons

git4refactor
filip mertens 7 months ago
parent c46e181394
commit 1e840f49ad
  1. 12
      libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx
  2. 5
      libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx
  3. 7
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx

@ -23,25 +23,33 @@ export const SourceControlButtons = (props: SourceControlButtonsProps) => {
useEffect(() => {
console.log('BRANCH DIFF SourceControlButtons', context.branchDifferences, remote, branch)
console.log('BRANCH DIFF SourceControlButtons',branch, remote, context.branchDifferences, context.currentBranch)
setDefaultRemote()
if (remote && branch && context.branchDifferences && context.branchDifferences[`${remote.remote}/${branch.name}`]) {
console.log('BRANCH DIFF found SourceControlButtons', context.branchDifferences[`${remote.remote}/${branch.name}`])
setCommitsAhead(context.branchDifferences[`${remote.remote}/${branch.name}`]?.uniqueHeadCommits)
setCommitsBehind(context.branchDifferences[`${remote.remote}/${branch.name}`]?.uniqueRemoteCommits)
}else{
setCommitsAhead([])
setCommitsBehind([])
}
}, [context.branchDifferences, branch, remote])
}, [context.branchDifferences, context.currentBranch, branch, remote])
const setDefaultRemote = () => {
if (context.remotes.length > 0) {
// find remote called origin
const origin = context.remotes.find(remote => remote.remote === 'origin')
console.log('DEFAULT REMOTE', origin)
if (origin) {
setRemote(origin)
} else {
setRemote(context.remotes[0])
}
return origin
}
return null
}
useEffect(() => {

@ -5,12 +5,13 @@ import React, { useContext, useEffect } from "react";
import { FormattedMessage } from "react-intl";
import { pluginActionsContext } from "../../state/context";
import { SourceControlButtons } from "../buttons/sourcecontrolbuttons";
import { gitPluginContext } from "../gitui";
import LoaderIndicator from "./loaderindicator";
import { SourceControlMenu } from "./menu/sourcecontrolmenu";
export const SourceControlNavigation = ({ eventKey, activePanel, callback }) => {
const pluginactions = React.useContext(pluginActionsContext)
const context = React.useContext(gitPluginContext)
const handleClick = () => {
if (!callback) return
if (activePanel === eventKey) {
@ -32,7 +33,7 @@ export const SourceControlNavigation = ({ eventKey, activePanel, callback }) =>
</span>
<SourceControlButtons />
<SourceControlButtons/>
</div>

@ -20,7 +20,6 @@ export const PushPull = () => {
setRemoteBranch(context.currentBranch.name)
setLocalBranch(context.currentBranch.name)
if ((!context.upstream) && context.currentBranch && context.currentBranch.remote && context.currentBranch.remote.remote) {
console.log('SET UPSTREAM', context.currentBranch.remote)
actions.setUpstreamRemote(context.currentBranch.remote)
}
}, [context.currentBranch])
@ -32,22 +31,16 @@ export const PushPull = () => {
}
const onLocalBranchChange = (value: any) => {
console.log('onLocalBranchChange', value)
setLocalBranch(value)
}
const onRemoteChange = (value: string) => {
console.log('onRemoteChange', value, context)
const remote: remote = context.remotes.find(r => r.remote === value)
if(remote) {
actions.setUpstreamRemote(remote)
}
}
useEffect(() => {
console.log('UPSTREAM', context.upstream, context)
}, [context.upstream])
const onForceChange = (event: any) => {
const target = event.target;
const value = target.checked;

Loading…
Cancel
Save