@backstage/plugin-catalog-import 0.13.16 → 0.13.17
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 +8 -0
- package/dist/components/StepPrepareCreatePullRequest/AutocompleteTextField.esm.js +15 -1
- package/dist/components/StepPrepareCreatePullRequest/AutocompleteTextField.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.esm.js +12 -6
- package/dist/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.esm.js.map +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/package.json.esm.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-import
|
|
2
2
|
|
|
3
|
+
## 0.13.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f400f2b: Fixed the owner selected in the import stepper being written to the generated `catalog-info.yaml` as a display name instead of an entity reference. Groups are still suggested by their display name, but selecting one now sets a valid `spec.owner`, for example picking `My Team` results in `my-team`.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-catalog-react@3.2.2
|
|
10
|
+
|
|
3
11
|
## 0.13.16
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -5,6 +5,19 @@ import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
|
5
5
|
import { Fragment } from 'react';
|
|
6
6
|
import { Controller } from 'react-hook-form';
|
|
7
7
|
|
|
8
|
+
function optionLabel(option) {
|
|
9
|
+
return typeof option === "string" ? option : option.label;
|
|
10
|
+
}
|
|
11
|
+
function optionValue(value, options) {
|
|
12
|
+
if (value === null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value !== "string") {
|
|
16
|
+
return value.id;
|
|
17
|
+
}
|
|
18
|
+
const option = options.find((o) => typeof o !== "string" && o.label === value);
|
|
19
|
+
return option && typeof option !== "string" ? option.id : value;
|
|
20
|
+
}
|
|
8
21
|
const AutocompleteTextField = (props) => {
|
|
9
22
|
const {
|
|
10
23
|
name,
|
|
@@ -31,7 +44,8 @@ const AutocompleteTextField = (props) => {
|
|
|
31
44
|
options: options || [],
|
|
32
45
|
autoSelect: true,
|
|
33
46
|
freeSolo: true,
|
|
34
|
-
|
|
47
|
+
getOptionLabel: optionLabel,
|
|
48
|
+
onChange: (_event, value) => onChange(optionValue(value, options)),
|
|
35
49
|
renderInput: (params) => /* @__PURE__ */ jsx(
|
|
36
50
|
TextField,
|
|
37
51
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteTextField.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/AutocompleteTextField.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 */\n\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport TextField from '@material-ui/core/TextField';\nimport { TextFieldProps } from '@material-ui/core/TextField/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { ComponentProps, ReactNode, ChangeEvent, Fragment } from 'react';\nimport { Controller, FieldErrors } from 'react-hook-form';\n\n/**\n * Props for {@link AutocompleteTextField}.\n *\n * @public\n */\nexport interface AutocompleteTextFieldProps<TFieldValue extends string> {\n name: TFieldValue;\n options:
|
|
1
|
+
{"version":3,"file":"AutocompleteTextField.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/AutocompleteTextField.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 */\n\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport TextField from '@material-ui/core/TextField';\nimport { TextFieldProps } from '@material-ui/core/TextField/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { ComponentProps, ReactNode, ChangeEvent, Fragment } from 'react';\nimport { Controller, FieldErrors } from 'react-hook-form';\n\n/**\n * An option of {@link AutocompleteTextField}.\n *\n * Plain strings are used both as the visible label and as the selected value,\n * while the object form allows the option to be presented with a different\n * label than the value it selects.\n *\n * @public\n */\nexport type AutocompleteTextFieldOption =\n | string\n | { label: string; id: string };\n\nfunction optionLabel(option: AutocompleteTextFieldOption): string {\n return typeof option === 'string' ? option : option.label;\n}\n\n/**\n * Resolves the value that is stored in the form for a selection.\n *\n * `autoSelect` combined with `freeSolo` makes the autocompletion emit the raw\n * input string rather than the option object, both when an option is picked\n * from the list and when the field is blurred. Labelled options are therefore\n * matched back to their id, so that the form never stores a display label.\n */\nfunction optionValue(\n value: AutocompleteTextFieldOption | null,\n options: AutocompleteTextFieldOption[],\n): string | null {\n if (value === null) {\n return null;\n }\n if (typeof value !== 'string') {\n return value.id;\n }\n const option = options.find(o => typeof o !== 'string' && o.label === value);\n return option && typeof option !== 'string' ? option.id : value;\n}\n\n/**\n * Props for {@link AutocompleteTextField}.\n *\n * @public\n */\nexport interface AutocompleteTextFieldProps<TFieldValue extends string> {\n name: TFieldValue;\n options: AutocompleteTextFieldOption[];\n required?: boolean;\n\n errors?: FieldErrors;\n rules?: ComponentProps<typeof Controller>['rules'];\n\n loading?: boolean;\n loadingText?: string;\n\n helperText?: ReactNode;\n errorHelperText?: string;\n\n textFieldProps?: Omit<TextFieldProps, 'required' | 'fullWidth'>;\n}\n\n/**\n * An autocompletion text field for the catalog import flows.\n *\n * @public\n */\nexport const AutocompleteTextField = <TFieldValue extends string>(\n props: AutocompleteTextFieldProps<TFieldValue>,\n) => {\n const {\n name,\n options,\n required,\n errors,\n rules,\n loading = false,\n loadingText,\n helperText,\n errorHelperText,\n textFieldProps = {},\n } = props;\n\n return (\n <Controller\n name={name}\n rules={rules}\n render={({ field: { onChange } }) => (\n <Autocomplete\n loading={loading}\n loadingText={loadingText}\n options={options || []}\n autoSelect\n freeSolo\n getOptionLabel={optionLabel}\n onChange={(\n _event: ChangeEvent<{}>,\n value: AutocompleteTextFieldOption | null,\n ) => onChange(optionValue(value, options))}\n renderInput={params => (\n <TextField\n {...params}\n helperText={(errors?.[name] && errorHelperText) || helperText}\n error={Boolean(errors?.[name])}\n margin=\"normal\"\n variant=\"outlined\"\n required={required}\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <Fragment>\n {loading ? (\n <CircularProgress color=\"inherit\" size=\"1em\" />\n ) : null}\n {params.InputProps.endAdornment}\n </Fragment>\n ),\n }}\n {...textFieldProps}\n />\n )}\n />\n )}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;AAoCA,SAAS,YAAY,MAAA,EAA6C;AAChE,EAAA,OAAO,OAAO,MAAA,KAAW,QAAA,GAAW,MAAA,GAAS,MAAA,CAAO,KAAA;AACtD;AAUA,SAAS,WAAA,CACP,OACA,OAAA,EACe;AACf,EAAA,IAAI,UAAU,IAAA,EAAM;AAClB,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO,KAAA,CAAM,EAAA;AAAA,EACf;AACA,EAAA,MAAM,MAAA,GAAS,QAAQ,IAAA,CAAK,CAAA,CAAA,KAAK,OAAO,CAAA,KAAM,QAAA,IAAY,CAAA,CAAE,KAAA,KAAU,K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QAAA,EAAA;AAAA,kBAAA,OAAA,uBACE,gBAAA,EAAA,EAAiB,KAAA,EAAM,SAAA,EAAU,IAAA,EAAK,OAAM,CAAA,GAC3C,IAAA;AAAA,kBACH,OAAO,UAAA,CAAW;AAAA,iBAAA,EACrB;AAAA,eAEJ;AAAA,cACC,GAAG;AAAA;AAAA;AACN;AAAA;AAEJ;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useApi, errorApiRef } from '@backstage/core-plugin-api';
|
|
3
3
|
import { toError } from '@backstage/errors';
|
|
4
4
|
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
5
|
-
import { catalogApiRef, entityPresentationApiRef } from '@backstage/plugin-catalog-react';
|
|
5
|
+
import { catalogApiRef, entityPresentationApiRef, humanizeEntityRef } from '@backstage/plugin-catalog-react';
|
|
6
6
|
import Box from '@material-ui/core/Box';
|
|
7
7
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
|
8
8
|
import Grid from '@material-ui/core/Grid';
|
|
@@ -73,12 +73,18 @@ const StepPrepareCreatePullRequest = (props) => {
|
|
|
73
73
|
const groupEntities = await catalogApi.getEntities({
|
|
74
74
|
filter: { kind: "group" }
|
|
75
75
|
});
|
|
76
|
-
const
|
|
77
|
-
groupEntities.items.map(
|
|
78
|
-
(
|
|
79
|
-
|
|
76
|
+
const options = await Promise.all(
|
|
77
|
+
groupEntities.items.map(async (entity) => ({
|
|
78
|
+
label: (await entityPresentationApi.forEntity(entity, {
|
|
79
|
+
defaultKind: "group"
|
|
80
|
+
}).promise).primaryTitle,
|
|
81
|
+
// The selected value is written verbatim to `spec.owner` of the
|
|
82
|
+
// generated entity, so it has to be an entity reference rather than a
|
|
83
|
+
// display name.
|
|
84
|
+
id: humanizeEntityRef(entity, { defaultKind: "group" })
|
|
85
|
+
}))
|
|
80
86
|
);
|
|
81
|
-
return
|
|
87
|
+
return options.sort((a, b) => a.label.localeCompare(b.label));
|
|
82
88
|
});
|
|
83
89
|
const handleResult = useCallback(
|
|
84
90
|
async (data) => {
|
package/dist/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepPrepareCreatePullRequest.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.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 */\n\nimport { Entity } from '@backstage/catalog-model';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { toError } from '@backstage/errors';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport {\n catalogApiRef,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport Box from '@material-ui/core/Box';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ReactNode, useCallback, useEffect, useState } from 'react';\nimport { NestedValue, UseFormReturn } from 'react-hook-form';\nimport useAsync from 'react-use/esm/useAsync';\nimport YAML from 'yaml';\n\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\nimport { catalogImportTranslationRef } from '../../translation';\nimport { PartialEntity } from '../../types';\nimport { BackButton, NextButton } from '../Buttons';\nimport { PrepareResult } from '../useImportState';\nimport { PreparePullRequestForm } from './PreparePullRequestForm';\nimport { PreviewCatalogInfoComponent } from './PreviewCatalogInfoComponent';\nimport { PreviewPullRequestComponent } from './PreviewPullRequestComponent';\n\nconst useStyles = makeStyles(theme => ({\n previewCard: {\n marginTop: theme.spacing(1),\n },\n previewCardContent: {\n paddingTop: 0,\n },\n}));\n\ntype FormData = {\n title: string;\n body: string;\n componentName: string;\n owner: string;\n useCodeowners: boolean;\n};\n\n/**\n * Helper for unpacking NestedValue into the underlying type.\n *\n * @public\n * @deprecated This is a copy of the type from react-hook-form, and will be removed in a future release\n */\nexport type UnpackNestedValue<T> = T extends NestedValue<infer U>\n ? U\n : T extends Date | FileList | File | Blob\n ? T\n : T extends object\n ? {\n [K in keyof T]: UnpackNestedValue<T[K]>;\n }\n : T;\n\n/**\n * Props for {@link StepPrepareCreatePullRequest}.\n *\n * @public\n */\nexport interface StepPrepareCreatePullRequestProps {\n analyzeResult: Extract<AnalyzeResult, { type: 'repository' }>;\n onPrepare: (\n result: PrepareResult,\n opts?: { notRepeatable?: boolean },\n ) => void;\n onGoBack?: () => void;\n\n renderFormFields: (\n props: Pick<\n UseFormReturn<FormData>,\n 'register' | 'setValue' | 'formState'\n > & {\n values: UnpackNestedValue<FormData>;\n groups: string[];\n groupsLoading: boolean;\n },\n ) => ReactNode;\n}\n\nexport function generateEntities(\n entities: PartialEntity[],\n componentName: string,\n owner?: string,\n): Entity[] {\n return entities.map(e => ({\n ...e,\n apiVersion: e.apiVersion!,\n kind: e.kind!,\n metadata: {\n ...e.metadata,\n name: componentName,\n },\n spec: {\n ...e.spec,\n ...(owner ? { owner } : {}),\n },\n }));\n}\n\n/**\n * Prepares a pull request.\n *\n * @public\n */\nexport const StepPrepareCreatePullRequest = (\n props: StepPrepareCreatePullRequestProps,\n) => {\n const { analyzeResult, onPrepare, onGoBack, renderFormFields } = props;\n\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const classes = useStyles();\n const catalogApi = useApi(catalogApiRef);\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const catalogImportApi = useApi(catalogImportApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string>();\n\n const catalogFilename = useCatalogFilename();\n\n const {\n loading: prDefaultsLoading,\n value: prDefaults,\n error: prDefaultsError,\n } = useAsync(\n () => catalogImportApi.preparePullRequest!(),\n [catalogImportApi.preparePullRequest],\n );\n\n useEffect(() => {\n if (prDefaultsError) {\n errorApi.post(prDefaultsError);\n }\n }, [prDefaultsError, errorApi]);\n\n const { loading: groupsLoading, value: groups } = useAsync(async () => {\n const groupEntities = await catalogApi.getEntities({\n filter: { kind: 'group' },\n });\n\n const presentations = await Promise.all(\n groupEntities.items.map(\n e =>\n entityPresentationApi.forEntity(e, { defaultKind: 'group' }).promise,\n ),\n );\n return presentations.map(p => p.primaryTitle).sort();\n });\n\n const handleResult = useCallback(\n async (data: FormData) => {\n setSubmitted(true);\n\n try {\n const pr = await catalogImportApi.submitPullRequest({\n repositoryUrl: analyzeResult.url,\n title: data.title,\n body: data.body,\n fileContent: generateEntities(\n analyzeResult.generatedEntities,\n data.componentName,\n data.owner,\n )\n .map(e => YAML.stringify(e))\n .join('---\\n'),\n });\n\n onPrepare(\n {\n type: 'repository',\n url: analyzeResult.url,\n integrationType: analyzeResult.integrationType,\n pullRequest: {\n url: pr.link,\n },\n locations: [\n {\n target: pr.location,\n entities: generateEntities(\n analyzeResult.generatedEntities,\n data.componentName,\n data.owner,\n ).map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace!,\n name: e.metadata.name,\n })),\n },\n ],\n },\n { notRepeatable: true },\n );\n } catch (e) {\n setError(toError(e).message);\n setSubmitted(false);\n }\n },\n [\n analyzeResult.generatedEntities,\n analyzeResult.integrationType,\n analyzeResult.url,\n catalogImportApi,\n onPrepare,\n ],\n );\n\n return (\n <>\n <Typography>\n {t('stepPrepareCreatePullRequest.description', {\n integrationType: analyzeResult.integrationType,\n catalogFilename: <code>{catalogFilename}</code>,\n })}\n </Typography>\n\n {!prDefaultsLoading && (\n <PreparePullRequestForm<FormData>\n onSubmit={handleResult}\n defaultValues={{\n title: prDefaults?.title ?? '',\n body: prDefaults?.body ?? '',\n owner:\n (analyzeResult.generatedEntities[0]?.spec?.owner as string) || '',\n componentName:\n analyzeResult.generatedEntities[0]?.metadata?.name || '',\n useCodeowners: false,\n }}\n render={({ values, formState, register, setValue }) => (\n <>\n {renderFormFields({\n values,\n formState,\n register,\n setValue,\n groups: groups ?? [],\n groupsLoading,\n })}\n\n <Box marginTop={2}>\n <Typography variant=\"h6\">\n {t('stepPrepareCreatePullRequest.previewPr.title')}\n </Typography>\n </Box>\n\n <PreviewPullRequestComponent\n title={values.title}\n description={values.body}\n classes={{\n card: classes.previewCard,\n cardContent: classes.previewCardContent,\n }}\n />\n\n <Box marginTop={2} marginBottom={1}>\n <Typography variant=\"h6\">\n {t('stepPrepareCreatePullRequest.previewCatalogInfo.title')}\n </Typography>\n </Box>\n\n <PreviewCatalogInfoComponent\n entities={generateEntities(\n analyzeResult.generatedEntities,\n values.componentName,\n values.owner,\n )}\n repositoryUrl={analyzeResult.url}\n classes={{\n card: classes.previewCard,\n cardContent: classes.previewCardContent,\n }}\n />\n\n {error && <FormHelperText error>{error}</FormHelperText>}\n\n <Grid container spacing={0}>\n {onGoBack && (\n <BackButton onClick={onGoBack} disabled={submitted} />\n )}\n <NextButton\n type=\"submit\"\n disabled={Boolean(\n formState.errors.title ||\n formState.errors.body ||\n formState.errors.owner,\n )}\n loading={submitted}\n >\n {t('stepPrepareCreatePullRequest.nextButtonText')}\n </NextButton>\n </Grid>\n </>\n )}\n />\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,WAAA,EAAa;AAAA,IACX,SAAA,EAAW,KAAA,CAAM,OAAA,CAAQ,CAAC;AAAA,GAC5B;AAAA,EACA,kBAAA,EAAoB;AAAA,IAClB,UAAA,EAAY;AAAA;AAEhB,CAAA,CA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epPrepareCreatePullRequest/StepPrepareCreatePullRequest.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 */\n\nimport { Entity } from '@backstage/catalog-model';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { toError } from '@backstage/errors';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport {\n catalogApiRef,\n entityPresentationApiRef,\n humanizeEntityRef,\n} from '@backstage/plugin-catalog-react';\nimport Box from '@material-ui/core/Box';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ReactNode, useCallback, useEffect, useState } from 'react';\nimport { NestedValue, UseFormReturn } from 'react-hook-form';\nimport useAsync from 'react-use/esm/useAsync';\nimport YAML from 'yaml';\n\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\nimport { catalogImportTranslationRef } from '../../translation';\nimport { PartialEntity } from '../../types';\nimport { BackButton, NextButton } from '../Buttons';\nimport { PrepareResult } from '../useImportState';\nimport { PreparePullRequestForm } from './PreparePullRequestForm';\nimport { PreviewCatalogInfoComponent } from './PreviewCatalogInfoComponent';\nimport { PreviewPullRequestComponent } from './PreviewPullRequestComponent';\nimport { AutocompleteTextFieldOption } from './AutocompleteTextField';\n\nconst useStyles = makeStyles(theme => ({\n previewCard: {\n marginTop: theme.spacing(1),\n },\n previewCardContent: {\n paddingTop: 0,\n },\n}));\n\ntype FormData = {\n title: string;\n body: string;\n componentName: string;\n owner: string;\n useCodeowners: boolean;\n};\n\n/**\n * Helper for unpacking NestedValue into the underlying type.\n *\n * @public\n * @deprecated This is a copy of the type from react-hook-form, and will be removed in a future release\n */\nexport type UnpackNestedValue<T> = T extends NestedValue<infer U>\n ? U\n : T extends Date | FileList | File | Blob\n ? T\n : T extends object\n ? {\n [K in keyof T]: UnpackNestedValue<T[K]>;\n }\n : T;\n\n/**\n * Props for {@link StepPrepareCreatePullRequest}.\n *\n * @public\n */\nexport interface StepPrepareCreatePullRequestProps {\n analyzeResult: Extract<AnalyzeResult, { type: 'repository' }>;\n onPrepare: (\n result: PrepareResult,\n opts?: { notRepeatable?: boolean },\n ) => void;\n onGoBack?: () => void;\n\n renderFormFields: (\n props: Pick<\n UseFormReturn<FormData>,\n 'register' | 'setValue' | 'formState'\n > & {\n values: UnpackNestedValue<FormData>;\n groups: AutocompleteTextFieldOption[];\n groupsLoading: boolean;\n },\n ) => ReactNode;\n}\n\nexport function generateEntities(\n entities: PartialEntity[],\n componentName: string,\n owner?: string,\n): Entity[] {\n return entities.map(e => ({\n ...e,\n apiVersion: e.apiVersion!,\n kind: e.kind!,\n metadata: {\n ...e.metadata,\n name: componentName,\n },\n spec: {\n ...e.spec,\n ...(owner ? { owner } : {}),\n },\n }));\n}\n\n/**\n * Prepares a pull request.\n *\n * @public\n */\nexport const StepPrepareCreatePullRequest = (\n props: StepPrepareCreatePullRequestProps,\n) => {\n const { analyzeResult, onPrepare, onGoBack, renderFormFields } = props;\n\n const { t } = useTranslationRef(catalogImportTranslationRef);\n const classes = useStyles();\n const catalogApi = useApi(catalogApiRef);\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const catalogImportApi = useApi(catalogImportApiRef);\n const errorApi = useApi(errorApiRef);\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string>();\n\n const catalogFilename = useCatalogFilename();\n\n const {\n loading: prDefaultsLoading,\n value: prDefaults,\n error: prDefaultsError,\n } = useAsync(\n () => catalogImportApi.preparePullRequest!(),\n [catalogImportApi.preparePullRequest],\n );\n\n useEffect(() => {\n if (prDefaultsError) {\n errorApi.post(prDefaultsError);\n }\n }, [prDefaultsError, errorApi]);\n\n const { loading: groupsLoading, value: groups } = useAsync(async () => {\n const groupEntities = await catalogApi.getEntities({\n filter: { kind: 'group' },\n });\n\n const options = await Promise.all(\n groupEntities.items.map(async entity => ({\n label: (\n await entityPresentationApi.forEntity(entity, {\n defaultKind: 'group',\n }).promise\n ).primaryTitle,\n // The selected value is written verbatim to `spec.owner` of the\n // generated entity, so it has to be an entity reference rather than a\n // display name.\n id: humanizeEntityRef(entity, { defaultKind: 'group' }),\n })),\n );\n\n return options.sort((a, b) => a.label.localeCompare(b.label));\n });\n\n const handleResult = useCallback(\n async (data: FormData) => {\n setSubmitted(true);\n\n try {\n const pr = await catalogImportApi.submitPullRequest({\n repositoryUrl: analyzeResult.url,\n title: data.title,\n body: data.body,\n fileContent: generateEntities(\n analyzeResult.generatedEntities,\n data.componentName,\n data.owner,\n )\n .map(e => YAML.stringify(e))\n .join('---\\n'),\n });\n\n onPrepare(\n {\n type: 'repository',\n url: analyzeResult.url,\n integrationType: analyzeResult.integrationType,\n pullRequest: {\n url: pr.link,\n },\n locations: [\n {\n target: pr.location,\n entities: generateEntities(\n analyzeResult.generatedEntities,\n data.componentName,\n data.owner,\n ).map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace!,\n name: e.metadata.name,\n })),\n },\n ],\n },\n { notRepeatable: true },\n );\n } catch (e) {\n setError(toError(e).message);\n setSubmitted(false);\n }\n },\n [\n analyzeResult.generatedEntities,\n analyzeResult.integrationType,\n analyzeResult.url,\n catalogImportApi,\n onPrepare,\n ],\n );\n\n return (\n <>\n <Typography>\n {t('stepPrepareCreatePullRequest.description', {\n integrationType: analyzeResult.integrationType,\n catalogFilename: <code>{catalogFilename}</code>,\n })}\n </Typography>\n\n {!prDefaultsLoading && (\n <PreparePullRequestForm<FormData>\n onSubmit={handleResult}\n defaultValues={{\n title: prDefaults?.title ?? '',\n body: prDefaults?.body ?? '',\n owner:\n (analyzeResult.generatedEntities[0]?.spec?.owner as string) || '',\n componentName:\n analyzeResult.generatedEntities[0]?.metadata?.name || '',\n useCodeowners: false,\n }}\n render={({ values, formState, register, setValue }) => (\n <>\n {renderFormFields({\n values,\n formState,\n register,\n setValue,\n groups: groups ?? [],\n groupsLoading,\n })}\n\n <Box marginTop={2}>\n <Typography variant=\"h6\">\n {t('stepPrepareCreatePullRequest.previewPr.title')}\n </Typography>\n </Box>\n\n <PreviewPullRequestComponent\n title={values.title}\n description={values.body}\n classes={{\n card: classes.previewCard,\n cardContent: classes.previewCardContent,\n }}\n />\n\n <Box marginTop={2} marginBottom={1}>\n <Typography variant=\"h6\">\n {t('stepPrepareCreatePullRequest.previewCatalogInfo.title')}\n </Typography>\n </Box>\n\n <PreviewCatalogInfoComponent\n entities={generateEntities(\n analyzeResult.generatedEntities,\n values.componentName,\n values.owner,\n )}\n repositoryUrl={analyzeResult.url}\n classes={{\n card: classes.previewCard,\n cardContent: classes.previewCardContent,\n }}\n />\n\n {error && <FormHelperText error>{error}</FormHelperText>}\n\n <Grid container spacing={0}>\n {onGoBack && (\n <BackButton onClick={onGoBack} disabled={submitted} />\n )}\n <NextButton\n type=\"submit\"\n disabled={Boolean(\n formState.errors.title ||\n formState.errors.body ||\n formState.errors.owner,\n )}\n loading={submitted}\n >\n {t('stepPrepareCreatePullRequest.nextButtonText')}\n </NextButton>\n </Grid>\n </>\n )}\n />\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,SAAA,GAAY,WAAW,CAAA,KAAA,MAAU;AAAA,EACrC,WAAA,EAAa;AAAA,IACX,SAAA,EAAW,KAAA,CAAM,OAAA,CAAQ,CAAC;AAAA,GAC5B;AAAA,EACA,kBAAA,EAAoB;AAAA,IAClB,UAAA,EAAY;AAAA;AAEhB,CAAA,CAAE,CAAA;AAmDK,SAAS,gBAAA,CACd,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E,6CAA6C;AAAA;AAAA;AAClD,WAAA,EACF;AAAA,SAAA,EACF;AAAA;AAAA;AAEJ,GAAA,EAEJ,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -340,6 +340,19 @@ interface StepInitAnalyzeUrlProps {
|
|
|
340
340
|
*/
|
|
341
341
|
declare const StepInitAnalyzeUrl: (props: StepInitAnalyzeUrlProps) => react_jsx_runtime.JSX.Element;
|
|
342
342
|
|
|
343
|
+
/**
|
|
344
|
+
* An option of {@link AutocompleteTextField}.
|
|
345
|
+
*
|
|
346
|
+
* Plain strings are used both as the visible label and as the selected value,
|
|
347
|
+
* while the object form allows the option to be presented with a different
|
|
348
|
+
* label than the value it selects.
|
|
349
|
+
*
|
|
350
|
+
* @public
|
|
351
|
+
*/
|
|
352
|
+
type AutocompleteTextFieldOption = string | {
|
|
353
|
+
label: string;
|
|
354
|
+
id: string;
|
|
355
|
+
};
|
|
343
356
|
/**
|
|
344
357
|
* Props for {@link AutocompleteTextField}.
|
|
345
358
|
*
|
|
@@ -347,7 +360,7 @@ declare const StepInitAnalyzeUrl: (props: StepInitAnalyzeUrlProps) => react_jsx_
|
|
|
347
360
|
*/
|
|
348
361
|
interface AutocompleteTextFieldProps<TFieldValue extends string> {
|
|
349
362
|
name: TFieldValue;
|
|
350
|
-
options:
|
|
363
|
+
options: AutocompleteTextFieldOption[];
|
|
351
364
|
required?: boolean;
|
|
352
365
|
errors?: FieldErrors;
|
|
353
366
|
rules?: ComponentProps<typeof Controller>['rules'];
|
|
@@ -458,7 +471,7 @@ interface StepPrepareCreatePullRequestProps {
|
|
|
458
471
|
onGoBack?: () => void;
|
|
459
472
|
renderFormFields: (props: Pick<UseFormReturn<FormData>, 'register' | 'setValue' | 'formState'> & {
|
|
460
473
|
values: UnpackNestedValue<FormData>;
|
|
461
|
-
groups:
|
|
474
|
+
groups: AutocompleteTextFieldOption[];
|
|
462
475
|
groupsLoading: boolean;
|
|
463
476
|
}) => ReactNode;
|
|
464
477
|
}
|
|
@@ -540,4 +553,4 @@ declare const catalogImportTranslationRef: _backstage_frontend_plugin_api.Transl
|
|
|
540
553
|
}>;
|
|
541
554
|
|
|
542
555
|
export { AutocompleteTextField, CatalogImportClient, CatalogImportPage, DefaultImportPage, EntityListComponent, ImportInfoCard, ImportStepper, PreparePullRequestForm, PreviewCatalogInfoComponent, PreviewPullRequestComponent, StepInitAnalyzeUrl, StepPrepareCreatePullRequest, catalogImportApiRef, catalogImportPlugin, catalogImportTranslationRef, defaultGenerateStepper, catalogImportPlugin as plugin };
|
|
543
|
-
export type { AnalyzeResult, AutocompleteTextFieldProps, CatalogImportApi, EntityListComponentProps, ImportFlows, ImportInfoCardProps, ImportState, ImportStepperProps, PreparePullRequestFormProps, PrepareResult, PreviewCatalogInfoComponentProps, PreviewPullRequestComponentProps, StepInitAnalyzeUrlProps, StepPrepareCreatePullRequestProps, UnpackNestedValue };
|
|
556
|
+
export type { AnalyzeResult, AutocompleteTextFieldOption, AutocompleteTextFieldProps, CatalogImportApi, EntityListComponentProps, ImportFlows, ImportInfoCardProps, ImportState, ImportStepperProps, PreparePullRequestFormProps, PrepareResult, PreviewCatalogInfoComponentProps, PreviewPullRequestComponentProps, StepInitAnalyzeUrlProps, StepPrepareCreatePullRequestProps, UnpackNestedValue };
|
package/dist/package.json.esm.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-import",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.17",
|
|
4
4
|
"description": "A Backstage plugin the helps you import entities into your catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@backstage/integration": "^2.1.0",
|
|
77
77
|
"@backstage/integration-react": "^1.2.21",
|
|
78
78
|
"@backstage/plugin-catalog-common": "^1.1.10",
|
|
79
|
-
"@backstage/plugin-catalog-react": "^3.2.
|
|
79
|
+
"@backstage/plugin-catalog-react": "^3.2.2",
|
|
80
80
|
"@backstage/plugin-permission-react": "^0.5.4",
|
|
81
81
|
"@material-ui/core": "^4.12.2",
|
|
82
82
|
"@material-ui/icons": "^4.9.1",
|