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
a992221f
Commit
a992221f
authored
Sep 29, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bugs associated to remixd test failing
parent
dc1f9d06
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
102 deletions
+61
-102
remixd.test.ts
apps/remix-ide-e2e/src/tests/remixd.test.ts
+0
-1
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+3
-0
tab-proxy.js
apps/remix-ide/src/app/panels/tab-proxy.js
+19
-6
remix-ui-helper.ts
libs/remix-ui/helper/src/lib/remix-ui-helper.ts
+1
-0
events.ts
libs/remix-ui/workspace/src/lib/actions/events.ts
+20
-82
file-explorer.tsx
libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
+2
-4
file-label.tsx
libs/remix-ui/workspace/src/lib/components/file-label.tsx
+2
-7
workspace.ts
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
+14
-2
No files found.
apps/remix-ide-e2e/src/tests/remixd.test.ts
View file @
a992221f
...
@@ -153,7 +153,6 @@ function runTests (browser: NightwatchBrowser) {
...
@@ -153,7 +153,6 @@ function runTests (browser: NightwatchBrowser) {
.
clickLaunchIcon
(
'filePanel'
)
.
clickLaunchIcon
(
'filePanel'
)
.
waitForElementVisible
(
'[data-path="folder1"]'
)
.
waitForElementVisible
(
'[data-path="folder1"]'
)
.
click
(
'[data-path="folder1"]'
)
.
click
(
'[data-path="folder1"]'
)
.
click
(
'[data-path="folder1"]'
)
// click twice because remixd does not return nested folder details after update
.
waitForElementVisible
(
'[data-path="folder1/contract1.sol"]'
)
.
waitForElementVisible
(
'[data-path="folder1/contract1.sol"]'
)
.
waitForElementVisible
(
'[data-path="folder1/renamed_contract_'
+
browserName
+
'.sol"]'
)
// check if renamed file is preset
.
waitForElementVisible
(
'[data-path="folder1/renamed_contract_'
+
browserName
+
'.sol"]'
)
// check if renamed file is preset
.
waitForElementNotPresent
(
'[data-path="folder1/contract_'
+
browserName
+
'.sol"]'
)
// check if renamed (old) file is not present
.
waitForElementNotPresent
(
'[data-path="folder1/contract_'
+
browserName
+
'.sol"]'
)
// check if renamed (old) file is not present
...
...
apps/remix-ide/src/app/files/fileManager.js
View file @
a992221f
...
@@ -469,6 +469,7 @@ class FileManager extends Plugin {
...
@@ -469,6 +469,7 @@ class FileManager extends Plugin {
}
}
closeFile
(
name
)
{
closeFile
(
name
)
{
return
new
Promise
((
resolve
)
=>
{
delete
this
.
openedFiles
[
name
]
delete
this
.
openedFiles
[
name
]
if
(
!
Object
.
keys
(
this
.
openedFiles
).
length
)
{
if
(
!
Object
.
keys
(
this
.
openedFiles
).
length
)
{
this
.
_deps
.
config
.
set
(
'currentFile'
,
''
)
this
.
_deps
.
config
.
set
(
'currentFile'
,
''
)
...
@@ -479,6 +480,8 @@ class FileManager extends Plugin {
...
@@ -479,6 +480,8 @@ class FileManager extends Plugin {
// TODO: Only keep `this.emit` (issue#2210)
// TODO: Only keep `this.emit` (issue#2210)
this
.
emit
(
'fileClosed'
,
name
)
this
.
emit
(
'fileClosed'
,
name
)
this
.
events
.
emit
(
'fileClosed'
,
name
)
this
.
events
.
emit
(
'fileClosed'
,
name
)
resolve
(
true
)
})
}
}
currentPath
()
{
currentPath
()
{
...
...
apps/remix-ide/src/app/panels/tab-proxy.js
View file @
a992221f
...
@@ -44,19 +44,32 @@ export class TabProxy extends Plugin {
...
@@ -44,19 +44,32 @@ export class TabProxy extends Plugin {
fileManager
.
events
.
on
(
'fileRemoved'
,
(
name
)
=>
{
fileManager
.
events
.
on
(
'fileRemoved'
,
(
name
)
=>
{
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
workspace
?
this
.
removeTab
(
workspace
+
'/'
+
name
)
:
this
.
removeTab
(
this
.
fileManager
.
mode
+
'/'
+
name
)
if
(
this
.
fileManager
.
mode
===
'browser'
)
{
name
=
name
.
startsWith
(
workspace
+
'/'
)
?
name
:
workspace
+
'/'
+
name
this
.
removeTab
(
name
)
}
else
{
name
=
name
.
startsWith
(
this
.
fileManager
.
mode
+
'/'
)
?
name
:
this
.
fileManager
.
mode
+
'/'
+
name
this
.
removeTab
(
name
)
}
})
})
fileManager
.
events
.
on
(
'fileClosed'
,
(
name
)
=>
{
fileManager
.
events
.
on
(
'fileClosed'
,
(
name
)
=>
{
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
workspace
?
this
.
removeTab
(
workspace
+
'/'
+
name
)
:
this
.
removeTab
(
this
.
fileManager
.
mode
+
'/'
+
name
)
if
(
this
.
fileManager
.
mode
===
'browser'
)
{
name
=
name
.
startsWith
(
workspace
+
'/'
)
?
name
:
workspace
+
'/'
+
name
this
.
removeTab
(
name
)
}
else
{
name
=
name
.
startsWith
(
this
.
fileManager
.
mode
+
'/'
)
?
name
:
this
.
fileManager
.
mode
+
'/'
+
name
this
.
removeTab
(
name
)
}
})
})
fileManager
.
events
.
on
(
'currentFileChanged'
,
(
file
)
=>
{
fileManager
.
events
.
on
(
'currentFileChanged'
,
(
file
)
=>
{
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
if
(
workspace
)
{
if
(
this
.
fileManager
.
mode
===
'browser'
)
{
const
workspacePath
=
workspace
+
'/'
+
file
const
workspacePath
=
workspace
+
'/'
+
file
if
(
this
.
_handlers
[
workspacePath
])
{
if
(
this
.
_handlers
[
workspacePath
])
{
...
@@ -72,7 +85,7 @@ export class TabProxy extends Plugin {
...
@@ -72,7 +85,7 @@ export class TabProxy extends Plugin {
this
.
event
.
emit
(
'closeFile'
,
file
)
this
.
event
.
emit
(
'closeFile'
,
file
)
})
})
}
else
{
}
else
{
const
path
=
this
.
fileManager
.
mode
+
'/'
+
file
const
path
=
file
.
startsWith
(
this
.
fileManager
.
mode
+
'/'
)
?
file
:
this
.
fileManager
.
mode
+
'/'
+
file
if
(
this
.
_handlers
[
path
])
{
if
(
this
.
_handlers
[
path
])
{
this
.
_view
.
filetabs
.
activateTab
(
path
)
this
.
_view
.
filetabs
.
activateTab
(
path
)
...
@@ -92,7 +105,7 @@ export class TabProxy extends Plugin {
...
@@ -92,7 +105,7 @@ export class TabProxy extends Plugin {
fileManager
.
events
.
on
(
'fileRenamed'
,
(
oldName
,
newName
,
isFolder
)
=>
{
fileManager
.
events
.
on
(
'fileRenamed'
,
(
oldName
,
newName
,
isFolder
)
=>
{
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
const
workspace
=
this
.
fileManager
.
currentWorkspace
()
if
(
workspace
)
{
if
(
this
.
fileManager
.
mode
===
'browser'
)
{
if
(
isFolder
)
{
if
(
isFolder
)
{
for
(
const
tab
of
this
.
loadedTabs
)
{
for
(
const
tab
of
this
.
loadedTabs
)
{
if
(
tab
.
name
.
indexOf
(
workspace
+
'/'
+
oldName
+
'/'
)
===
0
)
{
if
(
tab
.
name
.
indexOf
(
workspace
+
'/'
+
oldName
+
'/'
)
===
0
)
{
...
@@ -115,7 +128,7 @@ export class TabProxy extends Plugin {
...
@@ -115,7 +128,7 @@ export class TabProxy extends Plugin {
return
return
}
}
// should change the tab title too
// should change the tab title too
this
.
renameTab
(
this
.
fileManager
.
mode
+
'/'
+
oldName
,
workspac
e
+
'/'
+
newName
)
this
.
renameTab
(
this
.
fileManager
.
mode
+
'/'
+
oldName
,
this
.
fileManager
.
mod
e
+
'/'
+
newName
)
}
}
})
})
...
...
libs/remix-ui/helper/src/lib/remix-ui-helper.ts
View file @
a992221f
export
const
extractNameFromKey
=
(
key
:
string
):
string
=>
{
export
const
extractNameFromKey
=
(
key
:
string
):
string
=>
{
if
(
!
key
)
return
const
keyPath
=
key
.
split
(
'/'
)
const
keyPath
=
key
.
split
(
'/'
)
return
keyPath
[
keyPath
.
length
-
1
]
return
keyPath
[
keyPath
.
length
-
1
]
...
...
libs/remix-ui/workspace/src/lib/actions/events.ts
View file @
a992221f
...
@@ -4,8 +4,6 @@ import { action } from '../types'
...
@@ -4,8 +4,6 @@ import { action } from '../types'
import
{
displayNotification
,
displayPopUp
,
fileAddedSuccess
,
fileRemovedSuccess
,
fileRenamedSuccess
,
folderAddedSuccess
,
loadLocalhostError
,
loadLocalhostRequest
,
loadLocalhostSuccess
,
removeContextMenuItem
,
rootFolderChangedSuccess
,
setContextMenuItem
,
setMode
,
setReadOnlyMode
}
from
'./payload'
import
{
displayNotification
,
displayPopUp
,
fileAddedSuccess
,
fileRemovedSuccess
,
fileRenamedSuccess
,
folderAddedSuccess
,
loadLocalhostError
,
loadLocalhostRequest
,
loadLocalhostSuccess
,
removeContextMenuItem
,
rootFolderChangedSuccess
,
setContextMenuItem
,
setMode
,
setReadOnlyMode
}
from
'./payload'
import
{
addInputField
,
createWorkspace
,
fetchWorkspaceDirectory
,
renameWorkspace
,
switchToWorkspace
,
uploadFile
}
from
'./workspace'
import
{
addInputField
,
createWorkspace
,
fetchWorkspaceDirectory
,
renameWorkspace
,
switchToWorkspace
,
uploadFile
}
from
'./workspace'
const
queuedEvents
=
[]
const
pendingEvents
=
{}
const
LOCALHOST
=
' - connect to localhost - '
const
LOCALHOST
=
' - connect to localhost - '
let
plugin
,
dispatch
:
React
.
Dispatch
<
any
>
let
plugin
,
dispatch
:
React
.
Dispatch
<
any
>
...
@@ -37,52 +35,59 @@ export const listenOnPluginEvents = (filePanelPlugin) => {
...
@@ -37,52 +35,59 @@ export const listenOnPluginEvents = (filePanelPlugin) => {
})
})
plugin
.
on
(
'remixd'
,
'rootFolderChanged'
,
async
(
path
:
string
)
=>
{
plugin
.
on
(
'remixd'
,
'rootFolderChanged'
,
async
(
path
:
string
)
=>
{
await
executeEvent
(
'rootFolderChanged'
,
path
)
setTimeout
(()
=>
rootFolderChanged
(
path
),
0
)
})
})
}
}
export
const
listenOnProviderEvents
=
(
provider
)
=>
async
(
reducerDispatch
:
React
.
Dispatch
<
any
>
)
=>
{
export
const
listenOnProviderEvents
=
(
provider
)
=>
async
(
reducerDispatch
:
React
.
Dispatch
<
any
>
)
=>
{
dispatch
=
reducerDispatch
dispatch
=
reducerDispatch
provider
.
event
.
on
(
'fileAdded'
,
async
(
filePath
:
string
)
=>
{
provider
.
event
.
on
(
'fileAdded'
,
(
filePath
:
string
)
=>
{
await
executeEvent
(
'fileAdded'
,
filePath
)
setTimeout
(()
=>
fileAdded
(
filePath
),
0
)
})
})
provider
.
event
.
on
(
'folderAdded'
,
async
(
folderPath
:
string
)
=>
{
provider
.
event
.
on
(
'folderAdded'
,
(
folderPath
:
string
)
=>
{
if
(
folderPath
.
indexOf
(
'/.workspaces'
)
===
0
)
return
if
(
folderPath
.
indexOf
(
'/.workspaces'
)
===
0
)
return
await
executeEvent
(
'folderAdded'
,
folderPath
)
setTimeout
(()
=>
folderAdded
(
folderPath
),
0
)
})
})
provider
.
event
.
on
(
'fileRemoved'
,
async
(
removePath
:
string
)
=>
{
provider
.
event
.
on
(
'fileRemoved'
,
(
removePath
:
string
)
=>
{
await
executeEvent
(
'fileRemoved'
,
removePath
)
setTimeout
(()
=>
fileRemoved
(
removePath
),
0
)
})
})
provider
.
event
.
on
(
'fileRenamed'
,
async
(
oldPath
:
string
,
new
Path
:
string
)
=>
{
provider
.
event
.
on
(
'fileRenamed'
,
(
old
Path
:
string
)
=>
{
await
executeEvent
(
'fileRenamed'
,
oldPath
,
newPath
)
setTimeout
(()
=>
fileRenamed
(
oldPath
),
0
)
})
})
provider
.
event
.
on
(
'disconnected'
,
async
()
=>
{
provider
.
event
.
on
(
'disconnected'
,
()
=>
{
setTimeout
(
async
()
=>
{
plugin
.
fileManager
.
setMode
(
'browser'
)
plugin
.
fileManager
.
setMode
(
'browser'
)
dispatch
(
setMode
(
'browser'
))
dispatch
(
setMode
(
'browser'
))
dispatch
(
loadLocalhostError
(
'Remixd disconnected!'
))
dispatch
(
loadLocalhostError
(
'Remixd disconnected!'
))
const
workspaceProvider
=
plugin
.
fileProviders
.
workspace
const
workspaceProvider
=
plugin
.
fileProviders
.
workspace
await
switchToWorkspace
(
workspaceProvider
.
workspace
)
await
switchToWorkspace
(
workspaceProvider
.
workspace
)
},
0
)
})
})
provider
.
event
.
on
(
'connected'
,
async
()
=>
{
provider
.
event
.
on
(
'connected'
,
async
()
=>
{
setTimeout
(()
=>
{
plugin
.
fileManager
.
setMode
(
'localhost'
)
plugin
.
fileManager
.
setMode
(
'localhost'
)
dispatch
(
setMode
(
'localhost'
))
dispatch
(
setMode
(
'localhost'
))
fetchWorkspaceDirectory
(
'/'
)
fetchWorkspaceDirectory
(
'/'
)
dispatch
(
loadLocalhostSuccess
())
dispatch
(
loadLocalhostSuccess
())
},
0
)
})
})
provider
.
event
.
on
(
'loadingLocalhost'
,
async
()
=>
{
provider
.
event
.
on
(
'loadingLocalhost'
,
async
()
=>
{
setTimeout
(
async
()
=>
{
await
switchToWorkspace
(
LOCALHOST
)
await
switchToWorkspace
(
LOCALHOST
)
dispatch
(
loadLocalhostRequest
())
dispatch
(
loadLocalhostRequest
())
},
0
)
})
})
provider
.
event
.
on
(
'fileExternallyChanged'
,
async
(
path
:
string
,
file
:
{
content
:
string
})
=>
{
provider
.
event
.
on
(
'fileExternallyChanged'
,
async
(
path
:
string
,
file
:
{
content
:
string
})
=>
{
setTimeout
(()
=>
{
const
config
=
plugin
.
registry
.
get
(
'config'
).
api
const
config
=
plugin
.
registry
.
get
(
'config'
).
api
const
editor
=
plugin
.
registry
.
get
(
'editor'
).
api
const
editor
=
plugin
.
registry
.
get
(
'editor'
).
api
...
@@ -97,14 +102,15 @@ export const listenOnProviderEvents = (provider) => async (reducerDispatch: Reac
...
@@ -97,14 +102,15 @@ export const listenOnProviderEvents = (provider) => async (reducerDispatch: Reac
}
}
))
))
}
}
},
0
)
})
})
provider
.
event
.
on
(
'fileRenamedError'
,
async
()
=>
{
provider
.
event
.
on
(
'fileRenamedError'
,
async
()
=>
{
dispatch
(
displayNotification
(
'File Renamed Failed'
,
''
,
'Ok'
,
'Cancel'
)
)
setTimeout
(()
=>
dispatch
(
displayNotification
(
'File Renamed Failed'
,
''
,
'Ok'
,
'Cancel'
)),
0
)
})
})
provider
.
event
.
on
(
'readOnlyModeChanged'
,
(
mode
:
boolean
)
=>
{
provider
.
event
.
on
(
'readOnlyModeChanged'
,
(
mode
:
boolean
)
=>
{
dispatch
(
setReadOnlyMode
(
mode
)
)
setTimeout
(()
=>
dispatch
(
setReadOnlyMode
(
mode
)),
0
)
})
})
}
}
...
@@ -172,71 +178,3 @@ const fileRenamed = async (oldPath: string) => {
...
@@ -172,71 +178,3 @@ const fileRenamed = async (oldPath: string) => {
const
rootFolderChanged
=
async
(
path
)
=>
{
const
rootFolderChanged
=
async
(
path
)
=>
{
await
dispatch
(
rootFolderChangedSuccess
(
path
))
await
dispatch
(
rootFolderChangedSuccess
(
path
))
}
}
const
executeEvent
=
async
(
eventName
:
'fileAdded'
|
'folderAdded'
|
'fileRemoved'
|
'fileRenamed'
|
'rootFolderChanged'
,
...
args
)
=>
{
if
(
Object
.
keys
(
pendingEvents
).
length
)
{
return
queuedEvents
.
push
({
eventName
,
path
:
args
[
0
]
})
}
pendingEvents
[
eventName
+
args
[
0
]]
=
{
eventName
,
path
:
args
[
0
]
}
switch
(
eventName
)
{
case
'fileAdded'
:
setTimeout
(()
=>
{
fileAdded
(
args
[
0
])
},
0
)
delete
pendingEvents
[
eventName
+
args
[
0
]]
if
(
queuedEvents
.
length
)
{
const
next
=
queuedEvents
.
pop
()
await
executeEvent
(
next
.
eventName
,
next
.
path
)
}
break
case
'folderAdded'
:
setTimeout
(()
=>
{
folderAdded
(
args
[
0
])
},
0
)
delete
pendingEvents
[
eventName
+
args
[
0
]]
if
(
queuedEvents
.
length
)
{
const
next
=
queuedEvents
.
pop
()
await
executeEvent
(
next
.
eventName
,
next
.
path
)
}
break
case
'fileRemoved'
:
setTimeout
(()
=>
{
fileRemoved
(
args
[
0
])
},
0
)
delete
pendingEvents
[
eventName
+
args
[
0
]]
if
(
queuedEvents
.
length
)
{
const
next
=
queuedEvents
.
pop
()
await
executeEvent
(
next
.
eventName
,
next
.
path
)
}
break
case
'fileRenamed'
:
setTimeout
(()
=>
{
fileRenamed
(
args
[
0
])
},
0
)
delete
pendingEvents
[
eventName
+
args
[
0
]]
if
(
queuedEvents
.
length
)
{
const
next
=
queuedEvents
.
pop
()
await
executeEvent
(
next
.
eventName
,
next
.
path
)
}
break
case
'rootFolderChanged'
:
setTimeout
(()
=>
{
rootFolderChanged
(
args
[
0
])
},
0
)
delete
pendingEvents
[
eventName
+
args
[
0
]]
if
(
queuedEvents
.
length
)
{
const
next
=
queuedEvents
.
pop
()
await
executeEvent
(
next
.
eventName
,
next
.
path
)
}
break
}
}
libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
View file @
a992221f
...
@@ -304,14 +304,12 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -304,14 +304,12 @@ export const FileExplorer = (props: FileExplorerProps) => {
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
return
{
...
prevState
,
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
)
{
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
:
''
}
}
})
})
...
@@ -329,17 +327,17 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -329,17 +327,17 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
}
else
{
}
else
{
if
(
hasReservedKeyword
(
content
))
{
if
(
hasReservedKeyword
(
content
))
{
// editRef.current.textContent = state.focusEdit.lastEdit
props
.
modal
(
'Reserved Keyword'
,
`File name contains remix reserved keywords. '
${
content
}
'`
,
'Close'
,
()
=>
{})
props
.
modal
(
'Reserved Keyword'
,
`File name contains remix reserved keywords. '
${
content
}
'`
,
'Close'
,
()
=>
{})
}
else
{
}
else
{
if
(
state
.
focusEdit
.
element
)
{
const
oldPath
:
string
=
state
.
focusEdit
.
element
const
oldPath
:
string
=
state
.
focusEdit
.
element
const
oldName
=
extractNameFromKey
(
oldPath
)
const
oldName
=
extractNameFromKey
(
oldPath
)
const
newPath
=
oldPath
.
replace
(
oldName
,
content
)
const
newPath
=
oldPath
.
replace
(
oldName
,
content
)
// editRef.current.textContent = extractNameFromKey(oldPath)
renamePath
(
oldPath
,
newPath
)
renamePath
(
oldPath
,
newPath
)
}
}
}
}
}
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
})
})
...
...
libs/remix-ui/workspace/src/lib/components/file-label.tsx
View file @
a992221f
...
@@ -17,7 +17,6 @@ export const FileLabel = (props: FileLabelProps) => {
...
@@ -17,7 +17,6 @@ export const FileLabel = (props: FileLabelProps) => {
const
{
file
,
focusEdit
,
editModeOff
}
=
props
const
{
file
,
focusEdit
,
editModeOff
}
=
props
const
[
isEditable
,
setIsEditable
]
=
useState
<
boolean
>
(
false
)
const
[
isEditable
,
setIsEditable
]
=
useState
<
boolean
>
(
false
)
const
labelRef
=
useRef
(
null
)
const
labelRef
=
useRef
(
null
)
const
[
defaultValue
,
setDefaultValue
]
=
useState
<
string
>
(
null
)
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
focusEdit
.
element
&&
file
.
path
)
{
if
(
focusEdit
.
element
&&
file
.
path
)
{
...
@@ -33,22 +32,18 @@ export const FileLabel = (props: FileLabelProps) => {
...
@@ -33,22 +32,18 @@ export const FileLabel = (props: FileLabelProps) => {
}
}
},
[
isEditable
])
},
[
isEditable
])
useEffect
(()
=>
{
if
(
labelRef
.
current
)
setDefaultValue
(
labelRef
.
current
.
innerText
)
},
[
labelRef
.
current
])
const
handleEditInput
=
(
event
:
React
.
KeyboardEvent
<
HTMLDivElement
>
)
=>
{
const
handleEditInput
=
(
event
:
React
.
KeyboardEvent
<
HTMLDivElement
>
)
=>
{
if
(
event
.
which
===
13
)
{
if
(
event
.
which
===
13
)
{
event
.
preventDefault
()
event
.
preventDefault
()
editModeOff
(
labelRef
.
current
.
innerText
)
editModeOff
(
labelRef
.
current
.
innerText
)
labelRef
.
current
.
innerText
=
defaultValu
e
labelRef
.
current
.
innerText
=
file
.
nam
e
}
}
}
}
const
handleEditBlur
=
(
event
:
React
.
SyntheticEvent
)
=>
{
const
handleEditBlur
=
(
event
:
React
.
SyntheticEvent
)
=>
{
event
.
stopPropagation
()
event
.
stopPropagation
()
editModeOff
(
labelRef
.
current
.
innerText
)
editModeOff
(
labelRef
.
current
.
innerText
)
labelRef
.
current
.
innerText
=
defaultValu
e
labelRef
.
current
.
innerText
=
file
.
nam
e
}
}
return
(
return
(
...
...
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
View file @
a992221f
...
@@ -614,7 +614,13 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
...
@@ -614,7 +614,13 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
if
(
prevFiles
)
{
if
(
prevFiles
)
{
prevFiles
.
child
=
_
.
merge
(
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
),
prevFiles
.
child
)
prevFiles
.
child
=
_
.
merge
(
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
),
prevFiles
.
child
)
if
(
deletePath
)
delete
prevFiles
.
child
[
deletePath
]
if
(
deletePath
)
{
if
(
deletePath
.
endsWith
(
'/blank'
))
delete
prevFiles
.
child
[
deletePath
]
else
{
deletePath
=
extractNameFromKey
(
deletePath
)
delete
prevFiles
.
child
[
deletePath
]
}
}
files
=
_
.
set
(
files
,
_path
,
prevFiles
)
files
=
_
.
set
(
files
,
_path
,
prevFiles
)
}
else
if
(
payload
.
fileTree
&&
payload
.
path
)
{
}
else
if
(
payload
.
fileTree
&&
payload
.
path
)
{
files
=
{
[
payload
.
path
]:
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
)
}
files
=
{
[
payload
.
path
]:
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
)
}
...
@@ -635,7 +641,13 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
...
@@ -635,7 +641,13 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
if
(
prevFiles
)
{
if
(
prevFiles
)
{
prevFiles
.
child
=
_
.
merge
(
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
),
prevFiles
.
child
)
prevFiles
.
child
=
_
.
merge
(
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
),
prevFiles
.
child
)
if
(
deletePath
)
delete
prevFiles
.
child
[
deletePath
]
if
(
deletePath
)
{
if
(
deletePath
.
endsWith
(
'/blank'
))
delete
prevFiles
.
child
[
deletePath
]
else
{
deletePath
=
extractNameFromKey
(
deletePath
)
delete
prevFiles
.
child
[
deletePath
]
}
}
files
=
_
.
set
(
files
,
_path
,
prevFiles
)
files
=
_
.
set
(
files
,
_path
,
prevFiles
)
}
else
{
}
else
{
files
=
{
[
payload
.
path
]:
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
)
}
files
=
{
[
payload
.
path
]:
normalize
(
payload
.
fileTree
,
payload
.
path
,
payload
.
type
)
}
...
...
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