@backstage/plugin-scaffolder 1.28.0-next.3 → 1.29.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/alpha/components/TemplateEditorPage/DryRunContext.esm.js +12 -4
  3. package/dist/alpha/components/TemplateEditorPage/DryRunContext.esm.js.map +1 -1
  4. package/dist/alpha/components/TemplateWizardPage/TemplateWizardPage.esm.js +3 -2
  5. package/dist/alpha/components/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -1
  6. package/dist/alpha/extensions.esm.js +20 -6
  7. package/dist/alpha/extensions.esm.js.map +1 -1
  8. package/dist/alpha/hooks/useFormDecorators.esm.js +16 -10
  9. package/dist/alpha/hooks/useFormDecorators.esm.js.map +1 -1
  10. package/dist/alpha.d.ts +8 -3
  11. package/dist/components/Router/Router.esm.js +20 -2
  12. package/dist/components/Router/Router.esm.js.map +1 -1
  13. package/dist/components/fields/EntityPicker/EntityPicker.esm.js +3 -1
  14. package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -1
  15. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +3 -0
  16. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -1
  17. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js +3 -1
  18. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js.map +1 -1
  19. package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js +11 -1
  20. package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js.map +1 -1
  21. package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js +2 -0
  22. package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js.map +1 -1
  23. package/dist/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.esm.js +11 -1
  24. package/dist/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.esm.js.map +1 -1
  25. package/dist/components/fields/RepoBranchPicker/RepoBranchPicker.esm.js +3 -0
  26. package/dist/components/fields/RepoBranchPicker/RepoBranchPicker.esm.js.map +1 -1
  27. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +6 -3
  28. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -1
  29. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +8 -3
  30. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -1
  31. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +3 -1
  32. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -1
  33. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +3 -2
  34. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -1
  35. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +11 -2
  36. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -1
  37. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +11 -2
  38. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -1
  39. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js +14 -2
  40. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js.map +1 -1
  41. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +2 -2
  42. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -1
  43. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +11 -3
  44. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -1
  45. package/dist/packages/scaffolder-internal/src/wiring/InternalFormField.esm.js +3 -1
  46. package/dist/packages/scaffolder-internal/src/wiring/InternalFormField.esm.js.map +1 -1
  47. package/package.json +14 -14
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @backstage/plugin-scaffolder
2
2
 
3
+ ## 1.29.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9d864ff: Allowed passing `ui:disabled` for disabling the input field of all the pickers.
8
+
9
+ ### Patch Changes
10
+
11
+ - 6a3fa48: Fixes DryRunContext not forwarding the correct Scaffolder Secrets to the DryRun API
12
+ - b3b7c9c: Updated the alpha `page:scaffolder` extension to accept `formFields` input, matching the updated `FormFieldBlueprint`.
13
+ - Updated dependencies
14
+ - @backstage/plugin-catalog-react@1.16.0-next.0
15
+ - @backstage/plugin-scaffolder-react@1.14.6-next.0
16
+ - @backstage/frontend-plugin-api@0.9.6-next.0
17
+ - @backstage/core-compat-api@0.3.7-next.0
18
+ - @backstage/integration-react@1.2.4
19
+
20
+ ## 1.28.0
21
+
22
+ ### Minor Changes
23
+
24
+ - 17088d2: Updating the `TaskLogStream` to take up all space in a running task, and also show the last line of the log by default
25
+ - 5d469c9: Added support for autocompletion of GitHub branches in scaffolder
26
+ - 8e67e4a: Added support for autocompletion to GithubRepoPicker component
27
+
28
+ ### Patch Changes
29
+
30
+ - 82300ea: Added support for experimental form decorators when dry-running templates in the template editor.
31
+ - eb3d91a: Use the custom error page if provided for displaying errors instead of the default error page
32
+ - 3107f1f: Fixed a bug in the BitbucketRepoBranchPicker component that crashed the scaffolder
33
+ - fe44946: Fixed bug of passing wrong value to `onChange` handler when using `GitLab` autocomplete
34
+ - 3edf7e7: Add schema output return type to the `makeFieldSchema` function return
35
+ - 1e935f0: Added conditional rendering of `oneOf` output schemas on the Installed Actions page for scaffolder actions
36
+ - 58ec9e7: Removed older versions of React packages as a preparatory step for upgrading to React 19. This commit does not introduce any functional changes, but removes dependencies on previous React versions, allowing for a cleaner upgrade path in subsequent commits.
37
+ - 65d7020: Use template title for ongoing task page header
38
+ - Updated dependencies
39
+ - @backstage/plugin-scaffolder-react@1.14.5
40
+ - @backstage/core-components@0.16.4
41
+ - @backstage/plugin-catalog-react@1.15.2
42
+ - @backstage/frontend-plugin-api@0.9.5
43
+ - @backstage/integration-react@1.2.4
44
+ - @backstage/core-compat-api@0.3.6
45
+ - @backstage/core-plugin-api@1.10.4
46
+ - @backstage/plugin-permission-react@0.4.31
47
+ - @backstage/catalog-client@1.9.1
48
+ - @backstage/catalog-model@1.7.3
49
+ - @backstage/errors@1.2.7
50
+ - @backstage/integration@1.16.1
51
+ - @backstage/types@1.2.1
52
+ - @backstage/plugin-catalog-common@1.1.3
53
+ - @backstage/plugin-scaffolder-common@1.5.9
54
+
3
55
  ## 1.28.0-next.3
4
56
 
5
57
  ### Minor Changes
@@ -1,7 +1,8 @@
1
1
  import yaml from 'yaml';
2
2
  import { useApi } from '@backstage/core-plugin-api';
3
3
  import React, { createContext, useState, useRef, useCallback, useMemo, useContext } from 'react';
4
- import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';
4
+ import { scaffolderApiRef, useTemplateSecrets } from '@backstage/plugin-scaffolder-react';
5
+ import { useFormDecorators } from '../../hooks/useFormDecorators.esm.js';
5
6
 
6
7
  const MAX_CONTENT_SIZE = 64 * 1024;
7
8
  const CHUNK_SIZE = 32 * 1024;
@@ -25,7 +26,9 @@ function base64EncodeContent(content) {
25
26
  }
26
27
  }
