app-defaults,core-app-api: refactor into createApp/createSpecializedApp split

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-10-28 13:49:25 +02:00
parent 4217549648
commit 1c3413bab0
17 changed files with 63 additions and 539 deletions
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { apis, components, configLoader, icons, themes } from './defaults';
import { apis, components, icons, themes } from './defaults';
import {
AppTheme,
BackstagePlugin,
@@ -24,7 +24,7 @@ import {
AppComponents,
AppOptions,
AppIcons,
PrivateAppImpl,
createSpecializedApp,
} from '@backstage/core-app-api';
/**
@@ -33,8 +33,10 @@ import {
*
* @public
*/
export function createApp(options?: AppOptions) {
return new PrivateAppImpl({
export function createApp(
options?: Omit<AppOptions, keyof OptionalAppOptions> & OptionalAppOptions,
) {
return createSpecializedApp({
...options,
apis: options?.apis ?? [],
bindRoutes: options?.bindRoutes,
@@ -42,7 +44,7 @@ export function createApp(options?: AppOptions) {
...components,
...options?.components,
},
configLoader: options?.configLoader ?? configLoader,
configLoader: options?.configLoader,
defaultApis: apis,
icons: {
...icons,
@@ -53,16 +55,13 @@ export function createApp(options?: AppOptions) {
});
}
// NOTE: we don't re-export any of the types imported from core-app-api, as we
// want them to be imported from there rather than core-components.
/**
* The set of app options that will be populated by {@link withDefaults} if they
* are not passed in explicitly.
* The set of app options that {@link createApp} will provide defaults for
* if they are not passed in explicitly.
*
* @public
*/
export interface OptionalAppOptions {
export type OptionalAppOptions = {
/**
* A set of icons to override the default icons with.
*
@@ -91,4 +90,4 @@ export interface OptionalAppOptions {
* @public
*/
components?: Partial<AppComponents>;
}
};
@@ -1,17 +0,0 @@
/*
* Copyright 2020 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { createApp } from './createApp';
@@ -32,7 +32,7 @@ import MuiPeopleIcon from '@material-ui/icons/People';
import MuiPersonIcon from '@material-ui/icons/Person';
import MuiWarningIcon from '@material-ui/icons/Warning';
export const icons = () => ({
export const icons = {
brokenImage: MuiBrokenImageIcon as IconComponent,
// To be confirmed: see https://github.com/backstage/backstage/issues/4970
catalog: MuiMenuBookIcon as IconComponent,
@@ -52,4 +52,4 @@ export const icons = () => ({
'kind:user': MuiPersonIcon as IconComponent,
user: MuiPersonIcon as IconComponent,
warning: MuiWarningIcon as IconComponent,
});
};
+2 -1
View File
@@ -20,4 +20,5 @@
* @packageDocumentation
*/
export * from './createApp';
export { createApp } from './createApp';
export type { OptionalAppOptions } from './createApp';