remove comments and refactor components

pull/1344/head
joseph izang 3 years ago
parent 65b92084db
commit db95638a2c
  1. 17
      apps/remix-ide/src/app/components/plugin-manager-component.js
  2. 14
      libs/remix-ui/plugin-manager/src/lib/components/InactivePluginCardContainer.tsx
  3. 44
      libs/remix-ui/plugin-manager/src/lib/components/pluginManagerContext.tsx
  4. 16
      libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx
  5. 4
      libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx

@ -1,20 +1,9 @@
/* eslint-disable no-debugger */
/* eslint-disable no-unused-vars */
import {
IframePlugin,
ViewPlugin,
WebsocketPlugin
} from '@remixproject/engine-web'
import { ViewPlugin } from '@remixproject/engine-web'
import { PluginManagerSettings } from './plugin-manager-settings'
import React from 'react' // eslint-disable-line
import ReactDOM from 'react-dom'
import {RemixUiPluginManager} from '@remix-ui/plugin-manager' // eslint-disable-line
import * as packageJson from '../../../../../package.json'
const yo = require('yo-yo')
const csjs = require('csjs-inject')
const EventEmitter = require('events')
// const LocalPlugin = require('./local-plugin') // eslint-disable-line
const addToolTip = require('../ui/tooltip')
const _paq = window._paq = window._paq || []
const profile = {
@ -37,7 +26,6 @@ class PluginManagerComponent extends ViewPlugin {
this.appManager = appManager
this.engine = engine
this.pluginManagerSettings = new PluginManagerSettings()
// this.localPlugin = new LocalPlugin()
this.htmlElement = document.createElement('div')
this.htmlElement.setAttribute('id', 'pluginManager')
this.views = {
@ -91,8 +79,6 @@ class PluginManagerComponent extends ViewPlugin {
this.engine.register(localPlugin)
this.appManager.activatePlugin(localPlugin.profile.name)
this.getAndFilterPlugins()
// this.activateP(localPlugin.profile.name)
// localStorage.setItem('targetLocalPlugin', plugin.name)
localStorage.setItem('plugins/local', JSON.stringify(localPlugin))
}
}
@ -113,7 +99,6 @@ class PluginManagerComponent extends ViewPlugin {
}
onActivation () {
// this.getAndFilterPlugins()
this.renderComponent()
}

@ -26,22 +26,10 @@ function InactivePluginCardContainer ({ pluginComponent, setInactiveProfiles, in
}
useEffect(() => {
const savedInactiveProfiles: Profile[] = JSON.parse(localStorage.getItem('updatedInactives'))
const savedLocalPlugins: LocalPluginInterface = JSON.parse(localStorage.getItem('plugins/local'))
const savedActiveProfiles: Profile[] = JSON.parse(localStorage.getItem('newActivePlugins'))
if (savedInactiveProfiles && savedInactiveProfiles.length) {
if (Object.keys(savedLocalPlugins).length > 0 && !pluginComponent.inactivePlugins.includes(savedLocalPlugins.profile as Profile)) {
const inactiveLocalPlugin = savedLocalPlugins.profile
localStorage.setItem('currentLocalPlugin', inactiveLocalPlugin.name)
savedInactiveProfiles.push(inactiveLocalPlugin as Profile)
}
// setinactiveProfiles(savedInactiveProfiles)
} else if (pluginComponent.inactivePlugins && pluginComponent.inactivePlugins.length > 0) {
if (pluginComponent.inactivePlugins && pluginComponent.inactivePlugins.length) {
let temp: Profile[] = []
if (Object.keys(savedLocalPlugins).length > 0) {
const inactiveLocalPlugin = savedLocalPlugins.profile
localStorage.setItem('currentLocalPlugin', inactiveLocalPlugin.name)
}
if (Object.keys(savedLocalPlugins).length) {
temp = [...pluginComponent.inactivePlugins, savedLocalPlugins.profile as Profile]
} else {

@ -1,44 +0,0 @@
import { Profile } from '@remixproject/plugin-utils'
import React, { createContext, useEffect, useState } from 'react'
import { PluginManagerContextProviderProps } from '../../types'
interface PluginManagerContextInterface {
trackActiveProfiles: Profile[]
trackInactiveProfiles: Profile[]
setTrackActiveProfiles: React.Dispatch<Profile[]>
setTrackInactiveProfiles: React.Dispatch<Profile[]>
}
export const PluginManagerContext = createContext<PluginManagerContextInterface>(null)
function PluginManagerContextProvider ({ children, pluginComponent }: PluginManagerContextProviderProps) {
const [trackActiveProfiles, setTrackActiveProfiles] = useState([])
const [trackInactiveProfiles, setTrackInactiveProfiles] = useState([])
useEffect(() => {
const checkedActives = JSON.parse(localStorage.getItem('newActivePlugins'))
if (checkedActives && checkedActives.length > 0) {
setTrackActiveProfiles([...trackActiveProfiles, ...checkedActives])
} else {
localStorage.setItem('newActivePlugins', JSON.stringify(trackActiveProfiles))
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [trackActiveProfiles])
useEffect(() => {
const checkedInactives = JSON.parse(localStorage.getItem('updatedInactives'))
if (checkedInactives && checkedInactives.length > 0 && trackInactiveProfiles.length === 0) {
setTrackInactiveProfiles([...pluginComponent.inactivePlugins, ...checkedInactives])
} else {
localStorage.setItem('updatedInactives', JSON.stringify(trackInactiveProfiles))
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pluginComponent.inactivePlugins])
return (
<PluginManagerContext.Provider value={{ trackActiveProfiles, trackInactiveProfiles, setTrackActiveProfiles, setTrackInactiveProfiles }}>
{children}
</PluginManagerContext.Provider>
)
}
export default PluginManagerContextProvider

@ -35,8 +35,8 @@ function RootView ({ pluginComponent, children }: RootViewProps) {
* Component Local State declaration
*/
const [visible, setVisible] = useState<boolean>(true)
const [plugin, setPlugin] = useState(initialState)
const [filterPlugins, setFilterPlugin] = useState('')
const [plugin, setPlugin] = useState<FormStateProps>(initialState)
const [filterPlugins, setFilterPlugin] = useState<string>('')
// const { activeProfiles, inactiveProfiles } = useContext(PluginManagerContext)
@ -53,18 +53,6 @@ function RootView ({ pluginComponent, children }: RootViewProps) {
const closeModal = () => setVisible(true)
// <-- End Modal Visibility States -->
/**
* Gets the latest list of inactive plugin profiles and persist them
* in local storage
* @param inactivesList Array of inactive plugin profiles
* @returns {void}
*/
// function PersistNewInactivesState (inactivesList: Profile[]) {
// if (inactivesList && inactivesList.length) {
// localStorage.setItem('updatedInactives', JSON.stringify(inactivesList))
// }
// }
useEffect(() => {
pluginComponent.getAndFilterPlugins(filterPlugins)
// eslint-disable-next-line react-hooks/exhaustive-deps

@ -12,15 +12,13 @@ export const RemixUiPluginManager = ({ pluginComponent }: RemixUiPluginManagerPr
if (JSON.parse(localStorage.getItem('newActivePlugins')) === null) {
localStorage.setItem('newActivePlugins', '[]')
}
if (JSON.parse(localStorage.getItem('updatedInactives')) === null) {
localStorage.setItem('updatedInactives', '[]')
}
if (JSON.parse(localStorage.getItem('plugins/local')) === null) {
localStorage.setItem('plugins/local', '{}')
}
if (JSON.parse(localStorage.getItem('activatedPluginNames'))) {
localStorage.setItem('activatedPluginNames', '[]')
}
return (
<RootView pluginComponent={pluginComponent}>
<section data-id="pluginManagerComponentPluginManagerSection">

Loading…
Cancel
Save