improve gist

pull/5370/head
yann300 9 months ago
parent 9f7c60059d
commit 4c3159d28b
  1. 11
      libs/remix-ui/workspace/src/lib/actions/index.ts
  2. 4
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -72,9 +72,10 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
dispatch(setWorkspaces(workspaces)) dispatch(setWorkspaces(workspaces))
} }
if (params.gist) { if (params.gist) {
await createWorkspaceTemplate('code-sample', 'gist-template') const name = 'gist ' + params.gist
plugin.setWorkspace({ name: 'code-sample', isLocalhost: false }) await createWorkspaceTemplate(name, 'gist-template')
dispatch(setCurrentWorkspace({ name: 'code-sample', isGitRepo: false })) plugin.setWorkspace({ name, isLocalhost: false })
dispatch(setCurrentWorkspace({ name, isGitRepo: false }))
await loadWorkspacePreset('gist-template') await loadWorkspacePreset('gist-template')
} else if (params.code || params.url || params.shareCode) { } else if (params.code || params.url || params.shareCode) {
await createWorkspaceTemplate('code-sample', 'code-template') await createWorkspaceTemplate('code-sample', 'code-template')
@ -229,8 +230,8 @@ export const publishToGist = async (path?: string, type?: string) => {
const folder = path || '/' const folder = path || '/'
try { try {
const name = extractNameFromKey(path) const name = await plugin.call('filePanel', 'getCurrentWorkspace')
const id = name && name.startsWith('gist-') ? name.split('-')[1] : null const id = name && name.startsWith('gist ') ? name.split(' ')[1] : null
const packaged = await packageGistFiles(folder) const packaged = await packageGistFiles(folder)
// check for token // check for token

@ -345,9 +345,9 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
} }
if (data.files[element].type === 'application/json') { if (data.files[element].type === 'application/json') {
obj['/' + 'gist-' + gistId + '/' + path] = { content: JSON.stringify(value.content, null, '\t') } obj['/' + path] = { content: JSON.stringify(value.content, null, '\t') }
} else } else
obj['/' + 'gist-' + gistId + '/' + path] = value obj['/' + path] = value
} }
plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => { plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => {
if (errorLoadingFile) { if (errorLoadingFile) {

Loading…
Cancel
Save