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
fa1188e9
Commit
fa1188e9
authored
Feb 11, 2021
by
ioedeveloper
Committed by
GitHub
Feb 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug clashing names
parent
05f6f0ca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+7
-2
helper.js
apps/remix-ide/src/lib/helper.js
+1
-0
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+9
-4
No files found.
apps/remix-ide/src/app/files/fileManager.js
View file @
fa1188e9
...
@@ -100,13 +100,18 @@ class FileManager extends Plugin {
...
@@ -100,13 +100,18 @@ class FileManager extends Plugin {
* @param {string} path path of the directory or file
* @param {string} path path of the directory or file
* @returns {boolean} true if the path exists
* @returns {boolean} true if the path exists
*/
*/
exists
(
path
)
{
async
exists
(
path
,
type
)
{
const
provider
=
this
.
fileProviderOf
(
path
)
const
provider
=
this
.
fileProviderOf
(
path
)
const
result
=
provider
.
exists
(
path
,
(
err
,
result
)
=>
{
const
result
=
await
provider
.
exists
(
path
,
(
err
,
result
)
=>
{
if
(
err
)
return
false
if
(
err
)
return
false
return
result
return
result
})
})
if
(
type
===
'file'
)
{
return
result
&&
await
this
.
isFile
(
path
)
}
else
if
(
type
===
'folder'
)
{
return
result
&&
await
this
.
isDirectory
(
path
)
}
return
result
return
result
}
}
...
...
apps/remix-ide/src/lib/helper.js
View file @
fa1188e9
...
@@ -37,6 +37,7 @@ module.exports = {
...
@@ -37,6 +37,7 @@ module.exports = {
()
=>
{
return
exist
},
()
=>
{
return
exist
},
(
callback
)
=>
{
(
callback
)
=>
{
fileProvider
.
exists
(
name
+
counter
+
prefix
+
'.'
+
ext
,
(
error
,
currentExist
)
=>
{
fileProvider
.
exists
(
name
+
counter
+
prefix
+
'.'
+
ext
,
(
error
,
currentExist
)
=>
{
console
.
log
(
'currentExists: '
,
currentExist
)
if
(
error
)
{
if
(
error
)
{
callback
(
error
)
callback
(
error
)
}
else
{
}
else
{
...
...
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
fa1188e9
...
@@ -311,6 +311,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -311,6 +311,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
const
fileManager
=
state
.
fileManager
const
fileManager
=
state
.
fileManager
helper
.
createNonClashingName
(
newFilePath
,
filesProvider
,
async
(
error
,
newName
)
=>
{
helper
.
createNonClashingName
(
newFilePath
,
filesProvider
,
async
(
error
,
newName
)
=>
{
console
.
log
(
'newFilePath: '
,
newFilePath
)
console
.
log
(
'newName: '
,
newName
)
if
(
error
)
{
if
(
error
)
{
modal
(
'Create File Failed'
,
error
,
{
modal
(
'Create File Failed'
,
error
,
{
label
:
'Close'
,
label
:
'Close'
,
...
@@ -336,7 +338,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -336,7 +338,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
const
dirName
=
newFolderPath
+
'/'
const
dirName
=
newFolderPath
+
'/'
try
{
try
{
const
exists
=
await
fileManager
.
exists
(
dirName
)
const
exists
=
await
fileManager
.
exists
(
dirName
,
'folder'
)
console
.
log
(
'exists: '
,
exists
)
if
(
exists
)
return
if
(
exists
)
return
await
fileManager
.
mkdir
(
dirName
)
await
fileManager
.
mkdir
(
dirName
)
...
@@ -372,10 +375,11 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -372,10 +375,11 @@ export const FileExplorer = (props: FileExplorerProps) => {
})
})
}
}
const
renamePath
=
async
(
oldPath
:
string
,
newPath
:
string
)
=>
{
const
renamePath
=
async
(
oldPath
:
string
,
newPath
:
string
,
type
?:
string
)
=>
{
try
{
try
{
const
fileManager
=
state
.
fileManager
const
fileManager
=
state
.
fileManager
const
exists
=
await
fileManager
.
exists
(
newPath
)
const
exists
=
await
fileManager
.
exists
(
newPath
,
type
)
console
.
log
(
'exists: '
,
exists
)
if
(
exists
)
{
if
(
exists
)
{
modal
(
'Rename File Failed'
,
'File name already exists'
,
{
modal
(
'Rename File Failed'
,
'File name already exists'
,
{
...
@@ -814,9 +818,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -814,9 +818,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
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
)
const
type
:
string
=
state
.
focusEdit
.
type
editRef
.
current
.
textContent
=
extractNameFromKey
(
oldPath
)
editRef
.
current
.
textContent
=
extractNameFromKey
(
oldPath
)
renamePath
(
oldPath
,
newPath
)
renamePath
(
oldPath
,
newPath
,
type
)
}
}
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
return
{
...
prevState
,
focusEdit
:
{
element
:
null
,
isNew
:
false
,
type
:
''
,
lastEdit
:
''
}
}
...
...
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