feat: more work on form decorators

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-10-28 16:22:34 +01:00
parent 8d732a8d75
commit 7e3ca8be71
13 changed files with 109 additions and 68 deletions
@@ -95,11 +95,11 @@ export const Workflow = (workflowProps: WorkflowProps): JSX.Element | null => {
async (originalFormState: Record<string, JsonValue>) => {
let formState: Record<string, JsonValue> = { ...originalFormState };
if (manifest?.EXPERIMENTAL_formDecorators && formDecorators?.size) {
if (manifest?.EXPERIMENTAL_formDecorators) {
// for each of the form decorators, go and call the decorator with the context
await Promise.all(
manifest.EXPERIMENTAL_formDecorators.map(async decorator => {
const formDecorator = formDecorators.get(decorator.id);
const formDecorator = formDecorators?.get(decorator.id);
if (!formDecorator) {
// eslint-disable-next-line no-console
console.error('Failed to find form decorator', decorator.id);
@@ -52,6 +52,12 @@ export type ScaffolderFormDecorator<
) => Promise<void>;
};
/** @alpha */
export type AnyScaffolderFormDecorator = ScaffolderFormDecorator<
{ [key in string]: (zImpl: typeof z) => z.ZodType },
{ [key in string]: AnyApiRef },
any
>;
/**
* Method for creating decorators which can be used to collect
* secrets from the user before submitting to the backend.