From 596b7cf1a00729b06b80e967e6d2e0e834e213e9 Mon Sep 17 00:00:00 2001 From: Alex Rybchenko Date: Fri, 18 Nov 2022 14:47:10 +0100 Subject: [PATCH 1/3] initial support of ui options in scaffolder forms Signed-off-by: Alex Rybchenko --- .../sample-templates/bitbucket-demo/template.yaml | 2 ++ plugins/scaffolder-backend/src/service/router.ts | 1 + plugins/scaffolder/api-report.md | 3 +++ .../scaffolder/src/components/TemplatePage/TemplatePage.tsx | 1 + plugins/scaffolder/src/types.ts | 3 +++ 5 files changed, 10 insertions(+) diff --git a/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml b/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml index 52714f6d73..269c3be1a6 100644 --- a/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml @@ -4,6 +4,8 @@ metadata: name: bitbucket-demo title: Test Bitbucket RepoUrlPicker template description: scaffolder v1beta3 template demo publishing to bitbucket + ui:options: + finishButtonLabel: Publish spec: owner: backstage/techdocs-core type: service diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts index eff7e95c50..be3c89601c 100644 --- a/plugins/scaffolder-backend/src/service/router.ts +++ b/plugins/scaffolder-backend/src/service/router.ts @@ -259,6 +259,7 @@ export async function createRouter( res.json({ title: template.metadata.title ?? template.metadata.name, description: template.metadata.description, + 'ui:options': template.metadata['ui:options'], steps: parameters.map(schema => ({ title: schema.title ?? 'Please enter the following information', description: schema.description, diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index 33a5f8c2fe..e9cbc5bb0e 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -640,6 +640,9 @@ export type TemplateGroupFilter = { export type TemplateParameterSchema = { title: string; description?: string; + ['ui:options']?: { + finishButtonLabel?: string; + }; steps: Array<{ title: string; description?: string; diff --git a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx index 87678d2a83..4b2de4b56e 100644 --- a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx +++ b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx @@ -152,6 +152,7 @@ export const TemplatePage = ({ onReset={handleFormReset} onFinish={handleCreate} layouts={layouts} + finishButtonLabel={schema['ui:options']?.finishButtonLabel} steps={schema.steps.map(step => { return { ...step, diff --git a/plugins/scaffolder/src/types.ts b/plugins/scaffolder/src/types.ts index acb0f0e114..8645fc8697 100644 --- a/plugins/scaffolder/src/types.ts +++ b/plugins/scaffolder/src/types.ts @@ -80,6 +80,9 @@ export type ScaffolderTaskOutput = { export type TemplateParameterSchema = { title: string; description?: string; + ['ui:options']?: { + finishButtonLabel?: string; + }; steps: Array<{ title: string; description?: string; From 777d6c7bdce0f1f741e32e6928a3caf0fe873873 Mon Sep 17 00:00:00 2001 From: Alex Rybchenko Date: Wed, 23 Nov 2022 15:53:36 +0100 Subject: [PATCH 2/3] leave only backend changes Signed-off-by: Alex Rybchenko --- .../sample-templates/bitbucket-demo/template.yaml | 2 -- plugins/scaffolder/api-report.md | 3 --- .../scaffolder/src/components/TemplatePage/TemplatePage.tsx | 1 - plugins/scaffolder/src/types.ts | 3 --- 4 files changed, 9 deletions(-) diff --git a/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml b/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml index 269c3be1a6..52714f6d73 100644 --- a/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/bitbucket-demo/template.yaml @@ -4,8 +4,6 @@ metadata: name: bitbucket-demo title: Test Bitbucket RepoUrlPicker template description: scaffolder v1beta3 template demo publishing to bitbucket - ui:options: - finishButtonLabel: Publish spec: owner: backstage/techdocs-core type: service diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index e9cbc5bb0e..33a5f8c2fe 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -640,9 +640,6 @@ export type TemplateGroupFilter = { export type TemplateParameterSchema = { title: string; description?: string; - ['ui:options']?: { - finishButtonLabel?: string; - }; steps: Array<{ title: string; description?: string; diff --git a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx index 4b2de4b56e..87678d2a83 100644 --- a/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx +++ b/plugins/scaffolder/src/components/TemplatePage/TemplatePage.tsx @@ -152,7 +152,6 @@ export const TemplatePage = ({ onReset={handleFormReset} onFinish={handleCreate} layouts={layouts} - finishButtonLabel={schema['ui:options']?.finishButtonLabel} steps={schema.steps.map(step => { return { ...step, diff --git a/plugins/scaffolder/src/types.ts b/plugins/scaffolder/src/types.ts index 8645fc8697..acb0f0e114 100644 --- a/plugins/scaffolder/src/types.ts +++ b/plugins/scaffolder/src/types.ts @@ -80,9 +80,6 @@ export type ScaffolderTaskOutput = { export type TemplateParameterSchema = { title: string; description?: string; - ['ui:options']?: { - finishButtonLabel?: string; - }; steps: Array<{ title: string; description?: string; From b07ccffad01f34abefa9cb3e5b313a9ab5a23e47 Mon Sep 17 00:00:00 2001 From: Alex Rybchenko Date: Wed, 23 Nov 2022 16:01:22 +0100 Subject: [PATCH 3/3] added changeset Signed-off-by: Alex Rybchenko --- .changeset/nasty-lizards-train.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nasty-lizards-train.md diff --git a/.changeset/nasty-lizards-train.md b/.changeset/nasty-lizards-train.md new file mode 100644 index 0000000000..82d49cf682 --- /dev/null +++ b/.changeset/nasty-lizards-train.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Backend now returns 'ui:options' value from template metadata, it can be used by all your custom scaffolder components.