remove GetProps type from layouts

Signed-off-by: Paul Cowan <paul.cowan@cutting.scot>
This commit is contained in:
Paul Cowan
2022-09-20 12:25:57 +01:00
parent 4cd0f45a85
commit 99b0e29920
3 changed files with 6 additions and 31 deletions
+2 -10
View File
@@ -21,7 +21,6 @@ import { IdentityApi } from '@backstage/core-plugin-api';
import { JsonObject } from '@backstage/types';
import { JSONSchema7 } from 'json-schema';
import { JsonValue } from '@backstage/types';
import { ObjectFieldTemplateProps } from '@rjsf/core';
import { Observable } from '@backstage/types';
import { PropsWithChildren } from 'react';
import { default as React_2 } from 'react';
@@ -40,9 +39,9 @@ export function createScaffolderFieldExtension<
): Extension<FieldExtensionComponent<TReturnValue, TInputProps>>;
// @public
export function createScaffolderLayout(
export function createScaffolderLayout<TInputProps = unknown>(
options: LayoutOptions,
): Extension<GetProps<typeof options>>;
): Extension<LayoutComponent<TInputProps>>;
// @public
export type CustomFieldValidator<TFieldReturnValue> = (
@@ -117,13 +116,6 @@ export type FieldExtensionOptions<
validation?: CustomFieldValidator<TFieldReturnValue>;
};
// @public
export type GetProps<T> = T extends LayoutOptions
? T['component'] extends LayoutTemplate<infer P>
? LayoutComponent<ObjectFieldTemplateProps<P>>
: never
: never;
// @public
export type LayoutComponent<_TInputProps> = () => null;
+1 -6
View File
@@ -49,12 +49,7 @@ export type {
FieldExtensionComponent,
} from './extensions';
export { createScaffolderLayout, ScaffolderLayouts } from './layouts';
export type {
LayoutOptions,
LayoutTemplate,
GetProps,
LayoutComponent,
} from './layouts';
export type { LayoutOptions, LayoutTemplate, LayoutComponent } from './layouts';
export {
EntityPickerFieldExtension,
EntityNamePickerFieldExtension,
+3 -15
View File
@@ -15,8 +15,7 @@
*/
import { attachComponentData, Extension } from '@backstage/core-plugin-api';
import { ObjectFieldTemplateProps } from '@rjsf/core';
import type { LayoutOptions, LayoutTemplate } from './types';
import type { LayoutOptions } from './types';
export const LAYOUTS_KEY = 'scaffolder.layout.v1';
export const LAYOUTS_WRAPPER_KEY = 'scaffolder.layouts.wrapper.v1';
@@ -28,25 +27,14 @@ export const LAYOUTS_WRAPPER_KEY = 'scaffolder.layouts.wrapper.v1';
*/
export type LayoutComponent<_TInputProps> = () => null;
/**
* utility type to extract the component props from the LayoutOptions
*
* @public
*/
export type GetProps<T> = T extends LayoutOptions
? T['component'] extends LayoutTemplate<infer P>
? LayoutComponent<ObjectFieldTemplateProps<P>>
: never
: never;
/**
* Method for creating custom Layouts that can be used in the scaffolder frontend form
*
* @public
*/
export function createScaffolderLayout(
export function createScaffolderLayout<TInputProps = unknown>(
options: LayoutOptions,
): Extension<GetProps<typeof options>> {
): Extension<LayoutComponent<TInputProps>> {
return {
expose() {
const LayoutDataHolder: any = () => null;