minor changes to address failing other failing tests

pull/5370/head
joseph izang 3 years ago
parent b7f395856d
commit 78d2e54dff
  1. 4
      libs/remix-ui/plugin-manager/src/lib/components/ActivePluginCard.tsx
  2. 1
      libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx
  3. 2
      libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
  4. 9
      libs/remix-ui/plugin-manager/src/lib/reducers/pluginManagerReducer.ts
  5. 23
      libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx

@ -49,11 +49,9 @@ function ActivePluginCard ({
deactivatePlugin(profile.name)
const actives: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins'))
if (actives && actives.length) {
// const newList = actives.filter(active => active.name !== profile.name)
const newList = _.remove(actives, active => active.name !== profile.name)
console.log('removed using lodash and this is the result', newList)
// console.log('removed using lodash and this is the result', newList)
localStorage.setItem('newActivePlugins', JSON.stringify(newList))
setActivePlugins([])
setActivePlugins(newList)
}
} }

@ -40,7 +40,6 @@ function InactivePluginCardContainer ({ pluginComponent, setInactiveProfiles, in
return active.name === t.name
})
})
console.log(filtered)
setInactiveProfiles(filtered)
}
}, [pluginComponent, pluginComponent.inactivePlugins, setInactiveProfiles])

@ -4,7 +4,7 @@ import { ModalDialog } from '@remix-ui/modal-dialog'
import { Toaster } from '@remix-ui/toaster'
import { IframePlugin, WebsocketPlugin } from '@remixproject/engine-web'
import { FormStateProps, PluginManagerComponent } from '../../types'
import { localPluginReducerActionType, localPluginToastReducer } from '../../pluginManagerReducer'
import { localPluginReducerActionType, localPluginToastReducer } from '../reducers/pluginManagerReducer'
interface LocalPluginFormProps {
changeHandler: (propertyName: string, value: any) => void

@ -8,5 +8,14 @@ export function localPluginToastReducer (currentState: string, toastAction: loca
switch (toastAction.type) {
case 'show':
return `Cannot create Plugin : ${toastAction.payload!}`
default:
return currentState
}
}
export interface activePluginActionType {
type: 'load' | 'refresh'
}
export function loadActivePluginsReducer (activated: string[], action: activePluginActionType) {
}

@ -1,5 +1,5 @@
import { Profile } from '@remixproject/plugin-utils'
import React, { useState } from 'react'
import React, { useEffect, useState } from 'react'
import { RemixUiPluginManagerProps } from '../types'
import ActivePluginCardContainer from './components/ActivePluginCardContainer'
import InactivePluginCardContainer from './components/InactivePluginCardContainer'
@ -9,6 +9,8 @@ import './remix-ui-plugin-manager.css'
export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerProps) => {
const [activeProfiles, setActiveProfiles] = useState<Profile[]>(pluginComponent.activePlugins)
const [inactiveProfiles, setinactiveProfiles] = useState<Profile[]>(pluginComponent.inactivePlugins)
const [activated] = useState<string[]>(pluginComponent.activeProfiles)
if (JSON.parse(localStorage.getItem('newActivePlugins')) === null) {
localStorage.setItem('newActivePlugins', '[]')
}
@ -18,7 +20,26 @@ export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerPr
if (JSON.parse(localStorage.getItem('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 (
<RootView pluginComponent={pluginComponent}>
<section data-id="pluginManagerComponentPluginManagerSection">

Loading…
Cancel
Save