|
|
@ -1,83 +1,99 @@ |
|
|
|
|
|
|
|
|
|
|
|
import React, { useState } from 'react' |
|
|
|
import React, { useEffect, useRef, useState } from 'react' |
|
|
|
import { WorkSpacePlugin } from './Client' |
|
|
|
import { WorkSpacePlugin } from './Client' |
|
|
|
import { Logger } from './logger' |
|
|
|
import { Logger } from './logger' |
|
|
|
|
|
|
|
import { useBehaviorSubject } from './usesubscribe/index' |
|
|
|
|
|
|
|
import { filePanelProfile } from '@remixproject/plugin-api/lib/file-system/file-panel/profile' |
|
|
|
|
|
|
|
import { filSystemProfile } from '@remixproject/plugin-api/lib/file-system/file-manager/profile' |
|
|
|
|
|
|
|
import { dGitProfile } from '@remixproject/plugin-api/lib/dgit/profile' |
|
|
|
|
|
|
|
import { editorProfile } from '@remixproject/plugin-api/lib/editor/profile' |
|
|
|
|
|
|
|
import { settingsProfile } from '@remixproject/plugin-api/lib/settings/profile' |
|
|
|
|
|
|
|
import { networkProfile } from '@remixproject/plugin-api/lib/network/profile' |
|
|
|
|
|
|
|
import { terminalProfile } from '@remixproject/plugin-api/lib/terminal/profile' |
|
|
|
|
|
|
|
import { udappProfile } from '@remixproject/plugin-api/lib/udapp' |
|
|
|
|
|
|
|
import { compilerProfile } from '@remixproject/plugin-api/lib/compiler' |
|
|
|
|
|
|
|
import { contentImportProfile } from '@remixproject/plugin-api/lib/content-import' |
|
|
|
|
|
|
|
import { unitTestProfile } from '@remixproject/plugin-api/lib/unit-testing' |
|
|
|
|
|
|
|
import { windowProfile } from '@remixproject/plugin-api/lib/window' |
|
|
|
|
|
|
|
import { pluginManagerProfile } from '@remixproject/plugin-api/lib/plugin-manager' |
|
|
|
|
|
|
|
import { IFileSystem } from '@remixproject/plugin-api' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { Profile } from '@remixproject/plugin-utils' |
|
|
|
|
|
|
|
|
|
|
|
export const client = new WorkSpacePlugin() |
|
|
|
export const client = new WorkSpacePlugin() |
|
|
|
|
|
|
|
|
|
|
|
function App () { |
|
|
|
function App () { |
|
|
|
const [payload, setPayload] = useState<string>('') |
|
|
|
const [payload, setPayload] = useState<string>('') |
|
|
|
const [result, setResult] = useState<string>() |
|
|
|
|
|
|
|
const [append, setAppend] = useState<boolean>(false) |
|
|
|
const [append, setAppend] = useState<boolean>(false) |
|
|
|
|
|
|
|
const [log, setLog] = useState<any>() |
|
|
|
|
|
|
|
const [profiles, setProfiles] = useState<any[]>([pluginManagerProfile, filePanelProfile, filSystemProfile, dGitProfile, networkProfile, settingsProfile, editorProfile, terminalProfile, compilerProfile, udappProfile, contentImportProfile, unitTestProfile, windowProfile]) |
|
|
|
|
|
|
|
|
|
|
|
const handleChange = ({ target }: any) => { |
|
|
|
const handleChange = ({ target }: any) => { |
|
|
|
setPayload(target.value) |
|
|
|
setPayload(target.value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
client.onload(async () => { |
|
|
|
|
|
|
|
const customProfiles = ['solidity'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const name of customProfiles) { |
|
|
|
|
|
|
|
const p = await client.call('manager', 'getProfile', name) |
|
|
|
|
|
|
|
setProfiles(profiles => [p, ...profiles]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
profiles.map((profile: Profile) => { |
|
|
|
|
|
|
|
if (profile.events) { |
|
|
|
|
|
|
|
profile.events.map((event: string) => { |
|
|
|
|
|
|
|
console.log(profile.name, event) |
|
|
|
|
|
|
|
client.on(profile.name as any, event, (...args:any) => { |
|
|
|
|
|
|
|
console.log(event, args) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
const setAppendChange = ({ target }: any) => { |
|
|
|
const setAppendChange = ({ target }: any) => { |
|
|
|
console.log('append', target.checked) |
|
|
|
console.log('append', target.checked) |
|
|
|
setAppend(target.checked) |
|
|
|
setAppend(target.checked) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const clientMethod = async (profile: Profile, method: string) => { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
let ob: any = null |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
ob = JSON.parse(payload) |
|
|
|
|
|
|
|
} catch (e) {} |
|
|
|
|
|
|
|
const send = ob || [payload] |
|
|
|
|
|
|
|
const result = await client.call(profile.name as any, method, ...send) |
|
|
|
|
|
|
|
setLog(result) |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
setLog(e.message) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="App"> |
|
|
|
<div className="App container-fluid"> |
|
|
|
<div>v5</div> |
|
|
|
<h5>PLUGIN API TESTER</h5> |
|
|
|
<Logger append={append}></Logger> |
|
|
|
<Logger log={log} append={append}></Logger> |
|
|
|
<input id='appendToLog' type='checkbox' onChange={setAppendChange}/><label>append logs</label> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.zip()}>zip</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.ipfspush()}>ipfs push</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.ipfspull(payload)}>ipfs pull</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.ipfsConfig()}>ipfs config</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.getAccounts()}>get accounts</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.setSettings()}>set settings to injected</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.getSettings()}>get settings</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.soltest()}>run sol test</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.highlight(payload)}>highlight</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.addAnnotation(payload)}>annotation</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.clearAnnotations(payload)}>clear annotation</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.open(payload)}>openfile</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.readddir(payload)}>readdir</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.write(payload)}>write</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.switchfile(payload)}>switch to file</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.getcurrentfile()}>getcurrentfile</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.importcontent(payload)}>import content resolve</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.fetch(payload)}>api test fetch</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.axios(payload)}>api test axios</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.activate(payload)}>activate</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.deactivate(payload)}>deactivate</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.getresult()}>get compilation result</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.getcompilerconfig()}>get compiler config</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.getWorkSpace()}>get workspace</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.getWorkSpaces()}>get workspaces</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.createWorkSpace(payload)}>create workspace</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitinit(payload)}>git init</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitstatus(payload)}>git status</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitlog()}>git log</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitcommit()}>git commit</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitadd(payload)}>git add</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitremove(payload)}>git rm</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitlsfiles()}>git ls files</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitreadblob(payload)}>git read blob</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitresolveref()}>git resolve head</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitbranches()}>git branches</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitbranch(payload)}>git create branch</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitcheckout(payload)}>git checkout</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.gitcurrentbranch()}>git current branch</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.changetoinjected()}>change to injected</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.pinatapush()}>pinata write</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.pinlist()}>pinata list</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.setCallBacks()}>callbacks</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.log('')}>log</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.activatePlugin(payload)}>activate</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.deActivatePlugin(payload)}>deactivate</button> |
|
|
|
|
|
|
|
<button className='btn btn-primary btn-sm' onClick={async () => await client.debug(payload)}>debug</button> |
|
|
|
|
|
|
|
<input |
|
|
|
<input |
|
|
|
|
|
|
|
className='form-control w-100' |
|
|
|
type="text" |
|
|
|
type="text" |
|
|
|
id="payload" |
|
|
|
id="payload" |
|
|
|
placeholder="Enter payload here..." |
|
|
|
placeholder="Enter payload here..." |
|
|
|
value={payload} |
|
|
|
value={payload} |
|
|
|
onChange={handleChange} |
|
|
|
onChange={handleChange} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<input className='' id='appendToLog' type='checkbox' onChange={setAppendChange} /><label> Append logs</label> |
|
|
|
|
|
|
|
{profiles.map((profile: Profile) => { |
|
|
|
|
|
|
|
const methods = profile.methods.map((method: string) => { |
|
|
|
|
|
|
|
return <button data-id={`${profile.name}:${method}`} key={method} className='btn btn-primary btn-sm ml-1 mb-1' onClick={async () => await clientMethod(profile, method)}>{method}</button> |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return <div key={profile.name} className='small'><label>{profile.name}</label><br></br>{methods}</div> |
|
|
|
|
|
|
|
})} |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|