chore: refactor, and move the execution

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-11-19 12:44:47 +01:00
parent f217918b14
commit a8140e10aa
8 changed files with 109 additions and 69 deletions
@@ -17,7 +17,7 @@ import { githubAuthApiRef } from '@backstage/core-plugin-api';
import { createScaffolderFormDecorator } from '@backstage/plugin-scaffolder-react/alpha';
export const mockDecorator = createScaffolderFormDecorator({
id: 'githubOauth',
id: 'mock-decorator',
schema: {
input: {
test: z => z.string(),
@@ -26,8 +26,11 @@ export const mockDecorator = createScaffolderFormDecorator({
deps: {
githubApi: githubAuthApiRef,
},
decorator: async ({ setSecrets }, { githubApi }) => {
const token = await githubApi.getAccessToken();
setSecrets(state => ({ ...state, GITHUB_TOKEN: token }));
decorator: async (
{ setSecrets, setFormState, input: { test } },
{ githubApi: _githubApi },
) => {
setFormState(state => ({ ...state, test, mock: 'MOCK' }));
setSecrets(state => ({ ...state, GITHUB_TOKEN: 'MOCK_TOKEN' }));
},
});