Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open manually created file #769

Merged
merged 5 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/commands/addFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC
.sendKeys('*[data-id="treeViewLitreeViewItembrowser/blank"] .remixui_items', browser.Keys.ENTER)
.pause(2000)
.waitForElementVisible(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`)
.click(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`)
// .click(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`)
.setEditorValue(content.content)
.pause(1000)
.perform(function () {
Expand Down
15 changes: 11 additions & 4 deletions libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,12 @@ export const FileExplorer = (props: FileExplorerProps) => {
const createFile = await fileManager.writeFile(newName, '')

if (!createFile) {
toast('Failed to create file ' + newName)
return toast('Failed to create file ' + newName)
} else {
await fileManager.open(newName)
setState(prevState => {
return { ...prevState, focusElement: [{ key: newName, type: 'file' }] }
})
}
}
})
Expand All @@ -300,7 +305,9 @@ export const FileExplorer = (props: FileExplorerProps) => {

if (exists) return
await fileManager.mkdir(dirName)
// addFolder(parentFolder, newFolderPath)
setState(prevState => {
return { ...prevState, focusElement: [{ key: newFolderPath, type: 'folder' }] }
})
} catch (e) {
console.log('error: ', e)
toast('Failed to create folder: ' + newFolderPath)
Expand Down Expand Up @@ -376,7 +383,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
setState(prevState => {
const uniquePaths = [...new Set([...prevState.expandPath, ...expandPath])]

return { ...prevState, files, expandPath: uniquePaths, focusElement: [{ key: filePath, type: 'file' }] }
return { ...prevState, files, expandPath: uniquePaths }
})
if (filePath.includes('_test.sol')) {
plugin.event.trigger('newTestFileCreated', [filePath])
Expand All @@ -393,7 +400,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
setState(prevState => {
const uniquePaths = [...new Set([...prevState.expandPath, ...expandPath])]

return { ...prevState, files, expandPath: uniquePaths, focusElement: [{ key: folderPath, type: 'folder' }] }
return { ...prevState, files, expandPath: uniquePaths }
})
}

Expand Down