fix refreshing

desktop-master-git2
bunsenstraat 3 months ago
parent 955b9cf71e
commit edca0712d1
  1. 109
      libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx
  2. 4
      libs/remix-ui/git/src/components/navigation/branches.tsx
  3. 3
      libs/remix-ui/git/src/components/navigation/commits.tsx
  4. 3
      libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx
  5. 1
      libs/remix-ui/git/src/lib/gitactions.ts

@ -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 <FormattedMessage id="git.noremote" />
return <><FormattedMessage id={id} /> {getRemoteName()}</>
return (
<>
<FormattedMessage id={id} /> {getRemoteName()}
</>
)
}
return (
<span className='d-flex justify-content-end align-items-center'>
<CustomTooltip tooltipText={getTooltipText('git.pull')}>
<GitUIButton data-id='sourcecontrol-button-pull' disabledCondition={buttonsDisabled()} onClick={pull} className='btn btn-sm pl-0 pr-2'>
<div className="d-flex align-items-baseline">
{syncState.commitsBehind.length ? <div className="badge badge-pill pl-0">
{syncState.commitsBehind.length}
</div> : null}
<FontAwesomeIcon icon={faArrowDown} className="" />
</div>
</GitUIButton>
</CustomTooltip>
<CustomTooltip tooltipText={getTooltipText('git.push')}>
<GitUIButton data-id='sourcecontrol-button-push' disabledCondition={buttonsDisabled()} onClick={push} className='btn btn-sm pl-0 pr-2'>
<div className="d-flex align-items-baseline">
{syncState.commitsAhead.length ? <div className="badge badge-pill pl-0">
{syncState.commitsAhead.length}
</div> : null}
<FontAwesomeIcon icon={faArrowUp} className="" />
</div>
</GitUIButton>
</CustomTooltip>
<CustomTooltip tooltipText={getTooltipText('git.sync')}>
<GitUIButton data-id='sourcecontrol-button-sync' disabledCondition={buttonsDisabled()} onClick={sync} className='btn btn-sm pl-0 pr-2'><FontAwesomeIcon icon={faArrowsUpDown} className="" /></GitUIButton>
</CustomTooltip>
<span className="d-flex justify-content-end align-items-center">
{props.panel === gitUIPanels.COMMITS || props.panel === gitUIPanels.SOURCECONTROL ? (
<>
<CustomTooltip tooltipText={getTooltipText('git.pull')}>
<GitUIButton data-id="sourcecontrol-button-pull" disabledCondition={buttonsDisabled()} onClick={pull} className="btn btn-sm pl-0 pr-2">
<div className="d-flex align-items-baseline">
{syncState.commitsBehind.length ? <div className="badge badge-pill pl-0">{syncState.commitsBehind.length}</div> : null}
<FontAwesomeIcon icon={faArrowDown} className="" />
</div>
</GitUIButton>
</CustomTooltip>
<CustomTooltip tooltipText={getTooltipText('git.push')}>
<GitUIButton data-id="sourcecontrol-button-push" disabledCondition={buttonsDisabled()} onClick={push} className="btn btn-sm pl-0 pr-2">
<div className="d-flex align-items-baseline">
{syncState.commitsAhead.length ? <div className="badge badge-pill pl-0">{syncState.commitsAhead.length}</div> : null}
<FontAwesomeIcon icon={faArrowUp} className="" />
</div>
</GitUIButton>
</CustomTooltip>
<CustomTooltip tooltipText={getTooltipText('git.sync')}>
<GitUIButton data-id="sourcecontrol-button-sync" disabledCondition={buttonsDisabled()} onClick={sync} className="btn btn-sm pl-0 pr-2">
<FontAwesomeIcon icon={faArrowsUpDown} className="" />
</GitUIButton>
</CustomTooltip>
</>
) : null}
<CustomTooltip tooltipText={<FormattedMessage id="git.refresh" />}>
<GitUIButton onClick={refresh} className='btn btn-sm'><FontAwesomeIcon icon={faArrowRotateRight} className="" /></GitUIButton>
<GitUIButton onClick={refresh} className="btn btn-sm">
<FontAwesomeIcon icon={faArrowRotateRight} className="" />
</GitUIButton>
</CustomTooltip>
</span>
)
}
}

@ -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 }) => {
<label className="pl-2 nav form-check-label">BRANCHES</label>
<LoaderIndicator></LoaderIndicator>
</span>
<SourceControlBase><SourceControlButtons panel={gitUIPanels.BRANCHES}/></SourceControlBase>
</div>
</>
);

@ -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
</span>
{showButtons ?
<SourceControlBase branch={branch} remote={remote}>
<SourceControlButtons />
<SourceControlButtons panel={gitUIPanels.COMMITS} />
</SourceControlBase> : null}
</div>

@ -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 }) =>
</span>
<SourceControlBase><SourceControlButtons/></SourceControlBase>
<SourceControlBase><SourceControlButtons panel={gitUIPanels.SOURCECONTROL}/></SourceControlBase>
</div>
</>

@ -51,6 +51,7 @@ export const getBranches = async () => {
const branches = await plugin.call('dgitApi', 'branches')
dispatch(setBranches(branches));
await showCurrentBranch();
}
export const getRemotes = async () => {

Loading…
Cancel
Save