Make it possible to configure certain tings per template
Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -365,6 +365,7 @@ export async function createRouter(
|
||||
const parameters = [template.spec.parameters ?? []].flat();
|
||||
res.json({
|
||||
title: template.metadata.title ?? template.metadata.name,
|
||||
configurations: template.spec.configurations ?? {},
|
||||
description: template.metadata.description,
|
||||
'ui:options': template.metadata['ui:options'],
|
||||
steps: parameters.map(schema => ({
|
||||
|
||||
@@ -45,6 +45,9 @@ export interface TemplateEntityV1beta3 extends Entity {
|
||||
* The type that the Template will create. For example service, website or library.
|
||||
*/
|
||||
type: string;
|
||||
|
||||
configurations?: TemplateConfigurationsV1beta3;
|
||||
|
||||
/**
|
||||
* This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend
|
||||
* to collect user input and validate it against that schema. This can then be used in the `steps` part below to template
|
||||
@@ -67,6 +70,11 @@ export interface TemplateEntityV1beta3 extends Entity {
|
||||
};
|
||||
}
|
||||
|
||||
export interface TemplateConfigurationsV1beta3 {
|
||||
kickOffButtonText?: string;
|
||||
reviewButtonText?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step that is part of a Template Entity.
|
||||
*
|
||||
|
||||
@@ -27,6 +27,7 @@ export {
|
||||
isTemplateEntityV1beta3,
|
||||
} from './TemplateEntityV1beta3';
|
||||
export type {
|
||||
TemplateConfigurationsV1beta3,
|
||||
TemplateEntityV1beta3,
|
||||
TemplateEntityStepV1beta3,
|
||||
TemplateParametersV1beta3,
|
||||
|
||||
@@ -91,7 +91,7 @@ export const Stepper = (stepperProps: StepperProps) => {
|
||||
reviewButtonText = 'Review',
|
||||
} = components;
|
||||
const analytics = useAnalytics();
|
||||
const { steps } = useTemplateSchema(props.manifest);
|
||||
const { configurations, steps } = useTemplateSchema(props.manifest);
|
||||
const apiHolder = useApiHolder();
|
||||
const [activeStep, setActiveStep] = useState(0);
|
||||
const [isValidating, setIsValidating] = useState(false);
|
||||
@@ -229,7 +229,7 @@ export const Stepper = (stepperProps: StepperProps) => {
|
||||
);
|
||||
}}
|
||||
>
|
||||
{createButtonText}
|
||||
{configurations.kickOffButtonText ?? createButtonText}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { featureFlagsApiRef, useApi } from '@backstage/core-plugin-api';
|
||||
import { TemplateConfigurationsV1beta3 } from '@backstage/plugin-scaffolder-common';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { UiSchema } from '@rjsf/utils';
|
||||
import { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';
|
||||
@@ -39,7 +40,10 @@ export interface ParsedTemplateSchema {
|
||||
*/
|
||||
export const useTemplateSchema = (
|
||||
manifest: TemplateParameterSchema,
|
||||
): { steps: ParsedTemplateSchema[] } => {
|
||||
): {
|
||||
steps: ParsedTemplateSchema[];
|
||||
configurations: TemplateConfigurationsV1beta3;
|
||||
} => {
|
||||
const featureFlags = useApi(featureFlagsApiRef);
|
||||
const steps = manifest.steps.map(({ title, description, schema }) => ({
|
||||
title,
|
||||
@@ -76,6 +80,7 @@ export const useTemplateSchema = (
|
||||
}));
|
||||
|
||||
return {
|
||||
configurations: manifest.configurations,
|
||||
steps: returningSteps,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
import { JsonObject } from '@backstage/types';
|
||||
|
||||
import { TemplateConfigurationsV1beta3 } from '@backstage/plugin-scaffolder-common';
|
||||
|
||||
/**
|
||||
* The shape of each entry of parameters which gets rendered
|
||||
* as a separate step in the wizard input
|
||||
@@ -25,6 +27,7 @@ import { JsonObject } from '@backstage/types';
|
||||
export type TemplateParameterSchema = {
|
||||
title: string;
|
||||
description?: string;
|
||||
configurations?: TemplateConfigurationsV1beta3;
|
||||
steps: Array<{
|
||||
title: string;
|
||||
description?: string;
|
||||
|
||||
Reference in New Issue
Block a user