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
28cae6bf
Commit
28cae6bf
authored
Jun 30, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed failing publish to IPFS test
parent
d6ff40db
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
186 additions
and
115 deletions
+186
-115
getModalBody.ts
apps/remix-ide-e2e/src/commands/getModalBody.ts
+1
-1
publishContract.test.ts
apps/remix-ide-e2e/src/tests/publishContract.test.ts
+20
-10
publish-to-storage.tsx
...emix-ui/publish-to-storage/src/lib/publish-to-storage.tsx
+2
-2
compiler.ts
libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts
+42
-25
compiler-container.tsx
...remix-ui/solidity-compiler/src/lib/compiler-container.tsx
+88
-55
compiler.ts
libs/remix-ui/solidity-compiler/src/lib/reducers/compiler.ts
+33
-22
No files found.
apps/remix-ide-e2e/src/commands/getModalBody.ts
View file @
28cae6bf
...
@@ -3,7 +3,7 @@ import EventEmitter from 'events'
...
@@ -3,7 +3,7 @@ import EventEmitter from 'events'
class
GetModalBody
extends
EventEmitter
{
class
GetModalBody
extends
EventEmitter
{
command
(
this
:
NightwatchBrowser
,
callback
:
(
value
:
string
,
cb
:
VoidFunction
)
=>
void
)
{
command
(
this
:
NightwatchBrowser
,
callback
:
(
value
:
string
,
cb
:
VoidFunction
)
=>
void
)
{
this
.
api
.
waitForElement
Present
(
'.modal-body
'
)
this
.
api
.
waitForElement
Visible
(
'[data-id="modalDialogModalBody"]
'
)
.
getText
(
'#modal-dialog'
,
(
result
)
=>
{
.
getText
(
'#modal-dialog'
,
(
result
)
=>
{
console
.
log
(
result
)
console
.
log
(
result
)
const
value
=
typeof
result
.
value
===
'string'
?
result
.
value
:
null
const
value
=
typeof
result
.
value
===
'string'
?
result
.
value
:
null
...
...
apps/remix-ide-e2e/src/tests/publishContract.test.ts
View file @
28cae6bf
...
@@ -20,24 +20,33 @@ module.exports = {
...
@@ -20,24 +20,33 @@ module.exports = {
.
verifyContracts
([
'Ballot'
])
.
verifyContracts
([
'Ballot'
])
.
click
(
'#publishOnIpfs'
)
.
click
(
'#publishOnIpfs'
)
.
pause
(
8000
)
.
pause
(
8000
)
.
getModalBody
((
value
,
done
)
=>
{
.
waitForElementVisible
(
'[data-id="publishToStorageModalDialogModalBody-react"]'
,
60000
)
if
(
value
.
indexOf
(
'Metadata of "ballot" was published successfully.'
)
===
-
1
)
browser
.
assert
.
fail
(
'ipfs deploy failed'
,
''
,
''
)
.
getText
(
'[data-id="publishToStorageModalDialogModalBody-react"]'
,
(
result
)
=>
{
if
(
value
.
indexOf
(
'ipfs://'
)
===
-
1
)
browser
.
assert
.
fail
(
'ipfs deploy failed'
,
''
,
''
)
const
value
=
<
string
>
(
result
.
value
)
done
()
browser
.
perform
((
done
)
=>
{
if
(
value
.
indexOf
(
'Metadata of "ballot" was published successfully.'
)
===
-
1
)
browser
.
assert
.
fail
(
'ipfs deploy failed'
)
// if (value.indexOf('ipfs://') === -1) browser.assert.fail('ipfs deploy failed')
done
()
})
})
})
.
modalFooterOKClick
(
)
.
click
(
'[data-id="publishToStorage-modal-footer-ok-react"]'
)
},
},
'Publish on Swarm'
:
''
+
function
(
browser
:
NightwatchBrowser
)
{
'Publish on Swarm'
:
''
+
function
(
browser
:
NightwatchBrowser
)
{
browser
browser
.
click
(
'#publishOnSwarm'
)
.
click
(
'#publishOnSwarm'
)
.
pause
(
8000
)
.
pause
(
8000
)
.
getModalBody
((
value
,
done
)
=>
{
.
getText
(
'[data-id="publishToStorageModalDialogModalBody-react"]'
,
(
result
)
=>
{
if
(
value
.
indexOf
(
'Metadata of "ballot" was successfully.'
)
===
-
1
)
browser
.
assert
.
fail
(
'swarm deploy failed'
,
''
,
''
)
const
value
=
<
string
>
(
result
.
value
)
if
(
value
.
indexOf
(
'bzz'
)
===
-
1
)
browser
.
assert
.
fail
(
'swarm deploy failed'
,
''
,
''
)
done
()
browser
.
perform
((
done
)
=>
{
if
(
value
.
indexOf
(
'Metadata of "ballot" was published successfully.'
)
===
-
1
)
browser
.
assert
.
fail
(
'swarm deploy failed'
)
if
(
value
.
indexOf
(
'bzz'
)
===
-
1
)
browser
.
assert
.
fail
(
'swarm deploy failed'
)
done
()
})
})
})
.
modalFooterOKClick
(
)
.
click
(
'[data-id="publishToStorage-modal-footer-ok-react"]'
)
},
},
'Should publish contract metadata to ipfs on deploy'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should publish contract metadata to ipfs on deploy'
:
function
(
browser
:
NightwatchBrowser
)
{
...
@@ -48,6 +57,7 @@ module.exports = {
...
@@ -48,6 +57,7 @@ module.exports = {
.
clickLaunchIcon
(
'udapp'
)
.
clickLaunchIcon
(
'udapp'
)
.
waitForElementPresent
(
'*[data-id="contractDropdownIpfsCheckbox"]'
)
.
waitForElementPresent
(
'*[data-id="contractDropdownIpfsCheckbox"]'
)
.
click
(
'*[data-id="contractDropdownIpfsCheckbox"]'
)
.
click
(
'*[data-id="contractDropdownIpfsCheckbox"]'
)
.
waitForElementVisible
(
'*[data-id="Deploy - transact (not payable)"]'
)
.
click
(
'*[data-id="Deploy - transact (not payable)"]'
)
.
click
(
'*[data-id="Deploy - transact (not payable)"]'
)
.
pause
(
8000
)
.
pause
(
8000
)
.
getModalBody
((
value
,
done
)
=>
{
.
getModalBody
((
value
,
done
)
=>
{
...
...
libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx
View file @
28cae6bf
...
@@ -56,7 +56,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
...
@@ -56,7 +56,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
},
[
storage
])
},
[
storage
])
const
publishMessage
=
(
uploaded
)
=>
(
const
publishMessage
=
(
uploaded
)
=>
(
<
span
>
Metadata of
{
contract
.
name
.
toLowerCase
()
}
was published successfully.
<
br
/>
<
span
>
Metadata of
"
{
contract
.
name
.
toLowerCase
()
}
"
was published successfully.
<
br
/>
<
pre
>
<
pre
>
<
div
>
<
div
>
{
uploaded
.
map
((
value
,
index
)
=>
<
div
key=
{
index
}
><
b
>
{
value
.
filename
}
</
b
>
:
<
pre
>
{
value
.
output
.
url
}
</
pre
></
div
>)
}
{
uploaded
.
map
((
value
,
index
)
=>
<
div
key=
{
index
}
><
b
>
{
value
.
filename
}
</
b
>
:
<
pre
>
{
value
.
output
.
url
}
</
pre
></
div
>)
}
...
@@ -94,7 +94,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
...
@@ -94,7 +94,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
return
(
return
(
<
ModalDialog
<
ModalDialog
id=
'publishToStorage
ModalDialog
'
id=
'publishToStorage'
title=
{
state
.
modal
.
title
}
title=
{
state
.
modal
.
title
}
message=
{
state
.
modal
.
message
}
message=
{
state
.
modal
.
message
}
hide=
{
state
.
modal
.
hide
}
hide=
{
state
.
modal
.
hide
}
...
...
libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts
View file @
28cae6bf
import
React
from
'react'
import
React
from
'react'
const
queuedEvents
=
[]
export
const
setEditorMode
=
(
mode
:
string
)
=>
{
const
pendingEvents
=
{}
let
provider
=
null
let
plugin
=
null
let
dispatch
:
React
.
Dispatch
<
any
>
=
null
export
const
fetchCompilerError
=
(
error
:
any
)
=>
{
return
{
return
{
type
:
'
FETCH_COMPILER_ERROR
'
,
type
:
'
SET_EDITOR_MODE
'
,
payload
:
error
payload
:
mode
}
}
}
}
export
const
fetchCompilerRequest
=
(
promise
:
Promise
<
any
>
)
=>
{
export
const
resetEditorMode
=
()
=>
(
dispatch
:
React
.
Dispatch
<
any
>
)
=>
{
return
{
dispatch
({
type
:
'FETCH_COMPILER_REQUEST'
,
type
:
'RESET_EDITOR_MODE'
payload
:
promise
})
}
}
}
export
const
fetchCompilerSuccess
=
(
compiler
)
=>
{
export
const
setCompilerMode
=
(
mode
:
string
,
...
args
)
=>
{
return
{
return
{
type
:
'
FETCH_COMPILER_SUCCESS
'
,
type
:
'
SET_COMPILER_MODE
'
,
payload
:
compiler
payload
:
{
mode
,
args
}
}
}
}
}
export
const
fetchCompiler
=
(
provider
,
path
:
string
)
=>
(
dispatch
:
React
.
Dispatch
<
any
>
)
=>
{
export
const
resetCompilerMode
=
()
=>
(
dispatch
:
React
.
Dispatch
<
any
>
)
=>
{
const
promise
=
fetchDirectoryContent
(
provider
,
path
)
dispatch
({
type
:
'RESET_COMPILER_MODE'
})
}
export
const
listenToEvents
=
(
editor
,
compileTabLogic
)
=>
(
dispatch
:
React
.
Dispatch
<
any
>
)
=>
{
editor
.
event
.
register
(
'sessionSwitched'
,
()
=>
{
dispatch
(
setEditorMode
(
'sessionSwitched'
))
})
compileTabLogic
.
event
.
on
(
'startingCompilation'
,
()
=>
{
dispatch
(
setCompilerMode
(
'startingCompilation'
))
})
compileTabLogic
.
compiler
.
event
.
register
(
'compilationDuration'
,
(
speed
)
=>
{
dispatch
(
setCompilerMode
(
'compilationDuration'
,
speed
))
})
editor
.
event
.
register
(
'contentChanged'
,
()
=>
{
dispatch
(
setEditorMode
(
'contentChanged'
))
})
compileTabLogic
.
compiler
.
event
.
register
(
'loadingCompiler'
,
()
=>
{
dispatch
(
setCompilerMode
(
'compilationDuration'
))
})
compileTabLogic
.
compiler
.
event
.
register
(
'compilerLoaded'
,
()
=>
{
dispatch
(
setCompilerMode
(
'compilerLoaded'
))
})
dispatch
(
fetchDirectoryRequest
(
promise
))
compileTabLogic
.
compiler
.
event
.
register
(
'compilationFinished'
,
(
success
,
data
,
source
)
=>
{
promise
.
then
((
files
)
=>
{
dispatch
(
setCompilerMode
(
'compilationFinished'
,
success
,
data
,
source
))
dispatch
(
fetchDirectorySuccess
(
path
,
files
))
}).
catch
((
error
)
=>
{
dispatch
(
fetchDirectoryError
({
error
}))
})
})
return
promise
}
}
libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
View file @
28cae6bf
import
React
,
{
useEffect
,
useState
,
useRef
}
from
'react'
// eslint-disable-line
import
React
,
{
useEffect
,
useState
,
useRef
,
useReducer
}
from
'react'
// eslint-disable-line
import
semver
from
'semver'
import
semver
from
'semver'
import
{
CompilerContainerProps
}
from
'./types'
import
{
CompilerContainerProps
}
from
'./types'
import
*
as
helper
from
'../../../../../apps/remix-ide/src/lib/helper'
import
*
as
helper
from
'../../../../../apps/remix-ide/src/lib/helper'
import
{
canUseWorker
,
baseURLBin
,
baseURLWasm
,
urlFromVersion
,
pathToURL
,
promisedMiniXhr
}
from
'../../../../../apps/remix-ide/src/app/compiler/compiler-utils'
// eslint-disable-line
import
{
canUseWorker
,
baseURLBin
,
baseURLWasm
,
urlFromVersion
,
pathToURL
,
promisedMiniXhr
}
from
'../../../../../apps/remix-ide/src/app/compiler/compiler-utils'
// eslint-disable-line
import
{
compilerReducer
,
compilerInitialState
}
from
'./reducers/compiler'
import
{
resetCompilerMode
,
resetEditorMode
,
listenToEvents
}
from
'./actions/compiler'
import
'./css/style.css'
import
'./css/style.css'
...
@@ -29,6 +31,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
...
@@ -29,6 +31,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const
warningIcon
=
useRef
(
null
)
const
warningIcon
=
useRef
(
null
)
const
promptMessageInput
=
useRef
(
null
)
const
promptMessageInput
=
useRef
(
null
)
const
[
hhCompilation
,
sethhCompilation
]
=
useState
(
false
)
const
[
hhCompilation
,
sethhCompilation
]
=
useState
(
false
)
const
[
compilerContainer
,
dispatch
]
=
useReducer
(
compilerReducer
,
compilerInitialState
)
useEffect
(()
=>
{
useEffect
(()
=>
{
fetchAllVersion
((
allversions
,
selectedVersion
,
isURL
)
=>
{
fetchAllVersion
((
allversions
,
selectedVersion
,
isURL
)
=>
{
...
@@ -47,12 +50,11 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
...
@@ -47,12 +50,11 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const
currentFileName
=
config
.
get
(
'currentFile'
)
const
currentFileName
=
config
.
get
(
'currentFile'
)
currentFile
(
currentFileName
)
currentFile
(
currentFileName
)
listenToEvents
()
listenToEvents
(
editor
,
compileTabLogic
)(
dispatch
)
},
[])
},
[])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
compileTabLogic
&&
compileTabLogic
.
compiler
)
{
if
(
compileTabLogic
&&
compileTabLogic
.
compiler
)
{
compileTabLogic
.
compiler
.
event
.
register
(
'compilerLoaded'
,
compilerLoaded
)
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
return
{
...
prevState
,
...
prevState
,
...
@@ -71,13 +73,47 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
...
@@ -71,13 +73,47 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
})
})
},
[
compiledFileName
])
},
[
compiledFileName
])
const
compilerLoaded
=
(
version
:
string
)
=>
{
useEffect
(()
=>
{
setVersionText
(
version
)
if
(
compilerContainer
.
compiler
.
mode
)
{
}
switch
(
compilerContainer
.
compiler
.
mode
)
{
case
'startingCompilation'
:
startingCompilation
()
resetCompilerMode
()(
dispatch
)
break
case
'compilationDuration'
:
compilationDuration
(
compilerContainer
.
compiler
.
args
)
resetCompilerMode
()(
dispatch
)
break
case
'loadingCompiler'
:
loadingCompiler
()
resetCompilerMode
()(
dispatch
)
break
case
'compilerLoaded'
:
compilerLoaded
()
resetCompilerMode
()(
dispatch
)
break
case
'compilationFinished'
:
compilationFinished
(
compilerContainer
.
compiler
.
args
)
resetCompilerMode
()(
dispatch
)
break
}
}
},
[
compilerContainer
.
compiler
.
mode
])
const
setVersionText
=
(
text
)
=>
{
useEffect
(()
=>
{
// if (this._view.version) this._view.version.innerText = text
if
(
compilerContainer
.
editor
.
mode
)
{
}
switch
(
compilerContainer
.
editor
.
mode
)
{
case
'sessionSwitched'
:
sessionSwitched
()
resetEditorMode
()(
dispatch
)
break
case
'contentChanged'
:
contentChanged
()
resetEditorMode
()(
dispatch
)
break
}
}
},
[
compilerContainer
.
editor
.
mode
])
// fetching both normal and wasm builds and creating a [version, baseUrl] map
// fetching both normal and wasm builds and creating a [version, baseUrl] map
const
fetchAllVersion
=
async
(
callback
)
=>
{
const
fetchAllVersion
=
async
(
callback
)
=>
{
...
@@ -176,67 +212,64 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
...
@@ -176,67 +212,64 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
return
extention
.
toLowerCase
()
===
'sol'
||
extention
.
toLowerCase
()
===
'yul'
return
extention
.
toLowerCase
()
===
'sol'
||
extention
.
toLowerCase
()
===
'yul'
}
}
const
listenToEvents
=
()
=>
{
const
sessionSwitched
=
()
=>
{
editor
.
event
.
register
(
'sessionSwitched'
,
()
=>
{
if
(
!
compileIcon
.
current
)
return
if
(
!
compileIcon
.
current
)
return
scheduleCompilation
()
scheduleCompilation
()
}
})
compileTabLogic
.
event
.
on
(
'startingCompilation'
,
()
=>
{
const
startingCompilation
=
()
=>
{
if
(
!
compileIcon
.
current
)
return
if
(
!
compileIcon
.
current
)
return
compileIcon
.
current
.
setAttribute
(
'title'
,
'compiling...'
)
compileIcon
.
current
.
setAttribute
(
'title'
,
'compiling...'
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_bouncingIcon'
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_bouncingIcon'
)
compileIcon
.
current
.
classList
.
add
(
'remixui_spinningIcon'
)
compileIcon
.
current
.
classList
.
add
(
'remixui_spinningIcon'
)
})
}
compileTabLogic
.
compiler
.
event
.
register
(
'compilationDuration'
,
(
speed
)
=>
{
const
compilationDuration
=
({
speed
}
)
=>
{
if
(
!
warningIcon
.
current
)
return
if
(
!
warningIcon
.
current
)
return
if
(
speed
>
1000
)
{
if
(
speed
>
1000
)
{
const
msg
=
`Last compilation took
${
speed
}
ms. We suggest to turn off autocompilation.`
const
msg
=
`Last compilation took
${
speed
}
ms. We suggest to turn off autocompilation.`
warningIcon
.
current
.
setAttribute
(
'title'
,
msg
)
warningIcon
.
current
.
setAttribute
(
'title'
,
msg
)
warningIcon
.
current
.
style
.
visibility
=
'visible'
warningIcon
.
current
.
style
.
visibility
=
'visible'
}
else
{
}
else
{
warningIcon
.
current
.
style
.
visibility
=
'hidden'
warningIcon
.
current
.
style
.
visibility
=
'hidden'
}
}
})
}
editor
.
event
.
register
(
'contentChanged'
,
()
=>
{
const
contentChanged
=
()
=>
{
if
(
!
compileIcon
.
current
)
return
if
(
!
compileIcon
.
current
)
return
scheduleCompilation
()
scheduleCompilation
()
compileIcon
.
current
.
classList
.
add
(
'remixui_bouncingIcon'
)
// @TODO: compileView tab
compileIcon
.
current
.
classList
.
add
(
'remixui_bouncingIcon'
)
// @TODO: compileView tab
})
}
compileTabLogic
.
compiler
.
event
.
register
(
'loadingCompiler'
,
()
=>
{
const
loadingCompiler
=
()
=>
{
if
(
!
compileIcon
.
current
)
return
if
(
!
compileIcon
.
current
)
return
// _disableCompileBtn(true)
// _disableCompileBtn(true)
compileIcon
.
current
.
setAttribute
(
'title'
,
'compiler is loading, please wait a few moments.'
)
compileIcon
.
current
.
setAttribute
(
'title'
,
'compiler is loading, please wait a few moments.'
)
compileIcon
.
current
.
classList
.
add
(
'remixui_spinningIcon'
)
compileIcon
.
current
.
classList
.
add
(
'remixui_spinningIcon'
)
warningIcon
.
current
.
style
.
visibility
=
'hidden'
warningIcon
.
current
.
style
.
visibility
=
'hidden'
_updateLanguageSelector
()
_updateLanguageSelector
()
})
}
compileTabLogic
.
compiler
.
event
.
register
(
'compilerLoaded'
,
()
=>
{
const
compilerLoaded
=
()
=>
{
if
(
!
compileIcon
.
current
)
return
if
(
!
compileIcon
.
current
)
return
// _disableCompileBtn(false)
// _disableCompileBtn(false)
compileIcon
.
current
.
setAttribute
(
'title'
,
''
)
compileIcon
.
current
.
setAttribute
(
'title'
,
''
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_spinningIcon'
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_spinningIcon'
)
if
(
state
.
autoCompile
)
compile
()
if
(
state
.
autoCompile
)
compile
()
})
}
compileTabLogic
.
compiler
.
event
.
register
(
'compilationFinished'
,
(
success
,
data
,
source
)
=>
{
const
compilationFinished
=
({
success
,
data
,
source
}
)
=>
{
if
(
!
compileIcon
.
current
)
return
if
(
!
compileIcon
.
current
)
return
compileIcon
.
current
.
setAttribute
(
'title'
,
'idle'
)
compileIcon
.
current
.
setAttribute
(
'title'
,
'idle'
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_spinningIcon'
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_spinningIcon'
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_bouncingIcon'
)
compileIcon
.
current
.
classList
.
remove
(
'remixui_bouncingIcon'
)
})
}
}
const
scheduleCompilation
=
()
=>
{
const
scheduleCompilation
=
()
=>
{
const
autoCompile
=
config
.
get
(
'autoCompile'
)
if
(
!
state
.
autoCompile
)
return
if
(
!
autoCompile
)
return
if
(
state
.
compileTimeout
)
window
.
clearTimeout
(
state
.
compileTimeout
)
if
(
state
.
compileTimeout
)
window
.
clearTimeout
(
state
.
compileTimeout
)
const
compileTimeout
=
window
.
setTimeout
(()
=>
autoCompile
&&
compile
(),
state
.
timeout
)
const
compileTimeout
=
window
.
setTimeout
(()
=>
state
.
autoCompile
&&
compile
(),
state
.
timeout
)
setState
(
prevState
=>
{
setState
(
prevState
=>
{
return
{
...
prevState
,
compileTimeout
}
return
{
...
prevState
,
compileTimeout
}
...
...
libs/remix-ui/solidity-compiler/src/lib/reducers/compiler.ts
View file @
28cae6bf
...
@@ -5,47 +5,58 @@ interface Action {
...
@@ -5,47 +5,58 @@ interface Action {
export
const
compilerInitialState
=
{
export
const
compilerInitialState
=
{
compiler
:
{
compiler
:
{
compiler
:
null
,
mode
:
''
,
isRequesting
:
false
,
args
:
null
isSuccessful
:
false
,
},
error
:
null
editor
:
{
mode
:
''
}
}
}
}
export
const
compilerReducer
=
(
state
=
compilerInitialState
,
action
:
Action
)
=>
{
export
const
compilerReducer
=
(
state
=
compilerInitialState
,
action
:
Action
)
=>
{
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
case
'
FETCH_COMPILER_REQUEST
'
:
{
case
'
SET_COMPILER_MODE
'
:
{
return
{
return
{
...
state
,
...
state
,
compiler
:
action
.
payload
,
compiler
:
{
isRequesting
:
true
,
...
state
.
compiler
,
isSuccessful
:
false
,
mode
:
action
.
payload
.
mode
,
error
:
null
args
:
action
.
payload
.
args
||
null
}
}
}
}
}
case
'FETCH_COMPILER_SUCCESS'
:
{
case
'RESET_COMPILER_MODE'
:
{
return
{
return
{
...
state
,
...
state
,
provider
:
{
compiler
:
{
...
state
,
...
state
.
compiler
,
compiler
:
action
.
payload
,
mode
:
''
,
isRequesting
:
false
,
args
:
null
isSuccessful
:
true
,
error
:
null
}
}
}
}
}
}
case
'FETCH_COMPILER_ERROR'
:
{
case
'SET_EDITOR_MODE'
:
{
return
{
...
state
,
editor
:
{
...
state
.
editor
,
mode
:
action
.
payload
}
}
}
case
'RESET_EDITOR_MODE'
:
{
return
{
return
{
...
state
,
...
state
,
provider
:
{
editor
:
{
...
state
,
...
state
.
editor
,
isRequesting
:
false
,
mode
:
''
isSuccessful
:
false
,
error
:
action
.
payload
}
}
}
}
}
}
default
:
default
:
throw
new
Error
()
throw
new
Error
()
}
}
...
...
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