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
38b9bbf5
Commit
38b9bbf5
authored
Sep 08, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
folderAdded and rename
parent
cf05a97d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
73 deletions
+45
-73
workspace.ts
libs/remix-ui/workspace/src/lib/actions/workspace.ts
+39
-9
workspace.ts
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
+6
-64
No files found.
libs/remix-ui/workspace/src/lib/actions/workspace.ts
View file @
38b9bbf5
import
React
from
'react'
import
{
bufferToHex
,
keccakFromString
}
from
'ethereumjs-util'
import
axios
,
{
AxiosResponse
}
from
'axios'
import
{
checkSpecialChars
,
checkSlash
}
from
'@remix-ui/helper'
import
{
checkSpecialChars
,
checkSlash
,
extractParentFromKey
}
from
'@remix-ui/helper'
const
QueryParams
=
require
(
'../../../../../../apps/remix-ide/src/lib/query-params'
)
const
examples
=
require
(
'../../../../../../apps/remix-ide/src/app/editor/examples'
)
...
...
@@ -72,10 +72,10 @@ const fileAddedSuccess = (filePath: string) => {
}
}
const
folderAddedSuccess
=
(
folderPath
:
string
)
=>
{
const
folderAddedSuccess
=
(
folderPath
:
string
,
fileTree
)
=>
{
return
{
type
:
'FOLDER_ADDED_SUCCESS'
,
payload
:
folderPath
payload
:
{
path
:
folderPath
,
fileTree
}
}
}
...
...
@@ -86,10 +86,10 @@ const fileRemovedSuccess = (removePath: string) => {
}
}
const
fileRenamedSuccess
=
(
oldPath
:
string
,
newPath
:
string
)
=>
{
const
fileRenamedSuccess
=
(
path
:
string
,
oldPath
:
string
,
fileTree
)
=>
{
return
{
type
:
'FILE_RENAMED_SUCCESS'
,
payload
:
{
oldPath
,
newPath
}
payload
:
{
path
,
oldPath
,
fileTree
}
}
}
...
...
@@ -413,15 +413,45 @@ const fileAdded = async (filePath: string) => {
}
const
folderAdded
=
async
(
folderPath
:
string
)
=>
{
await
dispatch
(
folderAddedSuccess
(
folderPath
))
const
provider
=
plugin
.
fileManager
.
currentFileProvider
()
const
path
=
extractParentFromKey
(
folderPath
)
||
provider
.
workspace
||
provider
.
type
||
''
const
promise
=
new
Promise
((
resolve
)
=>
{
provider
.
resolveDirectory
(
path
,
(
error
,
fileTree
)
=>
{
if
(
error
)
console
.
error
(
error
)
resolve
(
fileTree
)
})
})
promise
.
then
((
files
)
=>
{
dispatch
(
folderAddedSuccess
(
path
,
files
))
}).
catch
((
error
)
=>
{
console
.
error
(
error
)
})
return
promise
}
const
fileRemoved
=
async
(
removePath
:
string
)
=>
{
await
dispatch
(
fileRemovedSuccess
(
removePath
))
}
const
fileRenamed
=
async
(
oldPath
:
string
,
newPath
:
string
)
=>
{
await
dispatch
(
fileRenamedSuccess
(
oldPath
,
newPath
))
const
fileRenamed
=
async
(
oldPath
:
string
)
=>
{
const
provider
=
plugin
.
fileManager
.
currentFileProvider
()
const
path
=
extractParentFromKey
(
oldPath
)
||
provider
.
workspace
||
provider
.
type
||
''
const
promise
=
new
Promise
((
resolve
)
=>
{
provider
.
resolveDirectory
(
path
,
(
error
,
fileTree
)
=>
{
if
(
error
)
console
.
error
(
error
)
resolve
(
fileTree
)
})
})
promise
.
then
((
files
)
=>
{
dispatch
(
fileRenamedSuccess
(
path
,
oldPath
,
files
))
}).
catch
((
error
)
=>
{
console
.
error
(
error
)
})
}
const
rootFolderChanged
=
async
(
path
)
=>
{
...
...
@@ -465,7 +495,7 @@ const executeEvent = async (eventName: 'fileAdded' | 'folderAdded' | 'fileRemove
break
case
'fileRenamed'
:
await
fileRenamed
(
args
[
0
]
,
args
[
1
]
)
await
fileRenamed
(
args
[
0
])
delete
pendingEvents
[
eventName
+
args
[
0
]]
if
(
queuedEvents
.
length
)
{
const
next
=
queuedEvents
.
pop
()
...
...
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
View file @
38b9bbf5
...
...
@@ -201,18 +201,18 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
}
case
'FOLDER_ADDED_SUCCESS'
:
{
const
payload
=
action
.
payload
as
string
const
payload
=
action
.
payload
as
{
path
:
string
,
fileTree
}
return
{
...
state
,
browser
:
{
...
state
.
browser
,
files
:
state
.
mode
===
'browser'
?
f
olderAdded
(
state
,
payload
)
:
state
.
browser
.
files
,
files
:
state
.
mode
===
'browser'
?
f
etchDirectoryContent
(
state
,
payload
)
:
state
.
browser
.
files
,
expandPath
:
state
.
mode
===
'browser'
?
[...
new
Set
([...
state
.
browser
.
expandPath
,
payload
])]
:
state
.
browser
.
expandPath
},
localhost
:
{
...
state
.
localhost
,
files
:
state
.
mode
===
'localhost'
?
f
olderAdded
(
state
,
payload
)
:
state
.
localhost
.
files
,
files
:
state
.
mode
===
'localhost'
?
f
etchDirectoryContent
(
state
,
payload
)
:
state
.
localhost
.
files
,
expandPath
:
state
.
mode
===
'localhost'
?
[...
new
Set
([...
state
.
localhost
.
expandPath
,
payload
])]
:
state
.
localhost
.
expandPath
}
}
...
...
@@ -290,17 +290,17 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
}
case
'FILE_RENAMED_SUCCESS'
:
{
const
payload
=
action
.
payload
as
{
oldPath
:
string
,
newPath
:
string
}
const
payload
=
action
.
payload
as
{
path
:
string
,
oldPath
:
string
,
fileTree
}
return
{
...
state
,
browser
:
{
...
state
.
browser
,
files
:
state
.
mode
===
'browser'
?
f
ileRenamed
(
state
,
payload
)
:
state
.
browser
.
files
files
:
state
.
mode
===
'browser'
?
f
etchDirectoryContent
(
state
,
payload
,
payload
.
oldPath
)
:
state
.
browser
.
files
},
localhost
:
{
...
state
.
localhost
,
files
:
state
.
mode
===
'localhost'
?
f
ileRenamed
(
state
,
payload
)
:
state
.
localhost
.
files
files
:
state
.
mode
===
'localhost'
?
f
etchDirectoryContent
(
state
,
payload
,
payload
.
oldPath
)
:
state
.
localhost
.
files
}
}
}
...
...
@@ -323,27 +323,6 @@ const fileAdded = (state: BrowserState, path: string): { [x: string]: Record<str
return
files
}
const
folderAdded
=
(
state
:
BrowserState
,
path
:
string
):
{
[
x
:
string
]:
Record
<
string
,
File
>
}
=>
{
let
files
=
state
.
mode
===
'browser'
?
state
.
browser
.
files
:
state
.
localhost
.
files
const
_path
=
splitPath
(
state
,
path
)
const
_dir
=
splitPath
(
state
,
extractParentFromKey
(
path
))
const
prevFiles
=
_
.
get
(
files
,
_dir
)
if
(
prevFiles
.
child
)
{
}
else
{
}
files
=
_
.
set
(
files
,
_path
,
{
path
:
path
,
name
:
extractNameFromKey
(
path
),
isDirectory
:
true
,
type
:
'folder'
})
return
files
}
const
fileRemoved
=
(
state
:
BrowserState
,
path
:
string
):
{
[
x
:
string
]:
Record
<
string
,
File
>
}
=>
{
const
files
=
state
.
mode
===
'browser'
?
state
.
browser
.
files
:
state
.
localhost
.
files
const
_path
=
splitPath
(
state
,
path
)
...
...
@@ -352,28 +331,6 @@ const fileRemoved = (state: BrowserState, path: string): { [x: string]: Record<s
return
files
}
const
fileRenamed
=
(
state
:
BrowserState
,
payload
:
{
oldPath
:
string
,
newPath
:
string
}):
{
[
x
:
string
]:
Record
<
string
,
File
>
}
=>
{
let
files
=
state
.
mode
===
'browser'
?
state
.
browser
.
files
:
state
.
localhost
.
files
const
_oldPath
=
splitPath
(
state
,
payload
.
oldPath
)
const
_newPath
=
splitPath
(
state
,
payload
.
newPath
)
const
prevFiles
=
_
.
get
(
files
,
_oldPath
)
const
nextFiles
=
{
...
prevFiles
,
path
:
payload
.
newPath
,
name
:
extractNameFromKey
(
payload
.
newPath
)
}
if
(
nextFiles
.
child
)
{
nextFiles
.
child
=
sortFolderAndFiles
(
nextFiles
.
child
)
files
=
_
.
set
(
files
,
_newPath
,
nextFiles
)
}
else
{
files
=
_
.
set
(
files
,
_newPath
,
nextFiles
)
files
=
state
.
mode
===
'browser'
?
{
[
state
.
browser
.
currentWorkspace
]:
sortFolderAndFiles
(
files
[
state
.
browser
.
currentWorkspace
])
}
:
{
[
state
.
mode
]:
sortFolderAndFiles
(
files
[
state
.
mode
])
}
}
_
.
unset
(
files
,
_oldPath
)
return
files
}
// IDEA: Modify function to remove blank input field without fetching content
const
fetchDirectoryContent
=
(
state
:
BrowserState
,
payload
:
{
fileTree
,
path
:
string
,
type
?:
'file'
|
'folder'
},
deletePath
?:
string
)
=>
{
if
(
state
.
mode
===
'browser'
)
{
...
...
@@ -473,18 +430,3 @@ const splitPath = (state: BrowserState, path: string): string[] | string => {
return
_path
}
const
sortFolderAndFiles
=
(
filesList
:
Record
<
string
,
File
>
):
Record
<
string
,
File
>
=>
{
const
folders
=
{}
const
files
=
{}
Object
.
keys
(
filesList
||
{}).
forEach
(
key
=>
{
if
(
filesList
[
key
].
isDirectory
)
{
folders
[
key
]
=
filesList
[
key
]
}
else
{
files
[
key
]
=
filesList
[
key
]
}
})
return
Object
.
assign
({},
folders
,
files
)
}
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