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
a5198dbf
Commit
a5198dbf
authored
Jan 26, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix create and upload file in home tab
parent
cf364f15
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
12 deletions
+54
-12
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+25
-1
landing-page.js
apps/remix-ide/src/app/ui/landing-page/landing-page.js
+7
-4
file-explorer-menu.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer-menu.tsx
+1
-0
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+18
-6
index.ts
libs/remix-ui/file-explorer/src/lib/types/index.ts
+3
-1
No files found.
apps/remix-ide/src/app/panels/file-panel.js
View file @
a5198dbf
...
@@ -34,7 +34,7 @@ var canUpload = window.File || window.FileReader || window.FileList || window.Bl
...
@@ -34,7 +34,7 @@ var canUpload = window.File || window.FileReader || window.FileList || window.Bl
const
profile
=
{
const
profile
=
{
name
:
'fileExplorers'
,
name
:
'fileExplorers'
,
displayName
:
'File explorers'
,
displayName
:
'File explorers'
,
methods
:
[],
methods
:
[
'createNewFile'
,
'uploadFile'
],
events
:
[],
events
:
[],
icon
:
'assets/img/fileManager.webp'
,
icon
:
'assets/img/fileManager.webp'
,
description
:
' - '
,
description
:
' - '
,
...
@@ -67,6 +67,8 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -67,6 +67,8 @@ module.exports = class Filepanel extends ViewPlugin {
}
}
this
.
reset
=
false
this
.
reset
=
false
this
.
registeredMenuItems
=
[]
this
.
registeredMenuItems
=
[]
this
.
displayNewFile
=
false
this
.
uploadFileEvent
=
null
this
.
el
=
yo
`
this
.
el
=
yo
`
<div id="fileExplorerView">
<div id="fileExplorerView">
</div>
</div>
...
@@ -99,6 +101,26 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -99,6 +101,26 @@ module.exports = class Filepanel extends ViewPlugin {
this
.
renderComponent
()
this
.
renderComponent
()
}
}
createNewFile
()
{
this
.
displayNewFile
=
true
this
.
renderComponent
()
}
resetNewFile
()
{
this
.
displayNewFile
=
false
this
.
renderComponent
()
}
uploadFile
(
target
)
{
this
.
uploadFileEvent
=
target
this
.
renderComponent
()
}
resetUploadFile
()
{
this
.
uploadFileEvent
=
null
this
.
renderComponent
()
}
render
()
{
render
()
{
return
this
.
el
return
this
.
el
}
}
...
@@ -132,6 +154,8 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -132,6 +154,8 @@ module.exports = class Filepanel extends ViewPlugin {
plugin
=
{
this
}
plugin
=
{
this
}
focusRoot
=
{
this
.
reset
}
focusRoot
=
{
this
.
reset
}
contextMenuItems
=
{
this
.
registeredMenuItems
}
contextMenuItems
=
{
this
.
registeredMenuItems
}
displayInput
=
{
this
.
displayNewFile
}
externalUploads
=
{
this
.
uploadFileEvent
}
/
>
/
>
<
/div
>
<
/div
>
<
div
className
=
'pl-2 filesystemexplorer remixui_treeview'
>
<
div
className
=
'pl-2 filesystemexplorer remixui_treeview'
>
...
...
apps/remix-ide/src/app/ui/landing-page/landing-page.js
View file @
a5198dbf
...
@@ -281,9 +281,13 @@ export class LandingPage extends ViewPlugin {
...
@@ -281,9 +281,13 @@ export class LandingPage extends ViewPlugin {
}
}
const
createNewFile
=
()
=>
{
const
createNewFile
=
()
=>
{
const
fileExplorer
=
globalRegistry
.
get
(
'fileexplorer/browser'
).
api
this
.
call
(
'fileExplorers'
,
'createNewFile'
)
fileExplorer
.
createNewFile
()
}
}
const
uploadFile
=
(
target
)
=>
{
this
.
call
(
'fileExplorers'
,
'uploadFile'
,
target
)
}
const
connectToLocalhost
=
()
=>
{
const
connectToLocalhost
=
()
=>
{
this
.
appManager
.
activatePlugin
(
'remixd'
)
this
.
appManager
.
activatePlugin
(
'remixd'
)
}
}
...
@@ -382,8 +386,7 @@ export class LandingPage extends ViewPlugin {
...
@@ -382,8 +386,7 @@ export class LandingPage extends ViewPlugin {
<input title="open file" type="file" onchange="
${
<input title="open file" type="file" onchange="
${
(
event
)
=>
{
(
event
)
=>
{
event
.
stopPropagation
()
event
.
stopPropagation
()
const
fileExplorer
=
globalRegistry
.
get
(
'fileexplorer/browser'
).
api
uploadFile
(
event
.
target
)
fileExplorer
.
uploadFile
(
event
)
}
}
}
" multiple />
}
" multiple />
</label>
</label>
...
...
libs/remix-ui/file-explorer/src/lib/file-explorer-menu.tsx
View file @
a5198dbf
...
@@ -60,6 +60,7 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => {
...
@@ -60,6 +60,7 @@ export const FileExplorerMenu = (props: FileExplorerMenuProps) => {
<
input
id=
"fileUpload"
data
-
id=
"fileExplorerFileUpload"
type=
"file"
onChange=
{
(
e
)
=>
{
<
input
id=
"fileUpload"
data
-
id=
"fileExplorerFileUpload"
type=
"file"
onChange=
{
(
e
)
=>
{
e
.
stopPropagation
()
e
.
stopPropagation
()
props
.
uploadFile
(
e
.
target
)
props
.
uploadFile
(
e
.
target
)
e
.
target
.
value
=
null
}
}
}
}
multiple
/>
multiple
/>
</
label
>
</
label
>
...
...
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
a5198dbf
...
@@ -16,7 +16,7 @@ import './css/file-explorer.css'
...
@@ -16,7 +16,7 @@ import './css/file-explorer.css'
const
queryParams
=
new
QueryParams
()
const
queryParams
=
new
QueryParams
()
export
const
FileExplorer
=
(
props
:
FileExplorerProps
)
=>
{
export
const
FileExplorer
=
(
props
:
FileExplorerProps
)
=>
{
const
{
filesProvider
,
name
,
registry
,
plugin
,
focusRoot
,
contextMenuItems
}
=
props
const
{
filesProvider
,
name
,
registry
,
plugin
,
focusRoot
,
contextMenuItems
,
displayInput
,
externalUploads
}
=
props
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
focusElement
:
[{
focusElement
:
[{
key
:
name
,
key
:
name
,
...
@@ -182,6 +182,20 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -182,6 +182,20 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
},
[
contextMenuItems
])
},
[
contextMenuItems
])
useEffect
(()
=>
{
if
(
displayInput
)
{
handleNewFileInput
()
plugin
.
resetNewFile
()
}
},
[
displayInput
])
useEffect
(()
=>
{
if
(
externalUploads
)
{
uploadFile
(
externalUploads
)
plugin
.
resetUploadFile
()
}
},
[
externalUploads
])
const
resolveDirectory
=
async
(
folderPath
,
dir
:
File
[],
isChild
=
false
):
Promise
<
File
[]
>
=>
{
const
resolveDirectory
=
async
(
folderPath
,
dir
:
File
[],
isChild
=
false
):
Promise
<
File
[]
>
=>
{
if
(
!
isChild
&&
(
state
.
focusEdit
.
element
===
'browser/blank'
)
&&
state
.
focusEdit
.
isNew
&&
(
dir
.
findIndex
(({
path
})
=>
path
===
'browser/blank'
)
===
-
1
))
{
if
(
!
isChild
&&
(
state
.
focusEdit
.
element
===
'browser/blank'
)
&&
state
.
focusEdit
.
isNew
&&
(
dir
.
findIndex
(({
path
})
=>
path
===
'browser/blank'
)
===
-
1
))
{
dir
=
state
.
focusEdit
.
type
===
'file'
?
[...
dir
,
{
dir
=
state
.
focusEdit
.
type
===
'file'
?
[...
dir
,
{
...
@@ -454,8 +468,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -454,8 +468,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
// pick that up via the 'fileAdded' event from the files module.
// pick that up via the 'fileAdded' event from the files module.
[...
target
.
files
].
forEach
((
file
)
=>
{
[...
target
.
files
].
forEach
((
file
)
=>
{
const
files
=
filesProvider
const
loadFile
=
(
name
:
string
):
void
=>
{
const
loadFile
=
(
name
:
string
):
void
=>
{
const
fileReader
=
new
FileReader
()
const
fileReader
=
new
FileReader
()
...
@@ -467,7 +479,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -467,7 +479,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
},
null
)
},
null
)
return
return
}
}
const
success
=
await
files
.
set
(
name
,
event
.
target
.
result
)
const
success
=
await
files
Provider
.
set
(
name
,
event
.
target
.
result
)
if
(
!
success
)
{
if
(
!
success
)
{
modal
(
'File Upload Failed'
,
'Failed to create file '
+
name
,
{
modal
(
'File Upload Failed'
,
'Failed to create file '
+
name
,
{
...
@@ -478,9 +490,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -478,9 +490,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
fileReader
.
readAsText
(
file
)
fileReader
.
readAsText
(
file
)
}
}
const
name
=
files
.
type
+
'/'
+
file
.
name
const
name
=
files
Provider
.
type
+
'/'
+
file
.
name
files
.
exists
(
name
,
(
error
,
exist
)
=>
{
files
Provider
.
exists
(
name
,
(
error
,
exist
)
=>
{
if
(
error
)
console
.
log
(
error
)
if
(
error
)
console
.
log
(
error
)
if
(
!
exist
)
{
if
(
!
exist
)
{
loadFile
(
name
)
loadFile
(
name
)
...
...
libs/remix-ui/file-explorer/src/lib/types/index.ts
View file @
a5198dbf
...
@@ -6,7 +6,9 @@ export interface FileExplorerProps {
...
@@ -6,7 +6,9 @@ export interface FileExplorerProps {
menuItems
?:
string
[],
menuItems
?:
string
[],
plugin
:
any
,
plugin
:
any
,
focusRoot
:
boolean
,
focusRoot
:
boolean
,
contextMenuItems
:
{
name
:
string
,
type
:
string
[],
path
:
string
[],
extension
:
string
[],
pattern
:
string
[]
}[]
contextMenuItems
:
{
name
:
string
,
type
:
string
[],
path
:
string
[],
extension
:
string
[],
pattern
:
string
[]
}[],
displayInput
?:
boolean
,
externalUploads
?:
EventTarget
&
HTMLInputElement
}
}
export
interface
File
{
export
interface
File
{
...
...
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