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
8c8c4953
Commit
8c8c4953
authored
Sep 26, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split files to fix circular dependency errors
parent
4bdddefb
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
26 deletions
+73
-26
events.ts
libs/remix-ui/workspace/src/lib/actions/events.ts
+12
-15
index.ts
libs/remix-ui/workspace/src/lib/actions/index.ts
+0
-0
payload.ts
libs/remix-ui/workspace/src/lib/actions/payload.ts
+19
-0
workspace.ts
libs/remix-ui/workspace/src/lib/actions/workspace.ts
+0
-0
file-explorer.tsx
libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
+1
-2
FileSystemProvider.tsx
...mix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
+1
-1
workspace.ts
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
+38
-0
remix-ui-workspace.tsx
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
+2
-8
No files found.
libs/remix-ui/workspace/src/lib/actions/events.ts
View file @
8c8c4953
import
{
extractParentFromKey
}
from
'@remix-ui/helper'
import
React
from
'react'
import
{
action
}
from
'../types'
import
{
displayNotification
,
displayPopUp
,
fileAddedSuccess
,
fileRemovedSuccess
,
fileRenamedSuccess
,
folderAddedSuccess
,
removeContextMenuItem
,
rootFolderChangedSuccess
,
setContextMenuItem
}
from
'./payload'
import
{
displayNotification
,
displayPopUp
,
fileAddedSuccess
,
fileRemovedSuccess
,
fileRenamedSuccess
,
folderAddedSuccess
,
loadLocalhostError
,
loadLocalhostRequest
,
loadLocalhostSuccess
,
removeContextMenuItem
,
rootFolderChangedSuccess
,
setContextMenuItem
,
setMode
}
from
'./payload'
import
{
addInputField
,
createWorkspace
,
fetchWorkspaceDirectory
,
renameWorkspace
,
switchToWorkspace
,
uploadFile
}
from
'./workspace'
const
queuedEvents
=
[]
...
...
@@ -61,28 +61,25 @@ export const listenOnProviderEvents = (provider) => async (reducerDispatch: Reac
await
executeEvent
(
'fileRenamed'
,
oldPath
,
newPath
)
})
// provider.event.on('disconnected', () => {
// dispatch(setMode('browser'))
// })
provider
.
event
.
on
(
'connected'
,
async
()
=>
{
fetchWorkspaceDirectory
(
'/'
)
// setState(prevState => {
// return { ...prevState, hideRemixdExplorer: false, loadingLocalhost: false }
// })
})
provider
.
event
.
on
(
'disconnected'
,
async
()
=>
{
plugin
.
fileManager
.
setMode
(
'browser'
)
dispatch
(
setMode
(
'browser'
))
dispatch
(
loadLocalhostError
(
'Remixd disconnected!'
))
const
workspaceProvider
=
plugin
.
fileProviders
.
workspace
await
switchToWorkspace
(
workspaceProvider
.
workspace
)
})
provider
.
event
.
on
(
'connected'
,
async
()
=>
{
plugin
.
fileManager
.
setMode
(
'localhost'
)
dispatch
(
setMode
(
'localhost'
))
fetchWorkspaceDirectory
(
'/'
)
dispatch
(
loadLocalhostSuccess
())
})
provider
.
event
.
on
(
'loadingLocalhost'
,
async
()
=>
{
await
switchToWorkspace
(
LOCALHOST
)
// setState(prevState => {
// return { ...prevState, loadingLocalhost: true }
// })
dispatch
(
loadLocalhostRequest
())
})
provider
.
event
.
on
(
'fileExternallyChanged'
,
async
(
path
:
string
,
file
:
{
content
:
string
})
=>
{
...
...
libs/remix-ui/workspace/src/lib/actions/index.ts
0 → 100644
View file @
8c8c4953
This diff is collapsed.
Click to expand it.
libs/remix-ui/workspace/src/lib/actions/payload.ts
View file @
8c8c4953
...
...
@@ -207,3 +207,22 @@ export const setExpandPath = (paths: string[]) => {
payload
:
paths
}
}
export
const
loadLocalhostError
=
(
error
:
any
)
=>
{
return
{
type
:
'LOAD_LOCALHOST_ERROR'
,
payload
:
error
}
}
export
const
loadLocalhostRequest
=
()
=>
{
return
{
type
:
'LOAD_LOCALHOST_REQUEST'
}
}
export
const
loadLocalhostSuccess
=
()
=>
{
return
{
type
:
'LOAD_LOCALHOST_SUCCESS'
}
}
libs/remix-ui/workspace/src/lib/actions/workspace.ts
View file @
8c8c4953
This diff is collapsed.
Click to expand it.
libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
View file @
8c8c4953
...
...
@@ -10,7 +10,6 @@ import '../css/file-explorer.css'
import
{
checkSpecialChars
,
extractNameFromKey
,
extractParentFromKey
,
joinPath
}
from
'@remix-ui/helper'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import
{
FileRender
}
from
'./file-render'
import
{
handleExpandPath
}
from
'../actions/workspace'
export
const
FileExplorer
=
(
props
:
FileExplorerProps
)
=>
{
const
{
name
,
contextMenuItems
,
removedContextMenuItems
,
files
}
=
props
...
...
@@ -404,7 +403,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
else
{
expandPath
=
[...
new
Set
(
props
.
expandPath
.
filter
(
key
=>
key
&&
(
typeof
key
===
'string'
)
&&
!
key
.
startsWith
(
props
.
name
)))]
}
h
andleExpandPath
(
expandPath
)
props
.
dispatchH
andleExpandPath
(
expandPath
)
}
return
(
...
...
libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
View file @
8c8c4953
...
...
@@ -5,7 +5,7 @@ import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import
{
FileSystemContext
}
from
'../contexts'
import
{
browserReducer
,
browserInitialState
}
from
'../reducers/workspace'
import
{
initWorkspace
,
fetchDirectory
,
addInputField
,
removeInputField
,
createWorkspace
,
fetchWorkspaceDirectory
,
switchToWorkspace
,
renameWorkspace
,
deleteWorkspace
,
clearPopUp
,
publishToGist
,
uploadFile
,
createNewFile
,
setFocusElement
,
createNewFolder
,
deletePath
,
renamePath
,
copyFile
,
copyFolder
,
runScript
,
emitContextMenuEvent
,
handleClickFile
,
handleExpandPath
}
from
'../actions/workspace
'
import
{
initWorkspace
,
fetchDirectory
,
removeInputField
,
deleteWorkspace
,
clearPopUp
,
publishToGist
,
createNewFile
,
setFocusElement
,
createNewFolder
,
deletePath
,
renamePath
,
copyFile
,
copyFolder
,
runScript
,
emitContextMenuEvent
,
handleClickFile
,
handleExpandPath
,
addInputField
,
createWorkspace
,
fetchWorkspaceDirectory
,
renameWorkspace
,
switchToWorkspace
,
uploadFile
}
from
'../actions
'
import
{
Modal
,
WorkspaceProps
}
from
'../types'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import
{
Workspace
}
from
'../remix-ui-workspace'
...
...
libs/remix-ui/workspace/src/lib/reducers/workspace.ts
View file @
8c8c4953
...
...
@@ -533,6 +533,44 @@ export const browserReducer = (state = browserInitialState, action: Action) => {
}
}
case
'LOAD_LOCALHOST_REQUEST'
:
{
return
{
...
state
,
localhost
:
{
...
state
.
localhost
,
isRequesting
:
true
,
isSuccessful
:
false
,
error
:
null
}
}
}
case
'LOAD_LOCALHOST_SUCCESS'
:
{
return
{
...
state
,
localhost
:
{
...
state
.
localhost
,
isRequesting
:
false
,
isSuccessful
:
true
,
error
:
null
}
}
}
case
'LOAD_LOCALHOST_ERROR'
:
{
const
payload
=
action
.
payload
as
string
return
{
...
state
,
localhost
:
{
...
state
.
localhost
,
isRequesting
:
false
,
isSuccessful
:
false
,
error
:
payload
}
}
}
default
:
throw
new
Error
()
}
...
...
libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
View file @
8c8c4953
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
// eslint-disable-line
import
{
FileExplorer
}
from
'./components/file-explorer'
// eslint-disable-line
import
'./css/remix-ui-workspace.css'
import
{
WorkspaceState
}
from
'./types'
import
{
FileSystemContext
}
from
'./contexts'
const
canUpload
=
window
.
File
||
window
.
FileReader
||
window
.
FileList
||
window
.
Blob
...
...
@@ -9,11 +8,6 @@ const canUpload = window.File || window.FileReader || window.FileList || window.
export
function
Workspace
()
{
const
LOCALHOST
=
' - connect to localhost - '
const
NO_WORKSPACE
=
' - none - '
const
[
state
]
=
useState
<
WorkspaceState
>
({
hideRemixdExplorer
:
true
,
displayNewFile
:
false
,
loadingLocalhost
:
false
})
const
[
currentWorkspace
,
setCurrentWorkspace
]
=
useState
<
string
>
(
NO_WORKSPACE
)
const
global
=
useContext
(
FileSystemContext
)
const
workspaceRenameInput
=
useRef
()
...
...
@@ -215,9 +209,9 @@ export function Workspace () {
}
</
div
>
{
state
.
loadingLocalhost
?
<
div
className=
"text-center py-5"
><
i
className=
"fas fa-spinner fa-pulse fa-2x"
></
i
></
div
>
global
.
fs
.
localhost
.
isRequesting
?
<
div
className=
"text-center py-5"
><
i
className=
"fas fa-spinner fa-pulse fa-2x"
></
i
></
div
>
:
<
div
className=
'pl-2 filesystemexplorer remixui_treeview'
>
{
global
.
fs
.
mode
===
'localhost'
&&
{
global
.
fs
.
mode
===
'localhost'
&&
global
.
fs
.
localhost
.
isSuccessful
&&
<
FileExplorer
name=
'localhost'
menuItems=
{
[
'createNewFile'
,
'createNewFolder'
]
}
...
...
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