-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { PluginManager } from "./plugins/pluginManager"; | ||
import { IndexPage } from "../pages"; | ||
import { PluginManagerProvider } from "./plugins/pluginsContext"; | ||
|
||
interface AppProps { | ||
pluginManager: PluginManager; | ||
} | ||
|
||
const LakeFSApp: React.FC<AppProps> = ({pluginManager}) => { | ||
return ( | ||
<PluginManagerProvider pluginManager={pluginManager}> | ||
<IndexPage/> | ||
</PluginManagerProvider> | ||
); | ||
}; | ||
|
||
export default LakeFSApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; | ||
|
||
export interface AppTab { | ||
id: string; | ||
name: string; | ||
component: React.FC; | ||
} | ||
|
||
export interface PluginAppTabs { | ||
tabs: AppTab[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { PluginAppTabs } from './pluginAppTabs'; | ||
|
||
export class PluginManager { | ||
private _appTabs: PluginAppTabs | null = null; | ||
|
||
registerPluginAppTabs(pluginAppTabs: PluginAppTabs) { | ||
this._appTabs = pluginAppTabs; | ||
} | ||
|
||
get appTabs(): PluginAppTabs | null { | ||
return this._appTabs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { createContext, useContext } from 'react'; | ||
import { PluginManager } from "./pluginManager"; | ||
|
||
const PluginsContext = createContext<PluginManager | undefined>(undefined); | ||
|
||
interface PluginManagerProviderProps { | ||
pluginManager: PluginManager; | ||
children: React.ReactNode; | ||
} | ||
|
||
export const PluginManagerProvider: React.FC<PluginManagerProviderProps> = ({pluginManager, children}) => { | ||
return ( | ||
<PluginsContext.Provider value={pluginManager}> | ||
{children} | ||
</PluginsContext.Provider> | ||
); | ||
}; | ||
|
||
export const usePluginManager = (): PluginManager => { | ||
const context = useContext(PluginsContext); | ||
if (!context) { | ||
throw new Error('usePluginManager must be used within a PluginManagerProvider'); | ||
} | ||
return context; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters