@backstage/plugin-scaffolder 1.24.0-next.3 → 1.25.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +169 -2
- package/dist/alpha.esm.js +32 -25
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/ActionsPage/ActionsPage.esm.js +14 -10
- package/dist/components/ActionsPage/ActionsPage.esm.js.map +1 -1
- package/dist/components/ListTasksPage/ListTasksPage.esm.js +15 -11
- package/dist/components/ListTasksPage/ListTasksPage.esm.js.map +1 -1
- package/dist/components/ListTasksPage/OwnerListPicker.esm.js +8 -5
- package/dist/components/ListTasksPage/OwnerListPicker.esm.js.map +1 -1
- package/dist/components/OngoingTask/ContextMenu.esm.js +12 -4
- package/dist/components/OngoingTask/ContextMenu.esm.js.map +1 -1
- package/dist/components/OngoingTask/OngoingTask.esm.js +10 -7
- package/dist/components/OngoingTask/OngoingTask.esm.js.map +1 -1
- package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js +4 -1
- package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js.map +1 -1
- package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js +7 -1
- package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js.map +1 -1
- package/dist/components/fields/EntityPicker/EntityPicker.esm.js +7 -1
- package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -1
- package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +5 -2
- package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -1
- package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js +7 -1
- package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js.map +1 -1
- package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js +7 -1
- package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js.map +1 -1
- package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js +7 -1
- package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js +3 -4
- package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +19 -15
- package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +23 -6
- package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +14 -11
- package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +14 -9
- package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +11 -8
- package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +14 -9
- package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +5 -2
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +13 -3
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js +20 -5
- package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js +4 -1
- package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js +17 -3
- package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js +22 -1
- package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js +6 -1
- package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js +36 -13
- package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js +13 -6
- package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js +5 -2
- package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js +30 -11
- package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js.map +1 -1
- package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js +5 -2
- package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js.map +1 -1
- package/dist/next/TemplateListPage/TemplateListPage.esm.js +25 -17
- package/dist/next/TemplateListPage/TemplateListPage.esm.js.map +1 -1
- package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js +6 -3
- package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -1
- package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js +11 -1
- package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js.map +1 -1
- package/dist/translation.esm.js +258 -0
- package/dist/translation.esm.js.map +1 -0
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityPicker.esm.js","sources":["../../../../src/components/fields/EntityPicker/EntityPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n type EntityFilterQuery,\n CATALOG_FILTER_EXISTS,\n} from '@backstage/catalog-client';\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefPresentationSnapshot,\n catalogApiRef,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport Autocomplete, {\n AutocompleteChangeReason,\n createFilterOptions,\n} from '@material-ui/lab/Autocomplete';\nimport React, { useCallback, useEffect } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n EntityPickerFilterQueryValue,\n EntityPickerProps,\n EntityPickerUiOptions,\n EntityPickerFilterQuery,\n} from './schema';\nimport { VirtualizedListbox } from '../VirtualizedListbox';\n\nexport { EntityPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityPicker = (props: EntityPickerProps) => {\n const {\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\n const { value: entities, loading } = useAsync(async () => {\n const fields = [\n 'metadata.name',\n 'metadata.namespace',\n 'metadata.title',\n 'kind',\n ];\n const { items } = await catalogApi.getEntities(\n catalogFilter\n ? { filter: catalogFilter, fields }\n : { filter: undefined, fields },\n );\n\n const entityRefToPresentation = new Map<\n string,\n EntityRefPresentationSnapshot\n >(\n await Promise.all(\n items.map(async item => {\n const presentation = await entityPresentationApi.forEntity(item)\n .promise;\n return [stringifyEntityRef(item), presentation] as [\n string,\n EntityRefPresentationSnapshot,\n ];\n }),\n ),\n );\n\n return { catalogEntities: items, entityRefToPresentation };\n });\n\n const allowArbitraryValues =\n uiSchema['ui:options']?.allowArbitraryValues ?? true;\n\n const getLabel = useCallback(\n (freeSoloValue: string) => {\n try {\n // Will throw if defaultKind or defaultNamespace are not set\n const parsedRef = parseEntityRef(freeSoloValue, {\n defaultKind,\n defaultNamespace,\n });\n\n return stringifyEntityRef(parsedRef);\n } catch (err) {\n return freeSoloValue;\n }\n },\n [defaultKind, defaultNamespace],\n );\n\n const onSelect = useCallback(\n (_: any, ref: string | Entity | null, reason: AutocompleteChangeReason) => {\n // ref can either be a string from free solo entry or\n if (typeof ref !== 'string') {\n // if ref does not exist: pass 'undefined' to trigger validation for required value\n onChange(ref ? stringifyEntityRef(ref as Entity) : undefined);\n } else {\n if (reason === 'blur' || reason === 'create-option') {\n // Add in default namespace, etc.\n let entityRef = ref;\n try {\n // Attempt to parse the entity ref into it's full form.\n entityRef = stringifyEntityRef(\n parseEntityRef(ref as string, {\n defaultKind,\n defaultNamespace,\n }),\n );\n } catch (err) {\n // If the passed in value isn't an entity ref, do nothing.\n }\n // We need to check against formData here as that's the previous value for this field.\n if (formData !== ref || allowArbitraryValues) {\n onChange(entityRef);\n }\n }\n }\n },\n [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues],\n );\n\n // Since free solo can be enabled, attempt to parse as a full entity ref first, then fall\n // back to the given value.\n const selectedEntity =\n entities?.catalogEntities.find(e => stringifyEntityRef(e) === formData) ??\n (allowArbitraryValues && formData ? getLabel(formData) : '');\n\n useEffect(() => {\n if (entities?.catalogEntities.length === 1 && selectedEntity === '') {\n onChange(stringifyEntityRef(entities.catalogEntities[0]));\n }\n }, [entities, onChange, selectedEntity]);\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !formData}\n >\n <Autocomplete\n disabled={entities?.catalogEntities.length === 1}\n id={idSchema?.$id}\n value={selectedEntity}\n loading={loading}\n onChange={onSelect}\n options={entities?.catalogEntities || []}\n getOptionLabel={option =>\n // option can be a string due to freeSolo.\n typeof option === 'string'\n ? option\n : entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.entityRef!\n }\n autoSelect\n freeSolo={allowArbitraryValues}\n renderInput={params => (\n <TextField\n {...params}\n label={title}\n margin=\"dense\"\n helperText={description}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }}\n variant=\"outlined\"\n required={required}\n InputProps={params.InputProps}\n />\n )}\n renderOption={option => <EntityDisplayName entityRef={option} />}\n filterOptions={createFilterOptions<Entity>({\n stringify: option =>\n entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.primaryTitle!,\n })}\n ListboxComponent={VirtualizedListbox}\n />\n </FormControl>\n );\n};\n\n/**\n * Converts a especial `{exists: true}` value to the `CATALOG_FILTER_EXISTS` symbol.\n *\n * @param value - The value to convert.\n * @returns The converted value.\n */\nfunction convertOpsValues(\n value: Exclude<EntityPickerFilterQueryValue, Array<any>>,\n): string | symbol {\n if (typeof value === 'object' && value.exists) {\n return CATALOG_FILTER_EXISTS;\n }\n return value?.toString();\n}\n\n/**\n * Converts schema filters to entity filter query, replacing `{exists:true}` values\n * with the constant `CATALOG_FILTER_EXISTS`.\n *\n * @param schemaFilters - An object containing schema filters with keys as filter names\n * and values as filter values.\n * @returns An object with the same keys as the input object, but with `{exists:true}` values\n * transformed to `CATALOG_FILTER_EXISTS` symbol.\n */\nfunction convertSchemaFiltersToQuery(\n schemaFilters: EntityPickerFilterQuery,\n): Exclude<EntityFilterQuery, Array<any>> {\n const query: EntityFilterQuery = {};\n\n for (const [key, value] of Object.entries(schemaFilters)) {\n if (Array.isArray(value)) {\n query[key] = value;\n } else {\n query[key] = convertOpsValues(value);\n }\n }\n\n return query;\n}\n\n/**\n * Builds an `EntityFilterQuery` based on the `uiSchema` passed in.\n * If `catalogFilter` is specified in the `uiSchema`, it is converted to a `EntityFilterQuery`.\n * If `allowedKinds` is specified in the `uiSchema` will support the legacy `allowedKinds` option.\n *\n * @param uiSchema The `uiSchema` of an `EntityPicker` component.\n * @returns An `EntityFilterQuery` based on the `uiSchema`, or `undefined` if `catalogFilter` is not specified in the `uiSchema`.\n */\nfunction buildCatalogFilter(\n uiSchema: EntityPickerProps['uiSchema'],\n): EntityFilterQuery | undefined {\n const allowedKinds = uiSchema['ui:options']?.allowedKinds;\n\n const catalogFilter: EntityPickerUiOptions['catalogFilter'] | undefined =\n uiSchema['ui:options']?.catalogFilter ||\n (allowedKinds && { kind: allowedKinds });\n\n if (!catalogFilter) {\n return undefined;\n }\n\n if (Array.isArray(catalogFilter)) {\n return catalogFilter.map(convertSchemaFiltersToQuery);\n }\n\n return convertSchemaFiltersToQuery(catalogFilter);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAuDa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,MAAQ,EAAA,EAAE,KAAQ,GAAA,QAAA,EAAU,cAAc,4BAA6B,EAAA;AAAA,IACvE,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,aAAA,GAAgB,mBAAmB,QAAQ,CAAA,CAAA;AACjD,EAAM,MAAA,WAAA,GAAc,QAAS,CAAA,YAAY,CAAG,EAAA,WAAA,CAAA;AAC5C,EA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,EAAM,MAAA,YAAA,GAAe,QAAS,CAAA,YAAY,CAAG,EAAA,YAAA,CAAA;AAE7C,EAAM,MAAA,aAAA,GACJ,SAAS,YAAY,CAAA,EAAG,iBACvB,YAAgB,IAAA,EAAE,MAAM,YAAa,EAAA,CAAA;AAExC,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":"EntityPicker.esm.js","sources":["../../../../src/components/fields/EntityPicker/EntityPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n type EntityFilterQuery,\n CATALOG_FILTER_EXISTS,\n} from '@backstage/catalog-client';\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefPresentationSnapshot,\n catalogApiRef,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport Autocomplete, {\n AutocompleteChangeReason,\n createFilterOptions,\n} from '@material-ui/lab/Autocomplete';\nimport React, { useCallback, useEffect } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n EntityPickerFilterQueryValue,\n EntityPickerProps,\n EntityPickerUiOptions,\n EntityPickerFilterQuery,\n} from './schema';\nimport { VirtualizedListbox } from '../VirtualizedListbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport { EntityPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityPicker = (props: EntityPickerProps) => {\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const {\n onChange,\n schema: {\n title = t('fields.entityPicker.title'),\n description = t('fields.entityPicker.description'),\n },\n required,\n uiSchema,\n rawErrors,\n formData,\n idSchema,\n } = props;\n const catalogFilter = buildCatalogFilter(uiSchema);\n const defaultKind = uiSchema['ui:options']?.defaultKind;\n const defaultNamespace =\n uiSchema['ui:options']?.defaultNamespace || undefined;\n\n const catalogApi = useApi(catalogApiRef);\n const entityPresentationApi = useApi(entityPresentationApiRef);\n\n const { value: entities, loading } = useAsync(async () => {\n const fields = [\n 'metadata.name',\n 'metadata.namespace',\n 'metadata.title',\n 'kind',\n ];\n const { items } = await catalogApi.getEntities(\n catalogFilter\n ? { filter: catalogFilter, fields }\n : { filter: undefined, fields },\n );\n\n const entityRefToPresentation = new Map<\n string,\n EntityRefPresentationSnapshot\n >(\n await Promise.all(\n items.map(async item => {\n const presentation = await entityPresentationApi.forEntity(item)\n .promise;\n return [stringifyEntityRef(item), presentation] as [\n string,\n EntityRefPresentationSnapshot,\n ];\n }),\n ),\n );\n\n return { catalogEntities: items, entityRefToPresentation };\n });\n\n const allowArbitraryValues =\n uiSchema['ui:options']?.allowArbitraryValues ?? true;\n\n const getLabel = useCallback(\n (freeSoloValue: string) => {\n try {\n // Will throw if defaultKind or defaultNamespace are not set\n const parsedRef = parseEntityRef(freeSoloValue, {\n defaultKind,\n defaultNamespace,\n });\n\n return stringifyEntityRef(parsedRef);\n } catch (err) {\n return freeSoloValue;\n }\n },\n [defaultKind, defaultNamespace],\n );\n\n const onSelect = useCallback(\n (_: any, ref: string | Entity | null, reason: AutocompleteChangeReason) => {\n // ref can either be a string from free solo entry or\n if (typeof ref !== 'string') {\n // if ref does not exist: pass 'undefined' to trigger validation for required value\n onChange(ref ? stringifyEntityRef(ref as Entity) : undefined);\n } else {\n if (reason === 'blur' || reason === 'create-option') {\n // Add in default namespace, etc.\n let entityRef = ref;\n try {\n // Attempt to parse the entity ref into it's full form.\n entityRef = stringifyEntityRef(\n parseEntityRef(ref as string, {\n defaultKind,\n defaultNamespace,\n }),\n );\n } catch (err) {\n // If the passed in value isn't an entity ref, do nothing.\n }\n // We need to check against formData here as that's the previous value for this field.\n if (formData !== ref || allowArbitraryValues) {\n onChange(entityRef);\n }\n }\n }\n },\n [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues],\n );\n\n // Since free solo can be enabled, attempt to parse as a full entity ref first, then fall\n // back to the given value.\n const selectedEntity =\n entities?.catalogEntities.find(e => stringifyEntityRef(e) === formData) ??\n (allowArbitraryValues && formData ? getLabel(formData) : '');\n\n useEffect(() => {\n if (entities?.catalogEntities.length === 1 && selectedEntity === '') {\n onChange(stringifyEntityRef(entities.catalogEntities[0]));\n }\n }, [entities, onChange, selectedEntity]);\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !formData}\n >\n <Autocomplete\n disabled={entities?.catalogEntities.length === 1}\n id={idSchema?.$id}\n value={selectedEntity}\n loading={loading}\n onChange={onSelect}\n options={entities?.catalogEntities || []}\n getOptionLabel={option =>\n // option can be a string due to freeSolo.\n typeof option === 'string'\n ? option\n : entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.entityRef!\n }\n autoSelect\n freeSolo={allowArbitraryValues}\n renderInput={params => (\n <TextField\n {...params}\n label={title}\n margin=\"dense\"\n helperText={description}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }}\n variant=\"outlined\"\n required={required}\n InputProps={params.InputProps}\n />\n )}\n renderOption={option => <EntityDisplayName entityRef={option} />}\n filterOptions={createFilterOptions<Entity>({\n stringify: option =>\n entities?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.primaryTitle!,\n })}\n ListboxComponent={VirtualizedListbox}\n />\n </FormControl>\n );\n};\n\n/**\n * Converts a especial `{exists: true}` value to the `CATALOG_FILTER_EXISTS` symbol.\n *\n * @param value - The value to convert.\n * @returns The converted value.\n */\nfunction convertOpsValues(\n value: Exclude<EntityPickerFilterQueryValue, Array<any>>,\n): string | symbol {\n if (typeof value === 'object' && value.exists) {\n return CATALOG_FILTER_EXISTS;\n }\n return value?.toString();\n}\n\n/**\n * Converts schema filters to entity filter query, replacing `{exists:true}` values\n * with the constant `CATALOG_FILTER_EXISTS`.\n *\n * @param schemaFilters - An object containing schema filters with keys as filter names\n * and values as filter values.\n * @returns An object with the same keys as the input object, but with `{exists:true}` values\n * transformed to `CATALOG_FILTER_EXISTS` symbol.\n */\nfunction convertSchemaFiltersToQuery(\n schemaFilters: EntityPickerFilterQuery,\n): Exclude<EntityFilterQuery, Array<any>> {\n const query: EntityFilterQuery = {};\n\n for (const [key, value] of Object.entries(schemaFilters)) {\n if (Array.isArray(value)) {\n query[key] = value;\n } else {\n query[key] = convertOpsValues(value);\n }\n }\n\n return query;\n}\n\n/**\n * Builds an `EntityFilterQuery` based on the `uiSchema` passed in.\n * If `catalogFilter` is specified in the `uiSchema`, it is converted to a `EntityFilterQuery`.\n * If `allowedKinds` is specified in the `uiSchema` will support the legacy `allowedKinds` option.\n *\n * @param uiSchema The `uiSchema` of an `EntityPicker` component.\n * @returns An `EntityFilterQuery` based on the `uiSchema`, or `undefined` if `catalogFilter` is not specified in the `uiSchema`.\n */\nfunction buildCatalogFilter(\n uiSchema: EntityPickerProps['uiSchema'],\n): EntityFilterQuery | undefined {\n const allowedKinds = uiSchema['ui:options']?.allowedKinds;\n\n const catalogFilter: EntityPickerUiOptions['catalogFilter'] | undefined =\n uiSchema['ui:options']?.catalogFilter ||\n (allowedKinds && { kind: allowedKinds });\n\n if (!catalogFilter) {\n return undefined;\n }\n\n if (Array.isArray(catalogFilter)) {\n return catalogFilter.map(convertSchemaFiltersToQuery);\n }\n\n return convertSchemaFiltersToQuery(catalogFilter);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAyDa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AACxD,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,KAAA,GAAQ,EAAE,2BAA2B,CAAA;AAAA,MACrC,WAAA,GAAc,EAAE,iCAAiC,CAAA;AAAA,KACnD;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,aAAA,GAAgB,mBAAmB,QAAQ,CAAA,CAAA;AACjD,EAAM,MAAA,WAAA,GAAc,QAAS,CAAA,YAAY,CAAG,EAAA,WAAA,CAAA;AAC5C,EAAA,MAAM,gBACJ,GAAA,QAAA,CAAS,YAAY,CAAA,EAAG,gBAAoB,IAAA,KAAA,CAAA,CAAA;AAE9C,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAM,MAAA,qBAAA,GAAwB,OAAO,wBAAwB,CAAA,CAAA;AAE7D,EAAA,MAAM,EAAE,KAAO,EAAA,QAAA,EAAU,OAAQ,EAAA,GAAI,SAAS,YAAY;AACxD,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,eAAA;AAAA,MACA,oBAAA;AAAA,MACA,gBAAA;AAAA,MACA,MAAA;AAAA,KACF,CAAA;AACA,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAM,UAAW,CAAA,WAAA;AAAA,MACjC,aAAA,GACI,EAAE,MA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catalog-react';
|
|
|
7
7
|
import FormControl from '@material-ui/core/FormControl';
|
|
8
8
|
import TextField from '@material-ui/core/TextField';
|
|
9
9
|
import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
10
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
11
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
10
12
|
export { EntityTagsPickerSchema } from './schema.esm.js';
|
|
11
13
|
|
|
12
14
|
const EntityTagsPicker = (props) => {
|
|
@@ -19,6 +21,7 @@ const EntityTagsPicker = (props) => {
|
|
|
19
21
|
const kinds = uiSchema["ui:options"]?.kinds;
|
|
20
22
|
const showCounts = uiSchema["ui:options"]?.showCounts;
|
|
21
23
|
const helperText = uiSchema["ui:options"]?.helperText;
|
|
24
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
22
25
|
const { loading, value: existingTags } = useAsync(async () => {
|
|
23
26
|
const facet = "metadata.tags";
|
|
24
27
|
const tagsRequest = { facets: [facet] };
|
|
@@ -69,10 +72,10 @@ const EntityTagsPicker = (props) => {
|
|
|
69
72
|
TextField,
|
|
70
73
|
{
|
|
71
74
|
...params,
|
|
72
|
-
label: "
|
|
75
|
+
label: t("fields.entityTagsPicker.title"),
|
|
73
76
|
onChange: (e) => setInputValue(e.target.value),
|
|
74
77
|
error: inputError,
|
|
75
|
-
helperText: helperText ?? "
|
|
78
|
+
helperText: helperText ?? t("fields.entityTagsPicker.description"),
|
|
76
79
|
FormHelperTextProps: { margin: "dense", style: { marginLeft: 0 } }
|
|
77
80
|
}
|
|
78
81
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityTagsPicker.esm.js","sources":["../../../../src/components/fields/EntityTagsPicker/EntityTagsPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport useEffectOnce from 'react-use/esm/useEffectOnce';\nimport { GetEntityFacetsRequest } from '@backstage/catalog-client';\nimport { makeValidator } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport TextField from '@material-ui/core/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { EntityTagsPickerProps } from './schema';\n\nexport { EntityTagsPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityTagsPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityTagsPicker = (props: EntityTagsPickerProps) => {\n const { formData, onChange, uiSchema } = props;\n const catalogApi = useApi(catalogApiRef);\n const [tagOptions, setTagOptions] = useState<string[]>([]);\n const [inputValue, setInputValue] = useState('');\n const [inputError, setInputError] = useState(false);\n const tagValidator = makeValidator().isValidTag;\n const kinds = uiSchema['ui:options']?.kinds;\n const showCounts = uiSchema['ui:options']?.showCounts;\n const helperText = uiSchema['ui:options']?.helperText;\n\n const { loading, value: existingTags } = useAsync(async () => {\n const facet = 'metadata.tags';\n const tagsRequest: GetEntityFacetsRequest = { facets: [facet] };\n if (kinds) {\n tagsRequest.filter = { kind: kinds };\n }\n\n const { facets } = await catalogApi.getEntityFacets(tagsRequest);\n\n const tagFacets = Object.fromEntries(\n facets[facet].map(({ value, count }) => [value, count]),\n );\n\n setTagOptions(\n Object.keys(tagFacets).sort((a, b) =>\n showCounts ? tagFacets[b] - tagFacets[a] : a.localeCompare(b),\n ),\n );\n\n return tagFacets;\n });\n\n const setTags = (_: React.ChangeEvent<{}>, values: string[] | null) => {\n // Reset error state in case all tags were removed\n let hasError = false;\n let addDuplicate = false;\n const currentTags = formData || [];\n\n // If adding a new tag\n if (values?.length && currentTags.length < values.length) {\n const newTag = (values[values.length - 1] = values[values.length - 1]\n .toLocaleLowerCase('en-US')\n .trim());\n hasError = !tagValidator(newTag);\n addDuplicate = currentTags.indexOf(newTag) !== -1;\n }\n\n setInputError(hasError);\n setInputValue(!hasError ? '' : inputValue);\n if (!hasError && !addDuplicate) {\n onChange(values || []);\n }\n };\n\n // Initialize field to always return an array\n useEffectOnce(() => onChange(formData || []));\n\n return (\n <FormControl margin=\"normal\">\n <Autocomplete\n multiple\n freeSolo\n filterSelectedOptions\n onChange={setTags}\n value={formData || []}\n inputValue={inputValue}\n loading={loading}\n options={tagOptions}\n ChipProps={{ size: 'small' }}\n renderOption={option =>\n showCounts ? `${option} (${existingTags?.[option]})` : option\n }\n renderInput={params => (\n <TextField\n {...params}\n label
|
|
1
|
+
{"version":3,"file":"EntityTagsPicker.esm.js","sources":["../../../../src/components/fields/EntityTagsPicker/EntityTagsPicker.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport useEffectOnce from 'react-use/esm/useEffectOnce';\nimport { GetEntityFacetsRequest } from '@backstage/catalog-client';\nimport { makeValidator } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport TextField from '@material-ui/core/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { EntityTagsPickerProps } from './schema';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport { EntityTagsPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityTagsPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityTagsPicker = (props: EntityTagsPickerProps) => {\n const { formData, onChange, uiSchema } = props;\n const catalogApi = useApi(catalogApiRef);\n const [tagOptions, setTagOptions] = useState<string[]>([]);\n const [inputValue, setInputValue] = useState('');\n const [inputError, setInputError] = useState(false);\n const tagValidator = makeValidator().isValidTag;\n const kinds = uiSchema['ui:options']?.kinds;\n const showCounts = uiSchema['ui:options']?.showCounts;\n const helperText = uiSchema['ui:options']?.helperText;\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const { loading, value: existingTags } = useAsync(async () => {\n const facet = 'metadata.tags';\n const tagsRequest: GetEntityFacetsRequest = { facets: [facet] };\n if (kinds) {\n tagsRequest.filter = { kind: kinds };\n }\n\n const { facets } = await catalogApi.getEntityFacets(tagsRequest);\n\n const tagFacets = Object.fromEntries(\n facets[facet].map(({ value, count }) => [value, count]),\n );\n\n setTagOptions(\n Object.keys(tagFacets).sort((a, b) =>\n showCounts ? tagFacets[b] - tagFacets[a] : a.localeCompare(b),\n ),\n );\n\n return tagFacets;\n });\n\n const setTags = (_: React.ChangeEvent<{}>, values: string[] | null) => {\n // Reset error state in case all tags were removed\n let hasError = false;\n let addDuplicate = false;\n const currentTags = formData || [];\n\n // If adding a new tag\n if (values?.length && currentTags.length < values.length) {\n const newTag = (values[values.length - 1] = values[values.length - 1]\n .toLocaleLowerCase('en-US')\n .trim());\n hasError = !tagValidator(newTag);\n addDuplicate = currentTags.indexOf(newTag) !== -1;\n }\n\n setInputError(hasError);\n setInputValue(!hasError ? '' : inputValue);\n if (!hasError && !addDuplicate) {\n onChange(values || []);\n }\n };\n\n // Initialize field to always return an array\n useEffectOnce(() => onChange(formData || []));\n\n return (\n <FormControl margin=\"normal\">\n <Autocomplete\n multiple\n freeSolo\n filterSelectedOptions\n onChange={setTags}\n value={formData || []}\n inputValue={inputValue}\n loading={loading}\n options={tagOptions}\n ChipProps={{ size: 'small' }}\n renderOption={option =>\n showCounts ? `${option} (${existingTags?.[option]})` : option\n }\n renderInput={params => (\n <TextField\n {...params}\n label={t('fields.entityTagsPicker.title')}\n onChange={e => setInputValue(e.target.value)}\n error={inputError}\n helperText={helperText ?? t('fields.entityTagsPicker.description')}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }}\n />\n )}\n />\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAqCa,MAAA,gBAAA,GAAmB,CAAC,KAAiC,KAAA;AAChE,EAAA,MAAM,EAAE,QAAA,EAAU,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AACzC,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAA,MAAM,CAAC,UAAY,EAAA,aAAa,CAAI,GAAA,QAAA,CAAmB,EAAE,CAAA,CAAA;AACzD,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,EAAE,CAAA,CAAA;AAC/C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAClD,EAAM,MAAA,YAAA,GAAe,eAAgB,CAAA,UAAA,CAAA;AACrC,EAAM,MAAA,KAAA,GAAQ,QAAS,CAAA,YAAY,CAAG,EAAA,KAAA,CAAA;AACtC,EAAM,MAAA,UAAA,GAAa,QAAS,CAAA,YAAY,CAAG,EAAA,UAAA,CAAA;AAC3C,EAAM,MAAA,UAAA,GAAa,QAAS,CAAA,YAAY,CAAG,EAAA,UAAA,CAAA;AAC3C,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AAExD,EAAA,MAAM,EA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AAA;AAAA,UACE,GAAG,MAAA;AAAA,UACJ,KAAA,EAAO,EAAE,+BAA+B,CAAA;AAAA,UACxC,QAAU,EAAA,CAAA,CAAA,KAAK,aAAc,CAAA,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,UAC3C,KAAO,EAAA,UAAA;AAAA,UACP,UAAA,EAAY,UAAc,IAAA,CAAA,CAAE,qCAAqC,CAAA;AAAA,UACjE,mBAAA,EAAqB,EAAE,MAAQ,EAAA,OAAA,EAAS,OAAO,EAAE,UAAA,EAAY,GAAI,EAAA;AAAA,SAAA;AAAA,OACnE;AAAA,KAAA;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -9,10 +9,16 @@ import { NotFoundError } from '@backstage/errors';
|
|
|
9
9
|
import useAsync from 'react-use/esm/useAsync';
|
|
10
10
|
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
11
11
|
import { VirtualizedListbox } from '../VirtualizedListbox.esm.js';
|
|
12
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
13
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
12
14
|
|
|
13
15
|
const MyGroupsPicker = (props) => {
|
|
16
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
14
17
|
const {
|
|
15
|
-
schema: {
|
|
18
|
+
schema: {
|
|
19
|
+
title = t("fields.myGroupsPicker.title"),
|
|
20
|
+
description = t("fields.myGroupsPicker.description")
|
|
21
|
+
},
|
|
16
22
|
required,
|
|
17
23
|
rawErrors,
|
|
18
24
|
onChange,
|
|
@@ -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, { useEffect } 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, {\n createFilterOptions,\n} from '@material-ui/lab/Autocomplete';\nimport {\n catalogApiRef,\n EntityDisplayName,\n entityPresentationApiRef,\n EntityRefPresentationSnapshot,\n} from '@backstage/plugin-catalog-react';\nimport { NotFoundError } from '@backstage/errors';\nimport useAsync from 'react-use/esm/useAsync';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { VirtualizedListbox } from '../VirtualizedListbox';\n\nexport { MyGroupsPickerSchema };\n\nexport const MyGroupsPicker = (props: MyGroupsPickerProps) => {\n const {\n schema: { title
|
|
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, { useEffect } 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, {\n createFilterOptions,\n} from '@material-ui/lab/Autocomplete';\nimport {\n catalogApiRef,\n EntityDisplayName,\n entityPresentationApiRef,\n EntityRefPresentationSnapshot,\n} from '@backstage/plugin-catalog-react';\nimport { NotFoundError } from '@backstage/errors';\nimport useAsync from 'react-use/esm/useAsync';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { VirtualizedListbox } from '../VirtualizedListbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport { MyGroupsPickerSchema };\n\nexport const MyGroupsPicker = (props: MyGroupsPickerProps) => {\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const {\n schema: {\n title = t('fields.myGroupsPicker.title'),\n description = t('fields.myGroupsPicker.description'),\n },\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 entityPresentationApi = useApi(entityPresentationApiRef);\n\n const { value: groups, loading } = useAsync(async () => {\n const { userEntityRef } = await identityApi.getBackstageIdentity();\n\n if (!userEntityRef) {\n errorApi.post(new NotFoundError('No user entity ref found'));\n return { catalogEntities: [], entityRefToPresentation: new Map() };\n }\n\n const { items } = await catalogApi.getEntities({\n filter: {\n kind: 'Group',\n ['relations.hasMember']: [userEntityRef],\n },\n });\n\n const entityRefToPresentation = new Map<\n string,\n EntityRefPresentationSnapshot\n >(\n await Promise.all(\n items.map(async item => {\n const presentation = await entityPresentationApi.forEntity(item)\n .promise;\n return [stringifyEntityRef(item), presentation] as [\n string,\n EntityRefPresentationSnapshot,\n ];\n }),\n ),\n );\n\n return { catalogEntities: items, entityRefToPresentation };\n });\n\n const updateChange = (_: React.ChangeEvent<{}>, value: Entity | null) => {\n onChange(value ? stringifyEntityRef(value) : '');\n };\n\n const selectedEntity =\n groups?.catalogEntities.find(e => stringifyEntityRef(e) === formData) ||\n null;\n\n useEffect(() => {\n if (groups?.catalogEntities.length === 1 && !selectedEntity) {\n onChange(stringifyEntityRef(groups.catalogEntities[0]));\n }\n }, [groups, onChange, selectedEntity]);\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0}\n >\n <Autocomplete\n disabled={groups?.catalogEntities.length === 1}\n id=\"OwnershipEntityRefPicker-dropdown\"\n options={groups?.catalogEntities || []}\n value={selectedEntity}\n loading={loading}\n onChange={updateChange}\n getOptionLabel={option =>\n groups?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.primaryTitle!\n }\n autoSelect\n renderInput={params => (\n <TextField\n {...params}\n label={title}\n margin=\"dense\"\n helperText={description}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }}\n variant=\"outlined\"\n required={required}\n InputProps={params.InputProps}\n />\n )}\n renderOption={option => <EntityDisplayName entityRef={option} />}\n filterOptions={createFilterOptions<Entity>({\n stringify: option =>\n groups?.entityRefToPresentation.get(stringifyEntityRef(option))\n ?.primaryTitle!,\n })}\n ListboxComponent={VirtualizedListbox}\n />\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA2Ca,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AACxD,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA;AAAA,MACN,KAAA,GAAQ,EAAE,6BAA6B,CAAA;AAAA,MACvC,WAAA,GAAc,EAAE,mCAAmC,CAAA;AAAA,KACrD;AAAA,IACA,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,CA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Y,EAAA,WAAA;AAAA,YACZ,mBAAA,EAAqB,EAAE,MAAQ,EAAA,OAAA,EAAS,OAAO,EAAE,UAAA,EAAY,GAAI,EAAA;AAAA,YACjE,OAAQ,EAAA,UAAA;AAAA,YACR,QAAA;AAAA,YACA,YAAY,MAAO,CAAA,UAAA;AAAA,WAAA;AAAA,SACrB;AAAA,QAEF,YAAc,EAAA,CAAA,MAAA,qBAAW,KAAA,CAAA,aAAA,CAAA,iBAAA,EAAA,EAAkB,WAAW,MAAQ,EAAA,CAAA;AAAA,QAC9D,eAAe,mBAA4B,CAAA;AAAA,UACzC,SAAA,EAAW,YACT,MAAQ,EAAA,uBAAA,CAAwB,IAAI,kBAAmB,CAAA,MAAM,CAAC,CAC1D,EAAA,YAAA;AAAA,SACP,CAAA;AAAA,QACD,gBAAkB,EAAA,kBAAA;AAAA,OAAA;AAAA,KACpB;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -5,11 +5,17 @@ import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import useAsync from 'react-use/esm/useAsync';
|
|
7
7
|
import { EntityPicker } from '../EntityPicker/EntityPicker.esm.js';
|
|
8
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
9
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
8
10
|
export { OwnedEntityPickerSchema } from './schema.esm.js';
|
|
9
11
|
|
|
10
12
|
const OwnedEntityPicker = (props) => {
|
|
13
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
11
14
|
const {
|
|
12
|
-
schema: {
|
|
15
|
+
schema: {
|
|
16
|
+
title = t("fields.ownedEntityPicker.title"),
|
|
17
|
+
description = t("fields.ownedEntityPicker.description")
|
|
18
|
+
},
|
|
13
19
|
uiSchema,
|
|
14
20
|
required
|
|
15
21
|
} = props;
|
|
@@ -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: {
|
|
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';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\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 { t } = useTranslationRef(scaffolderTranslationRef);\n const {\n schema: {\n title = t('fields.ownedEntityPicker.title'),\n description = t('fields.ownedEntityPicker.description'),\n },\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 = asArray(uiOptions.catalogFilter).map(e => ({\n ...e,\n ...(allowedKinds ? { kind: allowedKinds } : {}),\n [`relations.${RELATION_OWNED_BY}`]: identityRefs || [],\n }));\n\n return {\n 'ui:options': {\n catalogFilter,\n },\n };\n}\n\nfunction asArray(catalogFilter: any): any[] {\n if (catalogFilter) {\n return Array.isArray(catalogFilter) ? catalogFilter : [catalogFilter];\n }\n return [{}];\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAoCa,MAAA,iBAAA,GAAoB,CAAC,KAAkC,KAAA;AAClE,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AACxD,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA;AAAA,MACN,KAAA,GAAQ,EAAE,gCAAgC,CAAA;AAAA,MAC1C,WAAA,GAAc,EAAE,sCAAsC,CAAA;AAAA,KACxD;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA,CAAA;AACzC,EAAA,MAAM,EAAE,OAAS,EAAA,KAAA,EAAO,YAAa,EAAA,GAAI,SAAS,YAAY;AAC5D,IAAM,MAAA,QAAA,GAAW,MAAM,WAAA,CAAY,oBAAqB,EAAA,CAAA;AACxD,IAAA,OAAO,QAAS,CAAA,mBAAA,CAAA;AAAA,GACjB,CAAA,CAAA;AAED,EAAI,IAAA,OAAA;AACF,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,OAAA;AAAA,QACA,aAAa,CACX,MAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,SAAA;AAAA,UAAA;AAAA,YACE,GAAG,MAAA;AA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AA,aAAA,GAAgB,CAAC,aAAa,CAAA,CAAA;AAAA,GACtE;AACA,EAAO,OAAA,CAAC,EAAE,CAAA,CAAA;AACZ;;;;"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EntityPicker } from '../EntityPicker/EntityPicker.esm.js';
|
|
3
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
4
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
3
5
|
export { OwnerPickerSchema } from './schema.esm.js';
|
|
4
6
|
|
|
5
7
|
const OwnerPicker = (props) => {
|
|
8
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
6
9
|
const {
|
|
7
|
-
schema: {
|
|
10
|
+
schema: {
|
|
11
|
+
title = t("fields.ownerPicker.title"),
|
|
12
|
+
description = t("fields.ownerPicker.description")
|
|
13
|
+
},
|
|
8
14
|
uiSchema,
|
|
9
15
|
...restProps
|
|
10
16
|
} = props;
|
|
@@ -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: {
|
|
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';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\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 { t } = useTranslationRef(scaffolderTranslationRef);\n const {\n schema: {\n title = t('fields.ownerPicker.title'),\n description = t('fields.ownerPicker.description'),\n },\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":";;;;;;AA6Ba,MAAA,WAAA,GAAc,CAAC,KAA4B,KAAA;AACtD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AACxD,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA;AAAA,MACN,KAAA,GAAQ,EAAE,0BAA0B,CAAA;AAAA,MACpC,WAAA,GAAc,EAAE,gCAAgC,CAAA;AAAA,KAClD;AAAA,IACA,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;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import FormControl from '@material-ui/core/FormControl';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
|
4
|
-
import
|
|
5
|
-
import InputLabel from '@material-ui/core/InputLabel';
|
|
4
|
+
import TextField from '@material-ui/core/TextField';
|
|
6
5
|
|
|
7
6
|
const DefaultRepoBranchPicker = ({
|
|
8
7
|
onChange,
|
|
@@ -18,11 +17,11 @@ const DefaultRepoBranchPicker = ({
|
|
|
18
17
|
required,
|
|
19
18
|
error: rawErrors?.length > 0 && !branch
|
|
20
19
|
},
|
|
21
|
-
/* @__PURE__ */ React.createElement(InputLabel, { htmlFor: "branchInput" }, "Branch"),
|
|
22
20
|
/* @__PURE__ */ React.createElement(
|
|
23
|
-
|
|
21
|
+
TextField,
|
|
24
22
|
{
|
|
25
23
|
id: "branchInput",
|
|
24
|
+
label: "Branch",
|
|
26
25
|
onChange: (e) => onChange({ branch: e.target.value }),
|
|
27
26
|
value: branch
|
|
28
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultRepoBranchPicker.esm.js","sources":["../../../../src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport FormControl from '@material-ui/core/FormControl';\nimport React from 'react';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport
|
|
1
|
+
{"version":3,"file":"DefaultRepoBranchPicker.esm.js","sources":["../../../../src/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport FormControl from '@material-ui/core/FormControl';\nimport React from 'react';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport TextField from '@material-ui/core/TextField';\n\nimport { BaseRepoBranchPickerProps } from './types';\n\n/**\n * The underlying component that is rendered in the form for the `DefaultRepoBranchPicker`\n * field extension.\n *\n * @public\n *\n */\nexport const DefaultRepoBranchPicker = ({\n onChange,\n state,\n rawErrors,\n required,\n}: BaseRepoBranchPickerProps) => {\n const { branch } = state;\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !branch}\n >\n <TextField\n id=\"branchInput\"\n label=\"Branch\"\n onChange={e => onChange({ branch: e.target.value })}\n value={branch}\n />\n <FormHelperText>The branch of the repository</FormHelperText>\n </FormControl>\n );\n};\n"],"names":[],"mappings":";;;;;AA8BO,MAAM,0BAA0B,CAAC;AAAA,EACtC,QAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AACF,CAAiC,KAAA;AAC/B,EAAM,MAAA,EAAE,QAAW,GAAA,KAAA,CAAA;AAEnB,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAO,EAAA,QAAA;AAAA,MACP,QAAA;AAAA,MACA,KAAO,EAAA,SAAA,EAAW,MAAS,GAAA,CAAA,IAAK,CAAC,MAAA;AAAA,KAAA;AAAA,oBAEjC,KAAA,CAAA,aAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,aAAA;AAAA,QACH,KAAM,EAAA,QAAA;AAAA,QACN,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,QAAQ,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QAClD,KAAO,EAAA,MAAA;AAAA,OAAA;AAAA,KACT;AAAA,oBACA,KAAA,CAAA,aAAA,CAAC,sBAAe,8BAA4B,CAAA;AAAA,GAC9C,CAAA;AAEJ;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import FormControl from '@material-ui/core/FormControl';
|
|
3
3
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
|
4
|
-
import
|
|
5
|
-
import InputLabel from '@material-ui/core/InputLabel';
|
|
4
|
+
import TextField from '@material-ui/core/TextField';
|
|
6
5
|
import { Select } from '@backstage/core-components';
|
|
6
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
7
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
7
8
|
|
|
8
9
|
const AzureRepoPicker = (props) => {
|
|
9
10
|
const {
|
|
@@ -13,6 +14,7 @@ const AzureRepoPicker = (props) => {
|
|
|
13
14
|
state,
|
|
14
15
|
onChange
|
|
15
16
|
} = props;
|
|
17
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
16
18
|
const organizationItems = allowedOrganizations ? allowedOrganizations.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
|
|
17
19
|
const projectItems = allowedProject ? allowedProject.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
|
|
18
20
|
const { organization, project } = state;
|
|
@@ -23,25 +25,26 @@ const AzureRepoPicker = (props) => {
|
|
|
23
25
|
required: true,
|
|
24
26
|
error: rawErrors?.length > 0 && !organization
|
|
25
27
|
},
|
|
26
|
-
allowedOrganizations?.length ? /* @__PURE__ */ React.createElement(
|
|
28
|
+
allowedOrganizations?.length ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
27
29
|
Select,
|
|
28
30
|
{
|
|
29
31
|
native: true,
|
|
30
|
-
label: "
|
|
32
|
+
label: t("fields.azureRepoPicker.organization.title"),
|
|
31
33
|
onChange: (s) => onChange({ organization: String(Array.isArray(s) ? s[0] : s) }),
|
|
32
34
|
disabled: allowedOrganizations.length === 1,
|
|
33
35
|
selected: organization,
|
|
34
36
|
items: organizationItems
|
|
35
37
|
}
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
+
), /* @__PURE__ */ React.createElement(FormHelperText, null, t("fields.azureRepoPicker.organization.description"))) : /* @__PURE__ */ React.createElement(
|
|
39
|
+
TextField,
|
|
38
40
|
{
|
|
39
41
|
id: "orgInput",
|
|
42
|
+
label: t("fields.azureRepoPicker.organization.title"),
|
|
40
43
|
onChange: (e) => onChange({ organization: e.target.value }),
|
|
44
|
+
helperText: t("fields.azureRepoPicker.organization.description"),
|
|
41
45
|
value: organization
|
|
42
46
|
}
|
|
43
|
-
)
|
|
44
|
-
/* @__PURE__ */ React.createElement(FormHelperText, null, "The Organization that this repo will belong to")
|
|
47
|
+
)
|
|
45
48
|
), /* @__PURE__ */ React.createElement(
|
|
46
49
|
FormControl,
|
|
47
50
|
{
|
|
@@ -49,25 +52,26 @@ const AzureRepoPicker = (props) => {
|
|
|
49
52
|
required: true,
|
|
50
53
|
error: rawErrors?.length > 0 && !project
|
|
51
54
|
},
|
|
52
|
-
allowedProject?.length ? /* @__PURE__ */ React.createElement(
|
|
55
|
+
allowedProject?.length ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
53
56
|
Select,
|
|
54
57
|
{
|
|
55
58
|
native: true,
|
|
56
|
-
label: "
|
|
59
|
+
label: t("fields.azureRepoPicker.project.title"),
|
|
57
60
|
onChange: (s) => onChange({ project: String(Array.isArray(s) ? s[0] : s) }),
|
|
58
61
|
disabled: allowedProject.length === 1,
|
|
59
62
|
selected: project,
|
|
60
63
|
items: projectItems
|
|
61
64
|
}
|
|
62
|
-
)
|
|
63
|
-
|
|
65
|
+
), /* @__PURE__ */ React.createElement(FormHelperText, null, t("fields.azureRepoPicker.project.description"))) : /* @__PURE__ */ React.createElement(
|
|
66
|
+
TextField,
|
|
64
67
|
{
|
|
65
68
|
id: "projectInput",
|
|
69
|
+
label: t("fields.azureRepoPicker.project.title"),
|
|
66
70
|
onChange: (e) => onChange({ project: e.target.value }),
|
|
67
|
-
value: project
|
|
71
|
+
value: project,
|
|
72
|
+
helperText: t("fields.azureRepoPicker.project.description")
|
|
68
73
|
}
|
|
69
|
-
)
|
|
70
|
-
/* @__PURE__ */ React.createElement(FormHelperText, null, "The Project that this repo will belong to")
|
|
74
|
+
)
|
|
71
75
|
));
|
|
72
76
|
};
|
|
73
77
|
|
|
@@ -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
|
|
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 TextField from '@material-ui/core/TextField';\nimport { BaseRepoUrlPickerProps } from './types';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport const AzureRepoPicker = (\n props: BaseRepoUrlPickerProps<{\n allowedOrganizations?: string[];\n allowedProject?: string[];\n }>,\n) => {\n const {\n allowedOrganizations = [],\n allowedProject = [],\n rawErrors,\n state,\n onChange,\n } = props;\n const { t } = useTranslationRef(scaffolderTranslationRef);\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 <>\n <Select\n native\n label={t('fields.azureRepoPicker.organization.title')}\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 <FormHelperText>\n {t('fields.azureRepoPicker.organization.description')}\n </FormHelperText>\n </>\n ) : (\n <TextField\n id=\"orgInput\"\n label={t('fields.azureRepoPicker.organization.title')}\n onChange={e => onChange({ organization: e.target.value })}\n helperText={t('fields.azureRepoPicker.organization.description')}\n value={organization}\n />\n )}\n </FormControl>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !project}\n >\n {allowedProject?.length ? (\n <>\n <Select\n native\n label={t('fields.azureRepoPicker.project.title')}\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 <FormHelperText>\n {t('fields.azureRepoPicker.project.description')}\n </FormHelperText>\n </>\n ) : (\n <TextField\n id=\"projectInput\"\n label={t('fields.azureRepoPicker.project.title')}\n onChange={e => onChange({ project: e.target.value })}\n value={project}\n helperText={t('fields.azureRepoPicker.project.description')}\n />\n )}\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAyBa,MAAA,eAAA,GAAkB,CAC7B,KAIG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,uBAAuB,EAAC;AAAA,IACxB,iBAAiB,EAAC;AAAA,IAClB,SAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AAExD,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,MA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CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,MAAM,EAAA,IAAA;AAAA,QACN,KAAA,EAAO,EAAE,sCAAsC,CAAA;AAAA,QAC/C,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,eAAe,MAAW,KAAA,CAAA;AAAA,QACpC,QAAU,EAAA,OAAA;AAAA,QACV,KAAO,EAAA,YAAA;AAAA,OAAA;AAAA,uBAER,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,IAAA,EACE,EAAE,4CAA4C,CACjD,CACF,CAEA,mBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,SAAA;AAAA,MAAA;AAAA,QACC,EAAG,EAAA,cAAA;AAAA,QACH,KAAA,EAAO,EAAE,sCAAsC,CAAA;AAAA,QAC/C,QAAA,EAAU,OAAK,QAAS,CAAA,EAAE,SAAS,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,QACnD,KAAO,EAAA,OAAA;AAAA,QACP,UAAA,EAAY,EAAE,4CAA4C,CAAA;AAAA,OAAA;AAAA,KAC5D;AAAA,GAGN,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -7,6 +7,8 @@ import TextField from '@material-ui/core/TextField';
|
|
|
7
7
|
import useDebounce from 'react-use/esm/useDebounce';
|
|
8
8
|
import { useApi } from '@backstage/core-plugin-api';
|
|
9
9
|
import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';
|
|
10
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
11
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
10
12
|
|
|
11
13
|
const BitbucketRepoPicker = (props) => {
|
|
12
14
|
const {
|
|
@@ -17,6 +19,7 @@ const BitbucketRepoPicker = (props) => {
|
|
|
17
19
|
state,
|
|
18
20
|
accessToken
|
|
19
21
|
} = props;
|
|
22
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
20
23
|
const { host, workspace, project } = state;
|
|
21
24
|
const ownerItems = allowedOwners ? allowedOwners?.map((i) => ({ label: i, value: i })) : [];
|
|
22
25
|
const projectItems = allowedProjects ? allowedProjects?.map((i) => ({ label: i, value: i })) : [];
|
|
@@ -89,7 +92,7 @@ const BitbucketRepoPicker = (props) => {
|
|
|
89
92
|
Select,
|
|
90
93
|
{
|
|
91
94
|
native: true,
|
|
92
|
-
label: "
|
|
95
|
+
label: t("fields.bitbucketRepoPicker.workspaces.title"),
|
|
93
96
|
onChange: (s) => onChange({ workspace: String(Array.isArray(s) ? s[0] : s) }),
|
|
94
97
|
disabled: allowedOwners.length === 1,
|
|
95
98
|
selected: workspace,
|
|
@@ -103,12 +106,19 @@ const BitbucketRepoPicker = (props) => {
|
|
|
103
106
|
onChange({ workspace: newValue || "" });
|
|
104
107
|
},
|
|
105
108
|
options: availableWorkspaces,
|
|
106
|
-
renderInput: (params) => /* @__PURE__ */ React.createElement(
|
|
109
|
+
renderInput: (params) => /* @__PURE__ */ React.createElement(
|
|
110
|
+
TextField,
|
|
111
|
+
{
|
|
112
|
+
...params,
|
|
113
|
+
label: t("fields.bitbucketRepoPicker.workspaces.inputTitle"),
|
|
114
|
+
required: true
|
|
115
|
+
}
|
|
116
|
+
),
|
|
107
117
|
freeSolo: true,
|
|
108
118
|
autoSelect: true
|
|
109
119
|
}
|
|
110
120
|
),
|
|
111
|
-
/* @__PURE__ */ React.createElement(FormHelperText, null, "
|
|
121
|
+
/* @__PURE__ */ React.createElement(FormHelperText, null, t("fields.bitbucketRepoPicker.workspaces.description"))
|
|
112
122
|
), /* @__PURE__ */ React.createElement(
|
|
113
123
|
FormControl,
|
|
114
124
|
{
|
|
@@ -120,7 +130,7 @@ const BitbucketRepoPicker = (props) => {
|
|
|
120
130
|
Select,
|
|
121
131
|
{
|
|
122
132
|
native: true,
|
|
123
|
-
label: "
|
|
133
|
+
label: t("fields.bitbucketRepoPicker.project.title"),
|
|
124
134
|
onChange: (s) => onChange({ project: String(Array.isArray(s) ? s[0] : s) }),
|
|
125
135
|
disabled: allowedProjects.length === 1,
|
|
126
136
|
selected: project,
|
|
@@ -134,12 +144,19 @@ const BitbucketRepoPicker = (props) => {
|
|
|
134
144
|
onChange({ project: newValue || "" });
|
|
135
145
|
},
|
|
136
146
|
options: availableProjects,
|
|
137
|
-
renderInput: (params) => /* @__PURE__ */ React.createElement(
|
|
147
|
+
renderInput: (params) => /* @__PURE__ */ React.createElement(
|
|
148
|
+
TextField,
|
|
149
|
+
{
|
|
150
|
+
...params,
|
|
151
|
+
label: t("fields.bitbucketRepoPicker.project.inputTitle"),
|
|
152
|
+
required: true
|
|
153
|
+
}
|
|
154
|
+
),
|
|
138
155
|
freeSolo: true,
|
|
139
156
|
autoSelect: true
|
|
140
157
|
}
|
|
141
158
|
),
|
|
142
|
-
/* @__PURE__ */ React.createElement(FormHelperText, null, "
|
|
159
|
+
/* @__PURE__ */ React.createElement(FormHelperText, null, t("fields.bitbucketRepoPicker.project.description"))
|
|
143
160
|
));
|
|
144
161
|
};
|
|
145
162
|
|