@backstage/plugin-scaffolder 1.19.3 → 1.19.4-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 (152) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/alpha/package.json +1 -1
  3. package/dist/alpha.esm.js +3 -8
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/{esm/routes-BvToNy4N.esm.js → api.esm.js} +2 -46
  6. package/dist/api.esm.js.map +1 -0
  7. package/dist/components/ActionsPage/ActionsPage.esm.js +186 -0
  8. package/dist/components/ActionsPage/ActionsPage.esm.js.map +1 -0
  9. package/dist/components/FileBrowser/FileBrowser.esm.js +90 -0
  10. package/dist/components/FileBrowser/FileBrowser.esm.js.map +1 -0
  11. package/dist/components/ListTasksPage/ListTasksPage.esm.js +120 -0
  12. package/dist/components/ListTasksPage/ListTasksPage.esm.js.map +1 -0
  13. package/dist/components/ListTasksPage/OwnerListPicker.esm.js +88 -0
  14. package/dist/components/ListTasksPage/OwnerListPicker.esm.js.map +1 -0
  15. package/dist/components/ListTasksPage/columns/CreatedAtColumn.esm.js +13 -0
  16. package/dist/components/ListTasksPage/columns/CreatedAtColumn.esm.js.map +1 -0
  17. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js +31 -0
  18. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js.map +1 -0
  19. package/dist/components/ListTasksPage/columns/TaskStatusColumn.esm.js +17 -0
  20. package/dist/components/ListTasksPage/columns/TaskStatusColumn.esm.js.map +1 -0
  21. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js +21 -0
  22. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js.map +1 -0
  23. package/dist/components/OngoingTask/ContextMenu.esm.js +84 -0
  24. package/dist/components/OngoingTask/ContextMenu.esm.js.map +1 -0
  25. package/dist/components/OngoingTask/OngoingTask.esm.js +169 -0
  26. package/dist/components/OngoingTask/OngoingTask.esm.js.map +1 -0
  27. package/dist/components/Router/Router.esm.js +105 -0
  28. package/dist/components/Router/Router.esm.js.map +1 -0
  29. package/dist/components/Router/index.esm.js +2 -0
  30. package/dist/components/Router/index.esm.js.map +1 -0
  31. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js +70 -0
  32. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js.map +1 -0
  33. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js +34 -0
  34. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js.map +1 -0
  35. package/dist/components/fields/EntityNamePicker/schema.esm.js +8 -0
  36. package/dist/components/fields/EntityNamePicker/schema.esm.js.map +1 -0
  37. package/dist/components/fields/EntityNamePicker/validation.esm.js +12 -0
  38. package/dist/components/fields/EntityNamePicker/validation.esm.js.map +1 -0
  39. package/dist/components/fields/EntityPicker/EntityPicker.esm.js +151 -0
  40. package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -0
  41. package/dist/components/fields/EntityPicker/schema.esm.js +29 -0
  42. package/dist/components/fields/EntityPicker/schema.esm.js.map +1 -0
  43. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +84 -0
  44. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -0
  45. package/dist/components/fields/EntityTagsPicker/schema.esm.js +15 -0
  46. package/dist/components/fields/EntityTagsPicker/schema.esm.js.map +1 -0
  47. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js +168 -0
  48. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js.map +1 -0
  49. package/dist/components/fields/MultiEntityPicker/schema.esm.js +23 -0
  50. package/dist/components/fields/MultiEntityPicker/schema.esm.js.map +1 -0
  51. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js +83 -0
  52. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js.map +1 -0
  53. package/dist/components/fields/MyGroupsPicker/schema.esm.js +14 -0
  54. package/dist/components/fields/MyGroupsPicker/schema.esm.js.map +1 -0
  55. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js +68 -0
  56. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js.map +1 -0
  57. package/dist/components/fields/OwnedEntityPicker/schema.esm.js +24 -0
  58. package/dist/components/fields/OwnedEntityPicker/schema.esm.js.map +1 -0
  59. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js +37 -0
  60. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js.map +1 -0
  61. package/dist/components/fields/OwnerPicker/schema.esm.js +24 -0
  62. package/dist/components/fields/OwnerPicker/schema.esm.js.map +1 -0
  63. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +75 -0
  64. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -0
  65. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +80 -0
  66. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -0
  67. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +38 -0
  68. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -0
  69. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +44 -0
  70. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -0
  71. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +42 -0
  72. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -0
  73. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +44 -0
  74. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -0
  75. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js +200 -0
  76. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js.map +1 -0
  77. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +56 -0
  78. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -0
  79. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +48 -0
  80. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -0
  81. package/dist/components/fields/RepoUrlPicker/schema.esm.js +32 -0
  82. package/dist/components/fields/RepoUrlPicker/schema.esm.js.map +1 -0
  83. package/dist/components/fields/RepoUrlPicker/utils.esm.js +46 -0
  84. package/dist/components/fields/RepoUrlPicker/utils.esm.js.map +1 -0
  85. package/dist/components/fields/RepoUrlPicker/validation.esm.js +43 -0
  86. package/dist/components/fields/RepoUrlPicker/validation.esm.js.map +1 -0
  87. package/dist/components/fields/SecretInput/SecretInput.esm.js +48 -0
  88. package/dist/components/fields/SecretInput/SecretInput.esm.js.map +1 -0
  89. package/dist/components/fields/utils.esm.js +15 -0
  90. package/dist/components/fields/utils.esm.js.map +1 -0
  91. package/dist/deprecated.esm.js +13 -0
  92. package/dist/deprecated.esm.js.map +1 -0
  93. package/dist/extensions/default.esm.js +72 -0
  94. package/dist/extensions/default.esm.js.map +1 -0
  95. package/dist/index.esm.js +13 -214
  96. package/dist/index.esm.js.map +1 -1
  97. package/dist/lib/download/helpers.esm.js +11 -0
  98. package/dist/lib/download/helpers.esm.js.map +1 -0
  99. package/dist/lib/filesystem/WebFileSystemAccess.esm.js +56 -0
  100. package/dist/lib/filesystem/WebFileSystemAccess.esm.js.map +1 -0
  101. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js +151 -0
  102. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -0
  103. package/dist/next/TemplateEditorPage/DirectoryEditorContext.esm.js +186 -0
  104. package/dist/next/TemplateEditorPage/DirectoryEditorContext.esm.js.map +1 -0
  105. package/dist/next/TemplateEditorPage/DryRunContext.esm.js +110 -0
  106. package/dist/next/TemplateEditorPage/DryRunContext.esm.js.map +1 -0
  107. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js +70 -0
  108. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js.map +1 -0
  109. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js +98 -0
  110. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js.map +1 -0
  111. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsSplitView.esm.js +31 -0
  112. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsSplitView.esm.js.map +1 -0
  113. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js +145 -0
  114. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js.map +1 -0
  115. package/dist/next/TemplateEditorPage/DryRunResults/IconLink.esm.js +25 -0
  116. package/dist/next/TemplateEditorPage/DryRunResults/IconLink.esm.js.map +1 -0
  117. package/dist/next/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js +40 -0
  118. package/dist/next/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js.map +1 -0
  119. package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js +135 -0
  120. package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js.map +1 -0
  121. package/dist/next/TemplateEditorPage/TemplateEditor.esm.js +52 -0
  122. package/dist/next/TemplateEditorPage/TemplateEditor.esm.js.map +1 -0
  123. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js +74 -0
  124. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js.map +1 -0
  125. package/dist/next/TemplateEditorPage/TemplateEditorForm.esm.js +174 -0
  126. package/dist/next/TemplateEditorPage/TemplateEditorForm.esm.js.map +1 -0
  127. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js +93 -0
  128. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js.map +1 -0
  129. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js +82 -0
  130. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js.map +1 -0
  131. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js +120 -0
  132. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js.map +1 -0
  133. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js +160 -0
  134. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js.map +1 -0
  135. package/dist/next/TemplateListPage/RegisterExistingButton.esm.js +35 -0
  136. package/dist/next/TemplateListPage/RegisterExistingButton.esm.js.map +1 -0
  137. package/dist/next/TemplateListPage/TemplateListPage.esm.js +101 -0
  138. package/dist/next/TemplateListPage/TemplateListPage.esm.js.map +1 -0
  139. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js +67 -0
  140. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -0
  141. package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js +60 -0
  142. package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js.map +1 -0
  143. package/dist/plugin.esm.js +125 -0
  144. package/dist/plugin.esm.js.map +1 -0
  145. package/dist/routes.esm.js +47 -0
  146. package/dist/routes.esm.js.map +1 -0
  147. package/package.json +18 -18
  148. package/dist/esm/OngoingTask-ClfJCJcE.esm.js +0 -1575
  149. package/dist/esm/OngoingTask-ClfJCJcE.esm.js.map +0 -1
  150. package/dist/esm/index-UcPid-q1.esm.js +0 -2553
  151. package/dist/esm/index-UcPid-q1.esm.js.map +0 -1
  152. package/dist/esm/routes-BvToNy4N.esm.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityTagsPicker.esm.js","sources":["../../../../src/components/fields/EntityTagsPicker/EntityTagsPicker.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 React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport useEffectOnce from 'react-use/esm/useEffectOnce';\nimport { GetEntityFacetsRequest } from '@backstage/catalog-client';\nimport { makeValidator } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport TextField from '@material-ui/core/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { EntityTagsPickerProps } from './schema';\n\nexport { EntityTagsPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityTagsPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityTagsPicker = (props: EntityTagsPickerProps) => {\n const { formData, onChange, uiSchema } = props;\n const catalogApi = useApi(catalogApiRef);\n const [tagOptions, setTagOptions] = useState<string[]>([]);\n const [inputValue, setInputValue] = useState('');\n const [inputError, setInputError] = useState(false);\n const tagValidator = makeValidator().isValidTag;\n const kinds = uiSchema['ui:options']?.kinds;\n const showCounts = uiSchema['ui:options']?.showCounts;\n const helperText = uiSchema['ui:options']?.helperText;\n\n const { loading, value: existingTags } = useAsync(async () => {\n const facet = 'metadata.tags';\n const tagsRequest: GetEntityFacetsRequest = { facets: [facet] };\n if (kinds) {\n tagsRequest.filter = { kind: kinds };\n }\n\n const { facets } = await catalogApi.getEntityFacets(tagsRequest);\n\n const tagFacets = Object.fromEntries(\n facets[facet].map(({ value, count }) => [value, count]),\n );\n\n setTagOptions(\n Object.keys(tagFacets).sort((a, b) =>\n showCounts ? tagFacets[b] - tagFacets[a] : a.localeCompare(b),\n ),\n );\n\n return tagFacets;\n });\n\n const setTags = (_: React.ChangeEvent<{}>, values: string[] | null) => {\n // Reset error state in case all tags were removed\n let hasError = false;\n let addDuplicate = false;\n const currentTags = formData || [];\n\n // If adding a new tag\n if (values?.length && currentTags.length < values.length) {\n const newTag = (values[values.length - 1] = values[values.length - 1]\n .toLocaleLowerCase('en-US')\n .trim());\n hasError = !tagValidator(newTag);\n addDuplicate = currentTags.indexOf(newTag) !== -1;\n }\n\n setInputError(hasError);\n setInputValue(!hasError ? '' : inputValue);\n if (!hasError && !addDuplicate) {\n onChange(values || []);\n }\n };\n\n // Initialize field to always return an array\n useEffectOnce(() => onChange(formData || []));\n\n return (\n <FormControl margin=\"normal\">\n <Autocomplete\n multiple\n freeSolo\n filterSelectedOptions\n onChange={setTags}\n value={formData || []}\n inputValue={inputValue}\n loading={loading}\n options={tagOptions}\n ChipProps={{ size: 'small' }}\n renderOption={option =>\n showCounts ? `${option} (${existingTags?.[option]})` : option\n }\n renderInput={params => (\n <TextField\n {...params}\n label=\"Tags\"\n onChange={e => setInputValue(e.target.value)}\n error={inputError}\n helperText={\n helperText ??\n \"Add any relevant tags, hit 'Enter' to add new tags. Valid format: [a-z0-9+#] separated by [-], at most 63 characters\"\n }\n />\n )}\n />\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAmCa,MAAA,gBAAA,GAAmB,CAAC,KAAiC,KAAA;AAnClE,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAoCE,EAAA,MAAM,EAAE,QAAA,EAAU,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AACzC,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAA,MAAM,CAAC,UAAY,EAAA,aAAa,CAAI,GAAA,QAAA,CAAmB,EAAE,CAAA,CAAA;AACzD,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,EAAE,CAAA,CAAA;AAC/C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAClD,EAAM,MAAA,YAAA,GAAe,e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A,IAAA;AAAA,MACC,QAAQ,EAAA,IAAA;AAAA,MACR,QAAQ,EAAA,IAAA;AAAA,MACR,qBAAqB,EAAA,IAAA;AAAA,MACrB,QAAU,EAAA,OAAA;AAAA,MACV,KAAA,EAAO,YAAY,EAAC;AAAA,MACpB,UAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAS,EAAA,UAAA;AAAA,MACT,SAAA,EAAW,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,MAC3B,YAAA,EAAc,YACZ,UAAa,GAAA,CAAA,EAAG,MAAM,CAAK,EAAA,EAAA,YAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,YAAA,CAAe,OAAO,CAAM,CAAA,CAAA,GAAA,MAAA;AAAA,MAEzD,aAAa,CACX,MAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,SAAA;AAAA,QAAA;AAAA,UACE,GAAG,MAAA;AAAA,UACJ,KAAM,EAAA,MAAA;AAAA,UACN,QAAU,EAAA,CAAA,CAAA,KAAK,aAAc,CAAA,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,UAC3C,KAAO,EAAA,UAAA;AAAA,UACP,YACE,UACA,IAAA,IAAA,GAAA,UAAA,GAAA,sHAAA;AAAA,SAAA;AAAA,OAEJ;AAAA,KAAA;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { makeFieldSchemaFromZod } from '../utils.esm.js';
