Skip to content

Commit

Permalink
Plugin api improvements (#4935)
Browse files Browse the repository at this point in the history
* Support hook into App component
* Add hookable PluginSettings component
* Add useSettings to plugin hooks
* Make setting inputs hookable
* Add hooks for performer details panel
* Update docs
  • Loading branch information
WithoutPants authored Jun 11, 2024
1 parent ed057c9 commit 845d718
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 421 deletions.
80 changes: 45 additions & 35 deletions ui/v2.5/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { PluginRoutes } from "./plugins";
// import plugin_api to run code
import "./pluginApi";
import { ConnectionMonitor } from "./ConnectionMonitor";
import { PatchFunction } from "./patch";

const Performers = lazyComponent(
() => import("./components/Performers/Performers")
Expand Down Expand Up @@ -144,6 +145,13 @@ function sortPlugins(plugins: PluginList) {
return sorted;
}

const AppContainer: React.FC<React.PropsWithChildren<{}>> = PatchFunction(
"App",
(props: React.PropsWithChildren<{}>) => {
return <>{props.children}</>;
}
) as React.FC;

export const App: React.FC = () => {
const config = useConfiguration();
const [saveUI] = useConfigureUI();
Expand Down Expand Up @@ -357,41 +365,43 @@ export const App: React.FC = () => {
const titleProps = makeTitleProps();

return (
<ErrorBoundary>
{messages ? (
<IntlProvider
locale={language}
messages={messages}
formats={intlFormats}
>
<ConfigurationProvider
configuration={config.data?.configuration}
loading={config.loading}
<AppContainer>
<ErrorBoundary>
{messages ? (
<IntlProvider
locale={language}
messages={messages}
formats={intlFormats}
>
{maybeRenderReleaseNotes()}
<ToastProvider>
<ConnectionMonitor />
<Suspense fallback={<LoadingIndicator />}>
<LightboxProvider>
<ManualProvider>
<InteractiveProvider>
<Helmet {...titleProps} />
{maybeRenderNavbar()}
<div
className={`main container-fluid ${
appleRendering ? "apple" : ""
}`}
>
{renderContent()}
</div>
</InteractiveProvider>
</ManualProvider>
</LightboxProvider>
</Suspense>
</ToastProvider>
</ConfigurationProvider>
</IntlProvider>
) : null}
</ErrorBoundary>
<ConfigurationProvider
configuration={config.data?.configuration}
loading={config.loading}
>
{maybeRenderReleaseNotes()}
<ToastProvider>
<ConnectionMonitor />
<Suspense fallback={<LoadingIndicator />}>
<LightboxProvider>
<ManualProvider>
<InteractiveProvider>
<Helmet {...titleProps} />
{maybeRenderNavbar()}
<div
className={`main container-fluid ${
appleRendering ? "apple" : ""
}`}
>
{renderContent()}
</div>
</InteractiveProvider>
</ManualProvider>
</LightboxProvider>
</Suspense>
</ToastProvider>
</ConfigurationProvider>
</IntlProvider>
) : null}
</ErrorBoundary>
</AppContainer>
);
};
Loading

0 comments on commit 845d718

Please sign in to comment.