add action types

pull/4791/head
filip mertens 6 months ago
parent 9b0389616e
commit 320f4420bd
  1. 2
      apps/remix-ide-e2e/src/tests/workspace_git.test.ts
  2. 8
      apps/remix-ide/src/app/files/dgitProvider.ts
  3. 7
      apps/remix-ide/src/app/plugins/git.tsx
  4. 2
      apps/remix-ide/src/app/tabs/locales/en/filePanel.json
  5. 11
      libs/remix-ui/git/src/components/github/devicecode.tsx
  6. 23
      libs/remix-ui/git/src/components/gitui.tsx
  7. 2
      libs/remix-ui/git/src/components/navigation/github.tsx
  8. 51
      libs/remix-ui/git/src/components/panels/github.tsx
  9. 6
      libs/remix-ui/git/src/components/panels/githubcredentials.tsx
  10. 5
      libs/remix-ui/git/src/components/panels/setup.tsx
  11. 25
      libs/remix-ui/git/src/lib/gitactions.ts
  12. 10
      libs/remix-ui/git/src/lib/listeners.ts
  13. 51
      libs/remix-ui/git/src/state/actions.ts
  14. 4
      libs/remix-ui/git/src/state/context.tsx
  15. 11
      libs/remix-ui/git/src/state/gitpayload.ts
  16. 33
      libs/remix-ui/git/src/state/gitreducer.tsx
  17. 5
      libs/remix-ui/git/src/types/index.ts
  18. 4
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -139,7 +139,7 @@ module.exports = {
.click('[data-id="fileSystem-modal-footer-ok-react"]') .click('[data-id="fileSystem-modal-footer-ok-react"]')
.pause(5000) .pause(5000)
.waitForElementVisible('[data-id="cloneGitRepositoryModalDialogModalBody-react"]') .waitForElementVisible('[data-id="cloneGitRepositoryModalDialogModalBody-react"]')
.waitForElementContainsText('[data-id="cloneGitRepositoryModalDialogModalBody-react"]', 'An error occurred: Please check that you have the correct URL for the repo. If the repo is private, you need to add your github credentials (with the valid token permissions) in Settings plugin') .waitForElementContainsText('[data-id="cloneGitRepositoryModalDialogModalBody-react"]', 'An error occurred: Please check that you have the correct URL for the repo. If the repo is private, you need to add your github credentials (with the valid token permissions) in the Git plugin')
.click('[data-id="cloneGitRepository-modal-footer-ok-react"]') .click('[data-id="cloneGitRepository-modal-footer-ok-react"]')
}, },

