@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import React , { useState , useRef , useReducer , useEffect } from 'react'
import React , { useState , useRef , useReducer , useEffect } from 'react'
import { FormattedMessage } from 'react-intl'
import { FormattedMessage } from 'react-intl'
import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
const _paq = ( window . _paq = window . _paq || [ ] ) // eslint-disable-line
const _paq = ( window . _paq = window . _paq || [ ] ) // eslint-disable-line
import { CustomTooltip } from '@remix-ui/helper'
import { CustomTooltip } from '@remix-ui/helper'
import { TEMPLATE_NAMES } from '@remix-ui/workspace'
import { TEMPLATE_NAMES } from '@remix-ui/workspace'
@ -14,7 +14,7 @@ interface HomeTabFileProps {
const loadingInitialState = {
const loadingInitialState = {
tooltip : '' ,
tooltip : '' ,
showModalDialog : false ,
showModalDialog : false ,
importSource : ''
importSource : '' ,
}
}
const loadingReducer = ( state = loadingInitialState , action ) = > {
const loadingReducer = ( state = loadingInitialState , action ) = > {
@ -22,7 +22,7 @@ const loadingReducer = (state = loadingInitialState, action) => {
. . . state ,
. . . state ,
tooltip : action.tooltip ,
tooltip : action.tooltip ,
showModalDialog : false ,
showModalDialog : false ,
importSource : ''
importSource : '' ,
}
}
}
}
@ -45,7 +45,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
modalInfo : { title : '' , loadItem : '' , examples : [ ] , prefix : '' } ,
modalInfo : { title : '' , loadItem : '' , examples : [ ] , prefix : '' } ,
importSource : '' ,
importSource : '' ,
toasterMsg : '' ,
toasterMsg : '' ,
recentWorkspaces : [ ]
recentWorkspaces : [ ] ,
} )
} )
const [ , dispatch ] = useReducer ( loadingReducer , loadingInitialState )
const [ , dispatch ] = useReducer ( loadingReducer , loadingInitialState )
@ -71,7 +71,9 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
if ( ! recents ) {
if ( ! recents ) {
newRecents = [ ]
newRecents = [ ]
} else {
} else {
newRecents = recents . filter ( ( el ) = > { return el !== name } )
newRecents = recents . filter ( ( el ) = > {
return el !== name
} )
localStorage . setItem ( 'recentWorkspaces' , JSON . stringify ( newRecents ) )
localStorage . setItem ( 'recentWorkspaces' , JSON . stringify ( newRecents ) )
}
}
setState ( ( prevState ) = > {
setState ( ( prevState ) = > {
@ -85,8 +87,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
try {
try {
plugin . off ( 'filePanel' , 'setWorkspace' )
plugin . off ( 'filePanel' , 'setWorkspace' )
plugin . off ( 'filePanel' , 'workspaceDeleted' )
plugin . off ( 'filePanel' , 'workspaceDeleted' )
} catch ( e ) {
} catch ( e ) { }
}
}
}
} , [ plugin ] )
} , [ plugin ] )
@ -162,7 +163,6 @@ contract HelloWorld {
} else {
} else {
await plugin . call ( 'fileManager' , 'open' , '/contracts/HelloWorld.sol' )
await plugin . call ( 'fileManager' , 'open' , '/contracts/HelloWorld.sol' )
}
}
}
}
const uploadFile = async ( target ) = > {
const uploadFile = async ( target ) = > {
@ -216,14 +216,7 @@ contract HelloWorld {
return (
return (
< >
< >
< ModalDialog
< ModalDialog id = "homeTab" title = { 'Import from ' + state . modalInfo . title } okLabel = "Import" hide = { ! state . showModalDialog } handleHide = { ( ) = > hideFullMessage ( ) } okFn = { ( ) = > processLoading ( state . modalInfo . title ) } >
id = "homeTab"
title = { 'Import from ' + state . modalInfo . title }
okLabel = "Import"
hide = { ! state . showModalDialog }
handleHide = { ( ) = > hideFullMessage ( ) }
okFn = { ( ) = > processLoading ( state . modalInfo . title ) }
>
< div className = "p-2 user-select-auto" >
< div className = "p-2 user-select-auto" >
{ state . modalInfo . loadItem !== '' && < span > Enter the { state . modalInfo . loadItem } you would like to load . < / span > }
{ state . modalInfo . loadItem !== '' && < span > Enter the { state . modalInfo . loadItem } you would like to load . < / span > }
{ state . modalInfo . examples . length !== 0 && (
{ state . modalInfo . examples . length !== 0 && (
@ -236,9 +229,9 @@ contract HelloWorld {
{ state . modalInfo . prefix && < span className = "text-nowrap align-self-center mr-2" > ipfs : //</span>}
{ state . modalInfo . prefix && < span className = "text-nowrap align-self-center mr-2" > ipfs : //</span>}
< input
< input
ref = { inputValue }
ref = { inputValue }
type = 'text'
type = "text"
name = 'prompt_text'
name = "prompt_text"
id = 'inputPrompt_text'
id = "inputPrompt_text"
className = "w-100 mt-1 form-control"
className = "w-100 mt-1 form-control"
data - id = "homeTabModalDialogCustomPromptText"
data - id = "homeTabModalDialogCustomPromptText"
value = { state . importSource }
value = { state . importSource }
@ -256,7 +249,7 @@ contract HelloWorld {
{ ( state . recentWorkspaces [ 0 ] || state . recentWorkspaces [ 1 ] || state . recentWorkspaces [ 2 ] ) && (
{ ( state . recentWorkspaces [ 0 ] || state . recentWorkspaces [ 1 ] || state . recentWorkspaces [ 2 ] ) && (
< div className = "d-flex flex-column mb-3" >
< div className = "d-flex flex-column mb-3" >
< label style = { { fontSize : '0.8rem' } } className = "mt-3" >
< label style = { { fontSize : '0.8rem' } } className = "mt-3" >
Recent workspaces
Recent workspaces
< / label >
< / label >
{ state . recentWorkspaces [ 0 ] && state . recentWorkspaces [ 0 ] !== '' && (
{ state . recentWorkspaces [ 0 ] && state . recentWorkspaces [ 0 ] !== '' && (
< a className = "cursor-pointer mb-1 ml-2" href = "#" onClick = { ( e ) = > handleSwichToRecentWorkspace ( e , state . recentWorkspaces [ 0 ] ) } >
< a className = "cursor-pointer mb-1 ml-2" href = "#" onClick = { ( e ) = > handleSwichToRecentWorkspace ( e , state . recentWorkspaces [ 0 ] ) } >
@ -280,24 +273,12 @@ contract HelloWorld {
< / label >
< / label >
< div className = "d-flex flex-column" >
< div className = "d-flex flex-column" >
< div className = "d-flex flex-row" >
< div className = "d-flex flex-row" >
< CustomTooltip
< CustomTooltip placement = { 'top' } tooltipId = "overlay-tooltip" tooltipClasses = "text-nowrap" tooltipText = { < FormattedMessage id = "home.startCodingPlayground" / > } tooltipTextClasses = "border bg-light text-dark p-1 pr-3" >
placement = { 'top' }
tooltipId = "overlay-tooltip"
tooltipClasses = "text-nowrap"
tooltipText = { < FormattedMessage id = 'home.startCodingPlayground' / > }
tooltipTextClasses = "border bg-light text-dark p-1 pr-3"
>
< button className = "btn btn-primary text-nowrap p-2 mr-2 border my-1" data - id = "homeTabStartCoding" style = { { width : 'fit-content' } } onClick = { ( ) = > startCoding ( ) } >
< button className = "btn btn-primary text-nowrap p-2 mr-2 border my-1" data - id = "homeTabStartCoding" style = { { width : 'fit-content' } } onClick = { ( ) = > startCoding ( ) } >
< FormattedMessage id = "home.startCoding" / >
< FormattedMessage id = "home.startCoding" / >
< / button >
< / button >
< / CustomTooltip >
< / CustomTooltip >
< CustomTooltip
< CustomTooltip placement = { 'top' } tooltipId = "overlay-tooltip" tooltipClasses = "text-nowrap" tooltipText = { < FormattedMessage id = "home.openFileTooltip" / > } tooltipTextClasses = "border bg-light text-dark p-1 pr-3" >
placement = { 'top' }
tooltipId = "overlay-tooltip"
tooltipClasses = "text-nowrap"
tooltipText = { < FormattedMessage id = 'home.openFileTooltip' / > }
tooltipTextClasses = "border bg-light text-dark p-1 pr-3"
>
< span >
< span >
< label className = "btn text-nowrap p-2 mr-2 border my-1" style = { { width : 'fit-content' , cursor : 'pointer' } } htmlFor = "openFileInput" >
< label className = "btn text-nowrap p-2 mr-2 border my-1" style = { { width : 'fit-content' , cursor : 'pointer' } } htmlFor = "openFileInput" >
< FormattedMessage id = "home.openFile" / >
< FormattedMessage id = "home.openFile" / >
@ -315,23 +296,13 @@ contract HelloWorld {
/ >
/ >
< / span >
< / span >
< / CustomTooltip >
< / CustomTooltip >
< button
className = "btn text-nowrap p-2 mr-2 border my-1"
data - id = "landingPageImportFromGitHubButton"
onClick = { ( ) = >
showFullMessage ( 'GitHub' , 'github URL' , [
'https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol' ,
'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol' ,
] )
}
>
GitHub
< / button >
< button className = "btn text-nowrap p-2 mr-2 border my-1" onClick = { ( ) = > showFullMessage ( 'Ipfs' , 'ipfs hash' , [ 'ipfs://QmQQfBMkpDgmxKzYaoAtqfaybzfgGm9b2LWYyT56Chv6xH' ] , 'ipfs://' ) } >
< button className = "btn text-nowrap p-2 mr-2 border my-1" onClick = { ( ) = > showFullMessage ( 'Ipfs' , 'ipfs hash' , [ 'ipfs://QmQQfBMkpDgmxKzYaoAtqfaybzfgGm9b2LWYyT56Chv6xH' ] , 'ipfs://' ) } >
IPFS
IPFS
< / button >
< button className = "btn text-nowrap p-2 mr-2 border my-1" data - id = "landingPageImportFromGitHubButton" onClick = { ( ) = > showFullMessage ( 'GitHub' , 'github URL' , [ 'https://github.com/0xcert/ethereum-erc721/src/contracts/tokens/nf-token-metadata.sol' , 'https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67bca857eedf99bf44a4b6a0fc5b5ed553135316/contracts/access/Roles.sol' ] ) } >
Git Clone
< / button >
< / button >
< / div >
< / div >
< / div >
< / div >
{ / * < l a b e l s t y l e = { { f o n t S i z e : ' 0 . 8 r e m ' } } c l a s s N a m e = " p t - 3 " >
{ / * < l a b e l s t y l e = { { f o n t S i z e : ' 0 . 8 r e m ' } } c l a s s N a m e = " p t - 3 " >
< FormattedMessage id = "home.loadFrom" / >
< FormattedMessage id = "home.loadFrom" / >
@ -349,13 +320,7 @@ contract HelloWorld {
>
>
HTTPS
HTTPS
< / button > * / }
< / button > * / }
< CustomTooltip
< CustomTooltip placement = { 'top' } tooltipId = "overlay-tooltip" tooltipClasses = "text-nowrap" tooltipText = { < FormattedMessage id = "home.connectToLocalhost" / > } tooltipTextClasses = "border bg-light text-dark p-1 pr-3" >
placement = { 'top' }
tooltipId = "overlay-tooltip"
tooltipClasses = "text-nowrap"
tooltipText = { < FormattedMessage id = "home.connectToLocalhost" / > }
tooltipTextClasses = "border bg-light text-dark p-1 pr-3"
>
< button className = "btn btn-block w-100 text-nowrap p-2 border my-1" style = { { width : 'fit-content' } } onClick = { ( ) = > connectToLocalhost ( ) } >
< button className = "btn btn-block w-100 text-nowrap p-2 border my-1" style = { { width : 'fit-content' } } onClick = { ( ) = > connectToLocalhost ( ) } >
< FormattedMessage id = "home.accessFileSystem" / >
< FormattedMessage id = "home.accessFileSystem" / >
< / button >
< / button >