@backstage/plugin-scaffolder 1.19.4-next.2 → 1.20.1-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 (84) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +1 -2
  3. package/alpha/package.json +1 -1
  4. package/dist/api.esm.js +9 -17
  5. package/dist/api.esm.js.map +1 -1
  6. package/dist/components/ActionsPage/ActionsPage.esm.js +10 -13
  7. package/dist/components/ActionsPage/ActionsPage.esm.js.map +1 -1
  8. package/dist/components/FileBrowser/FileBrowser.esm.js +1 -1
  9. package/dist/components/FileBrowser/FileBrowser.esm.js.map +1 -1
  10. package/dist/components/ListTasksPage/ListTasksPage.esm.js +9 -17
  11. package/dist/components/ListTasksPage/ListTasksPage.esm.js.map +1 -1
  12. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js +1 -2
  13. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js.map +1 -1
  14. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js +1 -1
  15. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js.map +1 -1
  16. package/dist/components/OngoingTask/ContextMenu.esm.js +1 -1
  17. package/dist/components/OngoingTask/ContextMenu.esm.js.map +1 -1
  18. package/dist/components/OngoingTask/OngoingTask.esm.js +10 -18
  19. package/dist/components/OngoingTask/OngoingTask.esm.js.map +1 -1
  20. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js +3 -3
  21. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js.map +1 -1
  22. package/dist/components/fields/EntityPicker/EntityPicker.esm.js +11 -13
  23. package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -1
  24. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +6 -7
  25. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -1
  26. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js +29 -41
  27. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js.map +1 -1
  28. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js +7 -11
  29. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js.map +1 -1
  30. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js +1 -1
  31. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js.map +1 -1
  32. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js +4 -5
  33. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js.map +1 -1
  34. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +16 -16
  35. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -1
  36. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +6 -6
  37. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -1
  38. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +2 -2
  39. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -1
  40. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +2 -2
  41. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -1
  42. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +2 -2
  43. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -1
  44. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +2 -2
  45. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -1
  46. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js +8 -25
  47. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js.map +1 -1
  48. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +6 -6
  49. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -1
  50. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +3 -3
  51. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -1
  52. package/dist/components/fields/RepoUrlPicker/validation.esm.js +2 -3
  53. package/dist/components/fields/RepoUrlPicker/validation.esm.js.map +1 -1
  54. package/dist/components/fields/SecretInput/SecretInput.esm.js +3 -5
  55. package/dist/components/fields/SecretInput/SecretInput.esm.js.map +1 -1
  56. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js +14 -18
  57. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -1
  58. package/dist/next/TemplateEditorPage/DirectoryEditorContext.esm.js +55 -91
  59. package/dist/next/TemplateEditorPage/DirectoryEditorContext.esm.js.map +1 -1
  60. package/dist/next/TemplateEditorPage/DryRunContext.esm.js +5 -9
  61. package/dist/next/TemplateEditorPage/DryRunContext.esm.js.map +1 -1
  62. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js +1 -2
  63. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js.map +1 -1
  64. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js +8 -12
  65. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js.map +1 -1
  66. package/dist/next/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js +2 -5
  67. package/dist/next/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js.map +1 -1
  68. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js +1 -2
  69. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js.map +1 -1
  70. package/dist/next/TemplateEditorPage/TemplateEditorForm.esm.js +4 -13
  71. package/dist/next/TemplateEditorPage/TemplateEditorForm.esm.js.map +1 -1
  72. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js +3 -12
  73. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js.map +1 -1
  74. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js +3 -3
  75. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js.map +1 -1
  76. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js +5 -15
  77. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js.map +1 -1
  78. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js +4 -7
  79. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js.map +1 -1
  80. package/dist/next/TemplateListPage/TemplateListPage.esm.js +5 -7
  81. package/dist/next/TemplateListPage/TemplateListPage.esm.js.map +1 -1
  82. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js +1 -2
  83. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -1
  84. package/package.json +17 -17
@@ -1 +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={{\n ...params.InputProps,\n required: formData.length === 0 && required,\n }}\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,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AI,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AACxB,MAAA,KAAA,CAAM,GAAG,CAAI,GAAA,KAAA,CAAA;AAAA,KACR,MAAA;AACL,MAAM,KAAA,CAAA,GAAG,CAAI,GAAA,gBAAA,CAAiB,KAAK,CAAA,CAAA;AAAA,KACrC;AAAA,GACF;AAEA,EAAO,OAAA,KAAA,CAAA;AACT,CAAA;AASA,SAAS,mBACP,QAC+B,EAAA;AAxPjC,EAAA,IAAA,EAAA,CAAA;AAyPE,EAAA,MAAM,aACJ,GAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,IAAwB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,aAAA,CAAA;AAE1B,EAAA,IAAI,CAAC,aAAe,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AAEA,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,aAAa,CAAG,EAAA;AAChC,IAAO,OAAA,aAAA,CAAc,IAAI,2BAA2B,CAAA,CAAA;AAAA,GACtD;AAEA,EAAA,OAAO,4BAA4B,aAAa,CAAA,CAAA;AAClD;;;;"}
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 entityPresentationApiRef,\n EntityDisplayName,\n EntityRefPresentationSnapshot,\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 const entityPresentationApi = useApi(entityPresentationApiRef);\n const { value: entities, loading } = useAsync(async () => {\n const { items } = await catalogApi.getEntities(\n catalogFilter ? { filter: catalogFilter } : undefined,\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 return { entities: items, entityRefToPresentation };\n });\n const allowArbitraryValues =\n uiSchema['ui:options']?.allowArbitraryValues ?? true;\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?.entities?.length === 1) {\n onChange([stringifyEntityRef(entities?.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?.entities?.length === 1}\n id={idSchema?.$id}\n loading={loading}\n onChange={onSelect}\n options={entities?.entities || []}\n renderOption={option => <EntityDisplayName entityRef={option} />}\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={{\n margin: 'dense',\n style: { marginLeft: 0 },\n }}\n variant=\"outlined\"\n required={required}\n InputProps={{\n ...params.InputProps,\n required: formData.length === 0 && required,\n }}\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":";;;;;;;;;;;AAoDa,MAAA,iBAAA,GAAoB,CAAC,KAAkC,KAAA;AAClE,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,MAAQ,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AAA;AACT,CAAA;AASA,SAAS,mBACP,QAC+B,EAAA;AAC/B,EAAM,MAAA,aAAA,GACJ,QAAS,CAAA,YAAY,CAAG,EAAA,aAAA,CAAA;AAE1B,EAAA,IAAI,CAAC,aAAe,EAAA;AAClB,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AAEA,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,aAAa,CAAG,EAAA;AAChC,IAAO,OAAA,aAAA,CAAc,IAAI,2BAA2B,CAAA,CAAA;AAAA,GACtD;AAEA,EAAA,OAAO,4BAA4B,aAAa,CAAA,CAAA;AAClD;;;;"}
@@ -33,26 +33,22 @@ const MyGroupsPicker = (props) => {
33
33
  ["relations.hasMember"]: [userEntityRef]
34
34
  }
35
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
- });
36
+ const groupValues = items.filter((e) => Boolean(e)).map((item) => ({
37
+ label: item.metadata.title ?? item.metadata.name,
38
+ ref: stringifyEntityRef(item)
39
+ }));
43
40
  setGroups(groupValues);
