-
Notifications
You must be signed in to change notification settings - Fork 489
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
12 changed files
with
145 additions
and
106 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import React, { Suspense } from "react"; | ||
|
||
import ErrorBoundary from "@/components/Common/ErrorBoundary"; | ||
import Loading from "@/components/Common/Loading"; | ||
|
||
import { CareAppsContext, useCareApps } from "@/hooks/useCareApps"; | ||
|
||
import { SupportedPluginComponents, pluginMap } from "@/pluginTypes"; | ||
|
||
export default function PluginEngine({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<Suspense fallback={<Loading />}> | ||
<ErrorBoundary | ||
fallback={ | ||
<div className="flex h-screen w-screen items-center justify-center"> | ||
Error loading plugins | ||
</div> | ||
} | ||
> | ||
<CareAppsContext.Provider value={pluginMap}> | ||
{children} | ||
</CareAppsContext.Provider> | ||
</ErrorBoundary> | ||
</Suspense> | ||
); | ||
} | ||
|
||
type PluginProps<K extends keyof SupportedPluginComponents> = | ||
React.ComponentProps<SupportedPluginComponents[K]>; | ||
|
||
export function PLUGIN_Component<K extends keyof SupportedPluginComponents>({ | ||
__name, | ||
...props | ||
}: { __name: K } & PluginProps<K>) { | ||
const plugins = useCareApps(); | ||
|
||
return ( | ||
<> | ||
{plugins.map((plugin) => { | ||
const Component = plugin.components[ | ||
__name | ||
] as React.ComponentType<unknown>; | ||
|
||
if (!Component) { | ||
return null; | ||
} | ||
|
||
return <Component {...props} key={plugin.plugin} />; | ||
})} | ||
</> | ||
); | ||
} | ||
// /* eslint-disable i18next/no-literal-string */ | ||
// import React, { Suspense } from "react"; | ||
|
||
// import ErrorBoundary from "@/components/Common/ErrorBoundary"; | ||
// import Loading from "@/components/Common/Loading"; | ||
|
||
// import { CareAppsContext, useCareApps } from "@/hooks/useCareApps"; | ||
|
||
// // import { SupportedPluginComponents, pluginMap } from "@/pluginTypes"; | ||
|
||
// export default function PluginEngine({ | ||
// children, | ||
// }: { | ||
// children: React.ReactNode; | ||
// }) { | ||
// return ( | ||
// <Suspense fallback={<Loading />}> | ||
// <ErrorBoundary | ||
// fallback={ | ||
// <div className="flex h-screen w-screen items-center justify-center"> | ||
// Error loading plugins | ||
// </div> | ||
// } | ||
// > | ||
// <CareAppsContext.Provider value={pluginMap}> | ||
// {children} | ||
// </CareAppsContext.Provider> | ||
// </ErrorBoundary> | ||
// </Suspense> | ||
// ); | ||
// } | ||
|
||
// type PluginProps<K extends keyof SupportedPluginComponents> = | ||
// React.ComponentProps<SupportedPluginComponents[K]>; | ||
|
||
// export function PLUGIN_Component<K extends keyof SupportedPluginComponents>({ | ||
// __name, | ||
// ...props | ||
// }: { __name: K } & PluginProps<K>) { | ||
// const plugins = useCareApps(); | ||
|
||
// return ( | ||
// <> | ||
// {plugins.map((plugin) => { | ||
// const Component = plugin.components[ | ||
// __name | ||
// ] as React.ComponentType<unknown>; | ||
|
||
// if (!Component) { | ||
// return null; | ||
// } | ||
|
||
// return <Component {...props} key={plugin.plugin} />; | ||
// })} | ||
// </> | ||
// ); | ||
// } |
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
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
Oops, something went wrong.