translations

git4refactor
filip mertens 9 months ago
parent 933ae65fb8
commit 63c15f03d6
  1. 154
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 15
      apps/remix-ide/src/app/tabs/locales/en/git.json
  3. 4
      apps/remix-ide/src/app/tabs/locales/en/index.js
  4. 15
      apps/remix-ide/src/assets/list.json
  5. 7
      libs/remix-ui/git/src/components/gitui.tsx
  6. 6
      libs/remix-ui/git/src/components/navigation/commands.tsx
  7. 6
      libs/remix-ui/git/src/components/navigation/commits.tsx
  8. 4
      libs/remix-ui/git/src/components/navigation/remotesdetails.tsx
  9. 12
      libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx
  10. 4
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  11. 12
      libs/remix-ui/git/src/components/panels/github.tsx
  12. 8
      libs/remix-ui/git/src/components/panels/githubcredentials.tsx
  13. 2
      libs/remix-ui/git/src/lib/gitactions.ts
  14. 11
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -18,8 +18,11 @@ import {Registry} from '@remix-project/remix-lib'
import { Octokit, App } from "octokit"
import { OctokitResponse } from '@octokit/types'
import { Endpoints } from "@octokit/types"
import { commitChange, GitHubUser, RateLimit } from '@remix-ui/git'
import { IndexedDBStorage } from './filesystems/indexedDB'
import { GitHubUser, RateLimit, branch, commitChange, remote } from '@remix-ui/git'
declare global {
interface Window { remixFileSystemCallback: IndexedDBStorage; remixFileSystem: any; }
}
const profile = {
name: 'dGitProvider',
displayName: 'Decentralized git',
@ -338,10 +341,32 @@ class DGitProvider extends Plugin {
const defaultConfig = await this.getGitConfig()
const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig
const name = await git.currentBranch(cmd)
console.log('current branch', name)
let remote: remote = undefined
try {
const remoteName = await git.getConfig({
...defaultConfig,
path: `branch.${name}.remote`
})
if (remoteName)
{
const remoteUrl = await git.getConfig({
...defaultConfig,
path: `remote.${remoteName}.url`
})
remote = { remote: remoteName, url: remoteUrl }
}
return name
} catch (e) {
// do nothing
}
return {
remote: remote,
name: name || ''
}
} catch (e) {
return ''
return undefined
}
}
@ -746,7 +771,7 @@ class DGitProvider extends Plugin {
const files = await this.getDirectory('/')
this.filesToSend = []
for (const file of files) {
const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`)
const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`, null)
const ob = {
path: file,
content: c
@ -760,108 +785,6 @@ class DGitProvider extends Plugin {
return r.cid.string
}
async pin(pinataApiKey, pinataSecretApiKey) {
const workspace = await this.call('filePanel', 'getCurrentWorkspace')
const files = await this.getDirectory('/')
this.filesToSend = []
const data = new FormData()
for (const file of files) {
const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`)
data.append('file', new Blob([c]), `base/${file}`)
}
// get last commit data
let ob
try {
const commits = await this.log({ ref: 'HEAD' })
ob = {
ref: commits[0].oid,
message: commits[0].commit.message,
commits: JSON.stringify(commits.map((commit) => {
return {
oid: commit.oid,
commit: {
parent: commit.commit?.parent,
tree: commit.commit?.tree,
message: commit.commit?.message,
committer: {
timestamp: commit.commit?.committer?.timestamp
}
}
}
}))
}
} catch (e) {
ob = {
ref: 'no commits',
message: 'no commits'
}
}
const today = new Date()
const metadata = JSON.stringify({
name: `remix - ${workspace.name} - ${today.toLocaleString()}`,
keyvalues: ob
})
const pinataOptions = JSON.stringify({
wrapWithDirectory: false
})
data.append('pinataOptions', pinataOptions)
data.append('pinataMetadata', metadata)
const url = 'https://api.pinata.cloud/pinning/pinFileToIPFS'
try {
const result = await axios
.post(url, data, {
maxBodyLength: 'Infinity',
headers: {
'Content-Type': `multipart/form-data; boundary=${(data as any)._boundary}`,
pinata_api_key: pinataApiKey,
pinata_secret_api_key: pinataSecretApiKey
}
} as any).catch((e) => {
console.log(e)
})
// also commit to remix IPFS for availability after pinning to Pinata
return await this.export(this.remixIPFS) || (result as any).data.IpfsHash
} catch (error) {
throw new Error(error)
}
}
async pinList(pinataApiKey, pinataSecretApiKey) {
const url = 'https://api.pinata.cloud/data/pinList?status=pinned'
try {
const result = await axios
.get(url, {
maxBodyLength: 'Infinity',
headers: {
pinata_api_key: pinataApiKey,
pinata_secret_api_key: pinataSecretApiKey
}
} as any).catch((e) => {
console.log('Pinata unreachable')
})
return (result as any).data
} catch (error) {
throw new Error(error)
}
}
async unPin(pinataApiKey, pinataSecretApiKey, hashToUnpin) {
const url = `https://api.pinata.cloud/pinning/unpin/${hashToUnpin}`
try {
await axios
.delete(url, {
headers: {
pinata_api_key: pinataApiKey,
pinata_secret_api_key: pinataSecretApiKey
}
})
return true
} catch (error) {
throw new Error(error)
}
}
async importIPFSFiles(config, cid, workspace) {
const ipfs = IpfsHttpClient(config)
let result = false
@ -882,7 +805,7 @@ class DGitProvider extends Plugin {
await this.createDirectories(`${workspace.absolutePath}/${dir}`)
} catch (e) { throw new Error(e) }
try {
await window.remixFileSystem.writeFile(`${workspace.absolutePath}/${file.path}`, Buffer.concat(content) || new Uint8Array())
await window.remixFileSystem.writeFile(`${workspace.absolutePath}/${file.path}`, Buffer.concat(content) || new Uint8Array(), null)
} catch (e) { throw new Error(e) }
}
} catch (e) {
@ -948,7 +871,7 @@ class DGitProvider extends Plugin {
const files = await this.getDirectory('/')
this.filesToSend = []
for (const file of files) {
const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`)
const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`, null)
zip.file(file, c)
}
await zip.generateAsync({
@ -1064,20 +987,19 @@ class DGitProvider extends Plugin {
}
async repositories(input: { token: string }) {
console.log(input)
const octokit = new Octokit({
auth: input.token
})
const data = await octokit.request('GET /user/repos{?visibility,affiliation,type,sort,direction,per_page,page,since,before}', {
sort: "pushed",
direction: "desc",
console.log('octokit', input.token)
const data = await octokit.request('GET /user/repos', {
per_page: 100,
affiliation: "owner,collaborator"
page: 1
})
octokit
console.log(data.data)
return data.data
}

@ -0,0 +1,15 @@
{
"git.push": "push",
"git.pull": "pull",
"git.commit": "commit",
"git.sync": "sync",
"git.publish": "publish",
"git.ignore": "ignore",
"git.createBranch": "create branch",
"git.deleteBranch": "delete branch",
"git.mergeBranch": "merge branch",
"git.rebaseBranch": "rebase branch",
"git.checkout": "checkout",
"git.fetch": "fetch",
"git.refresh": "refresh"
}

@ -15,6 +15,7 @@ import solUmlGenJson from './solUmlGen.json'
import remixAppJson from './remixApp.json'
import remixUiTabsJson from './remixUiTabs.json'
import circuitJson from './circuit.json';
import gitJson from './git.json'
export default {
...debuggerJson,
@ -33,5 +34,6 @@ export default {
...solUmlGenJson,
...remixAppJson,
...remixUiTabsJson,
...circuitJson
...circuitJson,
...gitJson
}

@ -1079,9 +1079,22 @@
"bzzr://6e70fe6bfe8c3fc63f8a3eba733731aab129e6e58828b78058e53bb50440709b",
"dweb:/ipfs/QmZy5ho8W943FMGwppXZFS1WFrVwV3UXhUUwcD7oH5vrYe"
]
},
{
"path": "soljson-v0.8.24+commit.e11b9ed9.js",
"version": "0.8.24",
"build": "commit.e11b9ed9",
"longVersion": "0.8.24+commit.e11b9ed9",
"keccak256": "0x1b6ceeabad21bbb2011ba13373160f7c4d46c11371a354243ee1be07159345f3",
"sha256": "0x11b054b55273ec55f6ab3f445eb0eb2c83a23fed43d10079d34ac3eabe6ed8b1",
"urls": [
"bzzr://c604bdd6384bf73594cd0e5cfbe979048191549ebc88e70996346f3b744c0680",
"dweb:/ipfs/QmW2SQbEhiz3n2qV5iL8WBgzapv6cXjkLStvTMpCZhvr2x"
]
}
],
"releases": {
"0.8.24": "soljson-v0.8.24+commit.e11b9ed9.js",
"0.8.23": "soljson-v0.8.23+commit.f704f362.js",
"0.8.22": "soljson-v0.8.22+commit.4fc1097e.js",
"0.8.21": "soljson-v0.8.21+commit.d9974bed.js",
@ -1173,5 +1186,5 @@
"0.4.0": "soljson-v0.4.0+commit.acd334c9.js",
"0.3.6": "soljson-v0.3.6+commit.3fc68da5.js"
},
"latestRelease": "0.8.23"
"latestRelease": "0.8.24"
}

@ -162,13 +162,6 @@ export const GitUI = (props: IGitUi) => {
</>
</Accordion.Collapse>
<hr></hr>
<SettingsNavigation eventKey="6" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="6">
<>
<Settings></Settings>
</>
</Accordion.Collapse>
<hr></hr>
<GitHubNavigation eventKey="7" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="7">
<>

@ -32,13 +32,13 @@ export const CommandsNavigation = ({ eventKey, activePanel, callback }) => {
{
activePanel === eventKey ?
<span className='d-flex justify-content-end align-items-center w-25'>
<CustomTooltip tooltipText={<FormattedMessage id="Pull" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.pull" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowDown} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="Push" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.push" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowUp} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="Sync changes" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.sync" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowsUpDown} className="" /></button>
</CustomTooltip>
</span> : null

@ -31,13 +31,13 @@ export const CommitslNavigation = ({ eventKey, activePanel, callback }) => {
{
activePanel === eventKey ?
<span className='d-flex justify-content-end align-items-center w-25'>
<CustomTooltip tooltipText={<FormattedMessage id="Pull" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.pull" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowDown} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="Push" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.push" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowUp} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="Sync changes" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.sync" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowsUpDown} className="" /></button>
</CustomTooltip>
</span> : null

@ -34,7 +34,9 @@ export const RemotesDetailsNavigation = (props: RemotesDetailsNavigationProps) =
{
activePanel === eventKey ? <FontAwesomeIcon className='' icon={faCaretDown}></FontAwesomeIcon> : <FontAwesomeIcon className='' icon={faCaretRight}></FontAwesomeIcon>
}
<div className={`ml-1`}>{remote.remote} <FontAwesomeIcon className='' icon={faArrowRightArrowLeft}></FontAwesomeIcon> {remote.url}</div>
<div className="long-and-truncated">
{remote.remote} <FontAwesomeIcon className='' icon={faArrowRightArrowLeft}></FontAwesomeIcon> {remote.url}
</div>
</div>
{remote?.url && <FontAwesomeIcon className='ml-2 pointer' icon={faGlobe} onClick={() => openRemote()}></FontAwesomeIcon>}

@ -32,16 +32,16 @@ export const SourceControlNavigation = ({ eventKey, activePanel, callback }) =>
{
activePanel === eventKey ?
<span className='d-flex justify-content-end align-items-center w-25'>
<CustomTooltip tooltipText={<FormattedMessage id="Push" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowUp} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="Pull" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.pull" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowDown} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="Sync changes" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.push" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowUp} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="git.sync" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowsUpDown} className="" /></button>
</CustomTooltip>
<CustomTooltip tooltipText={<FormattedMessage id="Refresh" />}>
<CustomTooltip tooltipText={<FormattedMessage id="git.refresh" />}>
<button onClick={async () => { await pluginactions.loadFiles() }} className='btn btn-sm'><FontAwesomeIcon icon={faArrowRotateRight} className="" /></button>
</CustomTooltip>

@ -97,9 +97,9 @@ export const PushPull = () => {
<div className="btn-group w-100" role="group" aria-label="Basic example">
<button type="button" onClick={async () => push()} className="btn btn-primary mr-1">Push</button>
<button type="button" onClick={async () => pull()} className="btn btn-primary">Pull</button>
<button type="button" onClick={async () => pull()} className="btn btn-primary mr-1">Pull</button>
<button type="button" onClick={async () => push()} className="btn btn-primary">Push</button>
</div>

@ -13,7 +13,7 @@ export const GitHubAuth = () => {
const [gitHubResponse, setGitHubResponse] = React.useState<any>(null)
const [authorized, setAuthorized] = React.useState<boolean>(false)
const client_id = 'Iv1.12fc02c69c512462'// 'e90cf20e6cafa2fd71ea'
const getDeviceCodeFromGitHub = async () => {
@ -23,7 +23,7 @@ export const GitHubAuth = () => {
method: 'post',
url: 'http://0.0.0.0:3000/github.com/login/device/code',
data: {
client_id: 'Iv1.12fc02c69c512462'
client_id // : 'Iv1.12fc02c69c512462'
},
headers: {
'Content-Type': 'application/json',
@ -44,9 +44,9 @@ export const GitHubAuth = () => {
method: 'post',
url: 'http://0.0.0.0:3000/github.com/login/oauth/access_token',
data: {
client_id: 'Iv1.12fc02c69c512462',
client_id,// : 'Iv1.12fc02c69c512462',
device_code: gitHubResponse.device_code,
grant_type: 'urn:ietf:params:oauth:grant-type:device_code'
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
},
headers: {
'Content-Type': 'application/json',
@ -93,7 +93,7 @@ export const GitHubAuth = () => {
{(context.gitHubUser && context.gitHubUser.login) ? null :
<button className='btn btn-primary mt-1 w-100' onClick={async () => {
getDeviceCodeFromGitHub();
}}>Login in with github</button>
}}>Sign in with GitHub</button>
}
{gitHubResponse && !authorized &&
<div className="pt-2">
@ -120,7 +120,7 @@ export const GitHubAuth = () => {
<div className="pt-2">
<button className='btn btn-primary mt-1 w-100' onClick={async () => {
disconnect()
}}>Disconnect</button>
}}>Sign out</button>
</div>: null
}
{

@ -41,13 +41,15 @@ export const GitHubCredentials = () => {
return (
<>
<div className="input-group text-secondary mb-0 h6">
<input type="text" className="form-control" name='githubToken' />
<hr></hr>
<label className="pr-1">Manual Configuration</label>
<div className="input-group text-secondary mb-1 h6">
<input type="text" placeholder="GitHub token" className="form-control" name='githubToken' />
<div className="input-group-append">
<CopyToClipboard content={''} data-id='copyToClipboardCopyIcon' className='far fa-copy ml-1 p-2 mt-1' direction={"top"} />
</div>
</div>
<input name='githubUsername' onChange={e => handleChangeUserNameState(e.target.value)} value={githubUsername} className="form-control mb-2" placeholder="GitHub username" type="text" id="githubUsername" />
<input name='githubUsername' onChange={e => handleChangeUserNameState(e.target.value)} value={githubUsername} className="form-control mb-1" placeholder="GitHub username" type="text" id="githubUsername" />
<input name='githubEmail' onChange={e => handleChangeEmailState(e.target.value)} value={githubEmail} className="form-control mb-1" placeholder="GitHub email" type="text" id="githubEmail" />
<hr />
</>

@ -337,7 +337,7 @@ const tokenWarning = async () => {
title: 'No GitHub token set',
id: 'no-token-set',
}
plugin.call('notification', 'alert', modalContent)
//plugin.call('notification', 'alert', modalContent)
return false;
} else {
return token;

@ -42,6 +42,7 @@ import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files
import { getUncommittedFiles } from '../utils/gitStatusFilter'
import { AppModal, ModalTypes } from '@remix-ui/app'
import { contractDeployerScripts, etherscanScripts } from '@remix-project/remix-ws-templates'
import { branch } from '@remix-ui/git'
declare global {
interface Window {
@ -151,7 +152,7 @@ export const createWorkspace = async (
if (isGitRepo && createCommit) {
const name = await plugin.call('settings', 'get', 'settings/github-user-name')
const email = await plugin.call('settings', 'get', 'settings/github-email')
const currentBranch = await plugin.call('dGitProvider', 'currentbranch')
const currentBranch: branch = await plugin.call('dGitProvider', 'currentbranch')
if (!currentBranch) {
if (!name || !email) {
@ -673,8 +674,8 @@ export const checkGit = async () => {
dispatch(setCurrentWorkspaceIsGitRepo(isGitRepo))
dispatch(setCurrentWorkspaceHasGitSubmodules(hasGitSubmodule))
await refreshBranches()
const currentBranch = await plugin.call('dGitProvider', 'currentbranch')
dispatch(setCurrentWorkspaceCurrentBranch(currentBranch))
const currentBranch: branch = await plugin.call('dGitProvider', 'currentbranch')
dispatch(setCurrentWorkspaceCurrentBranch(currentBranch.name))
} catch (e) {}
}
@ -711,8 +712,8 @@ export const getGitRepoCurrentBranch = async (workspaceName: string) => {
fs: window.remixFileSystemCallback,
dir: addSlash(workspaceName),
}
const currentBranch: string = await plugin.call('dGitProvider', 'currentbranch', { ...gitConfig })
return currentBranch
const currentBranch: branch = await plugin.call('dGitProvider', 'currentbranch', { ...gitConfig })
return currentBranch.name
}
export const showAllBranches = async () => {

Loading…
Cancel
Save