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
8f2ea70e
Commit
8f2ea70e
authored
Dec 20, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert rename if empty
parent
a64cc67a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
36 deletions
+51
-36
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+47
-15
tree-view-item.tsx
...ix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx
+4
-20
index.ts
libs/remix-ui/tree-view/src/types/index.ts
+0
-1
No files found.
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
8f2ea70e
...
@@ -51,6 +51,11 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -51,6 +51,11 @@ export const FileExplorer = (props: FileExplorerProps) => {
handleHide
:
null
handleHide
:
null
}
}
})
})
const
editRef
=
useRef
(
null
)
useEffect
(()
=>
{
editRef
&&
editRef
.
current
&&
editRef
.
current
.
focus
()
},
[
state
.
focusEdit
.
element
])
useEffect
(()
=>
{
useEffect
(()
=>
{
(
async
()
=>
{
(
async
()
=>
{
...
@@ -165,8 +170,12 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -165,8 +170,12 @@ export const FileExplorer = (props: FileExplorerProps) => {
const
fileManager
=
state
.
fileManager
const
fileManager
=
state
.
fileManager
helper
.
createNonClashingName
(
newFilePath
,
filesProvider
,
async
(
error
,
newName
)
=>
{
helper
.
createNonClashingName
(
newFilePath
,
filesProvider
,
async
(
error
,
newName
)
=>
{
// if (error) return tooltip('Failed to create file ' + newName + ' ' + error)
if
(
error
)
{
if
(
error
)
return
return
modal
(
'Create File Failed'
,
error
,
{
label
:
'Close'
,
fn
:
async
()
=>
{}
},
null
)
}
else
{
const
createFile
=
await
fileManager
.
writeFile
(
newName
,
''
)
const
createFile
=
await
fileManager
.
writeFile
(
newName
,
''
)
if
(
!
createFile
)
{
if
(
!
createFile
)
{
...
@@ -175,6 +184,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -175,6 +184,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
addFile
(
parentFolder
,
newName
)
addFile
(
parentFolder
,
newName
)
await
fileManager
.
open
(
newName
)
await
fileManager
.
open
(
newName
)
}
}
}
})
})
// }, null, true)
// }, null, true)
}
}
...
@@ -227,8 +237,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -227,8 +237,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
const
exists
=
fileManager
.
exists
(
newPath
)
const
exists
=
fileManager
.
exists
(
newPath
)
if
(
exists
)
{
if
(
exists
)
{
return
modal
(
'
Create File Failed'
,
'Fil
e already exists'
,
{
return
modal
(
'
Rename File Failed'
,
'File nam
e already exists'
,
{
label
:
'
Ok
'
,
label
:
'
Close
'
,
fn
:
async
()
=>
{}
fn
:
async
()
=>
{}
},
null
)
},
null
)
}
else
{
}
else
{
...
@@ -240,7 +250,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -240,7 +250,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
})
})
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
// modalDialogCustom.alert('Unexpected error while renaming: ' + error)
modal
(
'Rename File Failed'
,
'Unexpected error while renaming: '
+
error
,
{
label
:
'Close'
,
fn
:
async
()
=>
{}
},
null
)
}
}
}
}
...
@@ -589,11 +602,17 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -589,11 +602,17 @@ export const FileExplorer = (props: FileExplorerProps) => {
return
{
...
prevState
,
files
:
updatedFiles
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
return
{
...
prevState
,
files
:
updatedFiles
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
})
})
}
else
{
}
else
{
editRef
.
current
.
textContent
=
state
.
focusEdit
.
lastEdit
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
})
})
}
}
}
else
{
}
else
{
if
(
state
.
focusEdit
.
lastEdit
===
content
)
{
return
setState
(
prevState
=>
{
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
})
}
if
(
helper
.
checkSpecialChars
(
content
))
{
if
(
helper
.
checkSpecialChars
(
content
))
{
modal
(
'Validation Error'
,
'Special characters are not allowed'
,
{
modal
(
'Validation Error'
,
'Special characters are not allowed'
,
{
label
:
'Ok'
,
label
:
'Ok'
,
...
@@ -647,20 +666,37 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -647,20 +666,37 @@ export const FileExplorer = (props: FileExplorerProps) => {
editModeOn
(
parentFolder
+
'/blank'
,
'folder'
,
true
)
editModeOn
(
parentFolder
+
'/blank'
,
'folder'
,
true
)
}
}
const
handleEditInput
=
(
event
)
=>
{
if
(
event
.
which
===
13
)
{
event
.
preventDefault
()
editModeOff
(
editRef
.
current
.
innerText
)
}
}
// warn if file changed outside of Remix
// warn if file changed outside of Remix
const
remixdDialog
=
()
=>
{
const
remixdDialog
=
()
=>
{
return
<
div
>
This file has been changed outside of Remix IDE.
</
div
>
return
<
div
>
This file has been changed outside of Remix IDE.
</
div
>
}
}
const
label
=
(
data
:
File
)
=>
{
const
label
=
(
file
:
File
)
=>
{
return
(
return
(
<
div
className=
'remixui_items'
>
<
div
className=
'remixui_items d-inline-block w-100'
ref=
{
state
.
focusEdit
.
element
===
file
.
path
?
editRef
:
null
}
suppressContentEditableWarning=
{
true
}
contentEditable=
{
state
.
focusEdit
.
element
===
file
.
path
}
onKeyDown=
{
handleEditInput
}
onBlur=
{
(
e
)
=>
{
e
.
stopPropagation
()
editModeOff
(
editRef
.
current
.
innerText
)
}
}
>
<
span
<
span
title=
{
data
.
path
}
title=
{
file
.
path
}
className=
{
'remixui_label '
+
(
data
.
isDirectory
?
'folder'
:
'remixui_leaf'
)
}
className=
{
'remixui_label '
+
(
file
.
isDirectory
?
'folder'
:
'remixui_leaf'
)
}
data
-
path=
{
data
.
path
}
data
-
path=
{
file
.
path
}
>
>
{
data
.
name
}
{
file
.
name
}
</
span
>
</
span
>
</
div
>
</
div
>
)
)
...
@@ -686,8 +722,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -686,8 +722,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
handleContextMenuFolder
(
e
.
pageX
,
e
.
pageY
,
file
.
path
,
e
.
target
.
textContent
)
handleContextMenuFolder
(
e
.
pageX
,
e
.
pageY
,
file
.
path
,
e
.
target
.
textContent
)
}
}
}
}
labelClass=
{
state
.
focusEdit
.
element
===
file
.
path
?
'bg-light'
:
state
.
focusElement
.
findIndex
(
item
=>
item
.
key
===
file
.
path
)
!==
-
1
?
'bg-secondary'
:
''
}
labelClass=
{
state
.
focusEdit
.
element
===
file
.
path
?
'bg-light'
:
state
.
focusElement
.
findIndex
(
item
=>
item
.
key
===
file
.
path
)
!==
-
1
?
'bg-secondary'
:
''
}
editable=
{
state
.
focusEdit
.
element
===
file
.
path
}
onBlur=
{
(
value
)
=>
editModeOff
(
value
)
}
controlBehaviour=
{
state
.
ctrlKey
}
controlBehaviour=
{
state
.
ctrlKey
}
expand=
{
state
.
expandPath
.
includes
(
file
.
path
)
}
expand=
{
state
.
expandPath
.
includes
(
file
.
path
)
}
>
>
...
@@ -734,8 +768,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -734,8 +768,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
}
}
icon=
'fa fa-file'
icon=
'fa fa-file'
labelClass=
{
state
.
focusEdit
.
element
===
file
.
path
?
'bg-light'
:
state
.
focusElement
.
findIndex
(
item
=>
item
.
key
===
file
.
path
)
!==
-
1
?
'bg-secondary'
:
''
}
labelClass=
{
state
.
focusEdit
.
element
===
file
.
path
?
'bg-light'
:
state
.
focusElement
.
findIndex
(
item
=>
item
.
key
===
file
.
path
)
!==
-
1
?
'bg-secondary'
:
''
}
editable=
{
state
.
focusEdit
.
element
===
file
.
path
}
onBlur=
{
(
value
)
=>
editModeOff
(
value
)
}
/>
/>
{
((
state
.
focusContext
.
element
===
file
.
path
)
&&
(
state
.
focusEdit
.
element
!==
file
.
path
))
&&
{
((
state
.
focusContext
.
element
===
file
.
path
)
&&
(
state
.
focusEdit
.
element
!==
file
.
path
))
&&
<
FileExplorerContextMenu
<
FileExplorerContextMenu
...
...
libs/remix-ui/tree-view/src/lib/tree-view-item/tree-view-item.tsx
View file @
8f2ea70e
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
// eslint-disable-line
import
React
,
{
useState
,
useEffect
}
from
'react'
// eslint-disable-line
import
{
TreeViewItemProps
}
from
'../../types'
import
{
TreeViewItemProps
}
from
'../../types'
import
'./tree-view-item.css'
import
'./tree-view-item.css'
export
const
TreeViewItem
=
(
props
:
TreeViewItemProps
)
=>
{
export
const
TreeViewItem
=
(
props
:
TreeViewItemProps
)
=>
{
const
{
id
,
children
,
label
,
labelClass
,
expand
,
iconX
=
'fas fa-caret-right'
,
iconY
=
'fas fa-caret-down'
,
icon
,
controlBehaviour
=
false
,
innerRef
,
editable
,
onBlur
,
...
otherProps
}
=
props
const
{
id
,
children
,
label
,
labelClass
,
expand
,
iconX
=
'fas fa-caret-right'
,
iconY
=
'fas fa-caret-down'
,
icon
,
controlBehaviour
=
false
,
innerRef
,
...
otherProps
}
=
props
const
[
isExpanded
,
setIsExpanded
]
=
useState
(
false
)
const
[
isExpanded
,
setIsExpanded
]
=
useState
(
false
)
const
contentRef
=
useRef
(
null
)
useEffect
(()
=>
{
useEffect
(()
=>
{
setIsExpanded
(
expand
)
setIsExpanded
(
expand
)
},
[
expand
])
},
[
expand
])
useEffect
(()
=>
{
if
(
editable
)
{
contentRef
.
current
.
focus
()
}
},
[
editable
])
const
handleInput
=
(
event
)
=>
{
if
(
editable
)
{
if
(
event
.
which
===
13
)
{
event
.
preventDefault
()
onBlur
&&
onBlur
(
contentRef
.
current
.
innerText
)
}
}
}
return
(
return
(
<
li
ref=
{
innerRef
}
key=
{
`treeViewLi${id}`
}
data
-
id=
{
`treeViewLi${id}`
}
className=
'li_tv'
onBlur=
{
()
=>
editable
&&
onBlur
(
contentRef
.
current
.
innerText
)
}
{
...
otherProps
}
>
<
li
ref=
{
innerRef
}
key=
{
`treeViewLi${id}`
}
data
-
id=
{
`treeViewLi${id}`
}
className=
'li_tv'
{
...
otherProps
}
>
<
div
key=
{
`treeViewDiv${id}`
}
data
-
id=
{
`treeViewDiv${id}`
}
className=
{
`d-flex flex-row align-items-center ${labelClass}`
}
onClick=
{
()
=>
!
controlBehaviour
&&
setIsExpanded
(
!
isExpanded
)
}
>
<
div
key=
{
`treeViewDiv${id}`
}
data
-
id=
{
`treeViewDiv${id}`
}
className=
{
`d-flex flex-row align-items-center ${labelClass}`
}
onClick=
{
()
=>
!
controlBehaviour
&&
setIsExpanded
(
!
isExpanded
)
}
>
{
children
?
<
div
className=
{
isExpanded
?
`px-1 ${iconY} caret caret_tv`
:
`px-1 ${iconX} caret caret_tv`
}
style=
{
{
visibility
:
children
?
'visible'
:
'hidden'
}
}
></
div
>
:
icon
?
<
div
className=
{
`pr-3 pl-1 ${icon} caret caret_tv`
}
></
div
>
:
null
}
{
children
?
<
div
className=
{
isExpanded
?
`px-1 ${iconY} caret caret_tv`
:
`px-1 ${iconX} caret caret_tv`
}
style=
{
{
visibility
:
children
?
'visible'
:
'hidden'
}
}
></
div
>
:
icon
?
<
div
className=
{
`pr-3 pl-1 ${icon} caret caret_tv`
}
></
div
>
:
null
}
<
span
className=
'w-100 pl-1'
ref=
{
contentRef
}
suppressContentEditableWarning=
{
true
}
contentEditable=
{
editable
}
tabIndex=
{
editable
?
-
3
:
null
}
onKeyDown=
{
handleInput
}
>
<
span
className=
'w-100 pl-1'
>
{
label
}
{
label
}
</
span
>
</
span
>
</
div
>
</
div
>
...
...
libs/remix-ui/tree-view/src/types/index.ts
View file @
8f2ea70e
...
@@ -18,6 +18,5 @@ export interface TreeViewItemProps {
...
@@ -18,6 +18,5 @@ export interface TreeViewItemProps {
controlBehaviour
?:
boolean
controlBehaviour
?:
boolean
innerRef
?:
any
,
innerRef
?:
any
,
onContextMenu
?:
(...
args
:
any
)
=>
void
,
onContextMenu
?:
(...
args
:
any
)
=>
void
,
editable
?:
boolean
,
onBlur
?:
(...
args
:
any
)
=>
void
onBlur
?:
(...
args
:
any
)
=>
void
}
}
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