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
c419968c
Unverified
Commit
c419968c
authored
May 26, 2021
by
David Disu
Committed by
GitHub
May 26, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1222 from ethereum/multi-paste
Allow multiple pasting of files and folders with non-clashing names.
parents
9db9476d
02b141c2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
9 deletions
+21
-9
fileManager_api.spec.ts
apps/remix-ide-e2e/src/tests/fileManager_api.spec.ts
+2
-2
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+5
-3
helper.js
apps/remix-ide/src/lib/helper.js
+14
-0
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+0
-4
No files found.
apps/remix-ide-e2e/src/tests/fileManager_api.spec.ts
View file @
c419968c
...
@@ -147,8 +147,8 @@ const executeReadFile = `
...
@@ -147,8 +147,8 @@ const executeReadFile = `
const
executeCopyFile
=
`
const
executeCopyFile
=
`
const run = async () => {
const run = async () => {
await remix.call('fileManager', 'copyFile', 'contracts/3_Ballot.sol', '/', '
new
_contract.sol')
await remix.call('fileManager', 'copyFile', 'contracts/3_Ballot.sol', '/', '
copy
_contract.sol')
const result = await remix.call('fileManager', 'readFile', '
new
_contract.sol')
const result = await remix.call('fileManager', 'readFile', '
copy
_contract.sol')
console.log(result)
console.log(result)
}
}
...
...
apps/remix-ide/src/app/files/fileManager.js
View file @
c419968c
...
@@ -222,9 +222,10 @@ class FileManager extends Plugin {
...
@@ -222,9 +222,10 @@ class FileManager extends Plugin {
await
this
.
_handleExists
(
dest
,
`Cannot paste content into
${
dest
}
. Path does not exist.`
)
await
this
.
_handleExists
(
dest
,
`Cannot paste content into
${
dest
}
. Path does not exist.`
)
await
this
.
_handleIsDir
(
dest
,
`Cannot paste content into
${
dest
}
. Path is not directory.`
)
await
this
.
_handleIsDir
(
dest
,
`Cannot paste content into
${
dest
}
. Path is not directory.`
)
const
content
=
await
this
.
readFile
(
src
)
const
content
=
await
this
.
readFile
(
src
)
const
copiedFileName
=
customName
?
'/'
+
customName
:
'/'
+
`Copy_
${
helper
.
extractNameFromKey
(
src
)}
`
let
copiedFilePath
=
dest
+
(
customName
?
'/'
+
customName
:
'/'
+
`Copy_
${
helper
.
extractNameFromKey
(
src
)}
`
)
copiedFilePath
=
await
helper
.
createNonClashingNameAsync
(
copiedFilePath
,
this
)
await
this
.
writeFile
(
dest
+
copiedFileName
,
content
)
await
this
.
writeFile
(
copiedFilePath
,
content
)
}
catch
(
e
)
{
}
catch
(
e
)
{
throw
new
Error
(
e
)
throw
new
Error
(
e
)
}
}
...
@@ -252,7 +253,8 @@ class FileManager extends Plugin {
...
@@ -252,7 +253,8 @@ class FileManager extends Plugin {
async
inDepthCopy
(
src
,
dest
,
count
=
0
)
{
async
inDepthCopy
(
src
,
dest
,
count
=
0
)
{
const
content
=
await
this
.
readdir
(
src
)
const
content
=
await
this
.
readdir
(
src
)
const
copiedFolderPath
=
count
===
0
?
dest
+
'/'
+
`Copy_
${
helper
.
extractNameFromKey
(
src
)}
`
:
dest
+
'/'
+
helper
.
extractNameFromKey
(
src
)
let
copiedFolderPath
=
count
===
0
?
dest
+
'/'
+
`Copy_
${
helper
.
extractNameFromKey
(
src
)}
`
:
dest
+
'/'
+
helper
.
extractNameFromKey
(
src
)
copiedFolderPath
=
await
helper
.
createNonClashingDirNameAsync
(
copiedFolderPath
,
this
)
await
this
.
mkdir
(
copiedFolderPath
)
await
this
.
mkdir
(
copiedFolderPath
)
...
...
apps/remix-ide/src/lib/helper.js
View file @
c419968c
...
@@ -71,6 +71,20 @@ module.exports = {
...
@@ -71,6 +71,20 @@ module.exports = {
return
name
+
counter
+
prefix
+
'.'
+
ext
return
name
+
counter
+
prefix
+
'.'
+
ext
},
},
async
createNonClashingDirNameAsync
(
name
,
fileManager
)
{
if
(
!
name
)
name
=
'Undefined'
let
counter
=
''
let
exist
=
true
do
{
const
isDuplicate
=
await
fileManager
.
exists
(
name
+
counter
)
if
(
isDuplicate
)
counter
=
(
counter
|
0
)
+
1
else
exist
=
false
}
while
(
exist
)
return
name
+
counter
},
checkSpecialChars
(
name
)
{
checkSpecialChars
(
name
)
{
return
name
.
match
(
/
[
:*?"<>
\\
'|
]
/
)
!=
null
return
name
.
match
(
/
[
:*?"<>
\\
'|
]
/
)
!=
null
},
},
...
...
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
c419968c
...
@@ -763,10 +763,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -763,10 +763,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
state
.
copyElement
.
map
(({
key
,
type
})
=>
{
state
.
copyElement
.
map
(({
key
,
type
})
=>
{
type
===
'file'
?
copyFile
(
key
,
dest
)
:
copyFolder
(
key
,
dest
)
type
===
'file'
?
copyFile
(
key
,
dest
)
:
copyFolder
(
key
,
dest
)
})
})
setState
(
prevState
=>
{
return
{
...
prevState
,
copyElement
:
[]
}
})
setCanPaste
(
false
)
}
}
const
label
=
(
file
:
File
)
=>
{
const
label
=
(
file
:
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