diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx
index ca34ae2548..304f07258e 100644
--- a/libs/remix-ui/git/src/components/gitui.tsx
+++ b/libs/remix-ui/git/src/components/gitui.tsx
@@ -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 } 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 } 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'
@@ -110,7 +110,8 @@ export const GitUI = (props: IGitUi) => {
getRemotes,
fetch,
pull,
- push
+ push,
+ setDefaultRemote
}
const pluginActionsProviderValue = {
diff --git a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx
index 7d59cd68d3..fec15bc5e1 100644
--- a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx
+++ b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx
@@ -1,6 +1,7 @@
-import { faCaretDown, faCaretRight, faArrowRightArrowLeft, faGlobe } from "@fortawesome/free-solid-svg-icons";
+import { faCaretDown, faCaretRight, faArrowRightArrowLeft, faGlobe, faToggleOff, faToggleOn } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { useContext, useEffect } from "react";
+import { gitActionsContext } from "../../state/context";
import { branch, remote } from "../../types";
import { gitPluginContext } from "../gitui";
@@ -14,6 +15,8 @@ interface RemotesDetailsNavigationProps {
export const RemotesDetailsNavigation = (props: RemotesDetailsNavigationProps) => {
const { eventKey, activePanel, callback, remote } = props;
const context = React.useContext(gitPluginContext)
+ const actions = React.useContext(gitActionsContext)
+
const handleClick = () => {
if (!callback) return
if (activePanel === eventKey) {
@@ -27,6 +30,10 @@ export const RemotesDetailsNavigation = (props: RemotesDetailsNavigationProps) =
window.open(`${remote.url}`, '_blank');
}
+ const setAsDefault = () => {
+ actions.setDefaultRemote(remote)
+ }
+
return (
<>
@@ -39,6 +46,11 @@ export const RemotesDetailsNavigation = (props: RemotesDetailsNavigationProps) =
+ {context.defaultRemote && context.defaultRemote?.url === remote.url ?
+
+ :
+
+ }
{remote?.url && openRemote()}>}
>
diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts
index e7ec3f4ca2..35155b5ea8 100644
--- a/libs/remix-ui/git/src/lib/gitactions.ts
+++ b/libs/remix-ui/git/src/lib/gitactions.ts
@@ -1,8 +1,8 @@
import { ViewPlugin } from "@remixproject/engine-web";
import { ReadBlobResult, ReadCommitResult } from "isomorphic-git";
import React from "react";
-import { fileStatus, fileStatusMerge, setRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRateLimit, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences } from "../state/gitpayload";
-import { GitHubUser, RateLimit, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference } from '../types';
+import { fileStatus, fileStatusMerge, setRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRateLimit, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault } from "../state/gitpayload";
+import { GitHubUser, RateLimit, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote } from '../types';
import { removeSlash } from "../utils";
import { disableCallBacks, enableCallBacks } from "./listeners";
import { AlertModal, ModalTypes } from "@remix-ui/app";
@@ -797,3 +797,7 @@ export const getBranchCommits = async (branch: branch, page: number) => {
await fetchBranch(branch, page)
}
}
+
+export const setDefaultRemote = async (remote: remote) => {
+ dispatch(setRemoteAsDefault(remote))
+}
diff --git a/libs/remix-ui/git/src/state/context.tsx b/libs/remix-ui/git/src/state/context.tsx
index 26632433f2..87fdb4dc30 100644
--- a/libs/remix-ui/git/src/state/context.tsx
+++ b/libs/remix-ui/git/src/state/context.tsx
@@ -1,6 +1,6 @@
import { ReadCommitResult } from "isomorphic-git"
import React from "react"
-import { branch, commitChange } from "../types"
+import { branch, commitChange, remote } from "../types"
export interface gitActions {
clone(url: string, path: string, depth: number, singleBranch: boolean): Promise
@@ -24,6 +24,7 @@ export interface gitActions {
setUpstreamRemote(upstream: string): Promise
getBranches: () => Promise
getRemotes: () => Promise
+ setDefaultRemote: (remote: remote) => Promise
}
export const gitActionsContext = React.createContext(null)
diff --git a/libs/remix-ui/git/src/state/gitpayload.ts b/libs/remix-ui/git/src/state/gitpayload.ts
index 4a9b7eae9d..8bcf16e32a 100644
--- a/libs/remix-ui/git/src/state/gitpayload.ts
+++ b/libs/remix-ui/git/src/state/gitpayload.ts
@@ -172,3 +172,10 @@ export const setGItHubToken = (token: string) => {
payload: token
}
}
+
+export const setRemoteAsDefault = (remote: remote) => {
+ return {
+ type: 'SET_DEFAULT_REMOTE',
+ payload: remote
+ }
+}
diff --git a/libs/remix-ui/git/src/state/gitreducer.tsx b/libs/remix-ui/git/src/state/gitreducer.tsx
index 28976380dc..fa42f03be3 100644
--- a/libs/remix-ui/git/src/state/gitreducer.tsx
+++ b/libs/remix-ui/git/src/state/gitreducer.tsx
@@ -1,6 +1,6 @@
import { ReadCommitResult } from "isomorphic-git"
import { allChangedButNotStagedFiles, getFilesByStatus, getFilesWithNotModifiedStatus } from "../lib/fileHelpers"
-import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction } from "../types"
+import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction, setDefaultRemoteAction } from "../types"
interface Action {
type: string
@@ -139,7 +139,7 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
}
case 'SET_BRANCH_DIFFERENCES':
-
+
state.branchDifferences[`${(action as setBranchDifferencesAction).payload.remote.remote}/${(action as setBranchDifferencesAction).payload.branch.name}`] = (action as setBranchDifferencesAction).payload.branchDifference
@@ -168,5 +168,11 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
...state,
gitHubAccessToken: action.payload
}
+
+ case 'SET_DEFAULT_REMOTE':
+ return {
+ ...state,
+ defaultRemote: (action as setDefaultRemoteAction).payload
+ }
}
}
\ No newline at end of file
diff --git a/libs/remix-ui/git/src/types/index.ts b/libs/remix-ui/git/src/types/index.ts
index 5c259c5053..678fcb6cab 100644
--- a/libs/remix-ui/git/src/types/index.ts
+++ b/libs/remix-ui/git/src/types/index.ts
@@ -12,6 +12,7 @@ export type gitState = {
canCommit: boolean
branches: branch[]
remotes: remote[]
+ defaultRemote: remote
fileStatusResult: fileStatusResult[]
canUseApp: boolean
loading: boolean
@@ -117,6 +118,7 @@ export const defaultGitState: gitState = {
canCommit: true,
branches: [],
remotes: [],
+ defaultRemote: null,
fileStatusResult: [],
staged: [],
untracked: [],
@@ -255,4 +257,9 @@ export interface setTokenAction {
payload: string
}
-export type gitActionDispatch = setTokenAction | setUpstreamAction | setRemoteBranchCommitsAction | setLocalBranchCommitsAction | setBranchDifferencesAction | setRemotesAction | setCurrentBranchAction | fileStatusAction | setLoadingAction | setCanUseAppAction | setRepoNameAction | setCommitsAction | setBranchesAction | setReposAction | setRemoteBranchesAction
\ No newline at end of file
+export interface setDefaultRemoteAction {
+ type: string,
+ payload: remote
+}
+
+export type gitActionDispatch = setDefaultRemoteAction | setTokenAction | setUpstreamAction | setRemoteBranchCommitsAction | setLocalBranchCommitsAction | setBranchDifferencesAction | setRemotesAction | setCurrentBranchAction | fileStatusAction | setLoadingAction | setCanUseAppAction | setRepoNameAction | setCommitsAction | setBranchesAction | setReposAction | setRemoteBranchesAction
\ No newline at end of file