|
|
@ -5,6 +5,7 @@ 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' |
|
|
|
|
|
|
|
|
|
|
|
interface HomeTabFileProps { |
|
|
|
interface HomeTabFileProps { |
|
|
|
plugin: any |
|
|
|
plugin: any |
|
|
@ -56,10 +57,8 @@ function HomeTabFile({plugin}: HomeTabFileProps) { |
|
|
|
const inputValue = useRef(null) |
|
|
|
const inputValue = useRef(null) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
console.log("useEffHomeFile") |
|
|
|
|
|
|
|
plugin.on('filePanel', 'setWorkspace', async () => { |
|
|
|
plugin.on('filePanel', 'setWorkspace', async () => { |
|
|
|
let recents = JSON.parse(localStorage.getItem('recentWorkspaces')) |
|
|
|
let recents = JSON.parse(localStorage.getItem('recentWorkspaces')) |
|
|
|
console.log("useEffHomeFilerecents ", recents) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!recents) recents = {first:'', second: '', third: ''} |
|
|
|
if (!recents) recents = {first:'', second: '', third: ''} |
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
@ -115,6 +114,15 @@ function HomeTabFile({plugin}: HomeTabFileProps) { |
|
|
|
const startCoding = async () => { |
|
|
|
const startCoding = async () => { |
|
|
|
_paq.push(['trackEvent', 'hometab', 'filesSection', 'startCoding']) |
|
|
|
_paq.push(['trackEvent', 'hometab', 'filesSection', 'startCoding']) |
|
|
|
plugin.verticalIcons.select('filePanel') |
|
|
|
plugin.verticalIcons.select('filePanel') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const wName = 'Coding playground' |
|
|
|
|
|
|
|
const workspaces = await plugin.call('filePanel', 'getWorkspaces') |
|
|
|
|
|
|
|
if (!workspaces.find(workspace => workspace.name === wName)) { |
|
|
|
|
|
|
|
await plugin.call('filePanel', 'createWorkspace', wName, 'remixDefault') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) |
|
|
|
|
|
|
|
await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // don't ask why
|
|
|
|
|
|
|
|
|
|
|
|
const content = ` |
|
|
|
const content = ` |
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
@ -122,8 +130,8 @@ function HomeTabFile({plugin}: HomeTabFileProps) { |
|
|
|
contract helloWorld { |
|
|
|
contract helloWorld { |
|
|
|
} |
|
|
|
} |
|
|
|
` |
|
|
|
` |
|
|
|
await plugin.call('fileManager', 'writeFile', '/helloWorld.sol', content) |
|
|
|
const {newContent, newPath} = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) |
|
|
|
await plugin.call('fileManager', 'open', '/helloWorld.sol') |
|
|
|
await plugin.call('fileManager', 'open', newPath) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const uploadFile = async (target) => { |
|
|
|
const uploadFile = async (target) => { |
|
|
@ -165,8 +173,12 @@ function HomeTabFile({plugin}: HomeTabFileProps) { |
|
|
|
|
|
|
|
|
|
|
|
const handleSwichToRecentWorkspace = async (e, workspaceName) => { |
|
|
|
const handleSwichToRecentWorkspace = async (e, workspaceName) => { |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false }) |
|
|
|
await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false }) |
|
|
|
console.log('The link was clicked.'); |
|
|
|
console.log('The link was clicked.'); |
|
|
|
|
|
|
|
======= |
|
|
|
|
|
|
|
await plugin.call('filePanel', 'switchToWorkspace', { name: workspaceName, isLocalhost: false }) |
|
|
|
|
|
|
|
>>>>>>> e9b2848c5... cleanup fix undefined workspaces. Creating default Workspace |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const examples = state.modalInfo.examples.map((urlEl, key) => ( |
|
|
|
const examples = state.modalInfo.examples.map((urlEl, key) => ( |
|
|
@ -196,15 +208,26 @@ function HomeTabFile({plugin}: HomeTabFileProps) { |
|
|
|
{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} |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
type="text" |
|
|
|
type="text" |
|
|
|
name="prompt_text" |
|
|
|
name="prompt_text" |
|
|
|
id="inputPrompt_text" |
|
|
|
id="inputPrompt_text" |
|
|
|
|
|
|
|
======= |
|
|
|
|
|
|
|
type='text' |
|
|
|
|
|
|
|
name='prompt_text' |
|
|
|
|
|
|
|
id='inputPrompt_text' |
|
|
|
|
|
|
|
>>>>>>> e9b2848c5... cleanup fix undefined workspaces. Creating default Workspace |
|
|
|
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} |
|
|
|
onInput={(e) => { |
|
|
|
onInput={(e) => { |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
setState((prevState) => { |
|
|
|
setState((prevState) => { |
|
|
|
return {...prevState, importSource: inputValue.current.value} |
|
|
|
return {...prevState, importSource: inputValue.current.value} |
|
|
|
|
|
|
|
======= |
|
|
|
|
|
|
|
setState(prevState => { |
|
|
|
|
|
|
|
return { ...prevState, importSource: inputValue.current.value } |
|
|
|
|
|
|
|
>>>>>>> e9b2848c5... cleanup fix undefined workspaces. Creating default Workspace |
|
|
|
}) |
|
|
|
}) |
|
|
|
}} |
|
|
|
}} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -255,24 +278,27 @@ function HomeTabFile({plugin}: HomeTabFileProps) { |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
</CustomTooltip> |
|
|
|
</CustomTooltip> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
{ !(state.recentWorkspaces.first == '' && |
|
|
|
|
|
|
|
state.recentWorkspaces.second == '' && |
|
|
|
|
|
|
|
state.recentWorkspaces.third == '') &&
|
|
|
|
<div className='d-flex flex-column'> |
|
|
|
<div className='d-flex flex-column'> |
|
|
|
<label style={{fontSize: "0.8rem"}} className='mt-3'>Recent workspaces</label> |
|
|
|
<label style={{fontSize: "0.8rem"}} className='mt-3'>Recent workspaces</label> |
|
|
|
<a |
|
|
|
{(state.recentWorkspaces.first !== 'undefined' && state.recentWorkspaces.first !== '') && <a |
|
|
|
className='cursor-pointer mb-1 ml-2' |
|
|
|
className='cursor-pointer mb-1 ml-2' |
|
|
|
href="#" |
|
|
|
href="#" |
|
|
|
onClick={(e) => handleSwichToRecentWorkspace(e, state.recentWorkspaces.first)}>{state.recentWorkspaces.first} |
|
|
|
onClick={(e) => handleSwichToRecentWorkspace(e, state.recentWorkspaces.first)}>{state.recentWorkspaces.first} |
|
|
|
</a> |
|
|
|
</a> } |
|
|
|
<a |
|
|
|
{(state.recentWorkspaces.second !== 'undefined' && state.recentWorkspaces.second !== '') && <a |
|
|
|
className='cursor-pointer mb-1 ml-2' |
|
|
|
className='cursor-pointer mb-1 ml-2' |
|
|
|
href="#" |
|
|
|
href="#" |
|
|
|
onClick={(e) => handleSwichToRecentWorkspace(e, state.recentWorkspaces.second)}>{state.recentWorkspaces.second} |
|
|
|
onClick={(e) => handleSwichToRecentWorkspace(e, state.recentWorkspaces.second)}>{state.recentWorkspaces.second} |
|
|
|
</a> |
|
|
|
</a> } |
|
|
|
<a |
|
|
|
{(state.recentWorkspaces.third !== 'undefined' && state.recentWorkspaces.third !== '') && <a |
|
|
|
className='cursor-pointer ml-2' |
|
|
|
className='cursor-pointer ml-2' |
|
|
|
href="#" |
|
|
|
href="#" |
|
|
|
onClick={(e) => handleSwichToRecentWorkspace(e, state.recentWorkspaces.third)}>{state.recentWorkspaces.third} |
|
|
|
onClick={(e) => handleSwichToRecentWorkspace(e, state.recentWorkspaces.third)}>{state.recentWorkspaces.third} |
|
|
|
</a> |
|
|
|
</a> } |
|
|
|
</div> |
|
|
|
</div> } |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<label style={{fontSize: "0.8rem"}} className="pt-3"><FormattedMessage id='home.loadFrom' /></label> |
|
|
|
<label style={{fontSize: "0.8rem"}} className="pt-3"><FormattedMessage id='home.loadFrom' /></label> |
|
|
|
<div className="d-flex"> |
|
|
|
<div className="d-flex"> |
|
|
|