pull/5026/head
bunsenstraat 7 months ago committed by Aniket
parent 123a077a07
commit 1747a4ba9f
  1. 6
      libs/remix-ui/git/src/components/navigation/commitdetails.tsx
  2. 3
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  3. 9
      libs/remix-ui/git/src/components/panels/commits/commitdetails.tsx
  4. 7
      libs/remix-ui/git/src/components/panels/commits/commitdetailsitem.tsx
  5. 7
      libs/remix-ui/git/src/components/panels/commits/commitsummary.tsx
  6. 6
      libs/remix-ui/git/src/lib/listeners.ts

@ -3,6 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { useContext, useEffect } from "react";
import { CommitSummary } from "../panels/commits/commitsummary";
import { ReadCommitResult } from "isomorphic-git"
import { branch } from "../../types";
interface CommitDetailsNavigationProps {
commit: ReadCommitResult,
@ -11,10 +12,11 @@ interface CommitDetailsNavigationProps {
activePanel: string
callback: (eventKey: string) => void
isAheadOfRepo: boolean
branch: branch
}
export const CommitDetailsNavigation = (props: CommitDetailsNavigationProps) => {
const { commit, checkout, eventKey, activePanel, callback, isAheadOfRepo } = props;
const { commit, checkout, eventKey, activePanel, callback, isAheadOfRepo, branch } = props;
const handleClick = () => {
if (!callback) return
if (activePanel === eventKey) {
@ -30,7 +32,7 @@ export const CommitDetailsNavigation = (props: CommitDetailsNavigationProps) =>
activePanel === eventKey ? <FontAwesomeIcon className='' icon={faCaretDown}></FontAwesomeIcon> : <FontAwesomeIcon className='' icon={faCaretRight}></FontAwesomeIcon>
}
<CommitSummary isAheadOfRepo={isAheadOfRepo} commit={commit} checkout={checkout}></CommitSummary>
<CommitSummary branch={branch} isAheadOfRepo={isAheadOfRepo} commit={commit} checkout={checkout}></CommitSummary>
</div>
</>
);

@ -19,10 +19,11 @@ export const PushPull = () => {
const [force, setForce] = useState(false)
useEffect(() => {
console.log('context.currentBranch', context.currentBranch, context.remotes, context.branches)
setRemoteBranch(context.currentBranch.name)
setLocalBranch(context.currentBranch.name)
const currentUpstreamIsInRemotes = context.upstream && context.remotes.find(r => r.name === context.upstream.name)
const currentUpstreamIsInRemotes = context.upstream && context.remotes.find(r => r.name === context.upstream.name && r.url === context.upstream.url)
if (!context.upstream || !currentUpstreamIsInRemotes) {
if (context.currentBranch && context.currentBranch.remote && context.currentBranch.remote.name) {
actions.setUpstreamRemote(context.currentBranch.remote)

@ -28,7 +28,7 @@ export const CommitDetails = (props: CommitDetailsProps) => {
}, [activePanel])
const getRemote = (): remote | null => {
return context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
return branch.remote? branch.remote: context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
}
const commitsAhead = (remote: remote) => {
@ -40,19 +40,20 @@ export const CommitDetails = (props: CommitDetailsProps) => {
return commitsAhead(getRemote()).findIndex((c) => c.oid === commit.oid) > -1
}
const openFileOnRemote = (file: string, hash: string) => {
const openFileOnRemote = (file: string, hash: string, branch: branch) => {
console.log(branch)
if (!getRemote()) return
window.open(`${getRemote() ? `${removeGitFromUrl(getRemote().url)}/blob/${hash}/${file}` : ""}`, "_blank")
}
return (<Accordion activeKey={activePanel} defaultActiveKey="">
<CommitDetailsNavigation isAheadOfRepo={isAheadOfRepo()} commit={commit} checkout={checkout} eventKey="0" activePanel={activePanel} callback={setActivePanel} />
<CommitDetailsNavigation isAheadOfRepo={isAheadOfRepo()} branch={branch} commit={commit} checkout={checkout} eventKey="0" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className="pl-2 border-left ml-1" eventKey="0">
<>
{context.commitChanges && context.commitChanges.filter(
(change) => change.hashModified === commit.oid && change.hashOriginal === commit.commit.parent[0]
).map((change, index) => {
return (<CommitDetailsItems openFileOnRemote={openFileOnRemote} isAheadOfRepo={isAheadOfRepo()} key={index} commitChange={change}></CommitDetailsItems>)
return (<CommitDetailsItems branch={branch} openFileOnRemote={openFileOnRemote} isAheadOfRepo={isAheadOfRepo()} key={index} commitChange={change}></CommitDetailsItems>)
})}
</>

@ -9,11 +9,12 @@ import GitUIButton from "../../buttons/gituibutton";
export interface CCommitDetailsItemsProps {
commitChange: commitChange;
isAheadOfRepo: boolean;
openFileOnRemote: (file: string, hash: string) => void;
openFileOnRemote: (file: string, hash: string, branch: branch) => void;
branch: branch
}
export const CommitDetailsItems = (props: CCommitDetailsItemsProps) => {
const { commitChange, isAheadOfRepo, openFileOnRemote } = props;
const { commitChange, isAheadOfRepo, openFileOnRemote, branch } = props;
const actions = React.useContext(gitActionsContext)
const pluginActions = React.useContext(pluginActionsContext)
@ -23,7 +24,7 @@ export const CommitDetailsItems = (props: CCommitDetailsItemsProps) => {
}
const openRemote = () => {
openFileOnRemote(commitChange.path, commitChange.hashModified)
openFileOnRemote(commitChange.path, commitChange.hashModified, branch)
}
function FunctionStatusIcons() {

@ -3,7 +3,7 @@ import { default as dateFormat } from "dateformat";
import React from "react";
import { faGlobe } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { remote } from "@remix-ui/git";
import { branch, remote } from "@remix-ui/git";
import GitUIButton from "../../buttons/gituibutton";
import { gitPluginContext } from "../../gitui";
import { removeGitFromUrl } from "../../../utils";
@ -12,10 +12,11 @@ export interface CommitSummaryProps {
commit: ReadCommitResult;
checkout: (oid: string) => void;
isAheadOfRepo: boolean
branch: branch
}
export const CommitSummary = (props: CommitSummaryProps) => {
const { commit, checkout, isAheadOfRepo } = props;
const { commit, checkout, isAheadOfRepo, branch } = props;
const context = React.useContext(gitPluginContext)
const getDate = (commit: ReadCommitResult) => {
@ -47,7 +48,7 @@ export const CommitSummary = (props: CommitSummaryProps) => {
};
const getRemote = (): remote | null => {
return context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
return branch.remote? branch.remote: context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
}
const openRemote = () => {

@ -141,6 +141,12 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
loadFileQueue.enqueue(async () => {
loadFiles()
})
loadFileQueue.enqueue(async () => {
getBranches()
})
loadFileQueue.enqueue(async () => {
gitlog()
})
})
plugin.on('manager', 'pluginActivated', async (p: Profile<any>) => {
if (p.name === 'dgitApi') {

Loading…
Cancel
Save