44
41
  });
45
42
  const updateChange = (_, value) => {
46
- var _a;
47
- onChange((_a = value == null ? void 0 : value.ref) != null ? _a : "");
43
+ onChange(value?.ref ?? "");
48
44
  };
49
- const selectedEntity = (groups == null ? void 0 : groups.find((e) => e.ref === formData)) || null;
45
+ const selectedEntity = groups?.find((e) => e.ref === formData) || null;
50
46
  return /* @__PURE__ */ React.createElement(
51
47
  FormControl,
52
48
  {
53
49
  margin: "normal",
54
50
  required,
55
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0
51
+ error: rawErrors?.length > 0
56
52
  },
57
53
  /* @__PURE__ */ React.createElement(
58
54
  Autocomplete,
@@ -1 +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 } }}\n variant=\"outlined\"\n required={required}\n />\n )}\n />\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAiCa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAA,EAAQ,EAAE,KAAA,EAAO,WAAY,EAAA;AAAA,IAC7B,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,CAAC,MAAQ,EAAA,SAAS,CAAI,GAAA,QAAA,CAK1B,EAAE,CAAA,CAAA;AAEJ,EAAA,QAAA,CAAS,YAAY;AACnB,IAAA,MAAM,EAAE,aAAA,EAAkB,GAAA,MAAM,YAAY,oBAAqB,EAAA,CAAA;AAEjE,IAAA,IAAI,CAAC,aAAe,EAAA;AAClB,MAAA,QAAA,CAAS,IAAK,CAAA,IAAI,aAAc,CAAA,0BAA0B,CAAC,CAAA,CAAA;AAC3D,MAAA,OAAA;AAAA,KACF;AAEA,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAM,WAAW,WAAY,CAAA;AAAA,MAC7C,MAAQ,EAAA;AAAA,QACN,IAAM,E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AAA,mCAAA;AAAA,QACH,OAAA,EAAS,UAAU,EAAC;AAAA,QACpB,KAAO,EAAA,cAAA;AAAA,QACP,QAAU,EAAA,YAAA;AAAA,QACV,cAAA,EAAgB,WAAS,KAAM,CAAA,KAAA;AAAA,QAC/B,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,WAAA;AAAA,SACF;AAAA,OAAA;AAAA,KAEJ;AAAA,GACF,CAAA;AAEJ;;;;"}
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 } }}\n variant=\"outlined\"\n required={required}\n />\n )}\n />\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAiCa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAA,EAAQ,EAAE,KAAA,EAAO,WAAY,EAAA;AAAA,IAC7B,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAA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AAA;AAAA,GAC3B,CAAA;AAEA,EAAA,MAAM,iBAAiB,MAAQ,EAAA,IAAA,CAAK,OAAK,CAAE,CAAA,GAAA,KAAQ,QAAQ,CAAK,IAAA,IAAA,CAAA;AAEhE,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAA;AAAA,MACA,KAAA,EAAO,WAAW,MAAS,GAAA,CAAA;AAAA,KAAA;AAAA,oBAE3B,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,mCAAA;AAAA,QACH,OAAA,EAAS,UAAU,EAAC;AAAA,QACpB,KAAO,EAAA,cAAA;AAAA,QACP,QAAU,EAAA,YAAA;AAAA,QACV,cAAA,EAAgB,WAAS,KAAM,CAAA,KAAA;AAAA,QAC/B,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,WAAA;AAAA,SACF;AAAA,OAAA;AAAA,KAEJ;AAAA,GACF,CAAA;AAEJ;;;;"}
@@ -46,7 +46,7 @@ const OwnedEntityPicker = (props) => {
46
46
  return /* @__PURE__ */ React.createElement(EntityPicker, { ...props, uiSchema: entityPickerUISchema });
47
47
  };
