From 97f3d6b0563c1562eb247de6242dc23efdad825a Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Mon, 29 Jun 2020 14:55:00 +0200 Subject: [PATCH] fix(scaffolder): make integration work --- .../react-ssr-template/template.yaml | 19 ++++-- .../src/scaffolder/jobs/processor.ts | 1 + .../src/components/CreatePage/CreatePage.tsx | 25 ++++++-- yarn.lock | 63 ++++++++----------- 4 files changed, 62 insertions(+), 46 deletions(-) diff --git a/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml b/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml index e01eb4cb45..39100308bf 100644 --- a/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml +++ b/plugins/scaffolder-backend/sample-templates/react-ssr-template/template.yaml @@ -11,8 +11,17 @@ spec: processor: cookiecutter type: website path: '.' - parameters: - component_name: - title: Component name - type: string - description: Name of the component + schema: + required: + - component_id + - description + properties: + component_id: + title: Name + type: string + description: Unique name of the component + description: + title: Description + type: string + description: Description of the component + diff --git a/plugins/scaffolder-backend/src/scaffolder/jobs/processor.ts b/plugins/scaffolder-backend/src/scaffolder/jobs/processor.ts index 1c76ae252d..c33ff13e00 100644 --- a/plugins/scaffolder-backend/src/scaffolder/jobs/processor.ts +++ b/plugins/scaffolder-backend/src/scaffolder/jobs/processor.ts @@ -98,6 +98,7 @@ export class JobProcessor implements Processor { try { // Run the handler with the context created for the Job and some // Additional logging helpers. + stage.status = 'STARTED'; const handlerResponse = await stage.handler({ ...job.context, logger, diff --git a/plugins/scaffolder/src/components/CreatePage/CreatePage.tsx b/plugins/scaffolder/src/components/CreatePage/CreatePage.tsx index f67a6dbd8e..23b7232cf4 100644 --- a/plugins/scaffolder/src/components/CreatePage/CreatePage.tsx +++ b/plugins/scaffolder/src/components/CreatePage/CreatePage.tsx @@ -1,3 +1,18 @@ +/* + * Copyright 2020 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 React, { useState } from 'react'; import useStaleWhileRevalidate from 'swr'; import { useParams } from 'react-router-dom'; @@ -43,8 +58,9 @@ export const CreatePage = () => { const [jobId, setJobId] = useState(null); const handleClose = () => setJobId(null); + if (!template && isValidating) return ; - if (!template || !template?.spec?.parameters) return null; + if (!template || !template?.spec?.schema) return null; const handleCreate = async () => { const job = await scaffolderApi.scaffold(template, formState); @@ -63,10 +79,9 @@ export const CreatePage = () => { subtitle="Create new software components using standard templates" /> - + {jobId && } + {/* { if (nextStep === 2) { @@ -80,7 +95,7 @@ export const CreatePage = () => { onChange={handleChange} schema={{ $schema: 'http://json-schema.org/draft-07/schema#', - properties: template?.spec?.parameters, + ...template?.spec?.schema, }} >