Commit f4b0e303 authored by joseph izang's avatar joseph izang

implement isActive logic for plugins

parent b7e37f1c
...@@ -106,6 +106,7 @@ class PluginManagerComponent extends ViewPlugin { ...@@ -106,6 +106,7 @@ class PluginManagerComponent extends ViewPlugin {
this.filter = '' this.filter = ''
this.activePlugins = [] this.activePlugins = []
this.inactivePlugins = [] this.inactivePlugins = []
this.activePlugins = this.appManager.actives
// this.appManager.event.on('activate', () => { this.reRender() }) // this.appManager.event.on('activate', () => { this.reRender() })
// this.appManager.event.on('deactivate', () => { this.reRender() }) // this.appManager.event.on('deactivate', () => { this.reRender() })
// this.engine.event.on('onRegistration', () => { this.reRender() }) // this.engine.event.on('onRegistration', () => { this.reRender() })
...@@ -123,7 +124,7 @@ class PluginManagerComponent extends ViewPlugin { ...@@ -123,7 +124,7 @@ class PluginManagerComponent extends ViewPlugin {
appManager={this.appManager} appManager={this.appManager}
engine={this.engine} engine={this.engine}
localPlugin={this.localPlugin} localPlugin={this.localPlugin}
isActive={() => false} activePlugins={this.activePlugins}
actives={this.activePlugins} actives={this.activePlugins}
inactives={this.inactivePlugins} inactives={this.inactivePlugins}
/>, />,
......
...@@ -9,7 +9,7 @@ interface PluginCardProps { ...@@ -9,7 +9,7 @@ interface PluginCardProps {
// eslint-disable-next-line no-empty-pattern // eslint-disable-next-line no-empty-pattern
function PluginCard ({ profile }: PluginCardProps) { function PluginCard ({ profile }: PluginCardProps) {
const { isActive } = useContext(PluginManagerContext) const { activePlugins } = useContext(PluginManagerContext)
const [displayName] = useState<string>((profile.displayName) ? profile.displayName : profile.name) const [displayName] = useState<string>((profile.displayName) ? profile.displayName : profile.name)
const [docLink] = useState<JSX.Element>((profile.documentation) ? ( const [docLink] = useState<JSX.Element>((profile.documentation) ? (
<a href={profile.documentation} className="px-1" title="link to documentation" target="_blank" rel="noreferrer"> <a href={profile.documentation} className="px-1" title="link to documentation" target="_blank" rel="noreferrer">
...@@ -31,7 +31,7 @@ function PluginCard ({ profile }: PluginCardProps) { ...@@ -31,7 +31,7 @@ function PluginCard ({ profile }: PluginCardProps) {
{docLink} {docLink}
{versionWarning} {versionWarning}
</div> </div>
{ isActive(profile.name) ? ( { activePlugins.includes(profile.name) ? (
<Button <Button
buttonText="Deactivate" buttonText="Deactivate"
/>) : <Button buttonText="Activate" /> />) : <Button buttonText="Activate" />
......
...@@ -107,11 +107,12 @@ export interface PluginManagerContextProviderProps { ...@@ -107,11 +107,12 @@ export interface PluginManagerContextProviderProps {
localPlugin: LocalPlugin localPlugin: LocalPlugin
_paq: _Paq _paq: _Paq
filter: string filter: string
activePlugins: string[]
actives: Partial<PluginManagerProfile>[] actives: Partial<PluginManagerProfile>[]
inactives: Partial<PluginManagerProfile>[] inactives: Partial<PluginManagerProfile>[]
activatePlugin: (name: string) => void activatePlugin: (name: string) => void
deActivatePlugin: (name: string) => void deActivatePlugin: (name: string) => void
isActive: (name: string) => boolean isActive?: (name: string) => boolean
filterPlugins: () => void filterPlugins: () => void
profile: Partial<PluginManagerProfile> profile: Partial<PluginManagerProfile>
defaultProfile: DefaultLocalPlugin defaultProfile: DefaultLocalPlugin
...@@ -124,11 +125,12 @@ export interface RemixUiPluginManagerProps { ...@@ -124,11 +125,12 @@ export interface RemixUiPluginManagerProps {
localPlugin: LocalPlugin localPlugin: LocalPlugin
_paq: _Paq _paq: _Paq
filter: string filter: string
activePlugins: string[]
actives: Partial<PluginManagerProfile>[] actives: Partial<PluginManagerProfile>[]
inactives: Partial<PluginManagerProfile>[] inactives: Partial<PluginManagerProfile>[]
activatePlugin: (name: string) => void activatePlugin: (name: string) => void
deActivatePlugin: (name: string) => void deActivatePlugin: (name: string) => void
isActive: (name: string) => boolean isActive?: (name: string) => boolean
filterPlugins: () => void filterPlugins: () => void
profile: Partial<PluginManagerProfile> profile: Partial<PluginManagerProfile>
headingLabel: string headingLabel: string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment