diff --git a/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx b/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx index 0f0300ae49..fcad46ffc9 100644 --- a/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx +++ b/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx @@ -1,17 +1,21 @@ -import { faArrowDown, faArrowUp, faArrowsUpDown, faArrowRotateRight } from "@fortawesome/free-solid-svg-icons" -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" -import { CustomTooltip } from "@remix-ui/helper" -import React, { useEffect, useState } from "react" -import { FormattedMessage } from "react-intl" -import { gitActionsContext } from "../../state/context" -import { branch, remote } from "@remix-api" -import { defaultGitState, gitMatomoEventTypes } from "../../types" -import { gitPluginContext } from "../gitui" -import GitUIButton from "./gituibutton" -import { syncStateContext } from "./sourceControlBase" -import { sendToMatomo } from "../../lib/pluginActions" +import {faArrowDown, faArrowUp, faArrowsUpDown, faArrowRotateRight} from '@fortawesome/free-solid-svg-icons' +import {FontAwesomeIcon} from '@fortawesome/react-fontawesome' +import {CustomTooltip} from '@remix-ui/helper' +import React, {useEffect, useState} from 'react' +import {FormattedMessage} from 'react-intl' +import {gitActionsContext} from '../../state/context' +import {branch, remote} from '@remix-api' +import {defaultGitState, gitMatomoEventTypes, gitUIPanels} from '../../types' +import {gitPluginContext} from '../gitui' +import GitUIButton from './gituibutton' +import {syncStateContext} from './sourceControlBase' +import {sendToMatomo} from '../../lib/pluginActions' -export const SourceControlButtons = () => { +export interface SourceControlButtonsProps { + panel: string +} + +export const SourceControlButtons = (props: SourceControlButtonsProps) => { const context = React.useContext(gitPluginContext) const actions = React.useContext(gitActionsContext) const syncState = React.useContext(syncStateContext) @@ -29,21 +33,21 @@ export const SourceControlButtons = () => { const pull = async () => { await actions.pull({ remote: getRemote(), - ref: branch ? branch : context.currentBranch + ref: branch ? branch : context.currentBranch, }) } const push = async () => { await actions.push({ remote: getRemote(), - ref: branch ? branch : context.currentBranch + ref: branch ? branch : context.currentBranch, }) await actions.fetch({ remote: getRemote(), ref: branch ? branch : context.currentBranch, relative: false, depth: 1, - singleBranch: true + singleBranch: true, }) } @@ -52,50 +56,63 @@ export const SourceControlButtons = () => { await push() } - const refresh = async() => { + const refresh = async () => { await sendToMatomo(gitMatomoEventTypes.REFRESH) await actions.getFileStatusMatrix(null) + if (props.panel === gitUIPanels.BRANCHES) { + await actions.getBranches() + } + if (props.panel === gitUIPanels.COMMITS) { + await actions.gitlog(defaultGitState.gitLogCount) + } actions.setStateGitLogCount(defaultGitState.gitLogCount) } const buttonsDisabled = () => { - return (!context.upstream) || context.remotes.length === 0 + return !context.upstream || context.remotes.length === 0 } const getTooltipText = (id: string) => { if (buttonsDisabled()) return - return <> {getRemoteName()} + return ( + <> + {getRemoteName()} + + ) } return ( - - - -
- {syncState.commitsBehind.length ?
- {syncState.commitsBehind.length} -
: null} - -
-
-
- - -
- {syncState.commitsAhead.length ?
- {syncState.commitsAhead.length} -
: null} - -
-
-
- - - + + {props.panel === gitUIPanels.COMMITS || props.panel === gitUIPanels.SOURCECONTROL ? ( + <> + + +
+ {syncState.commitsBehind.length ?
{syncState.commitsBehind.length}
: null} + +
+
+
+ + +
+ {syncState.commitsAhead.length ?
{syncState.commitsAhead.length}
: null} + +
+
+
+ + + + + + + ) : null} }> - + + +
- ) -} \ No newline at end of file +} diff --git a/libs/remix-ui/git/src/components/navigation/branches.tsx b/libs/remix-ui/git/src/components/navigation/branches.tsx index 21decc6e7a..be02305932 100644 --- a/libs/remix-ui/git/src/components/navigation/branches.tsx +++ b/libs/remix-ui/git/src/components/navigation/branches.tsx @@ -3,6 +3,9 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import React, { } from "react"; import { gitActionsContext, pluginActionsContext } from "../../state/context"; import LoaderIndicator from "./loaderindicator"; +import { gitUIPanels } from "../../types"; +import { SourceControlBase } from "../buttons/sourceControlBase"; +import { SourceControlButtons } from "../buttons/sourcecontrolbuttons"; export const BranchesNavigation = ({ eventKey, activePanel, callback }) => { const pluginactions = React.useContext(pluginActionsContext) @@ -26,6 +29,7 @@ export const BranchesNavigation = ({ eventKey, activePanel, callback }) => {
+ ); diff --git a/libs/remix-ui/git/src/components/navigation/commits.tsx b/libs/remix-ui/git/src/components/navigation/commits.tsx index 44c9299eb8..85c7dd1815 100644 --- a/libs/remix-ui/git/src/components/navigation/commits.tsx +++ b/libs/remix-ui/git/src/components/navigation/commits.tsx @@ -9,6 +9,7 @@ import { SourceControlBase } from "../buttons/sourceControlBase"; import { SourceControlButtons } from "../buttons/sourcecontrolbuttons"; import { gitPluginContext } from "../gitui"; import LoaderIndicator from "./loaderindicator"; +import { gitUIPanels } from "../../types"; export interface CommitsNavigationProps { title: string, @@ -53,7 +54,7 @@ export const CommitsNavigation = ({ eventKey, activePanel, callback, title, bran {showButtons ? - + : null} diff --git a/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx b/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx index 7baf2f50e1..9f66bc9314 100644 --- a/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx +++ b/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx @@ -9,6 +9,7 @@ import { SourceControlButtons } from "../buttons/sourcecontrolbuttons"; import { gitPluginContext } from "../gitui"; import LoaderIndicator from "./loaderindicator"; import { SourceControlMenu } from "./menu/sourcecontrolmenu"; +import { gitUIPanels } from "../../types"; export const SourceControlNavigation = ({ eventKey, activePanel, callback }) => { const pluginactions = React.useContext(pluginActionsContext) @@ -35,7 +36,7 @@ export const SourceControlNavigation = ({ eventKey, activePanel, callback }) => - + diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index 7505501118..7ced95da51 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -51,6 +51,7 @@ export const getBranches = async () => { const branches = await plugin.call('dgitApi', 'branches') dispatch(setBranches(branches)); + await showCurrentBranch(); } export const getRemotes = async () => {