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
049705d1
Commit
049705d1
authored
Aug 27, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fetch directory content on folder click
parent
587969bd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
53 deletions
+56
-53
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+2
-12
workspace.ts
libs/remix-ui/workspace/src/lib/actions/workspace.ts
+22
-6
workspace.ts
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
+32
-6
remix-ui-workspace.tsx
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
+0
-29
No files found.
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
049705d1
...
@@ -7,7 +7,7 @@ import { FileExplorerMenu } from './file-explorer-menu' // eslint-disable-line
...
@@ -7,7 +7,7 @@ import { FileExplorerMenu } from './file-explorer-menu' // eslint-disable-line
import
{
FileExplorerContextMenu
}
from
'./file-explorer-context-menu'
// eslint-disable-line
import
{
FileExplorerContextMenu
}
from
'./file-explorer-context-menu'
// eslint-disable-line
import
{
FileExplorerProps
,
File
,
MenuItems
,
FileExplorerState
}
from
'./types'
import
{
FileExplorerProps
,
File
,
MenuItems
,
FileExplorerState
}
from
'./types'
import
{
fileSystemReducer
,
fileSystemInitialState
}
from
'./reducers/fileSystem'
import
{
fileSystemReducer
,
fileSystemInitialState
}
from
'./reducers/fileSystem'
import
{
init
,
resolveDirectory
,
addInputField
,
removeInputField
}
from
'./actions/fileSystem'
import
{
addInputField
,
removeInputField
}
from
'./actions/fileSystem'
import
*
as
helper
from
'../../../../../apps/remix-ide/src/lib/helper'
import
*
as
helper
from
'../../../../../apps/remix-ide/src/lib/helper'
import
QueryParams
from
'../../../../../apps/remix-ide/src/lib/query-params'
import
QueryParams
from
'../../../../../apps/remix-ide/src/lib/query-params'
import
{
FileSystemContext
}
from
'@remix-ui/workspace'
import
{
FileSystemContext
}
from
'@remix-ui/workspace'
...
@@ -54,16 +54,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -54,16 +54,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
const
global
=
useContext
(
FileSystemContext
)
const
global
=
useContext
(
FileSystemContext
)
useEffect
(()
=>
{
useEffect
(()
=>
{
init
(
props
.
filesProvider
,
props
.
plugin
,
props
.
registry
)(
dispatch
)
},
[])
useEffect
(()
=>
{
if
(
fileSystem
.
notification
.
message
)
{
global
.
modal
(
fileSystem
.
notification
.
title
,
fileSystem
.
notification
.
message
,
fileSystem
.
notification
.
labelOk
,
fileSystem
.
notification
.
actionOk
,
fileSystem
.
notification
.
labelCancel
,
fileSystem
.
notification
.
actionCancel
)
}
},
[
fileSystem
.
notification
.
message
])
useEffect
(()
=>
{
if
(
global
.
fs
.
mode
===
'browser'
)
{
if
(
global
.
fs
.
mode
===
'browser'
)
{
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
expandPath
:
[...
new
Set
([...
prevState
.
expandPath
,
...
global
.
fs
.
browser
.
expandPath
])]
}
return
{
...
prevState
,
expandPath
:
[...
new
Set
([...
prevState
.
expandPath
,
...
global
.
fs
.
browser
.
expandPath
])]
}
...
@@ -550,7 +540,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -550,7 +540,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
if
(
!
state
.
expandPath
.
includes
(
path
))
{
if
(
!
state
.
expandPath
.
includes
(
path
))
{
expandPath
=
[...
new
Set
([...
state
.
expandPath
,
path
])]
expandPath
=
[...
new
Set
([...
state
.
expandPath
,
path
])]
resolveDirectory
(
fileSystem
.
provider
.
provider
,
path
)(
dispatc
h
)
global
.
dispatchFetchDirectory
(
pat
h
)
}
else
{
}
else
{
expandPath
=
[...
new
Set
(
state
.
expandPath
.
filter
(
key
=>
key
&&
(
typeof
key
===
'string'
)
&&
!
key
.
startsWith
(
path
)))]
expandPath
=
[...
new
Set
(
state
.
expandPath
.
filter
(
key
=>
key
&&
(
typeof
key
===
'string'
)
&&
!
key
.
startsWith
(
path
)))]
}
}
...
...
libs/remix-ui/workspace/src/lib/actions/workspace.ts
View file @
049705d1
...
@@ -45,10 +45,10 @@ const fetchDirectoryRequest = (promise: Promise<any>) => {
...
@@ -45,10 +45,10 @@ const fetchDirectoryRequest = (promise: Promise<any>) => {
}
}
}
}
const
fetchDirectorySuccess
=
(
path
:
string
,
file
s
)
=>
{
const
fetchDirectorySuccess
=
(
path
:
string
,
file
Tree
)
=>
{
return
{
return
{
type
:
'FETCH_DIRECTORY_SUCCESS'
,
type
:
'FETCH_DIRECTORY_SUCCESS'
,
payload
:
{
path
,
file
s
}
payload
:
{
path
,
file
Tree
}
}
}
}
}
...
@@ -231,16 +231,32 @@ const listenOnEvents = (provider) => {
...
@@ -231,16 +231,32 @@ const listenOnEvents = (provider) => {
dispatch
(
setMode
(
'browser'
))
dispatch
(
setMode
(
'browser'
))
})
})
// provider.event.on('connected', () => {
// provider.event.on('connected', () => {
// remixdExplorer.show()
// props.plugin.fileManager.setMode('localhost')
// setWorkspace(LOCALHOST)
// setState(prevState => {
// return { ...prevState, hideRemixdExplorer: false, loadingLocalhost: false }
// })
// })
// })
// provider.event.on('disconnected', () => {
// provider.event.on('disconnected', () => {
// remixdExplorer.hide()
// // If 'connect to localhost' is clicked from home tab, mode is not 'localhost'
// if (props.fileManager.mode === 'localhost') {
// await setWorkspace(NO_WORKSPACE)
// props.plugin.fileManager.setMode('browser')
// setState(prevState => {
// return { ...prevState, hideRemixdExplorer: true, loadingLocalhost: false }
// })
// } else {
// // Hide spinner in file explorer
// setState(prevState => {
// return { ...prevState, loadingLocalhost: false }
// })
// }
// })
// })
// provider.event.on('loading', () => {
// provider.event.on('loading', () => {
// remixdExplorer.loading()
// setState(prevState => {
// return { ...prevState, loadingLocalhost: true }
// })
// })
// })
provider
.
event
.
on
(
'fileExternallyChanged'
,
async
(
path
:
string
,
file
:
{
content
:
string
})
=>
{
provider
.
event
.
on
(
'fileExternallyChanged'
,
async
(
path
:
string
,
file
:
{
content
:
string
})
=>
{
...
...
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
View file @
049705d1
...
@@ -117,20 +117,20 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
...
@@ -117,20 +117,20 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
}
}
case
'FETCH_DIRECTORY_SUCCESS'
:
{
case
'FETCH_DIRECTORY_SUCCESS'
:
{
const
payload
=
action
.
payload
as
{
path
:
string
,
file
s
}
const
payload
=
action
.
payload
as
{
path
:
string
,
file
Tree
}
return
{
return
{
...
state
,
...
state
,
browser
:
{
browser
:
{
...
state
.
browser
,
...
state
.
browser
,
files
:
state
.
mode
===
'browser'
?
fetchDirectoryContent
(
payload
.
files
,
payload
.
path
)
:
state
.
browser
.
files
,
files
:
state
.
mode
===
'browser'
?
fetchDirectoryContent
(
state
,
payload
)
:
state
.
browser
.
files
,
isRequesting
:
false
,
isRequesting
:
false
,
isSuccessful
:
true
,
isSuccessful
:
true
,
error
:
null
error
:
null
},
},
localhost
:
{
localhost
:
{
...
state
.
localhost
,
...
state
.
localhost
,
files
:
state
.
mode
===
'localhost'
?
fetchDirectoryContent
(
payload
.
files
,
payload
.
path
)
:
state
.
localhost
.
files
,
files
:
state
.
mode
===
'localhost'
?
fetchDirectoryContent
(
state
,
payload
)
:
state
.
localhost
.
files
,
isRequesting
:
false
,
isRequesting
:
false
,
isSuccessful
:
true
,
isSuccessful
:
true
,
error
:
null
error
:
null
...
@@ -250,10 +250,36 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
...
@@ -250,10 +250,36 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
}
}
}
}
const
fetchDirectoryContent
=
(
fileTree
,
folderPath
:
string
)
=>
{
const
fetchDirectoryContent
=
(
state
:
BrowserState
,
payload
:
{
fileTree
,
path
:
string
})
=>
{
const
files
=
normalize
(
fileTree
)
if
(
state
.
mode
===
'browser'
)
{
if
(
payload
.
path
===
state
.
browser
.
currentWorkspace
)
{
const
files
=
normalize
(
payload
.
fileTree
)
return
{
[
extractNameFromKey
(
folderPath
)]:
files
}
return
{
[
state
.
browser
.
currentWorkspace
]:
files
}
}
else
{
let
files
=
state
.
browser
.
files
const
_path
=
splitPath
(
state
,
payload
.
path
)
const
prevFiles
=
_
.
get
(
files
,
_path
)
prevFiles
.
child
=
_
.
merge
(
normalize
(
payload
.
fileTree
),
prevFiles
.
child
)
files
=
_
.
set
(
files
,
_path
,
prevFiles
)
return
files
}
}
else
{
if
(
payload
.
path
===
state
.
mode
)
{
const
files
=
normalize
(
payload
.
fileTree
)
return
{
[
state
.
mode
]:
files
}
}
else
{
let
files
=
state
.
localhost
.
files
const
_path
=
splitPath
(
state
,
payload
.
path
)
const
prevFiles
=
_
.
get
(
files
,
_path
)
prevFiles
.
child
=
_
.
merge
(
normalize
(
payload
.
fileTree
),
prevFiles
.
child
)
files
=
_
.
set
(
files
,
_path
,
prevFiles
)
return
files
}
}
}
}
const
normalize
=
(
filesList
):
Record
<
string
,
File
>
=>
{
const
normalize
=
(
filesList
):
Record
<
string
,
File
>
=>
{
...
...
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
View file @
049705d1
...
@@ -168,35 +168,6 @@ export function Workspace (props: WorkspaceProps) {
...
@@ -168,35 +168,6 @@ export function Workspace (props: WorkspaceProps) {
})
})
}
}
const
remixdExplorer
=
{
hide
:
async
()
=>
{
// If 'connect to localhost' is clicked from home tab, mode is not 'localhost'
// if (props.fileManager.mode === 'localhost') {
await
setWorkspace
(
NO_WORKSPACE
)
props
.
plugin
.
fileManager
.
setMode
(
'browser'
)
setState
(
prevState
=>
{
return
{
...
prevState
,
hideRemixdExplorer
:
true
,
loadingLocalhost
:
false
}
})
// } else {
// // Hide spinner in file explorer
// setState(prevState => {
// return { ...prevState, loadingLocalhost: false }
// })
// }
},
show
:
()
=>
{
props
.
plugin
.
fileManager
.
setMode
(
'localhost'
)
setState
(
prevState
=>
{
return
{
...
prevState
,
hideRemixdExplorer
:
false
,
loadingLocalhost
:
false
}
})
},
loading
:
()
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
loadingLocalhost
:
true
}
})
}
}
const
createModalMessage
=
()
=>
{
const
createModalMessage
=
()
=>
{
return
(
return
(
<>
<>
...
...
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