()
function pluginChangeHandler (formProps: P, value: FormStateProps[P]) {
setPlugin({ ...plugin, [formProps]: value })
+ appManager.activatePlugin('')
}
const openModal = () => {
setVisible(false)
}
const closeModal = () => setVisible(true)
+ const isFiltered = (profile) => (profile.displayName ? profile.displayName : profile.name).toLowerCase().includes(filterPlugins)
+ const isNotRequired = (profile) => !appManager.isRequired(profile.name)
+ const isNotDependent = (profile) => !appManager.isDependent(profile.name)
+ const isNotHome = (profile) => profile.name !== 'home'
+ const sortByName = (profileA, profileB) => {
+ const nameA = ((profileA.displayName) ? profileA.displayName : profileA.name).toUpperCase()
+ const nameB = ((profileB.displayName) ? profileB.displayName : profileB.name).toUpperCase()
+ return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0
+ }
+
+ const getAndFilterPlugins = () => {
+ const { actives, inactives } = appManager.getAll()
+ .filter(isFiltered)
+ .filter(isNotRequired)
+ .filter(isNotDependent)
+ .filter(isNotHome)
+ .sort(sortByName)
+ .reduce(({ actives, inactives }, profile) => {
+ return activePluginNames.includes(profile.name)
+ ? { actives: [...actives, profile], inactives }
+ : { inactives: [...inactives, profile], actives }
+ }, { actives: [], inactives: [] })
+ setActiveP(actives)
+ setInactiveP(inactives)
+ }
+
useEffect(() => {
- // engine.event.on('onRegistration', () => )
+ setGetAndFilter(getAndFilterPlugins())
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [filterPlugins])
+
+ useEffect(() => {
+
})
+ console.log('This is the result of getting and filtering all plugins from app manager :', inactiveP)
return (
- {actives !== undefined
- ? ()
- : ()
+ {activeP !== undefined
+ ? (
+
+
+ {activeP.map((profile) => (
+
+ ))}
+
+ )
+ : null
}
- {inactives !== undefined ? () : }
+ {inactiveP !== undefined ? (
+
+
+ {inactiveP.map((profile) => (
+
+ ))}
+
+ ) : null}
diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx
index 26e5e33cbe..9d28b225a4 100644
--- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx
+++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx
@@ -5,7 +5,7 @@ import PluginManagerContextProvider from './contexts/pluginmanagercontext'
import './remix-ui-plugin-manager.css'
export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => {
- console.log('current state of appmanager', props.appManager)
+ console.log('current state of appmanager', props.pluginComponent)
console.log('The state of props ', props)
return (
diff --git a/libs/remix-ui/plugin-manager/src/types.d.ts b/libs/remix-ui/plugin-manager/src/types.d.ts
index 450f3a3336..23049a2430 100644
--- a/libs/remix-ui/plugin-manager/src/types.d.ts
+++ b/libs/remix-ui/plugin-manager/src/types.d.ts
@@ -2,48 +2,9 @@ import { PermissionHandler } from './app/ui/persmission-handler'
import { PluginManager } from '@remixproject/engine/lib/manager'
import { EventEmitter } from 'events'
import { Engine } from '@remixproject/engine/lib/engine'
-import { Profile } from '@remixproject/plugin-utils'
+import { PluginBase, Profile } from '@remixproject/plugin-utils'
+import { ViewPlugin } from '@remixproject/engine-web'
/* eslint-disable camelcase */
-
-// eslint-disable-next-line no-use-before-define
-export = LocalPlugin;
-declare class LocalPlugin {
- /**
- * Open a modal to create a local plugin
- * @param {Profile[]} plugins The list of the plugins in the store
- * @returns {Promise<{api: any, profile: any}>} A promise with the new plugin profile
- */
- open(plugins: any[]): Promise<{
- api: any;
- profile: any;
- }>;
-
- profile: any;
- /**
- * Create the object to add to the plugin-list
- */
- create(): any;
- updateName({ target }: {
- target: any;
- }): void;
-
- updateUrl({ target }: {
- target: any;
- }): void;
-
- updateDisplayName({ target }: {
- target: any;
- }): void;
-
- updateProfile(key: any, e: any): void;
- updateMethods({ target }: {
- target: any;
- }): void;
-
- /** The form to create a local plugin */
- form(): any;
-}
-
declare module 'yo-yo'{
interface yo_yo {
(strings:string[], ...values:any[]):HTMLElement;
@@ -99,17 +60,86 @@ export class RemixAppManager extends PluginManager {
turnPluginOff(name: string);
}
-export interface PluginManagerContextProviderProps {
+export class PluginManagerSettings {
+ openDialog(): void;
+ permissions: any;
+ currentSetting: any;
+ onValidation(): void;
+ /** Clear one permission from a plugin */
+ clearPersmission(from: any, to: any, method: any): void;
+ /** Clear all persmissions from a plugin */
+ clearAllPersmission(to: any): void;
+ settings(): any;
+ render(): any;
+}
+
+export class PluginManagerComponent extends ViewPlugin extends Plugin implements PluginBase {
+ constructor(appManager: RemixAppManager, engine: Engine)
appManager: RemixAppManager
- engine: RemixEngine
+ engine: Engine
+ htmlElement: HTMLDivElement
+ views: { root: null, items: {} }
localPlugin: LocalPlugin
- _paq: any
+ pluginNames: string[]
+ inactivePlugins: Profile[]
+ activePlugins: Profile[]
filter: string
+ isActive(name: string): boolean
+ activateP(name: string): void
+ deactivateP(name: string): void
+ onActivation(): void
+ renderComponent(): void
+ openLocalPlugin(): Promise
+ render(): HTMLDivElement
+ filterPlugins({ target }: { target: any }) : void
+}
+
+// eslint-disable-next-line no-use-before-define
+export = LocalPlugin;
+declare class LocalPlugin {
+ /**
+ * Open a modal to create a local plugin
+ * @param {Profile[]} plugins The list of the plugins in the store
+ * @returns {Promise<{api: any, profile: any}>} A promise with the new plugin profile
+ */
+ open(plugins: any[]): Promise<{
+ api: any;
+ profile: any;
+ }>;
+
+ profile: any;
+ /**
+ * Create the object to add to the plugin-list
+ */
+ create(): any;
+ updateName({ target }: {
+ target: any;
+ }): void;
+
+ updateUrl({ target }: {
+ target: any;
+ }): void;
+
+ updateDisplayName({ target }: {
+ target: any;
+ }): void;
+
+ updateProfile(key: any, e: any): void;
+ updateMethods({ target }: {
+ target: any;
+ }): void;
+
+ /** The form to create a local plugin */
+ form(): any;
+}
+
+export interface PluginManagerContextProviderProps {
+ appManager: RemixAppManager
+ pluginComponent: PluginManagerComponent
+ pluginSettings: PluginManagerSettings
activePluginNames: string[]
actives: Partial[]
inactives: Partial[]
- activatePlugin: (name: string) => void
- deActivatePlugin: (name: string) => void
isActive?: (name: string) => boolean
filterPlugins: () => void
profile: Partial
@@ -119,15 +149,11 @@ export interface PluginManagerContextProviderProps {
export interface RemixUiPluginManagerProps {
appManager: RemixAppManager
- engine: RemixEngine
- localPlugin: LocalPlugin
- _paq: any // Window & typeof globalThis | []
- filter: string
+ pluginComponent: PluginManagerComponent
+ pluginSettings: PluginManagerSettings // Window & typeof globalThis | []
activePluginNames: string[]
actives: Partial[]
inactives: Partial[]
- activatePlugin: (name: string) => void
- deActivatePlugin: (name: string) => void
isActive?: (name: string) => boolean
filterPlugins: () => void
profile: Partial