packages/core-api: add Progress as a configurable app component

This commit is contained in:
Patrik Oldsberg
2020-05-28 19:55:02 +02:00
parent a115bd6331
commit d120e5f8cb
3 changed files with 11 additions and 7 deletions
+8 -7
View File
@@ -149,14 +149,15 @@ export class PrivateAppImpl implements BackstageApp {
getProvider(): ComponentType<{}> {
const Provider: FC<{}> = ({ children }) => {
const config = useAsync(this.configLoader);
if (config.loading) {
return null;
}
let errorPage = undefined;
if (config.error) {
let childNode = children;
if (config.loading) {
const { Progress } = this.components;
childNode = <Progress />;
} else if (config.error) {
const { BootErrorPage } = this.components;
errorPage = <BootErrorPage step="load-config" error={config.error} />;
childNode = <BootErrorPage step="load-config" error={config.error} />;
}
const appApis = ApiRegistry.from([
@@ -168,7 +169,7 @@ export class PrivateAppImpl implements BackstageApp {
return (
<ApiProvider apis={apis}>
<AppContextProvider app={this}>
<AppThemeProvider>{errorPage ?? children}</AppThemeProvider>
<AppThemeProvider>{childNode}</AppThemeProvider>
</AppContextProvider>
</ApiProvider>
);
+1
View File
@@ -28,6 +28,7 @@ export type BootErrorPageProps = {
export type AppComponents = {
NotFoundErrorPage: ComponentType<{}>;
BootErrorPage: ComponentType<BootErrorPageProps>;
Progress: ComponentType<{}>;
};
/**
@@ -24,6 +24,7 @@ import privateExports, {
import { BrowserRouter as Router } from 'react-router-dom';
import { ErrorPage } from '../layout/ErrorPage';
import Progress from '../components/Progress';
import { lightTheme, darkTheme } from '@backstage/theme';
const { PrivateAppImpl } = privateExports;
@@ -59,6 +60,7 @@ export function createApp(options?: AppOptions) {
const components = {
NotFoundErrorPage: DefaultNotFoundPage,
BootErrorPage: DefaultBootErrorPage,
Progress: Progress,
...options?.components,
};
const themes = options?.themes ?? [