@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import React , { useState , useRef , useReducer , useEffect } from 'react'
import { FormattedMessage } from 'react-intl'
import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
const _paq = ( window . _paq = window . _paq || [ ] ) // eslint-disable-line
import { CustomTooltip } from '@remix-ui/helper'
import { TEMPLATE_NAMES } from '@remix-ui/workspace'
@ -14,7 +14,7 @@ interface HomeTabFileProps {
const loadingInitialState = {
tooltip : '' ,
showModalDialog : false ,
importSource : ''
importSource : '' ,
}
const loadingReducer = ( state = loadingInitialState , action ) = > {
@ -22,7 +22,7 @@ const loadingReducer = (state = loadingInitialState, action) => {
. . . state ,
tooltip : action.tooltip ,
showModalDialog : false ,
importSource : ''
importSource : '' ,
}
}
@ -45,7 +45,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
modalInfo : { title : '' , loadItem : '' , examples : [ ] , prefix : '' } ,
importSource : '' ,
toasterMsg : '' ,
recentWorkspaces : [ ]
recentWorkspaces : [ ] ,
} )
const [ , dispatch ] = useReducer ( loadingReducer , loadingInitialState )
@ -71,7 +71,9 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
if ( ! recents ) {
newRecents = [ ]
} else {
newRecents = recents . filter ( ( el ) = > { return el !== name } )
newRecents = recents . filter ( ( el ) = > {
return el !== name
} )
localStorage . setItem ( 'recentWorkspaces' , JSON . stringify ( newRecents ) )
}
setState ( ( prevState ) = > {
@ -85,8 +87,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
try {
plugin . off ( 'filePanel' , 'setWorkspace' )
plugin . off ( 'filePanel' , 'workspaceDeleted' )
} catch ( e ) {
}
} catch ( e ) { }
}
} , [ plugin ] )
@ -162,7 +163,6 @@ contract HelloWorld {
} else {
await plugin . call ( 'fileManager' , 'open' , '/contracts/HelloWorld.sol' )
}
}
const uploadFile = async ( target ) = > {
@ -216,14 +216,7 @@ contract HelloWorld {
return (
< >
< ModalDialog
id = "homeTab"
title = { 'Import from ' + state . modalInfo . title }
okLabel = "Import"
hide = { ! state . showModalDialog }
handleHide = { ( ) = > hideFullMessage ( ) }
okFn = { ( ) = > processLoading ( state . modalInfo . title ) }
>
< ModalDialog 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" >
{ state . modalInfo . loadItem !== '' && < span > Enter the { state . modalInfo . loadItem } you would like to load . < / span > }
{ 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>}
< input
ref = { inputValue }
type = 'text'
name = 'prompt_text'
id = 'inputPrompt_text'
type = "text"
name = "prompt_text"
id = "inputPrompt_text"
className = "w-100 mt-1 form-control"
data - id = "homeTabModalDialogCustomPromptText"
value = { state . importSource }
@ -256,7 +249,7 @@ contract HelloWorld {
{ ( state . recentWorkspaces [ 0 ] || state . recentWorkspaces [ 1 ] || state . recentWorkspaces [ 2 ] ) && (
< div className = "d-flex flex-column mb-3" >
< label style = { { fontSize : '0.8rem' } } className = "mt-3" >
Recent workspaces
Recent workspaces
< / label >
{ state . recentWorkspaces [ 0 ] && 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 >
< div className = "d-flex flex-column" >
< div className = "d-flex flex-row" >
< CustomTooltip
placement = { 'top' }
tooltipId = "overlay-tooltip"
tooltipClasses = "text-nowrap"
tooltipText = { < FormattedMessage id = 'home.startCodingPlayground' / > }
tooltipTextClasses = "border bg-light text-dark p-1 pr-3"
>
< CustomTooltip 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 ( ) } >
< FormattedMessage id = "home.startCoding" / >
< / button >
< / 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"
>
< CustomTooltip placement = { 'top' } tooltipId = "overlay-tooltip" tooltipClasses = "text-nowrap" tooltipText = { < FormattedMessage id = "home.openFileTooltip" / > } tooltipTextClasses = "border bg-light text-dark p-1 pr-3" >
< span >
< label className = "btn text-nowrap p-2 mr-2 border my-1" style = { { width : 'fit-content' , cursor : 'pointer' } } htmlFor = "openFileInput" >
< FormattedMessage id = "home.openFile" / >
@ -315,23 +296,13 @@ contract HelloWorld {
/ >
< / span >
< / 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://' ) } >
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 >
< / 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 " >
< FormattedMessage id = "home.loadFrom" / >
@ -349,13 +320,7 @@ contract HelloWorld {
>
HTTPS
< / button > * / }
< CustomTooltip
placement = { 'top' }
tooltipId = "overlay-tooltip"
tooltipClasses = "text-nowrap"
tooltipText = { < FormattedMessage id = "home.connectToLocalhost" / > }
tooltipTextClasses = "border bg-light text-dark p-1 pr-3"
>
< CustomTooltip 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 ( ) } >
< FormattedMessage id = "home.accessFileSystem" / >
< / button >