diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx
index 6cf10d7f08..38e92fc26a 100644
--- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx
+++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.test.tsx
@@ -326,4 +326,60 @@ describe('createExtensionBlueprint', () => {
expect(true).toBe(true);
});
+
+ it('should allow providing callback for properties to set with params', () => {
+ const Blueprint = createExtensionBlueprint({
+ kind: 'test-extension',
+ attachTo: { id: 'test', input: 'default' },
+ output: [coreExtensionData.reactElement],
+ namespace: props => props.test,
+ name: props => `${props.test}-name`,
+ config: {
+ schema: props => ({
+ test: z => z.string().default(props.test),
+ }),
+ },
+ factory(params: { test: string }) {
+ return [coreExtensionData.reactElement(
{params.test}
)];
+ },
+ });
+
+ expect(Blueprint.make({ params: { test: 'hello' } }))
+ .toMatchInlineSnapshot(`
+ {
+ "$$type": "@backstage/ExtensionDefinition",
+ "attachTo": {
+ "id": "test",
+ "input": "default",
+ },
+ "configSchema": {
+ "parse": [Function],
+ "schema": {
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "additionalProperties": false,
+ "properties": {
+ "test": {
+ "default": "test",
+ "type": "string",
+ },
+ },
+ "type": "object",
+ },
+ },
+ "disabled": false,
+ "factory": [Function],
+ "inputs": {},
+ "kind": "test-extension",
+ "name": "hello-name",
+ "namespace": "hello",
+ "output": [
+ [Function],
+ ],
+ "toString": [Function],
+ "version": "v2",
+ }
+ `);
+
+ expect(true).toBe(true);
+ });
});
diff --git a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts
index b579cc207a..4a8f4a7c46 100644
--- a/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts
+++ b/packages/frontend-plugin-api/src/wiring/createExtensionBlueprint.ts
@@ -47,14 +47,14 @@ export type CreateExtensionBlueprintOptions<
UFactoryOutput extends ExtensionDataValue,
TDataRefs extends { [name in string]: AnyExtensionDataRef },
> = {
- kind: string;
- namespace?: string;
+ kind: string | ((params: TParams) => string);
+ namespace?: string | ((params: TParams) => string);
attachTo: { id: string; input: string };
disabled?: boolean;
inputs?: TInputs;
output: Array;
config?: {
- schema: TConfigSchema;
+ schema: TConfigSchema | ((params: TParams) => TConfigSchema);
};
factory(
params: TParams,
@@ -254,6 +254,7 @@ class ExtensionBlueprintImpl<
...this.options.config?.schema,
...args.config?.schema,
} as TConfigSchema & TExtensionConfigSchema;
+
return createExtension({
kind: this.options.kind,
namespace: args.namespace ?? this.options.namespace,