chore: adding some more useful state to the context
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -20,14 +20,16 @@ import { ScaffolderFormDecorator } from '@backstage/plugin-scaffolder-react/alph
|
||||
export class DefaultScaffolderFormDecoratorsApi
|
||||
implements ScaffolderFormDecoratorsApi
|
||||
{
|
||||
constructor(
|
||||
private constructor(
|
||||
private readonly options: {
|
||||
decorators: Array<ScaffolderFormDecorator>;
|
||||
},
|
||||
) {}
|
||||
|
||||
static create(options: { decorators: ScaffolderFormDecorator[] }) {
|
||||
return new DefaultScaffolderFormDecoratorsApi(options);
|
||||
static create(options?: { decorators: ScaffolderFormDecorator[] }) {
|
||||
return new DefaultScaffolderFormDecoratorsApi(
|
||||
options ?? { decorators: [] },
|
||||
);
|
||||
}
|
||||
|
||||
async getFormDecorators(): Promise<ScaffolderFormDecorator[]> {
|
||||
|
||||
@@ -71,6 +71,8 @@ describe('useFormDecorators', () => {
|
||||
expect(testDecorator).toBeDefined();
|
||||
|
||||
await testDecorator.fn({
|
||||
formState: {},
|
||||
setFormState: () => {},
|
||||
setSecrets: () => {},
|
||||
input: { test: 'input value' },
|
||||
});
|
||||
|
||||
@@ -78,6 +78,8 @@ import {
|
||||
} from './components/fields/MyGroupsPicker/MyGroupsPicker';
|
||||
import { RepoBranchPicker } from './components/fields/RepoBranchPicker/RepoBranchPicker';
|
||||
import { RepoBranchPickerSchema } from './components/fields/RepoBranchPicker/schema';
|
||||
import { formDecoratorsApiRef } from './alpha/api/ref';
|
||||
import { DefaultScaffolderFormDecoratorsApi } from './alpha/api/FormDecoratorsApi';
|
||||
|
||||
/**
|
||||
* The main plugin export for the scaffolder.
|
||||
@@ -102,6 +104,11 @@ export const scaffolderPlugin = createPlugin({
|
||||
identityApi,
|
||||
}),
|
||||
}),
|
||||
createApiFactory({
|
||||
api: formDecoratorsApiRef,
|
||||
deps: {},
|
||||
factory: () => DefaultScaffolderFormDecoratorsApi.create(),
|
||||
}),
|
||||
],
|
||||
routes: {
|
||||
root: rootRouteRef,
|
||||
|
||||
Reference in New Issue
Block a user