implement isActive logic for plugins

pull/1344/head
joseph izang 3 years ago
parent cd878f1ad5
commit 576acde1e0
  1. 3
      apps/remix-ide/src/app/components/plugin-manager-component.js
  2. 4
      libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx
  3. 6
      libs/remix-ui/plugin-manager/src/types.d.ts

@ -106,6 +106,7 @@ class PluginManagerComponent extends ViewPlugin {
this.filter = ''
this.activePlugins = []
this.inactivePlugins = []
this.activePlugins = this.appManager.actives
// this.appManager.event.on('activate', () => { this.reRender() })
// this.appManager.event.on('deactivate', () => { this.reRender() })
// this.engine.event.on('onRegistration', () => { this.reRender() })
@ -123,7 +124,7 @@ class PluginManagerComponent extends ViewPlugin {
appManager={this.appManager}
engine={this.engine}
localPlugin={this.localPlugin}
isActive={() => false}
activePlugins={this.activePlugins}
actives={this.activePlugins}
inactives={this.inactivePlugins}
/>,

@ -9,7 +9,7 @@ interface PluginCardProps {
// eslint-disable-next-line no-empty-pattern
function PluginCard ({ profile }: PluginCardProps) {
const { isActive } = useContext(PluginManagerContext)
const { activePlugins } = useContext(PluginManagerContext)
const [displayName] = useState<string>((profile.displayName) ? profile.displayName : profile.name)
const [docLink] = useState<JSX.Element>((profile.documentation) ? (
<a href={profile.documentation} className="px-1" title="link to documentation" target="_blank" rel="noreferrer">
@ -31,7 +31,7 @@ function PluginCard ({ profile }: PluginCardProps) {
{docLink}
{versionWarning}
</div>
{ isActive(profile.name) ? (
{ activePlugins.includes(profile.name) ? (
<Button
buttonText="Deactivate"
/>) : <Button buttonText="Activate" />

@ -107,11 +107,12 @@ export interface PluginManagerContextProviderProps {
localPlugin: LocalPlugin
_paq: _Paq
filter: string
activePlugins: string[]
actives: Partial<PluginManagerProfile>[]
inactives: Partial<PluginManagerProfile>[]
activatePlugin: (name: string) => void
deActivatePlugin: (name: string) => void
isActive: (name: string) => boolean
isActive?: (name: string) => boolean
filterPlugins: () => void
profile: Partial<PluginManagerProfile>
defaultProfile: DefaultLocalPlugin
@ -124,11 +125,12 @@ export interface RemixUiPluginManagerProps {
localPlugin: LocalPlugin
_paq: _Paq
filter: string
activePlugins: string[]
actives: Partial<PluginManagerProfile>[]
inactives: Partial<PluginManagerProfile>[]
activatePlugin: (name: string) => void
deActivatePlugin: (name: string) => void
isActive: (name: string) => boolean
isActive?: (name: string) => boolean
filterPlugins: () => void
profile: Partial<PluginManagerProfile>
headingLabel: string

Loading…
Cancel
Save