3
+
4
+ const EntityTagsPickerFieldSchema = makeFieldSchemaFromZod(
5
+ z.array(z.string()),
6
+ z.object({
7
+ kinds: z.array(z.string()).optional().describe("List of kinds of entities to derive tags from"),
8
+ showCounts: z.boolean().optional().describe("Whether to show usage counts per tag"),
9
+ helperText: z.string().optional().describe("Helper text to display")
10
+ })
11
+ );
12
+ const EntityTagsPickerSchema = EntityTagsPickerFieldSchema.schema;
13
+
14
+ export { EntityTagsPickerFieldSchema, EntityTagsPickerSchema };
15
+ //# sourceMappingURL=schema.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../../src/components/fields/EntityTagsPicker/schema.ts"],"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 { z } from 'zod';\nimport { makeFieldSchemaFromZod } from '../utils';\n\n/**\n * @public\n */\nexport const EntityTagsPickerFieldSchema = makeFieldSchemaFromZod(\n z.array(z.string()),\n z.object({\n kinds: z\n .array(z.string())\n .optional()\n .describe('List of kinds of entities to derive tags from'),\n showCounts: z\n .boolean()\n .optional()\n .describe('Whether to show usage counts per tag'),\n helperText: z.string().optional().describe('Helper text to display'),\n }),\n);\n\nexport const EntityTagsPickerSchema = EntityTagsPickerFieldSchema.schema;\n\nexport type EntityTagsPickerProps = typeof EntityTagsPickerFieldSchema.type;\n\n/**\n * The input props that can be specified under `ui:options` for the\n * `EntityTagsPicker` field extension.\n *\n * @public\n */\nexport type EntityTagsPickerUiOptions =\n typeof EntityTagsPickerFieldSchema.uiOptionsType;\n"],"names":[],"mappings":";;;AAqBO,MAAM,2BAA8B,GAAA,sBAAA;AAAA,EACzC,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,MAAA,EAAQ,CAAA;AAAA,EAClB,EAAE,MAAO,CAAA;AAAA,IACP,KAAA,EAAO,CACJ,CAAA,KAAA,CAAM,CAAE,CAAA,MAAA,EAAQ,CAChB,CAAA,QAAA,EACA,CAAA,QAAA,CAAS,+CAA+C,CAAA;AAAA,IAC3D,YAAY,CACT,CAAA,OAAA,GACA,QAAS,EAAA,CACT,SAAS,sCAAsC,CAAA;AAAA,IAClD,YAAY,CAAE,CAAA,MAAA,GAAS,QAAS,EAAA,CAAE,SAAS,wBAAwB,CAAA;AAAA,GACpE,CAAA;AACH,EAAA;AAEO,MAAM,yBAAyB,2BAA4B,CAAA;;;;"}
@@ -0,0 +1,168 @@
1
+ import { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';
2
+ import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
3
+ import { useApi } from '@backstage/core-plugin-api';
4
+ import { catalogApiRef, humanizeEntityRef } from '@backstage/plugin-catalog-react';
5
+ import TextField from '@material-ui/core/TextField';
6
+ import FormControl from '@material-ui/core/FormControl';
7
+ import Autocomplete from '@material-ui/lab/Autocomplete';
8
+ import React, { useCallback, useEffect } from 'react';
9
+ import useAsync from 'react-use/esm/useAsync';
10
+ export { MultiEntityPickerSchema } from './schema.esm.js';
11
+
12
+ const MultiEntityPicker = (props) => {
13
+ var _a, _b, _c, _d, _e;
14
+ const {
15
+ onChange,
16
+ schema: { title = "Entity", description = "An entity from the catalog" },
17
+ required,
18
+ uiSchema,
19
+ rawErrors,
20
+ formData,
21
+ idSchema
22
+ } = props;
23
+ const catalogFilter = buildCatalogFilter(uiSchema);
24
+ const defaultKind = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.defaultKind;
25
+ const defaultNamespace = ((_b = uiSchema["ui:options"]) == null ? void 0 : _b.defaultNamespace) || void 0;
26
+ const catalogApi = useApi(catalogApiRef);
27
+ const { value: entities, loading } = useAsync(async () => {
28
+ const { items } = await catalogApi.getEntities(
29
+ catalogFilter ? { filter: catalogFilter } : void 0
30
+ );
31
+ return items;
32
+ });
33
+ const allowArbitraryValues = (_d = (_c = uiSchema["ui:options"]) == null ? void 0 : _c.allowArbitraryValues) != null ? _d : true;
34
+ const getLabel = useCallback(
35
+ (ref) => {
36
+ try {
37
+ return humanizeEntityRef(
38
+ parseEntityRef(ref, { defaultKind, defaultNamespace }),
39
+ {
40
+ defaultKind,
41
+ defaultNamespace
42
+ }
43
+ );
44
+ } catch (err) {
45
+ return ref;
46
+ }
47
+ },
48
+ [defaultKind, defaultNamespace]
49
+ );
50
+ const onSelect = useCallback(
51
+ (_, refs, reason) => {
52
+ const values = refs.map((ref) => {
53
+ if (typeof ref !== "string") {
54
+ return ref ? stringifyEntityRef(ref) : void 0;
55
+ }
56
+ if (reason === "blur" || reason === "create-option") {
57
+ let entityRef = ref;
58
+ try {
59
+ entityRef = stringifyEntityRef(
60
+ parseEntityRef(ref, {
61
+ defaultKind,
62
+ defaultNamespace
63
+ })
64
+ );
65
+ } catch (err) {
66
+ }
67
+ if (formData.includes(ref) || allowArbitraryValues) {
68
+ return entityRef;
69
+ }
70
+ }
71
+ return void 0;
72
+ }).filter((ref) => ref !== void 0);
73
+ onChange(values);
74
+ },
75
+ [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues]
76
+ );
77
+ useEffect(() => {
78
+ if ((entities == null ? void 0 : entities.length) === 1) {
79
+ onChange([stringifyEntityRef(entities[0])]);
80
+ }
81
+ }, [entities, onChange]);
82
+ return /* @__PURE__ */ React.createElement(
83
+ FormControl,
84
+ {
85
+ margin: "normal",
86
+ required,
87
+ error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !formData
88
+ },
89
+ /* @__PURE__ */ React.createElement(
90
+ Autocomplete,
91
+ {
92
+ multiple: true,
93
+ filterSelectedOptions: true,
94
+ disabled: (entities == null ? void 0 : entities.length) === 1,
95
+ id: idSchema == null ? void 0 : idSchema.$id,
96
+ value: (
97
+ // Since free solo can be enabled, attempt to parse as a full entity ref first, then fall
98
+ // back to the given value.
99
+ (_e = entities == null ? void 0 : entities.filter(
100
+ (e) => formData && formData.includes(stringifyEntityRef(e))
101
+ )) != null ? _e : allowArbitraryValues && formData ? formData.map(getLabel) : []
102
+ ),
103
+ loading,
104
+ onChange: onSelect,
105
+ options: entities || [],
106
+ getOptionLabel: (option) => (
107
+ // option can be a string due to freeSolo.
108
+ typeof option === "string" ? option : humanizeEntityRef(option, { defaultKind, defaultNamespace })
109
+ ),
110
+ autoSelect: true,
111
+ freeSolo: allowArbitraryValues,
112
+ renderInput: (params) => /* @__PURE__ */ React.createElement(
113
+ TextField,
114
+ {
115
+ ...params,
116
+ label: title,
117
+ margin: "dense",
118
+ helperText: description,
119
+ FormHelperTextProps: { margin: "dense", style: { marginLeft: 0 } },
120
+ variant: "outlined",
121
+ required,
122
+ InputProps: params.InputProps
123
+ }
124
+ )
125
+ }
126
+ )
127
+ );
128
+ };
129
+ const validateMultiEntityPickerValidation = (values, validation) => {
130
+ values.forEach((value) => {
131
+ try {
132
+ parseEntityRef(value);
133
+ } catch {
134
+ validation.addError(`${value} is not a valid entity ref`);
135
+ }
136
+ });
137
+ };
138
+ function convertOpsValues(value) {
139
+ if (typeof value === "object" && value.exists) {
140
+ return CATALOG_FILTER_EXISTS;
141
+ }
142
+ return value == null ? void 0 : value.toString();
143
+ }
144
+ function convertSchemaFiltersToQuery(schemaFilters) {
145
+ const query = {};
146
+ for (const [key, value] of Object.entries(schemaFilters)) {
147
+ if (Array.isArray(value)) {
148
+ query[key] = value;
149
+ } else {
150
+ query[key] = convertOpsValues(value);
151
+ }
152
+ }
153
+ return query;
154
+ }
155
+ function buildCatalogFilter(uiSchema) {
156
+ var _a;
157
+ const catalogFilter = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.catalogFilter;
158
+ if (!catalogFilter) {
159
+ return void 0;
160
+ }
161
+ if (Array.isArray(catalogFilter)) {
162
+ return catalogFilter.map(convertSchemaFiltersToQuery);
163
+ }
164
+ return convertSchemaFiltersToQuery(catalogFilter);
165
+ }
166
+
167
+ export { MultiEntityPicker, validateMultiEntityPickerValidation };
168
+ //# sourceMappingURL=MultiEntityPicker.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiEntityPicker.esm.js","sources":["../../../../src/components/fields/MultiEntityPicker/MultiEntityPicker.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 catalogApiRef,\n humanizeEntityRef,\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} from '@material-ui/lab/Autocomplete';\nimport React, { useCallback, useEffect } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { FieldValidation } from '@rjsf/utils';\nimport {\n MultiEntityPickerFilterQueryValue,\n MultiEntityPickerProps,\n MultiEntityPickerUiOptions,\n MultiEntityPickerFilterQuery,\n} from './schema';\n\nexport { MultiEntityPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `MultiEntityPicker`\n * field extension.\n */\nexport const MultiEntityPicker = (props: MultiEntityPickerProps) => {\n const {\n onChange,\n schema: { title = 'Entity', description = 'An entity from the catalog' },\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\n const { value: entities, loading } = useAsync(async () => {\n const { items } = await catalogApi.getEntities(\n catalogFilter ? { filter: catalogFilter } : undefined,\n );\n return items;\n });\n const allowArbitraryValues =\n uiSchema['ui:options']?.allowArbitraryValues ?? true;\n\n const getLabel = useCallback(\n (ref: string) => {\n try {\n return humanizeEntityRef(\n parseEntityRef(ref, { defaultKind, defaultNamespace }),\n {\n defaultKind,\n defaultNamespace,\n },\n );\n } catch (err) {\n return ref;\n }\n },\n [defaultKind, defaultNamespace],\n );\n\n const onSelect = useCallback(\n (_: any, refs: (string | Entity)[], reason: AutocompleteChangeReason) => {\n const values = refs\n .map(ref => {\n if (typeof ref !== 'string') {\n // if ref does not exist: pass 'undefined' to trigger validation for required value\n return ref ? stringifyEntityRef(ref as Entity) : undefined;\n }\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\n // We need to check against formData here as that's the previous value for this field.\n if (formData.includes(ref) || allowArbitraryValues) {\n return entityRef;\n }\n }\n\n return undefined;\n })\n .filter(ref => ref !== undefined) as string[];\n\n onChange(values);\n },\n [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues],\n );\n\n useEffect(() => {\n if (entities?.length === 1) {\n onChange([stringifyEntityRef(entities[0])]);\n }\n }, [entities, onChange]);\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !formData}\n >\n <Autocomplete\n multiple\n filterSelectedOptions\n disabled={entities?.length === 1}\n id={idSchema?.$id}\n value={\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 entities?.filter(\n e => formData && formData.includes(stringifyEntityRef(e)),\n ) ?? (allowArbitraryValues && formData ? formData.map(getLabel) : [])\n }\n loading={loading}\n onChange={onSelect}\n options={entities || []}\n getOptionLabel={option =>\n // option can be a string due to freeSolo.\n typeof option === 'string'\n ? option\n : humanizeEntityRef(option, { defaultKind, defaultNamespace })!\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 />\n </FormControl>\n );\n};\n\nexport const validateMultiEntityPickerValidation = (\n values: string[],\n validation: FieldValidation,\n) => {\n values.forEach(value => {\n try {\n parseEntityRef(value);\n } catch {\n validation.addError(`${value} is not a valid entity ref`);\n }\n });\n};\n\n/**\n * Converts a special `{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<MultiEntityPickerFilterQueryValue, 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: MultiEntityPickerFilterQuery,\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 *\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: MultiEntityPickerProps['uiSchema'],\n): EntityFilterQuery | undefined {\n const catalogFilter: MultiEntityPickerUiOptions['catalogFilter'] | undefined =\n uiSchema['ui:options']?.catalogFilter;\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":";;;;;;;;;;;AAkDa,MAAA,iBAAA,GAAoB,CAAC,KAAkC,KAAA;AAlDpE,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAmDE,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,MAAQ,EAAA,EAAE,KAAQ,GAAA,QAAA,EAAU,cAAc,4BAA6B,EAAA;AAAA,IACvE,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,aAAA,GAAgB,mBAAmB,QAAQ,CAAA,CAAA;AACjD,EAAA,MAAM,WAAc,GAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,IAAwB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,WAAA,CAAA;AAC5C,EAAA,MAAM,gBACJ,GAAA,CAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,mBAAwB,gBAAoB,KAAA,KAAA,CAAA,CAAA;AAE9C,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AAEvC,EAAA,MAAM,EAAE,KAAO,EAAA,QAAA,EAAU,OAAQ,EAAA,GAAI,SAAS,YAAY;AACxD,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAM,UAAW,CAAA,WAAA;AAAA,MACjC,aAAgB,GAAA,EAAE,MAAQ,EAAA,aAAA,EAAkB,GAAA,KAAA,CAAA;AAAA,KAC9C,CAAA;AACA,IAAO,OAAA,KAAA,CAAA;AAAA,GACR,CAAA,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FromZod } from '../utils.esm.js';
3
+
4
+ const entityQueryFilterExpressionSchema = z.record(
5
+ z.string().or(z.object({ exists: z.boolean().optional() })).or(z.array(z.string()))
6
+ );
7
+ const MultiEntityPickerFieldSchema = makeFieldSchemaFromZod(
8
+ z.array(z.string()),
9
+ z.object({
10
+ defaultKind: z.string().optional().describe(
11
+ "The default entity kind. Options of this kind will not be prefixed."
12
+ ),
13
+ allowArbitraryValues: z.boolean().optional().describe("Whether to allow arbitrary user input. Defaults to true"),
14
+ defaultNamespace: z.union([z.string(), z.literal(false)]).optional().describe(
15
+ "The default namespace. Options with this namespace will not be prefixed."
16
+ ),
17
+ catalogFilter: z.array(entityQueryFilterExpressionSchema).or(entityQueryFilterExpressionSchema).optional().describe("List of key-value filter expression for entities")
18
+ })
19
+ );
20
+ const MultiEntityPickerSchema = MultiEntityPickerFieldSchema.schema;
21
+
22
+ export { MultiEntityPickerFieldSchema, MultiEntityPickerSchema, entityQueryFilterExpressionSchema };
23
+ //# sourceMappingURL=schema.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../../src/components/fields/MultiEntityPicker/schema.ts"],"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 { z } from 'zod';\nimport { makeFieldSchemaFromZod } from '../utils';\n\nexport const entityQueryFilterExpressionSchema = z.record(\n z\n .string()\n .or(z.object({ exists: z.boolean().optional() }))\n .or(z.array(z.string())),\n);\n\nexport const MultiEntityPickerFieldSchema = makeFieldSchemaFromZod(\n z.array(z.string()),\n z.object({\n defaultKind: z\n .string()\n .optional()\n .describe(\n 'The default entity kind. Options of this kind will not be prefixed.',\n ),\n allowArbitraryValues: z\n .boolean()\n .optional()\n .describe('Whether to allow arbitrary user input. Defaults to true'),\n defaultNamespace: z\n .union([z.string(), z.literal(false)])\n .optional()\n .describe(\n 'The default namespace. Options with this namespace will not be prefixed.',\n ),\n catalogFilter: z\n .array(entityQueryFilterExpressionSchema)\n .or(entityQueryFilterExpressionSchema)\n .optional()\n .describe('List of key-value filter expression for entities'),\n }),\n);\n\n/**\n * The input props that can be specified under `ui:options` for the\n * `EntityPicker` field extension.\n */\nexport type MultiEntityPickerUiOptions =\n typeof MultiEntityPickerFieldSchema.uiOptionsType;\n\nexport type MultiEntityPickerProps = typeof MultiEntityPickerFieldSchema.type;\n\nexport const MultiEntityPickerSchema = MultiEntityPickerFieldSchema.schema;\n\nexport type MultiEntityPickerFilterQuery = z.TypeOf<\n typeof entityQueryFilterExpressionSchema\n>;\n\nexport type MultiEntityPickerFilterQueryValue =\n MultiEntityPickerFilterQuery[keyof MultiEntityPickerFilterQuery];\n"],"names":[],"mappings":";;;AAkBO,MAAM,oCAAoC,CAAE,CAAA,MAAA;AAAA,EACjD,CAAA,CACG,QACA,CAAA,EAAA,CAAG,EAAE,MAAO,CAAA,EAAE,MAAQ,EAAA,CAAA,CAAE,OAAQ,EAAA,CAAE,UAAW,EAAC,CAAC,CAC/C,CAAA,EAAA,CAAG,EAAE,KAAM,CAAA,CAAA,CAAE,MAAO,EAAC,CAAC,CAAA;AAC3B,EAAA;AAEO,MAAM,4BAA+B,GAAA,sBAAA;AAAA,EAC1C,CAAE,CAAA,KAAA,CAAM,CAAE,CAAA,MAAA,EAAQ,CAAA;AAAA,EAClB,EAAE,MAAO,CAAA;AAAA,IACP,WAAa,EAAA,CAAA,CACV,MAAO,EAAA,CACP,UACA,CAAA,QAAA;AAAA,MACC,qEAAA;AAAA,KACF;AAAA,IACF,sBAAsB,CACnB,CAAA,OAAA,GACA,QAAS,EAAA,CACT,SAAS,yDAAyD,CAAA;AAAA,IACrE,gBAAkB,EAAA,CAAA,CACf,KAAM,CAAA,CAAC,EAAE,MAAO,EAAA,EAAG,CAAE,CAAA,OAAA,CAAQ,KAAK,CAAC,CAAC,CAAA,CACpC,UACA,CAAA,QAAA;AAAA,MACC,0EAAA;AAAA,KACF;AAAA,IACF,aAAA,EAAe,CACZ,CAAA,KAAA,CAAM,iCAAiC,CAAA,CACvC,EAAG,CAAA,iCAAiC,CACpC,CAAA,QAAA,EACA,CAAA,QAAA,CAAS,kDAAkD,CAAA;AAAA,GAC/D,CAAA;AACH,EAAA;AAWO,MAAM,0BAA0B,4BAA6B,CAAA;;;;"}
@@ -0,0 +1,83 @@
1
+ import React, { useState } from 'react';
2
+ import { useApi, identityApiRef, errorApiRef } from '@backstage/core-plugin-api';
3
+ import TextField from '@material-ui/core/TextField';
4
+ import FormControl from '@material-ui/core/FormControl';
5
+ export { MyGroupsPickerSchema } from './schema.esm.js';
6
+ import Autocomplete from '@material-ui/lab/Autocomplete';
7
+ import { catalogApiRef } from '@backstage/plugin-catalog-react';
8
+ import { NotFoundError } from '@backstage/errors';
9
+ import useAsync from 'react-use/esm/useAsync';
10
+ import { stringifyEntityRef } from '@backstage/catalog-model';
11
+
12
+ const MyGroupsPicker = (props) => {
13
+ const {
14
+ schema: { title, description },
15
+ required,
16
+ rawErrors,
17
+ onChange,
18
+ formData
19
+ } = props;
20
+ const identityApi = useApi(identityApiRef);
21
+ const catalogApi = useApi(catalogApiRef);
22
+ const errorApi = useApi(errorApiRef);
23
+ const [groups, setGroups] = useState([]);
24
+ useAsync(async () => {
25
+ const { userEntityRef } = await identityApi.getBackstageIdentity();
26
+ if (!userEntityRef) {
27
+ errorApi.post(new NotFoundError("No user entity ref found"));
28
+ return;
29
+ }
30
+ const { items } = await catalogApi.getEntities({
31
+ filter: {
32
+ kind: "Group",
33
+ ["relations.hasMember"]: [userEntityRef]
34
+ }
35
+ });
36
+ const groupValues = items.filter((e) => Boolean(e)).map((item) => {
37
+ var _a;
38
+ return {
39
+ label: (_a = item.metadata.title) != null ? _a : item.metadata.name,
40
+ ref: stringifyEntityRef(item)
41
+ };
42
+ });
43
+ setGroups(groupValues);
44
+ });
45
+ const updateChange = (_, value) => {
46
+ var _a;
47
+ onChange((_a = value == null ? void 0 : value.ref) != null ? _a : "");
48
+ };
49
+ const selectedEntity = (groups == null ? void 0 : groups.find((e) => e.ref === formData)) || null;
50
+ return /* @__PURE__ */ React.createElement(
51
+ FormControl,
52
+ {
53
+ margin: "normal",
54
+ required,
55
+ error: (rawErrors == null ? void 0 : rawErrors.length) > 0
56
+ },
57
+ /* @__PURE__ */ React.createElement(
58
+ Autocomplete,
59
+ {
60
+ id: "OwnershipEntityRefPicker-dropdown",
61
+ options: groups || [],
62
+ value: selectedEntity,
63
+ onChange: updateChange,
64
+ getOptionLabel: (group) => group.label,
65
+ renderInput: (params) => /* @__PURE__ */ React.createElement(
66
+ TextField,
67
+ {
68
+ ...params,
69
+ label: title,
70
+ margin: "dense",
71
+ helperText: description,
72
+ FormHelperTextProps: { margin: "dense", style: { marginLeft: 0 } },
73
+ variant: "outlined",
74
+ required
75
+ }
76
+ )
77
+ }
78
+ )
79
+ );
80
+ };
81
+
82
+ export { MyGroupsPicker };
83
+ //# sourceMappingURL=MyGroupsPicker.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MyGroupsPicker.esm.js","sources":["../../../../src/components/fields/MyGroupsPicker/MyGroupsPicker.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 React, { useState } from 'react';\nimport {\n errorApiRef,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport { MyGroupsPickerProps, MyGroupsPickerSchema } from './schema';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { NotFoundError } from '@backstage/errors';\nimport useAsync from 'react-use/esm/useAsync';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\n\nexport { MyGroupsPickerSchema };\n\nexport const MyGroupsPicker = (props: MyGroupsPickerProps) => {\n const {\n schema: { title, description },\n required,\n rawErrors,\n onChange,\n formData,\n } = props;\n\n const identityApi = useApi(identityApiRef);\n const catalogApi = useApi(catalogApiRef);\n const errorApi = useApi(errorApiRef);\n const [groups, setGroups] = useState<\n {\n label: string;\n ref: string;\n }[]\n >([]);\n\n useAsync(async () => {\n const { userEntityRef } = await identityApi.getBackstageIdentity();\n\n if (!userEntityRef) {\n errorApi.post(new NotFoundError('No user entity ref found'));\n return;\n }\n\n const { items } = await catalogApi.getEntities({\n filter: {\n kind: 'Group',\n ['relations.hasMember']: [userEntityRef],\n },\n });\n\n const groupValues = items\n .filter((e): e is Entity => Boolean(e))\n .map(item => ({\n label: item.metadata.title ?? item.metadata.name,\n ref: stringifyEntityRef(item),\n }));\n\n setGroups(groupValues);\n });\n\n const updateChange = (\n _: React.ChangeEvent<{}>,\n value: { label: string; ref: string } | null,\n ) => {\n onChange(value?.ref ?? '');\n };\n\n const selectedEntity = groups?.find(e => e.ref === formData) || null;\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0}\n >\n <Autocomplete\n id=\"OwnershipEntityRefPicker-dropdown\"\n options={groups || []}\n value={selectedEntity}\n onChange={updateChange}\n getOptionLabel={group => group.label}\n renderInput={params => (\n <TextField\n {...params}\n label={title}\n margin=\"dense\"\n helperText={description}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 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A,OAAA;AAAA,YACP,UAAY,EAAA,WAAA;AAAA,YACZ,mBAAA,EAAqB,EAAE,MAAQ,EAAA,OAAA,EAAS,OAAO,EAAE,UAAA,EAAY,GAAI,EAAA;AAAA,YACjE,OAAQ,EAAA,UAAA;AAAA,YACR,QAAA;AAAA,WAAA;AAAA,SACF;AAAA,OAAA;AAAA,KAEJ;AAAA,GACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { makeFieldSchemaFromZod } from '../utils.esm.js';
3
+
4
+ const MyGroupsPickerFieldSchema = makeFieldSchemaFromZod(
5
+ z.string(),
6
+ z.object({
7
+ title: z.string().default("Group").describe("Group"),
8
+ description: z.string().default("A group you are part of").describe("The group to which the entity belongs")
9
+ })
10
+ );
11
+ const MyGroupsPickerSchema = MyGroupsPickerFieldSchema.schema;
12
+
13
+ export { MyGroupsPickerFieldSchema, MyGroupsPickerSchema };
14
+ //# sourceMappingURL=schema.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../../src/components/fields/MyGroupsPicker/schema.ts"],"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 { z } from 'zod';\nimport { makeFieldSchemaFromZod } from '../utils';\n\n/**\n * Field schema for the MyGroupsPicker.\n * @public\n */\n\nexport const MyGroupsPickerFieldSchema = makeFieldSchemaFromZod(\n z.string(),\n z.object({\n title: z.string().default('Group').describe('Group'),\n description: z\n .string()\n .default('A group you are part of')\n .describe('The group to which the entity belongs'),\n }),\n);\n\n/**\n * UI options for the MyGroupsPicker.\n * @public\n */\n\nexport type MyGroupsPickerUiOptions =\n typeof MyGroupsPickerFieldSchema.uiOptionsType;\n/**\n * Props for the MyGroupsPicker.\n * @public\n */\n\nexport type MyGroupsPickerProps = typeof MyGroupsPickerFieldSchema.type;\n\n/**\n * Schema for the MyGroupsPicker.\n * @public\n */\n\nexport const MyGroupsPickerSchema = MyGroupsPickerFieldSchema.schema;\n"],"names":[],"mappings":";;;AAwBO,MAAM,yBAA4B,GAAA,sBAAA;AAAA,EACvC,EAAE,MAAO,EAAA;AAAA,EACT,EAAE,MAAO,CAAA;AAAA,IACP,KAAA,EAAO,EAAE,MAAO,EAAA,CAAE,QAAQ,OAAO,CAAA,CAAE,SAAS,OAAO,CAAA;AAAA,IACnD,WAAA,EAAa,EACV,MAAO,EAAA,CACP,QAAQ,yBAAyB,CAAA,CACjC,SAAS,uCAAuC,CAAA;AAAA,GACpD,CAAA;AACH,EAAA;AAqBO,MAAM,uBAAuB,yBAA0B,CAAA;;;;"}
@@ -0,0 +1,68 @@
1
+ import { RELATION_OWNED_BY } from '@backstage/catalog-model';
2
+ import { useApi, identityApiRef } from '@backstage/core-plugin-api';
3
+ import TextField from '@material-ui/core/TextField';
4
+ import Autocomplete from '@material-ui/lab/Autocomplete';
5
+ import React from 'react';
6
+ import useAsync from 'react-use/esm/useAsync';
7
+ import { EntityPicker } from '../EntityPicker/EntityPicker.esm.js';
8
+ export { OwnedEntityPickerSchema } from './schema.esm.js';
9
+
10
+ const OwnedEntityPicker = (props) => {
11
+ const {
12
+ schema: { title = "Entity", description = "An entity from the catalog" },
13
+ uiSchema,
14
+ required
15
+ } = props;
16
+ const identityApi = useApi(identityApiRef);
17
+ const { loading, value: identityRefs } = useAsync(async () => {
18
+ const identity = await identityApi.getBackstageIdentity();
19
+ return identity.ownershipEntityRefs;
20
+ });
21
+ if (loading)
22
+ return /* @__PURE__ */ React.createElement(
23
+ Autocomplete,
24
+ {
25
+ loading,
26
+ renderInput: (params) => /* @__PURE__ */ React.createElement(
27
+ TextField,
28
+ {
29
+ ...params,
30
+ label: title,
31
+ margin: "dense",
32
+ helperText: description,
33
+ FormHelperTextProps: { margin: "dense", style: { marginLeft: 0 } },
34
+ variant: "outlined",
35
+ required,
36
+ InputProps: params.InputProps
37
+ }
38
+ ),
39
+ options: []
40
+ }
41
+ );
42
+ const entityPickerUISchema = buildEntityPickerUISchema(
43
+ uiSchema,
44
+ identityRefs
45
+ );
46
+ return /* @__PURE__ */ React.createElement(EntityPicker, { ...props, uiSchema: entityPickerUISchema });
47
+ };
48
+ function buildEntityPickerUISchema(uiSchema, identityRefs) {
49
+ const uiOptions = (uiSchema == null ? void 0 : uiSchema["ui:options"]) || {};
50
+ const allowedKinds = uiOptions.allowedKinds;
51
+ const catalogFilter = {
52
+ ...uiOptions.catalogFilter,
53
+ ...allowedKinds ? {
54
+ kind: allowedKinds,
55
+ [`relations.${RELATION_OWNED_BY}`]: identityRefs || []
56
+ } : {
57
+ [`relations.${RELATION_OWNED_BY}`]: identityRefs || []
58
+ }
59
+ };
60
+ return {
61
+ "ui:options": {
62
+ catalogFilter
63
+ }
64
+ };
65
+ }
66
+
67
+ export { OwnedEntityPicker };
68
+ //# sourceMappingURL=OwnedEntityPicker.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnedEntityPicker.esm.js","sources":["../../../../src/components/fields/OwnedEntityPicker/OwnedEntityPicker.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 { RELATION_OWNED_BY } from '@backstage/catalog-model';\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport TextField from '@material-ui/core/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport React from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { EntityPicker } from '../EntityPicker/EntityPicker';\n\nimport { OwnedEntityPickerProps } from './schema';\nimport { EntityPickerProps } from '../EntityPicker/schema';\n\nexport { OwnedEntityPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `OwnedEntityPicker`\n * field extension.\n *\n * @public\n */\nexport const OwnedEntityPicker = (props: OwnedEntityPickerProps) => {\n const {\n schema: { title = 'Entity', description = 'An entity from the catalog' },\n uiSchema,\n required,\n } = props;\n\n const identityApi = useApi(identityApiRef);\n const { loading, value: identityRefs } = useAsync(async () => {\n const identity = await identityApi.getBackstageIdentity();\n return identity.ownershipEntityRefs;\n });\n\n if (loading)\n return (\n <Autocomplete\n loading={loading}\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 options={[]}\n />\n );\n\n const entityPickerUISchema = buildEntityPickerUISchema(\n uiSchema,\n identityRefs,\n );\n\n return <EntityPicker {...props} uiSchema={entityPickerUISchema} />;\n};\n\n/**\n * Builds a `uiSchema` for an `EntityPicker` from a parent `OwnedEntityPicker`.\n * Migrates deprecated parameters such as `allowedKinds` to `catalogFilter` structure.\n *\n * @param uiSchema The `uiSchema` of an `OwnedEntityPicker` component.\n * @param identityRefs The user and group entities that the user claims ownership through.\n * @returns The `uiSchema` for an `EntityPicker` component.\n */\nfunction buildEntityPickerUISchema(\n uiSchema: OwnedEntityPickerProps['uiSchema'],\n identityRefs: string[] | undefined,\n): EntityPickerProps['uiSchema'] {\n // Note: This is typed to avoid es-lint rule TS2698\n const uiOptions: EntityPickerProps['uiSchema']['ui:options'] =\n uiSchema?.['ui:options'] || {};\n const allowedKinds = uiOptions.allowedKinds;\n\n const catalogFilter = {\n ...uiOptions.catalogFilter,\n ...(allowedKinds\n ? {\n kind: allowedKinds,\n [`relations.${RELATION_OWNED_BY}`]: identityRefs || [],\n }\n : {\n [`relations.${RELATION_OWNED_BY}`]: identityRefs || [],\n }),\n };\n\n return {\n 'ui:options': {\n catalogFilter,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAkCa,MAAA,iBAAA,GAAoB,CAAC,KAAkC,KAAA;AAClE,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA,EAAE,KAAQ,GAAA,QAAA,EAAU,cAAc,4BAA6B,EAAA;AAAA,IACvE,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,EAAE,OAAS,EAAA,KAAA,EAAO,YAAa,EAAA,GAAI,SAAS,YAAY;AAC5D,IAAM,MAAA,QAAA,GAAW,MAAM,WAAA,CAAY,oBAAqB,EAAA,CAAA;AACxD,IAAA,OAAO,QAAS,CAAA,mBAAA,CAAA;AAAA,GACjB,CAAA,CAAA;AAED,EAAI,IAAA,OAAA;AACF,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,OAAA;AAAA,QACA,aAAa,CACX,MAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,SAAA;AAAA,UAAA;AAAA,YACE,GAAG,MAAA;AAAA,YACJ,KAAO,EAAA,KAAA;AAAA,YACP,MAAO,EAAA,OAAA;AAAA,YACP,UAAY,EAAA,WAAA;AAAA,YACZ,mBAAA,EAAqB,EAAE,MAAQ,EAAA,OAAA,EAAS,OAAO,EAAE,UAAA,EAAY,GAAI,EAAA;AAAA,YACjE,OAAQ,EAAA,UAAA;AAAA,YACR,QAAA;AAAA,YACA,YAAY,MAAO,CAAA,UAAA;AAAA,WAAA;AAAA,SACrB;AAAA,QAEF,SAAS,EAAC;AAAA,OAAA;AAAA,KACZ,CAAA;AAGJ,EAAA,MAAM,oBAAuB,GAAA,yBAAA;AAAA,IAC3B,QAAA;AAAA,IACA,YAAA;AAAA,GACF,CAAA;AAEA,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAc,GAAG,KAAA,EAAO,UAAU,oBAAsB,EAAA,CAAA,CAAA;AAClE,EAAA;AAUA,SAAS,yBAAA,CACP,UACA,YAC+B,EAAA;AAE/B,EAAM,MAAA,SAAA,GAAA,CACJ,QAAW,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAA,YAAA,CAAA,KAAiB,EAAC,CAAA;AAC/B,EAAA,MAAM,eAAe,SAAU,CAAA,YAAA,CAAA;AAE/B,EAAA,MAAM,aAAgB,GAAA;AAAA,IACpB,GAAG,SAAU,CAAA,aAAA;AAAA,IACb,GAAI,YACA,GAAA;AAAA,MACE,IAAM,EAAA,YAAA;AAAA,MACN,CAAC,CAAa,UAAA,EAAA,iBAAiB,CAAE,CAAA,GAAG,gBAAgB,EAAC;AAAA,KAEvD,GAAA;AAAA,MACE,CAAC,CAAa,UAAA,EAAA,iBAAiB,CAAE,CAAA,GAAG,gBAAgB,EAAC;AAAA,KACvD;AAAA,GACN,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,YAAc,EAAA;AAAA,MACZ,aAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { makeFieldSchemaFromZod } from '../utils.esm.js';
3
+ import { entityQueryFilterExpressionSchema } from '../EntityPicker/schema.esm.js';
4
+
5
+ const OwnedEntityPickerFieldSchema = makeFieldSchemaFromZod(
6
+ z.string(),
7
+ z.object({
8
+ allowedKinds: z.array(z.string()).optional().describe(
9
+ "DEPRECATED: Use `catalogFilter` instead. List of kinds of entities to derive options from"
10
+ ),
11
+ defaultKind: z.string().optional().describe(
12
+ "The default entity kind. Options of this kind will not be prefixed."
13
+ ),
14
+ allowArbitraryValues: z.boolean().optional().describe("Whether to allow arbitrary user input. Defaults to true"),
15
+ defaultNamespace: z.union([z.string(), z.literal(false)]).optional().describe(
16
+ "The default namespace. Options with this namespace will not be prefixed."
17
+ ),
18
+ catalogFilter: z.array(entityQueryFilterExpressionSchema).or(entityQueryFilterExpressionSchema).optional().describe("List of key-value filter expression for entities")
19
+ })
20
+ );
21
+ const OwnedEntityPickerSchema = OwnedEntityPickerFieldSchema.schema;
22
+
23
+ export { OwnedEntityPickerFieldSchema, OwnedEntityPickerSchema };
24
+ //# sourceMappingURL=schema.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../../src/components/fields/OwnedEntityPicker/schema.ts"],"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 { z } from 'zod';\nimport { makeFieldSchemaFromZod } from '../utils';\nimport { entityQueryFilterExpressionSchema } from '../EntityPicker/schema';\n\n/**\n * @public\n */\nexport const OwnedEntityPickerFieldSchema = makeFieldSchemaFromZod(\n z.string(),\n z.object({\n allowedKinds: z\n .array(z.string())\n .optional()\n .describe(\n 'DEPRECATED: Use `catalogFilter` instead. List of kinds of entities to derive options from',\n ),\n defaultKind: z\n .string()\n .optional()\n .describe(\n 'The default entity kind. Options of this kind will not be prefixed.',\n ),\n allowArbitraryValues: z\n .boolean()\n .optional()\n .describe('Whether to allow arbitrary user input. Defaults to true'),\n defaultNamespace: z\n .union([z.string(), z.literal(false)])\n .optional()\n .describe(\n 'The default namespace. Options with this namespace will not be prefixed.',\n ),\n catalogFilter: z\n .array(entityQueryFilterExpressionSchema)\n .or(entityQueryFilterExpressionSchema)\n .optional()\n .describe('List of key-value filter expression for entities'),\n }),\n);\n\n/**\n * The input props that can be specified under `ui:options` for the\n * `OwnedEntityPicker` field extension.\n *\n * @public\n */\nexport type OwnedEntityPickerUiOptions =\n typeof OwnedEntityPickerFieldSchema.uiOptionsType;\n\nexport type OwnedEntityPickerProps = typeof OwnedEntityPickerFieldSchema.type;\n\nexport const OwnedEntityPickerSchema = OwnedEntityPickerFieldSchema.schema;\n"],"names":[],"mappings":";;;;AAsBO,MAAM,4BAA+B,GAAA,sBAAA;AAAA,EAC1C,EAAE,MAAO,EAAA;AAAA,EACT,EAAE,MAAO,CAAA;AAAA,IACP,YAAA,EAAc,EACX,KAAM,CAAA,CAAA,CAAE,QAAQ,CAAA,CAChB,UACA,CAAA,QAAA;AAAA,MACC,2FAAA;AAAA,KACF;AAAA,IACF,WAAa,EAAA,CAAA,CACV,MAAO,EAAA,CACP,UACA,CAAA,QAAA;AAAA,MACC,qEAAA;AAAA,KACF;AAAA,IACF,sBAAsB,CACnB,CAAA,OAAA,GACA,QAAS,EAAA,CACT,SAAS,yDAAyD,CAAA;AAAA,IACrE,gBAAkB,EAAA,CAAA,CACf,KAAM,CAAA,CAAC,EAAE,MAAO,EAAA,EAAG,CAAE,CAAA,OAAA,CAAQ,KAAK,CAAC,CAAC,CAAA,CACpC,UACA,CAAA,QAAA;AAAA,MACC,0EAAA;AAAA,KACF;AAAA,IACF,aAAA,EAAe,CACZ,CAAA,KAAA,CAAM,iCAAiC,CAAA,CACvC,EAAG,CAAA,iCAAiC,CACpC,CAAA,QAAA,EACA,CAAA,QAAA,CAAS,kDAAkD,CAAA;AAAA,GAC/D,CAAA;AACH,EAAA;AAaO,MAAM,0BAA0B,4BAA6B,CAAA;;;;"}
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { EntityPicker } from '../EntityPicker/EntityPicker.esm.js';
3
+ export { OwnerPickerSchema } from './schema.esm.js';
4
+
5
+ const OwnerPicker = (props) => {
6
+ var _a, _b, _c, _d, _e;
7
+ const {
8
+ schema: { title = "Owner", description = "The owner of the component" },
9
+ uiSchema,
10
+ ...restProps
11
+ } = props;
12
+ const defaultNamespace = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.defaultNamespace;
13
+ const allowedKinds = (_b = uiSchema["ui:options"]) == null ? void 0 : _b.allowedKinds;
14
+ const catalogFilter = ((_c = uiSchema["ui:options"]) == null ? void 0 : _c.catalogFilter) || {
15
+ kind: allowedKinds || ["Group", "User"]
16
+ };
17
+ const ownerUiSchema = {
18
+ ...uiSchema,
19
+ "ui:options": {
20
+ catalogFilter,
21
+ defaultKind: "Group",
22
+ allowArbitraryValues: (_e = (_d = uiSchema["ui:options"]) == null ? void 0 : _d.allowArbitraryValues) != null ? _e : true,
23
+ ...defaultNamespace !== void 0 ? { defaultNamespace } : {}
24
+ }
25
+ };
26
+ return /* @__PURE__ */ React.createElement(
27
+ EntityPicker,
28
+ {
29
+ ...restProps,
30
+ schema: { title, description },
31
+ uiSchema: ownerUiSchema
32
+ }
33
+ );
34
+ };
35
+
36
+ export { OwnerPicker };
37
+ //# sourceMappingURL=OwnerPicker.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OwnerPicker.esm.js","sources":["../../../../src/components/fields/OwnerPicker/OwnerPicker.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 React from 'react';\nimport { EntityPicker } from '../EntityPicker/EntityPicker';\nimport { OwnerPickerProps } from './schema';\n\nexport { OwnerPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `OwnerPicker`\n * field extension.\n *\n * @public\n */\nexport const OwnerPicker = (props: OwnerPickerProps) => {\n const {\n schema: { title = 'Owner', description = 'The owner of the component' },\n uiSchema,\n ...restProps\n } = props;\n\n const defaultNamespace = uiSchema['ui:options']?.defaultNamespace;\n const allowedKinds = uiSchema['ui:options']?.allowedKinds;\n\n const catalogFilter = uiSchema['ui:options']?.catalogFilter || {\n kind: allowedKinds || ['Group', 'User'],\n };\n\n const ownerUiSchema = {\n ...uiSchema,\n 'ui:options': {\n catalogFilter,\n defaultKind: 'Group',\n allowArbitraryValues:\n uiSchema['ui:options']?.allowArbitraryValues ?? true,\n ...(defaultNamespace !== undefined ? { defaultNamespace } : {}),\n },\n };\n\n return (\n <EntityPicker\n {...restProps}\n schema={{ title, description }}\n uiSchema={ownerUiSchema}\n />\n );\n};\n"],"names":[],"mappings":";;;;AA2Ba,MAAA,WAAA,GAAc,CAAC,KAA4B,KAAA;AA3BxD,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AA4BE,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA,EAAE,KAAQ,GAAA,OAAA,EAAS,cAAc,4BAA6B,EAAA;AAAA,IACtE,QAAA;AAAA,IACA,GAAG,SAAA;AAAA,GACD,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,gBAAmB,GAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,IAAwB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,gBAAA,CAAA;AACjD,EAAA,MAAM,YAAe,GAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,IAAwB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,YAAA,CAAA;AAE7C,EAAA,MAAM,aAAgB,GAAA,CAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,mBAAwB,aAAiB,KAAA;AAAA,IAC7D,IAAM,EAAA,YAAA,IAAgB,CAAC,OAAA,EAAS,MAAM,CAAA;AAAA,GACxC,CAAA;AAEA,EAAA,MAAM,aAAgB,GAAA;AAAA,IACpB,GAAG,QAAA;AAAA,IACH,YAAc,EAAA;AAAA,MACZ,aAAA;AAAA,MACA,WAAa,EAAA,OAAA;AAAA,MACb,uBACE,EAAS,GAAA,CAAA,EAAA,GAAA,QAAA,CAAA,YAAY,CAArB,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAwB,yBAAxB,IAAgD,GAAA,EAAA,GAAA,IAAA;AAAA,MAClD,GAAI,gBAAqB,KAAA,KAAA,CAAA,GAAY,EAAE,gBAAA,KAAqB,EAAC;AAAA,KAC/D;AAAA,GACF,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACE,GAAG,SAAA;AAAA,MACJ,MAAA,EAAQ,EAAE,KAAA,EAAO,WAAY,EAAA;AAAA,MAC7B,QAAU,EAAA,aAAA;AAAA,KAAA;AAAA,GACZ,CAAA;AAEJ;;;;"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { makeFieldSchemaFromZod } from '../utils.esm.js';
3
+ import { entityQueryFilterExpressionSchema } from '../EntityPicker/schema.esm.js';
4
+
5
+ const OwnerPickerFieldSchema = makeFieldSchemaFromZod(
6
+ z.string(),
7
+ z.object({
8
+ /**
9
+ * @deprecated Use `catalogFilter` instead.
10
+ */
11
+ allowedKinds: z.array(z.string()).default(["Group", "User"]).optional().describe(
12
+ "DEPRECATED: Use `catalogFilter` instead. List of kinds of entities to derive options from. Defaults to Group and User"
13
+ ),
14
+ allowArbitraryValues: z.boolean().optional().describe("Whether to allow arbitrary user input. Defaults to true"),
15
+ defaultNamespace: z.union([z.string(), z.literal(false)]).optional().describe(
16
+ "The default namespace. Options with this namespace will not be prefixed."
17
+ ),
18
+ catalogFilter: z.array(entityQueryFilterExpressionSchema).or(entityQueryFilterExpressionSchema).optional().describe("List of key-value filter expression for entities")
19
+ })
20
+ );
21
+ const OwnerPickerSchema = OwnerPickerFieldSchema.schema;
22
+
23
+ export { OwnerPickerFieldSchema, OwnerPickerSchema };
24
+ //# sourceMappingURL=schema.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../../src/components/fields/OwnerPicker/schema.ts"],"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 { z } from 'zod';\nimport { makeFieldSchemaFromZod } from '../utils';\nimport { entityQueryFilterExpressionSchema } from '../EntityPicker/schema';\n\n/**\n * @public\n */\nexport const OwnerPickerFieldSchema = makeFieldSchemaFromZod(\n z.string(),\n z.object({\n /**\n * @deprecated Use `catalogFilter` instead.\n */\n allowedKinds: z\n .array(z.string())\n .default(['Group', 'User'])\n .optional()\n .describe(\n 'DEPRECATED: Use `catalogFilter` instead. List of kinds of entities to derive options from. Defaults to Group and User',\n ),\n allowArbitraryValues: z\n .boolean()\n .optional()\n .describe('Whether to allow arbitrary user input. Defaults to true'),\n defaultNamespace: z\n .union([z.string(), z.literal(false)])\n .optional()\n .describe(\n 'The default namespace. Options with this namespace will not be prefixed.',\n ),\n catalogFilter: z\n .array(entityQueryFilterExpressionSchema)\n .or(entityQueryFilterExpressionSchema)\n .optional()\n .describe('List of key-value filter expression for entities'),\n }),\n);\n\n/**\n * The input props that can be specified under `ui:options` for the\n * `OwnerPicker` field extension.\n *\n * @public\n */\nexport type OwnerPickerUiOptions = typeof OwnerPickerFieldSchema.uiOptionsType;\n\nexport type OwnerPickerProps = typeof OwnerPickerFieldSchema.type;\n\nexport const OwnerPickerSchema = OwnerPickerFieldSchema.schema;\n"],"names":[],"mappings":";;;;AAsBO,MAAM,sBAAyB,GAAA,sBAAA;AAAA,EACpC,EAAE,MAAO,EAAA;AAAA,EACT,EAAE,MAAO,CAAA;AAAA;AAAA;AAAA;AAAA,IAIP,YAAc,EAAA,CAAA,CACX,KAAM,CAAA,CAAA,CAAE,QAAQ,CAAA,CAChB,OAAQ,CAAA,CAAC,OAAS,EAAA,MAAM,CAAC,CAAA,CACzB,UACA,CAAA,QAAA;AAAA,MACC,uHAAA;AAAA,KACF;AAAA,IACF,sBAAsB,CACnB,CAAA,OAAA,GACA,QAAS,EAAA,CACT,SAAS,yDAAyD,CAAA;AAAA,IACrE,gBAAkB,EAAA,CAAA,CACf,KAAM,CAAA,CAAC,EAAE,MAAO,EAAA,EAAG,CAAE,CAAA,OAAA,CAAQ,KAAK,CAAC,CAAC,CAAA,CACpC,UACA,CAAA,QAAA;AAAA,MACC,0EAAA;AAAA,KACF;AAAA,IACF,aAAA,EAAe,CACZ,CAAA,KAAA,CAAM,iCAAiC,CAAA,CACvC,EAAG,CAAA,iCAAiC,CACpC,CAAA,QAAA,EACA,CAAA,QAAA,CAAS,kDAAkD,CAAA;AAAA,GAC/D,CAAA;AACH,EAAA;AAYO,MAAM,oBAAoB,sBAAuB,CAAA;;;;"}