Merge pull request #4485 from ethereum/fix_gist

Fix gist
pull/4492/head
yann300 10 months ago committed by GitHub
commit 17899c92c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      apps/remix-ide-e2e/src/tests/gist.test.ts
  2. 1
      libs/remix-ui/workspace/src/lib/actions/index.ts
  3. 16
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -145,6 +145,18 @@ module.exports = {
.openFile(`gist-${testData.validGistId}/README.txt`)
.waitForElementVisible(`div[data-path='default_workspace/gist-${testData.validGistId}/README.txt']`)
.assert.containsText(`div[data-path='default_workspace/gist-${testData.validGistId}/README.txt'] > span`, 'README.txt')
.end()
}
},
'Load Gist from URL and verify truncated files are loaded #group3': function (browser: NightwatchBrowser) {
const gistId = '1b179bf1b92c8b0664b4cbe61774e15d'
browser
.url('http://127.0.0.1:8080/#gist=' + gistId)
.refreshPage()
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 15000)
.waitForElementVisible(`#fileExplorerView li[data-path='gist-${gistId}/README.txt']`, 30000)
.openFile(`gist-${gistId}/scripts/deploy_with_ethers.ts`)
.getEditorValue((content) => {
browser.assert.ok(content !== '')
})
}
}

@ -402,6 +402,7 @@ export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'g
if (type === 'file' && path.endsWith('.md')) {
// just opening the preview
await plugin.call('doc-viewer' as any, 'viewDocs', [path])
plugin.call('tabs' as any, 'focus', 'doc-viewer')
} else {
await plugin.fileManager.open(path)
dispatch(focusElement([{ key: path, type }]))

@ -308,11 +308,21 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
}
const obj = {}
Object.keys(data.files).forEach((element) => {
for (const [element] of Object.entries(data.files)) {
const path = element.replace(/\.\.\./g, '/')
let value
if (data.files[element].truncated) {
const response: AxiosResponse = await axios.get(data.files[element].raw_url)
value = { content: response.data }
} else {
value = { content: data.files[element].content }
}
obj['/' + 'gist-' + gistId + '/' + path] = data.files[element]
})
if (data.files[element].type === 'application/json') {
obj['/' + 'gist-' + gistId + '/' + path] = { content: JSON.stringify(value.content, null, '\t') }
} else
obj['/' + 'gist-' + gistId + '/' + path] = value
}
plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => {
if (errorLoadingFile) {
dispatch(displayNotification('', errorLoadingFile.message || errorLoadingFile, 'OK', null, () => {}, null))

Loading…
Cancel
Save