@backstage/plugin-catalog-import 0.12.6-next.0 → 0.12.6-next.2
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 +37 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api/AzureDevops.esm.js.map +1 -1
- package/dist/api/AzureRepoApiClient.esm.js.map +1 -1
- package/dist/api/CatalogImportApi.esm.js.map +1 -1
- package/dist/api/CatalogImportClient.esm.js +9 -7
- package/dist/api/CatalogImportClient.esm.js.map +1 -1
- package/dist/api/GitHub.esm.js.map +1 -1
- package/dist/components/Buttons/index.esm.js.map +1 -1
- package/dist/components/DefaultImportPage/DefaultImportPage.esm.js.map +1 -1
- package/dist/components/EntityListComponent/EntityListComponent.esm.js.map +1 -1
- package/dist/components/ImportInfoCard/ImportInfoCard.esm.js.map +1 -1
- package/dist/components/ImportPage/ImportPage.esm.js.map +1 -1
- package/dist/components/ImportStepper/ImportStepper.esm.js.map +1 -1
- package/dist/components/ImportStepper/defaults.esm.js.map +1 -1
- package/dist/components/StepFinishImportLocation/StepFinishImportLocation.esm.js.map +1 -1
- package/dist/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/AutocompleteTextField.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/PreparePullRequestForm.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/PreviewCatalogInfoComponent.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/PreviewPullRequestComponent.esm.js.map +1 -1
- package/dist/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.esm.js.map +1 -1
- package/dist/components/StepPrepareSelectLocations/StepPrepareSelectLocations.esm.js.map +1 -1
- package/dist/components/StepReviewLocation/StepReviewLocation.esm.js.map +1 -1
- package/dist/components/helpers.esm.js.map +1 -1
- package/dist/components/useImportState.esm.js.map +1 -1
- package/dist/hooks/useCatalogFilename.esm.js.map +1 -1
- package/dist/plugin.esm.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-import
|
|
2
2
|
|
|
3
|
+
## 0.12.6-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ea5b7f3: Fixed parsing of catalog-info.yaml when creating a PR to register a repository if the file contains more than one document
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/catalog-client@1.8.0-next.1
|
|
10
|
+
- @backstage/plugin-catalog-react@1.14.1-next.2
|
|
11
|
+
- @backstage/catalog-model@1.7.0
|
|
12
|
+
- @backstage/config@1.2.0
|
|
13
|
+
- @backstage/core-compat-api@0.3.2-next.1
|
|
14
|
+
- @backstage/core-components@0.16.0-next.1
|
|
15
|
+
- @backstage/core-plugin-api@1.10.0
|
|
16
|
+
- @backstage/errors@1.2.4
|
|
17
|
+
- @backstage/frontend-plugin-api@0.9.1-next.1
|
|
18
|
+
- @backstage/integration@1.15.1
|
|
19
|
+
- @backstage/integration-react@1.2.0
|
|
20
|
+
- @backstage/plugin-catalog-common@1.1.0
|
|
21
|
+
|
|
22
|
+
## 0.12.6-next.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/catalog-client@1.8.0-next.0
|
|
28
|
+
- @backstage/catalog-model@1.7.0
|
|
29
|
+
- @backstage/config@1.2.0
|
|
30
|
+
- @backstage/core-compat-api@0.3.2-next.1
|
|
31
|
+
- @backstage/core-components@0.16.0-next.1
|
|
32
|
+
- @backstage/core-plugin-api@1.10.0
|
|
33
|
+
- @backstage/errors@1.2.4
|
|
34
|
+
- @backstage/frontend-plugin-api@0.9.1-next.1
|
|
35
|
+
- @backstage/integration@1.15.1
|
|
36
|
+
- @backstage/integration-react@1.2.0
|
|
37
|
+
- @backstage/plugin-catalog-common@1.1.0
|
|
38
|
+
- @backstage/plugin-catalog-react@1.14.1-next.1
|
|
39
|
+
|
|
3
40
|
## 0.12.6-next.0
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configApiRef,\n createApiFactory,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n createFrontendPlugin,\n PageBlueprint,\n ApiBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport React from 'react';\nimport { CatalogImportClient, catalogImportApiRef } from './api';\nimport { rootRouteRef } from './plugin';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\n// TODO: It's currently possible to override the import page with a custom one. We need to decide\n// whether this type of override is typically done with an input or by overriding the entire extension.\nconst catalogImportPage = PageBlueprint.make({\n params: {\n defaultPath: '/catalog-import',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: () =>\n import('./components/ImportPage').then(m =>\n compatWrapper(<m.ImportPage />),\n ),\n },\n});\n\nconst catalogImportApi = ApiBlueprint.make({\n params: {\n factory: createApiFactory({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n },\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n id: 'catalog-import',\n extensions: [catalogImportApi, catalogImportPage],\n routes: {\n importPage: convertLegacyRouteRef(rootRouteRef),\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;AA0CA,MAAM,iBAAA,GAAoB,cAAc,IAAK,CAAA;AAAA,EAC3C,MAAQ,EAAA;AAAA,IACN,WAAa,EAAA,iBAAA;AAAA,IACb,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,MAAQ,EAAA,MACN,OAAO,sCAAyB,CAAE,CAAA,IAAA;AAAA,MAAK,OACrC,aAAc,iBAAA,KAAA,CAAA,aAAA,CAAC,CAAE,CAAA,UAAA,EAAF,IAAa,CAAE
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configApiRef,\n createApiFactory,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n createFrontendPlugin,\n PageBlueprint,\n ApiBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport React from 'react';\nimport { CatalogImportClient, catalogImportApiRef } from './api';\nimport { rootRouteRef } from './plugin';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\n// TODO: It's currently possible to override the import page with a custom one. We need to decide\n// whether this type of override is typically done with an input or by overriding the entire extension.\nconst catalogImportPage = PageBlueprint.make({\n params: {\n defaultPath: '/catalog-import',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: () =>\n import('./components/ImportPage').then(m =>\n compatWrapper(<m.ImportPage />),\n ),\n },\n});\n\nconst catalogImportApi = ApiBlueprint.make({\n params: {\n factory: createApiFactory({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n },\n});\n\n/** @alpha */\nexport default createFrontendPlugin({\n id: 'catalog-import',\n extensions: [catalogImportApi, catalogImportPage],\n routes: {\n importPage: convertLegacyRouteRef(rootRouteRef),\n },\n});\n"],"names":[],"mappings":";;;;;;;;;;AA0CA,MAAM,iBAAA,GAAoB,cAAc,IAAK,CAAA;AAAA,EAC3C,MAAQ,EAAA;AAAA,IACN,WAAa,EAAA,iBAAA;AAAA,IACb,QAAA,EAAU,sBAAsB,YAAY,CAAA;AAAA,IAC5C,MAAQ,EAAA,MACN,OAAO,sCAAyB,CAAE,CAAA,IAAA;AAAA,MAAK,OACrC,aAAc,iBAAA,KAAA,CAAA,aAAA,CAAC,CAAE,CAAA,UAAA,EAAF,IAAa,CAAE;AAAA;AAChC;AAEN,CAAC,CAAA;AAED,MAAM,gBAAA,GAAmB,aAAa,IAAK,CAAA;AAAA,EACzC,MAAQ,EAAA;AAAA,IACN,SAAS,gBAAiB,CAAA;AAAA,MACxB,GAAK,EAAA,mBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,UAAY,EAAA,aAAA;AAAA,QACZ,QAAU,EAAA,WAAA;AAAA,QACV,kBAAoB,EAAA,qBAAA;AAAA,QACpB,UAAY,EAAA,aAAA;AAAA,QACZ,SAAW,EAAA;AAAA,OACb;AAAA,MACA,SAAS,CAAC;AAAA,QACR,YAAA;AAAA,QACA,UAAA;AAAA,QACA,QAAA;AAAA,QACA,kBAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OACF,KACE,IAAI,mBAAoB,CAAA;AAAA,QACtB,YAAA;AAAA,QACA,UAAA;AAAA,QACA,kBAAA;AAAA,QACA,QAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OACD;AAAA,KACJ;AAAA;AAEL,CAAC,CAAA;AAGD,YAAe,oBAAqB,CAAA;AAAA,EAClC,EAAI,EAAA,gBAAA;AAAA,EACJ,UAAA,EAAY,CAAC,gBAAA,EAAkB,iBAAiB,CAAA;AAAA,EAChD,MAAQ,EAAA;AAAA,IACN,UAAA,EAAY,sBAAsB,YAAY;AAAA;AAElD,CAAC,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureDevops.esm.js","sources":["../../src/api/AzureDevops.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { createAzurePullRequest } from './AzureRepoApiClient';\n\nexport interface AzureRepoParts {\n tenantUrl: string;\n repoName: string;\n project: string;\n}\n\nexport function parseAzureUrl(repoUrl: string): AzureRepoParts {\n const { org, repo, project, host } = parseRepoUrl(repoUrl);\n if (!org || !repo || !project) {\n throw new Error(\n 'Invalid AzureDevops Repository. Please use a valid repository url and try again ',\n );\n }\n const tenantUrl = `https://${host}/${org}`;\n\n return { tenantUrl, repoName: repo, project: project };\n}\n\nexport async function submitAzurePrToRepo(\n options: {\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n },\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n) {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n const { tenantUrl, repoName, project } = parseAzureUrl(repositoryUrl);\n const result = await createAzurePullRequest({\n token,\n fileContent,\n title,\n description: body,\n project,\n repository: repoName,\n branchName,\n tenantUrl,\n fileName,\n });\n const catalogLocation = `${result.repository.webUrl}?path=/${fileName}`;\n const prLocation = `${result.repository.webUrl}/pullrequest/${result.pullRequestId}`;\n return {\n link: prLocation!,\n location: catalogLocation,\n };\n}\n\nexport function parseRepoUrl(sourceUrl: string) {\n const url = new URL(sourceUrl);\n\n let host = url.host;\n let org;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n org = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n org = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n host = `${host}/${parts[1]}`;\n org = parts[2];\n project = parts[3];\n repo = parts[5];\n }\n\n return { host, org, project, repo };\n}\n"],"names":[],"mappings":";;;AA0BO,SAAS,cAAc,OAAiC,EAAA;AAC7D,EAAA,MAAM,EAAE,GAAK,EAAA,IAAA,EAAM,SAAS,IAAK,EAAA,GAAI,aAAa,OAAO,CAAA
|
|
1
|
+
{"version":3,"file":"AzureDevops.esm.js","sources":["../../src/api/AzureDevops.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { createAzurePullRequest } from './AzureRepoApiClient';\n\nexport interface AzureRepoParts {\n tenantUrl: string;\n repoName: string;\n project: string;\n}\n\nexport function parseAzureUrl(repoUrl: string): AzureRepoParts {\n const { org, repo, project, host } = parseRepoUrl(repoUrl);\n if (!org || !repo || !project) {\n throw new Error(\n 'Invalid AzureDevops Repository. Please use a valid repository url and try again ',\n );\n }\n const tenantUrl = `https://${host}/${org}`;\n\n return { tenantUrl, repoName: repo, project: project };\n}\n\nexport async function submitAzurePrToRepo(\n options: {\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n },\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n) {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n const { tenantUrl, repoName, project } = parseAzureUrl(repositoryUrl);\n const result = await createAzurePullRequest({\n token,\n fileContent,\n title,\n description: body,\n project,\n repository: repoName,\n branchName,\n tenantUrl,\n fileName,\n });\n const catalogLocation = `${result.repository.webUrl}?path=/${fileName}`;\n const prLocation = `${result.repository.webUrl}/pullrequest/${result.pullRequestId}`;\n return {\n link: prLocation!,\n location: catalogLocation,\n };\n}\n\nexport function parseRepoUrl(sourceUrl: string) {\n const url = new URL(sourceUrl);\n\n let host = url.host;\n let org;\n let project;\n let repo;\n\n const parts = url.pathname.split('/').map(part => decodeURIComponent(part));\n if (parts[2] === '_git') {\n org = parts[1];\n project = repo = parts[3];\n } else if (parts[3] === '_git') {\n org = parts[1];\n project = parts[2];\n repo = parts[4];\n } else if (parts[4] === '_git') {\n host = `${host}/${parts[1]}`;\n org = parts[2];\n project = parts[3];\n repo = parts[5];\n }\n\n return { host, org, project, repo };\n}\n"],"names":[],"mappings":";;;AA0BO,SAAS,cAAc,OAAiC,EAAA;AAC7D,EAAA,MAAM,EAAE,GAAK,EAAA,IAAA,EAAM,SAAS,IAAK,EAAA,GAAI,aAAa,OAAO,CAAA;AACzD,EAAA,IAAI,CAAC,GAAA,IAAO,CAAC,IAAA,IAAQ,CAAC,OAAS,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA;AAEF,EAAA,MAAM,SAAY,GAAA,CAAA,QAAA,EAAW,IAAI,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA;AAExC,EAAA,OAAO,EAAE,SAAA,EAAW,QAAU,EAAA,IAAA,EAAM,OAAiB,EAAA;AACvD;AAEsB,eAAA,mBAAA,CACpB,OAMA,EAAA,UAAA,EACA,SACA,EAAA;AACA,EAAA,MAAM,EAAE,aAAA,EAAe,WAAa,EAAA,KAAA,EAAO,MAAS,GAAA,OAAA;AAEpD,EAAM,MAAA,UAAA,GAAa,cAAc,SAAS,CAAA;AAC1C,EAAM,MAA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A,GAAA,GAAM,MAAM,CAAC,CAAA;AACb,IAAU,OAAA,GAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,GACf,MAAA,IAAA,KAAA,CAAM,CAAC,CAAA,KAAM,MAAQ,EAAA;AAC9B,IAAA,GAAA,GAAM,MAAM,CAAC,CAAA;AACb,IAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACjB,IAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA,GACL,MAAA,IAAA,KAAA,CAAM,CAAC,CAAA,KAAM,MAAQ,EAAA;AAC9B,IAAA,IAAA,GAAO,CAAG,EAAA,IAAI,CAAI,CAAA,EAAA,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAC1B,IAAA,GAAA,GAAM,MAAM,CAAC,CAAA;AACb,IAAA,OAAA,GAAU,MAAM,CAAC,CAAA;AACjB,IAAA,IAAA,GAAO,MAAM,CAAC,CAAA;AAAA;AAGhB,EAAA,OAAO,EAAE,IAAA,EAAM,GAAK,EAAA,OAAA,EAAS,IAAK,EAAA;AACpC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureRepoApiClient.esm.js","sources":["../../src/api/AzureRepoApiClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface AzurePrOptions {\n tenantUrl: string;\n title: string;\n project: string;\n branchName: string;\n repository: string;\n token: string;\n fileContent: string;\n fileName: string;\n description: string;\n}\n\nexport interface CreateAzurePr {\n sourceRefName: string;\n targetRefName: string;\n title: string;\n description: string;\n}\n\nexport interface AzureRepo {\n id: string;\n name: string;\n defaultBranch: string;\n}\n\nexport interface AzureRef {\n name: string;\n objectId: string;\n}\n\ninterface RefQueryResult {\n value: AzureRef[];\n}\n\nexport interface AzureCommit {\n comment: string;\n\n changes: {\n changeType: string;\n item: {\n path: string;\n };\n newContent: {\n content: string;\n contentType: 'rawtext';\n };\n }[];\n}\n\nexport interface AzureRefUpdate {\n repositoryId: string;\n name: string;\n oldObjectId: string;\n newObjectId: string;\n}\n\nexport interface AzurePushResult {\n refUpdates: AzureRefUpdate[];\n}\n\nexport interface AzurePush {\n refUpdates: {\n name: string;\n oldObjectId: string;\n }[];\n commits: AzureCommit[];\n}\n\nexport interface AzurePrResult {\n pullRequestId: string;\n repository: {\n name: string;\n webUrl: string;\n };\n}\n\nconst apiVersions = '6.0';\n\nexport interface RepoApiClientOptions {\n project: string;\n tenantUrl: string;\n}\n\nexport interface NewBranchOptions {\n fileContent: string;\n fileName: string;\n title: string;\n branchName: string;\n repoName: string;\n sourceBranch: AzureRef;\n}\n\nexport interface CreatePrOptions {\n repoName: string;\n sourceName: string;\n targetName: string;\n description: string;\n title: string;\n}\n\nexport class RepoApiClient {\n private createEndpoint = (\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n ) => {\n const url = new URL(\n `${this._options.tenantUrl}/${this._options.project}/_apis/git/repositories`,\n );\n url.pathname += path;\n\n url.searchParams.set('api-version', version);\n Object.entries(queryParams ?? {}).forEach(([key, value]) =>\n url.searchParams.set(key, value),\n );\n return url.toString();\n };\n\n constructor(private _options: RepoApiClientOptions) {}\n\n private async get<T>(\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version, queryParams);\n const result = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n private async post<T>(\n path: string,\n version: string,\n payload: unknown,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version);\n const result = await fetch(endpoint, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n async getRepository(\n repositoryName: string,\n token: string,\n ): Promise<AzureRepo> {\n return this.get(`/${repositoryName}`, apiVersions, undefined, token);\n }\n\n async getDefaultBranch(repo: AzureRepo, token: string): Promise<AzureRef> {\n const filter = repo.defaultBranch.replace('refs/', '');\n const result: RefQueryResult = await this.get(\n `/${repo.name}/refs`,\n apiVersions,\n { filter },\n token,\n );\n if (!result.value?.length) {\n return Promise.reject(\n new Error(`The requested ref '${filter}' was not found`),\n );\n }\n return result.value[0];\n }\n\n async pushNewBranch(\n options: NewBranchOptions,\n token: string,\n ): Promise<AzureRefUpdate> {\n const { sourceBranch, repoName } = options;\n const push: AzurePush = {\n refUpdates: [\n {\n name: `refs/heads/${options.branchName}`,\n oldObjectId: sourceBranch.objectId,\n },\n ],\n commits: [\n {\n comment: options.title,\n changes: [\n {\n changeType: 'add',\n item: {\n path: `/${options.fileName}`,\n },\n newContent: {\n content: options.fileContent,\n contentType: 'rawtext',\n },\n },\n ],\n },\n ],\n };\n const result = await this.post<AzurePushResult>(\n `/${repoName}/pushes`,\n apiVersions,\n push,\n token,\n );\n return result.refUpdates[0];\n }\n\n async createPullRequest(\n options: CreatePrOptions,\n token: string,\n ): Promise<AzurePrResult> {\n const { repoName, sourceName, targetName } = options;\n const payload: CreateAzurePr = {\n title: options.title,\n description: options.description,\n sourceRefName: sourceName,\n targetRefName: targetName,\n };\n\n return await this.post<AzurePrResult>(\n `/${repoName}/pullrequests`,\n apiVersions,\n payload,\n token,\n );\n }\n}\n\nexport async function createAzurePullRequest(\n options: AzurePrOptions,\n client: RepoApiClient | undefined = undefined,\n): Promise<AzurePrResult> {\n const {\n title,\n repository,\n token,\n fileContent,\n fileName,\n branchName,\n description,\n } = options;\n const actualClient = client ?? new RepoApiClient(options);\n const repo = await actualClient.getRepository(repository, token);\n const defaultBranch = await actualClient.getDefaultBranch(repo, token);\n const branchOptions: NewBranchOptions = {\n title: title,\n repoName: repo.name,\n sourceBranch: defaultBranch,\n branchName: branchName,\n fileContent: fileContent,\n fileName: fileName,\n };\n const refUpdate = await actualClient.pushNewBranch(branchOptions, token);\n const prOptions: CreatePrOptions = {\n title,\n description,\n repoName: repo.name,\n sourceName: refUpdate.name,\n targetName: defaultBranch.name,\n };\n return actualClient.createPullRequest(prOptions, token);\n}\n"],"names":[],"mappings":"AA4FA,MAAM,WAAc,GAAA,KAAA,CAAA;AAwBb,MAAM,aAAc,CAAA;AAAA,EAkBzB,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA,CAAA;AAAA,GAAiC;AAAA,EAjB7C,cAAiB,GAAA,CACvB,IACA,EAAA,OAAA,EACA,cAAkD,KAC/C,CAAA,KAAA;AACH,IAAA,MAAM,MAAM,IAAI,GAAA;AAAA,MACd,GAAG,IAAK,CAAA,QAAA,CAAS,SAAS,CAAI,CAAA,EAAA,IAAA,CAAK,SAAS,OAAO,CAAA,uBAAA,CAAA;AAAA,KACrD,CAAA;AACA,IAAA,GAAA,CAAI,QAAY,IAAA,IAAA,CAAA;AAEhB,IAAI,GAAA,CAAA,YAAA,CAAa,GAAI,CAAA,aAAA,EAAe,OAAO,CAAA,CAAA;AAC3C,IAAA,MAAA,CAAO,OAAQ,CAAA,WAAA,IAAe,EAAE,CAAE,CAAA,OAAA;AAAA,MAAQ,CAAC,CAAC,GAAK,EAAA,KAAK,MACpD,GAAI,CAAA,YAAA,CAAa,GAAI,CAAA,GAAA,EAAK,KAAK,CAAA;AAAA,KACjC,CAAA;AACA,IAAA,OAAO,IAAI,QAAS,EAAA,CAAA;AAAA,GACtB,CAAA;AAAA,EAIA,MAAc,GACZ,CAAA,IAAA,EAC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AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,GACE,GAAA,OAAA,CAAA;AACJ,EAAA,MAAM,YAAe,GAAA,MAAA,IAAU,IAAI,aAAA,CAAc,OAAO,CAAA,CAAA;AACxD,EAAA,MAAM,IAAO,GAAA,MAAM,YAAa,CAAA,aAAA,CAAc,YAAY,KAAK,CAAA,CAAA;AAC/D,EAAA,MAAM,aAAgB,GAAA,MAAM,YAAa,CAAA,gBAAA,CAAiB,MAAM,KAAK,CAAA,CAAA;AACrE,EAAA,MAAM,aAAkC,GAAA;AAAA,IACtC,KAAA;AAAA,IACA,UAAU,IAAK,CAAA,IAAA;AAAA,IACf,YAAc,EAAA,aAAA;AAAA,IACd,UAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,GACF,CAAA;AACA,EAAA,MAAM,SAAY,GAAA,MAAM,YAAa,CAAA,aAAA,CAAc,eAAe,KAAK,CAAA,CAAA;AACvE,EAAA,MAAM,SAA6B,GAAA;AAAA,IACjC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAU,IAAK,CAAA,IAAA;AAAA,IACf,YAAY,SAAU,CAAA,IAAA;AAAA,IACtB,YAAY,aAAc,CAAA,IAAA;AAAA,GAC5B,CAAA;AACA,EAAO,OAAA,YAAA,CAAa,iBAAkB,CAAA,SAAA,EAAW,KAAK,CAAA,CAAA;AACxD;;;;"}
|
|
1
|
+
{"version":3,"file":"AzureRepoApiClient.esm.js","sources":["../../src/api/AzureRepoApiClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface AzurePrOptions {\n tenantUrl: string;\n title: string;\n project: string;\n branchName: string;\n repository: string;\n token: string;\n fileContent: string;\n fileName: string;\n description: string;\n}\n\nexport interface CreateAzurePr {\n sourceRefName: string;\n targetRefName: string;\n title: string;\n description: string;\n}\n\nexport interface AzureRepo {\n id: string;\n name: string;\n defaultBranch: string;\n}\n\nexport interface AzureRef {\n name: string;\n objectId: string;\n}\n\ninterface RefQueryResult {\n value: AzureRef[];\n}\n\nexport interface AzureCommit {\n comment: string;\n\n changes: {\n changeType: string;\n item: {\n path: string;\n };\n newContent: {\n content: string;\n contentType: 'rawtext';\n };\n }[];\n}\n\nexport interface AzureRefUpdate {\n repositoryId: string;\n name: string;\n oldObjectId: string;\n newObjectId: string;\n}\n\nexport interface AzurePushResult {\n refUpdates: AzureRefUpdate[];\n}\n\nexport interface AzurePush {\n refUpdates: {\n name: string;\n oldObjectId: string;\n }[];\n commits: AzureCommit[];\n}\n\nexport interface AzurePrResult {\n pullRequestId: string;\n repository: {\n name: string;\n webUrl: string;\n };\n}\n\nconst apiVersions = '6.0';\n\nexport interface RepoApiClientOptions {\n project: string;\n tenantUrl: string;\n}\n\nexport interface NewBranchOptions {\n fileContent: string;\n fileName: string;\n title: string;\n branchName: string;\n repoName: string;\n sourceBranch: AzureRef;\n}\n\nexport interface CreatePrOptions {\n repoName: string;\n sourceName: string;\n targetName: string;\n description: string;\n title: string;\n}\n\nexport class RepoApiClient {\n private createEndpoint = (\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n ) => {\n const url = new URL(\n `${this._options.tenantUrl}/${this._options.project}/_apis/git/repositories`,\n );\n url.pathname += path;\n\n url.searchParams.set('api-version', version);\n Object.entries(queryParams ?? {}).forEach(([key, value]) =>\n url.searchParams.set(key, value),\n );\n return url.toString();\n };\n\n constructor(private _options: RepoApiClientOptions) {}\n\n private async get<T>(\n path: string,\n version: string,\n queryParams: Record<string, string> | undefined = undefined,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version, queryParams);\n const result = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n private async post<T>(\n path: string,\n version: string,\n payload: unknown,\n token: string,\n ): Promise<T> {\n const endpoint = this.createEndpoint(path, version);\n const result = await fetch(endpoint, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n if (!result.ok) {\n return result.json().then(it => Promise.reject(new Error(it.message)));\n }\n return await result.json();\n }\n\n async getRepository(\n repositoryName: string,\n token: string,\n ): Promise<AzureRepo> {\n return this.get(`/${repositoryName}`, apiVersions, undefined, token);\n }\n\n async getDefaultBranch(repo: AzureRepo, token: string): Promise<AzureRef> {\n const filter = repo.defaultBranch.replace('refs/', '');\n const result: RefQueryResult = await this.get(\n `/${repo.name}/refs`,\n apiVersions,\n { filter },\n token,\n );\n if (!result.value?.length) {\n return Promise.reject(\n new Error(`The requested ref '${filter}' was not found`),\n );\n }\n return result.value[0];\n }\n\n async pushNewBranch(\n options: NewBranchOptions,\n token: string,\n ): Promise<AzureRefUpdate> {\n const { sourceBranch, repoName } = options;\n const push: AzurePush = {\n refUpdates: [\n {\n name: `refs/heads/${options.branchName}`,\n oldObjectId: sourceBranch.objectId,\n },\n ],\n commits: [\n {\n comment: options.title,\n changes: [\n {\n changeType: 'add',\n item: {\n path: `/${options.fileName}`,\n },\n newContent: {\n content: options.fileContent,\n contentType: 'rawtext',\n },\n },\n ],\n },\n ],\n };\n const result = await this.post<AzurePushResult>(\n `/${repoName}/pushes`,\n apiVersions,\n push,\n token,\n );\n return result.refUpdates[0];\n }\n\n async createPullRequest(\n options: CreatePrOptions,\n token: string,\n ): Promise<AzurePrResult> {\n const { repoName, sourceName, targetName } = options;\n const payload: CreateAzurePr = {\n title: options.title,\n description: options.description,\n sourceRefName: sourceName,\n targetRefName: targetName,\n };\n\n return await this.post<AzurePrResult>(\n `/${repoName}/pullrequests`,\n apiVersions,\n payload,\n token,\n );\n }\n}\n\nexport async function createAzurePullRequest(\n options: AzurePrOptions,\n client: RepoApiClient | undefined = undefined,\n): Promise<AzurePrResult> {\n const {\n title,\n repository,\n token,\n fileContent,\n fileName,\n branchName,\n description,\n } = options;\n const actualClient = client ?? new RepoApiClient(options);\n const repo = await actualClient.getRepository(repository, token);\n const defaultBranch = await actualClient.getDefaultBranch(repo, token);\n const branchOptions: NewBranchOptions = {\n title: title,\n repoName: repo.name,\n sourceBranch: defaultBranch,\n branchName: branchName,\n fileContent: fileContent,\n fileName: fileName,\n };\n const refUpdate = await actualClient.pushNewBranch(branchOptions, token);\n const prOptions: CreatePrOptions = {\n title,\n description,\n repoName: repo.name,\n sourceName: refUpdate.name,\n targetName: defaultBranch.name,\n };\n return actualClient.createPullRequest(prOptions, token);\n}\n"],"names":[],"mappings":"AA4FA,MAAM,WAAc,GAAA,KAAA;AAwBb,MAAM,aAAc,CAAA;AAAA,EAkBzB,YAAoB,QAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAAA;AAAiC,EAjB7C,cAAiB,GAAA,CACvB,IACA,EAAA,OAAA,EACA,cAAkD,KAC/C,CAAA,KAAA;AACH,IAAA,MAAM,MAAM,IAAI,GAAA;AAAA,MACd,GAAG,IAAK,CAAA,QAAA,CAAS,SAAS,CAAI,CAAA,EAAA,IAAA,CAAK,SAAS,OAAO,CAAA,uBAAA;AAAA,KACrD;AACA,IAAA,GAAA,CAAI,QAAY,IAAA,IAAA;AAEhB,IAAI,GAAA,CAAA,YAAA,CAAa,GAAI,CAAA,aAAA,EAAe,OAAO,CAAA;AAC3C,IAAA,MAAA,CAAO,OAAQ,CAAA,WAAA,IAAe,EAAE,CAAE,CAAA,OAAA;AAAA,MAAQ,CAAC,CAAC,GAAK,EAAA,KAAK,MACpD,GAAI,CAAA,YAAA,CAAa,GAA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M,IAAO,GAAA,MAAM,YAAa,CAAA,aAAA,CAAc,YAAY,KAAK,CAAA;AAC/D,EAAA,MAAM,aAAgB,GAAA,MAAM,YAAa,CAAA,gBAAA,CAAiB,MAAM,KAAK,CAAA;AACrE,EAAA,MAAM,aAAkC,GAAA;AAAA,IACtC,KAAA;AAAA,IACA,UAAU,IAAK,CAAA,IAAA;AAAA,IACf,YAAc,EAAA,aAAA;AAAA,IACd,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,MAAM,SAAY,GAAA,MAAM,YAAa,CAAA,aAAA,CAAc,eAAe,KAAK,CAAA;AACvE,EAAA,MAAM,SAA6B,GAAA;AAAA,IACjC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAU,IAAK,CAAA,IAAA;AAAA,IACf,YAAY,SAAU,CAAA,IAAA;AAAA,IACtB,YAAY,aAAc,CAAA;AAAA,GAC5B;AACA,EAAO,OAAA,YAAA,CAAa,iBAAkB,CAAA,SAAA,EAAW,KAAK,CAAA;AACxD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogImportApi.esm.js","sources":["../../src/api/CatalogImportApi.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { CompoundEntityRef } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { PartialEntity } from '../types';\n\n/**\n * Utility API reference for the {@link CatalogImportApi}.\n *\n * @public\n */\nexport const catalogImportApiRef = createApiRef<CatalogImportApi>({\n id: 'plugin.catalog-import.service',\n});\n\n/**\n * Result of the analysis.\n *\n * @public\n */\nexport type AnalyzeResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n generatedEntities: PartialEntity[];\n };\n\n/**\n * API for driving catalog imports.\n *\n * @public\n */\nexport interface CatalogImportApi {\n analyzeUrl(url: string): Promise<AnalyzeResult>;\n\n preparePullRequest?(): Promise<{\n title: string;\n body: string;\n }>;\n\n submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }>;\n}\n"],"names":[],"mappings":";;AAyBO,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA
|
|
1
|
+
{"version":3,"file":"CatalogImportApi.esm.js","sources":["../../src/api/CatalogImportApi.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { CompoundEntityRef } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { PartialEntity } from '../types';\n\n/**\n * Utility API reference for the {@link CatalogImportApi}.\n *\n * @public\n */\nexport const catalogImportApiRef = createApiRef<CatalogImportApi>({\n id: 'plugin.catalog-import.service',\n});\n\n/**\n * Result of the analysis.\n *\n * @public\n */\nexport type AnalyzeResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n generatedEntities: PartialEntity[];\n };\n\n/**\n * API for driving catalog imports.\n *\n * @public\n */\nexport interface CatalogImportApi {\n analyzeUrl(url: string): Promise<AnalyzeResult>;\n\n preparePullRequest?(): Promise<{\n title: string;\n body: string;\n }>;\n\n submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }>;\n}\n"],"names":[],"mappings":";;AAyBO,MAAM,sBAAsB,YAA+B,CAAA;AAAA,EAChE,EAAI,EAAA;AACN,CAAC;;;;"}
|
|
@@ -101,13 +101,15 @@ For more information, read an [overview of the Backstage software catalog](https
|
|
|
101
101
|
}
|
|
102
102
|
async submitPullRequest(options) {
|
|
103
103
|
const { repositoryUrl, fileContent, title, body } = options;
|
|
104
|
-
const parseData = YAML.
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
const parseData = YAML.parseAllDocuments(fileContent);
|
|
105
|
+
for (const document of parseData) {
|
|
106
|
+
const validationResponse = await this.catalogApi.validateEntity(
|
|
107
|
+
document.toJS(),
|
|
108
|
+
`url:${repositoryUrl}`
|
|
109
|
+
);
|
|
110
|
+
if (!validationResponse.valid) {
|
|
111
|
+
throw new Error(validationResponse.errors[0].message);
|
|
112
|
+
}
|
|
111
113
|
}
|
|
112
114
|
const provider = this.scmIntegrationsApi.byUrl(repositoryUrl);
|
|
113
115
|
switch (provider?.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogImportClient.esm.js","sources":["../../src/api/CatalogImportClient.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { CatalogApi } from '@backstage/catalog-client';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport {\n GithubIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport YAML from 'yaml';\nimport { GitHubOptions, submitGitHubPrToRepo } from './GitHub';\nimport { getCatalogFilename } from '../components/helpers';\nimport { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport parseGitUrl from 'git-url-parse';\nimport { submitAzurePrToRepo } from './AzureDevops';\n\n/**\n * The default implementation of the {@link CatalogImportApi}.\n *\n * @public\n */\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly scmAuthApi: ScmAuthApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly catalogApi: CatalogApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n scmAuthApi: ScmAuthApi;\n fetchApi: FetchApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.fetchApi = options.fetchApi;\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.catalogApi = options.catalogApi;\n this.configApi = options.configApi;\n }\n\n async analyzeUrl(url: string): Promise<AnalyzeResult> {\n if (\n new URL(url).pathname.match(/\\.ya?ml$/) ||\n new URL(url).searchParams.get('path')?.match(/.ya?ml$/)\n ) {\n const location = await this.catalogApi.addLocation({\n type: 'url',\n target: url,\n dryRun: true,\n });\n\n return {\n type: 'locations',\n locations: [\n {\n exists: location.exists,\n target: location.location.target,\n entities: location.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n },\n ],\n };\n }\n const supportedIntegrations = ['github', 'azure'];\n const foundIntegration = this.scmIntegrationsApi.byUrl(url);\n const iSupported =\n !!foundIntegration &&\n supportedIntegrations.find(it => it === foundIntegration.type);\n if (!iSupported) {\n const catalogFilename = getCatalogFilename(this.configApi);\n\n if (foundIntegration) {\n throw new Error(\n `The ${foundIntegration.title} integration only supports full URLs to ${catalogFilename} files. Did you try to pass in the URL of a directory instead?`,\n );\n }\n throw new Error(\n `This URL was not recognized as a valid git URL because there was no configured integration that matched the given host name. Currently GitHub and Azure DevOps are supported. You could try to paste the full URL to a ${catalogFilename} file instead.`,\n );\n }\n\n const analyzation = await this.analyzeLocation({\n repo: url,\n });\n\n if (analyzation.existingEntityFiles.length > 0) {\n const locations = analyzation.existingEntityFiles.reduce<\n Record<\n string,\n {\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }\n >\n >((state, curr) => {\n state[curr.location.target] = {\n target: curr.location.target,\n exists: curr.isRegistered,\n entities: [\n ...(curr.location.target in state\n ? state[curr.location.target].entities\n : []),\n {\n name: curr.entity.metadata.name,\n namespace: curr.entity.metadata.namespace ?? 'default',\n kind: curr.entity.kind,\n },\n ],\n };\n return state;\n }, {});\n return {\n type: 'locations',\n locations: Object.values(locations),\n };\n }\n\n return {\n type: 'repository',\n integrationType: foundIntegration.type,\n url: url,\n generatedEntities: analyzation.generateEntities.map(x => x.entity),\n };\n }\n\n async preparePullRequest(): Promise<{\n title: string;\n body: string;\n }> {\n const appTitle =\n this.configApi.getOptionalString('app.title') ?? 'Backstage';\n const appBaseUrl = this.configApi.getString('app.baseUrl');\n const catalogFilename = getCatalogFilename(this.configApi);\n\n return {\n title: `Add ${catalogFilename} config file`,\n body: `This pull request adds a **Backstage entity metadata file** \\\nto this repository so that the component can be added to the \\\n[${appTitle} software catalog](${appBaseUrl}).\\n\\nAfter this pull request is merged, \\\nthe component will become available.\\n\\nFor more information, read an \\\n[overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).`,\n };\n }\n\n async submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const { repositoryUrl, fileContent, title, body } = options;\n const parseData = YAML.parse(fileContent);\n\n const validationResponse = await this.catalogApi.validateEntity(\n parseData,\n `url:${repositoryUrl}`,\n );\n if (!validationResponse.valid) {\n throw new Error(validationResponse.errors[0].message);\n }\n\n const provider = this.scmIntegrationsApi.byUrl(repositoryUrl);\n\n switch (provider?.type) {\n case 'github': {\n const { config } = provider as GithubIntegration;\n const { name, owner } = parseGitUrl(repositoryUrl);\n const options2: GitHubOptions = {\n githubIntegrationConfig: config,\n repo: name,\n owner: owner,\n repositoryUrl,\n fileContent,\n title,\n body,\n };\n return submitGitHubPrToRepo(options2, this.scmAuthApi, this.configApi);\n }\n case 'azure': {\n return submitAzurePrToRepo(\n {\n repositoryUrl,\n fileContent,\n title,\n body,\n },\n this.scmAuthApi,\n this.configApi,\n );\n }\n default: {\n throw new Error('unimplemented!');\n }\n }\n }\n\n // TODO: this could be part of the catalog api\n private async analyzeLocation(options: {\n repo: string;\n }): Promise<AnalyzeLocationResponse> {\n const response = await this.fetchApi\n .fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: options.repo },\n ...(this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ) && {\n catalogFilename: this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ),\n }),\n }),\n },\n )\n .catch(e => {\n throw new Error(`Failed to generate entity definitions, ${e.message}`);\n });\n if (!response.ok) {\n throw new Error(\n `Failed to generate entity definitions. Received http response ${response.status}: ${response.statusText}`,\n );\n }\n\n const payload = await response.json();\n return payload;\n }\n}\n"],"names":[],"mappings":";;;;;;AAqCO,MAAM,mBAAgD,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A,CAAS,MAAM,CAAA,EAAA,EAAK,SAAS,UAAU,CAAA,CAAA;AAAA,OAC1G,CAAA;AAAA,KACF;AAEA,IAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,IAAK,EAAA,CAAA;AACpC,IAAO,OAAA,OAAA,CAAA;AAAA,GACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"CatalogImportClient.esm.js","sources":["../../src/api/CatalogImportClient.ts"],"sourcesContent":["/*\n * Copyright 2020 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 { CatalogApi } from '@backstage/catalog-client';\nimport { ConfigApi, DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';\nimport {\n GithubIntegration,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport YAML from 'yaml';\nimport { GitHubOptions, submitGitHubPrToRepo } from './GitHub';\nimport { getCatalogFilename } from '../components/helpers';\nimport { AnalyzeLocationResponse } from '@backstage/plugin-catalog-common';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport parseGitUrl from 'git-url-parse';\nimport { submitAzurePrToRepo } from './AzureDevops';\n\n/**\n * The default implementation of the {@link CatalogImportApi}.\n *\n * @public\n */\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly fetchApi: FetchApi;\n private readonly scmAuthApi: ScmAuthApi;\n private readonly scmIntegrationsApi: ScmIntegrationRegistry;\n private readonly catalogApi: CatalogApi;\n private readonly configApi: ConfigApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n scmAuthApi: ScmAuthApi;\n fetchApi: FetchApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.fetchApi = options.fetchApi;\n this.scmIntegrationsApi = options.scmIntegrationsApi;\n this.catalogApi = options.catalogApi;\n this.configApi = options.configApi;\n }\n\n async analyzeUrl(url: string): Promise<AnalyzeResult> {\n if (\n new URL(url).pathname.match(/\\.ya?ml$/) ||\n new URL(url).searchParams.get('path')?.match(/.ya?ml$/)\n ) {\n const location = await this.catalogApi.addLocation({\n type: 'url',\n target: url,\n dryRun: true,\n });\n\n return {\n type: 'locations',\n locations: [\n {\n exists: location.exists,\n target: location.location.target,\n entities: location.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n },\n ],\n };\n }\n const supportedIntegrations = ['github', 'azure'];\n const foundIntegration = this.scmIntegrationsApi.byUrl(url);\n const iSupported =\n !!foundIntegration &&\n supportedIntegrations.find(it => it === foundIntegration.type);\n if (!iSupported) {\n const catalogFilename = getCatalogFilename(this.configApi);\n\n if (foundIntegration) {\n throw new Error(\n `The ${foundIntegration.title} integration only supports full URLs to ${catalogFilename} files. Did you try to pass in the URL of a directory instead?`,\n );\n }\n throw new Error(\n `This URL was not recognized as a valid git URL because there was no configured integration that matched the given host name. Currently GitHub and Azure DevOps are supported. You could try to paste the full URL to a ${catalogFilename} file instead.`,\n );\n }\n\n const analyzation = await this.analyzeLocation({\n repo: url,\n });\n\n if (analyzation.existingEntityFiles.length > 0) {\n const locations = analyzation.existingEntityFiles.reduce<\n Record<\n string,\n {\n target: string;\n exists?: boolean;\n entities: CompoundEntityRef[];\n }\n >\n >((state, curr) => {\n state[curr.location.target] = {\n target: curr.location.target,\n exists: curr.isRegistered,\n entities: [\n ...(curr.location.target in state\n ? state[curr.location.target].entities\n : []),\n {\n name: curr.entity.metadata.name,\n namespace: curr.entity.metadata.namespace ?? 'default',\n kind: curr.entity.kind,\n },\n ],\n };\n return state;\n }, {});\n return {\n type: 'locations',\n locations: Object.values(locations),\n };\n }\n\n return {\n type: 'repository',\n integrationType: foundIntegration.type,\n url: url,\n generatedEntities: analyzation.generateEntities.map(x => x.entity),\n };\n }\n\n async preparePullRequest(): Promise<{\n title: string;\n body: string;\n }> {\n const appTitle =\n this.configApi.getOptionalString('app.title') ?? 'Backstage';\n const appBaseUrl = this.configApi.getString('app.baseUrl');\n const catalogFilename = getCatalogFilename(this.configApi);\n\n return {\n title: `Add ${catalogFilename} config file`,\n body: `This pull request adds a **Backstage entity metadata file** \\\nto this repository so that the component can be added to the \\\n[${appTitle} software catalog](${appBaseUrl}).\\n\\nAfter this pull request is merged, \\\nthe component will become available.\\n\\nFor more information, read an \\\n[overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).`,\n };\n }\n\n async submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const { repositoryUrl, fileContent, title, body } = options;\n\n const parseData = YAML.parseAllDocuments(fileContent);\n\n for (const document of parseData) {\n const validationResponse = await this.catalogApi.validateEntity(\n document.toJS(),\n `url:${repositoryUrl}`,\n );\n if (!validationResponse.valid) {\n throw new Error(validationResponse.errors[0].message);\n }\n }\n\n const provider = this.scmIntegrationsApi.byUrl(repositoryUrl);\n\n switch (provider?.type) {\n case 'github': {\n const { config } = provider as GithubIntegration;\n const { name, owner } = parseGitUrl(repositoryUrl);\n const options2: GitHubOptions = {\n githubIntegrationConfig: config,\n repo: name,\n owner: owner,\n repositoryUrl,\n fileContent,\n title,\n body,\n };\n return submitGitHubPrToRepo(options2, this.scmAuthApi, this.configApi);\n }\n case 'azure': {\n return submitAzurePrToRepo(\n {\n repositoryUrl,\n fileContent,\n title,\n body,\n },\n this.scmAuthApi,\n this.configApi,\n );\n }\n default: {\n throw new Error('unimplemented!');\n }\n }\n }\n\n // TODO: this could be part of the catalog api\n private async analyzeLocation(options: {\n repo: string;\n }): Promise<AnalyzeLocationResponse> {\n const response = await this.fetchApi\n .fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: options.repo },\n ...(this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ) && {\n catalogFilename: this.configApi.getOptionalString(\n 'catalog.import.entityFilename',\n ),\n }),\n }),\n },\n )\n .catch(e => {\n throw new Error(`Failed to generate entity definitions, ${e.message}`);\n });\n if (!response.ok) {\n throw new Error(\n `Failed to generate entity definitions. Received http response ${response.status}: ${response.statusText}`,\n );\n }\n\n const payload = await response.json();\n return payload;\n }\n}\n"],"names":[],"mappings":";;;;;;AAqCO,MAAM,mBAAgD,CAAA;AAAA,EAC1C,YAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EAEjB,YAAY,OAOT,EAAA;AACD,IAAA,IAAA,CAAK,eAAe,OAAQ,CAAA,YAAA;AAC5B,IAAA,IAAA,CAAK,aAAa,OAAQ,CAAA,UAAA;AAC1B,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA;AACxB,IAAA,IAAA,CAAK,qBAAqB,OAAQ,CAAA,kBAAA;AAClC,IAAA,IAAA,CAAK,aAAa,OAAQ,CAAA,UAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA;AAAA;AAC3B,EAEA,MAAM,WAAW,GAAqC,EAAA;AACpD,IAAA,IACE,IAAI,GAAI,CAAA,GAAG,EAAE,QAAS,CAAA,KAAA,CAAM,UAAU,CACtC,IAAA,IAAI,GAAI,CAAA,GAAG,EAAE,YAAa,CAAA,GAAA,CAAI,MAAM,CAAG,EAAA,KAAA,CAAM,SAA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E,CAAA,CAAA;AAAA,KACtE,CAAA;AACH,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAiE,8DAAA,EAAA,QAAA,CAAS,MAAM,CAAA,EAAA,EAAK,SAAS,UAAU,CAAA;AAAA,OAC1G;AAAA;AAGF,IAAM,MAAA,OAAA,GAAU,MAAM,QAAA,CAAS,IAAK,EAAA;AACpC,IAAO,OAAA,OAAA;AAAA;AAEX;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHub.esm.js","sources":["../../src/api/GitHub.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { Octokit } from '@octokit/rest';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { Base64 } from 'js-base64';\n\nexport interface GitHubOptions {\n owner: string;\n repo: string;\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n githubIntegrationConfig: GithubIntegrationConfig;\n}\nexport const getGithubIntegrationConfig = (\n scmIntegrationsApi: ScmIntegrationRegistry,\n location: string,\n) => {\n const integration = scmIntegrationsApi.github.byUrl(location);\n if (!integration) {\n return undefined;\n }\n\n const { name: repo, owner } = parseGitUrl(location);\n return {\n repo,\n owner,\n githubIntegrationConfig: integration.config,\n };\n};\n\nexport async function submitGitHubPrToRepo(\n options: GitHubOptions,\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n): Promise<{ link: string; location: string }> {\n const {\n owner,\n repo,\n title,\n body,\n fileContent,\n repositoryUrl,\n githubIntegrationConfig,\n } = options;\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n\n const octo = new Octokit({\n auth: token,\n baseUrl: githubIntegrationConfig.apiBaseUrl,\n });\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const repoData = await octo.repos\n .get({\n owner,\n repo,\n })\n .catch(e => {\n throw new Error(formatHttpErrorMessage(\"Couldn't fetch repo data\", e));\n });\n\n const parentRef = await octo.git\n .getRef({\n owner,\n repo,\n ref: `heads/${repoData.data.default_branch}`,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\"Couldn't fetch default branch data\", e),\n );\n });\n\n await octo.git\n .createRef({\n owner,\n repo,\n ref: `refs/heads/${branchName}`,\n sha: parentRef.data.object.sha,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a new branch with name '${branchName}'`,\n e,\n ),\n );\n });\n\n await octo.repos\n .createOrUpdateFileContents({\n owner,\n repo,\n path: fileName,\n message: title,\n content: Base64.encode(fileContent),\n branch: branchName,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a commit with ${fileName} file added`,\n e,\n ),\n );\n });\n\n const pullRequestResponse = await octo.pulls\n .create({\n owner,\n repo,\n title,\n head: branchName,\n body,\n base: repoData.data.default_branch,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a pull request for ${branchName} branch`,\n e,\n ),\n );\n });\n\n return {\n link: pullRequestResponse.data.html_url,\n location: `https://${githubIntegrationConfig.host}/${owner}/${repo}/blob/${repoData.data.default_branch}/${fileName}`,\n };\n}\n\nfunction formatHttpErrorMessage(\n message: string,\n error: { status: number; message: string },\n) {\n return `${message}, received http response status code ${error.status}: ${error.message}`;\n}\n"],"names":[],"mappings":";;;;;AAqDsB,eAAA,oBAAA,CACpB,OACA,EAAA,UAAA,EACA,SAC6C,EAAA;AAC7C,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA
|
|
1
|
+
{"version":3,"file":"GitHub.esm.js","sources":["../../src/api/GitHub.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n GithubIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { Octokit } from '@octokit/rest';\nimport { getBranchName, getCatalogFilename } from '../components/helpers';\nimport { ConfigApi } from '@backstage/core-plugin-api';\nimport { Base64 } from 'js-base64';\n\nexport interface GitHubOptions {\n owner: string;\n repo: string;\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n githubIntegrationConfig: GithubIntegrationConfig;\n}\nexport const getGithubIntegrationConfig = (\n scmIntegrationsApi: ScmIntegrationRegistry,\n location: string,\n) => {\n const integration = scmIntegrationsApi.github.byUrl(location);\n if (!integration) {\n return undefined;\n }\n\n const { name: repo, owner } = parseGitUrl(location);\n return {\n repo,\n owner,\n githubIntegrationConfig: integration.config,\n };\n};\n\nexport async function submitGitHubPrToRepo(\n options: GitHubOptions,\n scmAuthApi: ScmAuthApi,\n configApi: ConfigApi,\n): Promise<{ link: string; location: string }> {\n const {\n owner,\n repo,\n title,\n body,\n fileContent,\n repositoryUrl,\n githubIntegrationConfig,\n } = options;\n\n const { token } = await scmAuthApi.getCredentials({\n url: repositoryUrl,\n additionalScope: {\n repoWrite: true,\n },\n });\n\n const octo = new Octokit({\n auth: token,\n baseUrl: githubIntegrationConfig.apiBaseUrl,\n });\n\n const branchName = getBranchName(configApi);\n const fileName = getCatalogFilename(configApi);\n\n const repoData = await octo.repos\n .get({\n owner,\n repo,\n })\n .catch(e => {\n throw new Error(formatHttpErrorMessage(\"Couldn't fetch repo data\", e));\n });\n\n const parentRef = await octo.git\n .getRef({\n owner,\n repo,\n ref: `heads/${repoData.data.default_branch}`,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\"Couldn't fetch default branch data\", e),\n );\n });\n\n await octo.git\n .createRef({\n owner,\n repo,\n ref: `refs/heads/${branchName}`,\n sha: parentRef.data.object.sha,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a new branch with name '${branchName}'`,\n e,\n ),\n );\n });\n\n await octo.repos\n .createOrUpdateFileContents({\n owner,\n repo,\n path: fileName,\n message: title,\n content: Base64.encode(fileContent),\n branch: branchName,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a commit with ${fileName} file added`,\n e,\n ),\n );\n });\n\n const pullRequestResponse = await octo.pulls\n .create({\n owner,\n repo,\n title,\n head: branchName,\n body,\n base: repoData.data.default_branch,\n })\n .catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n `Couldn't create a pull request for ${branchName} branch`,\n e,\n ),\n );\n });\n\n return {\n link: pullRequestResponse.data.html_url,\n location: `https://${githubIntegrationConfig.host}/${owner}/${repo}/blob/${repoData.data.default_branch}/${fileName}`,\n };\n}\n\nfunction formatHttpErrorMessage(\n message: string,\n error: { status: number; message: string },\n) {\n return `${message}, received http response status code ${error.status}: ${error.message}`;\n}\n"],"names":[],"mappings":";;;;;AAqDsB,eA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U,EAAA,CAAA,QAAA,EAAW,uBAAwB,CAAA,IAAI,CAAI,CAAA,EAAA,KAAK,CAAI,CAAA,EAAA,IAAI,CAAS,MAAA,EAAA,QAAA,CAAS,IAAK,CAAA,cAAc,IAAI,QAAQ,CAAA;AAAA,GACrH;AACF;AAEA,SAAS,sBAAA,CACP,SACA,KACA,EAAA;AACA,EAAA,OAAO,GAAG,OAAO,CAAA,qCAAA,EAAwC,MAAM,MAAM,CAAA,EAAA,EAAK,MAAM,OAAO,CAAA,CAAA;AACzF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../../src/components/Buttons/index.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 { LinkButton } from '@backstage/core-components';\nimport Button from '@material-ui/core/Button';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { ComponentProps } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n wrapper: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n position: 'relative',\n },\n buttonProgress: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n marginTop: -12,\n marginLeft: -12,\n },\n button: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n },\n}));\n\nexport const NextButton = (\n props: ComponentProps<typeof Button> & { loading?: boolean },\n) => {\n const { loading, ...buttonProps } = props;\n const classes = useStyles();\n\n return (\n <div className={classes.wrapper}>\n <Button\n color=\"primary\"\n variant=\"contained\"\n {...buttonProps}\n disabled={props.disabled || props.loading}\n />\n {props.loading && (\n <CircularProgress size=\"1.5rem\" className={classes.buttonProgress} />\n )}\n {props.loading}\n </div>\n );\n};\n\nexport const BackButton = (props: ComponentProps<typeof Button>) => {\n const classes = useStyles();\n\n return (\n <Button variant=\"outlined\" className={classes.button} {...props}>\n {props.children || 'Back'}\n </Button>\n );\n};\n\nexport const ViewComponentButton = (\n props: ComponentProps<typeof LinkButton>,\n) => {\n const classes = useStyles();\n\n return (\n <LinkButton\n color=\"primary\"\n variant=\"contained\"\n className={classes.button}\n {...props}\n >\n {props.children}\n </LinkButton>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,OAAS,EAAA;AAAA,IACP,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC1B,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC5B,QAAU,EAAA
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../src/components/Buttons/index.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 { LinkButton } from '@backstage/core-components';\nimport Button from '@material-ui/core/Button';\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { ComponentProps } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n wrapper: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n position: 'relative',\n },\n buttonProgress: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n marginTop: -12,\n marginLeft: -12,\n },\n button: {\n marginTop: theme.spacing(1),\n marginRight: theme.spacing(1),\n },\n}));\n\nexport const NextButton = (\n props: ComponentProps<typeof Button> & { loading?: boolean },\n) => {\n const { loading, ...buttonProps } = props;\n const classes = useStyles();\n\n return (\n <div className={classes.wrapper}>\n <Button\n color=\"primary\"\n variant=\"contained\"\n {...buttonProps}\n disabled={props.disabled || props.loading}\n />\n {props.loading && (\n <CircularProgress size=\"1.5rem\" className={classes.buttonProgress} />\n )}\n {props.loading}\n </div>\n );\n};\n\nexport const BackButton = (props: ComponentProps<typeof Button>) => {\n const classes = useStyles();\n\n return (\n <Button variant=\"outlined\" className={classes.button} {...props}>\n {props.children || 'Back'}\n </Button>\n );\n};\n\nexport const ViewComponentButton = (\n props: ComponentProps<typeof LinkButton>,\n) => {\n const classes = useStyles();\n\n return (\n <LinkButton\n color=\"primary\"\n variant=\"contained\"\n className={classes.button}\n {...props}\n >\n {props.children}\n </LinkButton>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,OAAS,EAAA;AAAA,IACP,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC1B,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC5B,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,cAAgB,EAAA;AAAA,IACd,QAAU,EAAA,UAAA;AAAA,IACV,GAAK,EAAA,KAAA;AAAA,IACL,IAAM,EAAA,KAAA;AAAA,IACN,SAAW,EAAA,CAAA,EAAA;AAAA,IACX,UAAY,EAAA,CAAA;AAAA,GACd;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IAC1B,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA;AAEhC,CAAE,CAAA,CAA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|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultImportPage.esm.js","sources":["../../../src/components/DefaultImportPage/DefaultImportPage.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 {\n Content,\n ContentHeader,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport Grid from '@material-ui/core/Grid';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport { useTheme } from '@material-ui/core/styles';\nimport React from 'react';\nimport { ImportInfoCard } from '../ImportInfoCard';\nimport { ImportStepper } from '../ImportStepper';\n\n/**\n * The default catalog import page.\n *\n * @public\n */\nexport const DefaultImportPage = () => {\n const theme = useTheme();\n const configApi = useApi(configApiRef);\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'));\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n\n const supportTitle = `Start tracking your component in ${appTitle} by adding it to the software catalog.`;\n\n const contentItems = [\n <Grid key={0} item xs={12} md={4} lg={6} xl={8}>\n <ImportInfoCard />\n </Grid>,\n\n <Grid key={1} item xs={12} md={8} lg={6} xl={4}>\n <ImportStepper />\n </Grid>,\n ];\n\n return (\n <Page themeId=\"home\">\n <Header title=\"Register an existing component\" />\n <Content>\n <ContentHeader title={`Start tracking your component in ${appTitle}`}>\n <SupportButton>{supportTitle}</SupportButton>\n </ContentHeader>\n\n <Grid container spacing={2}>\n {isMobile ? contentItems : contentItems.reverse()}\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAM,oBAAoB,MAAM;AACrC,EAAA,MAAM,QAAQ,QAAS,EAAA
|
|
1
|
+
{"version":3,"file":"DefaultImportPage.esm.js","sources":["../../../src/components/DefaultImportPage/DefaultImportPage.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 {\n Content,\n ContentHeader,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport Grid from '@material-ui/core/Grid';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport { useTheme } from '@material-ui/core/styles';\nimport React from 'react';\nimport { ImportInfoCard } from '../ImportInfoCard';\nimport { ImportStepper } from '../ImportStepper';\n\n/**\n * The default catalog import page.\n *\n * @public\n */\nexport const DefaultImportPage = () => {\n const theme = useTheme();\n const configApi = useApi(configApiRef);\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'));\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n\n const supportTitle = `Start tracking your component in ${appTitle} by adding it to the software catalog.`;\n\n const contentItems = [\n <Grid key={0} item xs={12} md={4} lg={6} xl={8}>\n <ImportInfoCard />\n </Grid>,\n\n <Grid key={1} item xs={12} md={8} lg={6} xl={4}>\n <ImportStepper />\n </Grid>,\n ];\n\n return (\n <Page themeId=\"home\">\n <Header title=\"Register an existing component\" />\n <Content>\n <ContentHeader title={`Start tracking your component in ${appTitle}`}>\n <SupportButton>{supportTitle}</SupportButton>\n </ContentHeader>\n\n <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AA,aAAA,CAAA,aAAA,EAAA,IAAA,EAAe,YAAa,CAC/B,CAEA,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,SAAS,EAAA,IAAA,EAAC,OAAS,EAAA,CAAA,EAAA,EACtB,WAAW,YAAe,GAAA,YAAA,CAAa,OAAQ,EAClD,CACF,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityListComponent.esm.js","sources":["../../../src/components/EntityListComponent/EntityListComponent.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 {\n Entity,\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefLink,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport Collapse from '@material-ui/core/Collapse';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandLessIcon from '@material-ui/icons/ExpandLess';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport React, { useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n nested: {\n paddingLeft: theme.spacing(4),\n },\n}));\n\n/**\n * Props for {@link EntityListComponent}.\n *\n * @public\n */\nexport interface EntityListComponentProps {\n locations: Array<{\n target: string;\n entities: (Entity | CompoundEntityRef)[];\n }>;\n locationListItemIcon: (target: string) => React.ReactElement;\n collapsed?: boolean;\n firstListItem?: React.ReactElement;\n onItemClick?: (target: string) => void;\n withLinks?: boolean;\n}\n\n/**\n * Shows a result list of entities.\n *\n * @public\n */\nexport const EntityListComponent = (props: EntityListComponentProps) => {\n const {\n locations,\n collapsed = false,\n locationListItemIcon,\n onItemClick,\n firstListItem,\n withLinks = false,\n } = props;\n\n const classes = useStyles();\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const [expandedUrls, setExpandedUrls] = useState<string[]>([]);\n\n const handleClick = (url: string) => {\n setExpandedUrls(urls =>\n urls.includes(url) ? urls.filter(u => u !== url) : urls.concat(url),\n );\n };\n\n function sortEntities(entities: Array<CompoundEntityRef | Entity>) {\n return entities.sort((a, b) =>\n entityPresentationApi\n .forEntity(stringifyEntityRef(a))\n .snapshot.entityRef.localeCompare(\n entityPresentationApi.forEntity(stringifyEntityRef(b)).snapshot\n .entityRef,\n ),\n );\n }\n\n return (\n <List>\n {firstListItem}\n {locations.map(r => (\n <React.Fragment key={r.target}>\n <ListItem\n dense\n button={Boolean(onItemClick) as any}\n onClick={() => onItemClick?.(r.target)}\n >\n <ListItemIcon>{locationListItemIcon(r.target)}</ListItemIcon>\n\n <ListItemText\n primary={r.target}\n secondary={`Entities: ${r.entities.length}`}\n />\n\n {collapsed && (\n <ListItemSecondaryAction>\n <IconButton edge=\"end\" onClick={() => handleClick(r.target)}>\n {expandedUrls.includes(r.target) ? (\n <ExpandLessIcon />\n ) : (\n <ExpandMoreIcon />\n )}\n </IconButton>\n </ListItemSecondaryAction>\n )}\n </ListItem>\n\n <Collapse\n in={!collapsed || expandedUrls.includes(r.target)}\n timeout=\"auto\"\n unmountOnExit\n >\n <List component=\"div\" disablePadding dense>\n {sortEntities(r.entities).map(entity => {\n return (\n <ListItem\n key={stringifyEntityRef(entity)}\n className={classes.nested}\n {...(withLinks\n ? {\n component: EntityRefLink,\n entityRef: entity,\n button: withLinks as any,\n }\n : {})}\n >\n <ListItemText\n primary={<EntityDisplayName entityRef={entity} />}\n />\n </ListItem>\n );\n })}\n </List>\n </Collapse>\n </React.Fragment>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACN,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"EntityListComponent.esm.js","sources":["../../../src/components/EntityListComponent/EntityListComponent.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 {\n Entity,\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n EntityDisplayName,\n EntityRefLink,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport Collapse from '@material-ui/core/Collapse';\nimport IconButton from '@material-ui/core/IconButton';\nimport List from '@material-ui/core/List';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandLessIcon from '@material-ui/icons/ExpandLess';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport React, { useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n nested: {\n paddingLeft: theme.spacing(4),\n },\n}));\n\n/**\n * Props for {@link EntityListComponent}.\n *\n * @public\n */\nexport interface EntityListComponentProps {\n locations: Array<{\n target: string;\n entities: (Entity | CompoundEntityRef)[];\n }>;\n locationListItemIcon: (target: string) => React.ReactElement;\n collapsed?: boolean;\n firstListItem?: React.ReactElement;\n onItemClick?: (target: string) => void;\n withLinks?: boolean;\n}\n\n/**\n * Shows a result list of entities.\n *\n * @public\n */\nexport const EntityListComponent = (props: EntityListComponentProps) => {\n const {\n locations,\n collapsed = false,\n locationListItemIcon,\n onItemClick,\n firstListItem,\n withLinks = false,\n } = props;\n\n const classes = useStyles();\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const [expandedUrls, setExpandedUrls] = useState<string[]>([]);\n\n const handleClick = (url: string) => {\n setExpandedUrls(urls =>\n urls.includes(url) ? urls.filter(u => u !== url) : urls.concat(url),\n );\n };\n\n function sortEntities(entities: Array<CompoundEntityRef | Entity>) {\n return entities.sort((a, b) =>\n entityPresentationApi\n .forEntity(stringifyEntityRef(a))\n .snapshot.entityRef.localeCompare(\n entityPresentationApi.forEntity(stringifyEntityRef(b)).snapshot\n .entityRef,\n ),\n );\n }\n\n return (\n <List>\n {firstListItem}\n {locations.map(r => (\n <React.Fragment key={r.target}>\n <ListItem\n dense\n button={Boolean(onItemClick) as any}\n onClick={() => onItemClick?.(r.target)}\n >\n <ListItemIcon>{locationListItemIcon(r.target)}</ListItemIcon>\n\n <ListItemText\n primary={r.target}\n secondary={`Entities: ${r.entities.length}`}\n />\n\n {collapsed && (\n <ListItemSecondaryAction>\n <IconButton edge=\"end\" onClick={() => handleClick(r.target)}>\n {expandedUrls.includes(r.target) ? (\n <ExpandLessIcon />\n ) : (\n <ExpandMoreIcon />\n )}\n </IconButton>\n </ListItemSecondaryAction>\n )}\n </ListItem>\n\n <Collapse\n in={!collapsed || expandedUrls.includes(r.target)}\n timeout=\"auto\"\n unmountOnExit\n >\n <List component=\"div\" disablePadding dense>\n {sortEntities(r.entities).map(entity => {\n return (\n <ListItem\n key={stringifyEntityRef(entity)}\n className={classes.nested}\n {...(withLinks\n ? {\n component: EntityRefLink,\n entityRef: entity,\n button: withLinks as any,\n }\n : {})}\n >\n <ListItemText\n primary={<EntityDisplayName entityRef={entity} />}\n />\n </ListItem>\n );\n })}\n </List>\n </Collapse>\n </React.Fragment>\n ))}\n </List>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACN,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA;AAEhC,CAAE,CAAA,CAAA;AAwBW,MAAA,mBAAA,GAAsB,CAAC,KAAoC,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,SAAY,GAAA,KAAA;AAAA,IACZ,oBAAA;AAAA,IACA,WAAA;AAAA,IACA,aAAA;AAAA,IACA,SAAY,GAAA;AAAA,GACV,GAAA,KAAA;AAEJ,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAM,MAAA,qBAAA,GAAwB,OAAO,wBAAwB,CAAA;AAC7D,EAAA,MAAM,CAAC,YAAc,EAAA,eAAe,CAAI,GAAA,QAAA,CAAmB,EAAE,CAAA;AAE7D,EAAM,MAAA,WAAA,GAAc,CAAC,GAAgB,KAAA;AACnC,IAAA,eAAA;AAAA,MAAgB,CACd,IAAA,KAAA,IAAA,CAAK,QAAS,CAAA,GAAG,CAAI,GAAA,IAAA,CAAK,MAAO,CAAA,CAAA,CAAA,KAAK,CAAM,KAAA,GAAG,CAAI,GAAA,IAAA,CAAK,OAAO,GAAG;AAAA,KACpE;AAAA,GACF;AAEA,EAAA,SAAS,aAAa,QAA6C,EAAA;AACjE,IAAA,OAAO,QAAS,CAAA,IAAA;AAAA,MAAK,CAAC,CAAG,EAAA,CAAA,KACvB,qBACG,CAAA,SAAA,CAAU,mBAAmB,CAA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,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,IAAI,CAAC,SAAA,IAAa,YAAa,CAAA,QAAA,CAAS,EAAE,MAAM,CAAA;AAAA,MAChD,OAAQ,EAAA,MAAA;AAAA,MACR,aAAa,EAAA;AAAA,KAAA;AAAA,oBAEZ,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,SAAU,EAAA,KAAA,EAAM,cAAc,EAAA,IAAA,EAAC,KAAK,EAAA,IAAA,EAAA,EACvC,YAAa,CAAA,CAAA,CAAE,QAAQ,CAAA,CAAE,IAAI,CAAU,MAAA,KAAA;AACtC,MACE,uBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,GAAA,EAAK,mBAAmB,MAAM,CAAA;AAAA,UAC9B,WAAW,OAAQ,CAAA,MAAA;AAAA,UAClB,GAAI,SACD,GAAA;AAAA,YACE,SAAW,EAAA,aAAA;AAAA,YACX,SAAW,EAAA,MAAA;AAAA,YACX,MAAQ,EAAA;AAAA,cAEV;AAAC,SAAA;AAAA,wBAEL,KAAA,CAAA,aAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,iBAAkB,EAAA,EAAA,SAAA,EAAW,MAAQ,EAAA;AAAA;AAAA;AACjD,OACF;AAAA,KAEH,CACH;AAAA,GAEJ,CACD,CACH,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportInfoCard.esm.js","sources":["../../../src/components/ImportInfoCard/ImportInfoCard.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 { InfoCard } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport Chip from '@material-ui/core/Chip';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\nimport { catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\n\n/**\n * Props for {@link ImportInfoCard}.\n *\n * @public\n */\nexport interface ImportInfoCardProps {\n exampleLocationUrl?: string;\n exampleRepositoryUrl?: string;\n}\n\n/**\n * Shows information about the import process.\n *\n * @public\n */\nexport const ImportInfoCard = (props: ImportInfoCardProps) => {\n const {\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n exampleRepositoryUrl = 'https://github.com/backstage/backstage',\n } = props;\n\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const hasGithubIntegration = configApi.has('integrations.github');\n\n const catalogFilename = useCatalogFilename();\n\n return (\n <InfoCard\n title=\"Register an existing component\"\n titleTypographyProps={{ component: 'h3' }}\n deepLink={{\n title: 'Learn more about the Software Catalog',\n link: 'https://backstage.io/docs/features/software-catalog/',\n }}\n >\n <Typography variant=\"body2\" paragraph>\n Enter the URL to your source code repository to add it to {appTitle}.\n </Typography>\n <Typography component=\"h4\" variant=\"h6\">\n Link to an existing entity file\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n Example: <code>{exampleLocationUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n The wizard analyzes the file, previews the entities, and adds them to\n the {appTitle} catalog.\n </Typography>\n {hasGithubIntegration && (\n <>\n <Typography component=\"h4\" variant=\"h6\">\n Link to a repository{' '}\n <Chip label=\"GitHub only\" variant=\"outlined\" size=\"small\" />\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n Example: <code>{exampleRepositoryUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n The wizard discovers all <code>{catalogFilename}</code> files in the\n repository, previews the entities, and adds them to the {appTitle}{' '}\n catalog.\n </Typography>\n {catalogImportApi.preparePullRequest && (\n <Typography variant=\"body2\" paragraph>\n If no entities are found, the wizard will prepare a Pull Request\n that adds an example <code>{catalogFilename}</code> and prepares\n the {appTitle} catalog to load all entities as soon as the Pull\n Request is merged.\n </Typography>\n )}\n </>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAuCa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,kBAAqB,GAAA,sEAAA;AAAA,IACrB,oBAAuB,GAAA
|
|
1
|
+
{"version":3,"file":"ImportInfoCard.esm.js","sources":["../../../src/components/ImportInfoCard/ImportInfoCard.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 { InfoCard } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\nimport Chip from '@material-ui/core/Chip';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\nimport { catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\n\n/**\n * Props for {@link ImportInfoCard}.\n *\n * @public\n */\nexport interface ImportInfoCardProps {\n exampleLocationUrl?: string;\n exampleRepositoryUrl?: string;\n}\n\n/**\n * Shows information about the import process.\n *\n * @public\n */\nexport const ImportInfoCard = (props: ImportInfoCardProps) => {\n const {\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n exampleRepositoryUrl = 'https://github.com/backstage/backstage',\n } = props;\n\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const hasGithubIntegration = configApi.has('integrations.github');\n\n const catalogFilename = useCatalogFilename();\n\n return (\n <InfoCard\n title=\"Register an existing component\"\n titleTypographyProps={{ component: 'h3' }}\n deepLink={{\n title: 'Learn more about the Software Catalog',\n link: 'https://backstage.io/docs/features/software-catalog/',\n }}\n >\n <Typography variant=\"body2\" paragraph>\n Enter the URL to your source code repository to add it to {appTitle}.\n </Typography>\n <Typography component=\"h4\" variant=\"h6\">\n Link to an existing entity file\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n Example: <code>{exampleLocationUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n The wizard analyzes the file, previews the entities, and adds them to\n the {appTitle} catalog.\n </Typography>\n {hasGithubIntegration && (\n <>\n <Typography component=\"h4\" variant=\"h6\">\n Link to a repository{' '}\n <Chip label=\"GitHub only\" variant=\"outlined\" size=\"small\" />\n </Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n Example: <code>{exampleRepositoryUrl}</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n The wizard discovers all <code>{catalogFilename}</code> files in the\n repository, previews the entities, and adds them to the {appTitle}{' '}\n catalog.\n </Typography>\n {catalogImportApi.preparePullRequest && (\n <Typography variant=\"body2\" paragraph>\n If no entities are found, the wizard will prepare a Pull Request\n that adds an example <code>{catalogFilename}</code> and prepares\n the {appTitle} catalog to load all entities as soon as the Pull\n Request is merged.\n </Typography>\n )}\n </>\n )}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAuCa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,kBAAqB,G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,IAAA,kBACG,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAU,EAAA,IAAA,EAAK,OAAQ,EAAA,IAAA,EAAA,EAAK,sBACjB,EAAA,GAAA,kBACpB,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,OAAM,aAAc,EAAA,OAAA,EAAQ,UAAW,EAAA,IAAA,EAAK,OAAQ,EAAA,CAC5D,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,WAAA,EAAY,KAAM,EAAA,eAAA,EAAgB,SAAS,EAAA,IAAA,EAAA,EAAC,WACrD,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAM,oBAAqB,CACvC,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,SAAA,EAAS,IAAC,EAAA,EAAA,2BAAA,kBACV,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAM,eAAgB,CAAA,EAAO,wEACE,EAAA,QAAA,EAAU,KAAI,UAEzE,CAAA,EACC,gBAAiB,CAAA,kBAAA,oBACf,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAQ,WAAS,IAAC,EAAA,EAAA,wFAAA,kBAEd,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAM,eAAgB,CAAA,EAAO,oBAC9C,EAAA,QAAA,EAAS,sEAEhB,CAEJ;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportPage.esm.js","sources":["../../../src/components/ImportPage/ImportPage.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useOutlet } from 'react-router-dom';\nimport { DefaultImportPage } from '../DefaultImportPage';\n\n/**\n * The whole catalog import page.\n *\n * @public\n */\nexport const ImportPage = () => {\n const outlet = useOutlet();\n\n return outlet || <DefaultImportPage />;\n};\n"],"names":[],"mappings":";;;;AAyBO,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,SAAS,SAAU,EAAA
|
|
1
|
+
{"version":3,"file":"ImportPage.esm.js","sources":["../../../src/components/ImportPage/ImportPage.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useOutlet } from 'react-router-dom';\nimport { DefaultImportPage } from '../DefaultImportPage';\n\n/**\n * The whole catalog import page.\n *\n * @public\n */\nexport const ImportPage = () => {\n const outlet = useOutlet();\n\n return outlet || <DefaultImportPage />;\n};\n"],"names":[],"mappings":";;;;AAyBO,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,SAAS,SAAU,EAAA;AAEzB,EAAO,OAAA,MAAA,wCAAW,iBAAkB,EAAA,IAAA,CAAA;AACtC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportStepper.esm.js","sources":["../../../src/components/ImportStepper/ImportStepper.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 { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport Step from '@material-ui/core/Step';\nimport StepContent from '@material-ui/core/StepContent';\nimport Stepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { useMemo } from 'react';\nimport { catalogImportApiRef } from '../../api';\nimport { ImportFlows, ImportState, useImportState } from '../useImportState';\nimport {\n defaultGenerateStepper,\n defaultStepper,\n StepConfiguration,\n StepperProvider,\n} from './defaults';\n\nconst useStyles = makeStyles(() => ({\n stepperRoot: {\n padding: 0,\n },\n}));\n\n/**\n * Props for {@link ImportStepper}.\n *\n * @public\n */\nexport interface ImportStepperProps {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n}\n\n/**\n * The stepper that holds the different import stages.\n *\n * @public\n */\nexport const ImportStepper = (props: ImportStepperProps) => {\n const {\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n } = props;\n\n const catalogImportApi = useApi(catalogImportApiRef);\n const classes = useStyles();\n const state = useImportState({ initialUrl });\n\n const states = useMemo<StepperProvider>(\n () => generateStepper(state.activeFlow, defaultStepper),\n [generateStepper, state.activeFlow],\n );\n\n const render = (step: StepConfiguration) => {\n return (\n <Step>\n {step.stepLabel}\n <StepContent>{step.content}</StepContent>\n </Step>\n );\n };\n\n return (\n <InfoCard variant={variant}>\n <Stepper\n classes={{ root: classes.stepperRoot }}\n activeStep={state.activeStepNumber}\n orientation=\"vertical\"\n >\n {render(\n states.analyze(\n state as Extract<ImportState, { activeState: 'analyze' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n {render(\n states.prepare(\n state as Extract<ImportState, { activeState: 'prepare' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n {render(\n states.review(\n state as Extract<ImportState, { activeState: 'review' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n {render(\n states.finish(\n state as Extract<ImportState, { activeState: 'finish' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n </Stepper>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAgCA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,WAAa,EAAA;AAAA,IACX,OAAS,EAAA
|
|
1
|
+
{"version":3,"file":"ImportStepper.esm.js","sources":["../../../src/components/ImportStepper/ImportStepper.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 { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport Step from '@material-ui/core/Step';\nimport StepContent from '@material-ui/core/StepContent';\nimport Stepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { useMemo } from 'react';\nimport { catalogImportApiRef } from '../../api';\nimport { ImportFlows, ImportState, useImportState } from '../useImportState';\nimport {\n defaultGenerateStepper,\n defaultStepper,\n StepConfiguration,\n StepperProvider,\n} from './defaults';\n\nconst useStyles = makeStyles(() => ({\n stepperRoot: {\n padding: 0,\n },\n}));\n\n/**\n * Props for {@link ImportStepper}.\n *\n * @public\n */\nexport interface ImportStepperProps {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n}\n\n/**\n * The stepper that holds the different import stages.\n *\n * @public\n */\nexport const ImportStepper = (props: ImportStepperProps) => {\n const {\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n } = props;\n\n const catalogImportApi = useApi(catalogImportApiRef);\n const classes = useStyles();\n const state = useImportState({ initialUrl });\n\n const states = useMemo<StepperProvider>(\n () => generateStepper(state.activeFlow, defaultStepper),\n [generateStepper, state.activeFlow],\n );\n\n const render = (step: StepConfiguration) => {\n return (\n <Step>\n {step.stepLabel}\n <StepContent>{step.content}</StepContent>\n </Step>\n );\n };\n\n return (\n <InfoCard variant={variant}>\n <Stepper\n classes={{ root: classes.stepperRoot }}\n activeStep={state.activeStepNumber}\n orientation=\"vertical\"\n >\n {render(\n states.analyze(\n state as Extract<ImportState, { activeState: 'analyze' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n {render(\n states.prepare(\n state as Extract<ImportState, { activeState: 'prepare' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n {render(\n states.review(\n state as Extract<ImportState, { activeState: 'review' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n {render(\n states.finish(\n state as Extract<ImportState, { activeState: 'finish' }>,\n { apis: { catalogImportApi } },\n ),\n )}\n </Stepper>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAgCA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,WAAa,EAAA;AAAA,IACX,OAAS,EAAA;AAAA;AAEb,CAAE,CAAA,CAAA;AAqBW,MAAA,aAAA,GAAgB,CAAC,KAA8B,KAAA;AAC1D,EAAM,MAAA;AAAA,IACJ,UAAA;AAAA,IACA,eAAkB,GAAA,sBAAA;AAAA,IAClB;AAAA,GACE,GAAA,KAAA;AAEJ,EAAM,MAAA,gBAAA,GAAmB,OAAO,mBAAmB,CAAA;AACnD,EAAA,MAAM,UAAU,SAAU,EAAA;AAC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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.esm.js","sources":["../../../src/components/ImportStepper/defaults.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 Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport StepLabel from '@material-ui/core/StepLabel';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\nimport { BackButton } from '../Buttons';\nimport { asInputRef } from '../helpers';\nimport { StepFinishImportLocation } from '../StepFinishImportLocation';\nimport { StepInitAnalyzeUrl } from '../StepInitAnalyzeUrl';\nimport {\n AutocompleteTextField,\n StepPrepareCreatePullRequest,\n} from '../StepPrepareCreatePullRequest';\nimport { StepPrepareSelectLocations } from '../StepPrepareSelectLocations';\nimport { StepReviewLocation } from '../StepReviewLocation';\nimport { StepperApis } from '../types';\nimport { ImportFlows, ImportState } from '../useImportState';\n\nexport type StepConfiguration = {\n stepLabel: React.ReactElement;\n content: React.ReactElement;\n};\n\n/**\n * Defines the details of the stepper.\n *\n * @public\n */\nexport interface StepperProvider {\n analyze: (\n s: Extract<ImportState, { activeState: 'analyze' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n prepare: (\n s: Extract<ImportState, { activeState: 'prepare' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n review: (\n s: Extract<ImportState, { activeState: 'review' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n finish: (\n s: Extract<ImportState, { activeState: 'finish' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n}\n\n/**\n * The default stepper generation function.\n *\n * Override this function to customize the import flow. Each flow should at\n * least override the prepare operation.\n *\n * @param flow - the name of the active flow\n * @param defaults - the default steps\n * @public\n */\nexport function defaultGenerateStepper(\n flow: ImportFlows,\n defaults: StepperProvider,\n): StepperProvider {\n switch (flow) {\n // the prepare step is skipped but the label of the step is updated\n case 'single-location':\n return {\n ...defaults,\n prepare: () => ({\n stepLabel: (\n <StepLabel\n optional={\n <Typography variant=\"caption\">\n Discovered Locations: 1\n </Typography>\n }\n >\n Select Locations\n </StepLabel>\n ),\n content: <></>,\n }),\n };\n\n // let the user select one or more of the discovered locations in the prepare step\n case 'multiple-locations':\n return {\n ...defaults,\n prepare: (state, opts) => {\n if (state.analyzeResult.type !== 'locations') {\n return defaults.prepare(state, opts);\n }\n\n return {\n stepLabel: (\n <StepLabel\n optional={\n <Typography variant=\"caption\">\n Discovered Locations: {state.analyzeResult.locations.length}\n </Typography>\n }\n >\n Select Locations\n </StepLabel>\n ),\n content: (\n <StepPrepareSelectLocations\n analyzeResult={state.analyzeResult}\n prepareResult={state.prepareResult}\n onPrepare={state.onPrepare}\n onGoBack={state.onGoBack}\n />\n ),\n };\n },\n };\n\n case 'no-location':\n return {\n ...defaults,\n prepare: (state, opts) => {\n if (state.analyzeResult.type !== 'repository') {\n return defaults.prepare(state, opts);\n }\n\n return {\n stepLabel: <StepLabel>Create Pull Request</StepLabel>,\n content: (\n <StepPrepareCreatePullRequest\n analyzeResult={state.analyzeResult}\n onPrepare={state.onPrepare}\n onGoBack={state.onGoBack}\n renderFormFields={({\n values,\n setValue,\n formState,\n groupsLoading,\n groups,\n register,\n }) => (\n <>\n <Box marginTop={2}>\n <Typography variant=\"h6\">Pull Request Details</Typography>\n </Box>\n\n <TextField\n {...asInputRef(\n register('title', {\n required: true,\n }),\n )}\n label=\"Pull Request Title\"\n placeholder=\"Add Backstage catalog entity descriptor files\"\n margin=\"normal\"\n variant=\"outlined\"\n fullWidth\n error={Boolean(formState.errors.title)}\n required\n />\n\n <TextField\n {...asInputRef(\n register('body', {\n required: true,\n }),\n )}\n label=\"Pull Request Body\"\n placeholder=\"A describing text with Markdown support\"\n margin=\"normal\"\n variant=\"outlined\"\n fullWidth\n error={Boolean(formState.errors.body)}\n multiline\n required\n />\n\n <Box marginTop={2}>\n <Typography variant=\"h6\">Entity Configuration</Typography>\n </Box>\n\n <TextField\n {...asInputRef(\n register('componentName', { required: true }),\n )}\n label=\"Name of the created component\"\n placeholder=\"my-component\"\n margin=\"normal\"\n variant=\"outlined\"\n fullWidth\n error={Boolean(formState.errors.componentName)}\n required\n />\n\n {!values.useCodeowners && (\n <AutocompleteTextField\n name=\"owner\"\n errors={formState.errors}\n options={groups || []}\n loading={groupsLoading}\n loadingText=\"Loading groups…\"\n helperText=\"Select an owner from the list or enter a reference to a Group or a User\"\n errorHelperText=\"required value\"\n textFieldProps={{\n label: 'Entity Owner',\n placeholder: 'my-group',\n }}\n rules={{ required: true }}\n required\n />\n )}\n\n <FormControlLabel\n control={\n <Checkbox\n {...asInputRef(register('useCodeowners'))}\n onChange={(_, value) => {\n if (value) {\n setValue('owner', '');\n }\n }}\n />\n }\n label={\n <>\n Use <em>CODEOWNERS</em> file as Entity Owner\n </>\n }\n />\n <FormHelperText>\n WARNING: This may fail if no CODEOWNERS file is found at\n the target location.\n </FormHelperText>\n </>\n )}\n />\n ),\n };\n },\n };\n\n default:\n return defaults;\n }\n}\n\nexport const defaultStepper: StepperProvider = {\n analyze: (state, { apis }) => ({\n stepLabel: <StepLabel>Select URL</StepLabel>,\n content: (\n <StepInitAnalyzeUrl\n key=\"analyze\"\n analysisUrl={state.analysisUrl}\n onAnalysis={state.onAnalysis}\n disablePullRequest={!apis.catalogImportApi.preparePullRequest}\n />\n ),\n }),\n\n prepare: state => ({\n stepLabel: (\n <StepLabel optional={<Typography variant=\"caption\">Optional</Typography>}>\n Import Actions\n </StepLabel>\n ),\n content: <BackButton onClick={state.onGoBack} />,\n }),\n\n review: state => ({\n stepLabel: <StepLabel>Review</StepLabel>,\n content: (\n <StepReviewLocation\n prepareResult={state.prepareResult}\n onReview={state.onReview}\n onGoBack={state.onGoBack}\n />\n ),\n }),\n\n finish: state => ({\n stepLabel: <StepLabel>Finish</StepLabel>,\n content: (\n <StepFinishImportLocation\n prepareResult={state.prepareResult}\n onReset={state.onReset}\n />\n ),\n }),\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4EgB,SAAA,sBAAA,CACd,MACA,QACiB,EAAA;AACjB,EAAA,QAAQ,IAAM;AAAA;AAAA,IAEZ,KAAK,iBAAA;AACH,MAAO,OAAA;AAAA,QACL,GAAG,QAAA;AAAA,QACH,SAAS,OAAO;AAAA,UACd,SACE,kBAAA,KAAA,CAAA,aAAA;AAAA,YAAC,SAAA;AAAA,YAAA;AAAA,cACC,QACE,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,aAAU,yBAE9B,CAAA;AAAA,aAAA;AAAA,YAEH,kBAAA;AAAA,WAED;AAAA,UAEF,yBAAW,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,CAAA;AAAA,SACb,CAAA;AAAA,OACF,CAAA;AAAA;AAAA,IAGF,KAAK,oBAAA;AACH,MAAO,OAAA;AAAA,QACL,GAAG,QAAA;AAAA,QACH,OAAA,EAAS,CAAC,KAAA,EAAO,IAAS,KAAA;AACxB,UAAI,IAAA,KAAA,CAAM,aAAc,CAAA,IAAA,KAAS,WAAa,EAAA;AAC5C,YAAO,OAAA,QAAA,CAAS,OAAQ,CAAA,KAAA,EAAO,IAAI,CAAA,CAAA;AAAA,WACrC;AAEA,UAAO,OAAA;AAAA,YACL,SACE,kBAAA,KAAA,CAAA,aAAA;AAAA,cAAC,SAAA;AAAA,cAAA;AAAA,gBACC,QAAA,sCACG,UAAW,EAAA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,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAS,MAAM,QAAU,EAAA,CAAA;AAAA,GAChD,CAAA;AAAA,EAEA,QAAQ,CAAU,KAAA,MAAA;AAAA,IAChB,SAAA,kBAAY,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,IAAA,EAAU,QAAM,CAAA;AAAA,IAC5B,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,kBAAA;AAAA,MAAA;AAAA,QACC,eAAe,KAAM,CAAA,aAAA;AAAA,QACrB,UAAU,KAAM,CAAA,QAAA;AAAA,QAChB,UAAU,KAAM,CAAA,QAAA;AAAA,OAAA;AAAA,KAClB;AAAA,GAEJ,CAAA;AAAA,EAEA,QAAQ,CAAU,KAAA,MAAA;AAAA,IAChB,SAAA,kBAAY,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,IAAA,EAAU,QAAM,CAAA;AAAA,IAC5B,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,wBAAA;AAAA,MAAA;AAAA,QACC,eAAe,KAAM,CAAA,aAAA;AAAA,QACrB,SAAS,KAAM,CAAA,OAAA;AAAA,OAAA;AAAA,KACjB;AAAA,GAEJ,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"defaults.esm.js","sources":["../../../src/components/ImportStepper/defaults.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 Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport StepLabel from '@material-ui/core/StepLabel';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\nimport { BackButton } from '../Buttons';\nimport { asInputRef } from '../helpers';\nimport { StepFinishImportLocation } from '../StepFinishImportLocation';\nimport { StepInitAnalyzeUrl } from '../StepInitAnalyzeUrl';\nimport {\n AutocompleteTextField,\n StepPrepareCreatePullRequest,\n} from '../StepPrepareCreatePullRequest';\nimport { StepPrepareSelectLocations } from '../StepPrepareSelectLocations';\nimport { StepReviewLocation } from '../StepReviewLocation';\nimport { StepperApis } from '../types';\nimport { ImportFlows, ImportState } from '../useImportState';\n\nexport type StepConfiguration = {\n stepLabel: React.ReactElement;\n content: React.ReactElement;\n};\n\n/**\n * Defines the details of the stepper.\n *\n * @public\n */\nexport interface StepperProvider {\n analyze: (\n s: Extract<ImportState, { activeState: 'analyze' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n prepare: (\n s: Extract<ImportState, { activeState: 'prepare' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n review: (\n s: Extract<ImportState, { activeState: 'review' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n finish: (\n s: Extract<ImportState, { activeState: 'finish' }>,\n opts: { apis: StepperApis },\n ) => StepConfiguration;\n}\n\n/**\n * The default stepper generation function.\n *\n * Override this function to customize the import flow. Each flow should at\n * least override the prepare operation.\n *\n * @param flow - the name of the active flow\n * @param defaults - the default steps\n * @public\n */\nexport function defaultGenerateStepper(\n flow: ImportFlows,\n defaults: StepperProvider,\n): StepperProvider {\n switch (flow) {\n // the prepare step is skipped but the label of the step is updated\n case 'single-location':\n return {\n ...defaults,\n prepare: () => ({\n stepLabel: (\n <StepLabel\n optional={\n <Typography variant=\"caption\">\n Discovered Locations: 1\n </Typography>\n }\n >\n Select Locations\n </StepLabel>\n ),\n content: <></>,\n }),\n };\n\n // let the user select one or more of the discovered locations in the prepare step\n case 'multiple-locations':\n return {\n ...defaults,\n prepare: (state, opts) => {\n if (state.analyzeResult.type !== 'locations') {\n return defaults.prepare(state, opts);\n }\n\n return {\n stepLabel: (\n <StepLabel\n optional={\n <Typography variant=\"caption\">\n Discovered Locations: {state.analyzeResult.locations.length}\n </Typography>\n }\n >\n Select Locations\n </StepLabel>\n ),\n content: (\n <StepPrepareSelectLocations\n analyzeResult={state.analyzeResult}\n prepareResult={state.prepareResult}\n onPrepare={state.onPrepare}\n onGoBack={state.onGoBack}\n />\n ),\n };\n },\n };\n\n case 'no-location':\n return {\n ...defaults,\n prepare: (state, opts) => {\n if (state.analyzeResult.type !== 'repository') {\n return defaults.prepare(state, opts);\n }\n\n return {\n stepLabel: <StepLabel>Create Pull Request</StepLabel>,\n content: (\n <StepPrepareCreatePullRequest\n analyzeResult={state.analyzeResult}\n onPrepare={state.onPrepare}\n onGoBack={state.onGoBack}\n renderFormFields={({\n values,\n setValue,\n formState,\n groupsLoading,\n groups,\n register,\n }) => (\n <>\n <Box marginTop={2}>\n <Typography variant=\"h6\">Pull Request Details</Typography>\n </Box>\n\n <TextField\n {...asInputRef(\n register('title', {\n required: true,\n }),\n )}\n label=\"Pull Request Title\"\n placeholder=\"Add Backstage catalog entity descriptor files\"\n margin=\"normal\"\n variant=\"outlined\"\n fullWidth\n error={Boolean(formState.errors.title)}\n required\n />\n\n <TextField\n {...asInputRef(\n register('body', {\n required: true,\n }),\n )}\n label=\"Pull Request Body\"\n placeholder=\"A describing text with Markdown support\"\n margin=\"normal\"\n variant=\"outlined\"\n fullWidth\n error={Boolean(formState.errors.body)}\n multiline\n required\n />\n\n <Box marginTop={2}>\n <Typography variant=\"h6\">Entity Configuration</Typography>\n </Box>\n\n <TextField\n {...asInputRef(\n register('componentName', { required: true }),\n )}\n label=\"Name of the created component\"\n placeholder=\"my-component\"\n margin=\"normal\"\n variant=\"outlined\"\n fullWidth\n error={Boolean(formState.errors.componentName)}\n required\n />\n\n {!values.useCodeowners && (\n <AutocompleteTextField\n name=\"owner\"\n errors={formState.errors}\n options={groups || []}\n loading={groupsLoading}\n loadingText=\"Loading groups…\"\n helperText=\"Select an owner from the list or enter a reference to a Group or a User\"\n errorHelperText=\"required value\"\n textFieldProps={{\n label: 'Entity Owner',\n placeholder: 'my-group',\n }}\n rules={{ required: true }}\n required\n />\n )}\n\n <FormControlLabel\n control={\n <Checkbox\n {...asInputRef(register('useCodeowners'))}\n onChange={(_, value) => {\n if (value) {\n setValue('owner', '');\n }\n }}\n />\n }\n label={\n <>\n Use <em>CODEOWNERS</em> file as Entity Owner\n </>\n }\n />\n <FormHelperText>\n WARNING: This may fail if no CODEOWNERS file is found at\n the target location.\n </FormHelperText>\n </>\n )}\n />\n ),\n };\n },\n };\n\n default:\n return defaults;\n }\n}\n\nexport const defaultStepper: StepperProvider = {\n analyze: (state, { apis }) => ({\n stepLabel: <StepLabel>Select URL</StepLabel>,\n content: (\n <StepInitAnalyzeUrl\n key=\"analyze\"\n analysisUrl={state.analysisUrl}\n onAnalysis={state.onAnalysis}\n disablePullRequest={!apis.catalogImportApi.preparePullRequest}\n />\n ),\n }),\n\n prepare: state => ({\n stepLabel: (\n <StepLabel optional={<Typography variant=\"caption\">Optional</Typography>}>\n Import Actions\n </StepLabel>\n ),\n content: <BackButton onClick={state.onGoBack} />,\n }),\n\n review: state => ({\n stepLabel: <StepLabel>Review</StepLabel>,\n content: (\n <StepReviewLocation\n prepareResult={state.prepareResult}\n onReview={state.onReview}\n onGoBack={state.onGoBack}\n />\n ),\n }),\n\n finish: state => ({\n stepLabel: <StepLabel>Finish</StepLabel>,\n content: (\n <StepFinishImportLocation\n prepareResult={state.prepareResult}\n onReset={state.onReset}\n />\n ),\n }),\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4EgB,SAAA,sBAAA,CACd,MACA,QACiB,EAAA;AACjB,EAAA,QAAQ,IAAM;AAAA;AAAA,IAEZ,KAAK,iBAAA;AACH,MAAO,OAAA;AAAA,QACL,GAAG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sources":["../../../src/components/StepFinishImportLocation/StepFinishImportLocation.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 Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React from 'react';\nimport { BackButton, ViewComponentButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult } from '../useImportState';\nimport { Link } from '@backstage/core-components';\nimport partition from 'lodash/partition';\nimport { CompoundEntityRef, DEFAULT_NAMESPACE } from '@backstage/catalog-model';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport { useRouteRef } from '@backstage/core-plugin-api';\n\ntype Props = {\n prepareResult: PrepareResult;\n onReset: () => void;\n};\n\n// Among the newly registered entities, return a software entity (e.g. Component, API, Resource)\nconst filterComponentEntity = (\n newLocations: Array<{\n exists?: boolean;\n target: string;\n entities: CompoundEntityRef[];\n }>,\n): CompoundEntityRef | null => {\n for (const location of newLocations) {\n for (const entity of location.entities) {\n if (\n ['component', 'api', 'resource'].includes(\n entity.kind.toLocaleLowerCase('en-US'),\n )\n ) {\n return {\n kind: entity.kind.toLocaleLowerCase('en-US'),\n namespace:\n entity.namespace?.toLocaleLowerCase('en-US') ?? DEFAULT_NAMESPACE,\n name: entity.name,\n };\n }\n }\n }\n\n return null;\n};\n\nexport const StepFinishImportLocation = ({ prepareResult, onReset }: Props) => {\n const entityRoute = useRouteRef(entityRouteRef);\n\n if (prepareResult.type === 'repository') {\n return (\n <>\n <Typography paragraph>\n The following Pull Request has been opened:{' '}\n <Link\n to={prepareResult.pullRequest.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {prepareResult.pullRequest.url}\n </Link>\n </Typography>\n <Typography paragraph>\n Your entities will be imported as soon as the Pull Request is merged.\n </Typography>\n <Grid container spacing={0}>\n <BackButton onClick={onReset}>Register another</BackButton>\n </Grid>\n </>\n );\n }\n\n const [existingLocations, newLocations] = partition(\n prepareResult.locations,\n l => l.exists,\n );\n const newComponentEntity = filterComponentEntity(newLocations);\n return (\n <>\n {newLocations.length > 0 && (\n <>\n <Typography>\n The following entities have been added to the catalog:\n </Typography>\n\n <EntityListComponent\n locations={newLocations}\n locationListItemIcon={() => <LocationOnIcon />}\n withLinks\n />\n </>\n )}\n {existingLocations.length > 0 && (\n <>\n <Typography>\n A refresh was triggered for the following locations:\n </Typography>\n\n <EntityListComponent\n locations={existingLocations}\n locationListItemIcon={() => <LocationOnIcon />}\n withLinks\n />\n </>\n )}\n <Grid container spacing={0}>\n {newComponentEntity && (\n <ViewComponentButton to={entityRoute(newComponentEntity)}>\n View Component\n </ViewComponentButton>\n )}\n <BackButton onClick={onReset}>Register another</BackButton>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAmCA,MAAM,qBAAA,GAAwB,CAC5B,YAK6B,KAAA;AAC7B,EAAA,KAAA,MAAW,YAAY,YAAc,EAAA;AACnC,IAAW,KAAA,MAAA,MAAA,IAAU,SAAS,QAAU,EAAA;AACtC,MAAA,IACE,CAAC,WAAA,EAAa,KAAO,EAAA,UAAU,CAAE,CAAA,QAAA;AAAA,QAC/B,MAAA,CAAO,IAAK,CAAA,iBAAA,CAAkB,OAAO
|
|
1
|
+
{"version":3,"file":"StepFinishImportLocation.esm.js","sources":["../../../src/components/StepFinishImportLocation/StepFinishImportLocation.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 Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React from 'react';\nimport { BackButton, ViewComponentButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult } from '../useImportState';\nimport { Link } from '@backstage/core-components';\nimport partition from 'lodash/partition';\nimport { CompoundEntityRef, DEFAULT_NAMESPACE } from '@backstage/catalog-model';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport { useRouteRef } from '@backstage/core-plugin-api';\n\ntype Props = {\n prepareResult: PrepareResult;\n onReset: () => void;\n};\n\n// Among the newly registered entities, return a software entity (e.g. Component, API, Resource)\nconst filterComponentEntity = (\n newLocations: Array<{\n exists?: boolean;\n target: string;\n entities: CompoundEntityRef[];\n }>,\n): CompoundEntityRef | null => {\n for (const location of newLocations) {\n for (const entity of location.entities) {\n if (\n ['component', 'api', 'resource'].includes(\n entity.kind.toLocaleLowerCase('en-US'),\n )\n ) {\n return {\n kind: entity.kind.toLocaleLowerCase('en-US'),\n namespace:\n entity.namespace?.toLocaleLowerCase('en-US') ?? DEFAULT_NAMESPACE,\n name: entity.name,\n };\n }\n }\n }\n\n return null;\n};\n\nexport const StepFinishImportLocation = ({ prepareResult, onReset }: Props) => {\n const entityRoute = useRouteRef(entityRouteRef);\n\n if (prepareResult.type === 'repository') {\n return (\n <>\n <Typography paragraph>\n The following Pull Request has been opened:{' '}\n <Link\n to={prepareResult.pullRequest.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n {prepareResult.pullRequest.url}\n </Link>\n </Typography>\n <Typography paragraph>\n Your entities will be imported as soon as the Pull Request is merged.\n </Typography>\n <Grid container spacing={0}>\n <BackButton onClick={onReset}>Register another</BackButton>\n </Grid>\n </>\n );\n }\n\n const [existingLocations, newLocations] = partition(\n prepareResult.locations,\n l => l.exists,\n );\n const newComponentEntity = filterComponentEntity(newLocations);\n return (\n <>\n {newLocations.length > 0 && (\n <>\n <Typography>\n The following entities have been added to the catalog:\n </Typography>\n\n <EntityListComponent\n locations={newLocations}\n locationListItemIcon={() => <LocationOnIcon />}\n withLinks\n />\n </>\n )}\n {existingLocations.length > 0 && (\n <>\n <Typography>\n A refresh was triggered for the following locations:\n </Typography>\n\n <EntityListComponent\n locations={existingLocations}\n locationListItemIcon={() => <LocationOnIcon />}\n withLinks\n />\n </>\n )}\n <Grid container spacing={0}>\n {newComponentEntity && (\n <ViewComponentButton to={entityRoute(newComponentEntity)}>\n View Component\n </ViewComponentButton>\n )}\n <BackButton onClick={onReset}>Register another</BackButton>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAmCA,MAAM,qBAAA,GAAwB,CAC5B,YAK6B,KAAA;AAC7B,EAAA,KAAA,MAAW,YAAY,YAAc,EAAA;AACnC,IAAW,KAAA,MAAA,MAAA,IAAU,SAAS,QAAU,EAAA;AACtC,MAAA,IACE,CAAC,WAAA,EAAa,KAAO,EAAA,UAAU,CAAE,CAAA,QAAA;AAAA,QAC/B,MAAA,CAAO,IAAK,CAAA,iBAAA,CAAkB,OAAO;AAAA,OAEvC,EAAA;AACA,QAAO,OAAA;AAAA,UACL,IAAM,EAAA,MAAA,CAAO,IAAK,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,UAC3C,SACE,EAAA,MAAA,CAAO,SAAW,EAAA,iBAAA,CAAkB,OAAO,CAAK,IAAA,iBAAA;AAAA,UAClD,MAAM,MAAO,CAAA;AAAA,SACf;AAAA;AACF;AACF;AAGF,EAAO,OAAA,IAAA;AACT,CAAA;AAEO,MAAM,wBAA2B,GAAA,CAAC,EAAE,aAAA,EAAe,SAAqB,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A;AAAA;AAAA,GAEb,GAED,iBAAkB,CAAA,MAAA,GAAS,qBAExB,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,IAAA,EAAA,sDAEZ,CAEA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,iBAAA;AAAA,MACX,oBAAA,EAAsB,sBAAM,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,IAAA,CAAA;AAAA,MAC5C,SAAS,EAAA;AAAA;AAAA,GAEb,mBAED,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,WAAS,IAAC,EAAA,OAAA,EAAS,CACtB,EAAA,EAAA,kBAAA,oBACE,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA,EAAoB,IAAI,WAAY,CAAA,kBAAkB,CAAG,EAAA,EAAA,gBAE1D,CAEF,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAS,EAAA,OAAA,EAAA,EAAS,kBAAgB,CAChD,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepInitAnalyzeUrl.esm.js","sources":["../../../src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport TextField from '@material-ui/core/TextField';\nimport React, { useCallback, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { NextButton } from '../Buttons';\nimport { asInputRef } from '../helpers';\nimport { ImportFlows, PrepareResult } from '../useImportState';\n\ntype FormData = {\n url: string;\n};\n\n/**\n * Props for {@link StepInitAnalyzeUrl}.\n *\n * @public\n */\nexport interface StepInitAnalyzeUrlProps {\n onAnalysis: (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n ) => void;\n disablePullRequest?: boolean;\n analysisUrl?: string;\n exampleLocationUrl?: string;\n}\n\n/**\n * A form that lets the user input a url and analyze it for existing locations or potential entities.\n *\n * @param onAnalysis - is called when the analysis was successful\n * @param analysisUrl - a url that can be used as a default value\n * @param disablePullRequest - if true, repositories without entities will abort the wizard\n * @public\n */\nexport const StepInitAnalyzeUrl = (props: StepInitAnalyzeUrlProps) => {\n const {\n onAnalysis,\n analysisUrl = '',\n disablePullRequest = false,\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n } = props;\n\n const errorApi = useApi(errorApiRef);\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const {\n register,\n handleSubmit,\n formState: { errors },\n watch,\n } = useForm<FormData>({\n mode: 'onTouched',\n defaultValues: {\n url: analysisUrl,\n },\n });\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string | undefined>(undefined);\n\n const handleResult = useCallback(\n async ({ url }: FormData) => {\n setSubmitted(true);\n\n try {\n const analysisResult = await catalogImportApi.analyzeUrl(url);\n\n switch (analysisResult.type) {\n case 'repository':\n if (\n !disablePullRequest &&\n analysisResult.generatedEntities.length > 0\n ) {\n onAnalysis('no-location', url, analysisResult);\n } else {\n setError(\"Couldn't generate entities for your repository\");\n setSubmitted(false);\n }\n break;\n\n case 'locations': {\n if (analysisResult.locations.length === 1) {\n onAnalysis('single-location', url, analysisResult, {\n prepareResult: analysisResult,\n });\n } else if (analysisResult.locations.length > 1) {\n onAnalysis('multiple-locations', url, analysisResult);\n } else {\n setError('There are no entities at this location');\n setSubmitted(false);\n }\n break;\n }\n\n default: {\n const err = `Received unknown analysis result of type ${\n (analysisResult as any).type\n }. Please contact the support team.`;\n setError(err);\n setSubmitted(false);\n\n errorApi.post(new Error(err));\n break;\n }\n }\n } catch (e: any) {\n setError(e?.data?.error?.message ?? e.message);\n setSubmitted(false);\n }\n },\n [catalogImportApi, disablePullRequest, errorApi, onAnalysis],\n );\n\n return (\n <form onSubmit={handleSubmit(handleResult)}>\n <TextField\n {...asInputRef(\n register('url', {\n required: true,\n validate: {\n httpsValidator: (value: any) =>\n (typeof value === 'string' &&\n value.match(/^http[s]?:\\/\\//) !== null) ||\n 'Must start with http:// or https://.',\n },\n }),\n )}\n fullWidth\n id=\"url\"\n label=\"URL\"\n placeholder={exampleLocationUrl}\n helperText=\"Enter the full path to your entity file to start tracking your component\"\n margin=\"normal\"\n variant=\"outlined\"\n error={Boolean(errors.url)}\n required\n />\n\n {errors.url && (\n <FormHelperText error>{errors.url.message}</FormHelperText>\n )}\n\n {error && <FormHelperText error>{error}</FormHelperText>}\n\n <Grid container spacing={0}>\n <NextButton\n disabled={Boolean(errors.url) || !watch('url')}\n loading={submitted}\n type=\"submit\"\n >\n Analyze\n </NextButton>\n </Grid>\n </form>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAwDa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAM,MAAA;AAAA,IACJ,UAAA;AAAA,IACA,WAAc,GAAA,EAAA;AAAA,IACd,kBAAqB,GAAA,KAAA;AAAA,IACrB,kBAAqB,GAAA
|
|
1
|
+
{"version":3,"file":"StepInitAnalyzeUrl.esm.js","sources":["../../../src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.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 { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport TextField from '@material-ui/core/TextField';\nimport React, { useCallback, useState } from 'react';\nimport { useForm } from 'react-hook-form';\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { NextButton } from '../Buttons';\nimport { asInputRef } from '../helpers';\nimport { ImportFlows, PrepareResult } from '../useImportState';\n\ntype FormData = {\n url: string;\n};\n\n/**\n * Props for {@link StepInitAnalyzeUrl}.\n *\n * @public\n */\nexport interface StepInitAnalyzeUrlProps {\n onAnalysis: (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n ) => void;\n disablePullRequest?: boolean;\n analysisUrl?: string;\n exampleLocationUrl?: string;\n}\n\n/**\n * A form that lets the user input a url and analyze it for existing locations or potential entities.\n *\n * @param onAnalysis - is called when the analysis was successful\n * @param analysisUrl - a url that can be used as a default value\n * @param disablePullRequest - if true, repositories without entities will abort the wizard\n * @public\n */\nexport const StepInitAnalyzeUrl = (props: StepInitAnalyzeUrlProps) => {\n const {\n onAnalysis,\n analysisUrl = '',\n disablePullRequest = false,\n exampleLocationUrl = 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml',\n } = props;\n\n const errorApi = useApi(errorApiRef);\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const {\n register,\n handleSubmit,\n formState: { errors },\n watch,\n } = useForm<FormData>({\n mode: 'onTouched',\n defaultValues: {\n url: analysisUrl,\n },\n });\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string | undefined>(undefined);\n\n const handleResult = useCallback(\n async ({ url }: FormData) => {\n setSubmitted(true);\n\n try {\n const analysisResult = await catalogImportApi.analyzeUrl(url);\n\n switch (analysisResult.type) {\n case 'repository':\n if (\n !disablePullRequest &&\n analysisResult.generatedEntities.length > 0\n ) {\n onAnalysis('no-location', url, analysisResult);\n } else {\n setError(\"Couldn't generate entities for your repository\");\n setSubmitted(false);\n }\n break;\n\n case 'locations': {\n if (analysisResult.locations.length === 1) {\n onAnalysis('single-location', url, analysisResult, {\n prepareResult: analysisResult,\n });\n } else if (analysisResult.locations.length > 1) {\n onAnalysis('multiple-locations', url, analysisResult);\n } else {\n setError('There are no entities at this location');\n setSubmitted(false);\n }\n break;\n }\n\n default: {\n const err = `Received unknown analysis result of type ${\n (analysisResult as any).type\n }. Please contact the support team.`;\n setError(err);\n setSubmitted(false);\n\n errorApi.post(new Error(err));\n break;\n }\n }\n } catch (e: any) {\n setError(e?.data?.error?.message ?? e.message);\n setSubmitted(false);\n }\n },\n [catalogImportApi, disablePullRequest, errorApi, onAnalysis],\n );\n\n return (\n <form onSubmit={handleSubmit(handleResult)}>\n <TextField\n {...asInputRef(\n register('url', {\n required: true,\n validate: {\n httpsValidator: (value: any) =>\n (typeof value === 'string' &&\n value.match(/^http[s]?:\\/\\//) !== null) ||\n 'Must start with http:// or https://.',\n },\n }),\n )}\n fullWidth\n id=\"url\"\n label=\"URL\"\n placeholder={exampleLocationUrl}\n helperText=\"Enter the full path to your entity file to start tracking your component\"\n margin=\"normal\"\n variant=\"outlined\"\n error={Boolean(errors.url)}\n required\n />\n\n {errors.url && (\n <FormHelperText error>{errors.url.message}</FormHelperText>\n )}\n\n {error && <FormHelperText error>{error}</FormHelperText>}\n\n <Grid container spacing={0}>\n <NextButton\n disabled={Boolean(errors.url) || !watch('url')}\n loading={submitted}\n type=\"submit\"\n >\n Analyze\n </NextButton>\n </Grid>\n </form>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA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,YAChB,KAAM,CAAA,KAAA,CAAM,gBAAgB,CAAA,KAAM,IACpC,IAAA;AAAA;AACJ,SACD;AAAA,OACH;AAAA,MACA,SAAS,EAAA,IAAA;AAAA,MACT,EAAG,EAAA,KAAA;AAAA,MACH,KAAM,EAAA,KAAA;AAAA,MACN,WAAa,EAAA,kBAAA;AAAA,MACb,UAAW,EAAA,0EAAA;AAAA,MACX,MAAO,EAAA,QAAA;AAAA,MACP,OAAQ,EAAA,UAAA;AAAA,MACR,KAAA,EAAO,OAAQ,CAAA,MAAA,CAAO,GAAG,CAAA;AAAA,MACzB,QAAQ,EAAA;AAAA;AAAA,GACV,EAEC,OAAO,GACN,oBAAA,KAAA,CAAA,aAAA,CAAC,kBAAe,KAAK,EAAA,IAAA,EAAA,EAAE,MAAO,CAAA,GAAA,CAAI,OAAQ,CAAA,EAG3C,yBAAU,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,EAAe,KAAK,EAAA,IAAA,EAAA,EAAE,KAAM,CAAA,sCAEtC,IAAK,EAAA,EAAA,SAAA,EAAS,IAAC,EAAA,OAAA,EAAS,CACvB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,UAAU,OAAQ,CAAA,MAAA,CAAO,GAAG,CAAK,IAAA,CAAC,MAAM,KAAK,CAAA;AAAA,MAC7C,OAAS,EAAA,SAAA;AAAA,MACT,IAAK,EAAA;AAAA,KAAA;AAAA,IACN;AAAA,GAGH,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -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 React 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: string[];\n required?: boolean;\n\n errors?: FieldErrors;\n rules?: React.ComponentProps<typeof Controller>['rules'];\n\n loading?: boolean;\n loadingText?: string;\n\n helperText?: React.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 onChange={(_event: React.ChangeEvent<{}>, value: string | null) =>\n onChange(value)\n }\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 <React.Fragment>\n {loading ? (\n <CircularProgress color=\"inherit\" size=\"1em\" />\n ) : null}\n {params.InputProps.endAdornment}\n </React.Fragment>\n ),\n }}\n {...textFieldProps}\n />\n )}\n />\n )}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;AAkDa,MAAA,qBAAA,GAAwB,CACnC,KACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,OAAU,GAAA,KAAA;AAAA,IACV,WAAA;AAAA,IACA,UAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAiB
|
|
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 React 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: string[];\n required?: boolean;\n\n errors?: FieldErrors;\n rules?: React.ComponentProps<typeof Controller>['rules'];\n\n loading?: boolean;\n loadingText?: string;\n\n helperText?: React.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 onChange={(_event: React.ChangeEvent<{}>, value: string | null) =>\n onChange(value)\n }\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 <React.Fragment>\n {loading ? (\n <CircularProgress color=\"inherit\" size=\"1em\" />\n ) : null}\n {params.InputProps.endAdornment}\n </React.Fragment>\n ),\n }}\n {...textFieldProps}\n />\n )}\n />\n )}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;AAkDa,MAAA,qBAAA,GAAwB,CACnC,KACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,OAAU,GAAA,KAAA;AAAA,IACV,WAAA;AAAA,IACA,UAAA;AAAA,IACA,eAAA;AAAA,IACA,iBAAiB;AAAC,GAChB,GAAA,KAAA;AAEJ,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,KAAA;AAAA,MACA,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAA,IAClB,qBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,YAAA;AAAA,QAAA;AAAA,UACC,OAAA;AAAA,UACA,WAAA;AAAA,UACA,OAAA,EAAS,WAAW,EAAC;AAAA,UACrB,UAAU,EAAA,IAAA;AAAA,UACV,QAAQ,EAAA,IAAA;AAAA,UACR,QAAU,EAAA,CAAC,MAA+B,EAAA,KAAA,KACxC,SAAS,KAAK,CAAA;AAAA,UAEhB,aAAa,CACX,MAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,YAAC,SAAA;AAAA,YAAA;AAAA,cACE,GAAG,MAAA;AAAA,cACJ,UAAa,EAAA,MAAA,GAAS,IAAI,CAAA,IAAK,eAAoB,IAAA,UAAA;AAAA,cACnD,KAAO,EAAA,OAAA,CAAQ,MAAS,GAAA,IAAI,CAAC,CAAA;AAAA,cAC7B,MAAO,EAAA,QAAA;AAAA,cACP,OAAQ,EAAA,UAAA;AAAA,cACR,QAAA;AAAA,cACA,UAAY,EAAA;AAAA,gBACV,GAAG,MAAO,CAAA,UAAA;AAAA,gBACV,8BACG,KAAA,CAAA,aAAA,CAAA,KAAA,CAAM,QAAN,EAAA,IAAA,EACE,0BACE,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAiB,KAAM,EAAA,SAAA,EAAU,MAAK,KAAM,EAAA,CAAA,GAC3C,IACH,EAAA,MAAA,CAAO,WAAW,YACrB;AAAA,eAEJ;AAAA,cACC,GAAG;AAAA;AAAA;AACN;AAAA;AAEJ;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreparePullRequestForm.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.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 React from 'react';\nimport {\n FormProvider,\n SubmitHandler,\n useForm,\n UseFormProps,\n UseFormReturn,\n} from 'react-hook-form';\n\n/**\n * Props for {@link PreparePullRequestForm}.\n *\n * @public\n */\nexport type PreparePullRequestFormProps<\n TFieldValues extends Record<string, any>,\n> = Pick<UseFormProps<TFieldValues>, 'defaultValues'> & {\n onSubmit: SubmitHandler<TFieldValues>;\n\n render: (\n props: Pick<\n UseFormReturn<TFieldValues>,\n 'formState' | 'register' | 'control' | 'setValue'\n > & {\n values: TFieldValues;\n },\n ) => React.ReactNode;\n};\n\n/**\n * A form wrapper that creates a form that is used to prepare a pull request. It\n * hosts the form logic.\n *\n * @param defaultValues - the default values of the form\n * @param onSubmit - a callback that is executed when the form is submitted\n * (initiated by a button of type=\"submit\")\n * @param render - render the form elements\n * @public\n */\nexport const PreparePullRequestForm = <\n TFieldValues extends Record<string, any>,\n>(\n props: PreparePullRequestFormProps<TFieldValues>,\n) => {\n const { defaultValues, onSubmit, render } = props;\n\n const methods = useForm<TFieldValues>({ mode: 'onTouched', defaultValues });\n const { handleSubmit, watch, control, register, formState, setValue } =\n methods;\n\n return (\n <FormProvider {...methods}>\n <form onSubmit={handleSubmit(onSubmit)}>\n {render({ values: watch(), formState, register, control, setValue })}\n </form>\n </FormProvider>\n );\n};\n"],"names":[],"mappings":";;;AAuDa,MAAA,sBAAA,GAAyB,CAGpC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,aAAA,EAAe,QAAU,EAAA,MAAA,EAAW,GAAA,KAAA
|
|
1
|
+
{"version":3,"file":"PreparePullRequestForm.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.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 React from 'react';\nimport {\n FormProvider,\n SubmitHandler,\n useForm,\n UseFormProps,\n UseFormReturn,\n} from 'react-hook-form';\n\n/**\n * Props for {@link PreparePullRequestForm}.\n *\n * @public\n */\nexport type PreparePullRequestFormProps<\n TFieldValues extends Record<string, any>,\n> = Pick<UseFormProps<TFieldValues>, 'defaultValues'> & {\n onSubmit: SubmitHandler<TFieldValues>;\n\n render: (\n props: Pick<\n UseFormReturn<TFieldValues>,\n 'formState' | 'register' | 'control' | 'setValue'\n > & {\n values: TFieldValues;\n },\n ) => React.ReactNode;\n};\n\n/**\n * A form wrapper that creates a form that is used to prepare a pull request. It\n * hosts the form logic.\n *\n * @param defaultValues - the default values of the form\n * @param onSubmit - a callback that is executed when the form is submitted\n * (initiated by a button of type=\"submit\")\n * @param render - render the form elements\n * @public\n */\nexport const PreparePullRequestForm = <\n TFieldValues extends Record<string, any>,\n>(\n props: PreparePullRequestFormProps<TFieldValues>,\n) => {\n const { defaultValues, onSubmit, render } = props;\n\n const methods = useForm<TFieldValues>({ mode: 'onTouched', defaultValues });\n const { handleSubmit, watch, control, register, formState, setValue } =\n methods;\n\n return (\n <FormProvider {...methods}>\n <form onSubmit={handleSubmit(onSubmit)}>\n {render({ values: watch(), formState, register, control, setValue })}\n </form>\n </FormProvider>\n );\n};\n"],"names":[],"mappings":";;;AAuDa,MAAA,sBAAA,GAAyB,CAGpC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,aAAA,EAAe,QAAU,EAAA,MAAA,EAAW,GAAA,KAAA;AAE5C,EAAA,MAAM,UAAU,OAAsB,CAAA,EAAE,IAAM,EAAA,WAAA,EAAa,eAAe,CAAA;AAC1E,EAAA,MAAM,EAAE,YAAc,EAAA,KAAA,EAAO,SAAS,QAAU,EAAA,SAAA,EAAW,UACzD,GAAA,OAAA;AAEF,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,gBAAc,GAAG,OAAA,EAAA,sCACf,MAAK,EAAA,EAAA,QAAA,EAAU,aAAa,QAAQ,CAAA,EAAA,EAClC,OAAO,EAAE,MAAA,EAAQ,OAAS,EAAA,SAAA,EAAW,UAAU,OAAS,EAAA,QAAA,EAAU,CACrE,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewCatalogInfoComponent.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/PreviewCatalogInfoComponent.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 Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport React from 'react';\nimport YAML from 'yaml';\nimport { CodeSnippet } from '@backstage/core-components';\nimport { trimEnd } from 'lodash';\nimport { useCatalogFilename } from '../../hooks';\n\n/**\n * Props for {@link PreviewCatalogInfoComponent}.\n *\n * @public\n */\nexport interface PreviewCatalogInfoComponentProps {\n repositoryUrl: string;\n entities: Entity[];\n classes?: { card?: string; cardContent?: string };\n}\n\n/**\n * Previews information about an entity to create.\n *\n * @public\n */\nexport const PreviewCatalogInfoComponent = (\n props: PreviewCatalogInfoComponentProps,\n) => {\n const { repositoryUrl, entities, classes } = props;\n const catalogFilename = useCatalogFilename();\n\n return (\n <Card variant=\"outlined\" className={classes?.card}>\n <CardHeader\n title={\n <code>{`${trimEnd(repositoryUrl, '/')}/${catalogFilename}`}</code>\n }\n />\n\n <CardContent className={classes?.cardContent}>\n <CodeSnippet\n text={entities\n .map(e => YAML.stringify(e))\n .join('---\\n')\n .trim()}\n language=\"yaml\"\n />\n </CardContent>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA0Ca,MAAA,2BAAA,GAA8B,CACzC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,aAAA,EAAe,QAAU,EAAA,OAAA,EAAY,GAAA,KAAA
|
|
1
|
+
{"version":3,"file":"PreviewCatalogInfoComponent.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/PreviewCatalogInfoComponent.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 Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport React from 'react';\nimport YAML from 'yaml';\nimport { CodeSnippet } from '@backstage/core-components';\nimport { trimEnd } from 'lodash';\nimport { useCatalogFilename } from '../../hooks';\n\n/**\n * Props for {@link PreviewCatalogInfoComponent}.\n *\n * @public\n */\nexport interface PreviewCatalogInfoComponentProps {\n repositoryUrl: string;\n entities: Entity[];\n classes?: { card?: string; cardContent?: string };\n}\n\n/**\n * Previews information about an entity to create.\n *\n * @public\n */\nexport const PreviewCatalogInfoComponent = (\n props: PreviewCatalogInfoComponentProps,\n) => {\n const { repositoryUrl, entities, classes } = props;\n const catalogFilename = useCatalogFilename();\n\n return (\n <Card variant=\"outlined\" className={classes?.card}>\n <CardHeader\n title={\n <code>{`${trimEnd(repositoryUrl, '/')}/${catalogFilename}`}</code>\n }\n />\n\n <CardContent className={classes?.cardContent}>\n <CodeSnippet\n text={entities\n .map(e => YAML.stringify(e))\n .join('---\\n')\n .trim()}\n language=\"yaml\"\n />\n </CardContent>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA0Ca,MAAA,2BAAA,GAA8B,CACzC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,aAAA,EAAe,QAAU,EAAA,OAAA,EAAY,GAAA,KAAA;AAC7C,EAAA,MAAM,kBAAkB,kBAAmB,EAAA;AAE3C,EAAA,2CACG,IAAK,EAAA,EAAA,OAAA,EAAQ,UAAW,EAAA,SAAA,EAAW,SAAS,IAC3C,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA,kBACG,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAM,CAAG,EAAA,OAAA,CAAQ,eAAe,GAAG,CAAC,CAAI,CAAA,EAAA,eAAe,CAAG,CAAA;AAAA;AAAA,GAI/D,kBAAA,KAAA,CAAA,aAAA,CAAC,WAAY,EAAA,EAAA,SAAA,EAAW,SAAS,WAC/B,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,QAAA,CACH,GAAI,CAAA,CAAA,CAAA,KAAK,IAAK,CAAA,SAAA,CAAU,CAAC,CAAC,CAC1B,CAAA,IAAA,CAAK,OAAO,CAAA,CACZ,IAAK,EAAA;AAAA,MACR,QAAS,EAAA;AAAA;AAAA,GAEb,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewPullRequestComponent.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/PreviewPullRequestComponent.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 Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport React from 'react';\nimport { MarkdownContent } from '@backstage/core-components';\n\n/**\n * Props for {@link PreviewPullRequestComponent}.\n *\n * @public\n */\nexport interface PreviewPullRequestComponentProps {\n title: string;\n description: string;\n classes?: { card?: string; cardContent?: string };\n}\n\n/**\n * Previews a pull request.\n *\n * @public\n */\nexport const PreviewPullRequestComponent = (\n props: PreviewPullRequestComponentProps,\n) => {\n const { title, description, classes } = props;\n return (\n <Card variant=\"outlined\" className={classes?.card}>\n <CardHeader title={title} subheader=\"Create a new Pull Request\" />\n <CardContent className={classes?.cardContent}>\n <MarkdownContent content={description} />\n </CardContent>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsCa,MAAA,2BAAA,GAA8B,CACzC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,KAAA,EAAO,WAAa,EAAA,OAAA,EAAY,GAAA,KAAA
|
|
1
|
+
{"version":3,"file":"PreviewPullRequestComponent.esm.js","sources":["../../../src/components/StepPrepareCreatePullRequest/PreviewPullRequestComponent.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 Card from '@material-ui/core/Card';\nimport CardContent from '@material-ui/core/CardContent';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport React from 'react';\nimport { MarkdownContent } from '@backstage/core-components';\n\n/**\n * Props for {@link PreviewPullRequestComponent}.\n *\n * @public\n */\nexport interface PreviewPullRequestComponentProps {\n title: string;\n description: string;\n classes?: { card?: string; cardContent?: string };\n}\n\n/**\n * Previews a pull request.\n *\n * @public\n */\nexport const PreviewPullRequestComponent = (\n props: PreviewPullRequestComponentProps,\n) => {\n const { title, description, classes } = props;\n return (\n <Card variant=\"outlined\" className={classes?.card}>\n <CardHeader title={title} subheader=\"Create a new Pull Request\" />\n <CardContent className={classes?.cardContent}>\n <MarkdownContent content={description} />\n </CardContent>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsCa,MAAA,2BAAA,GAA8B,CACzC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,KAAA,EAAO,WAAa,EAAA,OAAA,EAAY,GAAA,KAAA;AACxC,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,OAAQ,EAAA,UAAA,EAAW,WAAW,OAAS,EAAA,IAAA,EAAA,kBAC1C,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,KAAc,EAAA,SAAA,EAAU,6BAA4B,CAChE,kBAAA,KAAA,CAAA,aAAA,CAAC,WAAY,EAAA,EAAA,SAAA,EAAW,OAAS,EAAA,WAAA,EAAA,sCAC9B,eAAgB,EAAA,EAAA,OAAA,EAAS,WAAa,EAAA,CACzC,CACF,CAAA;AAEJ;;;;"}
|
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 { assertError } from '@backstage/errors';\nimport {\n catalogApiRef,\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 React, { useCallback, useEffect, useState } from 'react';\nimport { UnpackNestedValue, UseFormReturn } from 'react-hook-form';\nimport useAsync from 'react-use/esm/useAsync';\nimport YAML from 'yaml';\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\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 * 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 ) => React.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 classes = useStyles();\n const catalogApi = useApi(catalogApiRef);\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 return groupEntities.items\n .map(e => humanizeEntityRef(e, { defaultKind: 'group' }))\n .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 assertError(e);\n setError(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 You entered a link to a {analyzeResult.integrationType} repository but a{' '}\n <code>{catalogFilename}</code> could not be found. Use this form to open\n a Pull Request that creates one.\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\">Preview Pull Request</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\">Preview Entities</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 Create PR\n </NextButton>\n </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,UAAU,MAAO,CAAA,KAAA;AAAA,WACrB;AAAA,UACA,OAAS,EAAA,SAAA;AAAA,SAAA;AAAA,QACV,WAAA;AAAA,OAGH,CACF,CAAA;AAAA,KAAA;AAAA,GAIR,CAAA,CAAA;AAEJ;;;;"}
|
|
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 { assertError } from '@backstage/errors';\nimport {\n catalogApiRef,\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 React, { useCallback, useEffect, useState } from 'react';\nimport { UnpackNestedValue, UseFormReturn } from 'react-hook-form';\nimport useAsync from 'react-use/esm/useAsync';\nimport YAML from 'yaml';\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\nimport { useCatalogFilename } from '../../hooks';\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 * 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 ) => React.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 classes = useStyles();\n const catalogApi = useApi(catalogApiRef);\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 return groupEntities.items\n .map(e => humanizeEntityRef(e, { defaultKind: 'group' }))\n .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 assertError(e);\n setError(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 You entered a link to a {analyzeResult.integrationType} repository but a{' '}\n <code>{catalogFilename}</code> could not be found. Use this form to open\n a Pull Request that creates one.\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\">Preview Pull Request</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\">Preview Entities</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 Create PR\n </NextButton>\n </Grid>\n </>\n )}\n />\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,WAAa,EAAA;AAAA,IACX,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA,GAC5B;AAAA,EACA,kBAAoB,EAAA;AAAA,IAClB,UAAY,EAAA;AAAA;AAEhB,CAAE,CAAA,CAAA;AAmCc,SAAA,gBAAA,CACd,QACA,EAAA,aAAA,EACA,KACU,EAAA;AACV,EAAO,OAAA,QAAA,CAAS,IAAI,CAAM,CAAA,MAAA;AAAA,IACxB,GAAG,CAAA;AAAA,IACH,YAAY,CAAE,CAAA,UAAA;AAAA,IACd,MAAM,CAAE,CAAA,IAAA;AAAA,IACR,QAAU,EAAA;AAAA,MACR,GAAG,CAAE,CAAA,QAAA;AAAA,MACL,IAAM,EAAA;AAAA,KACR;AAAA,IACA,IAAM,EAAA;AAAA,MACJ,GAAG,CAAE,CAAA,IAAA;AAAA,MACL,GAAI,KAAA,GAAQ,EAAE,KAAA,KAAU;AAAC;AAC3B,GACA,CAAA,CAAA;AACJ;AAOa,MAAA,4BAAA,GAA+B,CAC1C,KACG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A;AAAA,UACC,IAAK,EAAA,QAAA;AAAA,UACL,QAAU,EAAA,OAAA;AAAA,YACR,UAAU,MAAO,CAAA,KAAA,IACf,UAAU,MAAO,CAAA,IAAA,IACjB,UAAU,MAAO,CAAA;AAAA,WACrB;AAAA,UACA,OAAS,EAAA;AAAA,SAAA;AAAA,QACV;AAAA,OAGH,CACF;AAAA;AAAA,GAIR,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepPrepareSelectLocations.esm.js","sources":["../../../src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.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 Checkbox from '@material-ui/core/Checkbox';\nimport Grid from '@material-ui/core/Grid';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Typography from '@material-ui/core/Typography';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React, { useCallback, useState } from 'react';\nimport { AnalyzeResult } from '../../api';\nimport { BackButton, NextButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult } from '../useImportState';\nimport partition from 'lodash/partition';\n\ntype Props = {\n analyzeResult: Extract<AnalyzeResult, { type: 'locations' }>;\n prepareResult?: PrepareResult;\n onPrepare: (result: PrepareResult) => void;\n onGoBack?: () => void;\n};\n\n/**\n * A form that lets a user select one of a list of locations to import\n *\n * @param analyzeResult - the result of the analysis\n * @param prepareResult - the selectected locations from a previous step\n * @param onPrepare - called after the selection\n * @param onGoBack - called to go back to the previous step\n */\nexport const StepPrepareSelectLocations = ({\n analyzeResult,\n prepareResult,\n onPrepare,\n onGoBack,\n}: Props) => {\n const [selectedUrls, setSelectedUrls] = useState<string[]>(\n prepareResult?.locations.map(l => l.target) || [],\n );\n\n const [existingLocations, locations] = partition(\n analyzeResult?.locations,\n l => l.exists,\n );\n\n const handleResult = useCallback(async () => {\n onPrepare({\n type: 'locations',\n locations: locations.filter((l: any) => selectedUrls.includes(l.target)),\n });\n }, [locations, onPrepare, selectedUrls]);\n\n const onItemClick = (url: string) => {\n setSelectedUrls(urls =>\n urls.includes(url) ? urls.filter(u => u !== url) : urls.concat(url),\n );\n };\n\n const onSelectAll = () => {\n setSelectedUrls(urls =>\n urls.length < locations.length ? locations.map(l => l.target) : [],\n );\n };\n\n return (\n <>\n {locations.length > 0 && (\n <>\n <Typography>\n Select one or more locations that are present in your git\n repository:\n </Typography>\n <EntityListComponent\n firstListItem={\n <ListItem dense button onClick={onSelectAll}>\n <ListItemIcon>\n <Checkbox\n edge=\"start\"\n checked={selectedUrls.length === locations.length}\n indeterminate={\n selectedUrls.length > 0 &&\n selectedUrls.length < locations.length\n }\n tabIndex={-1}\n disableRipple\n />\n </ListItemIcon>\n <ListItemText primary=\"Select All\" />\n </ListItem>\n }\n onItemClick={onItemClick}\n locations={locations}\n locationListItemIcon={target => (\n <Checkbox\n edge=\"start\"\n checked={selectedUrls.includes(target)}\n tabIndex={-1}\n disableRipple\n />\n )}\n collapsed\n />\n </>\n )}\n\n {existingLocations.length > 0 && (\n <>\n <Typography>These locations already exist in the catalog:</Typography>\n <EntityListComponent\n locations={existingLocations}\n locationListItemIcon={() => <LocationOnIcon />}\n withLinks\n collapsed\n />\n </>\n )}\n\n <Grid container spacing={0}>\n {onGoBack && <BackButton onClick={onGoBack} />}\n <NextButton disabled={selectedUrls.length === 0} onClick={handleResult}>\n Review\n </NextButton>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA6CO,MAAM,6BAA6B,CAAC;AAAA,EACzC,aAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA
|
|
1
|
+
{"version":3,"file":"StepPrepareSelectLocations.esm.js","sources":["../../../src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.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 Checkbox from '@material-ui/core/Checkbox';\nimport Grid from '@material-ui/core/Grid';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Typography from '@material-ui/core/Typography';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React, { useCallback, useState } from 'react';\nimport { AnalyzeResult } from '../../api';\nimport { BackButton, NextButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult } from '../useImportState';\nimport partition from 'lodash/partition';\n\ntype Props = {\n analyzeResult: Extract<AnalyzeResult, { type: 'locations' }>;\n prepareResult?: PrepareResult;\n onPrepare: (result: PrepareResult) => void;\n onGoBack?: () => void;\n};\n\n/**\n * A form that lets a user select one of a list of locations to import\n *\n * @param analyzeResult - the result of the analysis\n * @param prepareResult - the selectected locations from a previous step\n * @param onPrepare - called after the selection\n * @param onGoBack - called to go back to the previous step\n */\nexport const StepPrepareSelectLocations = ({\n analyzeResult,\n prepareResult,\n onPrepare,\n onGoBack,\n}: Props) => {\n const [selectedUrls, setSelectedUrls] = useState<string[]>(\n prepareResult?.locations.map(l => l.target) || [],\n );\n\n const [existingLocations, locations] = partition(\n analyzeResult?.locations,\n l => l.exists,\n );\n\n const handleResult = useCallback(async () => {\n onPrepare({\n type: 'locations',\n locations: locations.filter((l: any) => selectedUrls.includes(l.target)),\n });\n }, [locations, onPrepare, selectedUrls]);\n\n const onItemClick = (url: string) => {\n setSelectedUrls(urls =>\n urls.includes(url) ? urls.filter(u => u !== url) : urls.concat(url),\n );\n };\n\n const onSelectAll = () => {\n setSelectedUrls(urls =>\n urls.length < locations.length ? locations.map(l => l.target) : [],\n );\n };\n\n return (\n <>\n {locations.length > 0 && (\n <>\n <Typography>\n Select one or more locations that are present in your git\n repository:\n </Typography>\n <EntityListComponent\n firstListItem={\n <ListItem dense button onClick={onSelectAll}>\n <ListItemIcon>\n <Checkbox\n edge=\"start\"\n checked={selectedUrls.length === locations.length}\n indeterminate={\n selectedUrls.length > 0 &&\n selectedUrls.length < locations.length\n }\n tabIndex={-1}\n disableRipple\n />\n </ListItemIcon>\n <ListItemText primary=\"Select All\" />\n </ListItem>\n }\n onItemClick={onItemClick}\n locations={locations}\n locationListItemIcon={target => (\n <Checkbox\n edge=\"start\"\n checked={selectedUrls.includes(target)}\n tabIndex={-1}\n disableRipple\n />\n )}\n collapsed\n />\n </>\n )}\n\n {existingLocations.length > 0 && (\n <>\n <Typography>These locations already exist in the catalog:</Typography>\n <EntityListComponent\n locations={existingLocations}\n locationListItemIcon={() => <LocationOnIcon />}\n withLinks\n collapsed\n />\n </>\n )}\n\n <Grid container spacing={0}>\n {onGoBack && <BackButton onClick={onGoBack} />}\n <NextButton disabled={selectedUrls.length === 0} onClick={handleResult}>\n Review\n </NextButton>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA6CO,MAAM,6BAA6B,CAAC;AAAA,EACzC,aAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAa,KAAA;AACX,EAAM,MAAA,CAAC,YAAc,EAAA,eAAe,CAAI,GA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C5C,SAAS,EAAA,IAAA;AAAA,MACT,SAAS,EAAA;AAAA;AAAA,GAEb,CAGF,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,SAAA,EAAS,MAAC,OAAS,EAAA,CAAA,EAAA,EACtB,QAAY,oBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAS,UAAU,CAC5C,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,QAAA,EAAU,YAAa,CAAA,MAAA,KAAW,GAAG,OAAS,EAAA,YAAA,EAAA,EAAc,QAExE,CACF,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepReviewLocation.esm.js","sources":["../../../src/components/StepReviewLocation/StepReviewLocation.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 { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React, { useCallback, useState } from 'react';\nimport { BackButton, NextButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult, ReviewResult } from '../useImportState';\n\nimport { configApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { Link } from '@backstage/core-components';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { assertError } from '@backstage/errors';\n\ntype Props = {\n prepareResult: PrepareResult;\n onReview: (result: ReviewResult) => void;\n onGoBack?: () => void;\n};\n\nexport const StepReviewLocation = ({\n prepareResult,\n onReview,\n onGoBack,\n}: Props) => {\n const catalogApi = useApi(catalogApiRef);\n const configApi = useApi(configApiRef);\n const analytics = useAnalytics();\n\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string>();\n const exists =\n prepareResult.type === 'locations' &&\n prepareResult.locations.some(l => l.exists)\n ? true\n : false;\n const handleClick = useCallback(async () => {\n setSubmitted(true);\n analytics.captureEvent('click', 'import entity');\n try {\n let refreshed = new Array<{ target: string }>();\n if (prepareResult.type === 'locations') {\n refreshed = await Promise.all(\n prepareResult.locations\n .filter(l => l.exists)\n .map(async l => {\n const ref = stringifyEntityRef(l.entities[0] ?? l);\n await catalogApi.refreshEntity(ref);\n return { target: l.target };\n }),\n );\n }\n\n const locations = await Promise.all(\n prepareResult.locations\n .filter((l: unknown) => !(l as { exists?: boolean }).exists)\n .map(async l => {\n const result = await catalogApi.addLocation({\n type: 'url',\n target: l.target,\n });\n return {\n target: result.location.target,\n entities: result.entities,\n };\n }),\n );\n\n onReview({\n ...prepareResult,\n ...{ refreshed },\n locations,\n });\n } catch (e) {\n assertError(e);\n // TODO: this error should be handled differently. We add it as 'optional' and\n // it is not uncommon that a PR has not been merged yet.\n if (\n prepareResult.type === 'repository' &&\n e.message.startsWith(\n 'Location was added but has no entities specified yet',\n )\n ) {\n onReview({\n ...prepareResult,\n locations: prepareResult.locations.map(l => ({\n target: l.target,\n entities: [],\n })),\n });\n } else {\n setError(e.message);\n setSubmitted(false);\n }\n }\n }, [prepareResult, onReview, catalogApi, analytics]);\n\n return (\n <>\n {prepareResult.type === 'repository' && (\n <>\n <Typography paragraph>\n The following Pull Request has been opened:{' '}\n <Link\n to={prepareResult.pullRequest.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {prepareResult.pullRequest.url}\n </Link>\n </Typography>\n\n <Typography paragraph>\n You can already import the location and {appTitle} will fetch the\n entities as soon as the Pull Request is merged.\n </Typography>\n </>\n )}\n\n <Typography>\n {exists\n ? 'The following locations already exist in the catalog:'\n : 'The following entities will be added to the catalog:'}\n </Typography>\n\n <EntityListComponent\n locations={prepareResult.locations}\n locationListItemIcon={() => <LocationOnIcon />}\n />\n\n {error && <FormHelperText error>{error}</FormHelperText>}\n\n <Grid container spacing={0}>\n {onGoBack && <BackButton onClick={onGoBack} disabled={submitted} />}\n <NextButton\n disabled={submitted}\n loading={submitted}\n onClick={() => handleClick()}\n >\n {exists ? 'Refresh' : 'Import'}\n </NextButton>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAqCO,MAAM,qBAAqB,CAAC;AAAA,EACjC,aAAA;AAAA,EACA,QAAA;AAAA,EACA
|
|
1
|
+
{"version":3,"file":"StepReviewLocation.esm.js","sources":["../../../src/components/StepReviewLocation/StepReviewLocation.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 { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React, { useCallback, useState } from 'react';\nimport { BackButton, NextButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult, ReviewResult } from '../useImportState';\n\nimport { configApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { Link } from '@backstage/core-components';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { assertError } from '@backstage/errors';\n\ntype Props = {\n prepareResult: PrepareResult;\n onReview: (result: ReviewResult) => void;\n onGoBack?: () => void;\n};\n\nexport const StepReviewLocation = ({\n prepareResult,\n onReview,\n onGoBack,\n}: Props) => {\n const catalogApi = useApi(catalogApiRef);\n const configApi = useApi(configApiRef);\n const analytics = useAnalytics();\n\n const appTitle = configApi.getOptionalString('app.title') || 'Backstage';\n\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string>();\n const exists =\n prepareResult.type === 'locations' &&\n prepareResult.locations.some(l => l.exists)\n ? true\n : false;\n const handleClick = useCallback(async () => {\n setSubmitted(true);\n analytics.captureEvent('click', 'import entity');\n try {\n let refreshed = new Array<{ target: string }>();\n if (prepareResult.type === 'locations') {\n refreshed = await Promise.all(\n prepareResult.locations\n .filter(l => l.exists)\n .map(async l => {\n const ref = stringifyEntityRef(l.entities[0] ?? l);\n await catalogApi.refreshEntity(ref);\n return { target: l.target };\n }),\n );\n }\n\n const locations = await Promise.all(\n prepareResult.locations\n .filter((l: unknown) => !(l as { exists?: boolean }).exists)\n .map(async l => {\n const result = await catalogApi.addLocation({\n type: 'url',\n target: l.target,\n });\n return {\n target: result.location.target,\n entities: result.entities,\n };\n }),\n );\n\n onReview({\n ...prepareResult,\n ...{ refreshed },\n locations,\n });\n } catch (e) {\n assertError(e);\n // TODO: this error should be handled differently. We add it as 'optional' and\n // it is not uncommon that a PR has not been merged yet.\n if (\n prepareResult.type === 'repository' &&\n e.message.startsWith(\n 'Location was added but has no entities specified yet',\n )\n ) {\n onReview({\n ...prepareResult,\n locations: prepareResult.locations.map(l => ({\n target: l.target,\n entities: [],\n })),\n });\n } else {\n setError(e.message);\n setSubmitted(false);\n }\n }\n }, [prepareResult, onReview, catalogApi, analytics]);\n\n return (\n <>\n {prepareResult.type === 'repository' && (\n <>\n <Typography paragraph>\n The following Pull Request has been opened:{' '}\n <Link\n to={prepareResult.pullRequest.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {prepareResult.pullRequest.url}\n </Link>\n </Typography>\n\n <Typography paragraph>\n You can already import the location and {appTitle} will fetch the\n entities as soon as the Pull Request is merged.\n </Typography>\n </>\n )}\n\n <Typography>\n {exists\n ? 'The following locations already exist in the catalog:'\n : 'The following entities will be added to the catalog:'}\n </Typography>\n\n <EntityListComponent\n locations={prepareResult.locations}\n locationListItemIcon={() => <LocationOnIcon />}\n />\n\n {error && <FormHelperText error>{error}</FormHelperText>}\n\n <Grid container spacing={0}>\n {onGoBack && <BackButton onClick={onGoBack} disabled={submitted} />}\n <NextButton\n disabled={submitted}\n loading={submitted}\n onClick={() => handleClick()}\n >\n {exists ? 'Refresh' : 'Import'}\n </NextButton>\n </Grid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAqCO,MAAM,qBAAqB,CAAC;AAAA,EACjC,aAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAa,KAAA;AACX,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AACvC,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,YAAY,YAAa,EAAA;AAE/B,EAAA,MAAM,QAAW,GAAA,SAAA,CAAU,iBAAkB,CAAA,WAAW,CAAK,IAAA,WAAA;AAE7D,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAiB,EAAA;AAC3C,EAAM,MAAA,MAAA,GACJ,aAAc,CAAA,IAAA,KAAS,WACvB,IAAA,aAAA,CAAc,SAAU,CAAA,IAAA,CAAK,CAAK,CAAA,KAAA,CAAA,CAAE,MAAM,CAAA,GACtC,IACA,GAAA,KAAA;AACN,EAAM,MAAA,WAAA,GAAc,YAAY,YAAY;AAC1C,IAAA,YAAA,CAAa,IAAI,CAAA;AACjB,IAAU,S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AAA,CAAC,cAAe,EAAA,IAAA;AAAA;AAAA,GAC9C,EAEC,yBAAU,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,EAAe,OAAK,IAAE,EAAA,EAAA,KAAM,mBAEtC,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,WAAS,IAAC,EAAA,OAAA,EAAS,KACtB,QAAY,oBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAS,EAAA,QAAA,EAAU,QAAU,EAAA,SAAA,EAAW,CACjE,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,QAAU,EAAA,SAAA;AAAA,MACV,OAAS,EAAA,SAAA;AAAA,MACT,OAAA,EAAS,MAAM,WAAY;AAAA,KAAA;AAAA,IAE1B,SAAS,SAAY,GAAA;AAAA,GAE1B,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.esm.js","sources":["../../src/components/helpers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Config } from '@backstage/config';\nimport { UseFormRegisterReturn } from 'react-hook-form';\n\n/**\n * A helper that converts the result of a render('name', opts) to make it compatible with material-ui.\n *\n * See also https://github.com/react-hook-form/react-hook-form/issues/4629#issuecomment-815840872\n * TODO: remove when updating to material-ui v5 (https://github.com/mui-org/material-ui/pull/23174)\n *\n * @param renderResult - the result of a render('name', opts)\n */\nexport function asInputRef(renderResult: UseFormRegisterReturn) {\n const { ref, ...rest } = renderResult;\n return {\n inputRef: ref,\n ...rest,\n };\n}\n\nexport function getCatalogFilename(config: Config): string {\n return (\n config.getOptionalString('catalog.import.entityFilename') ??\n 'catalog-info.yaml'\n );\n}\n\nexport function getBranchName(config: Config): string {\n return (\n config.getOptionalString('catalog.import.pullRequestBranchName') ??\n 'backstage-integration'\n );\n}\n"],"names":[],"mappings":"AA2BO,SAAS,WAAW,YAAqC,EAAA;AAC9D,EAAA,MAAM,EAAE,GAAA,EAAK,GAAG,IAAA,EAAS,GAAA,YAAA
|
|
1
|
+
{"version":3,"file":"helpers.esm.js","sources":["../../src/components/helpers.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Config } from '@backstage/config';\nimport { UseFormRegisterReturn } from 'react-hook-form';\n\n/**\n * A helper that converts the result of a render('name', opts) to make it compatible with material-ui.\n *\n * See also https://github.com/react-hook-form/react-hook-form/issues/4629#issuecomment-815840872\n * TODO: remove when updating to material-ui v5 (https://github.com/mui-org/material-ui/pull/23174)\n *\n * @param renderResult - the result of a render('name', opts)\n */\nexport function asInputRef(renderResult: UseFormRegisterReturn) {\n const { ref, ...rest } = renderResult;\n return {\n inputRef: ref,\n ...rest,\n };\n}\n\nexport function getCatalogFilename(config: Config): string {\n return (\n config.getOptionalString('catalog.import.entityFilename') ??\n 'catalog-info.yaml'\n );\n}\n\nexport function getBranchName(config: Config): string {\n return (\n config.getOptionalString('catalog.import.pullRequestBranchName') ??\n 'backstage-integration'\n );\n}\n"],"names":[],"mappings":"AA2BO,SAAS,WAAW,YAAqC,EAAA;AAC9D,EAAA,MAAM,EAAE,GAAA,EAAK,GAAG,IAAA,EAAS,GAAA,YAAA;AACzB,EAAO,OAAA;AAAA,IACL,QAAU,EAAA,GAAA;AAAA,IACV,GAAG;AAAA,GACL;AACF;AAEO,SAAS,mBAAmB,MAAwB,EAAA;AACzD,EACE,OAAA,MAAA,CAAO,iBAAkB,CAAA,+BAA+B,CACxD,IAAA,mBAAA;AAEJ;AAEO,SAAS,cAAc,MAAwB,EAAA;AACpD,EACE,OAAA,MAAA,CAAO,iBAAkB,CAAA,sCAAsC,CAC/D,IAAA,uBAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useImportState.esm.js","sources":["../../src/components/useImportState.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity, CompoundEntityRef } from '@backstage/catalog-model';\nimport { useReducer } from 'react';\nimport { AnalyzeResult } from '../api';\n\n/**\n * The configuration of the stepper.\n *\n * @public\n */\nexport type ImportFlows =\n | 'unknown'\n | 'single-location'\n | 'multiple-locations'\n | 'no-location';\n\n// the available states of the stepper\ntype ImportStateTypes = 'analyze' | 'prepare' | 'review' | 'finish';\n\n/**\n * Result of the prepare state.\n *\n * @public\n */\nexport type PrepareResult =\n | {\n type: 'locations';\n locations: Array<{\n exists?: boolean;\n target: string;\n entities: CompoundEntityRef[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n pullRequest: {\n url: string;\n };\n locations: Array<{\n target: string;\n entities: CompoundEntityRef[];\n }>;\n };\n\n// result of the review result\nexport type ReviewResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n entities: Entity[];\n }>;\n refreshed: Array<{ target: string }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n pullRequest: {\n url: string;\n };\n locations: Array<{\n target: string;\n entities: Entity[];\n }>;\n };\n\n// function type for the 'analysis' -> 'prepare'/'review' transition\ntype onAnalysisFn = (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n) => void;\n\n// function type for the 'prepare' -> 'review' transition\ntype onPrepareFn = (\n result: PrepareResult,\n opts?: { notRepeatable?: boolean },\n) => void;\n\n// function type for the 'review' -> 'finish' transition\ntype onReviewFn = (result: ReviewResult) => void;\n\n// the type interfaces that are available in each state. every state provides\n// already known information and means to go to the next, or the previous step.\ntype State =\n | {\n activeState: 'analyze';\n onAnalysis: onAnalysisFn;\n }\n | {\n activeState: 'prepare';\n analyzeResult: AnalyzeResult;\n prepareResult?: PrepareResult;\n onPrepare: onPrepareFn;\n }\n | {\n activeState: 'review';\n analyzeResult: AnalyzeResult;\n prepareResult: PrepareResult;\n onReview: onReviewFn;\n }\n | {\n activeState: 'finish';\n analyzeResult: AnalyzeResult;\n prepareResult: PrepareResult;\n reviewResult: ReviewResult;\n };\n\nexport type ImportState = State & {\n activeFlow: ImportFlows;\n activeStepNumber: number;\n analysisUrl?: string;\n\n onGoBack?: () => void;\n onReset: () => void;\n};\n\ntype ReducerActions =\n | { type: 'onAnalysis'; args: Parameters<onAnalysisFn> }\n | { type: 'onPrepare'; args: Parameters<onPrepareFn> }\n | { type: 'onReview'; args: Parameters<onReviewFn> }\n | { type: 'onGoBack' }\n | { type: 'onReset'; initialUrl?: string };\n\ntype ReducerState = {\n activeFlow: ImportFlows;\n activeState: ImportStateTypes;\n analysisUrl?: string;\n analyzeResult?: AnalyzeResult;\n prepareResult?: PrepareResult;\n reviewResult?: ReviewResult;\n\n previousStates: ImportStateTypes[];\n};\n\nfunction init(initialUrl?: string): ReducerState {\n return {\n activeFlow: 'unknown',\n activeState: 'analyze',\n analysisUrl: initialUrl,\n previousStates: [],\n };\n}\n\nfunction reducer(state: ReducerState, action: ReducerActions): ReducerState {\n switch (action.type) {\n case 'onAnalysis': {\n if (state.activeState !== 'analyze') {\n return state;\n }\n\n const { activeState, previousStates } = state;\n const [activeFlow, analysisUrl, analyzeResult, opts] = action.args;\n\n return {\n ...state,\n analysisUrl,\n activeFlow,\n analyzeResult,\n prepareResult: opts?.prepareResult,\n\n activeState: opts?.prepareResult === undefined ? 'prepare' : 'review',\n previousStates: previousStates.concat(activeState),\n };\n }\n\n case 'onPrepare': {\n if (state.activeState !== 'prepare') {\n return state;\n }\n\n const { activeState, previousStates } = state;\n const [prepareResult, opts] = action.args;\n\n return {\n ...state,\n prepareResult,\n\n activeState: 'review',\n previousStates: opts?.notRepeatable\n ? []\n : previousStates.concat(activeState),\n };\n }\n\n case 'onReview': {\n if (state.activeState !== 'review') {\n return state;\n }\n\n const { activeState, previousStates } = state;\n const [reviewResult] = action.args;\n\n return {\n ...state,\n reviewResult,\n\n activeState: 'finish',\n previousStates: previousStates.concat(activeState),\n };\n }\n\n case 'onGoBack': {\n const { activeState, previousStates } = state;\n\n return {\n ...state,\n\n activeState:\n previousStates.length > 0\n ? previousStates[previousStates.length - 1]\n : activeState,\n previousStates: previousStates.slice(0, previousStates.length - 1),\n };\n }\n\n case 'onReset':\n return {\n ...init(action.initialUrl),\n\n // we keep the old prepareResult since the form is animated and an\n // undefined value might crash the last step.\n prepareResult: state.prepareResult,\n };\n\n default:\n throw new Error();\n }\n}\n\n/**\n * A hook that manages the state machine of the form. It handles different flows\n * which each can implement up to four states:\n * 1. analyze\n * 2. preview (skippable from analyze->review)\n * 3. review\n * 4. finish\n *\n * @param options - options\n */\nexport const useImportState = (options?: {\n initialUrl?: string;\n}): ImportState => {\n const [state, dispatch] = useReducer(reducer, options?.initialUrl, init);\n\n const { activeFlow, activeState, analysisUrl, previousStates } = state;\n\n return {\n activeFlow,\n activeState,\n activeStepNumber: ['analyze', 'prepare', 'review', 'finish'].indexOf(\n activeState,\n ),\n analysisUrl: analysisUrl,\n\n analyzeResult: state.analyzeResult!,\n prepareResult: state.prepareResult!,\n reviewResult: state.reviewResult!,\n\n onAnalysis: (flow, url, result, opts) =>\n dispatch({\n type: 'onAnalysis',\n args: [flow, url, result, opts],\n }),\n\n onPrepare: (result, opts) =>\n dispatch({\n type: 'onPrepare',\n args: [result, opts],\n }),\n\n onReview: result => dispatch({ type: 'onReview', args: [result] }),\n\n onGoBack:\n previousStates.length > 0\n ? () => dispatch({ type: 'onGoBack' })\n : undefined,\n\n onReset: () =>\n dispatch({ type: 'onReset', initialUrl: options?.initialUrl }),\n };\n};\n"],"names":[],"mappings":";;AA0JA,SAAS,KAAK,UAAmC,EAAA;AAC/C,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,SAAA;AAAA,IACZ,WAAa,EAAA,SAAA;AAAA,IACb,WAAa,EAAA,UAAA;AAAA,IACb,gBAAgB,EAAC;AAAA,GACnB,CAAA;AACF,CAAA;AAEA,SAAS,OAAA,CAAQ,OAAqB,MAAsC,EAAA;AAC1E,EAAA,QAAQ,OAAO,IAAM;AAAA,IACnB,KAAK,YAAc,EAAA;AACjB,MAAI,IAAA,KAAA,CAAM,gBAAgB,SAAW,EAAA;AACnC,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAEA,MAAM,MAAA,EAAE,WAAa,EAAA,cAAA,EAAmB,GAAA,KAAA,CAAA;AACxC,MAAA,MAAM,CAAC,UAAY,EAAA,WAAA,EAAa,aAAe,EAAA,IAAI,IAAI,MAAO,CAAA,IAAA,CAAA;AAE9D,MAAO,OAAA;AAAA,QACL,GAAG,KAAA;AAAA,QACH,WAAA;AAAA,QACA,UAAA;AAAA,QACA,aAAA;AAAA,QACA,eAAe,IAAM,EAAA,aAAA;AAAA,QAErB,WAAa,EAAA,IAAA,EAAM,aAAkB,KAAA,KAAA,CAAA,GAAY,SAAY,GAAA,QAAA;AAAA,QAC7D,cAAA,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AAA;AAAA,IAEH,QAAA,EAAU,CAAU,MAAA,KAAA,QAAA,CAAS,EAAE,IAAA,EAAM,YAAY,IAAM,EAAA,CAAC,MAAM,CAAA,EAAG,CAAA;AAAA,IAEjE,QAAA,EACE,cAAe,CAAA,MAAA,GAAS,CACpB,GAAA,MAAM,SAAS,EAAE,IAAA,EAAM,UAAW,EAAC,CACnC,GAAA,KAAA,CAAA;AAAA,IAEN,OAAA,EAAS,MACP,QAAS,CAAA,EAAE,MAAM,SAAW,EAAA,UAAA,EAAY,OAAS,EAAA,UAAA,EAAY,CAAA;AAAA,GACjE,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useImportState.esm.js","sources":["../../src/components/useImportState.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Entity, CompoundEntityRef } from '@backstage/catalog-model';\nimport { useReducer } from 'react';\nimport { AnalyzeResult } from '../api';\n\n/**\n * The configuration of the stepper.\n *\n * @public\n */\nexport type ImportFlows =\n | 'unknown'\n | 'single-location'\n | 'multiple-locations'\n | 'no-location';\n\n// the available states of the stepper\ntype ImportStateTypes = 'analyze' | 'prepare' | 'review' | 'finish';\n\n/**\n * Result of the prepare state.\n *\n * @public\n */\nexport type PrepareResult =\n | {\n type: 'locations';\n locations: Array<{\n exists?: boolean;\n target: string;\n entities: CompoundEntityRef[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n pullRequest: {\n url: string;\n };\n locations: Array<{\n target: string;\n entities: CompoundEntityRef[];\n }>;\n };\n\n// result of the review result\nexport type ReviewResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n entities: Entity[];\n }>;\n refreshed: Array<{ target: string }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n pullRequest: {\n url: string;\n };\n locations: Array<{\n target: string;\n entities: Entity[];\n }>;\n };\n\n// function type for the 'analysis' -> 'prepare'/'review' transition\ntype onAnalysisFn = (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n) => void;\n\n// function type for the 'prepare' -> 'review' transition\ntype onPrepareFn = (\n result: PrepareResult,\n opts?: { notRepeatable?: boolean },\n) => void;\n\n// function type for the 'review' -> 'finish' transition\ntype onReviewFn = (result: ReviewResult) => void;\n\n// the type interfaces that are available in each state. every state provides\n// already known information and means to go to the next, or the previous step.\ntype State =\n | {\n activeState: 'analyze';\n onAnalysis: onAnalysisFn;\n }\n | {\n activeState: 'prepare';\n analyzeResult: AnalyzeResult;\n prepareResult?: PrepareResult;\n onPrepare: onPrepareFn;\n }\n | {\n activeState: 'review';\n analyzeResult: AnalyzeResult;\n prepareResult: PrepareResult;\n onReview: onReviewFn;\n }\n | {\n activeState: 'finish';\n analyzeResult: AnalyzeResult;\n prepareResult: PrepareResult;\n reviewResult: ReviewResult;\n };\n\nexport type ImportState = State & {\n activeFlow: ImportFlows;\n activeStepNumber: number;\n analysisUrl?: string;\n\n onGoBack?: () => void;\n onReset: () => void;\n};\n\ntype ReducerActions =\n | { type: 'onAnalysis'; args: Parameters<onAnalysisFn> }\n | { type: 'onPrepare'; args: Parameters<onPrepareFn> }\n | { type: 'onReview'; args: Parameters<onReviewFn> }\n | { type: 'onGoBack' }\n | { type: 'onReset'; initialUrl?: string };\n\ntype ReducerState = {\n activeFlow: ImportFlows;\n activeState: ImportStateTypes;\n analysisUrl?: string;\n analyzeResult?: AnalyzeResult;\n prepareResult?: PrepareResult;\n reviewResult?: ReviewResult;\n\n previousStates: ImportStateTypes[];\n};\n\nfunction init(initialUrl?: string): ReducerState {\n return {\n activeFlow: 'unknown',\n activeState: 'analyze',\n analysisUrl: initialUrl,\n previousStates: [],\n };\n}\n\nfunction reducer(state: ReducerState, action: ReducerActions): ReducerState {\n switch (action.type) {\n case 'onAnalysis': {\n if (state.activeState !== 'analyze') {\n return state;\n }\n\n const { activeState, previousStates } = state;\n const [activeFlow, analysisUrl, analyzeResult, opts] = action.args;\n\n return {\n ...state,\n analysisUrl,\n activeFlow,\n analyzeResult,\n prepareResult: opts?.prepareResult,\n\n activeState: opts?.prepareResult === undefined ? 'prepare' : 'review',\n previousStates: previousStates.concat(activeState),\n };\n }\n\n case 'onPrepare': {\n if (state.activeState !== 'prepare') {\n return state;\n }\n\n const { activeState, previousStates } = state;\n const [prepareResult, opts] = action.args;\n\n return {\n ...state,\n prepareResult,\n\n activeState: 'review',\n previousStates: opts?.notRepeatable\n ? []\n : previousStates.concat(activeState),\n };\n }\n\n case 'onReview': {\n if (state.activeState !== 'review') {\n return state;\n }\n\n const { activeState, previousStates } = state;\n const [reviewResult] = action.args;\n\n return {\n ...state,\n reviewResult,\n\n activeState: 'finish',\n previousStates: previousStates.concat(activeState),\n };\n }\n\n case 'onGoBack': {\n const { activeState, previousStates } = state;\n\n return {\n ...state,\n\n activeState:\n previousStates.length > 0\n ? previousStates[previousStates.length - 1]\n : activeState,\n previousStates: previousStates.slice(0, previousStates.length - 1),\n };\n }\n\n case 'onReset':\n return {\n ...init(action.initialUrl),\n\n // we keep the old prepareResult since the form is animated and an\n // undefined value might crash the last step.\n prepareResult: state.prepareResult,\n };\n\n default:\n throw new Error();\n }\n}\n\n/**\n * A hook that manages the state machine of the form. It handles different flows\n * which each can implement up to four states:\n * 1. analyze\n * 2. preview (skippable from analyze->review)\n * 3. review\n * 4. finish\n *\n * @param options - options\n */\nexport const useImportState = (options?: {\n initialUrl?: string;\n}): ImportState => {\n const [state, dispatch] = useReducer(reducer, options?.initialUrl, init);\n\n const { activeFlow, activeState, analysisUrl, previousStates } = state;\n\n return {\n activeFlow,\n activeState,\n activeStepNumber: ['analyze', 'prepare', 'review', 'finish'].indexOf(\n activeState,\n ),\n analysisUrl: analysisUrl,\n\n analyzeResult: state.analyzeResult!,\n prepareResult: state.prepareResult!,\n reviewResult: state.reviewResult!,\n\n onAnalysis: (flow, url, result, opts) =>\n dispatch({\n type: 'onAnalysis',\n args: [flow, url, result, opts],\n }),\n\n onPrepare: (result, opts) =>\n dispatch({\n type: 'onPrepare',\n args: [result, opts],\n }),\n\n onReview: result => dispatch({ type: 'onReview', args: [result] }),\n\n onGoBack:\n previousStates.length > 0\n ? () => dispatch({ type: 'onGoBack' })\n : undefined,\n\n onReset: () =>\n dispatch({ type: 'onReset', initialUrl: options?.initialUrl }),\n };\n};\n"],"names":[],"mappings":";;AA0JA,SAAS,KAAK,UAAmC,EAAA;AAC/C,EAAO,OAAA;AAAA,IACL,UAAY,EAAA,SAAA;AAAA,IACZ,WAAa,EAAA,SAAA;AAAA,IACb,WAAa,EAAA,UAAA;AAAA,IACb,gBAAgB;AAAC,GACnB;AACF;AAEA,SAAS,OAAA,CAAQ,OAAqB,MAAsC,EAAA;AAC1E,EAAA,QAAQ,OAAO,IAAM;AAAA,IACnB,KAAK,YAAc,EAAA;AACjB,MAAI,IAAA,KAAA,CAAM,gBAAgB,SAAW,EAAA;AACnC,QAAO,OAAA,KAAA;AAAA;AAGT,MAAM,MAAA,EAAE,WAAa,EAAA,cAAA,EAAmB,GAAA,KAAA;AACxC,MAAA,MAAM,CAAC,UAAY,EAAA,WAAA,EAAa,aAAe,EAAA,IAAI,IAAI,MAAO,CAAA,IAAA;AAE9D,MAAO,OAAA;AAAA,QACL,GAAG,KAAA;AAAA,QACH,WAAA;AAAA,QACA,UAAA;AAAA,QACA,aAAA;AAAA,QACA,eAAe,IAAM,EAAA,aAAA;AAAA,QAErB,WAAa,EAAA,IAAA,EAAM,aAAkB,KAAA,KAAA,CAAA,GAAY,SAAY,GAAA,QAAA;AAAA,QAC7D,cAAA,EAAgB,cAAe,CAAA,MAA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AAA,EAAM,UAAW,EAAC,CACnC,GAAA,KAAA,CAAA;AAAA,IAEN,OAAA,EAAS,MACP,QAAS,CAAA,EAAE,MAAM,SAAW,EAAA,UAAA,EAAY,OAAS,EAAA,UAAA,EAAY;AAAA,GACjE;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCatalogFilename.esm.js","sources":["../../src/hooks/useCatalogFilename.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useApi, configApiRef } from '@backstage/core-plugin-api';\nimport { getCatalogFilename } from '../components/helpers';\n\nexport function useCatalogFilename(): string {\n const config = useApi(configApiRef);\n\n return getCatalogFilename(config);\n}\n"],"names":[],"mappings":";;;AAmBO,SAAS,kBAA6B,GAAA;AAC3C,EAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA
|
|
1
|
+
{"version":3,"file":"useCatalogFilename.esm.js","sources":["../../src/hooks/useCatalogFilename.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useApi, configApiRef } from '@backstage/core-plugin-api';\nimport { getCatalogFilename } from '../components/helpers';\n\nexport function useCatalogFilename(): string {\n const config = useApi(configApiRef);\n\n return getCatalogFilename(config);\n}\n"],"names":[],"mappings":";;;AAmBO,SAAS,kBAA6B,GAAA;AAC3C,EAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA;AAElC,EAAA,OAAO,mBAAmB,MAAM,CAAA;AAClC;;;;"}
|
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configApiRef,\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n createRouteRef,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { catalogImportApiRef, CatalogImportClient } from './api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'catalog-import',\n});\n\n/**\n * A plugin that helps the user in importing projects and YAML files into the\n * catalog.\n *\n * @public\n */\nexport const catalogImportPlugin = createPlugin({\n id: 'catalog-import',\n apis: [\n createApiFactory({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n ],\n routes: {\n importPage: rootRouteRef,\n },\n});\n\n/**\n * The page for importing projects and YAML files into the catalog.\n *\n * @public\n */\nexport const CatalogImportPage = catalogImportPlugin.provide(\n createRoutableExtension({\n name: 'CatalogImportPage',\n component: () => import('./components/ImportPage').then(m => m.ImportPage),\n mountPoint: rootRouteRef,\n }),\n);\n"],"names":[],"mappings":";;;;;;AAgCO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n configApiRef,\n createApiFactory,\n createPlugin,\n createRoutableExtension,\n createRouteRef,\n discoveryApiRef,\n fetchApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { catalogImportApiRef, CatalogImportClient } from './api';\n\nexport const rootRouteRef = createRouteRef({\n id: 'catalog-import',\n});\n\n/**\n * A plugin that helps the user in importing projects and YAML files into the\n * catalog.\n *\n * @public\n */\nexport const catalogImportPlugin = createPlugin({\n id: 'catalog-import',\n apis: [\n createApiFactory({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n fetchApi: fetchApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n fetchApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n fetchApi,\n catalogApi,\n configApi,\n }),\n }),\n ],\n routes: {\n importPage: rootRouteRef,\n },\n});\n\n/**\n * The page for importing projects and YAML files into the catalog.\n *\n * @public\n */\nexport const CatalogImportPage = catalogImportPlugin.provide(\n createRoutableExtension({\n name: 'CatalogImportPage',\n component: () => import('./components/ImportPage').then(m => m.ImportPage),\n mountPoint: rootRouteRef,\n }),\n);\n"],"names":[],"mappings":";;;;;;AAgCO,MAAM,eAAe,cAAe,CAAA;AAAA,EACzC,EAAI,EAAA;AACN,CAAC;AAQM,MAAM,sBAAsB,YAAa,CAAA;AAAA,EAC9C,EAAI,EAAA,gBAAA;AAAA,EACJ,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,mBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,UAAY,EAAA,aAAA;AAAA,QACZ,QAAU,EAAA,WAAA;AAAA,QACV,kBAAoB,EAAA,qBAAA;AAAA,QACpB,UAAY,EAAA,aAAA;AAAA,QACZ,SAAW,EAAA;AAAA,OACb;AAAA,MACA,SAAS,CAAC;AAAA,QACR,YAAA;AAAA,QACA,UAAA;AAAA,QACA,QAAA;AAAA,QACA,kBAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OACF,KACE,IAAI,mBAAoB,CAAA;AAAA,QACtB,YAAA;AAAA,QACA,UAAA;AAAA,QACA,kBAAA;AAAA,QACA,QAAA;AAAA,QACA,UAAA;AAAA,QACA;AAAA,OACD;AAAA,KACJ;AAAA,GACH;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,UAAY,EAAA;AAAA;AAEhB,CAAC;AAOM,MAAM,oBAAoB,mBAAoB,CAAA,OAAA;AAAA,EACnD,uBAAwB,CAAA;AAAA,IACtB,IAAM,EAAA,mBAAA;AAAA,IACN,SAAA,EAAW,MAAM,OAAO,sCAAyB,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,UAAU,CAAA;AAAA,IACzE,UAAY,EAAA;AAAA,GACb;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-import",
|
|
3
|
-
"version": "0.12.6-next.
|
|
3
|
+
"version": "0.12.6-next.2",
|
|
4
4
|
"description": "A Backstage plugin the helps you import entities into your catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"test": "backstage-cli package test"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@backstage/catalog-client": "1.8.0-next.
|
|
57
|
+
"@backstage/catalog-client": "1.8.0-next.1",
|
|
58
58
|
"@backstage/catalog-model": "1.7.0",
|
|
59
59
|
"@backstage/config": "1.2.0",
|
|
60
|
-
"@backstage/core-compat-api": "0.3.2-next.
|
|
61
|
-
"@backstage/core-components": "0.16.0-next.
|
|
60
|
+
"@backstage/core-compat-api": "0.3.2-next.1",
|
|
61
|
+
"@backstage/core-components": "0.16.0-next.1",
|
|
62
62
|
"@backstage/core-plugin-api": "1.10.0",
|
|
63
63
|
"@backstage/errors": "1.2.4",
|
|
64
|
-
"@backstage/frontend-plugin-api": "0.9.1-next.
|
|
64
|
+
"@backstage/frontend-plugin-api": "0.9.1-next.1",
|
|
65
65
|
"@backstage/integration": "1.15.1",
|
|
66
66
|
"@backstage/integration-react": "1.2.0",
|
|
67
67
|
"@backstage/plugin-catalog-common": "1.1.0",
|
|
68
|
-
"@backstage/plugin-catalog-react": "1.14.1-next.
|
|
68
|
+
"@backstage/plugin-catalog-react": "1.14.1-next.2",
|
|
69
69
|
"@material-ui/core": "^4.12.2",
|
|
70
70
|
"@material-ui/icons": "^4.9.1",
|
|
71
71
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
"yaml": "^2.0.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@backstage/cli": "0.29.0-next.
|
|
81
|
+
"@backstage/cli": "0.29.0-next.2",
|
|
82
82
|
"@backstage/core-app-api": "1.15.1",
|
|
83
|
-
"@backstage/dev-utils": "1.1.3-next.
|
|
84
|
-
"@backstage/plugin-catalog": "1.24.1-next.
|
|
85
|
-
"@backstage/test-utils": "1.7.0",
|
|
83
|
+
"@backstage/dev-utils": "1.1.3-next.2",
|
|
84
|
+
"@backstage/plugin-catalog": "1.24.1-next.2",
|
|
85
|
+
"@backstage/test-utils": "1.7.1-next.0",
|
|
86
86
|
"@testing-library/dom": "^10.0.0",
|
|
87
87
|
"@testing-library/jest-dom": "^6.0.0",
|
|
88
88
|
"@testing-library/react": "^16.0.0",
|