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
0a5c9de9
Commit
0a5c9de9
authored
Dec 15, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show directory content for new input
parent
e07b38f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+21
-8
No files found.
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
0a5c9de9
...
@@ -33,7 +33,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -33,7 +33,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
type
:
''
,
type
:
''
,
isNew
:
false
isNew
:
false
},
},
fileExternallyChanged
:
false
fileExternallyChanged
:
false
,
expandPath
:
[]
})
})
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -427,9 +428,16 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -427,9 +428,16 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
}
else
{
}
else
{
const
files
=
await
resolveDirectory
(
path
,
state
.
files
)
const
files
=
await
resolveDirectory
(
path
,
state
.
files
)
let
expandPath
=
[]
if
(
!
state
.
expandPath
.
includes
(
path
))
{
expandPath
=
[...
state
.
expandPath
,
path
]
}
else
{
expandPath
=
state
.
expandPath
.
filter
(
key
=>
key
!==
path
)
}
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
focusElement
:
[{
key
:
path
,
type
:
'folder'
}],
files
}
return
{
...
prevState
,
focusElement
:
[{
key
:
path
,
type
:
'folder'
}],
files
,
expandPath
}
})
})
}
}
}
}
...
@@ -506,23 +514,27 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -506,23 +514,27 @@ export const FileExplorer = (props: FileExplorerProps) => {
})
})
}
}
const
handleNewFileInput
=
(
parentFolder
?:
string
)
=>
{
const
handleNewFileInput
=
async
(
parentFolder
?:
string
)
=>
{
if
(
!
parentFolder
)
parentFolder
=
state
.
focusElement
[
0
]
?
state
.
focusElement
[
0
].
type
===
'folder'
?
state
.
focusElement
[
0
].
key
:
extractParentFromKey
(
state
.
focusElement
[
0
].
key
)
:
name
if
(
!
parentFolder
)
parentFolder
=
state
.
focusElement
[
0
]
?
state
.
focusElement
[
0
].
type
===
'folder'
?
state
.
focusElement
[
0
].
key
:
extractParentFromKey
(
state
.
focusElement
[
0
].
key
)
:
name
const
files
=
addEmptyFile
(
parentFolder
,
state
.
files
)
let
files
=
await
resolveDirectory
(
parentFolder
,
state
.
files
)
const
expandPath
=
[...
state
.
expandPath
,
parentFolder
]
files
=
addEmptyFile
(
parentFolder
,
files
)
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
files
}
return
{
...
prevState
,
files
,
expandPath
}
})
})
editModeOn
(
parentFolder
+
'/blank'
,
'file'
,
true
)
editModeOn
(
parentFolder
+
'/blank'
,
'file'
,
true
)
}
}
const
handleNewFolderInput
=
(
parentFolder
?:
string
)
=>
{
const
handleNewFolderInput
=
async
(
parentFolder
?:
string
)
=>
{
if
(
!
parentFolder
)
parentFolder
=
state
.
focusElement
[
0
]
?
state
.
focusElement
[
0
].
type
===
'folder'
?
state
.
focusElement
[
0
].
key
:
extractParentFromKey
(
state
.
focusElement
[
0
].
key
)
:
name
if
(
!
parentFolder
)
parentFolder
=
state
.
focusElement
[
0
]
?
state
.
focusElement
[
0
].
type
===
'folder'
?
state
.
focusElement
[
0
].
key
:
extractParentFromKey
(
state
.
focusElement
[
0
].
key
)
:
name
else
if
(
parentFolder
.
indexOf
(
'.sol'
)
!==
-
1
)
parentFolder
=
extractParentFromKey
(
parentFolder
)
else
if
(
parentFolder
.
indexOf
(
'.sol'
)
!==
-
1
)
parentFolder
=
extractParentFromKey
(
parentFolder
)
const
files
=
addEmptyFolder
(
parentFolder
,
state
.
files
)
let
files
=
await
resolveDirectory
(
parentFolder
,
state
.
files
)
const
expandPath
=
[...
state
.
expandPath
,
parentFolder
]
files
=
addEmptyFolder
(
parentFolder
,
state
.
files
)
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
files
}
return
{
...
prevState
,
files
,
expandPath
}
})
})
editModeOn
(
parentFolder
+
'/blank'
,
'folder'
,
true
)
editModeOn
(
parentFolder
+
'/blank'
,
'folder'
,
true
)
}
}
...
@@ -569,6 +581,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -569,6 +581,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
editable=
{
state
.
focusEdit
.
element
===
file
.
path
}
editable=
{
state
.
focusEdit
.
element
===
file
.
path
}
onBlur=
{
(
value
)
=>
editModeOff
(
value
)
}
onBlur=
{
(
value
)
=>
editModeOff
(
value
)
}
controlBehaviour=
{
state
.
ctrlKey
}
controlBehaviour=
{
state
.
ctrlKey
}
expand=
{
state
.
expandPath
.
includes
(
file
.
path
)
}
>
>
{
{
file
.
child
?
<
TreeView
id=
{
`treeView${file.path}`
}
key=
{
index
}
>
{
file
.
child
?
<
TreeView
id=
{
`treeView${file.path}`
}
key=
{
index
}
>
{
...
...
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