Make it possible to configure certain tings per template

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2023-10-09 17:41:26 +02:00
parent 6498ee3582
commit 2e2b1f94e0
6 changed files with 21 additions and 3 deletions
@@ -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,
};
};
+3
View File
@@ -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;