From 63c15f03d61686e1e56316476fd27ae19b27cf8f Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 15 Feb 2024 09:00:53 +0100 Subject: [PATCH] translations --- apps/remix-ide/src/app/files/dgitProvider.ts | 154 +++++------------- .../src/app/tabs/locales/en/git.json | 15 ++ .../src/app/tabs/locales/en/index.js | 4 +- apps/remix-ide/src/assets/list.json | 15 +- libs/remix-ui/git/src/components/gitui.tsx | 7 - .../src/components/navigation/commands.tsx | 6 +- .../git/src/components/navigation/commits.tsx | 6 +- .../components/navigation/remotesdetails.tsx | 4 +- .../components/navigation/sourcecontrol.tsx | 12 +- .../components/panels/commands/pushpull.tsx | 6 +- .../git/src/components/panels/github.tsx | 12 +- .../components/panels/githubcredentials.tsx | 8 +- libs/remix-ui/git/src/lib/gitactions.ts | 2 +- .../workspace/src/lib/actions/workspace.ts | 11 +- 14 files changed, 106 insertions(+), 156 deletions(-) create mode 100644 apps/remix-ide/src/app/tabs/locales/en/git.json diff --git a/apps/remix-ide/src/app/files/dgitProvider.ts b/apps/remix-ide/src/app/files/dgitProvider.ts index 669a28e78b..12c9d35693 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.ts +++ b/apps/remix-ide/src/app/files/dgitProvider.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 } + } + + } catch (e) { + // do nothing + } - return name + 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 }) + + console.log('octokit', input.token) - const data = await octokit.request('GET /user/repos{?visibility,affiliation,type,sort,direction,per_page,page,since,before}', { - sort: "pushed", - direction: "desc", + const data = await octokit.request('GET /user/repos', { per_page: 100, - affiliation: "owner,collaborator" + page: 1 }) - - octokit - + console.log(data.data) return data.data } diff --git a/apps/remix-ide/src/app/tabs/locales/en/git.json b/apps/remix-ide/src/app/tabs/locales/en/git.json new file mode 100644 index 0000000000..2ccdb2e2ba --- /dev/null +++ b/apps/remix-ide/src/app/tabs/locales/en/git.json @@ -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" +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/tabs/locales/en/index.js b/apps/remix-ide/src/app/tabs/locales/en/index.js index 8da7dd179f..31c606f7a7 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/index.js +++ b/apps/remix-ide/src/app/tabs/locales/en/index.js @@ -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 } diff --git a/apps/remix-ide/src/assets/list.json b/apps/remix-ide/src/assets/list.json index 7c75a856e5..b22d882d4b 100644 --- a/apps/remix-ide/src/assets/list.json +++ b/apps/remix-ide/src/assets/list.json @@ -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" } \ No newline at end of file diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 32cfe7c321..0c15769cfb 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -162,13 +162,6 @@ export const GitUI = (props: IGitUi) => {
- - - <> - - - -
<> diff --git a/libs/remix-ui/git/src/components/navigation/commands.tsx b/libs/remix-ui/git/src/components/navigation/commands.tsx index 0ab669fd63..1d69ca9c01 100644 --- a/libs/remix-ui/git/src/components/navigation/commands.tsx +++ b/libs/remix-ui/git/src/components/navigation/commands.tsx @@ -32,13 +32,13 @@ export const CommandsNavigation = ({ eventKey, activePanel, callback }) => { { activePanel === eventKey ? - }> + }> - }> + }> - }> + }> : null diff --git a/libs/remix-ui/git/src/components/navigation/commits.tsx b/libs/remix-ui/git/src/components/navigation/commits.tsx index 4b3f455e03..8d07175748 100644 --- a/libs/remix-ui/git/src/components/navigation/commits.tsx +++ b/libs/remix-ui/git/src/components/navigation/commits.tsx @@ -31,13 +31,13 @@ export const CommitslNavigation = ({ eventKey, activePanel, callback }) => { { activePanel === eventKey ? - }> + }> - }> + }> - }> + }> : null diff --git a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx index 4665e6d281..60ef11aa17 100644 --- a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx +++ b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx @@ -34,7 +34,9 @@ export const RemotesDetailsNavigation = (props: RemotesDetailsNavigationProps) = { activePanel === eventKey ? : } -
{remote.remote} {remote.url}
+
+ {remote.remote} {remote.url} +
{remote?.url && openRemote()}>} diff --git a/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx b/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx index bd21c3e6e0..c7c83b46f9 100644 --- a/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx +++ b/libs/remix-ui/git/src/components/navigation/sourcecontrol.tsx @@ -32,16 +32,16 @@ export const SourceControlNavigation = ({ eventKey, activePanel, callback }) => { activePanel === eventKey ? - }> - - - }> + }> - }> + }> + + + }> - }> + }> diff --git a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx index 22adc81dc2..ca6ed1c8ae 100644 --- a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx +++ b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx @@ -97,9 +97,9 @@ export const PushPull = () => {
- - - + + +
diff --git a/libs/remix-ui/git/src/components/panels/github.tsx b/libs/remix-ui/git/src/components/panels/github.tsx index 8d7958c1b9..57ce6938b6 100644 --- a/libs/remix-ui/git/src/components/panels/github.tsx +++ b/libs/remix-ui/git/src/components/panels/github.tsx @@ -13,7 +13,7 @@ export const GitHubAuth = () => { const [gitHubResponse, setGitHubResponse] = React.useState(null) const [authorized, setAuthorized] = React.useState(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 : + }}>Sign in with GitHub } {gitHubResponse && !authorized &&
@@ -120,7 +120,7 @@ export const GitHubAuth = () => {
+ }}>Sign out
: null } { diff --git a/libs/remix-ui/git/src/components/panels/githubcredentials.tsx b/libs/remix-ui/git/src/components/panels/githubcredentials.tsx index 3e23b56988..de7bb09d94 100644 --- a/libs/remix-ui/git/src/components/panels/githubcredentials.tsx +++ b/libs/remix-ui/git/src/components/panels/githubcredentials.tsx @@ -41,13 +41,15 @@ export const GitHubCredentials = () => { return ( <> -
- +
+ +
+
- handleChangeUserNameState(e.target.value)} value={githubUsername} className="form-control mb-2" placeholder="GitHub username" type="text" id="githubUsername" /> + handleChangeUserNameState(e.target.value)} value={githubUsername} className="form-control mb-1" placeholder="GitHub username" type="text" id="githubUsername" /> handleChangeEmailState(e.target.value)} value={githubEmail} className="form-control mb-1" placeholder="GitHub email" type="text" id="githubEmail" />
diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index d079b9e889..d9bc95baa8 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -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; diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 3a932a8f9d..4bc4220107 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -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 () => {