Skip to content

Commit

Permalink
refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
bunsenstraat committed May 5, 2024
1 parent ec4afca commit 41d15a3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export const SourceControlButtons = () => {
}

const refresh = async() => {
await actions.getFileStatusMatrix(null)
await actions.getBranches()
await actions.gitlog()
await actions.refresh()
}

const buttonsDisabled = () => {
Expand Down
8 changes: 5 additions & 3 deletions libs/remix-ui/git/src/components/github/repositoryselect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import Select from 'react-select';
import { gitActionsContext } from '../../state/context';
import { repository } from '../../types';
import { selectStyles, selectTheme } from '../../types/styles';
import GitUIButton from '../buttons/gituibutton';
import { gitPluginContext } from '../gitui';
import { TokenWarning } from '../panels/tokenWarning';

interface RepositorySelectProps {
select: (repo: repository) => void;
title: string;
}

const RepositorySelect = (props: RepositorySelectProps) => {
Expand Down Expand Up @@ -64,9 +66,9 @@ const RepositorySelect = (props: RepositorySelectProps) => {
};

return (
<><Button onClick={fetchRepositories} className="w-100 mt-1">
<i className="fab fa-github mr-1"></i>Fetch Repositories from GitHub
</Button>
<><GitUIButton onClick={fetchRepositories} className="btn btn-primary w-100 mt-1">
<i className="fab fa-github mr-1"></i>{props.title}
</GitUIButton>
{
show ?
<Select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { gitPluginContext } from "../gitui";
import RepositorySelect from "./repositoryselect";
import { BranchSelect } from "./branchselect";
import { TokenWarning } from "../panels/tokenWarning";
import GitUIButton from "../buttons/gituibutton";

interface RepositoriesProps {
cloneDepth?: number
Expand Down Expand Up @@ -38,14 +39,14 @@ export const SelectAndCloneRepositories = (props: RepositoriesProps) => {
return (
<>
<TokenWarning />
<RepositorySelect select={selectRepo} />
<RepositorySelect title={`Clone Repository from GitHub`} select={selectRepo} />

{repo &&<BranchSelect select={selectRemoteBranch} />}

{repo && branch && branch.name && branch.name !== '0' ?
<button data-id='clonebtn' className='btn btn-primary mt-1 w-100' onClick={async () => {
<GitUIButton data-id='clonebtn' className='btn btn-primary mt-1 w-100' onClick={async () => {
await clone()
}}>clone {repo.full_name}:{branch.name}</button> : null}
}}>clone {repo.full_name}:{branch.name}</GitUIButton> : null}

</>
)
Expand Down
5 changes: 3 additions & 2 deletions libs/remix-ui/git/src/components/gitui.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useReducer, useState } from 'react'
import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, getGitHubUser, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentials, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix, gitlog } from '../lib/gitactions'
import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, getGitHubUser, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentials, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix, gitlog, refresh } from '../lib/gitactions'
import { loadFiles, setCallBacks } from '../lib/listeners'
import { openDiff, openFile, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions'
import { gitActionsContext, pluginActionsContext } from '../state/context'
Expand Down Expand Up @@ -113,7 +113,8 @@ export const GitUI = (props: IGitUi) => {
sendToGitLog,
clearGitLog,
getFileStatusMatrix,
gitlog
gitlog,
refresh
}

const pluginActionsProviderValue = {
Expand Down
4 changes: 2 additions & 2 deletions libs/remix-ui/git/src/components/panels/clone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Clone = () => {

const [cloneDepth, setCloneDepth] = useLocalStorage(
"CLONE_DEPTH",
1
10
);

const [cloneBranch, setCloneBranch] = useLocalStorage(
Expand Down Expand Up @@ -73,7 +73,7 @@ export const Clone = () => {
<InputGroup className="mt-1 mb-1">
<InputGroup.Prepend>
<InputGroup.Text id="clonedepthprepend">
--depth
depth
</InputGroup.Text>
</InputGroup.Prepend>
<FormControl id="clonedepth" type="number" value={cloneDepth} onChange={e => onDepthChange(parseInt(e.target.value))} aria-describedby="clonedepthprepend" />
Expand Down
4 changes: 2 additions & 2 deletions libs/remix-ui/git/src/components/panels/remotesimport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export const RemotesImport = () => {
return (
<>
<TokenWarning />
<RepositorySelect select={selectRepo} />
<RepositorySelect title={`Select repository from GitHub`} select={selectRepo} />

{repo ?
<input placeholder="remote name" name='remotename' onChange={e => onRemoteNameChange(e.target.value)} value={remoteName} className="form-control mb-2" type="text" id="remotename" />
<input placeholder="remote name" name='remotename' onChange={e => onRemoteNameChange(e.target.value)} value={remoteName} className="form-control mb-2 mt-1" type="text" id="remotename" />
: null}

{repo && remoteName ?
Expand Down
10 changes: 10 additions & 0 deletions libs/remix-ui/git/src/lib/gitactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,4 +834,14 @@ export const sendToGitLog = async (message: gitLog) => {

export const clearGitLog = async () => {
dispatch(clearLog())
}

export const refresh = async() =>{
dispatch(setLoading(true))
await disableCallBacks()
await getFileStatusMatrix(null)
await getBranches()
await gitlog()
dispatch(setLoading(false))
await enableCallBacks()
}
1 change: 1 addition & 0 deletions libs/remix-ui/git/src/state/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface gitActions {
sendToGitLog: (message: gitLog) => Promise<void>
clearGitLog: () => Promise<void>
getFileStatusMatrix(filespaths:[]): Promise<void>
refresh:() => Promise<void>
}

export const gitActionsContext = React.createContext<gitActions>(null)
Expand Down

0 comments on commit 41d15a3

Please sign in to comment.