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
ecda8a37
Commit
ecda8a37
authored
Jun 28, 2019
by
LianaHus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code refactoring (Yann, Liana)
parent
0d369491
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
fileManager.js
src/app/files/fileManager.js
+21
-27
No files found.
src/app/files/fileManager.js
View file @
ecda8a37
...
@@ -137,22 +137,14 @@ class FileManager extends FileSystemApi {
...
@@ -137,22 +137,14 @@ class FileManager extends FileSystemApi {
async
setFile
(
path
,
content
)
{
async
setFile
(
path
,
content
)
{
if
(
this
.
currentRequest
)
{
if
(
this
.
currentRequest
)
{
let
reject
=
false
let
reject
=
false
let
savedAsCopy
=
false
let
saveAsCopy
=
false
let
accept
=
false
let
actions
=
(
toaster
)
=>
{
return
yo
`
let
actions
=
(
toaster
)
=>
{
return
yo
`
<div class="container ml-1">
<div class="container ml-1">
<button class="btn btn-primary btn-sm m-1" onclick=
${(
e
)
=>
{
<button class="btn btn-primary btn-sm m-1" onclick=
${(
e
)
=>
{
accept
=
tru
e
;
reject
=
fals
e
;
e
.
target
.
innerHTML
=
'Accepted'
;
e
.
target
.
innerHTML
=
'Accepted'
;
const
fileProvider
=
this
.
fileProviderOf
(
path
)
toaster
.
hide
();
if
(
!
fileProvider
)
return
toaster
.
forceResolve
()
if
(
!
fileProvider
.
set
(
path
,
content
))
{
return
modalDialogCustom
.
alert
(
'Failed to create a file '
+
path
)
}
this
.
syncEditor
(
path
)
this
.
switchFile
(
path
)
toaster
.
hide
()
}}
>
}}
>
Accept
Accept
<
/button
>
<
/button
>
...
@@ -164,36 +156,38 @@ class FileManager extends FileSystemApi {
...
@@ -164,36 +156,38 @@ class FileManager extends FileSystemApi {
Cancel
Cancel
<
/button
>
<
/button
>
<
button
class
=
"btn btn-primary btn-sm m-1"
onclick
=
$
{(
e
)
=>
{
<
button
class
=
"btn btn-primary btn-sm m-1"
onclick
=
$
{(
e
)
=>
{
if
(
savedAsCopy
)
return
if
(
saveAsCopy
)
return
savedAsCopy
=
true
const
fileProvider
=
this
.
fileProviderOf
(
path
)
const
fileProvider
=
this
.
fileProviderOf
(
path
)
if
(
!
fileProvider
)
return
if
(
fileProvider
)
{
helper
.
createNonClashingNameWithPrefix
(
path
,
fileProvider
,
''
,
(
error
,
newFile
)
=>
{
helper
.
createNonClashingNameWithPrefix
(
path
,
fileProvider
,
''
,
(
error
,
copyName
)
=>
{
if
(
error
)
return
modalDialogCustom
.
alert
(
'Failed to create file. '
+
newFile
+
' '
+
error
)
if
(
error
)
{
if
(
!
fileProvider
.
set
(
newFile
,
content
))
return
modalDialogCustom
.
alert
(
'Failed to create a file '
+
newFile
)
console
.
log
(
'createNonClashingNameWithPrefix'
,
error
)
this
.
switchFile
(
newFile
)
copyName
=
path
+
'.'
+
this
.
currentRequest
.
from
this
.
syncEditor
(
path
)
}
this
.
_setFileInternal
(
copyName
,
content
)
this
.
switchFile
(
copyName
)
})
})
}
e
.
target
.
innerHTML
=
'Saved'
e
.
target
.
innerHTML
=
'Saved'
saveAsCopy
=
true
toaster
.
hide
()
toaster
.
hide
()
}}
>
}}
>
Save
As
Copy
Save
As
Copy
<
/button
>
<
/button
>
<
/div
>
<
/div
>
`
`}
}
await toaster(yo`
await toaster(yo`
<
div
>
<
div
>
<
i
class
=
"fas fa-exclamation-triangle text-danger mr-1"
><
/i
>
<
i
class
=
"fas fa-exclamation-triangle text-danger mr-1"
><
/i
>
<
span
>
<
span
>
$
{
this
.
currentRequest
.
from
}
<span class="text-danger"> is trying to modify </span>
${
path
}
$
{
this
.
currentRequest
.
from
}
<span class="text-danger
font-weight-bold
"> is trying to modify </span>
${
path
}
</span>
</span>
</div>
</div>
`
,
actions
,
{
time
:
4
000
})
`
,
actions
,
{
time
:
5
000
})
if
(
reject
)
throw
new
Error
(
`set file operation on
${
path
}
aborted by user.`
)
if
(
reject
)
throw
new
Error
(
`set file operation on
${
path
}
aborted by user.`
)
if
(
accept
||
savedAsCopy
)
return
if
(
saveAsCopy
)
return
else
this
.
_setFileInternal
(
path
,
content
)
}
}
this
.
_setFileInternal
(
path
,
content
)
}
}
_setFileInternal
(
path
,
content
)
{
_setFileInternal
(
path
,
content
)
{
...
...
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