27
28
  function DryRunProvider(props) {
29
+ const decorators = useFormDecorators();
28
30
  const scaffolderApi = useApi(scaffolderApiRef);
31
+ const { secrets: contextSecrets } = useTemplateSecrets();
29
32
  const [state, setState] = useState({
30
33
  results: [],
31
34
  selectedResult: void 0
@@ -63,10 +66,15 @@ function DryRunProvider(props) {
63
66
  throw new Error("Scaffolder API does not support dry-run");
64
67
  }
65
68
  const parsed = yaml.parse(options.templateContent);
69
+ const { formState: values, secrets } = await decorators.run({
70
+ formState: options.values,
71
+ secrets: contextSecrets,
72
+ manifest: parsed?.spec
73
+ });
66
74
  const response = await scaffolderApi.dryRun({
67
75
  template: parsed,
68
- values: options.values,
69
- secrets: {},
76
+ values,
77
+ secrets,
70
78
  directoryContents: options.files.map((file) => ({
71
79
  path: file.path,
72
80
  base64Content: base64EncodeContent(file.content)
@@ -81,7 +89,7 @@ function DryRunProvider(props) {
81
89
  selectedResult: prevState.selectedResult ?? result
82
90
  }));
83
91
  },
84
- [scaffolderApi]
92
+ [scaffolderApi, decorators, contextSecrets]
85
93
  );
86
94
  const dryRun = useMemo(
87
95
  () => ({
@@ -1 +1 @@
1
- {"version":3,"file":"DryRunContext.esm.js","sources":["../../../../src/alpha/components/TemplateEditorPage/DryRunContext.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport yaml from 'yaml';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { JsonObject } from '@backstage/types';\nimport React, {\n createContext,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n scaffolderApiRef,\n ScaffolderDryRunResponse,\n} from '@backstage/plugin-scaffolder-react';\n\nconst MAX_CONTENT_SIZE = 64 * 1024;\nconst CHUNK_SIZE = 32 * 1024;\n\ninterface DryRunOptions {\n templateContent: string;\n values: JsonObject;\n files: Array<{ path: string; content: string }>;\n}\n\nexport interface DryRunResult extends ScaffolderDryRunResponse {\n id: number;\n}\n\ninterface DryRun {\n results: DryRunResult[];\n selectedResult: DryRunResult | undefined;\n\n selectResult(id: number): void;\n deleteResult(id: number): void;\n execute(options: DryRunOptions): Promise<void>;\n}\n\nconst DryRunContext = createContext<DryRun | undefined>(undefined);\n\ninterface DryRunProviderProps {\n children: ReactNode;\n}\n\nexport function base64EncodeContent(content: string): string {\n if (content.length > MAX_CONTENT_SIZE) {\n return window.btoa('<file too large>');\n }\n\n try {\n return window.btoa(content);\n } catch {\n const decoder = new TextEncoder();\n const buffer = decoder.encode(content);\n\n const chunks = new Array<string>();\n for (let offset = 0; offset < buffer.length; offset += CHUNK_SIZE) {\n chunks.push(\n String.fromCharCode(...buffer.slice(offset, offset + CHUNK_SIZE)),\n );\n }\n return window.btoa(chunks.join(''));\n }\n}\n\nexport function DryRunProvider(props: DryRunProviderProps) {\n const scaffolderApi = useApi(scaffolderApiRef);\n\n const [state, setState] = useState<\n Pick<DryRun, 'results' | 'selectedResult'>\n >({\n results: [],\n selectedResult: undefined,\n });\n const idRef = useRef(1);\n\n const selectResult = useCallback((id: number) => {\n setState(prevState => {\n const result = prevState.results.find(r => r.id === id);\n if (result === prevState.selectedResult) {\n return prevState;\n }\n return {\n results: prevState.results,\n selectedResult: result,\n };\n });\n }, []);\n\n const deleteResult = useCallback((id: number) => {\n setState(prevState => {\n const index = prevState.results.findIndex(r => r.id === id);\n if (index === -1) {\n return prevState;\n }\n const newResults = prevState.results.slice();\n const [deleted] = newResults.splice(index, 1);\n return {\n results: newResults,\n selectedResult:\n prevState.selectedResult?.id === deleted.id\n ? newResults[0]\n : prevState.selectedResult,\n };\n });\n }, []);\n\n const execute = useCallback(\n async (options: DryRunOptions) => {\n if (!scaffolderApi.dryRun) {\n throw new Error('Scaffolder API does not support dry-run');\n }\n\n const parsed = yaml.parse(options.templateContent);\n\n const response = await scaffolderApi.dryRun({\n template: parsed,\n values: options.values,\n secrets: {},\n directoryContents: options.files.map(file => ({\n path: file.path,\n base64Content: base64EncodeContent(file.content),\n })),\n });\n\n const result = {\n ...response,\n id: idRef.current++,\n };\n\n setState(prevState => ({\n results: [...prevState.results, result],\n selectedResult: prevState.selectedResult ?? result,\n }));\n },\n [scaffolderApi],\n );\n\n const dryRun = useMemo(\n () => ({\n ...state,\n selectResult,\n deleteResult,\n execute,\n }),\n [state, selectResult, deleteResult, execute],\n );\n\n return (\n <DryRunContext.Provider value={dryRun}>\n {props.children}\n </DryRunContext.Provider>\n );\n}\n\nexport function useDryRun(): DryRun {\n const value = useContext(DryRunContext);\n if (!value) {\n throw new Error('must be used within a DryRunProvider');\n }\n return value;\n}\n"],"names":[],"mappings":";;;;;AAiCA,MAAM,mBAAmB,EAAK,GAAA,IAAA;AAC9B,MAAM,aAAa,EAAK,GAAA,IAAA;AAqBxB,MAAM,aAAA,GAAgB,cAAkC,KAAS,CAAA,CAAA;AAM1D,SAAS,oBAAoB,OAAyB,EAAA;AAC3D,EAAI,IAAA,OAAA,CAAQ,SAAS,gBAAkB,EAAA;AACrC,IAAO,OAAA,MAAA,CAAO,KAAK,kBAAkB,CAAA;AAAA;AAGvC,EAAI,IAAA;AACF,IAAO,OAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AAAA,GACpB,CAAA,MAAA;AACN,IAAM,MAAA,OAAA,GAAU,IAAI,WAAY,EAAA;AAChC,IAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,MAAA,CAAO,OAAO,CAAA;AAErC,IAAM,MAAA,MAAA,GAAS,IAAI,KAAc,EAAA;AACjC,IAAA,KAAA,IAAS,SAAS,CAAG,EAAA,MAAA,GAAS,MAAO,CAAA,MAAA,EAAQ,UAAU,UAAY,EAAA;AACjE,MAAO,MAAA,CAAA,IAAA;AAAA,QACL,MAAA,CAAO,aAAa,GAAG,MAAA,CAAO,MAAM,MAAQ,EAAA,MAAA,GAAS,UAAU,CAAC;AAAA,OAClE;AAAA;AAEF,IAAA,OAAO,MAAO,CAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA;AAEtC;AAEO,SAAS,eAAe,KAA4B,EAAA;AACzD,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA;AAE7C,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAExB,CAAA;AAAA,IACA,SAAS,EAAC;AAAA,IACV,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,aAAa,CAAA;AACtC,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA;AAAA;AAExD,EAAO,OAAA,KAAA;AACT;;;;"}
1
+ {"version":3,"file":"DryRunContext.esm.js","sources":["../../../../src/alpha/components/TemplateEditorPage/DryRunContext.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport yaml from 'yaml';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { JsonObject, JsonValue } from '@backstage/types';\nimport React, {\n createContext,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n scaffolderApiRef,\n ScaffolderDryRunResponse,\n useTemplateSecrets,\n} from '@backstage/plugin-scaffolder-react';\nimport { useFormDecorators } from '../../hooks/useFormDecorators';\n\nconst MAX_CONTENT_SIZE = 64 * 1024;\nconst CHUNK_SIZE = 32 * 1024;\n\ninterface DryRunOptions {\n templateContent: string;\n values: JsonObject;\n files: Array<{ path: string; content: string }>;\n}\n\nexport interface DryRunResult extends ScaffolderDryRunResponse {\n id: number;\n}\n\ninterface DryRun {\n results: DryRunResult[];\n selectedResult: DryRunResult | undefined;\n\n selectResult(id: number): void;\n deleteResult(id: number): void;\n execute(options: DryRunOptions): Promise<void>;\n}\n\nconst DryRunContext = createContext<DryRun | undefined>(undefined);\n\ninterface DryRunProviderProps {\n children: ReactNode;\n}\n\nexport function base64EncodeContent(content: string): string {\n if (content.length > MAX_CONTENT_SIZE) {\n return window.btoa('<file too large>');\n }\n\n try {\n return window.btoa(content);\n } catch {\n const decoder = new TextEncoder();\n const buffer = decoder.encode(content);\n\n const chunks = new Array<string>();\n for (let offset = 0; offset < buffer.length; offset += CHUNK_SIZE) {\n chunks.push(\n String.fromCharCode(...buffer.slice(offset, offset + CHUNK_SIZE)),\n );\n }\n return window.btoa(chunks.join(''));\n }\n}\n\nexport function DryRunProvider(props: DryRunProviderProps) {\n const decorators = useFormDecorators();\n const scaffolderApi = useApi(scaffolderApiRef);\n const { secrets: contextSecrets } = useTemplateSecrets();\n const [state, setState] = useState<\n Pick<DryRun, 'results' | 'selectedResult'>\n >({\n results: [],\n selectedResult: undefined,\n });\n const idRef = useRef(1);\n\n const selectResult = useCallback((id: number) => {\n setState(prevState => {\n const result = prevState.results.find(r => r.id === id);\n if (result === prevState.selectedResult) {\n return prevState;\n }\n return {\n results: prevState.results,\n selectedResult: result,\n };\n });\n }, []);\n\n const deleteResult = useCallback((id: number) => {\n setState(prevState => {\n const index = prevState.results.findIndex(r => r.id === id);\n if (index === -1) {\n return prevState;\n }\n const newResults = prevState.results.slice();\n const [deleted] = newResults.splice(index, 1);\n return {\n results: newResults,\n selectedResult:\n prevState.selectedResult?.id === deleted.id\n ? newResults[0]\n : prevState.selectedResult,\n };\n });\n }, []);\n\n const execute = useCallback(\n async (options: DryRunOptions) => {\n if (!scaffolderApi.dryRun) {\n throw new Error('Scaffolder API does not support dry-run');\n }\n\n const parsed = yaml.parse(options.templateContent);\n\n const { formState: values, secrets } = await decorators.run({\n formState: options.values as Record<string, JsonValue>,\n secrets: contextSecrets,\n manifest: parsed?.spec,\n });\n\n const response = await scaffolderApi.dryRun({\n template: parsed,\n values,\n secrets,\n directoryContents: options.files.map(file => ({\n path: file.path,\n base64Content: base64EncodeContent(file.content),\n })),\n });\n\n const result = {\n ...response,\n id: idRef.current++,\n };\n\n setState(prevState => ({\n results: [...prevState.results, result],\n selectedResult: prevState.selectedResult ?? result,\n }));\n },\n [scaffolderApi, decorators, contextSecrets],\n );\n\n const dryRun = useMemo(\n () => ({\n ...state,\n selectResult,\n deleteResult,\n execute,\n }),\n [state, selectResult, deleteResult, execute],\n );\n\n return (\n <DryRunContext.Provider value={dryRun}>\n {props.children}\n </DryRunContext.Provider>\n );\n}\n\nexport function useDryRun(): DryRun {\n const value = useContext(DryRunContext);\n if (!value) {\n throw new Error('must be used within a DryRunProvider');\n }\n return value;\n}\n"],"names":[],"mappings":";;;;;;AAmCA,MAAM,mBAAmB,EAAK,GAAA,IAAA;AAC9B,MAAM,aAAa,EAAK,GAAA,IAAA;AAqBxB,MAAM,aAAA,GAAgB,cAAkC,KAAS,CAAA,CAAA;AAM1D,SAAS,oBAAoB,OAAyB,EAAA;AAC3D,EAAI,IAAA,OAAA,CAAQ,SAAS,gBAAkB,EAAA;AACrC,IAAO,OAAA,MAAA,CAAO,KAAK,kBAAkB,CAAA;AAAA;AAGvC,EAAI,IAAA;AACF,IAAO,OAAA,MAAA,CAAO,KAAK,OAAO,CAAA;AAAA,GACpB,CAAA,MAAA;AACN,IAAM,MAAA,OAAA,GAAU,IAAI,WAAY,EAAA;AAChC,IAAM,MAAA,MAAA,GAAS,OAAQ,CAAA,MAAA,CAAO,OAAO,CAAA;AAErC,IAAM,MAAA,MAAA,GAAS,IAAI,KAAc,EAAA;AACjC,IAAA,KAAA,IAAS,SAAS,CAAG,EAAA,MAAA,GAAS,MAAO,CAAA,MAAA,EAAQ,UAAU,UAAY,EAAA;AACjE,MAAO,MAAA,CAAA,IAAA;AAAA,QACL,MAAA,CAAO,aAAa,GAAG,MAAA,CAAO,MAAM,MAAQ,EAAA,MAAA,GAAS,UAAU,CAAC;AAAA,OAClE;AAAA;AAEF,IAAA,OAAO,MAAO,CAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,EAAE,CAAC,CAAA;AAAA;AAEtC;AAEO,SAAS,eAAe,KAA4B,EAAA;AACzD,EAAA,MAAM,aAAa,iBAAkB,EAAA;AACrC,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAA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A,EAAA,MAAM,MAAS,GAAA,OAAA;AAAA,IACb,OAAO;AAAA,MACL,GAAG,KAAA;AAAA,MACH,YAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,YAAc,EAAA,YAAA,EAAc,OAAO;AAAA,GAC7C;AAEA,EAAA,2CACG,aAAc,CAAA,QAAA,EAAd,EAAuB,KAAO,EAAA,MAAA,EAAA,EAC5B,MAAM,QACT,CAAA;AAEJ;AAEO,SAAS,SAAoB,GAAA;AAClC,EAAM,MAAA,KAAA,GAAQ,WAAW,aAAa,CAAA;AACtC,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAM,MAAA,IAAI,MAAM,sCAAsC,CAAA;AAAA;AAExD,EAAO,OAAA,KAAA;AACT;;;;"}
@@ -31,7 +31,7 @@ const TemplateWizardPage = (props) => {
31
31
  name: templateName
32
32
  });
33
33
  const { manifest } = useTemplateParameterSchema(templateRef);
34
- const decorators = useFormDecorators({ manifest });
34
+ const decorators = useFormDecorators();
35
35
  const { value: editUrl } = useAsync(async () => {
36
36
  const data = await catalogApi.getEntityByRef(templateRef);
37
37
  return data?.metadata.annotations?.[ANNOTATION_EDIT_URL];
@@ -43,7 +43,8 @@ const TemplateWizardPage = (props) => {
43
43
  setIsCreating(true);
44
44
  const { formState: values, secrets } = await decorators.run({
45
45
  formState: initialValues,
46
- secrets: contextSecrets
46
+ secrets: contextSecrets,
47
+ manifest
47
48
  });
48
49
  const { taskId } = await scaffolderApi.scaffold({
49
50
  templateRef,
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateWizardPage.esm.js","sources":["../../../../src/alpha/components/TemplateWizardPage/TemplateWizardPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useState } from 'react';\nimport { Navigate, useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n stringifyEntityRef,\n ANNOTATION_EDIT_URL,\n} from '@backstage/catalog-model';\nimport {\n AnalyticsContext,\n useApi,\n useRouteRef,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\nimport {\n scaffolderApiRef,\n useTemplateSecrets,\n type LayoutOptions,\n FormProps,\n FieldExtensionOptions,\n ReviewStepProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport {\n Workflow,\n useTemplateParameterSchema,\n} from '@backstage/plugin-scaffolder-react/alpha';\nimport { JsonValue } from '@backstage/types';\nimport { Header, Page, Progress } from '@backstage/core-components';\n\nimport {\n rootRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n} from '../../../routes';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nimport { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu';\nimport { useFormDecorators } from '../../hooks';\n\n/**\n * @alpha\n */\nexport type TemplateWizardPageProps = {\n customFieldExtensions: FieldExtensionOptions<any, any>[];\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n };\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n};\n\nexport const TemplateWizardPage = (props: TemplateWizardPageProps) => {\n const rootRef = useRouteRef(rootRouteRef);\n const taskRoute = useRouteRef(scaffolderTaskRouteRef);\n const { secrets: contextSecrets } = useTemplateSecrets();\n const scaffolderApi = useApi(scaffolderApiRef);\n const catalogApi = useApi(catalogApiRef);\n const [isCreating, setIsCreating] = useState(false);\n const navigate = useNavigate();\n const { templateName, namespace } = useRouteRefParams(\n selectedTemplateRouteRef,\n );\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const templateRef = stringifyEntityRef({\n kind: 'Template',\n namespace,\n name: templateName,\n });\n\n const { manifest } = useTemplateParameterSchema(templateRef);\n const decorators = useFormDecorators({ manifest });\n\n const { value: editUrl } = useAsync(async () => {\n const data = await catalogApi.getEntityByRef(templateRef);\n return data?.metadata.annotations?.[ANNOTATION_EDIT_URL];\n }, [templateRef, catalogApi]);\n\n const onCreate = async (initialValues: Record<string, JsonValue>) => {\n if (isCreating) {\n return;\n }\n\n setIsCreating(true);\n\n const { formState: values, secrets } = await decorators.run({\n formState: initialValues,\n secrets: contextSecrets,\n });\n\n const { taskId } = await scaffolderApi.scaffold({\n templateRef,\n values,\n secrets,\n });\n\n navigate(taskRoute({ taskId }));\n };\n\n const onError = () => <Navigate to={rootRef()} />;\n\n return (\n <AnalyticsContext attributes={{ entityRef: templateRef }}>\n <Page themeId=\"website\">\n <Header\n pageTitleOverride={t('templateWizardPage.pageTitle')}\n title={t('templateWizardPage.title')}\n subtitle={t('templateWizardPage.subtitle')}\n {...props.headerOptions}\n >\n <TemplateWizardPageContextMenu editUrl={editUrl} />\n </Header>\n {isCreating && <Progress />}\n <Workflow\n namespace={namespace}\n templateName={templateName}\n onCreate={onCreate}\n components={props.components}\n onError={onError}\n extensions={props.customFieldExtensions}\n formProps={props.formProps}\n layouts={props.layouts}\n />\n </Page>\n </AnalyticsContext>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAyEa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAM,MAAA,OAAA,GAAU,YAAY,YAAY,CAAA;AACxC,EAAM,MAAA,SAAA,GAAY,YAAY,sBAAsB,CAAA;AACpD,EAAA,MAAM,EAAE,OAAA,EAAS,cAAe,EAAA,GAAI,kBAAmB,EAAA;AACvD,EAAM,MAAA,aAAA,GA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,WAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAED,IAAA,QAAA,CAAS,SAAU,CAAA,EAAE,MAAO,EAAC,CAAC,CAAA;AAAA,GAChC;AAEA,EAAA,MAAM,UAAU,sBAAM,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,EAAA,EAAI,SAAW,EAAA,CAAA;AAE/C,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,gBAAiB,EAAA,EAAA,UAAA,EAAY,EAAE,SAAA,EAAW,aACzC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,SACZ,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,iBAAA,EAAmB,EAAE,8BAA8B,CAAA;AAAA,MACnD,KAAA,EAAO,EAAE,0BAA0B,CAAA;AAAA,MACnC,QAAA,EAAU,EAAE,6BAA6B,CAAA;AAAA,MACxC,GAAG,KAAM,CAAA;AAAA,KAAA;AAAA,oBAEV,KAAA,CAAA,aAAA,CAAC,iCAA8B,OAAkB,EAAA;AAAA,GAElD,EAAA,UAAA,oBAAe,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAS,CACzB,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,YAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAY,KAAM,CAAA,UAAA;AAAA,MAClB,OAAA;AAAA,MACA,YAAY,KAAM,CAAA,qBAAA;AAAA,MAClB,WAAW,KAAM,CAAA,SAAA;AAAA,MACjB,SAAS,KAAM,CAAA;AAAA;AAAA,GAEnB,CACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateWizardPage.esm.js","sources":["../../../../src/alpha/components/TemplateWizardPage/TemplateWizardPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useState } from 'react';\nimport { Navigate, useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n stringifyEntityRef,\n ANNOTATION_EDIT_URL,\n} from '@backstage/catalog-model';\nimport {\n AnalyticsContext,\n useApi,\n useRouteRef,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\nimport {\n scaffolderApiRef,\n useTemplateSecrets,\n type LayoutOptions,\n FormProps,\n FieldExtensionOptions,\n ReviewStepProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport {\n Workflow,\n useTemplateParameterSchema,\n} from '@backstage/plugin-scaffolder-react/alpha';\nimport { JsonValue } from '@backstage/types';\nimport { Header, Page, Progress } from '@backstage/core-components';\n\nimport {\n rootRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n} from '../../../routes';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nimport { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu';\nimport { useFormDecorators } from '../../hooks';\n\n/**\n * @alpha\n */\nexport type TemplateWizardPageProps = {\n customFieldExtensions: FieldExtensionOptions<any, any>[];\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n };\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n};\n\nexport const TemplateWizardPage = (props: TemplateWizardPageProps) => {\n const rootRef = useRouteRef(rootRouteRef);\n const taskRoute = useRouteRef(scaffolderTaskRouteRef);\n const { secrets: contextSecrets } = useTemplateSecrets();\n const scaffolderApi = useApi(scaffolderApiRef);\n const catalogApi = useApi(catalogApiRef);\n const [isCreating, setIsCreating] = useState(false);\n const navigate = useNavigate();\n const { templateName, namespace } = useRouteRefParams(\n selectedTemplateRouteRef,\n );\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const templateRef = stringifyEntityRef({\n kind: 'Template',\n namespace,\n name: templateName,\n });\n\n const { manifest } = useTemplateParameterSchema(templateRef);\n const decorators = useFormDecorators();\n\n const { value: editUrl } = useAsync(async () => {\n const data = await catalogApi.getEntityByRef(templateRef);\n return data?.metadata.annotations?.[ANNOTATION_EDIT_URL];\n }, [templateRef, catalogApi]);\n\n const onCreate = async (initialValues: Record<string, JsonValue>) => {\n if (isCreating) {\n return;\n }\n\n setIsCreating(true);\n\n const { formState: values, secrets } = await decorators.run({\n formState: initialValues,\n secrets: contextSecrets,\n manifest,\n });\n\n const { taskId } = await scaffolderApi.scaffold({\n templateRef,\n values,\n secrets,\n });\n\n navigate(taskRoute({ taskId }));\n };\n\n const onError = () => <Navigate to={rootRef()} />;\n\n return (\n <AnalyticsContext attributes={{ entityRef: templateRef }}>\n <Page themeId=\"website\">\n <Header\n pageTitleOverride={t('templateWizardPage.pageTitle')}\n title={t('templateWizardPage.title')}\n subtitle={t('templateWizardPage.subtitle')}\n {...props.headerOptions}\n >\n <TemplateWizardPageContextMenu editUrl={editUrl} />\n </Header>\n {isCreating && <Progress />}\n <Workflow\n namespace={namespace}\n templateName={templateName}\n onCreate={onCreate}\n components={props.components}\n onError={onError}\n extensions={props.customFieldExtensions}\n formProps={props.formProps}\n layouts={props.layouts}\n />\n </Page>\n </AnalyticsContext>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAyEa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAM,MAAA,OAAA,GAAU,YAAY,YAAY,CAAA;AACxC,EAAM,MAAA,SAAA,GAAY,YAA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rapper } from '@backstage/core-compat-api';
2
- import { PageBlueprint, NavItemBlueprint, ApiBlueprint, createApiFactory, discoveryApiRef, fetchApiRef, identityApiRef } from '@backstage/frontend-plugin-api';
2
+ import { PageBlueprint, createExtensionInput, NavItemBlueprint, ApiBlueprint, createApiFactory, discoveryApiRef, fetchApiRef, identityApiRef } from '@backstage/frontend-plugin-api';
3
3
  import React from 'react';
4
4
  import { rootRouteRef } from '../routes.esm.js';
5
5
  import CreateComponentIcon from '@material-ui/icons/AddCircleOutline';
@@ -8,11 +8,25 @@ import { scmIntegrationsApiRef } from '@backstage/integration-react';
8
8
  import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';
9
9
  import { ScaffolderClient } from '../api.esm.js';
10
10
 
11
- const scaffolderPage = PageBlueprint.make({
12
- params: {
13
- routeRef: convertLegacyRouteRef(rootRouteRef),
14
- defaultPath: "/create",
15
- loader: () => import('../components/Router/index.esm.js').then((m) => compatWrapper(/* @__PURE__ */ React.createElement(m.Router, null)))
11
+ const scaffolderPage = PageBlueprint.makeWithOverrides({
12
+ inputs: {
13
+ formFields: createExtensionInput([
14
+ FormFieldBlueprint.dataRefs.formFieldLoader
15
+ ])
16
+ },
17
+ factory(originalFactory, { inputs }) {
18
+ const formFieldLoaders = inputs.formFields.map(
19
+ (i) => i.get(FormFieldBlueprint.dataRefs.formFieldLoader)
20
+ );
21
+ return originalFactory({
22
+ routeRef: convertLegacyRouteRef(rootRouteRef),
23
+ defaultPath: "/create",
24
+ loader: () => import('../components/Router/Router.esm.js').then(
25
+ (m) => compatWrapper(
26
+ /* @__PURE__ */ React.createElement(m.InternalRouter, { formFieldLoaders })
27
+ )
28
+ )
29
+ });
16
30
  }
17
31
  });
18
32
  const scaffolderNavItem = NavItemBlueprint.make({
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.esm.js","sources":["../../src/alpha/extensions.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n NavItemBlueprint,\n PageBlueprint,\n ApiBlueprint,\n createApiFactory,\n discoveryApiRef,\n fetchApiRef,\n identityApiRef,\n} from '@backstage/frontend-plugin-api';\nimport React from 'react';\nimport { rootRouteRef } from '../routes';\nimport CreateComponentIcon from '@material-ui/icons/AddCircleOutline';\nimport { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';\nimport { scmIntegrationsApiRef } from '@backstage/integration-react';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport { ScaffolderClient } from '../api';\n\nexport const scaffolderPage = PageBlueprint.make({\n params: {\n routeRef: convertLegacyRouteRef(rootRouteRef),\n defaultPath: '/create',\n loader: () =>\n import('../components/Router').then(m => compatWrapper(<m.Router />)),\n },\n});\n\nexport const scaffolderNavItem = NavItemBlueprint.make({\n params: {\n routeRef: convertLegacyRouteRef(rootRouteRef),\n title: 'Create...',\n icon: CreateComponentIcon,\n },\n});\n\nexport const repoUrlPickerFormField = FormFieldBlueprint.make({\n name: 'repo-url-picker',\n params: {\n field: () => import('./fields/RepoUrlPicker').then(m => m.RepoUrlPicker),\n },\n});\n\nexport const scaffolderApi = ApiBlueprint.make({\n params: {\n factory: createApiFactory({\n api: scaffolderApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n fetchApi: fetchApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) =>\n new ScaffolderClient({\n discoveryApi,\n scmIntegrationsApi,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AA;AAAA,QACA;AAAA,OACD;AAAA,KACJ;AAAA;AAEL,CAAC;;;;"}
1
+ {"version":3,"file":"extensions.esm.js","sources":["../../src/alpha/extensions.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n NavItemBlueprint,\n PageBlueprint,\n ApiBlueprint,\n createApiFactory,\n discoveryApiRef,\n fetchApiRef,\n identityApiRef,\n createExtensionInput,\n} from '@backstage/frontend-plugin-api';\nimport React from 'react';\nimport { rootRouteRef } from '../routes';\nimport CreateComponentIcon from '@material-ui/icons/AddCircleOutline';\nimport { FormFieldBlueprint } from '@backstage/plugin-scaffolder-react/alpha';\nimport { scmIntegrationsApiRef } from '@backstage/integration-react';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport { ScaffolderClient } from '../api';\n\nexport const scaffolderPage = PageBlueprint.makeWithOverrides({\n inputs: {\n formFields: createExtensionInput([\n FormFieldBlueprint.dataRefs.formFieldLoader,\n ]),\n },\n factory(originalFactory, { inputs }) {\n const formFieldLoaders = inputs.formFields.map(i =>\n i.get(FormFieldBlueprint.dataRefs.formFieldLoader),\n );\n return originalFactory({\n routeRef: convertLegacyRouteRef(rootRouteRef),\n defaultPath: '/create',\n loader: () =>\n import('../components/Router/Router').then(m =>\n compatWrapper(\n <m.InternalRouter formFieldLoaders={formFieldLoaders} />,\n ),\n ),\n });\n },\n});\n\nexport const scaffolderNavItem = NavItemBlueprint.make({\n params: {\n routeRef: convertLegacyRouteRef(rootRouteRef),\n title: 'Create...',\n icon: CreateComponentIcon,\n },\n});\n\nexport const repoUrlPickerFormField = FormFieldBlueprint.make({\n name: 'repo-url-picker',\n params: {\n field: () => import('./fields/RepoUrlPicker').then(m => m.RepoUrlPicker),\n },\n});\n\nexport const scaffolderApi = ApiBlueprint.make({\n params: {\n factory: createApiFactory({\n api: scaffolderApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n fetchApi: fetchApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ discoveryApi, scmIntegrationsApi, fetchApi, identityApi }) =>\n new ScaffolderClient({\n discoveryApi,\n scmIntegrationsApi,\n fetchApi,\n identityApi,\n }),\n }),\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;AAsCa,MAAA,cAAA,GAAiB,cAAc,iBAAkB,CAAA;AAAA,EAC5D,MAAQ,EAAA;AAAA,IACN,YAAY,oBAAqB,CAAA;AAAA,MAC/B,mBAAmB,QAAS,CAAA;AAAA,KAC7B;AAAA,GACH;AAAA,EACA,OAAQ,CAAA,eAAA,EAAiB,EAAE,MAAA,EAAU,EAAA;AACnC,IAAM,MAAA,gBAAA,GAAmB,OAAO,UAAW,CAAA,GAAA;AAAA,MAAI,CAC7C,CAAA,KAAA,CAAA,CAAE,GAAI,CAAA,kBAAA,CAAmB,SAAS,eAAe;AAAA,KACnD;AACA,IAAA,OAAO,eAAgB,CAAA;AAAA,MACrB,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,MAC5C,WAAa,EAAA,SAAA;AAAA,MACb,MAAQ,EAAA,MACN,OAAO,oCAA6B,CAAE,CAAA,IAAA;AAAA,QAAK,CACzC,CAAA,KAAA,aAAA;AAAA,0BACG,KAAA,CAAA,aAAA,CAAA,CAAA,CAAE,cAAF,EAAA,EAAiB,gBAAoC,EAAA;AAAA;AACxD;AACF,KACH,CAAA;AAAA;AAEL,CAAC;AAEY,MAAA,iBAAA,GAAoB,iBAAiB,IAAK,CAAA;AAAA,EACrD,MAAQ,EAAA;AAAA,IACN,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,KAAO,EAAA,WAAA;AAAA,IACP,IAAM,EAAA;AAAA;AAEV,CAAC;AAEY,MAAA,sBAAA,GAAyB,mBAAmB,IAAK,CAAA;AAAA,EAC5D,IAAM,EAAA,iBAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,KAAA,EAAO,MAAM,OAAO,+BAAwB,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,aAAa;AAAA;AAE3E,CAAC;AAEY,MAAA,aAAA,GAAgB,aAAa,IAAK,CAAA;AAAA,EAC7C,MAAQ,EAAA;AAAA,IACN,SAAS,gBAAiB,CAAA;AAAA,MACxB,GAAK,EAAA,gBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,kBAAoB,EAAA,qBAAA;AAAA,QACpB,QAAU,EAAA,WAAA;AAAA,QACV,WAAa,EAAA;AAAA,OACf;AAAA,MACA,OAAA,EAAS,CAAC,EAAE,YAAA,EAAc,oBAAoB,QAAU,EAAA,WAAA,EACtD,KAAA,IAAI,gBAAiB,CAAA;AAAA,QACnB,YAAA;AAAA,QACA,kBAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD;AAAA,KACJ;AAAA;AAEL,CAAC;;;;"}
@@ -1,13 +1,11 @@
1
1
  import { useApi, errorApiRef, useApiHolder } from '@backstage/core-plugin-api';
2
2
  import { formDecoratorsApiRef } from '../api/ref.esm.js';
3
3
  import useAsync from 'react-use/esm/useAsync';
4
- import { useMemo } from 'react';
4
+ import { useMemo, useCallback } from 'react';
5
5
  import { OpaqueFormDecorator } from '../../packages/scaffolder-internal/src/wiring/InternalFormDecorator.esm.js';
6
6
  import '../../packages/scaffolder-internal/src/wiring/InternalFormField.esm.js';
7
7
 
8
- const useFormDecorators = ({
9
- manifest
10
- }) => {
8
+ const useFormDecorators = () => {
11
9
  const formDecoratorsApi = useApi(formDecoratorsApiRef);
12
10
  const errorApi = useApi(errorApiRef);
13
11
  const { value: decorators } = useAsync(
@@ -39,13 +37,14 @@ const useFormDecorators = ({
39
37
  }
40
38
  return decoratorsMap;
41
39
  }, [apiHolder, decorators, errorApi]);
42
- return {
43
- run: async (opts) => {
40
+ const run = useCallback(
41
+ async (opts) => {
44
42
  let formState = { ...opts.formState };
45
43
  let secrets = { ...opts.secrets };
46
- if (manifest?.EXPERIMENTAL_formDecorators) {
44
+ const formDecorators = opts.manifest?.EXPERIMENTAL_formDecorators;
45
+ if (formDecorators) {
47
46
  await Promise.all(
48
- manifest.EXPERIMENTAL_formDecorators.map(async (decorator) => {
47
+ formDecorators.map(async (decorator) => {
49
48
  const formDecorator = boundDecorators?.get(decorator.id);
50
49
  if (!formDecorator) {
51
50
  errorApi.post(
@@ -67,8 +66,15 @@ const useFormDecorators = ({
67
66
  );
68
67
  }
69
68
  return { formState, secrets };
70
- }
71
- };
69
+ },
70
+ [boundDecorators, errorApi]
71
+ );
72
+ return useMemo(
73
+ () => ({
74
+ run
75
+ }),
76
+ [run]
77
+ );
72
78
  };
73
79
 
74
80
  export { useFormDecorators };
@@ -1 +1 @@
1
- {"version":3,"file":"useFormDecorators.esm.js","sources":["../../../src/alpha/hooks/useFormDecorators.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { errorApiRef, useApi, useApiHolder } from '@backstage/core-plugin-api';\nimport { formDecoratorsApiRef } from '../api/ref';\nimport useAsync from 'react-use/esm/useAsync';\nimport { useMemo } from 'react';\nimport { ScaffolderFormDecoratorContext } from '@backstage/plugin-scaffolder-react/alpha';\nimport { OpaqueFormDecorator } from '@internal/scaffolder';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\nimport { JsonValue } from '@backstage/types';\n\n/** @internal */\ntype BoundFieldDecorator = {\n decorator: (ctx: ScaffolderFormDecoratorContext) => Promise<void>;\n};\n\nexport const useFormDecorators = ({\n manifest,\n}: {\n manifest?: TemplateParameterSchema;\n}) => {\n const formDecoratorsApi = useApi(formDecoratorsApiRef);\n const errorApi = useApi(errorApiRef);\n const { value: decorators } = useAsync(\n () => formDecoratorsApi.getFormDecorators(),\n [],\n );\n const apiHolder = useApiHolder();\n\n const boundDecorators = useMemo(() => {\n const decoratorsMap = new Map<string, BoundFieldDecorator>();\n\n for (const decorator of decorators ?? []) {\n try {\n const { decorator: decoratorFn, deps } =\n OpaqueFormDecorator.toInternal(decorator);\n\n const resolvedDeps = Object.entries(deps ?? {}).map(([key, value]) => {\n const api = apiHolder.get(value);\n if (!api) {\n throw new Error(\n `Failed to resolve apiRef ${value.id} for form decorator ${decorator.id} it will be disabled`,\n );\n }\n return [key, api];\n });\n\n decoratorsMap.set(decorator.id, {\n decorator: ctx => decoratorFn(ctx, Object.fromEntries(resolvedDeps)),\n });\n } catch (ex) {\n errorApi.post(ex);\n return undefined;\n }\n }\n return decoratorsMap;\n }, [apiHolder, decorators, errorApi]);\n\n return {\n run: async (opts: {\n formState: Record<string, JsonValue>;\n secrets: Record<string, string>;\n }) => {\n let formState: Record<string, JsonValue> = { ...opts.formState };\n let secrets: Record<string, string> = { ...opts.secrets };\n\n if (manifest?.EXPERIMENTAL_formDecorators) {\n // for each of the form decorators, go and call the decorator with the context\n await Promise.all(\n manifest.EXPERIMENTAL_formDecorators.map(async decorator => {\n const formDecorator = boundDecorators?.get(decorator.id);\n if (!formDecorator) {\n errorApi.post(\n new Error(`Failed to find form decorator ${decorator.id}`),\n );\n return;\n }\n\n await formDecorator.decorator({\n setSecrets: (\n handler: (\n oldState: Record<string, string>,\n ) => Record<string, string>,\n ) => {\n secrets = { ...handler(secrets) };\n },\n setFormState: (\n handler: (\n oldState: Record<string, JsonValue>,\n ) => Record<string, JsonValue>,\n ) => {\n formState = { ...handler(formState) };\n },\n formState,\n input: decorator.input ?? {},\n });\n }),\n );\n }\n\n return { formState, secrets };\n },\n };\n};\n"],"names":[],"mappings":";;;;;;;AA6BO,MAAM,oBAAoB,CAAC;AAAA,EAChC;AACF,CAEM,KAAA;AACJ,EAAM,MAAA,iBAAA,GAAoB,OAAO,oBAAoB,CAAA;AACrD,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAM,MAAA,EAAE,KAAO,EAAA,UAAA,EAAe,GAAA,QAAA;AAAA,IAC5B,MAAM,kBAAkB,iBAAkB,EAAA;AAAA,IAC1C;AAAC,GACH;AACA,EAAA,MAAM,YAAY,YAAa,EAAA;AAE/B,EAAM,MAAA,eAAA,GAAkB,QAAQ,MAAM;AACpC,IAAM,MAAA,aAAA,uBAAoB,GAAiC,EAAA;AAE3D,IAAW,KAAA,MAAA,SAAA,IAAa,UAAc,IAAA,EAAI,EAAA;AACxC,MAAI,IAAA;AACF,QAAA,MAAM,EAAE,SAAW,EAAA,WAAA,EAAa,MAC9B,GAAA,mBAAA,CAAoB,WAAW,SAAS,CAAA;AAE1C,QAAA,MAAM,YAAe,GAAA,MAAA,CAAO,OAAQ,CAAA,IAAA,IAAQ,EAAE,CAAE,CAAA,GAAA,CAAI,CAAC,CAAC,GAAK,EAAA,KAAK,CAAM,KAAA;AACpE,UAAM,MAAA,GAAA,GAAM,SAAU,CAAA,GAAA,CAAI,KAAK,CAAA;AAC/B,UAAA,IAAI,CAAC,GAAK,EAAA;AACR,YAAA,MAAM,IAAI,KAAA;AAAA,cACR,CAA4B,yBAAA,EAAA,KAAA,CAAM,EAAE,CAAA,oBAAA,EAAuB,UAAU,EAAE,CAAA,oBAAA;AAAA,aACzE;AAAA;AAEF,UAA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EAAE,GAAG,OAAQ,CAAA,SAAS,CAAE,EAAA;AAAA,eACtC;AAAA,cACA,SAAA;AAAA,cACA,KAAA,EAAO,SAAU,CAAA,KAAA,IAAS;AAAC,aAC5B,CAAA;AAAA,WACF;AAAA,SACH;AAAA;AAGF,MAAO,OAAA,EAAE,WAAW,OAAQ,EAAA;AAAA;AAC9B,GACF;AACF;;;;"}
1
+ {"version":3,"file":"useFormDecorators.esm.js","sources":["../../../src/alpha/hooks/useFormDecorators.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { errorApiRef, useApi, useApiHolder } from '@backstage/core-plugin-api';\nimport { formDecoratorsApiRef } from '../api/ref';\nimport useAsync from 'react-use/esm/useAsync';\nimport { useCallback, useMemo } from 'react';\nimport { ScaffolderFormDecoratorContext } from '@backstage/plugin-scaffolder-react/alpha';\nimport { OpaqueFormDecorator } from '@internal/scaffolder';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\nimport { JsonValue } from '@backstage/types';\n\n/** @internal */\ntype BoundFieldDecorator = {\n decorator: (ctx: ScaffolderFormDecoratorContext) => Promise<void>;\n};\n\nexport const useFormDecorators = () => {\n const formDecoratorsApi = useApi(formDecoratorsApiRef);\n const errorApi = useApi(errorApiRef);\n const { value: decorators } = useAsync(\n () => formDecoratorsApi.getFormDecorators(),\n [],\n );\n const apiHolder = useApiHolder();\n\n const boundDecorators = useMemo(() => {\n const decoratorsMap = new Map<string, BoundFieldDecorator>();\n\n for (const decorator of decorators ?? []) {\n try {\n const { decorator: decoratorFn, deps } =\n OpaqueFormDecorator.toInternal(decorator);\n\n const resolvedDeps = Object.entries(deps ?? {}).map(([key, value]) => {\n const api = apiHolder.get(value);\n if (!api) {\n throw new Error(\n `Failed to resolve apiRef ${value.id} for form decorator ${decorator.id} it will be disabled`,\n );\n }\n return [key, api];\n });\n\n decoratorsMap.set(decorator.id, {\n decorator: ctx => decoratorFn(ctx, Object.fromEntries(resolvedDeps)),\n });\n } catch (ex) {\n errorApi.post(ex);\n return undefined;\n }\n }\n return decoratorsMap;\n }, [apiHolder, decorators, errorApi]);\n\n const run = useCallback(\n async (opts: {\n formState: Record<string, JsonValue>;\n secrets: Record<string, string>;\n manifest?: TemplateParameterSchema;\n }) => {\n let formState: Record<string, JsonValue> = { ...opts.formState };\n let secrets: Record<string, string> = { ...opts.secrets };\n\n const formDecorators = opts.manifest?.EXPERIMENTAL_formDecorators;\n if (formDecorators) {\n // for each of the form decorators, go and call the decorator with the context\n await Promise.all(\n formDecorators.map(async decorator => {\n const formDecorator = boundDecorators?.get(decorator.id);\n if (!formDecorator) {\n errorApi.post(\n new Error(`Failed to find form decorator ${decorator.id}`),\n );\n return;\n }\n\n await formDecorator.decorator({\n setSecrets: (\n handler: (\n oldState: Record<string, string>,\n ) => Record<string, string>,\n ) => {\n secrets = { ...handler(secrets) };\n },\n setFormState: (\n handler: (\n oldState: Record<string, JsonValue>,\n ) => Record<string, JsonValue>,\n ) => {\n formState = { ...handler(formState) };\n },\n formState,\n input: decorator.input ?? {},\n });\n }),\n );\n }\n\n return { formState, secrets };\n },\n [boundDecorators, errorApi],\n );\n\n return useMemo(\n () => ({\n run,\n }),\n [run],\n );\n};\n"],"names":[],"mappings":";;;;;;;AA6BO,MAAM,oBAAoB,MAAM;AACrC,EAAM,MAAA,iBAAA,GAAoB,OAAO,oBAAoB,CAAA;AACrD,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAM,MAAA,EAAE,KAAO,EAAA,UAAA,EAAe,GAAA,QAAA;AAAA,IAC5B,MA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.FrontendPlugin<{
334
334
  };
335
335
  }>;
336
336
  "page:scaffolder": _backstage_frontend_plugin_api.ExtensionDefinition<{
337
- kind: "page";
338
- name: undefined;
339
337
  config: {
340
338
  path: string | undefined;
341
339
  };
@@ -345,7 +343,14 @@ declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
345
343
  output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<React.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, "core.routing.path", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<_backstage_frontend_plugin_api.RouteRef<_backstage_frontend_plugin_api.AnyRouteRefParams>, "core.routing.ref", {
346
344
  optional: true;
347
345
  }>;
348
- inputs: {};
346
+ inputs: {
347
+ formFields: _backstage_frontend_plugin_api.ExtensionInput<_backstage_frontend_plugin_api.ConfigurableExtensionDataRef<() => Promise<FormField>, "scaffolder.form-field-loader", {}>, {
348
+ singleton: false;
349
+ optional: false;
350
+ }>;
351
+ };
352
+ kind: "page";
353
+ name: undefined;
349
354
  params: {
350
355
  defaultPath: string;
351
356
  loader: () => Promise<JSX.Element>;
@@ -15,8 +15,11 @@ import { CustomFieldsPage } from '../../alpha/components/TemplateEditorPage/Cust
15
15
  import { RequirePermission } from '@backstage/plugin-permission-react';
16
16
  import { taskReadPermission, templateManagementPermission } from '@backstage/plugin-scaffolder-common/alpha';
17
17
  import { useApp } from '@backstage/core-plugin-api';
18
+ import { useAsync, useMountEffect } from '@react-hookz/web';
19
+ import { OpaqueFormField } from '../../packages/scaffolder-internal/src/wiring/InternalFormField.esm.js';
20
+ import '../../packages/scaffolder-internal/src/wiring/InternalFormDecorator.esm.js';
18
21
 
19
- const Router = (props) => {
22
+ const InternalRouter = (props) => {
20
23
  const {
21
24
  components: {
22
25
  TemplateCardComponent,
@@ -29,10 +32,12 @@ const Router = (props) => {
29
32
  } = props;
30
33
  const outlet = useOutlet() || props.children;
31
34
  const customFieldExtensions = useCustomFieldExtensions(outlet);
35
+ const loadedFieldExtensions = useFormFieldLoaders(props.formFieldLoaders);
32
36
  const app = useApp();
33
37
  const { NotFoundErrorPage } = app.getComponents();
34
38
  const fieldExtensions = [
35
39
  ...customFieldExtensions,
40
+ ...loadedFieldExtensions,
36
41
  ...DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS.filter(
37
42
  ({ name }) => !customFieldExtensions.some(
38
43
  (customFieldExtension) => customFieldExtension.name === name
@@ -133,6 +138,19 @@ const Router = (props) => {
133
138
  }
134
139
  ), /* @__PURE__ */ React.createElement(Route, { path: "*", element: /* @__PURE__ */ React.createElement(NotFoundErrorPage, null) }));
135
140
  };
141
+ const Router = (props) => {
142
+ return /* @__PURE__ */ React.createElement(InternalRouter, { ...props });
143
+ };
144
+ function useFormFieldLoaders(formFieldLoaders) {
145
+ const [{ result: loadedFieldExtensions }, { execute }] = useAsync(async () => {
146
+ const loaded = await Promise.all(
147
+ (formFieldLoaders ?? []).map((loader) => loader())
148
+ );
149
+ return loaded.map((f) => OpaqueFormField.toInternal(f));
150
+ }, []);
151
+ useMountEffect(execute);
152
+ return loadedFieldExtensions;
153
+ }
136
154
 
137
- export { Router };
155
+ export { InternalRouter, Router };
138
156
  //# sourceMappingURL=Router.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Router.esm.js","sources":["../../../src/components/Router/Router.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { PropsWithChildren } from 'react';\nimport { Routes, Route, useOutlet } from 'react-router-dom';\n\nimport {\n FieldExtensionOptions,\n FormProps,\n ReviewStepProps,\n TemplateGroupFilter,\n} from '@backstage/plugin-scaffolder-react';\nimport {\n ScaffolderTaskOutput,\n SecretsContextProvider,\n useCustomFieldExtensions,\n useCustomLayouts,\n} from '@backstage/plugin-scaffolder-react';\n\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../../extensions/default';\n\nimport {\n actionsRouteRef,\n editorRouteRef,\n customFieldsRouteRef,\n editRouteRef,\n scaffolderListTaskRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n templateFormRouteRef,\n} from '../../routes';\n\nimport { ActionsPage } from '../../components/ActionsPage';\nimport { ListTasksPage } from '../../components/ListTasksPage';\n\nimport {\n TemplateListPageProps,\n TemplateWizardPageProps,\n} from '@backstage/plugin-scaffolder/alpha';\nimport { TemplateListPage, TemplateWizardPage } from '../../alpha/components';\nimport { OngoingTask } from '../OngoingTask';\nimport {\n TemplateFormPage,\n TemplateIntroPage,\n TemplateEditorPage,\n CustomFieldsPage,\n} from '../../alpha/components/TemplateEditorPage';\nimport { RequirePermission } from '@backstage/plugin-permission-react';\nimport {\n taskReadPermission,\n templateManagementPermission,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { useApp } from '@backstage/core-plugin-api';\n\n/**\n * The Props for the Scaffolder Router\n *\n * @public\n */\nexport type RouterProps = {\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n TaskPageComponent?: React.ComponentType<PropsWithChildren<{}>>;\n EXPERIMENTAL_TemplateOutputsComponent?: React.ComponentType<{\n output?: ScaffolderTaskOutput;\n }>;\n EXPERIMENTAL_TemplateListPageComponent?: React.ComponentType<TemplateListPageProps>;\n EXPERIMENTAL_TemplateWizardPageComponent?: React.ComponentType<TemplateWizardPageProps>;\n };\n groups?: TemplateGroupFilter[];\n templateFilter?: (entity: TemplateEntityV1beta3) => boolean;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n defaultPreviewTemplate?: string;\n formProps?: FormProps;\n contextMenu?: {\n /** Whether to show a link to the template editor */\n editor?: boolean;\n /** Whether to show a link to the actions documentation */\n actions?: boolean;\n /** Whether to show a link to the tasks page */\n tasks?: boolean;\n /** Whether to show a link to the create page (on /create subroutes) */\n create?: boolean;\n };\n};\n\n/**\n * The Scaffolder Router\n *\n * @public\n */\nexport const Router = (props: PropsWithChildren<RouterProps>) => {\n const {\n components: {\n TemplateCardComponent,\n TaskPageComponent = OngoingTask,\n ReviewStepComponent,\n EXPERIMENTAL_TemplateOutputsComponent: TemplateOutputsComponent,\n EXPERIMENTAL_TemplateListPageComponent:\n TemplateListPageComponent = TemplateListPage,\n EXPERIMENTAL_TemplateWizardPageComponent:\n TemplateWizardPageComponent = TemplateWizardPage,\n } = {},\n } = props;\n const outlet = useOutlet() || props.children;\n const customFieldExtensions =\n useCustomFieldExtensions<FieldExtensionOptions>(outlet);\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n\n const fieldExtensions = [\n ...customFieldExtensions,\n ...DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS.filter(\n ({ name }) =>\n !customFieldExtensions.some(\n customFieldExtension => customFieldExtension.name === name,\n ),\n ),\n ] as FieldExtensionOptions[];\n\n const customLayouts = useCustomLayouts(outlet);\n\n return (\n <Routes>\n <Route\n path=\"/\"\n element={\n <TemplateListPageComponent\n TemplateCardComponent={TemplateCardComponent}\n contextMenu={props.contextMenu}\n groups={props.groups}\n templateFilter={props.templateFilter}\n headerOptions={props.headerOptions}\n />\n }\n />\n <Route\n path={selectedTemplateRouteRef.path}\n element={\n <SecretsContextProvider>\n <TemplateWizardPageComponent\n headerOptions={props.headerOptions}\n customFieldExtensions={fieldExtensions}\n layouts={customLayouts}\n components={{ ReviewStepComponent }}\n formProps={props.formProps}\n />\n </SecretsContextProvider>\n }\n />\n <Route\n path={scaffolderTaskRouteRef.path}\n element={\n <RequirePermission permission={taskReadPermission}>\n <TaskPageComponent\n TemplateOutputsComponent={TemplateOutputsComponent}\n />\n </RequirePermission>\n }\n />\n <Route\n path={editRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <TemplateIntroPage />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n <Route\n path={customFieldsRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <CustomFieldsPage fieldExtensions={fieldExtensions} />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n <Route\n path={templateFormRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <TemplateFormPage\n layouts={customLayouts}\n formProps={props.formProps}\n fieldExtensions={fieldExtensions}\n />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n\n <Route\n path={actionsRouteRef.path}\n element={<ActionsPage contextMenu={props.contextMenu} />}\n />\n <Route\n path={scaffolderListTaskRouteRef.path}\n element={\n <RequirePermission permission={taskReadPermission}>\n <ListTasksPage contextMenu={props.contextMenu} />\n </RequirePermission>\n }\n />\n <Route\n path={editorRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <TemplateEditorPage\n layouts={customLayouts}\n formProps={props.formProps}\n fieldExtensions={fieldExtensions}\n />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n <Route path=\"*\" element={<NotFoundErrorPage />} />\n </Routes>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA+Ga,MAAA,MAAA,GAAS,CAAC,KAA0C,KAAA;AAC/D,EAAM,MAAA;AAAA,IACJ,UAAY,EAAA;AAAA,MACV,qBAAA;AAAA,MACA,iBAAoB,GAAA,WAAA;AAAA,MACpB,mBAAA;AAAA,MACA,qCAAuC,EAAA,wBAAA;AAAA,MACvC,wCACE,yBAA4B,GAAA,gBAAA;AAAA,MAC9B,0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/Router.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { PropsWithChildren } from 'react';\nimport { Routes, Route, useOutlet } from 'react-router-dom';\n\nimport {\n FieldExtensionOptions,\n FormProps,\n ReviewStepProps,\n TemplateGroupFilter,\n} from '@backstage/plugin-scaffolder-react';\nimport {\n ScaffolderTaskOutput,\n SecretsContextProvider,\n useCustomFieldExtensions,\n useCustomLayouts,\n} from '@backstage/plugin-scaffolder-react';\n\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../../extensions/default';\n\nimport {\n actionsRouteRef,\n editorRouteRef,\n customFieldsRouteRef,\n editRouteRef,\n scaffolderListTaskRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n templateFormRouteRef,\n} from '../../routes';\n\nimport { ActionsPage } from '../../components/ActionsPage';\nimport { ListTasksPage } from '../../components/ListTasksPage';\n\nimport {\n TemplateListPageProps,\n TemplateWizardPageProps,\n} from '@backstage/plugin-scaffolder/alpha';\nimport { TemplateListPage, TemplateWizardPage } from '../../alpha/components';\nimport { OngoingTask } from '../OngoingTask';\nimport {\n TemplateFormPage,\n TemplateIntroPage,\n TemplateEditorPage,\n CustomFieldsPage,\n} from '../../alpha/components/TemplateEditorPage';\nimport { RequirePermission } from '@backstage/plugin-permission-react';\nimport {\n taskReadPermission,\n templateManagementPermission,\n} from '@backstage/plugin-scaffolder-common/alpha';\nimport { useApp } from '@backstage/core-plugin-api';\nimport { FormField, OpaqueFormField } from '@internal/scaffolder';\nimport { useAsync, useMountEffect } from '@react-hookz/web';\n\n/**\n * The Props for the Scaffolder Router\n *\n * @public\n */\nexport type RouterProps = {\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n TaskPageComponent?: React.ComponentType<PropsWithChildren<{}>>;\n EXPERIMENTAL_TemplateOutputsComponent?: React.ComponentType<{\n output?: ScaffolderTaskOutput;\n }>;\n EXPERIMENTAL_TemplateListPageComponent?: React.ComponentType<TemplateListPageProps>;\n EXPERIMENTAL_TemplateWizardPageComponent?: React.ComponentType<TemplateWizardPageProps>;\n };\n groups?: TemplateGroupFilter[];\n templateFilter?: (entity: TemplateEntityV1beta3) => boolean;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n defaultPreviewTemplate?: string;\n formProps?: FormProps;\n contextMenu?: {\n /** Whether to show a link to the template editor */\n editor?: boolean;\n /** Whether to show a link to the actions documentation */\n actions?: boolean;\n /** Whether to show a link to the tasks page */\n tasks?: boolean;\n /** Whether to show a link to the create page (on /create subroutes) */\n create?: boolean;\n };\n};\n\n/**\n * Internal router with additional props that aren't available in the public API\n * for the old frontend system.\n *\n * @internal\n */\nexport const InternalRouter = (\n props: PropsWithChildren<\n RouterProps & { formFieldLoaders?: Array<() => Promise<FormField>> }\n >,\n) => {\n const {\n components: {\n TemplateCardComponent,\n TaskPageComponent = OngoingTask,\n ReviewStepComponent,\n EXPERIMENTAL_TemplateOutputsComponent: TemplateOutputsComponent,\n EXPERIMENTAL_TemplateListPageComponent:\n TemplateListPageComponent = TemplateListPage,\n EXPERIMENTAL_TemplateWizardPageComponent:\n TemplateWizardPageComponent = TemplateWizardPage,\n } = {},\n } = props;\n const outlet = useOutlet() || props.children;\n const customFieldExtensions = useCustomFieldExtensions(outlet);\n const loadedFieldExtensions = useFormFieldLoaders(props.formFieldLoaders);\n\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n\n const fieldExtensions = [\n ...customFieldExtensions,\n ...loadedFieldExtensions,\n ...DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS.filter(\n ({ name }) =>\n !customFieldExtensions.some(\n customFieldExtension => customFieldExtension.name === name,\n ),\n ),\n ] as FieldExtensionOptions[];\n\n const customLayouts = useCustomLayouts(outlet);\n\n return (\n <Routes>\n <Route\n path=\"/\"\n element={\n <TemplateListPageComponent\n TemplateCardComponent={TemplateCardComponent}\n contextMenu={props.contextMenu}\n groups={props.groups}\n templateFilter={props.templateFilter}\n headerOptions={props.headerOptions}\n />\n }\n />\n <Route\n path={selectedTemplateRouteRef.path}\n element={\n <SecretsContextProvider>\n <TemplateWizardPageComponent\n headerOptions={props.headerOptions}\n customFieldExtensions={fieldExtensions}\n layouts={customLayouts}\n components={{ ReviewStepComponent }}\n formProps={props.formProps}\n />\n </SecretsContextProvider>\n }\n />\n <Route\n path={scaffolderTaskRouteRef.path}\n element={\n <RequirePermission permission={taskReadPermission}>\n <TaskPageComponent\n TemplateOutputsComponent={TemplateOutputsComponent}\n />\n </RequirePermission>\n }\n />\n <Route\n path={editRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <TemplateIntroPage />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n <Route\n path={customFieldsRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <CustomFieldsPage fieldExtensions={fieldExtensions} />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n <Route\n path={templateFormRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <TemplateFormPage\n layouts={customLayouts}\n formProps={props.formProps}\n fieldExtensions={fieldExtensions}\n />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n\n <Route\n path={actionsRouteRef.path}\n element={<ActionsPage contextMenu={props.contextMenu} />}\n />\n <Route\n path={scaffolderListTaskRouteRef.path}\n element={\n <RequirePermission permission={taskReadPermission}>\n <ListTasksPage contextMenu={props.contextMenu} />\n </RequirePermission>\n }\n />\n <Route\n path={editorRouteRef.path}\n element={\n <RequirePermission permission={templateManagementPermission}>\n <SecretsContextProvider>\n <TemplateEditorPage\n layouts={customLayouts}\n formProps={props.formProps}\n fieldExtensions={fieldExtensions}\n />\n </SecretsContextProvider>\n </RequirePermission>\n }\n />\n <Route path=\"*\" element={<NotFoundErrorPage />} />\n </Routes>\n );\n};\n\n/**\n * The Scaffolder Router\n *\n * @public\n */\nexport const Router = (props: PropsWithChildren<RouterProps>) => {\n return <InternalRouter {...props} />;\n};\n\nfunction useFormFieldLoaders(\n formFieldLoaders?: Array<() => Promise<FormField>>,\n) {\n const [{ result: loadedFieldExtensions }, { execute }] =\n useAsync(async () => {\n const loaded = await Promise.all(\n (formFieldLoaders ?? []).map(loader => loader()),\n );\n return loaded.map(f => OpaqueFormField.toInternal(f));\n }, []);\n useMountEffect(execute);\n return loadedFieldExtensions;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkHa,MAAA,cAAA,GAAiB,CAC5B,KAGG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,UAAY,EAAA;AAAA,MACV,qBAAA;AAAA,MACA,iBAAoB,GAAA,WAAA;AAAA,MACpB,mBAAA;AAAA,MACA,qCAAuC,EAAA,wBAAA;AAAA,MACvC,wCACE,yBAA4B,GAAA,gBAAA;AAAA,MAC9B,0CACE,2BAA8B,GAAA;AAAA,QAC9B;AAAC,GACH,GAAA,KAAA;AACJ,EAAM,MAAA,MAAA,GAAS,SAAU,EAAA,IAAK,KAAM,CAAA,QAAA;AACpC,EAAM,MAAA,qBAAA,GAAwB,yBAAyB,MAAM,CAAA;AAC7D,EAAM,MAAA,qBAAA,GAAwB,mBAAoB,CAAA,KAAA,CAAM,gBAAgB,CAAA;AAExE,EAAA,MAAM,MAAM,MAAO,EAAA;AACnB,EAAA,MAAM,EAAE,iBAAA,EAAsB,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YAAY;AACnB,IAAM,MAAA,MAAA,GAAS,MAAM,OAAQ,CAAA,GAAA;AAAA,MAAA,CAC1B,oBAAoB,EAAC,EAAG,GAAI,CAAA,CAAA,MAAA,KAAU,QAAQ;AAAA,KACjD;AACA,IAAA,OAAO,OAAO,GAAI,CAAA,CAAA,CAAA,KAAK,eAAgB,CAAA,UAAA,CAAW,CAAC,CAAC,CAAA;AAAA,GACtD,EAAG,EAAE,CAAA;AACP,EAAA,cAAA,CAAe,OAAO,CAAA;AACtB,EAAO,OAAA,qBAAA;AACT;;;;"}
@@ -29,6 +29,7 @@ const EntityPicker = (props) => {
29
29
  const catalogFilter = buildCatalogFilter(uiSchema);
30
30
  const defaultKind = uiSchema["ui:options"]?.defaultKind;
31
31
  const defaultNamespace = uiSchema["ui:options"]?.defaultNamespace || void 0;
32
+ const isDisabled = uiSchema?.["ui:disabled"] ?? false;
32
33
  const catalogApi = useApi(catalogApiRef);
33
34
  const entityPresentationApi = useApi(entityPresentationApiRef);
34
35
  const { value: entities, loading } = useAsync(async () => {
@@ -106,7 +107,7 @@ const EntityPicker = (props) => {
106
107
  /* @__PURE__ */ React.createElement(
107
108
  Autocomplete,
108
109
  {
109
- disabled: required && !allowArbitraryValues && entities?.catalogEntities.length === 1,
110
+ disabled: isDisabled || required && !allowArbitraryValues && entities?.catalogEntities.length === 1,
110
111
  id: idSchema?.$id,
111
112
  value: selectedEntity,
112
113
  loading,
@@ -128,6 +129,7 @@ const EntityPicker = (props) => {
128
129
  FormHelperTextProps: { margin: "dense", style: { marginLeft: 0 } },
129
130
  variant: "outlined",
130
131
  required,
132
+ disabled: isDisabled,
131
133
  InputProps: params.InputProps
132
134
  }
133
135
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"EntityPicker.esm.js","sources":["../../../../src/components/fields/EntityPicker/EntityPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n type EntityFilterQuery,\n CATALOG_FILTER_EXISTS,\n} from '@backstage/catalog-client';\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefPresentationSnapshot,\n catalogApiRef,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport Autocomplete, {\n AutocompleteChangeReason,\n createFilterOptions,\n} from '@material-ui/lab/Autocomplete';\nimport React, { useCallback, useEffect } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n EntityPickerFilterQueryValue,\n EntityPickerProps,\n EntityPickerUiOptions,\n EntityPickerFilterQuery,\n} from './schema';\nimport { VirtualizedListbox } from '../VirtualizedListbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport { EntityPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityPicker = (props: EntityPickerProps) => {\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const {\n onChange,\n schema: {\n title = t('fields.entityPicker.title'),\n description = t('fields.entityPicker.description'),\n },\n required,\n uiSchema,\n rawErrors,\n formData,\n idSchema,\n } = props;\n const catalogFilter = buildCatalogFilter(uiSchema);\n const defaultKind = uiSchema['ui:options']?.defaultKind;\n const defaultNamespace =\n uiSchema['ui:options']?.defaultNamespace || undefined;\n\n const catalogApi = useApi(catalogApiRef);\n const entityPresentationApi = useApi(entityPresentationApiRef);\n\n const { value: entities, loading } = useAsync(async () => {\n const fields = [\n 'metadata.name',\n 'metadata.namespace',\n 'metadata.title',\n 'kind',\n ];\n const { items } = await catalogApi.getEntities(\n catalogFilter\n ? { filter: catalogFilter, fields }\n : { filter: undefined, fields },\n );\n\n const entityRefToPresentation = new Map<\n string,\n EntityRefPresentationSnapshot\n >(\n await Promise.all(\n items.map(async item => {\n const presentation = await entityPresentationApi.forEntity(item)\n .promise;\n return [stringifyEntityRef(item), presentation] as [\n string,\n EntityRefPresentationSnapshot,\n ];\n }),\n ),\n );\n\n return { catalogEntities: items, entityRefToPresentation };\n });\n\n const allowArbitraryValues =\n uiSchema['ui:options']?.allowArbitraryValues ?? true;\n\n const getLabel = useCallback(\n (freeSoloValue: string) => {\n try {\n // Will throw if defaultKind or defaultNamespace are not set\n const parsedRef = parseEntityRef(freeSoloValue, {\n defaultKind,\n defaultNamespace,\n });\n\n return stringifyEntityRef(parsedRef);\n } catch (err) {\n return freeSoloValue;\n }\n },\n [defaultKind, defaultNamespace],\n );\n\n const onSelect = useCallback(\n (_: any, ref: string | Entity | null, reason: AutocompleteChangeReason) => {\n // ref can either be a string from free solo entry or\n if (typeof ref !== 'string') {\n // if ref does not exist: pass 'undefined' to trigger validation for required value\n onChange(ref ? stringifyEntityRef(ref as Entity) : undefined);\n } else {\n if (reason === 'blur' || reason === 'create-option') {\n // Add in default namespace, etc.\n let entityRef = ref;\n try {\n // Attempt to parse the entity ref into it's full form.\n entityRef = stringifyEntityRef(\n parseEntityRef(ref as string, {\n defaultKind,\n defaultNamespace,\n }),\n );\n } catch (err) {\n // If the passed in value isn't an entity ref, do nothing.\n }\n // We need to check against formData here as that's the previous value for this field.\n if (formData !== ref || allowArbitraryValues) {\n onChange(entityRef);\n }\n }\n }\n },\n [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues],\n );\n\n // Since free solo can be enabled, attempt to parse as a full entity ref first, then fall\n // back to the given value.\n const selectedEntity =\n entities?.catalogEntities.find(e => stringifyEntityRef(e) === formData) ??\n (allowArbitraryValues && formData ? getLabel(formData) : '');\n\n useEffect(() => {\n if (\n required &&\n !allowArbitraryValues &&\n entities?.catalogEntities.length === 1 &&\n selectedEntity === ''\n ) {\n onChange(stringifyEntityRef(entities.catalogEntities[0]));\n }\n }, [entities, onChange, selectedEntity, required, allowArbitraryValues]);\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !formData}\n >\n <Autocomplete\n disabled={\n required &&\n !allowArbitraryValues &&\n entities?.catalogEntities.length === 1\n }\n id={idSchema?.$id}\n value={selectedEntity}\n loading={loading}\n onChange={onSelect}\n options={entities?.catalogEntities || []}\n getOptionLabel={option =>\n // option can be a string due to freeSolo.\n typeof option === 'string'\n ? option\n : entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.entityRef!\n }\n autoSelect\n freeSolo={allowArbitraryValues}\n renderInput={params => (\n <TextField\n {...params}\n label={title}\n margin=\"dense\"\n helperText={description}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }}\n variant=\"outlined\"\n required={required}\n InputProps={params.InputProps}\n />\n )}\n renderOption={option => <EntityDisplayName entityRef={option} />}\n filterOptions={createFilterOptions<Entity>({\n stringify: option =>\n entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.primaryTitle!,\n })}\n ListboxComponent={VirtualizedListbox}\n />\n </FormControl>\n );\n};\n\n/**\n * Converts a especial `{exists: true}` value to the `CATALOG_FILTER_EXISTS` symbol.\n *\n * @param value - The value to convert.\n * @returns The converted value.\n */\nfunction convertOpsValues(\n value: Exclude<EntityPickerFilterQueryValue, Array<any>>,\n): string | symbol {\n if (typeof value === 'object' && value.exists) {\n return CATALOG_FILTER_EXISTS;\n }\n return value?.toString();\n}\n\n/**\n * Converts schema filters to entity filter query, replacing `{exists:true}` values\n * with the constant `CATALOG_FILTER_EXISTS`.\n *\n * @param schemaFilters - An object containing schema filters with keys as filter names\n * and values as filter values.\n * @returns An object with the same keys as the input object, but with `{exists:true}` values\n * transformed to `CATALOG_FILTER_EXISTS` symbol.\n */\nfunction convertSchemaFiltersToQuery(\n schemaFilters: EntityPickerFilterQuery,\n): Exclude<EntityFilterQuery, Array<any>> {\n const query: EntityFilterQuery = {};\n\n for (const [key, value] of Object.entries(schemaFilters)) {\n if (Array.isArray(value)) {\n query[key] = value;\n } else {\n query[key] = convertOpsValues(value);\n }\n }\n\n return query;\n}\n\n/**\n * Builds an `EntityFilterQuery` based on the `uiSchema` passed in.\n * If `catalogFilter` is specified in the `uiSchema`, it is converted to a `EntityFilterQuery`.\n * If `allowedKinds` is specified in the `uiSchema` will support the legacy `allowedKinds` option.\n *\n * @param uiSchema The `uiSchema` of an `EntityPicker` component.\n * @returns An `EntityFilterQuery` based on the `uiSchema`, or `undefined` if `catalogFilter` is not specified in the `uiSchema`.\n */\nfunction buildCatalogFilter(\n uiSchema: EntityPickerProps['uiSchema'],\n): EntityFilterQuery | undefined {\n const allowedKinds = uiSchema['ui:options']?.allowedKinds;\n\n const catalogFilter: EntityPickerUiOptions['catalogFilter'] | undefined =\n uiSchema['ui:options']?.catalogFilter ||\n (allowedKinds && { kind: allowedKinds });\n\n if (!catalogFilter) {\n return undefined;\n }\n\n if (Array.isArray(catalogFilter)) {\n return catalogFilter.map(convertSchemaFiltersToQuery);\n }\n\n return convertSchemaFiltersToQuery(catalogFilter);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAyDa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAA,GAAQ,EAAE,2BAA2B,CAAA;AAAA,MACrC,WAAA,GAAc,EAAE,iCAAiC;AAAA,KACnD;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,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M,YAAa,EAAA;AAExC,EAAA,IAAI,CAAC,aAAe,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,aAAa,CAAG,EAAA;AAChC,IAAO,OAAA,aAAA,CAAc,IAAI,2BAA2B,CAAA;AAAA;AAGtD,EAAA,OAAO,4BAA4B,aAAa,CAAA;AAClD;;;;"}
1
+ {"version":3,"file":"EntityPicker.esm.js","sources":["../../../../src/components/fields/EntityPicker/EntityPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n type EntityFilterQuery,\n CATALOG_FILTER_EXISTS,\n} from '@backstage/catalog-client';\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefPresentationSnapshot,\n catalogApiRef,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport Autocomplete, {\n AutocompleteChangeReason,\n createFilterOptions,\n} from '@material-ui/lab/Autocomplete';\nimport React, { useCallback, useEffect } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n EntityPickerFilterQueryValue,\n EntityPickerProps,\n EntityPickerUiOptions,\n EntityPickerFilterQuery,\n} from './schema';\nimport { VirtualizedListbox } from '../VirtualizedListbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport { EntityPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityPicker = (props: EntityPickerProps) => {\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const {\n onChange,\n schema: {\n title = t('fields.entityPicker.title'),\n description = t('fields.entityPicker.description'),\n },\n required,\n uiSchema,\n rawErrors,\n formData,\n idSchema,\n } = props;\n const catalogFilter = buildCatalogFilter(uiSchema);\n const defaultKind = uiSchema['ui:options']?.defaultKind;\n const defaultNamespace =\n uiSchema['ui:options']?.defaultNamespace || undefined;\n const isDisabled = uiSchema?.['ui:disabled'] ?? false;\n\n const catalogApi = useApi(catalogApiRef);\n const entityPresentationApi = useApi(entityPresentationApiRef);\n\n const { value: entities, loading } = useAsync(async () => {\n const fields = [\n 'metadata.name',\n 'metadata.namespace',\n 'metadata.title',\n 'kind',\n ];\n const { items } = await catalogApi.getEntities(\n catalogFilter\n ? { filter: catalogFilter, fields }\n : { filter: undefined, fields },\n );\n\n const entityRefToPresentation = new Map<\n string,\n EntityRefPresentationSnapshot\n >(\n await Promise.all(\n items.map(async item => {\n const presentation = await entityPresentationApi.forEntity(item)\n .promise;\n return [stringifyEntityRef(item), presentation] as [\n string,\n EntityRefPresentationSnapshot,\n ];\n }),\n ),\n );\n\n return { catalogEntities: items, entityRefToPresentation };\n });\n\n const allowArbitraryValues =\n uiSchema['ui:options']?.allowArbitraryValues ?? true;\n\n const getLabel = useCallback(\n (freeSoloValue: string) => {\n try {\n // Will throw if defaultKind or defaultNamespace are not set\n const parsedRef = parseEntityRef(freeSoloValue, {\n defaultKind,\n defaultNamespace,\n });\n\n return stringifyEntityRef(parsedRef);\n } catch (err) {\n return freeSoloValue;\n }\n },\n [defaultKind, defaultNamespace],\n );\n\n const onSelect = useCallback(\n (_: any, ref: string | Entity | null, reason: AutocompleteChangeReason) => {\n // ref can either be a string from free solo entry or\n if (typeof ref !== 'string') {\n // if ref does not exist: pass 'undefined' to trigger validation for required value\n onChange(ref ? stringifyEntityRef(ref as Entity) : undefined);\n } else {\n if (reason === 'blur' || reason === 'create-option') {\n // Add in default namespace, etc.\n let entityRef = ref;\n try {\n // Attempt to parse the entity ref into it's full form.\n entityRef = stringifyEntityRef(\n parseEntityRef(ref as string, {\n defaultKind,\n defaultNamespace,\n }),\n );\n } catch (err) {\n // If the passed in value isn't an entity ref, do nothing.\n }\n // We need to check against formData here as that's the previous value for this field.\n if (formData !== ref || allowArbitraryValues) {\n onChange(entityRef);\n }\n }\n }\n },\n [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues],\n );\n\n // Since free solo can be enabled, attempt to parse as a full entity ref first, then fall\n // back to the given value.\n const selectedEntity =\n entities?.catalogEntities.find(e => stringifyEntityRef(e) === formData) ??\n (allowArbitraryValues && formData ? getLabel(formData) : '');\n\n useEffect(() => {\n if (\n required &&\n !allowArbitraryValues &&\n entities?.catalogEntities.length === 1 &&\n selectedEntity === ''\n ) {\n onChange(stringifyEntityRef(entities.catalogEntities[0]));\n }\n }, [entities, onChange, selectedEntity, required, allowArbitraryValues]);\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !formData}\n >\n <Autocomplete\n disabled={\n isDisabled ||\n (required &&\n !allowArbitraryValues &&\n entities?.catalogEntities.length === 1)\n }\n id={idSchema?.$id}\n value={selectedEntity}\n loading={loading}\n onChange={onSelect}\n options={entities?.catalogEntities || []}\n getOptionLabel={option =>\n // option can be a string due to freeSolo.\n typeof option === 'string'\n ? option\n : entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.entityRef!\n }\n autoSelect\n freeSolo={allowArbitraryValues}\n renderInput={params => (\n <TextField\n {...params}\n label={title}\n margin=\"dense\"\n helperText={description}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }}\n variant=\"outlined\"\n required={required}\n disabled={isDisabled}\n InputProps={params.InputProps}\n />\n )}\n renderOption={option => <EntityDisplayName entityRef={option} />}\n filterOptions={createFilterOptions<Entity>({\n stringify: option =>\n entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.primaryTitle!,\n })}\n ListboxComponent={VirtualizedListbox}\n />\n </FormControl>\n );\n};\n\n/**\n * Converts a especial `{exists: true}` value to the `CATALOG_FILTER_EXISTS` symbol.\n *\n * @param value - The value to convert.\n * @returns The converted value.\n */\nfunction convertOpsValues(\n value: Exclude<EntityPickerFilterQueryValue, Array<any>>,\n): string | symbol {\n if (typeof value === 'object' && value.exists) {\n return CATALOG_FILTER_EXISTS;\n }\n return value?.toString();\n}\n\n/**\n * Converts schema filters to entity filter query, replacing `{exists:true}` values\n * with the constant `CATALOG_FILTER_EXISTS`.\n *\n * @param schemaFilters - An object containing schema filters with keys as filter names\n * and values as filter values.\n * @returns An object with the same keys as the input object, but with `{exists:true}` values\n * transformed to `CATALOG_FILTER_EXISTS` symbol.\n */\nfunction convertSchemaFiltersToQuery(\n schemaFilters: EntityPickerFilterQuery,\n): Exclude<EntityFilterQuery, Array<any>> {\n const query: EntityFilterQuery = {};\n\n for (const [key, value] of Object.entries(schemaFilters)) {\n if (Array.isArray(value)) {\n query[key] = value;\n } else {\n query[key] = convertOpsValues(value);\n }\n }\n\n return query;\n}\n\n/**\n * Builds an `EntityFilterQuery` based on the `uiSchema` passed in.\n * If `catalogFilter` is specified in the `uiSchema`, it is converted to a `EntityFilterQuery`.\n * If `allowedKinds` is specified in the `uiSchema` will support the legacy `allowedKinds` option.\n *\n * @param uiSchema The `uiSchema` of an `EntityPicker` component.\n * @returns An `EntityFilterQuery` based on the `uiSchema`, or `undefined` if `catalogFilter` is not specified in the `uiSchema`.\n */\nfunction buildCatalogFilter(\n uiSchema: EntityPickerProps['uiSchema'],\n): EntityFilterQuery | undefined {\n const allowedKinds = uiSchema['ui:options']?.allowedKinds;\n\n const catalogFilter: EntityPickerUiOptions['catalogFilter'] | undefined =\n uiSchema['ui:options']?.catalogFilter ||\n (allowedKinds && { kind: allowedKinds });\n\n if (!catalogFilter) {\n return undefined;\n }\n\n if (Array.isArray(catalogFilter)) {\n return catalogFilter.map(convertSchemaFiltersToQuery);\n }\n\n return convertSchemaFiltersToQuery(catalogFilter);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAyDa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAA,GAAQ,EAAE,2BAA2B,CAAA;AAAA,MACrC,WAAA,GAAc,EAAE,iCAAiC;AAAA,KACnD;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAM,MAAA,aAAA,GAAgB,mBAAmB,QAAQ,CAAA;AACjD,EAAM,MAAA,WAAA,GAAc,QAAS,CAAA,YAAY,CAAG,EAAA,WAAA;AAC5C,EAAA,MAAM,gBACJ,GAAA,QAAA,CAAS,YAAY,CAAA,EAAG,gBAAoB,IAAA,KAAA,CAAA;AAC9C,EAAM,MAAA,UAAA,GAAa,QAAW,GAAA,aAAa,CAAK,IAAA,KAAA;AAEhD,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AACvC,EAAM,MAAA,qBAAA,GAAwB,OAAO,wBAAwB,CAAA;AAE7D,EAAA,MAAM,EAAE,KAAO,EAAA,QAAA,EAAU,OAAQ,EAAA,GAAI,SAAS,YAAY;AACxD,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,eAAA;AAAA,MACA,oBAAA;AAAA,MACA,gBAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAM,UAAW,CAAA,WAAA;AAAA,MACjC,aAAA,GACI,EAAE,MAAQ,EAAA,aAAA,EAAe,QACzB,GAAA,EAAE,MAAQ,EAAA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AO,QAAS,EAAA;AACzB;AAWA,SAAS,4BACP,aACwC,EAAA;AACxC,EAAA,MAAM,QAA2B,EAAC;AAElC,EAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,KAAK,MAAO,CAAA,OAAA,CAAQ,aAAa,CAAG,EAAA;AACxD,IAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AACxB,MAAA,KAAA,CAAM,GAAG,CAAI,GAAA,KAAA;AAAA,KACR,MAAA;AACL,MAAM,KAAA,CAAA,GAAG,CAAI,GAAA,gBAAA,CAAiB,KAAK,CAAA;AAAA;AACrC;AAGF,EAAO,OAAA,KAAA;AACT;AAUA,SAAS,mBACP,QAC+B,EAAA;AAC/B,EAAM,MAAA,YAAA,GAAe,QAAS,CAAA,YAAY,CAAG,EAAA,YAAA;AAE7C,EAAM,MAAA,aAAA,GACJ,SAAS,YAAY,CAAA,EAAG,iBACvB,YAAgB,IAAA,EAAE,MAAM,YAAa,EAAA;AAExC,EAAA,IAAI,CAAC,aAAe,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,aAAa,CAAG,EAAA;AAChC,IAAO,OAAA,aAAA,CAAc,IAAI,2BAA2B,CAAA;AAAA;AAGtD,EAAA,OAAO,4BAA4B,aAAa,CAAA;AAClD;;;;"}
@@ -21,6 +21,7 @@ const EntityTagsPicker = (props) => {
21
21
  const kinds = uiSchema["ui:options"]?.kinds;
22
22
  const showCounts = uiSchema["ui:options"]?.showCounts;
23
23
  const helperText = uiSchema["ui:options"]?.helperText;
24
+ const isDisabled = uiSchema?.["ui:disabled"] ?? false;
24
25
  const { t } = useTranslationRef(scaffolderTranslationRef);
25
26
  const { loading, value: existingTags } = useAsync(async () => {
26
27
  const facet = "metadata.tags";
@@ -62,6 +63,7 @@ const EntityTagsPicker = (props) => {
62
63
  freeSolo: true,
63
64
  filterSelectedOptions: true,
64
65
  onChange: setTags,
66
+ disabled: isDisabled,
65
67
  value: formData || [],
66
68
  inputValue,
67
69
  loading,
@@ -73,6 +75,7 @@ const EntityTagsPicker = (props) => {
73
75
  {
74
76
  ...params,
75
77
  label: t("fields.entityTagsPicker.title"),
78
+ disabled: isDisabled,
76
79
  onChange: (e) => setInputValue(e.target.value),
77
80
  error: inputError,
78
81
  helperText: helperText ?? t("fields.entityTagsPicker.description"),