|
|
@ -1,5 +1,5 @@ |
|
|
|
import { Profile } from '@remixproject/plugin-utils' |
|
|
|
import { Profile } from '@remixproject/plugin-utils' |
|
|
|
import React, { useState } from 'react' |
|
|
|
import React, { useEffect, useState } from 'react' |
|
|
|
import { RemixUiPluginManagerProps } from '../types' |
|
|
|
import { RemixUiPluginManagerProps } from '../types' |
|
|
|
import ActivePluginCardContainer from './components/ActivePluginCardContainer' |
|
|
|
import ActivePluginCardContainer from './components/ActivePluginCardContainer' |
|
|
|
import InactivePluginCardContainer from './components/InactivePluginCardContainer' |
|
|
|
import InactivePluginCardContainer from './components/InactivePluginCardContainer' |
|
|
@ -9,6 +9,8 @@ import './remix-ui-plugin-manager.css' |
|
|
|
export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerProps) => { |
|
|
|
export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerProps) => { |
|
|
|
const [activeProfiles, setActiveProfiles] = useState<Profile[]>(pluginComponent.activePlugins) |
|
|
|
const [activeProfiles, setActiveProfiles] = useState<Profile[]>(pluginComponent.activePlugins) |
|
|
|
const [inactiveProfiles, setinactiveProfiles] = useState<Profile[]>(pluginComponent.inactivePlugins) |
|
|
|
const [inactiveProfiles, setinactiveProfiles] = useState<Profile[]>(pluginComponent.inactivePlugins) |
|
|
|
|
|
|
|
const [activated] = useState<string[]>(pluginComponent.activeProfiles) |
|
|
|
|
|
|
|
|
|
|
|
if (JSON.parse(localStorage.getItem('newActivePlugins')) === null) { |
|
|
|
if (JSON.parse(localStorage.getItem('newActivePlugins')) === null) { |
|
|
|
localStorage.setItem('newActivePlugins', '[]') |
|
|
|
localStorage.setItem('newActivePlugins', '[]') |
|
|
|
} |
|
|
|
} |
|
|
@ -18,7 +20,26 @@ export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerPr |
|
|
|
if (JSON.parse(localStorage.getItem('activatedPluginNames'))) { |
|
|
|
if (JSON.parse(localStorage.getItem('activatedPluginNames'))) { |
|
|
|
localStorage.setItem('activatedPluginNames', '[]') |
|
|
|
localStorage.setItem('activatedPluginNames', '[]') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log('activated profile names :', activated) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
console.log('first time into use effect the activated state is', activated) |
|
|
|
|
|
|
|
const checkSolidity = async () => { |
|
|
|
|
|
|
|
const savedActives: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins')) |
|
|
|
|
|
|
|
if (activated.includes('solidity') && activated.includes('solidity-logic')) { |
|
|
|
|
|
|
|
if (savedActives && savedActives.length >= 0) { |
|
|
|
|
|
|
|
if (!savedActives.find(active => active.name === 'solidity') && !savedActives.find(active => active.name === 'solidity-logic')) { |
|
|
|
|
|
|
|
const solidity = await pluginComponent.appManager.getProfile('solidity') |
|
|
|
|
|
|
|
const logic = await pluginComponent.appManager.getProfile('solidity-logic') |
|
|
|
|
|
|
|
savedActives.push(solidity, logic) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log('Use effect called, activated state is', activated) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
checkSolidity() |
|
|
|
|
|
|
|
console.log('activated state right at useEffect exit', activated) |
|
|
|
|
|
|
|
}, [activated, pluginComponent.appManager]) |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<RootView pluginComponent={pluginComponent}> |
|
|
|
<RootView pluginComponent={pluginComponent}> |
|
|
|
<section data-id="pluginManagerComponentPluginManagerSection"> |
|
|
|
<section data-id="pluginManagerComponentPluginManagerSection"> |
|
|
|