|
|
@ -12,6 +12,7 @@ import { ROOT_PATH, slitherYml, solTestYml, tsSolTestYml } from '../utils/consta |
|
|
|
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
|
|
|
|
// eslint-disable-next-line @nrwl/nx/enforce-module-boundaries
|
|
|
|
import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files/filesystems/indexedDB' |
|
|
|
import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files/filesystems/indexedDB' |
|
|
|
import { getUncommittedFiles } from '../utils/gitStatusFilter' |
|
|
|
import { getUncommittedFiles } from '../utils/gitStatusFilter' |
|
|
|
|
|
|
|
import { AppModal, ModalTypes } from '@remix-ui/app' |
|
|
|
|
|
|
|
|
|
|
|
declare global { |
|
|
|
declare global { |
|
|
|
interface Window { remixFileSystemCallback: IndexedDBStorage; } |
|
|
|
interface Window { remixFileSystemCallback: IndexedDBStorage; } |
|
|
@ -358,14 +359,7 @@ export const switchToWorkspace = async (name: string) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const uploadFile = async (target, targetFolder: string, cb?: (err: Error, result?: string | number | boolean | Record<string, any>) => void) => { |
|
|
|
const loadFile = (name, file, provider, cb?): void => { |
|
|
|
// TODO The file explorer is merely a view on the current state of
|
|
|
|
|
|
|
|
// the files module. Please ask the user here if they want to overwrite
|
|
|
|
|
|
|
|
// a file and then just use `files.add`. The file explorer will
|
|
|
|
|
|
|
|
// pick that up via the 'fileAdded' event from the files module.
|
|
|
|
|
|
|
|
[...target.files].forEach(async (file) => { |
|
|
|
|
|
|
|
const workspaceProvider = plugin.fileProviders.workspace |
|
|
|
|
|
|
|
const loadFile = (name: string): void => { |
|
|
|
|
|
|
|
const fileReader = new FileReader() |
|
|
|
const fileReader = new FileReader() |
|
|
|
|
|
|
|
|
|
|
|
fileReader.onload = async function (event) { |
|
|
|
fileReader.onload = async function (event) { |
|
|
@ -373,7 +367,7 @@ export const uploadFile = async (target, targetFolder: string, cb?: (err: Error, |
|
|
|
return dispatch(displayNotification('File Upload Failed', 'Special characters are not allowed', 'Close', null, async () => { })) |
|
|
|
return dispatch(displayNotification('File Upload Failed', 'Special characters are not allowed', 'Close', null, async () => { })) |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
await workspaceProvider.set(name, event.target.result) |
|
|
|
await provider.set(name, event.target.result) |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
return dispatch(displayNotification('File Upload Failed', 'Failed to create file ' + name, 'Close', null, async () => { })) |
|
|
|
return dispatch(displayNotification('File Upload Failed', 'Failed to create file ' + name, 'Close', null, async () => { })) |
|
|
|
} |
|
|
|
} |
|
|
@ -388,18 +382,62 @@ export const uploadFile = async (target, targetFolder: string, cb?: (err: Error, |
|
|
|
fileReader.readAsText(file) |
|
|
|
fileReader.readAsText(file) |
|
|
|
cb && cb(null, true) |
|
|
|
cb && cb(null, true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const uploadFile = async (target, targetFolder: string, cb?: (err: Error, result?: string | number | boolean | Record<string, any>) => void) => { |
|
|
|
|
|
|
|
// TODO The file explorer is merely a view on the current state of
|
|
|
|
|
|
|
|
// the files module. Please ask the user here if they want to overwrite
|
|
|
|
|
|
|
|
// a file and then just use `files.add`. The file explorer will
|
|
|
|
|
|
|
|
// pick that up via the 'fileAdded' event from the files module.
|
|
|
|
|
|
|
|
[...target.files].forEach(async (file) => { |
|
|
|
|
|
|
|
const workspaceProvider = plugin.fileProviders.workspace |
|
|
|
const name = targetFolder === '/' ? file.name : `${targetFolder}/${file.name}` |
|
|
|
const name = targetFolder === '/' ? file.name : `${targetFolder}/${file.name}` |
|
|
|
|
|
|
|
|
|
|
|
if (!await workspaceProvider.exists(name)) { |
|
|
|
if (!await workspaceProvider.exists(name)) { |
|
|
|
loadFile(name) |
|
|
|
loadFile(name, file, workspaceProvider, cb) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dispatch(displayNotification('Confirm overwrite', `The file ${name} already exists! Would you like to overwrite it?`, 'OK', null, () => { |
|
|
|
const modalContent: AppModal = { |
|
|
|
loadFile(name) |
|
|
|
id: 'overwriteUploadFile', |
|
|
|
}, () => { })) |
|
|
|
title: 'Confirm overwrite', |
|
|
|
|
|
|
|
message: `The file "${name}" already exists! Would you like to overwrite it?`, |
|
|
|
|
|
|
|
modalType: ModalTypes.confirm, |
|
|
|
|
|
|
|
okLabel: 'OK', |
|
|
|
|
|
|
|
cancelLabel: 'Cancel', |
|
|
|
|
|
|
|
okFn: () => { |
|
|
|
|
|
|
|
loadFile(name, file, workspaceProvider, cb) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
cancelFn: () => {}, |
|
|
|
|
|
|
|
hideFn: () => {} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
plugin.call('notification', 'modal', modalContent) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const uploadFolder = async (target, targetFolder: string, cb?: (err: Error, result?: string | number | boolean | Record<string, any>) => void) => { |
|
|
|
|
|
|
|
for(const file of [...target.files]) { |
|
|
|
|
|
|
|
const workspaceProvider = plugin.fileProviders.workspace |
|
|
|
|
|
|
|
const name = targetFolder === '/' ? file.webkitRelativePath : `${targetFolder}/${file.webkitRelativePath}` |
|
|
|
|
|
|
|
if (!await workspaceProvider.exists(name)) { |
|
|
|
|
|
|
|
loadFile(name, file, workspaceProvider, cb) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
const modalContent: AppModal = { |
|
|
|
|
|
|
|
id: 'overwriteUploadFolderFile', |
|
|
|
|
|
|
|
title: 'Confirm overwrite', |
|
|
|
|
|
|
|
message: `The file "${name}" already exists! Would you like to overwrite it?`, |
|
|
|
|
|
|
|
modalType: ModalTypes.confirm, |
|
|
|
|
|
|
|
okLabel: 'OK', |
|
|
|
|
|
|
|
cancelLabel: 'Cancel', |
|
|
|
|
|
|
|
okFn: () => { |
|
|
|
|
|
|
|
loadFile(name, file, workspaceProvider, cb) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
cancelFn: () => {}, |
|
|
|
|
|
|
|
hideFn: () => {} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
plugin.call('notification', 'modal', modalContent) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const getWorkspaces = async (): Promise<{ name: string, isGitRepo: boolean, branches?: { remote: any; name: string; }[], currentBranch?: string }[]> | undefined => { |
|
|
|
export const getWorkspaces = async (): Promise<{ name: string, isGitRepo: boolean, branches?: { remote: any; name: string; }[], currentBranch?: string }[]> | undefined => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const workspaces: { name: string, isGitRepo: boolean, branches?: { remote: any; name: string; }[], currentBranch?: string }[] = await new Promise((resolve, reject) => { |
|
|
|
const workspaces: { name: string, isGitRepo: boolean, branches?: { remote: any; name: string; }[], currentBranch?: string }[] = await new Promise((resolve, reject) => { |
|
|
|