Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
2af196bb
Unverified
Commit
2af196bb
authored
Jan 20, 2021
by
David Disu
Committed by
GitHub
Jan 20, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #756 from ethereum/fix-explorer-bug
Fixed file explorer bugs
parents
1674b57d
c2c45388
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+9
-1
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+14
-4
index.ts
libs/remix-ui/file-explorer/src/lib/types/index.ts
+2
-1
No files found.
apps/remix-ide/src/app/panels/file-panel.js
View file @
2af196bb
...
@@ -65,6 +65,7 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -65,6 +65,7 @@ module.exports = class Filepanel extends ViewPlugin {
this
.
renderComponent
()
this
.
renderComponent
()
}
}
}
}
this
.
reset
=
false
this
.
el
=
yo
`
this
.
el
=
yo
`
<div id="fileExplorerView">
<div id="fileExplorerView">
</div>
</div>
...
@@ -92,6 +93,11 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -92,6 +93,11 @@ module.exports = class Filepanel extends ViewPlugin {
this
.
renderComponent
()
this
.
renderComponent
()
}
}
resetFocus
(
value
)
{
this
.
reset
=
value
this
.
renderComponent
()
}
render
()
{
render
()
{
return
this
.
el
return
this
.
el
}
}
...
@@ -99,7 +105,7 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -99,7 +105,7 @@ module.exports = class Filepanel extends ViewPlugin {
renderComponent
()
{
renderComponent
()
{
ReactDOM
.
render
(
ReactDOM
.
render
(
<
div
className
=
'remixui_container'
>
<
div
className
=
'remixui_container'
>
<
div
className
=
'remixui_fileexplorer'
>
<
div
className
=
'remixui_fileexplorer'
onClick
=
{()
=>
this
.
resetFocus
(
true
)}
>
<
div
className
=
'remixui_fileExplorerTree'
>
<
div
className
=
'remixui_fileExplorerTree'
>
<
div
>
<
div
>
<
div
className
=
'pl-2 remixui_treeview'
data
-
id
=
'filePanelFileExplorerTree'
>
<
div
className
=
'pl-2 remixui_treeview'
data
-
id
=
'filePanelFileExplorerTree'
>
...
@@ -109,6 +115,7 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -109,6 +115,7 @@ module.exports = class Filepanel extends ViewPlugin {
filesProvider
=
{
this
.
_deps
.
fileProviders
.
browser
}
filesProvider
=
{
this
.
_deps
.
fileProviders
.
browser
}
menuItems
=
{[
'createNewFile'
,
'createNewFolder'
,
'publishToGist'
,
canUpload
?
'uploadFile'
:
''
]}
menuItems
=
{[
'createNewFile'
,
'createNewFolder'
,
'publishToGist'
,
canUpload
?
'uploadFile'
:
''
]}
plugin
=
{
this
}
plugin
=
{
this
}
focusRoot
=
{
this
.
reset
}
/
>
/
>
<
/div
>
<
/div
>
<
div
className
=
'pl-2 filesystemexplorer remixui_treeview'
>
<
div
className
=
'pl-2 filesystemexplorer remixui_treeview'
>
...
@@ -119,6 +126,7 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -119,6 +126,7 @@ module.exports = class Filepanel extends ViewPlugin {
filesProvider
=
{
this
.
_deps
.
fileProviders
.
localhost
}
filesProvider
=
{
this
.
_deps
.
fileProviders
.
localhost
}
menuItems
=
{[
'createNewFile'
,
'createNewFolder'
]}
menuItems
=
{[
'createNewFile'
,
'createNewFolder'
]}
plugin
=
{
this
}
plugin
=
{
this
}
focusRoot
=
{
this
.
reset
}
/
>
/
>
}
}
<
/div
>
<
/div
>
...
...
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
2af196bb
...
@@ -16,7 +16,7 @@ import './css/file-explorer.css'
...
@@ -16,7 +16,7 @@ import './css/file-explorer.css'
const
queryParams
=
new
QueryParams
()
const
queryParams
=
new
QueryParams
()
export
const
FileExplorer
=
(
props
:
FileExplorerProps
)
=>
{
export
const
FileExplorer
=
(
props
:
FileExplorerProps
)
=>
{
const
{
filesProvider
,
name
,
registry
,
plugin
}
=
props
const
{
filesProvider
,
name
,
registry
,
plugin
,
focusRoot
}
=
props
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
focusElement
:
[{
focusElement
:
[{
key
:
name
,
key
:
name
,
...
@@ -156,6 +156,15 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -156,6 +156,15 @@ export const FileExplorer = (props: FileExplorerProps) => {
filesProvider
.
event
.
register
(
'fileRenamed'
,
fileRenamed
)
filesProvider
.
event
.
register
(
'fileRenamed'
,
fileRenamed
)
},
[
state
.
files
])
},
[
state
.
files
])
useEffect
(()
=>
{
if
(
focusRoot
)
{
setState
(
prevState
=>
{
return
{
...
prevState
,
focusElement
:
[{
key
:
name
,
type
:
'folder'
}]
}
})
plugin
.
resetFocus
(
false
)
}
},
[
focusRoot
])
const
resolveDirectory
=
async
(
folderPath
,
dir
:
File
[],
isChild
=
false
):
Promise
<
File
[]
>
=>
{
const
resolveDirectory
=
async
(
folderPath
,
dir
:
File
[],
isChild
=
false
):
Promise
<
File
[]
>
=>
{
if
(
!
isChild
&&
(
state
.
focusEdit
.
element
===
'browser/blank'
)
&&
state
.
focusEdit
.
isNew
&&
(
dir
.
findIndex
(({
path
})
=>
path
===
'browser/blank'
)
===
-
1
))
{
if
(
!
isChild
&&
(
state
.
focusEdit
.
element
===
'browser/blank'
)
&&
state
.
focusEdit
.
isNew
&&
(
dir
.
findIndex
(({
path
})
=>
path
===
'browser/blank'
)
===
-
1
))
{
dir
=
state
.
focusEdit
.
type
===
'file'
?
[...
dir
,
{
dir
=
state
.
focusEdit
.
type
===
'file'
?
[...
dir
,
{
...
@@ -287,7 +296,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -287,7 +296,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const
isDir
=
state
.
fileManager
.
isDirectory
(
path
)
const
isDir
=
state
.
fileManager
.
isDirectory
(
path
)
modal
(
'Delete file'
,
`Are you sure you want to delete
${
path
}
${
isDir
?
'folder'
:
'file'
}
?`
,
{
modal
(
`Delete
${
isDir
?
'folder'
:
'file'
}
`
,
`Are you sure you want to delete
${
path
}
${
isDir
?
'folder'
:
'file'
}
?`
,
{
label
:
'Ok'
,
label
:
'Ok'
,
fn
:
async
()
=>
{
fn
:
async
()
=>
{
try
{
try
{
...
@@ -295,7 +304,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -295,7 +304,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
await
fileManager
.
remove
(
path
)
await
fileManager
.
remove
(
path
)
}
catch
(
e
)
{
}
catch
(
e
)
{
toast
(
`Failed to remove
file
${
path
}
.`
)
toast
(
`Failed to remove
${
isDir
?
'folder'
:
'file'
}
${
path
}
.`
)
}
}
}
}
},
{
},
{
...
@@ -684,6 +693,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -684,6 +693,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const
editModeOff
=
async
(
content
:
string
)
=>
{
const
editModeOff
=
async
(
content
:
string
)
=>
{
if
(
typeof
content
===
'string'
)
content
=
content
.
trim
()
const
parentFolder
=
extractParentFromKey
(
state
.
focusEdit
.
element
)
const
parentFolder
=
extractParentFromKey
(
state
.
focusEdit
.
element
)
if
(
!
content
||
(
content
.
trim
()
===
''
))
{
if
(
!
content
||
(
content
.
trim
()
===
''
))
{
...
@@ -702,6 +712,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -702,6 +712,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
}
else
{
}
else
{
if
(
state
.
focusEdit
.
lastEdit
===
content
)
{
if
(
state
.
focusEdit
.
lastEdit
===
content
)
{
editRef
.
current
.
textContent
=
content
return
setState
(
prevState
=>
{
return
setState
(
prevState
=>
{
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
})
})
...
@@ -827,7 +838,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -827,7 +838,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
createNewFolder=
{
handleNewFolderInput
}
createNewFolder=
{
handleNewFolderInput
}
deletePath=
{
deletePath
}
deletePath=
{
deletePath
}
renamePath=
{
editModeOn
}
renamePath=
{
editModeOn
}
extractParentFromKey=
{
extractParentFromKey
}
publishToGist=
{
publishToGist
}
publishToGist=
{
publishToGist
}
pageX=
{
state
.
focusContext
.
x
}
pageX=
{
state
.
focusContext
.
x
}
pageY=
{
state
.
focusContext
.
y
}
pageY=
{
state
.
focusContext
.
y
}
...
...
libs/remix-ui/file-explorer/src/lib/types/index.ts
View file @
2af196bb
...
@@ -4,7 +4,8 @@ export interface FileExplorerProps {
...
@@ -4,7 +4,8 @@ export interface FileExplorerProps {
registry
:
any
,
registry
:
any
,
filesProvider
:
any
,
filesProvider
:
any
,
menuItems
?:
string
[],
menuItems
?:
string
[],
plugin
:
any
plugin
:
any
,
focusRoot
:
boolean
}
}
export
interface
File
{
export
interface
File
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment