more clean up

pull/1344/head
joseph izang 4 years ago
parent 80bbf4f49d
commit 12b7feb2f5
  1. 20
      libs/remix-ui/plugin-manager/src/lib/components/ActivePluginCard.tsx
  2. 13
      libs/remix-ui/plugin-manager/src/lib/components/ActivePluginCardContainer.tsx
  3. 13
      libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCard.tsx
  4. 25
      libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx
  5. 3
      libs/remix-ui/plugin-manager/src/lib/components/LocalPluginForm.tsx
  6. 3
      libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
  7. 31
      libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx
  8. 2
      libs/remix-ui/plugin-manager/src/pluginManagerStateMachine.ts

@ -1,26 +1,15 @@
/* eslint-disable no-debugger */
import { Profile } from '@remixproject/plugin-utils'
import React, { Dispatch, useState } from 'react'
import React from 'react'
import '../remix-ui-plugin-manager.css'
import * as _ from 'lodash'
interface PluginCardProps {
// profile: Profile & {
// icon?: string
// }
profile: any
buttonText: string
deactivatePlugin: (pluginName: string) => void
// setActivePlugins: Dispatch<React.SetStateAction<Profile<any>[]>>
// activePlugins: Profile[]
}
// eslint-disable-next-line no-empty-pattern
function ActivePluginCard ({
profile,
buttonText,
deactivatePlugin
// activePlugins,
// setActivePlugins
}: PluginCardProps) {
return (
<div className="list-group list-group-flush plugins-list-group" data-id="pluginManagerComponentActiveTile">
@ -44,13 +33,6 @@ function ActivePluginCard ({
{<button
onClick={() => {
deactivatePlugin(profile.name)
// const actives: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins'))
// if (actives && actives.length) {
// const newList = _.remove(actives, active => active.name !== profile.name)
// // console.log('removed using lodash and this is the result', newList)
// localStorage.setItem('newActivePlugins', JSON.stringify(newList))
// setActivePlugins(newList)
// }
} }
className="btn btn-secondary btn-sm"
data-id={`pluginManagerComponentDeactivateButton${profile.name}`}

@ -1,5 +1,5 @@
import { Profile } from '@remixproject/plugin-utils'
import React, { Fragment, useEffect, useState } from 'react'
import React, { Fragment } from 'react'
import { PluginManagerComponent } from '../../types'
import ActivePluginCard from './ActivePluginCard'
import ModuleHeading from './moduleHeading'
@ -10,19 +10,10 @@ interface ActivePluginCardContainerProps {
activeProfiles: Profile[]
}
function ActivePluginCardContainer ({ pluginComponent }: ActivePluginCardContainerProps) {
// const [activeProfiles, setActiveProfiles] = useState<Profile[]>()
const deactivatePlugin = (pluginName: string) => {
pluginComponent.deactivateP(pluginName)
}
// useEffect(() => {
// const savedActiveProfiles = JSON.parse(localStorage.getItem('newActivePlugins'))
// if (pluginComponent.activePlugins && pluginComponent.activePlugins.length > 0) {
// setActiveProfiles(pluginComponent.activePlugins)
// } else if (savedActiveProfiles && savedActiveProfiles.length > 0 && pluginComponent.activePlugins.length === 0) {
// setActiveProfiles(savedActiveProfiles)
// }
// }, [pluginComponent, pluginComponent.activePlugins])
return (
<Fragment>
{(pluginComponent.activePlugins && pluginComponent.activePlugins.length) ? <ModuleHeading headingLabel="Active Modules" count={pluginComponent.activePlugins.length} /> : null}
@ -33,8 +24,6 @@ function ActivePluginCardContainer ({ pluginComponent }: ActivePluginCardContain
profile={profile}
deactivatePlugin={deactivatePlugin}
key={idx}
// activePlugins={pluginComponent.activePlugins}
// setActivePlugins={setActiveProfiles}
/>
)
})

@ -1,6 +1,6 @@
/* eslint-disable no-debugger */
import { Profile } from '@remixproject/plugin-utils'
import React, { useState } from 'react'
import React from 'react'
import '../remix-ui-plugin-manager.css'
interface PluginCardProps {
profile: Profile & {
@ -8,14 +8,8 @@ interface PluginCardProps {
}
buttonText: string
activatePlugin: (plugin: string) => void
// inactivePlugins: Profile[]
// setInactivePlugins: Dispatch<React.SetStateAction<Profile<any>[]>>
// setActivePlugins: Dispatch<React.SetStateAction<Profile<any>[]>>
// activePlugins: Profile[]
// pluginComponent: PluginManagerComponent
}
// eslint-disable-next-line no-empty-pattern
function InactivePluginCard ({
profile,
buttonText,
@ -44,11 +38,6 @@ function InactivePluginCard ({
<button
onClick={() => {
activatePlugin(profile.name)
// const newActives: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins'))
// if (!newActives.includes(profile)) {
// newActives.push(profile)
// localStorage.setItem('newActivePlugins', JSON.stringify(newActives))
// }
}}
className="btn btn-success btn-sm"
data-id={`pluginManagerComponentActivateButton${profile.name}`}

@ -1,5 +1,5 @@
import { Profile } from '@remixproject/plugin-utils'
import React, { Fragment, useEffect } from 'react'
import React, { Fragment } from 'react'
import { PluginManagerComponent, PluginManagerProfile } from '../../types'
import InactivePluginCard from './InactivePluginCard'
import ModuleHeading from './moduleHeading'
@ -11,7 +11,7 @@ interface InactivePluginCardContainerProps {
}
interface LocalPluginInterface {
profile: Partial<PluginManagerProfile> // { name: string, displayName: string, url: string, type: 'iframe' | 'ws', hash: string, methods: string, location: 'sidePanel' | 'mainPanel' | 'none'}
profile: Partial<PluginManagerProfile>
activateService: {}
requestQueue: []
options: { queueTimeout: number }
@ -20,34 +20,15 @@ interface LocalPluginInterface {
listener: []
iframe: {}
}
function InactivePluginCardContainer ({ pluginComponent, setInactiveProfiles, inactiveProfiles }: InactivePluginCardContainerProps) {
function InactivePluginCardContainer ({ pluginComponent }: InactivePluginCardContainerProps) {
const activatePlugin = (pluginName: string) => {
pluginComponent.activateP(pluginName)
}
// useEffect(() => {
// const savedLocalPlugins: LocalPluginInterface = JSON.parse(localStorage.getItem('plugins/local'))
// const savedActiveProfiles: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins'))
// if (pluginComponent.inactivePlugins && pluginComponent.inactivePlugins.length) {
// let temp: Profile[] = []
// if (Object.keys(savedLocalPlugins).length) {
// temp = [...pluginComponent.inactivePlugins, savedLocalPlugins.profile as Profile]
// } else {
// temp = [...pluginComponent.inactivePlugins]
// }
// const filtered = temp.filter(t => {
// return !savedActiveProfiles.find(active => {
// return active.name === t.name
// })
// })
// setInactiveProfiles(filtered)
// }
// }, [pluginComponent, pluginComponent.inactivePlugins, setInactiveProfiles])
return (
<Fragment>
{(pluginComponent.inactivePlugins && pluginComponent.inactivePlugins.length) ? <ModuleHeading headingLabel="Inactive Modules" count={pluginComponent.inactivePlugins.length} /> : null}
{pluginComponent.inactivePlugins && pluginComponent.inactivePlugins.map((profile, idx) => {
// console.log('profile: ', profile)
return (
<InactivePluginCard
buttonText="Activate"

@ -1,5 +1,4 @@
/* eslint-disable no-debugger */
import React, { Dispatch, useReducer, useState } from 'react'
import React, { useReducer, useState } from 'react'
import { ModalDialog } from '@remix-ui/modal-dialog'
import { Toaster } from '@remix-ui/toaster'
import { IframePlugin, WebsocketPlugin } from '@remixproject/engine-web'

@ -38,8 +38,6 @@ function RootView ({ pluginComponent, children }: RootViewProps) {
const [plugin, setPlugin] = useState<FormStateProps>(initialState)
const [filterPlugins, setFilterPlugin] = useState<string>('')
// const { activeProfiles, inactiveProfiles } = useContext(PluginManagerContext)
function pluginChangeHandler<P extends keyof FormStateProps> (formProps: P, value: FormStateProps[P]) {
setPlugin({ ...plugin, [formProps]: value })
}
@ -51,7 +49,6 @@ function RootView ({ pluginComponent, children }: RootViewProps) {
setVisible(false)
}
const closeModal = () => setVisible(true)
// <-- End Modal Visibility States -->
useEffect(() => {
pluginComponent.getAndFilterPlugins(filterPlugins)

@ -1,5 +1,5 @@
import { Profile } from '@remixproject/plugin-utils'
import React, { useEffect, useState } from 'react'
import React, { useState } from 'react'
import { RemixUiPluginManagerProps } from '../types'
import ActivePluginCardContainer from './components/ActivePluginCardContainer'
import InactivePluginCardContainer from './components/InactivePluginCardContainer'
@ -9,36 +9,7 @@ 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', '[]')
// }
// if (JSON.parse(localStorage.getItem('plugins/local')) === null) {
// localStorage.setItem('plugins/local', '{}')
// }
// if (JSON.parse(localStorage.getItem('activatedPluginNames'))) {
// localStorage.setItem('activatedPluginNames', '[]')
// }
// 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">

@ -1,5 +1,3 @@
import { Profile } from '@remixproject/plugin-utils'
import { useState } from 'react'
import { PluginManagerComponent } from './types'
export const defaultActivatedPlugins = [

Loading…
Cancel
Save