From 81e6f5542ccf8f515882d1427b86e1380c63906c Mon Sep 17 00:00:00 2001 From: blam Date: Wed, 12 May 2021 10:09:46 +0200 Subject: [PATCH] chore: starting to addthje scaffolder form extension point Signed-off-by: blam --- .../core-api/src/extensions/extensions.tsx | 2 +- packages/core-api/src/extensions/index.ts | 1 + plugins/scaffolder/src/extensions/index.tsx | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 plugins/scaffolder/src/extensions/index.tsx diff --git a/packages/core-api/src/extensions/extensions.tsx b/packages/core-api/src/extensions/extensions.tsx index 9f6412f960..d16f24c229 100644 --- a/packages/core-api/src/extensions/extensions.tsx +++ b/packages/core-api/src/extensions/extensions.tsx @@ -20,7 +20,7 @@ import { BackstagePlugin, Extension } from '../plugin/types'; import { RouteRef, useRouteRef } from '../routing'; import { attachComponentData } from './componentData'; -type ComponentLoader = +export type ComponentLoader = | { lazy: () => Promise; } diff --git a/packages/core-api/src/extensions/index.ts b/packages/core-api/src/extensions/index.ts index 26a0c597b1..2f80b1c42c 100644 --- a/packages/core-api/src/extensions/index.ts +++ b/packages/core-api/src/extensions/index.ts @@ -20,3 +20,4 @@ export { createRoutableExtension, createComponentExtension, } from './extensions'; +export type { ComponentLoader } from './extensions'; diff --git a/plugins/scaffolder/src/extensions/index.tsx b/plugins/scaffolder/src/extensions/index.tsx new file mode 100644 index 0000000000..71d762739d --- /dev/null +++ b/plugins/scaffolder/src/extensions/index.tsx @@ -0,0 +1,25 @@ +/* + * Copyright 2021 Spotify AB + * + * 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. + */ +import { Extension, ComponentLoader } from '@backstage/core'; + +export type FormExtensionOptions = { + name: string; + component: ComponentLoader; +}; + +export function createScaffolderFormExtension< + T extends (props: any) => JSX.Element | null +>(options: FormExtensionOptions): Extension {}