@ -19,7 +19,7 @@ import { Octokit, App } from "octokit"
import { OctokitResponse } from '@octokit/types' import { OctokitResponse } from '@octokit/types'
import { Endpoints } from "@octokit/types" import { Endpoints } from "@octokit/types"
import { IndexedDBStorage } from './filesystems/indexedDB' import { IndexedDBStorage } from './filesystems/indexedDB'
import { GitHubUser, RateLimit, branch, commitChange, remote, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInput, rmInput, resolveRefInput, readBlobInput, repositoriesInput, commitInput, branchDifference, compareBranchesInput, initInput } from '@remix-ui/git' import { GitHubUser, RateLimit, branch, commitChange, remote, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInput, rmInput, resolveRefInput, readBlobInput, repositoriesInput, commitInput, branchDifference, compareBranchesInput, initInput, userEmails } from '@remix-ui/git'
import { LibraryProfile, StatusEvents } from '@remixproject/plugin-utils' import { LibraryProfile, StatusEvents } from '@remixproject/plugin-utils'
import { ITerminal } from '@remixproject/plugin-api/src/lib/terminal' import { ITerminal } from '@remixproject/plugin-api/src/lib/terminal'
@ -1004,7 +1004,8 @@ class DGitProvider extends Plugin {
async getGitHubUser(input: { token: string }): Promise<{ async getGitHubUser(input: { token: string }): Promise<{
user: GitHubUser, user: GitHubUser,
ratelimit: RateLimit ratelimit: RateLimit,
emails: userEmails,
scopes: string[] scopes: string[]
}> { }> {
const octokit = new Octokit({ const octokit = new Octokit({
@ -1023,6 +1024,8 @@ class DGitProvider extends Plugin {
console.log('rate limit', localResetTimeString) console.log('rate limit', localResetTimeString)
const user = await octokit.request('GET /user') const user = await octokit.request('GET /user')
const emails = await octokit.request('GET /user/emails')
const scopes = user.headers['x-oauth-scopes']; const scopes = user.headers['x-oauth-scopes'];
@ -1030,6 +1033,7 @@ class DGitProvider extends Plugin {
return { return {
user: user.data, user: user.data,
emails: emails.data,
ratelimit: ratelimit.data, ratelimit: ratelimit.data,
scopes: scopes.split(',') scopes: scopes.split(',')
} }

@ -2,13 +2,18 @@
import { ViewPlugin } from '@remixproject/engine-web'; import { ViewPlugin } from '@remixproject/engine-web';
import React from 'react' // eslint-disable-line import React from 'react' // eslint-disable-line
import { gitState, GitUI } from '@remix-ui/git'; import { gitState, GitUI } from '@remix-ui/git';
import * as packageJson from '../../../../../package.json'
const profile = { const profile = {
name: 'dgit', name: 'dgit',
desciption: 'Git plugin for Remix', desciption: 'Git plugin for Remix',
methods: ['pull', 'track', 'diff', 'clone', 'open'], methods: ['pull', 'track', 'diff', 'clone', 'open'],
events: [''], events: [''],
version: '0.0.1', version: packageJson.version,
maintainedBy: 'Remix',
permission: true,
description: 'Use this plugin to interact with your git repositories',
location: 'sidePanel', location: 'sidePanel',
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTIxLjAwNyA4LjIyMTY4QzIxLjAxMDUgNy41Mjc5MiAyMC44MjA3IDYuODQ2ODkgMjAuNDU5MSA2LjI1NDg1QzIwLjA5NzQgNS42NjI4MSAxOS41NzggNS4xODMxNSAxOC45NTkyIDQuODY5NTdDMTguMzQwMyA0LjU1NiAxNy42NDYzIDQuNDIwOTEgMTYuOTU1MSA0LjQ3OTQxQzE2LjI2MzcgNC41Mzc5MyAxNS42MDI1IDQuNzg3NzMgMTUuMDQ1IDUuMjAwODVDMTQuNDg3NyA1LjYxMzk3IDE0LjA1NjMgNi4xNzQwOSAxMy43OTkzIDYuODE4NUMxMy41NDI0IDcuNDYyOSAxMy40Njk3IDguMTY2MTMgMTMuNTg5OCA4Ljg0OTQ0QzEzLjcwOTkgOS41MzI3NCAxNC4wMTc3IDEwLjE2OTIgMTQuNDc4OSAxMC42ODc0QzE0Ljk0M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DkuODM5NTQgMTUuMzY4NSA5LjQ4OTM3IDE1LjE5ODggOS4wNzk2OUMxNS4wMjkxIDguNjcgMTQuOTg0NyA4LjIxOTIgMTUuMDcxMiA3Ljc4NDI3QzE1LjE1NzYgNy4zNDkzNSAxNS4zNzEyIDYuOTQ5ODUgMTUuNjg0OCA2LjYzNjI5QzE1Ljk5ODQgNi4zMjI3MyAxNi4zOTc5IDYuMTA5MTkgMTYuODMyNyA2LjAyMjY4QzE3LjI2NzcgNS45MzYxNyAxNy43MTg1IDUuOTgwNTggMTguMTI4MSA2LjE1MDI3QzE4LjUzNzkgNi4zMTk5NyAxOC44ODgxIDYuNjA3MzQgMTkuMTM0NCA2Ljk3NjA1QzE5LjM4MDcgNy4zNDQ3NiAxOS41MTIzIDcuNzc4MjMgMTkuNTEyMyA4LjIyMTY4QzE5LjUxMjMgOC44MTYzMiAxOS4yNzYgOS4zODY2IDE4Ljg1NTYgOS44MDcwNkMxOC40MzUxIDEwLjIyNzUgMTcuODY0OCAxMC40NjM4IDE3LjI3MDIgMTAuNDYzOFoiIGZpbGw9IiM0MjQyNDIiLz4KPC9zdmc+Cg=="
} }

@ -78,7 +78,7 @@
"filePanel.checkoutGitBranch": "Checkout Git Branch", "filePanel.checkoutGitBranch": "Checkout Git Branch",
"filePanel.findOrCreateABranch": "Find or create a branch.", "filePanel.findOrCreateABranch": "Find or create a branch.",
"filePanel.initGitRepositoryLabel": "Initialize workspace as a new git repository", "filePanel.initGitRepositoryLabel": "Initialize workspace as a new git repository",
"filePanel.initGitRepositoryWarning": "To use Git features, add username and email to the Github section of the Settings panel.", "filePanel.initGitRepositoryWarning": "To use Git features, add username and email to the Github section of the Git plugin.",
"filePanel.workspaceName": "Workspace name", "filePanel.workspaceName": "Workspace name",
"filePanel.customizeTemplate": "Customize template", "filePanel.customizeTemplate": "Customize template",
"filePanel.features": "Features", "filePanel.features": "Features",

@ -21,7 +21,7 @@ export const GetDeviceCode = () => {
url: 'http://0.0.0.0:3000/github.com/login/device/code', url: 'http://0.0.0.0:3000/github.com/login/device/code',
data: { data: {
client_id: '2795b4e41e7197d6ea11', client_id: '2795b4e41e7197d6ea11',
scope: 'repo gist' scope: 'repo gist user:email read:user'
}, },
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -63,7 +63,7 @@ export const GetDeviceCode = () => {
if (response.access_token) { if (response.access_token) {
setAuthorized(true) setAuthorized(true)
await pluginActions.saveToken(response.access_token) await pluginActions.saveToken(response.access_token)
await actions.getGitHubUser() await actions.loadGitHubUserFromToken()
} }
} }
@ -72,11 +72,11 @@ export const GetDeviceCode = () => {
setAuthorized(false) setAuthorized(false)
setGitHubResponse(null) setGitHubResponse(null)
await pluginActions.saveToken(null) await pluginActions.saveToken(null)
await actions.getGitHubUser() await actions.loadGitHubUserFromToken()
} }
const checkConnection = async () => { const checkConnection = async () => {
//await actions.getGitHubUser() //await actions.loadGitHubUserFromToken()
} }
useEffect(() => { useEffect(() => {
@ -131,6 +131,9 @@ export const GetDeviceCode = () => {
<Card.Text> <Card.Text>
<img src={context.gitHubUser.avatar_url} className="w-100" /> <img src={context.gitHubUser.avatar_url} className="w-100" />
<a target="_blank" href={context.gitHubUser.html_url}>{context.gitHubUser.html_url}</a> <a target="_blank" href={context.gitHubUser.html_url}>{context.gitHubUser.html_url}</a>
{context.userEmails && context.userEmails.filter((email: any) => email.primary).map((email: any) => {
return <span key={email.email}><br></br>{email.email}</span>
})}
</Card.Text> </Card.Text>
</Card.Body> </Card.Body>
</Card> </Card>

@ -1,5 +1,5 @@
import React, { useEffect, useReducer, useState } from 'react' 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 } from '../lib/gitactions' import { add, addall, checkout, checkoutfile, clone, commit, createBranch, remoteBranches, repositories, rm, getCommitChanges, diff, resolveRef, getBranchCommits, setUpstreamRemote, loadGitHubUserFromToken, getBranches, getRemotes, remoteCommits, saveGitHubCredentials, getGitHubCredentialsFromLocalStorage, fetch, pull, push, setDefaultRemote, addRemote, removeRemote, sendToGitLog, clearGitLog, getBranchDifferences, getFileStatusMatrix } from '../lib/gitactions'
import { loadFiles, setCallBacks } from '../lib/listeners' import { loadFiles, setCallBacks } from '../lib/listeners'
import { openDiff, openFile, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions' import { openDiff, openFile, saveToken, setModifiedDecorator, setPlugin, setUntrackedDecorator, statusChanged } from '../lib/pluginActions'
import { gitActionsContext, pluginActionsContext } from '../state/context' import { gitActionsContext, pluginActionsContext } from '../state/context'
@ -42,7 +42,8 @@ export const GitUI = (props: IGitUi) => {
const plugin = props.plugin const plugin = props.plugin
const [gitState, gitDispatch] = useReducer(gitReducer, defaultGitState) const [gitState, gitDispatch] = useReducer(gitReducer, defaultGitState)
const [loaderState, loaderDispatch] = useReducer(loaderReducer, defaultLoaderState) const [loaderState, loaderDispatch] = useReducer(loaderReducer, defaultLoaderState)
const [activePanel, setActivePanel] = useState<string>("0"); const [activePanel, setActivePanel] = useState<string>("0")
const [setup, setSetup] = useState<boolean>(false)
useEffect(() => { useEffect(() => {
setCallBacks(plugin, gitDispatch, loaderDispatch) setCallBacks(plugin, gitDispatch, loaderDispatch)
@ -51,6 +52,18 @@ export const GitUI = (props: IGitUi) => {
console.log(props) console.log(props)
}, []) }, [])
useEffect(() => {
async function checkconfig() {
const username = await plugin.call('settings', 'get', 'settings/github-user-name')
const email = await plugin.call('settings', 'get', 'settings/github-email')
const token = await plugin.call('settings', 'get', 'settings/gist-access-token')
console.log('gitState', gitState, username, email, token)
setSetup(!(username && email))
}
checkconfig()
},[gitState.gitHubAccessToken, gitState.gitHubUser, gitState.userEmails])
useEffect(() => { useEffect(() => {
async function setDecorators(gitState: gitState) { async function setDecorators(gitState: gitState) {
@ -97,7 +110,7 @@ export const GitUI = (props: IGitUi) => {
diff, diff,
resolveRef, resolveRef,
setUpstreamRemote, setUpstreamRemote,
getGitHubUser, loadGitHubUserFromToken: loadGitHubUserFromToken,
getBranches, getBranches,
getRemotes, getRemotes,
fetch, fetch,
@ -118,7 +131,7 @@ export const GitUI = (props: IGitUi) => {
openDiff, openDiff,
saveToken, saveToken,
saveGitHubCredentials, saveGitHubCredentials,
getGitHubCredentials getGitHubCredentialsFromLocalStorage
} }
return ( return (
@ -128,7 +141,7 @@ export const GitUI = (props: IGitUi) => {
<gitActionsContext.Provider value={gitActionsProviderValue}> <gitActionsContext.Provider value={gitActionsProviderValue}>
<BranchHeader/> <BranchHeader/>
<pluginActionsContext.Provider value={pluginActionsProviderValue}> <pluginActionsContext.Provider value={pluginActionsProviderValue}>
<Setup></Setup> {setup? <Setup></Setup>: null}
<Accordion activeKey={activePanel} defaultActiveKey="0"> <Accordion activeKey={activePanel} defaultActiveKey="0">
<SourceControlNavigation eventKey="0" activePanel={activePanel} callback={setActivePanel} /> <SourceControlNavigation eventKey="0" activePanel={activePanel} callback={setActivePanel} />

@ -21,7 +21,7 @@ export const GitHubNavigation = ({ eventKey, activePanel, callback }) => {
{ {
activePanel === eventKey ? <FontAwesomeIcon className='' icon={faCaretDown}></FontAwesomeIcon> : <FontAwesomeIcon className='' icon={faCaretRight}></FontAwesomeIcon> activePanel === eventKey ? <FontAwesomeIcon className='' icon={faCaretDown}></FontAwesomeIcon> : <FontAwesomeIcon className='' icon={faCaretRight}></FontAwesomeIcon>
} }
<label className="pl-1 nav form-check-label">GITHUB</label> <label className="pl-1 nav form-check-label">GITHUB SETUP</label>
</span> </span>
</div> </div>
</> </>

@ -1,51 +0,0 @@
import React, { useEffect } from "react";
import { gitActionsContext, pluginActionsContext } from "../../state/context";
import { gitPluginContext, loaderContext } from "../gitui";
import axios from "axios";
import { CopyToClipboard } from "@remix-ui/clipboard";
import { Card } from "react-bootstrap";
export const GitHubAuth = () => {
const context = React.useContext(gitPluginContext)
const actions = React.useContext(gitActionsContext)
const loader = React.useContext(loaderContext)
const pluginActions = React.useContext(pluginActionsContext)
const [gitHubResponse, setGitHubResponse] = React.useState<any>(null)
const [authorized, setAuthorized] = React.useState<boolean>(false)
useEffect(() => {
checkConnection()
}, [context.gitHubAccessToken, loader.plugin])
const checkConnection = async () => {
console.log('checkConnection', context.gitHubAccessToken)
await actions.getGitHubUser()
}
useEffect(() => {
console.log('context.rateLimit', context.rateLimit)
}, [context.rateLimit])
return (
<>
{(context.gitHubUser && context.gitHubUser.login) ? null :
<li className="text-warning list-group-item d-flex justify-content-between align-items-center">
Not connected to GitHub. Add a valid token.</li>
}
{
(context.gitHubUser && context.gitHubUser.login) ?
<div className="pt-2">
<Card>
<Card.Body>
<Card.Title>Connected as {context.gitHubUser.login}</Card.Title>
<Card.Text>
<img src={context.gitHubUser.avatar_url} className="w-100" />
<a target="_blank" href={context.gitHubUser.html_url}>{context.gitHubUser.html_url}</a>
</Card.Text>
</Card.Body>
</Card>
</div>: null
}
</>)
}

@ -6,10 +6,12 @@ import { CustomTooltip } from "@remix-ui/helper";
import { useIntl, FormattedMessage } from "react-intl"; import { useIntl, FormattedMessage } from "react-intl";
import { CopyToClipboard } from "@remix-ui/clipboard"; import { CopyToClipboard } from "@remix-ui/clipboard";
export const GitHubCredentials = () => { export const GitHubCredentials = () => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
const pluginactions = React.useContext(pluginActionsContext) const pluginactions = React.useContext(pluginActionsContext)
const loader = React.useContext(loaderContext) const loader = React.useContext(loaderContext)
const actions = React.useContext(gitActionsContext)
const [githubToken, setGithubToken] = React.useState('') const [githubToken, setGithubToken] = React.useState('')
const [githubUsername, setGithubUsername] = React.useState('') const [githubUsername, setGithubUsername] = React.useState('')
const [githubEmail, setGithubEmail] = React.useState('') const [githubEmail, setGithubEmail] = React.useState('')
@ -17,7 +19,7 @@ export const GitHubCredentials = () => {
useEffect(() => { useEffect(() => {
refresh() refresh()
}, [loader.plugin, context.gitHubAccessToken]) }, [loader.plugin, context.gitHubAccessToken, context.userEmails, context.gitHubUser])
function handleChangeTokenState(e: string): void { function handleChangeTokenState(e: string): void {
setGithubToken(e) setGithubToken(e)
@ -40,7 +42,7 @@ export const GitHubCredentials = () => {
} }
async function refresh() { async function refresh() {
const credentials = await pluginactions.getGitHubCredentials() const credentials = await pluginactions.getGitHubCredentialsFromLocalStorage()
if (!credentials) return if (!credentials) return
console.log('credentials', credentials) console.log('credentials', credentials)
setGithubToken(credentials.token || '') setGithubToken(credentials.token || '')

@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { GetDeviceCode } from '../github/devicecode'
import { GitHubCredentials } from './githubcredentials' import { GitHubCredentials } from './githubcredentials'
export const Setup = () => { export const Setup = () => {
@ -9,12 +10,14 @@ export const Setup = () => {
if (screen === 0) { if (screen === 0) {
return ( return (
<> <>
<h5>SETUP - STEP 1</h5> <h5>SETUP</h5>
<div> <div>
<div className='mt-1 mb-2'> <div className='mt-1 mb-2'>
To ensure that your commits are properly attributed in Git, you need to configure a username and email address. To ensure that your commits are properly attributed in Git, you need to configure a username and email address.
These will be used to identify the author of the commit. These will be used to identify the author of the commit.
</div> </div>
<GetDeviceCode></GetDeviceCode>
<hr></hr>
<GitHubCredentials></GitHubCredentials> <GitHubCredentials></GitHubCredentials>
</div> </div>
</> </>

@ -1,8 +1,8 @@
import { ViewPlugin } from "@remixproject/engine-web"; import { ViewPlugin } from "@remixproject/engine-web";
import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; import { ReadBlobResult, ReadCommitResult } from "isomorphic-git";
import React from "react"; import React from "react";
import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRateLimit, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog } from "../state/gitpayload"; import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRateLimit, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails } from "../state/gitpayload";
import { GitHubUser, RateLimit, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository } from '../types'; import { GitHubUser, RateLimit, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails } from '../types';
import { removeSlash } from "../utils"; import { removeSlash } from "../utils";
import { disableCallBacks, enableCallBacks } from "./listeners"; import { disableCallBacks, enableCallBacks } from "./listeners";
import { AlertModal, ModalTypes } from "@remix-ui/app"; import { AlertModal, ModalTypes } from "@remix-ui/app";
@ -532,7 +532,7 @@ export const saveGitHubCredentials = async (credentials: { username: string, ema
} }
} }
export const getGitHubCredentials = async () => { export const getGitHubCredentialsFromLocalStorage = async () => {
if (!plugin) return if (!plugin) return
try { try {
const username = await plugin.call('config', 'getAppParameter', 'settings/github-user-name') const username = await plugin.call('config', 'getAppParameter', 'settings/github-user-name')
@ -548,7 +548,7 @@ export const getGitHubCredentials = async () => {
} }
} }
export const getGitHubUser = async () => { export const loadGitHubUserFromToken = async () => {
if (!plugin) return if (!plugin) return
try { try {
const token = await tokenWarning(); const token = await tokenWarning();
@ -557,14 +557,25 @@ export const getGitHubUser = async () => {
user: GitHubUser, user: GitHubUser,
ratelimit: RateLimit ratelimit: RateLimit
scopes: string[] scopes: string[]
emails: userEmails
} = await plugin.call('dgitApi' as any, 'getGitHubUser', { token }); } = await plugin.call('dgitApi' as any, 'getGitHubUser', { token });
console.log('GET USER"', data) console.log('GET USER"', data)
if (data && data.emails && data.user && data.user.login) {
const primaryEmail = data.emails.find(email => email.primary)
if (primaryEmail) await plugin.call('config', 'setAppParameter', 'settings/github-email', primaryEmail.email)
data.user && data.user.login && await plugin.call('config', 'setAppParameter', 'settings/github-user-name', data.user.login)
dispatch(setGitHubUser(data.user)) dispatch(setGitHubUser(data.user))
dispatch(setRateLimit(data.ratelimit)) dispatch(setRateLimit(data.ratelimit))
dispatch(setScopes(data.scopes)) dispatch(setScopes(data.scopes))
dispatch(setUserEmails(data.emails))
}
} else { } else {
const credentials = await getGitHubCredentialsFromLocalStorage()
if (credentials) {
//dispatch(setGitHubUser({ login: credentials.username }))
//dispatch(setUserEmails([{ email: credentials.email, primary: true, visibility: 'public', verified: true }]))
}
dispatch(setGitHubUser(null)) dispatch(setGitHubUser(null))
} }
} catch (e) { } catch (e) {
@ -585,10 +596,6 @@ export const statusMatrix = async (filepaths: string[]) => {
return result; return result;
} }
export const diffFiles = async (filename: string | undefined) => {
}
export const resolveRef = async (ref: string) => { export const resolveRef = async (ref: string) => {
const oid = await plugin.call('dgitApi', "resolveref", { const oid = await plugin.call('dgitApi', "resolveref", {
ref, ref,

@ -1,9 +1,9 @@
import React from "react"; import React from "react";
import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog } from "../state/gitpayload"; import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog, setGitHubUser, setUserEmails } from "../state/gitpayload";
import { gitActionDispatch } from "../types"; import { gitActionDispatch } from "../types";
import { Plugin } from "@remixproject/engine"; import { Plugin } from "@remixproject/engine";
import { getBranches, getFileStatusMatrix, getGitHubUser, getRemotes, gitlog, setPlugin } from "./gitactions"; import { getBranches, getFileStatusMatrix, loadGitHubUserFromToken, getRemotes, gitlog, setPlugin } from "./gitactions";
import { Profile } from "@remixproject/plugin-utils"; import { Profile } from "@remixproject/plugin-utils";
import { CustomRemixApi } from "@remix-api"; import { CustomRemixApi } from "@remix-api";
@ -141,7 +141,7 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
}) })
plugin.on('manager', 'pluginActivated', async (p: Profile<any>) => { plugin.on('manager', 'pluginActivated', async (p: Profile<any>) => {
if (p.name === 'dgitApi') { if (p.name === 'dgitApi') {
getGitHubUser(); loadGitHubUserFromToken();
plugin.off('manager', 'pluginActivated'); plugin.off('manager', 'pluginActivated');
} }
}) })
@ -162,6 +162,10 @@ export const getGitConfig = async () => {
const token = await plugin.call('settings', 'get', 'settings/gist-access-token') const token = await plugin.call('settings', 'get', 'settings/gist-access-token')
const config = { username, email, token } const config = { username, email, token }
gitDispatch(setGItHubToken(config.token)) gitDispatch(setGItHubToken(config.token))
gitDispatch(setGitHubUser({
login: config.username,
}))
gitDispatch(setUserEmails([{ email: email, primary: true, visibility: 'public', verified: true }]))
return config return config
} }

@ -0,0 +1,51 @@
import { ReadCommitResult } from "isomorphic-git"
import { branch, branchDifference, commitChange, fileStatusResult, GitHubUser, gitLog, pagedCommits, remote, remoteBranch, repository, userEmails } from "../types"
export interface ActionPayloadTypes {
FILE_STATUS: fileStatusResult[],
FILE_STATUS_MERGE: fileStatusResult[]
SET_COMMITS: ReadCommitResult[]
SET_BRANCHES: branch[]
SET_CURRENT_BRANCH: branch
SET_CAN_USE_APP: boolean
SET_REPO_NAME: string
SET_LOADING: boolean
SET_REPOS: repository[]
SET_REMOTE_BRANCHES: remoteBranch[]
SET_CAN_COMMIT: boolean
SET_REMOTES: remote[]
SET_UPSTREAM: remote
SET_COMMIT_CHANGES: commitChange[]
RESET_REMOTE_BRANCH_COMMITS: {
branch: branch
pagedCommits: pagedCommits[]
}
SET_REMOTE_BRANCH_COMMITS: {
branch: branch
commits: pagedCommits[]
}
SET_LOCAL_BRANCH_COMMITS: {
branch: branch
commits: ReadCommitResult[]
}
SET_BRANCH_DIFFERENCES: {
branch: branch
remote: remote
branchDifference: branchDifference
}
SET_GITHUB_USER: GitHubUser
SET_RATE_LIMIT: any
SET_GITHUB_ACCESS_TOKEN: string
SET_SCOPES: string[]
SET_DEFAULT_REMOTE: remote
SET_LOG: gitLog
CLEAR_LOG: void
SET_USER_EMAILS: userEmails
}
export interface Action<T extends keyof ActionPayloadTypes> {
type: T,
payload: ActionPayloadTypes[T]
}
export type Actions = {[A in keyof ActionPayloadTypes]: Action<A>}[keyof ActionPayloadTypes]

@ -20,7 +20,7 @@ export interface gitActions {
getCommitChanges(oid1: string, oid2: string, branch?: branch, remote?: remote): Promise<commitChange[] | boolean> getCommitChanges(oid1: string, oid2: string, branch?: branch, remote?: remote): Promise<commitChange[] | boolean>
getBranchCommits(branch: branch, page: number): Promise<void> getBranchCommits(branch: branch, page: number): Promise<void>
getBranchDifferences(branch: branch, remote?: remote, state?: gitState): Promise<void> getBranchDifferences(branch: branch, remote?: remote, state?: gitState): Promise<void>
getGitHubUser(): Promise<any> loadGitHubUserFromToken(): Promise<any>
diff(commitChange: commitChange): Promise<void> diff(commitChange: commitChange): Promise<void>
resolveRef(ref: string): Promise<string> resolveRef(ref: string): Promise<string>
setUpstreamRemote(upstream: remote): Promise<void> setUpstreamRemote(upstream: remote): Promise<void>
@ -46,7 +46,7 @@ export interface pluginActions {
email, email,
token token
}): Promise<void> }): Promise<void>
getGitHubCredentials(): Promise<{ getGitHubCredentialsFromLocalStorage(): Promise<{
username: string username: string
email: string email: string
token: string token: string

@ -1,5 +1,5 @@
import { ReadCommitResult } from "isomorphic-git" import { ReadCommitResult } from "isomorphic-git"
import { GitHubUser, branch, commitChange, fileStatusResult, remote, pagedCommits, branchDifference, gitLog, repository } from "../types" import { GitHubUser, branch, commitChange, fileStatusResult, remote, pagedCommits, branchDifference, gitLog, repository, userEmails } from "../types"
import { Endpoints } from "@octokit/types" import { Endpoints } from "@octokit/types"
export const fileStatus = (files: fileStatusResult[]) => { export const fileStatus = (files: fileStatusResult[]) => {
@ -44,13 +44,20 @@ export const setRemoteBranches = (branches: any[]) => {
} }
} }
export const setGitHubUser = (user: any) => { export const setGitHubUser = (user: GitHubUser) => {
return { return {
type: 'SET_GITHUB_USER', type: 'SET_GITHUB_USER',
payload: user payload: user
} }
} }
export const setUserEmails = (emails: userEmails) => {
return {
type: 'SET_USER_EMAILS',
payload: emails
}
}
export const setRateLimit = (rateLimit: any) => { export const setRateLimit = (rateLimit: any) => {
return { return {
type: 'SET_RATE_LIMIT', type: 'SET_RATE_LIMIT',

@ -1,13 +1,9 @@
import { ReadCommitResult } from "isomorphic-git" import { ReadCommitResult } from "isomorphic-git"
import { allChangedButNotStagedFiles, getFilesByStatus, getFilesWithNotModifiedStatus } from "../lib/fileHelpers" import { allChangedButNotStagedFiles, getFilesByStatus, getFilesWithNotModifiedStatus } from "../lib/fileHelpers"
import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction, setDefaultRemoteAction, setRemotesAction, setUpstreamAction } from "../types" import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction, setDefaultRemoteAction, setRemotesAction, setUpstreamAction } from "../types"
import { Actions } from "./actions"
interface Action { export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => {
type: string
payload: any
}
export const gitReducer = (state: gitState = defaultGitState, action: Action): gitState => {
///console.log(action, state) ///console.log(action, state)
switch (action.type) { switch (action.type) {
@ -104,7 +100,7 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
case 'SET_UPSTREAM': case 'SET_UPSTREAM':
return { return {
...state, ...state,
upstream: (action as setUpstreamAction).payload upstream: action.payload
} }
case 'SET_COMMIT_CHANGES': case 'SET_COMMIT_CHANGES':
@ -119,8 +115,8 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
} }
case 'RESET_REMOTE_BRANCH_COMMITS': case 'RESET_REMOTE_BRANCH_COMMITS':
if (state.remoteBranchCommits[(action as setRemoteBranchCommitsAction).payload.branch.name]) { if (state.remoteBranchCommits[action.payload.branch.name]) {
delete state.remoteBranchCommits[(action as setRemoteBranchCommitsAction).payload.branch.name] delete state.remoteBranchCommits[action.payload.branch.name]
} }
return { return {
...state, ...state,
@ -128,10 +124,10 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
} }
case 'SET_REMOTE_BRANCH_COMMITS': case 'SET_REMOTE_BRANCH_COMMITS':
if (state.remoteBranchCommits[(action as setRemoteBranchCommitsAction).payload.branch.name]) { if (state.remoteBranchCommits[action.payload.branch.name]) {
state.remoteBranchCommits[(action as setRemoteBranchCommitsAction).payload.branch.name].push(...(action as setRemoteBranchCommitsAction).payload.commits) state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits)
} else { } else {
state.remoteBranchCommits[(action as setRemoteBranchCommitsAction).payload.branch.name] = (action as setRemoteBranchCommitsAction).payload.commits state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits
} }
return { return {
...state, ...state,
@ -140,7 +136,7 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
case 'SET_LOCAL_BRANCH_COMMITS': case 'SET_LOCAL_BRANCH_COMMITS':
state.localBranchCommits[(action as setLocalBranchCommitsAction).payload.branch.name] = (action as setLocalBranchCommitsAction).payload.commits state.localBranchCommits[action.payload.branch.name] = action.payload.commits
return { return {
...state, ...state,
localBranchCommits: { ...state.localBranchCommits } localBranchCommits: { ...state.localBranchCommits }
@ -148,7 +144,7 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
case 'SET_BRANCH_DIFFERENCES': case 'SET_BRANCH_DIFFERENCES':
state.branchDifferences[`${(action as setBranchDifferencesAction).payload.remote.name}/${(action as setBranchDifferencesAction).payload.branch.name}`] = (action as setBranchDifferencesAction).payload.branchDifference state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference
return { return {
...state, ...state,
@ -180,10 +176,17 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
gitHubScopes: action.payload gitHubScopes: action.payload
} }
case 'SET_USER_EMAILS':
return {
...state,
userEmails: action.payload
}
case 'SET_DEFAULT_REMOTE': case 'SET_DEFAULT_REMOTE':
return { return {
...state, ...state,
defaultRemote: (action as setDefaultRemoteAction).payload defaultRemote: action.payload
} }
case 'SET_LOG': case 'SET_LOG':

@ -2,8 +2,9 @@ import { Endpoints } from "@octokit/types"
import { IRemixApi } from "@remixproject/plugin-api" import { IRemixApi } from "@remixproject/plugin-api"
import { LibraryProfile, StatusEvents } from "@remixproject/plugin-utils" import { LibraryProfile, StatusEvents } from "@remixproject/plugin-utils"
import { CommitObject, ReadBlobResult, ReadCommitResult, StatusRow } from "isomorphic-git" import { CommitObject, ReadBlobResult, ReadCommitResult, StatusRow } from "isomorphic-git"
export type GitHubUser = Endpoints["GET /user"]["response"]['data'] export type GitHubUser = Partial<Endpoints["GET /user"]["response"]['data']>
export type RateLimit = Endpoints["GET /rate_limit"]["response"]["data"] export type RateLimit = Endpoints["GET /rate_limit"]["response"]["data"]
export type userEmails = Endpoints["GET /user/emails"]["response"]["data"]
export interface IGitApi { export interface IGitApi {
events: { events: {
@ -180,6 +181,7 @@ export type gitState = {
upstream: remote upstream: remote
gitHubUser: GitHubUser gitHubUser: GitHubUser
rateLimit: RateLimit rateLimit: RateLimit
userEmails: userEmails
gitHubScopes: string[] gitHubScopes: string[]
gitHubAccessToken: string gitHubAccessToken: string
log: gitLog[] log: gitLog[]
@ -293,6 +295,7 @@ export const defaultGitState: gitState = {
upstream: null, upstream: null,
gitHubUser: {} as GitHubUser, gitHubUser: {} as GitHubUser,
rateLimit: {} as RateLimit, rateLimit: {} as RateLimit,
userEmails: [] as userEmails,
gitHubScopes: [], gitHubScopes: [],
gitHubAccessToken: "", gitHubAccessToken: "",
log: [] log: []

@ -160,7 +160,7 @@ export const createWorkspace = async (
if (!currentBranch) { if (!currentBranch) {
if (!name || !email) { if (!name || !email) {
await plugin.call('notification', 'toast', 'To use Git features, add username and email to the Github section of the Settings panel.') await plugin.call('notification', 'toast', 'To use Git features, add username and email to the Github section of the Git plugin.')
} else { } else {
// commit the template as first commit // commit the template as first commit
plugin.call('notification', 'toast', 'Creating initial git commit ...') plugin.call('notification', 'toast', 'Creating initial git commit ...')
@ -691,7 +691,7 @@ export const cloneRepository = async (url: string) => {
id: 'cloneGitRepository', id: 'cloneGitRepository',
title: 'Clone Git Repository', title: 'Clone Git Repository',
message: message:
'An error occurred: Please check that you have the correct URL for the repo. If the repo is private, you need to add your github credentials (with the valid token permissions) in Settings plugin', 'An error occurred: Please check that you have the correct URL for the repo. If the repo is private, you need to add your github credentials (with the valid token permissions) in the Git plugin',
modalType: 'modal', modalType: 'modal',
okLabel: plugin.registry.get('platform').api.isDesktop() ? 'Select or create folder':'OK', okLabel: plugin.registry.get('platform').api.isDesktop() ? 'Select or create folder':'OK',
okFn: async () => { okFn: async () => {

Loading…
Cancel
Save