48
48
  function buildEntityPickerUISchema(uiSchema, identityRefs) {
49
- const uiOptions = (uiSchema == null ? void 0 : uiSchema["ui:options"]) || {};
49
+ const uiOptions = uiSchema?.["ui:options"] || {};
50
50
  const allowedKinds = uiOptions.allowedKinds;
51
51
  const catalogFilter = {
52
52
  ...uiOptions.catalogFilter,
@@ -1 +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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B,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;;;;"}
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,CAA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A,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;;;;"}
@@ -3,15 +3,14 @@ import { EntityPicker } from '../EntityPicker/EntityPicker.esm.js';
3
3
  export { OwnerPickerSchema } from './schema.esm.js';
4
4
 
5
5
  const OwnerPicker = (props) => {
6
- var _a, _b, _c, _d, _e;
7
6
  const {
8
7
  schema: { title = "Owner", description = "The owner of the component" },
9
8
  uiSchema,
10
9
  ...restProps
11
10
  } = 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) || {
11
+ const defaultNamespace = uiSchema["ui:options"]?.defaultNamespace;
12
+ const allowedKinds = uiSchema["ui:options"]?.allowedKinds;
13
+ const catalogFilter = uiSchema["ui:options"]?.catalogFilter || {
15
14
  kind: allowedKinds || ["Group", "User"]
16
15
  };
17
16
  const ownerUiSchema = {
@@ -19,7 +18,7 @@ const OwnerPicker = (props) => {
19
18
  "ui:options": {
20
19
  catalogFilter,
21
20
  defaultKind: "Group",
22
- allowArbitraryValues: (_e = (_d = uiSchema["ui:options"]) == null ? void 0 : _d.allowArbitraryValues) != null ? _e : true,
21
+ allowArbitraryValues: uiSchema["ui:options"]?.allowArbitraryValues ?? true,
23
22
  ...defaultNamespace !== void 0 ? { defaultNamespace } : {}
24
23
  }
25
24
  };
@@ -1 +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;;;;"}
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;AACtD,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,EAAM,MAAA,gBAAA,GAAmB,QAAS,CAAA,YAAY,CAAG,EAAA,gBAAA,CAAA;AACjD,EAAM,MAAA,YAAA,GAAe,QAAS,CAAA,YAAY,CAAG,EAAA,YAAA,CAAA;AAE7C,EAAA,MAAM,aAAgB,GAAA,QAAA,CAAS,YAAY,CAAA,EAAG,aAAiB,IAAA;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,oBACE,EAAA,QAAA,CAAS,YAAY,CAAA,EAAG,oBAAwB,IAAA,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;;;;"}
@@ -8,22 +8,22 @@ import { Select } from '@backstage/core-components';
8
8
  const AzureRepoPicker = (props) => {
9
9
  const {
10
10
  allowedOrganizations = [],
11
- allowedOwners = [],
11
+ allowedProject = [],
12
12
  rawErrors,
13
13
  state,
14
14
  onChange
15
15
  } = props;
16
16
  const organizationItems = allowedOrganizations ? allowedOrganizations.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
17
- const ownerItems = allowedOwners ? allowedOwners.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
18
- const { organization, owner } = state;
17
+ const projectItems = allowedProject ? allowedProject.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
18
+ const { organization, project } = state;
19
19
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
20
20
  FormControl,
21
21
  {
22
22
  margin: "normal",
23
23
  required: true,
24
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !organization
24
+ error: rawErrors?.length > 0 && !organization
25
25
  },
26
- (allowedOrganizations == null ? void 0 : allowedOrganizations.length) ? /* @__PURE__ */ React.createElement(
26
+ allowedOrganizations?.length ? /* @__PURE__ */ React.createElement(
27
27
  Select,
28
28
  {
29
29
  native: true,
@@ -47,24 +47,24 @@ const AzureRepoPicker = (props) => {
47
47
  {
48
48
  margin: "normal",
49
49
  required: true,
50
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !owner
50
+ error: rawErrors?.length > 0 && !project
51
51
  },
52
- (allowedOwners == null ? void 0 : allowedOwners.length) ? /* @__PURE__ */ React.createElement(
52
+ allowedProject?.length ? /* @__PURE__ */ React.createElement(
53
53
  Select,
54
54
  {
55
55
  native: true,
56
- label: "Owner",
57
- onChange: (s) => onChange({ owner: String(Array.isArray(s) ? s[0] : s) }),
58
- disabled: allowedOwners.length === 1,
59
- selected: owner,
60
- items: ownerItems
56
+ label: "Project",
57
+ onChange: (s) => onChange({ project: String(Array.isArray(s) ? s[0] : s) }),
58
+ disabled: allowedProject.length === 1,
59
+ selected: project,
60
+ items: projectItems
61
61
  }
62
- ) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(InputLabel, { htmlFor: "ownerInput" }, "Project"), /* @__PURE__ */ React.createElement(
62
+ ) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(InputLabel, { htmlFor: "projectInput" }, "Project"), /* @__PURE__ */ React.createElement(
63
63
  Input,
64
64
  {
65
- id: "ownerInput",
66
- onChange: (e) => onChange({ owner: e.target.value }),
67
- value: owner
65
+ id: "projectInput",
66
+ onChange: (e) => onChange({ project: e.target.value }),
67
+ value: project
68
68
  }
69
69
  )),
70
70
  /* @__PURE__ */ React.createElement(FormHelperText, null, "The Project that this repo will belong to")
@@ -1 +1 @@
1
- {"version":3,"file":"AzureRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/AzureRepoPicker.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 React from 'react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { RepoUrlPickerState } from './types';\nimport { Select, SelectItem } from '@backstage/core-components';\n\nexport const AzureRepoPicker = (props: {\n allowedOrganizations?: string[];\n allowedOwners?: string[];\n rawErrors: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n}) => {\n const {\n allowedOrganizations = [],\n allowedOwners = [],\n rawErrors,\n state,\n onChange,\n } = props;\n\n const organizationItems: SelectItem[] = allowedOrganizations\n ? allowedOrganizations.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { organization, owner } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !organization}\n >\n {allowedOrganizations?.length ? (\n <Select\n native\n label=\"Organization\"\n onChange={s =>\n onChange({ organization: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedOrganizations.length === 1}\n selected={organization}\n items={organizationItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"orgInput\">Organization</InputLabel>\n <Input\n id=\"orgInput\"\n onChange={e => onChange({ organization: e.target.value })}\n value={organization}\n />\n </>\n )}\n <FormHelperText>\n The Organization that this repo will belong to\n </FormHelperText>\n </FormControl>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !owner}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Owner\"\n onChange={s =>\n onChange({ owner: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedOwners.length === 1}\n selected={owner}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"ownerInput\">Project</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n </>\n )}\n <FormHelperText>\n The Project that this repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAwBa,MAAA,eAAA,GAAkB,CAAC,KAM1B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,uBAAuB,EAAC;AAAA,IACxB,gBAAgB,EAAC;AAAA,IACjB,SAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,oBAAkC,oBACpC,GAAA,oBAAA,CAAqB,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IACtD,CAAC,EAAE,OAAO,YAAc,EAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAE9C,EAAA,MAAM,aAA2B,aAC7B,GAAA,aAAA,CAAc,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IAC/C,CAAC,EAAE,OAAO,YAAc,EAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAE9C,EAAM,MAAA,EAAE,YAAc,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAEhC,EAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MAC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AA,KAAA,CAAA,GAAA,SAAA,CAAW,MAAS,IAAA,CAAA,IAAK,CAAC,KAAA;AAAA,KAAA;AAAA,IAAA,CAEhC,+CAAe,MACd,oBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,KAAM,EAAA,OAAA;AAAA,QACN,QAAU,EAAA,CAAA,CAAA,KACR,QAAS,CAAA,EAAE,OAAO,MAAO,CAAA,KAAA,CAAM,OAAQ,CAAA,CAAC,IAAI,CAAE,CAAA,CAAC,CAAI,GAAA,CAAC,GAAG,CAAA;AAAA,QAEzD,QAAA,EAAU,cAAc,MAAW,KAAA,CAAA;AAAA,QACnC,QAAU,EAAA,KAAA;AAAA,QACV,KAAO,EAAA,UAAA;AAAA,OAAA;AAAA,wBAIP,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,YAAA,EAAA,EAAa,SAAO,CACxC,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,YAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,OAAO,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACjD,KAAO,EAAA,KAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,2CAEhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"AzureRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/AzureRepoPicker.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 React from 'react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { RepoUrlPickerState } from './types';\nimport { Select, SelectItem } from '@backstage/core-components';\n\nexport const AzureRepoPicker = (props: {\n allowedOrganizations?: string[];\n allowedProject?: string[];\n rawErrors: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n}) => {\n const {\n allowedOrganizations = [],\n allowedProject = [],\n rawErrors,\n state,\n onChange,\n } = props;\n\n const organizationItems: SelectItem[] = allowedOrganizations\n ? allowedOrganizations.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const projectItems: SelectItem[] = allowedProject\n ? allowedProject.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { organization, project } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !organization}\n >\n {allowedOrganizations?.length ? (\n <Select\n native\n label=\"Organization\"\n onChange={s =>\n onChange({ organization: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedOrganizations.length === 1}\n selected={organization}\n items={organizationItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"orgInput\">Organization</InputLabel>\n <Input\n id=\"orgInput\"\n onChange={e => onChange({ organization: e.target.value })}\n value={organization}\n />\n </>\n )}\n <FormHelperText>\n The Organization that this repo will belong to\n </FormHelperText>\n </FormControl>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !project}\n >\n {allowedProject?.length ? (\n <Select\n native\n label=\"Project\"\n onChange={s =>\n onChange({ project: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedProject.length === 1}\n selected={project}\n items={projectItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"projectInput\">Project</InputLabel>\n <Input\n id=\"projectInput\"\n onChange={e => onChange({ project: e.target.value })}\n value={project}\n />\n </>\n )}\n <FormHelperText>\n The Project that this repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAwBa,MAAA,eAAA,GAAkB,CAAC,KAM1B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,uBAAuB,EAAC;AAAA,IACxB,iBAAiB,EAAC;AAAA,IAClB,SAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,oBAAkC,oBACpC,GAAA,oBAAA,CAAqB,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IACtD,CAAC,EAAE,OAAO,YAAc,EAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAE9C,EAAA,MAAM,eAA6B,cAC/B,GAAA,cAAA,CAAe,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IAChD,CAAC,EAAE,OAAO,YAAc,EAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAE9C,EAAM,MAAA,EAAE,YAAc,EAAA,OAAA,EAAY,GAAA,KAAA,CAAA;AAElC,EAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAQ,EAAA,IAAA;AAAA,MACR,KAAO,EAAA,SAAA,EAAW,MAAS,GAAA,CAAA,IAAK,CAAC,YAAA;AAAA,KAAA;AAAA,IAEhC,sBAAsB,MACrB,mBAAA,KAAA,CAAA,aAAA;AAAA,MA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KAAA,CAAM,OAAQ,CAAA,CAAC,IAAI,CAAE,CAAA,CAAC,CAAI,GAAA,CAAC,GAAG,CAAA;AAAA,QAE3D,QAAA,EAAU,eAAe,MAAW,KAAA,CAAA;AAAA,QACpC,QAAU,EAAA,OAAA;AAAA,QACV,KAAO,EAAA,YAAA;AAAA,OAAA;AAAA,wBAIP,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,cAAA,EAAA,EAAe,SAAO,CAC1C,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,cAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,SAAS,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACnD,KAAO,EAAA,OAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,2CAEhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
@@ -14,8 +14,8 @@ const BitbucketRepoPicker = (props) => {
14
14
  state
15
15
  } = props;
16
16
  const { host, workspace, project } = state;
17
- const ownerItems = allowedOwners ? allowedOwners == null ? void 0 : allowedOwners.map((i) => ({ label: i, value: i })) : [];
18
- const projectItems = allowedProjects ? allowedProjects == null ? void 0 : allowedProjects.map((i) => ({ label: i, value: i })) : [];
17
+ const ownerItems = allowedOwners ? allowedOwners?.map((i) => ({ label: i, value: i })) : [];
18
+ const projectItems = allowedProjects ? allowedProjects?.map((i) => ({ label: i, value: i })) : [];
19
19
  useEffect(() => {
20
20
  if (host === "bitbucket.org" && allowedOwners.length) {
21
21
  onChange({ workspace: allowedOwners[0] });
@@ -26,9 +26,9 @@ const BitbucketRepoPicker = (props) => {
26
26
  {
27
27
  margin: "normal",
28
28
  required: true,
29
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !workspace
29
+ error: rawErrors?.length > 0 && !workspace
30
30
  },
31
- (allowedOwners == null ? void 0 : allowedOwners.length) ? /* @__PURE__ */ React.createElement(
31
+ allowedOwners?.length ? /* @__PURE__ */ React.createElement(
32
32
  Select,
33
33
  {
34
34
  native: true,
@@ -52,9 +52,9 @@ const BitbucketRepoPicker = (props) => {
52
52
  {
53
53
  margin: "normal",
54
54
  required: true,
55
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !project
55
+ error: rawErrors?.length > 0 && !project
56
56
  },
57
- (allowedProjects == null ? void 0 : allowedProjects.length) ? /* @__PURE__ */ React.createElement(
57
+ allowedProjects?.length ? /* @__PURE__ */ React.createElement(
58
58
  Select,
59
59
  {
60
60
  native: true,
@@ -1 +1 @@
1
- {"version":3,"file":"BitbucketRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/BitbucketRepoPicker.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, { useEffect } from 'react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\n/**\n * The underlying component that is rendered in the form for the `BitbucketRepoPicker`\n * field extension.\n *\n * @public\n * @param allowedOwners - Allowed workspaces for the Bitbucket cloud repository\n * @param allowedProjects - Allowed projects for the Bitbucket cloud repository\n *\n */\nexport const BitbucketRepoPicker = (props: {\n allowedOwners?: string[];\n allowedProjects?: string[];\n onChange: (state: RepoUrlPickerState) => void;\n state: RepoUrlPickerState;\n rawErrors: string[];\n}) => {\n const {\n allowedOwners = [],\n allowedProjects = [],\n onChange,\n rawErrors,\n state,\n } = props;\n const { host, workspace, project } = state;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners?.map(i => ({ label: i, value: i }))\n : [];\n const projectItems: SelectItem[] = allowedProjects\n ? allowedProjects?.map(i => ({ label: i, value: i }))\n : [];\n\n useEffect(() => {\n if (host === 'bitbucket.org' && allowedOwners.length) {\n onChange({ workspace: allowedOwners[0] });\n }\n }, [allowedOwners, host, onChange]);\n\n return (\n <>\n {host === 'bitbucket.org' && (\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !workspace}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Allowed Workspaces\"\n onChange={s =>\n onChange({ workspace: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedOwners.length === 1}\n selected={workspace}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"workspaceInput\">Workspace</InputLabel>\n <Input\n id=\"workspaceInput\"\n onChange={e => onChange({ workspace: e.target.value })}\n value={workspace}\n />\n </>\n )}\n <FormHelperText>\n The Workspace that this repo will belong to\n </FormHelperText>\n </FormControl>\n )}\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !project}\n >\n {allowedProjects?.length ? (\n <Select\n native\n label=\"Allowed Projects\"\n onChange={s =>\n onChange({ project: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedProjects.length === 1}\n selected={project}\n items={projectItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"projectInput\">Project</InputLabel>\n <Input\n id=\"projectInput\"\n onChange={e => onChange({ project: e.target.value })}\n value={project}\n />\n </>\n )}\n <FormHelperText>\n The Project that this repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAgCa,MAAA,mBAAA,GA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;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,KAAM,EAAA,kBAAA;AAAA,QACN,QAAU,EAAA,CAAA,CAAA,KACR,QAAS,CAAA,EAAE,SAAS,MAAO,CAAA,KAAA,CAAM,OAAQ,CAAA,CAAC,IAAI,CAAE,CAAA,CAAC,CAAI,GAAA,CAAC,GAAG,CAAA;AAAA,QAE3D,QAAA,EAAU,gBAAgB,MAAW,KAAA,CAAA;AAAA,QACrC,QAAU,EAAA,OAAA;AAAA,QACV,KAAO,EAAA,YAAA;AAAA,OAAA;AAAA,wBAIP,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,cAAA,EAAA,EAAe,SAAO,CAC1C,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,cAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,SAAS,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACnD,KAAO,EAAA,OAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,2CAEhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"BitbucketRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/BitbucketRepoPicker.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, { useEffect } from 'react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\n/**\n * The underlying component that is rendered in the form for the `BitbucketRepoPicker`\n * field extension.\n *\n * @public\n * @param allowedOwners - Allowed workspaces for the Bitbucket cloud repository\n * @param allowedProjects - Allowed projects for the Bitbucket cloud repository\n *\n */\nexport const BitbucketRepoPicker = (props: {\n allowedOwners?: string[];\n allowedProjects?: string[];\n onChange: (state: RepoUrlPickerState) => void;\n state: RepoUrlPickerState;\n rawErrors: string[];\n}) => {\n const {\n allowedOwners = [],\n allowedProjects = [],\n onChange,\n rawErrors,\n state,\n } = props;\n const { host, workspace, project } = state;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners?.map(i => ({ label: i, value: i }))\n : [];\n const projectItems: SelectItem[] = allowedProjects\n ? allowedProjects?.map(i => ({ label: i, value: i }))\n : [];\n\n useEffect(() => {\n if (host === 'bitbucket.org' && allowedOwners.length) {\n onChange({ workspace: allowedOwners[0] });\n }\n }, [allowedOwners, host, onChange]);\n\n return (\n <>\n {host === 'bitbucket.org' && (\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !workspace}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Allowed Workspaces\"\n onChange={s =>\n onChange({ workspace: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedOwners.length === 1}\n selected={workspace}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"workspaceInput\">Workspace</InputLabel>\n <Input\n id=\"workspaceInput\"\n onChange={e => onChange({ workspace: e.target.value })}\n value={workspace}\n />\n </>\n )}\n <FormHelperText>\n The Workspace that this repo will belong to\n </FormHelperText>\n </FormControl>\n )}\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !project}\n >\n {allowedProjects?.length ? (\n <Select\n native\n label=\"Allowed Projects\"\n onChange={s =>\n onChange({ project: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedProjects.length === 1}\n selected={project}\n items={projectItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"projectInput\">Project</InputLabel>\n <Input\n id=\"projectInput\"\n onChange={e => onChange({ project: e.target.value })}\n value={project}\n />\n </>\n )}\n <FormHelperText>\n The Project that this repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAgCa,MAAA,mBAAA,GAAsB,CAAC,KAM9B,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,gBAAgB,EAAC;AAAA,IACjB,kBAAkB,EAAC;AAAA,IACnB,QAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,EAAE,IAAA,EAAM,SAAW,EAAA,OAAA,EAAY,GAAA,KAAA,CAAA;AACrC,EAAA,MAAM,UAA2B,GAAA,aAAA,GAC7B,aAAe,EAAA,GAAA,CAAI,CAAM,CAAA,MAAA,EAAE,KAAO,EAAA,CAAA,EAAG,KAAO,EAAA,CAAA,EAAI,CAAA,CAAA,GAChD,EAAC,CAAA;AACL,EAAA,MAAM,YAA6B,GAAA,eAAA,GAC/B,eAAiB,EAAA,GAAA,CAAI,CAAM,CAAA,MAAA,EAAE,KAAO,EAAA,CAAA,EAAG,KAAO,EAAA,CAAA,EAAI,CAAA,CAAA,GAClD,EAAC,CAAA;AAEL,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,IAAA,KAAS,eAAmB,IAAA,aAAA,CAAc,MAAQ,EAAA;AACpD,MAAA,QAAA,CAAS,EAAE,SAAA,EAAW,aAAc,CAAA,CAAC,GAAG,CAAA,CAAA;AAAA,KAC1C;AAAA,GACC,EAAA,CAAC,aAAe,EAAA,IAAA,EAAM,QAAQ,CAAC,CAA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,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAQ,EAAA,IAAA;AAAA,MACR,KAAO,EAAA,SAAA,EAAW,MAAS,GAAA,CAAA,IAAK,CAAC,OAAA;AAAA,KAAA;AAAA,IAEhC,iBAAiB,MAChB,mBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,KAAM,EAAA,kBAAA;AAAA,QACN,QAAU,EAAA,CAAA,CAAA,KACR,QAAS,CAAA,EAAE,SAAS,MAAO,CAAA,KAAA,CAAM,OAAQ,CAAA,CAAC,IAAI,CAAE,CAAA,CAAC,CAAI,GAAA,CAAC,GAAG,CAAA;AAAA,QAE3D,QAAA,EAAU,gBAAgB,MAAW,KAAA,CAAA;AAAA,QACrC,QAAU,EAAA,OAAA;AAAA,QACV,KAAO,EAAA,YAAA;AAAA,OAAA;AAAA,wBAIP,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,cAAA,EAAA,EAAe,SAAO,CAC1C,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,cAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,SAAS,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACnD,KAAO,EAAA,OAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,2CAEhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
@@ -7,7 +7,7 @@ import InputLabel from '@material-ui/core/InputLabel';
7
7
  const GerritRepoPicker = (props) => {
8
8
  const { onChange, rawErrors, state } = props;
9
9
  const { workspace, owner } = state;
10
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(FormControl, { margin: "normal", error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !workspace }, /* @__PURE__ */ React.createElement(InputLabel, { htmlFor: "ownerInput" }, "Owner"), /* @__PURE__ */ React.createElement(
10
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(FormControl, { margin: "normal", error: rawErrors?.length > 0 && !workspace }, /* @__PURE__ */ React.createElement(InputLabel, { htmlFor: "ownerInput" }, "Owner"), /* @__PURE__ */ React.createElement(
11
11
  Input,
12
12
  {
13
13
  id: "ownerInput",
@@ -19,7 +19,7 @@ const GerritRepoPicker = (props) => {
19
19
  {
20
20
  margin: "normal",
21
21
  required: true,
22
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !workspace
22
+ error: rawErrors?.length > 0 && !workspace
23
23
  },
24
24
  /* @__PURE__ */ React.createElement(InputLabel, { htmlFor: "parentInput" }, "Parent"),
25
25
  /* @__PURE__ */ React.createElement(
@@ -1 +1 @@
1
- {"version":3,"file":"GerritRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GerritRepoPicker.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 from 'react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { RepoUrlPickerState } from './types';\n\nexport const GerritRepoPicker = (props: {\n onChange: (state: RepoUrlPickerState) => void;\n state: RepoUrlPickerState;\n rawErrors: string[];\n}) => {\n const { onChange, rawErrors, state } = props;\n const { workspace, owner } = state;\n return (\n <>\n <FormControl margin=\"normal\" error={rawErrors?.length > 0 && !workspace}>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n <FormHelperText>The owner of the project (optional)</FormHelperText>\n </FormControl>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !workspace}\n >\n <InputLabel htmlFor=\"parentInput\">Parent</InputLabel>\n <Input\n id=\"parentInput\"\n onChange={e => onChange({ workspace: e.target.value })}\n value={workspace}\n />\n <FormHelperText>\n The project parent that the repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsBa,MAAA,gBAAA,GAAmB,CAAC,KAI3B,KAAA;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,SAAW,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AACvC,EAAM,MAAA,EAAE,SAAW,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAC7B,EAAA,iFAEK,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAY,MAAO,EAAA,QAAA,EAAS,QAAO,SAAW,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,SAAA,CAAA,MAAA,IAAS,CAAK,IAAA,CAAC,6BAC3D,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,YAAA,EAAA,EAAa,OAAK,CACtC,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,EAAG,EAAA,YAAA;AAAA,MACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,OAAO,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,MACjD,KAAO,EAAA,KAAA;AAAA,KAAA;AAAA,GAET,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,IAAA,EAAA,qCAAmC,CACrD,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAQ,EAAA,IAAA;AAAA,MACR,KAAO,EAAA,CAAA,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,SAAA,CAAW,MAAS,IAAA,CAAA,IAAK,CAAC,SAAA;AAAA,KAAA;AAAA,oBAEhC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,aAAA,EAAA,EAAc,QAAM,CAAA;AAAA,oBACxC,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,aAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,WAAW,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACrD,KAAO,EAAA,SAAA;AAAA,OAAA;AAAA,KACT;AAAA,oBACA,KAAA,CAAA,aAAA,CAAC,sBAAe,iDAEhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"GerritRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GerritRepoPicker.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 from 'react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { RepoUrlPickerState } from './types';\n\nexport const GerritRepoPicker = (props: {\n onChange: (state: RepoUrlPickerState) => void;\n state: RepoUrlPickerState;\n rawErrors: string[];\n}) => {\n const { onChange, rawErrors, state } = props;\n const { workspace, owner } = state;\n return (\n <>\n <FormControl margin=\"normal\" error={rawErrors?.length > 0 && !workspace}>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n <FormHelperText>The owner of the project (optional)</FormHelperText>\n </FormControl>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !workspace}\n >\n <InputLabel htmlFor=\"parentInput\">Parent</InputLabel>\n <Input\n id=\"parentInput\"\n onChange={e => onChange({ workspace: e.target.value })}\n value={workspace}\n />\n <FormHelperText>\n The project parent that the repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsBa,MAAA,gBAAA,GAAmB,CAAC,KAI3B,KAAA;AACJ,EAAA,MAAM,EAAE,QAAA,EAAU,SAAW,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AACvC,EAAM,MAAA,EAAE,SAAW,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAC7B,EAAA,iFAEK,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAY,MAAO,EAAA,QAAA,EAAS,OAAO,SAAW,EAAA,MAAA,GAAS,CAAK,IAAA,CAAC,6BAC3D,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,YAAA,EAAA,EAAa,OAAK,CACtC,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,EAAG,EAAA,YAAA;AAAA,MACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,OAAO,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,MACjD,KAAO,EAAA,KAAA;AAAA,KAAA;AAAA,GAET,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,IAAA,EAAA,qCAAmC,CACrD,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAQ,EAAA,IAAA;AAAA,MACR,KAAO,EAAA,SAAA,EAAW,MAAS,GAAA,CAAA,IAAK,CAAC,SAAA;AAAA,KAAA;AAAA,oBAEhC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,aAAA,EAAA,EAAc,QAAM,CAAA;AAAA,oBACxC,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,aAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,WAAW,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACrD,KAAO,EAAA,SAAA;AAAA,OAAA;AAAA,KACT;AAAA,oBACA,KAAA,CAAA,aAAA,CAAC,sBAAe,iDAEhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
@@ -14,9 +14,9 @@ const GiteaRepoPicker = (props) => {
14
14
  {
15
15
  margin: "normal",
16
16
  required: true,
17
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !owner
17
+ error: rawErrors?.length > 0 && !owner
18
18
  },
19
- (allowedOwners == null ? void 0 : allowedOwners.length) ? /* @__PURE__ */ React.createElement(
19
+ allowedOwners?.length ? /* @__PURE__ */ React.createElement(
20
20
  Select,
21
21
  {
22
22
  native: true,
@@ -1 +1 @@
1
- {"version":3,"file":"GiteaRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GiteaRepoPicker.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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\nexport const GiteaRepoPicker = (props: {\n allowedOwners?: string[];\n allowedRepos?: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n rawErrors: string[];\n}) => {\n const { allowedOwners = [], state, onChange, rawErrors } = props;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { owner } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !owner}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Owner Available\"\n onChange={selected =>\n onChange({\n owner: String(Array.isArray(selected) ? selected[0] : selected),\n })\n }\n disabled={allowedOwners.length === 1}\n selected={owner}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n </>\n )}\n <FormHelperText>\n Gitea namespace where this repository will belong to. It can be the\n name of organization, group, subgroup, user, or the project.\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuBa,MAAA,eAAA,GAAkB,CAAC,KAM1B,KAAA;AACJ,EAAA,MAAM,EAAE,aAAgB,GAAA,IAAI,KAAO,EAAA,QAAA,EAAU,WAAc,GAAA,KAAA,CAAA;AAC3D,EAAA,MAAM,aAA2B,aAC7B,GAAA,aAAA,CAAc,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAA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AA;AAAA,QACjD,KAAO,EAAA,KAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,kIAGhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"GiteaRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GiteaRepoPicker.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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\nexport const GiteaRepoPicker = (props: {\n allowedOwners?: string[];\n allowedRepos?: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n rawErrors: string[];\n}) => {\n const { allowedOwners = [], state, onChange, rawErrors } = props;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { owner } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !owner}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Owner Available\"\n onChange={selected =>\n onChange({\n owner: String(Array.isArray(selected) ? selected[0] : selected),\n })\n }\n disabled={allowedOwners.length === 1}\n selected={owner}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n </>\n )}\n <FormHelperText>\n Gitea namespace where this repository will belong to. It can be the\n name of organization, group, subgroup, user, or the project.\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuBa,MAAA,eAAA,GAAkB,CAAC,KAM1B,KAAA;AACJ,EAAA,MAAM,EAAE,aAAgB,GAAA,IAAI,KAAO,EAAA,QAAA,EAAU,WAAc,GAAA,KAAA,CAAA;AAC3D,EAAA,MAAM,aAA2B,aAC7B,GAAA,aAAA,CAAc,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IAC/C,CAAC,EAAE,OAAO,YAAc,EAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAE9C,EAAM,MAAA,EAAE,OAAU,GAAA,KAAA,CAAA;AAElB,EAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAQ,EAAA,IAAA;AAAA,MACR,KAAO,EAAA,SAAA,EAAW,MAAS,GAAA,CAAA,IAAK,CAAC,KAAA;AAAA,KAAA;AAAA,IAEhC,eAAe,MACd,mBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,KAAM,EAAA,iBAAA;AAAA,QACN,QAAA,EAAU,cACR,QAAS,CAAA;AAAA,UACP,KAAA,EAAO,OAAO,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAI,GAAA,QAAA,CAAS,CAAC,CAAA,GAAI,QAAQ,CAAA;AAAA,SAC/D,CAAA;AAAA,QAEH,QAAA,EAAU,cAAc,MAAW,KAAA,CAAA;AAAA,QACnC,QAAU,EAAA,KAAA;AAAA,QACV,KAAO,EAAA,UAAA;AAAA,OAAA;AAAA,wBAIP,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,YAAA,EAAA,EAAa,OAAK,CACtC,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,YAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,OAAO,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACjD,KAAO,EAAA,KAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,kIAGhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
@@ -14,9 +14,9 @@ const GithubRepoPicker = (props) => {
14
14
  {
15
15
  margin: "normal",
16
16
  required: true,
17
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !owner
17
+ error: rawErrors?.length > 0 && !owner
18
18
  },
19
- (allowedOwners == null ? void 0 : allowedOwners.length) ? /* @__PURE__ */ React.createElement(
19
+ allowedOwners?.length ? /* @__PURE__ */ React.createElement(
20
20
  Select,
21
21
  {
22
22
  native: true,
@@ -1 +1 @@
1
- {"version":3,"file":"GithubRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GithubRepoPicker.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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\nexport const GithubRepoPicker = (props: {\n allowedOwners?: string[];\n rawErrors: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n}) => {\n const { allowedOwners = [], rawErrors, state, onChange } = props;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { owner } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !owner}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Owner Available\"\n onChange={s =>\n onChange({ owner: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedOwners.length === 1}\n selected={owner}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n </>\n )}\n <FormHelperText>\n The organization, user or project that this repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuBa,MAAA,gBAAA,GAAmB,CAAC,KAK3B,KAAA;AACJ,EAAA,MAAM,EAAE,aAAgB,GAAA,IAAI,SAAW,EAAA,KAAA,EAAO,UAAa,GAAA,KAAA,CAAA;AAC3D,EAAA,MAAM,aAA2B,aAC7B,GAAA,aAAA,CAAc,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IAC/C,CAAC,EAAE,OAAO,YAAc,EAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAE9C,EAAM,MAAA,EAAE,OAAU,GAAA,KAAA,CAAA;AAElB,EAA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"GithubRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GithubRepoPicker.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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\nexport const GithubRepoPicker = (props: {\n allowedOwners?: string[];\n rawErrors: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n}) => {\n const { allowedOwners = [], rawErrors, state, onChange } = props;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { owner } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !owner}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Owner Available\"\n onChange={s =>\n onChange({ owner: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={allowedOwners.length === 1}\n selected={owner}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n </>\n )}\n <FormHelperText>\n The organization, user or project that this repo will belong to\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuBa,MAAA,gBAAA,GAA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AAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,YAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,OAAO,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACjD,KAAO,EAAA,KAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,iEAEhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
@@ -14,9 +14,9 @@ const GitlabRepoPicker = (props) => {
14
14
  {
15
15
  margin: "normal",
16
16
  required: true,
17
- error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !owner
17
+ error: rawErrors?.length > 0 && !owner
18
18
  },
19
- (allowedOwners == null ? void 0 : allowedOwners.length) ? /* @__PURE__ */ React.createElement(
19
+ allowedOwners?.length ? /* @__PURE__ */ React.createElement(
20
20
  Select,
21
21
  {
22
22
  native: true,
@@ -1 +1 @@
1
- {"version":3,"file":"GitlabRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GitlabRepoPicker.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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\nexport const GitlabRepoPicker = (props: {\n allowedOwners?: string[];\n allowedRepos?: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n rawErrors: string[];\n}) => {\n const { allowedOwners = [], state, onChange, rawErrors } = props;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { owner } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !owner}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Owner Available\"\n onChange={selected =>\n onChange({\n owner: String(Array.isArray(selected) ? selected[0] : selected),\n })\n }\n disabled={allowedOwners.length === 1}\n selected={owner}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n </>\n )}\n <FormHelperText>\n GitLab namespace where this repository will belong to. It can be the\n name of organization, group, subgroup, user, or the project.\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuBa,MAAA,gBAAA,GAAmB,CAAC,KAM3B,KAAA;AACJ,EAAA,MAAM,EAAE,aAAgB,GAAA,IAAI,KAAO,EAAA,QAAA,EAAU,WAAc,GAAA,KAAA,CAAA;AAC3D,EAAA,MAAM,aAA2B,aAC7B,GAAA,aAAA,CAAc,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IAC/C,CAAC,EAAE,OAAO,YAAc,EAAA,KAAA,EAAO,WAAW,CAAA,CAAA;AAE9C,EAAM,MAAA,EAAE,OAAU,GAAA,KAAA,CAAA;AAElB,EAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAQ,EAAA,IAAA;AAAA,MACR,KAAO,EAAA,CAAA,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,SAAA,CAAW,MAAS,IAAA,CAAA,IAAK,CAAC,KAAA;AAAA,KAAA;AAAA,IAAA,CAEhC,+CAAe,MACd,oBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,KAAM,EAAA,iBAAA;AAAA,QACN,QAAA,EAAU,cACR,QAAS,CAAA;AAAA,UACP,KAAA,EAAO,OAAO,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAI,GAAA,QAAA,CAAS,CAAC,CAAA,GAAI,QAAQ,CAAA;AAAA,SAC/D,CAAA;AAAA,QAEH,QAAA,EAAU,cAAc,MAAW,KAAA,CAAA;AAAA,QACnC,QAAU,EAAA,KAAA;AAAA,QACV,KAAO,EAAA,UAAA;AAAA,OAAA;AAAA,wBAIP,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,YAAA,EAAA,EAAa,OAAK,CACtC,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,YAAA;AAAA,QACH,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,OAAO,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACjD,KAAO,EAAA,KAAA;AAAA,OAAA;AAAA,KAEX,CAAA;AAAA,oBAEF,KAAA,CAAA,aAAA,CAAC,sBAAe,mIAGhB,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"GitlabRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/GitlabRepoPicker.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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Input from '@material-ui/core/Input';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { RepoUrlPickerState } from './types';\n\nexport const GitlabRepoPicker = (props: {\n allowedOwners?: string[];\n allowedRepos?: string[];\n state: RepoUrlPickerState;\n onChange: (state: RepoUrlPickerState) => void;\n rawErrors: string[];\n}) => {\n const { allowedOwners = [], state, onChange, rawErrors } = props;\n const ownerItems: SelectItem[] = allowedOwners\n ? allowedOwners.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { owner } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !owner}\n >\n {allowedOwners?.length ? (\n <Select\n native\n label=\"Owner Available\"\n onChange={selected =>\n onChange({\n owner: String(Array.isArray(selected) ? selected[0] : selected),\n })\n }\n disabled={allowedOwners.length === 1}\n selected={owner}\n items={ownerItems}\n />\n ) : (\n <>\n <InputLabel htmlFor=\"ownerInput\">Owner</InputLabel>\n <Input\n id=\"ownerInput\"\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n </>\n )}\n <FormHelperText>\n GitLab namespace where this repository will belong to. It can be the\n name of organization, group, subgroup, user, or the project.\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAuBa,MAAA,gBAAA,GAAmB,CAAC,KAM3B,KAAA;AACJ,EAAA,MAAM,EAAE,aAAgB,GAAA,IAAI,KAAO,EAAA,QAAA,EAAU,WAAc,GAAA,KAAA,CAAA;AAC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