@backstage/plugin-catalog-import 0.7.1 → 0.7.5
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
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-import
|
|
2
2
|
|
|
3
|
+
## 0.7.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cd450844f6: Moved React dependencies to `peerDependencies` and allow both React v16 and v17 to be used.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.8.0
|
|
10
|
+
- @backstage/core-plugin-api@0.3.0
|
|
11
|
+
- @backstage/integration-react@0.1.15
|
|
12
|
+
- @backstage/plugin-catalog-react@0.6.5
|
|
13
|
+
|
|
14
|
+
## 0.7.4
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- a125278b81: Refactor out the deprecated path and icon from RouteRefs
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @backstage/catalog-client@0.5.2
|
|
21
|
+
- @backstage/catalog-model@0.9.7
|
|
22
|
+
- @backstage/plugin-catalog-react@0.6.4
|
|
23
|
+
- @backstage/core-components@0.7.4
|
|
24
|
+
- @backstage/core-plugin-api@0.2.0
|
|
25
|
+
- @backstage/integration-react@0.1.14
|
|
26
|
+
|
|
27
|
+
## 0.7.3
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 36e67d2f24: Internal updates to apply more strict checks to throw errors.
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
- @backstage/core-components@0.7.1
|
|
34
|
+
- @backstage/errors@0.1.3
|
|
35
|
+
- @backstage/core-plugin-api@0.1.11
|
|
36
|
+
- @backstage/plugin-catalog-react@0.6.1
|
|
37
|
+
- @backstage/catalog-model@0.9.5
|
|
38
|
+
|
|
39
|
+
## 0.7.2
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Updated dependencies
|
|
44
|
+
- @backstage/plugin-catalog-react@0.6.0
|
|
45
|
+
- @backstage/integration@0.6.8
|
|
46
|
+
- @backstage/core-components@0.7.0
|
|
47
|
+
- @backstage/integration-react@0.1.12
|
|
48
|
+
|
|
3
49
|
## 0.7.1
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
|
@@ -19,6 +19,7 @@ import 'lodash/partition';
|
|
|
19
19
|
import 'react-hook-form';
|
|
20
20
|
import '@material-ui/lab';
|
|
21
21
|
import 'yaml';
|
|
22
|
+
import '@backstage/errors';
|
|
22
23
|
import 'react-use';
|
|
23
24
|
import '@backstage/catalog-model';
|
|
24
25
|
|
|
@@ -28,4 +29,4 @@ const ImportPage = () => {
|
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
export { ImportPage };
|
|
31
|
-
//# sourceMappingURL=index-
|
|
32
|
+
//# sourceMappingURL=index-5d141285.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-5d141285.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';\nimport { DefaultImportPage } from '../DefaultImportPage';\n\nexport const ImportPage = () => {\n const outlet = useOutlet();\n\n return outlet || <DefaultImportPage />;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;MAoBa,aAAa,MAAM;AAC9B,QAAM,SAAS;AAEf,SAAO,8CAAW,mBAAD;AAAA;;;;"}
|
package/dist/index.esm.js
CHANGED
|
@@ -17,6 +17,7 @@ import partition from 'lodash/partition';
|
|
|
17
17
|
import { useForm, Controller, FormProvider } from 'react-hook-form';
|
|
18
18
|
import { Autocomplete } from '@material-ui/lab';
|
|
19
19
|
import YAML from 'yaml';
|
|
20
|
+
import { assertError } from '@backstage/errors';
|
|
20
21
|
import { useAsync } from 'react-use';
|
|
21
22
|
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
22
23
|
|
|
@@ -30,7 +31,7 @@ const getGithubIntegrationConfig = (scmIntegrationsApi, location) => {
|
|
|
30
31
|
if (!integration) {
|
|
31
32
|
return void 0;
|
|
32
33
|
}
|
|
33
|
-
const {name: repo, owner} = parseGitUrl(location);
|
|
34
|
+
const { name: repo, owner } = parseGitUrl(location);
|
|
34
35
|
return {
|
|
35
36
|
repo,
|
|
36
37
|
owner,
|
|
@@ -138,11 +139,11 @@ For more information, read an [overview of the Backstage software catalog](https
|
|
|
138
139
|
const response = await fetch(`${await this.discoveryApi.getBaseUrl("catalog")}/analyze-location`, {
|
|
139
140
|
headers: {
|
|
140
141
|
"Content-Type": "application/json",
|
|
141
|
-
...idToken && {Authorization: `Bearer ${idToken}`}
|
|
142
|
+
...idToken && { Authorization: `Bearer ${idToken}` }
|
|
142
143
|
},
|
|
143
144
|
method: "POST",
|
|
144
145
|
body: JSON.stringify({
|
|
145
|
-
location: {type: "url", target: repo}
|
|
146
|
+
location: { type: "url", target: repo }
|
|
146
147
|
})
|
|
147
148
|
}).catch((e) => {
|
|
148
149
|
throw new Error(`Failed to generate entity definitions, ${e.message}`);
|
|
@@ -159,19 +160,19 @@ For more information, read an [overview of the Backstage software catalog](https
|
|
|
159
160
|
repo,
|
|
160
161
|
githubIntegrationConfig
|
|
161
162
|
}) {
|
|
162
|
-
const {token} = await this.scmAuthApi.getCredentials({url});
|
|
163
|
+
const { token } = await this.scmAuthApi.getCredentials({ url });
|
|
163
164
|
const octo = new Octokit({
|
|
164
165
|
auth: token,
|
|
165
166
|
baseUrl: githubIntegrationConfig.apiBaseUrl
|
|
166
167
|
});
|
|
167
168
|
const catalogFileName = "catalog-info.yaml";
|
|
168
169
|
const query = `repo:${owner}/${repo}+filename:${catalogFileName}`;
|
|
169
|
-
const searchResult = await octo.search.code({q: query}).catch((e) => {
|
|
170
|
+
const searchResult = await octo.search.code({ q: query }).catch((e) => {
|
|
170
171
|
throw new Error(formatHttpErrorMessage("Couldn't search repository for metadata file.", e));
|
|
171
172
|
});
|
|
172
173
|
const exists = searchResult.data.total_count > 0;
|
|
173
174
|
if (exists) {
|
|
174
|
-
const repoInformation = await octo.repos.get({owner, repo}).catch((e) => {
|
|
175
|
+
const repoInformation = await octo.repos.get({ owner, repo }).catch((e) => {
|
|
175
176
|
throw new Error(formatHttpErrorMessage("Couldn't fetch repo data", e));
|
|
176
177
|
});
|
|
177
178
|
const defaultBranch = repoInformation.data.default_branch;
|
|
@@ -206,7 +207,7 @@ For more information, read an [overview of the Backstage software catalog](https
|
|
|
206
207
|
repositoryUrl,
|
|
207
208
|
githubIntegrationConfig
|
|
208
209
|
}) {
|
|
209
|
-
const {token} = await this.scmAuthApi.getCredentials({
|
|
210
|
+
const { token } = await this.scmAuthApi.getCredentials({
|
|
210
211
|
url: repositoryUrl,
|
|
211
212
|
additionalScope: {
|
|
212
213
|
repoWrite: true
|
|
@@ -270,8 +271,7 @@ function formatHttpErrorMessage(message, error) {
|
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
const rootRouteRef = createRouteRef({
|
|
273
|
-
|
|
274
|
-
title: "catalog-import"
|
|
274
|
+
id: "catalog-import"
|
|
275
275
|
});
|
|
276
276
|
const catalogImportPlugin = createPlugin({
|
|
277
277
|
id: "catalog-import",
|
|
@@ -309,7 +309,7 @@ const catalogImportPlugin = createPlugin({
|
|
|
309
309
|
});
|
|
310
310
|
const CatalogImportPage = catalogImportPlugin.provide(createRoutableExtension({
|
|
311
311
|
name: "CatalogImportPage",
|
|
312
|
-
component: () => import('./esm/index-
|
|
312
|
+
component: () => import('./esm/index-5d141285.esm.js').then((m) => m.ImportPage),
|
|
313
313
|
mountPoint: rootRouteRef
|
|
314
314
|
}));
|
|
315
315
|
|
|
@@ -370,7 +370,7 @@ function reducer(state, action) {
|
|
|
370
370
|
if (state.activeState !== "analyze") {
|
|
371
371
|
return state;
|
|
372
372
|
}
|
|
373
|
-
const {activeState, previousStates} = state;
|
|
373
|
+
const { activeState, previousStates } = state;
|
|
374
374
|
const [activeFlow, analysisUrl, analyzeResult, opts] = action.args;
|
|
375
375
|
return {
|
|
376
376
|
...state,
|
|
@@ -386,7 +386,7 @@ function reducer(state, action) {
|
|
|
386
386
|
if (state.activeState !== "prepare") {
|
|
387
387
|
return state;
|
|
388
388
|
}
|
|
389
|
-
const {activeState, previousStates} = state;
|
|
389
|
+
const { activeState, previousStates } = state;
|
|
390
390
|
const [prepareResult, opts] = action.args;
|
|
391
391
|
return {
|
|
392
392
|
...state,
|
|
@@ -399,7 +399,7 @@ function reducer(state, action) {
|
|
|
399
399
|
if (state.activeState !== "review") {
|
|
400
400
|
return state;
|
|
401
401
|
}
|
|
402
|
-
const {activeState, previousStates} = state;
|
|
402
|
+
const { activeState, previousStates } = state;
|
|
403
403
|
const [reviewResult] = action.args;
|
|
404
404
|
return {
|
|
405
405
|
...state,
|
|
@@ -409,7 +409,7 @@ function reducer(state, action) {
|
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
411
|
case "onGoBack": {
|
|
412
|
-
const {activeState, previousStates} = state;
|
|
412
|
+
const { activeState, previousStates } = state;
|
|
413
413
|
return {
|
|
414
414
|
...state,
|
|
415
415
|
activeState: previousStates.length > 0 ? previousStates[previousStates.length - 1] : activeState,
|
|
@@ -427,7 +427,7 @@ function reducer(state, action) {
|
|
|
427
427
|
}
|
|
428
428
|
const useImportState = (options) => {
|
|
429
429
|
const [state, dispatch] = useReducer(reducer, options == null ? void 0 : options.initialUrl, init);
|
|
430
|
-
const {activeFlow, activeState, analysisUrl, previousStates} = state;
|
|
430
|
+
const { activeFlow, activeState, analysisUrl, previousStates } = state;
|
|
431
431
|
return {
|
|
432
432
|
activeFlow,
|
|
433
433
|
activeState,
|
|
@@ -444,9 +444,9 @@ const useImportState = (options) => {
|
|
|
444
444
|
type: "onPrepare",
|
|
445
445
|
args: [result, opts]
|
|
446
446
|
}),
|
|
447
|
-
onReview: (result) => dispatch({type: "onReview", args: [result]}),
|
|
448
|
-
onGoBack: previousStates.length > 0 ? () => dispatch({type: "onGoBack"}) : void 0,
|
|
449
|
-
onReset: () => dispatch({type: "onReset", initialUrl: options == null ? void 0 : options.initialUrl})
|
|
447
|
+
onReview: (result) => dispatch({ type: "onReview", args: [result] }),
|
|
448
|
+
onGoBack: previousStates.length > 0 ? () => dispatch({ type: "onGoBack" }) : void 0,
|
|
449
|
+
onReset: () => dispatch({ type: "onReset", initialUrl: options == null ? void 0 : options.initialUrl })
|
|
450
450
|
};
|
|
451
451
|
};
|
|
452
452
|
|
|
@@ -469,7 +469,7 @@ const useStyles$3 = makeStyles((theme) => ({
|
|
|
469
469
|
}
|
|
470
470
|
}));
|
|
471
471
|
const NextButton = (props) => {
|
|
472
|
-
const {loading, ...buttonProps} = props;
|
|
472
|
+
const { loading, ...buttonProps } = props;
|
|
473
473
|
const classes = useStyles$3();
|
|
474
474
|
return /* @__PURE__ */ React.createElement("div", {
|
|
475
475
|
className: classes.wrapper
|
|
@@ -493,7 +493,7 @@ const BackButton = (props) => {
|
|
|
493
493
|
};
|
|
494
494
|
|
|
495
495
|
function asInputRef(renderResult) {
|
|
496
|
-
const {ref, ...rest} = renderResult;
|
|
496
|
+
const { ref, ...rest } = renderResult;
|
|
497
497
|
return {
|
|
498
498
|
inputRef: ref,
|
|
499
499
|
...rest
|
|
@@ -559,7 +559,7 @@ const EntityListComponent = ({
|
|
|
559
559
|
}))))));
|
|
560
560
|
};
|
|
561
561
|
|
|
562
|
-
const StepFinishImportLocation = ({prepareResult, onReset}) => {
|
|
562
|
+
const StepFinishImportLocation = ({ prepareResult, onReset }) => {
|
|
563
563
|
const continueButton = /* @__PURE__ */ React.createElement(Grid, {
|
|
564
564
|
container: true,
|
|
565
565
|
spacing: 0
|
|
@@ -599,7 +599,7 @@ const StepInitAnalyzeUrl = ({
|
|
|
599
599
|
const {
|
|
600
600
|
register,
|
|
601
601
|
handleSubmit,
|
|
602
|
-
formState: {errors},
|
|
602
|
+
formState: { errors },
|
|
603
603
|
watch
|
|
604
604
|
} = useForm({
|
|
605
605
|
mode: "onTouched",
|
|
@@ -609,7 +609,7 @@ const StepInitAnalyzeUrl = ({
|
|
|
609
609
|
});
|
|
610
610
|
const [submitted, setSubmitted] = useState(false);
|
|
611
611
|
const [error, setError] = useState(void 0);
|
|
612
|
-
const handleResult = useCallback(async ({url}) => {
|
|
612
|
+
const handleResult = useCallback(async ({ url }) => {
|
|
613
613
|
var _a, _b, _c;
|
|
614
614
|
setSubmitted(true);
|
|
615
615
|
try {
|
|
@@ -645,7 +645,7 @@ const StepInitAnalyzeUrl = ({
|
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
} catch (e) {
|
|
648
|
-
setError((_c = (_b = (_a = e.data) == null ? void 0 : _a.error) == null ? void 0 : _b.message) != null ? _c : e.message);
|
|
648
|
+
setError((_c = (_b = (_a = e == null ? void 0 : e.data) == null ? void 0 : _a.error) == null ? void 0 : _b.message) != null ? _c : e.message);
|
|
649
649
|
setSubmitted(false);
|
|
650
650
|
}
|
|
651
651
|
}, [catalogImportApi, disablePullRequest, errorApi, onAnalysis]);
|
|
@@ -696,7 +696,7 @@ const AutocompleteTextField = ({
|
|
|
696
696
|
return /* @__PURE__ */ React.createElement(Controller, {
|
|
697
697
|
name,
|
|
698
698
|
rules,
|
|
699
|
-
render: ({field: {onChange}}) => /* @__PURE__ */ React.createElement(Autocomplete, {
|
|
699
|
+
render: ({ field: { onChange } }) => /* @__PURE__ */ React.createElement(Autocomplete, {
|
|
700
700
|
loading,
|
|
701
701
|
loadingText,
|
|
702
702
|
options: options || [],
|
|
@@ -728,13 +728,13 @@ const PreparePullRequestForm = ({
|
|
|
728
728
|
onSubmit,
|
|
729
729
|
render
|
|
730
730
|
}) => {
|
|
731
|
-
const methods = useForm({mode: "onTouched", defaultValues});
|
|
732
|
-
const {handleSubmit, watch, control, register, formState, setValue} = methods;
|
|
731
|
+
const methods = useForm({ mode: "onTouched", defaultValues });
|
|
732
|
+
const { handleSubmit, watch, control, register, formState, setValue } = methods;
|
|
733
733
|
return /* @__PURE__ */ React.createElement(FormProvider, {
|
|
734
734
|
...methods
|
|
735
735
|
}, /* @__PURE__ */ React.createElement("form", {
|
|
736
736
|
onSubmit: handleSubmit(onSubmit)
|
|
737
|
-
}, render({values: watch(), formState, register, control, setValue})));
|
|
737
|
+
}, render({ values: watch(), formState, register, control, setValue })));
|
|
738
738
|
};
|
|
739
739
|
|
|
740
740
|
const PreviewCatalogInfoComponent = ({
|
|
@@ -792,7 +792,7 @@ function generateEntities(entities, componentName, owner) {
|
|
|
792
792
|
},
|
|
793
793
|
spec: {
|
|
794
794
|
...e.spec,
|
|
795
|
-
...owner ? {owner} : {}
|
|
795
|
+
...owner ? { owner } : {}
|
|
796
796
|
}
|
|
797
797
|
}));
|
|
798
798
|
}
|
|
@@ -819,11 +819,11 @@ const StepPrepareCreatePullRequest = ({
|
|
|
819
819
|
errorApi.post(prDefaultsError);
|
|
820
820
|
}
|
|
821
821
|
}, [prDefaultsError, errorApi]);
|
|
822
|
-
const {loading: groupsLoading, value: groups} = useAsync(async () => {
|
|
822
|
+
const { loading: groupsLoading, value: groups } = useAsync(async () => {
|
|
823
823
|
const groupEntities = await catalogApi.getEntities({
|
|
824
|
-
filter: {kind: "group"}
|
|
824
|
+
filter: { kind: "group" }
|
|
825
825
|
});
|
|
826
|
-
return groupEntities.items.map((e) => formatEntityRefTitle(e, {defaultKind: "group"})).sort();
|
|
826
|
+
return groupEntities.items.map((e) => formatEntityRefTitle(e, { defaultKind: "group" })).sort();
|
|
827
827
|
});
|
|
828
828
|
const handleResult = useCallback(async (data) => {
|
|
829
829
|
setSubmitted(true);
|
|
@@ -851,8 +851,9 @@ const StepPrepareCreatePullRequest = ({
|
|
|
851
851
|
}))
|
|
852
852
|
}
|
|
853
853
|
]
|
|
854
|
-
}, {notRepeatable: true});
|
|
854
|
+
}, { notRepeatable: true });
|
|
855
855
|
} catch (e) {
|
|
856
|
+
assertError(e);
|
|
856
857
|
setError(e.message);
|
|
857
858
|
setSubmitted(false);
|
|
858
859
|
}
|
|
@@ -872,7 +873,7 @@ const StepPrepareCreatePullRequest = ({
|
|
|
872
873
|
componentName: ((_f = (_e = analyzeResult.generatedEntities[0]) == null ? void 0 : _e.metadata) == null ? void 0 : _f.name) || "",
|
|
873
874
|
useCodeowners: false
|
|
874
875
|
},
|
|
875
|
-
render: ({values, formState, register, setValue}) => /* @__PURE__ */ React.createElement(React.Fragment, null, renderFormFields({
|
|
876
|
+
render: ({ values, formState, register, setValue }) => /* @__PURE__ */ React.createElement(React.Fragment, null, renderFormFields({
|
|
876
877
|
values,
|
|
877
878
|
formState,
|
|
878
879
|
register,
|
|
@@ -997,7 +998,7 @@ const StepReviewLocation = ({
|
|
|
997
998
|
var _a;
|
|
998
999
|
const ref = stringifyEntityRef((_a = l.entities[0]) != null ? _a : l);
|
|
999
1000
|
await catalogApi.refreshEntity(ref);
|
|
1000
|
-
return {target: l.target};
|
|
1001
|
+
return { target: l.target };
|
|
1001
1002
|
}));
|
|
1002
1003
|
}
|
|
1003
1004
|
const locations = await Promise.all(prepareResult.locations.filter((l) => !l.exists).map(async (l) => {
|
|
@@ -1013,10 +1014,11 @@ const StepReviewLocation = ({
|
|
|
1013
1014
|
}));
|
|
1014
1015
|
onReview({
|
|
1015
1016
|
...prepareResult,
|
|
1016
|
-
...{refreshed},
|
|
1017
|
+
...{ refreshed },
|
|
1017
1018
|
locations
|
|
1018
1019
|
});
|
|
1019
1020
|
} catch (e) {
|
|
1021
|
+
assertError(e);
|
|
1020
1022
|
if (prepareResult.type === "repository" && e.message.startsWith("Location was added but has no entities specified yet")) {
|
|
1021
1023
|
onReview({
|
|
1022
1024
|
...prepareResult,
|
|
@@ -1145,7 +1147,7 @@ function defaultGenerateStepper(flow, defaults) {
|
|
|
1145
1147
|
}, /* @__PURE__ */ React.createElement(Typography, {
|
|
1146
1148
|
variant: "h6"
|
|
1147
1149
|
}, "Entity Configuration")), /* @__PURE__ */ React.createElement(TextField, {
|
|
1148
|
-
...asInputRef(register("componentName", {required: true})),
|
|
1150
|
+
...asInputRef(register("componentName", { required: true })),
|
|
1149
1151
|
label: "Name of the created component",
|
|
1150
1152
|
placeholder: "my-component",
|
|
1151
1153
|
margin: "normal",
|
|
@@ -1165,7 +1167,7 @@ function defaultGenerateStepper(flow, defaults) {
|
|
|
1165
1167
|
label: "Entity Owner",
|
|
1166
1168
|
placeholder: "my-group"
|
|
1167
1169
|
},
|
|
1168
|
-
rules: {required: true},
|
|
1170
|
+
rules: { required: true },
|
|
1169
1171
|
required: true
|
|
1170
1172
|
}), /* @__PURE__ */ React.createElement(FormControlLabel, {
|
|
1171
1173
|
control: /* @__PURE__ */ React.createElement(Checkbox, {
|
|
@@ -1187,7 +1189,7 @@ function defaultGenerateStepper(flow, defaults) {
|
|
|
1187
1189
|
}
|
|
1188
1190
|
}
|
|
1189
1191
|
const defaultStepper = {
|
|
1190
|
-
analyze: (state, {apis}) => ({
|
|
1192
|
+
analyze: (state, { apis }) => ({
|
|
1191
1193
|
stepLabel: /* @__PURE__ */ React.createElement(StepLabel, null, "Select URL"),
|
|
1192
1194
|
content: /* @__PURE__ */ React.createElement(StepInitAnalyzeUrl, {
|
|
1193
1195
|
key: "analyze",
|
|
@@ -1235,7 +1237,7 @@ const ImportStepper = ({
|
|
|
1235
1237
|
}) => {
|
|
1236
1238
|
const catalogImportApi = useApi(catalogImportApiRef);
|
|
1237
1239
|
const classes = useStyles();
|
|
1238
|
-
const state = useImportState({initialUrl});
|
|
1240
|
+
const state = useImportState({ initialUrl });
|
|
1239
1241
|
const states = useMemo(() => generateStepper(state.activeFlow, defaultStepper), [generateStepper, state.activeFlow]);
|
|
1240
1242
|
const render = (step) => {
|
|
1241
1243
|
return /* @__PURE__ */ React.createElement(Step, null, step.stepLabel, /* @__PURE__ */ React.createElement(StepContent, null, step.content));
|
|
@@ -1243,10 +1245,10 @@ const ImportStepper = ({
|
|
|
1243
1245
|
return /* @__PURE__ */ React.createElement(InfoCard, {
|
|
1244
1246
|
variant
|
|
1245
1247
|
}, /* @__PURE__ */ React.createElement(Stepper, {
|
|
1246
|
-
classes: {root: classes.stepperRoot},
|
|
1248
|
+
classes: { root: classes.stepperRoot },
|
|
1247
1249
|
activeStep: state.activeStepNumber,
|
|
1248
1250
|
orientation: "vertical"
|
|
1249
|
-
}, render(states.analyze(state, {apis: {catalogImportApi}})), render(states.prepare(state, {apis: {catalogImportApi}})), render(states.review(state, {apis: {catalogImportApi}})), render(states.finish(state, {apis: {catalogImportApi}}))));
|
|
1251
|
+
}, render(states.analyze(state, { apis: { catalogImportApi } })), render(states.prepare(state, { apis: { catalogImportApi } })), render(states.review(state, { apis: { catalogImportApi } })), render(states.finish(state, { apis: { catalogImportApi } }))));
|
|
1250
1252
|
};
|
|
1251
1253
|
|
|
1252
1254
|
const DefaultImportPage = () => {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/api/CatalogImportApi.ts","../src/api/GitHub.ts","../src/api/CatalogImportClient.ts","../src/plugin.ts","../src/components/ImportInfoCard/ImportInfoCard.tsx","../src/components/useImportState.ts","../src/components/Buttons/index.tsx","../src/components/helpers.ts","../src/components/EntityListComponent/EntityListComponent.tsx","../src/components/StepFinishImportLocation/StepFinishImportLocation.tsx","../src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.tsx","../src/components/StepPrepareCreatePullRequest/AutocompleteTextField.tsx","../src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.tsx","../src/components/StepPrepareCreatePullRequest/PreviewCatalogInfoComponent.tsx","../src/components/StepPrepareCreatePullRequest/PreviewPullRequestComponent.tsx","../src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.tsx","../src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.tsx","../src/components/StepReviewLocation/StepReviewLocation.tsx","../src/components/ImportStepper/defaults.tsx","../src/components/ImportStepper/ImportStepper.tsx","../src/components/DefaultImportPage/DefaultImportPage.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 { EntityName } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { PartialEntity } from '../types';\n\nexport const catalogImportApiRef = createApiRef<CatalogImportApi>({\n id: 'plugin.catalog-import.service',\n description: 'Used by the catalog import plugin to make requests',\n});\n\n// result of the analyze state\nexport type AnalyzeResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n exists?: boolean;\n entities: EntityName[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n generatedEntities: PartialEntity[];\n };\n\nexport interface CatalogImportApi {\n analyzeUrl(url: string): Promise<AnalyzeResult>;\n\n preparePullRequest?(): Promise<{\n title: string;\n body: string;\n }>;\n submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }>;\n}\n","/*\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 { ScmIntegrationRegistry } from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\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","/*\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 { EntityName } from '@backstage/catalog-model';\nimport {\n ConfigApi,\n DiscoveryApi,\n IdentityApi,\n} from '@backstage/core-plugin-api';\nimport {\n GitHubIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { Octokit } from '@octokit/rest';\nimport { Base64 } from 'js-base64';\nimport { PartialEntity } from '../types';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport { getGithubIntegrationConfig } from './GitHub';\nimport { trimEnd } from 'lodash';\n\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly identityApi: IdentityApi;\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 identityApi: IdentityApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.identityApi = options.identityApi;\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\n const ghConfig = getGithubIntegrationConfig(this.scmIntegrationsApi, url);\n if (!ghConfig) {\n const other = this.scmIntegrationsApi.byUrl(url);\n if (other) {\n throw new Error(\n `The ${other.title} integration only supports full URLs to catalog-info.yaml 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 GitHub URL because there was no configured integration that matched the given host name. You could try to paste the full URL to a catalog-info.yaml file instead.',\n );\n }\n\n // TODO: this could be part of the analyze-location endpoint\n const locations = await this.checkGitHubForExistingCatalogInfo({\n ...ghConfig,\n url,\n });\n\n if (locations.length > 0) {\n return {\n type: 'locations',\n locations,\n };\n }\n\n return {\n type: 'repository',\n integrationType: 'github',\n url: url,\n generatedEntities: await this.generateEntityDefinitions({\n repo: url,\n }),\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\n return {\n title: 'Add catalog-info.yaml 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/software-catalog-overview).`,\n };\n }\n\n async submitPullRequest({\n repositoryUrl,\n fileContent,\n title,\n body,\n }: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const ghConfig = getGithubIntegrationConfig(\n this.scmIntegrationsApi,\n repositoryUrl,\n );\n\n if (ghConfig) {\n return await this.submitGitHubPrToRepo({\n ...ghConfig,\n repositoryUrl,\n fileContent,\n title,\n body,\n });\n }\n\n throw new Error('unimplemented!');\n }\n\n // TODO: this could be part of the catalog api\n private async generateEntityDefinitions({\n repo,\n }: {\n repo: string;\n }): Promise<PartialEntity[]> {\n const idToken = await this.identityApi.getIdToken();\n const response = await fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n ...(idToken && { Authorization: `Bearer ${idToken}` }),\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: repo },\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.generateEntities.map((x: any) => x.entity);\n }\n\n // TODO: this response should better be part of the analyze-locations response and scm-independent / implemented per scm\n private async checkGitHubForExistingCatalogInfo({\n url,\n owner,\n repo,\n githubIntegrationConfig,\n }: {\n url: string;\n owner: string;\n repo: string;\n githubIntegrationConfig: GitHubIntegrationConfig;\n }): Promise<\n Array<{\n target: string;\n entities: EntityName[];\n }>\n > {\n const { token } = await this.scmAuthApi.getCredentials({ url });\n const octo = new Octokit({\n auth: token,\n baseUrl: githubIntegrationConfig.apiBaseUrl,\n });\n const catalogFileName = 'catalog-info.yaml';\n const query = `repo:${owner}/${repo}+filename:${catalogFileName}`;\n\n const searchResult = await octo.search.code({ q: query }).catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n \"Couldn't search repository for metadata file.\",\n e,\n ),\n );\n });\n const exists = searchResult.data.total_count > 0;\n if (exists) {\n const repoInformation = await octo.repos.get({ owner, repo }).catch(e => {\n throw new Error(formatHttpErrorMessage(\"Couldn't fetch repo data\", e));\n });\n const defaultBranch = repoInformation.data.default_branch;\n\n return await Promise.all(\n searchResult.data.items\n .map(i => `${trimEnd(url, '/')}/blob/${defaultBranch}/${i.path}`)\n .map(async target => {\n const result = await this.catalogApi.addLocation({\n type: 'url',\n target,\n dryRun: true,\n });\n return {\n target,\n exists: result.exists,\n entities: result.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n };\n }),\n );\n }\n\n return [];\n }\n\n // TODO: extract this function and implement for non-github\n private async submitGitHubPrToRepo({\n owner,\n repo,\n title,\n body,\n fileContent,\n repositoryUrl,\n githubIntegrationConfig,\n }: {\n owner: string;\n repo: string;\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n githubIntegrationConfig: GitHubIntegrationConfig;\n }): Promise<{ link: string; location: string }> {\n const { token } = await this.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 = 'backstage-integration';\n const fileName = 'catalog-info.yaml';\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}\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","/*\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 identityApiRef,\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 path: '',\n title: 'catalog-import',\n});\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 identityApi: identityApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n identityApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n identityApi,\n catalogApi,\n configApi,\n }),\n }),\n ],\n routes: {\n importPage: rootRouteRef,\n },\n});\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","/*\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, Typography } from '@material-ui/core';\nimport React from 'react';\nimport { catalogImportApiRef } from '../../api';\n\nexport const ImportInfoCard = () => {\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptional('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const integrations = configApi.getConfig('integrations');\n const hasGithubIntegration = integrations.has('github');\n\n return (\n <InfoCard\n title=\"Register an existing component\"\n deepLink={{\n title: 'Learn more about the Software Catalog',\n link: 'https://backstage.io/docs/features/software-catalog/software-catalog-overview',\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 variant=\"h6\">Link to an existing entity file</Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n Example:{' '}\n <code>\n https://github.com/backstage/backstage/blob/master/catalog-info.yaml\n </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 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>https://github.com/backstage/backstage</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n The wizard discovers all <code>catalog-info.yaml</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>catalog-info.yaml</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","/*\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, EntityName } from '@backstage/catalog-model';\nimport { useReducer } from 'react';\nimport { AnalyzeResult } from '../api';\n\n// the configuration of the stepper\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// result of the prepare state\nexport type PrepareResult =\n | {\n type: 'locations';\n locations: Array<{\n exists?: boolean;\n target: string;\n entities: EntityName[];\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: EntityName[];\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","/*\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 { Button, CircularProgress } from '@material-ui/core';\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","/*\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 { 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","/*\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, EntityName } from '@backstage/catalog-model';\nimport { useApp } from '@backstage/core-plugin-api';\nimport {\n EntityRefLink,\n formatEntityRefTitle,\n} from '@backstage/plugin-catalog-react';\nimport {\n Collapse,\n IconButton,\n List,\n ListItem,\n ListItemIcon,\n ListItemSecondaryAction,\n ListItemText,\n} from '@material-ui/core';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandLessIcon from '@material-ui/icons/ExpandLess';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport WorkIcon from '@material-ui/icons/Work';\nimport React, { useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n nested: {\n paddingLeft: theme.spacing(4),\n },\n}));\n\nfunction sortEntities(entities: Array<EntityName | Entity>) {\n return entities.sort((a, b) =>\n formatEntityRefTitle(a).localeCompare(formatEntityRefTitle(b)),\n );\n}\n\ntype Props = {\n locations: Array<{ target: string; entities: (Entity | EntityName)[] }>;\n locationListItemIcon: (target: string) => React.ReactElement;\n collapsed?: boolean;\n firstListItem?: React.ReactElement;\n onItemClick?: (target: string) => void;\n withLinks?: boolean;\n};\n\nexport const EntityListComponent = ({\n locations,\n collapsed = false,\n locationListItemIcon,\n onItemClick,\n firstListItem,\n withLinks = false,\n}: Props) => {\n const app = useApp();\n const classes = useStyles();\n\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 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?.call(this, 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 const Icon =\n app.getSystemIcon(\n `kind:${entity.kind.toLocaleLowerCase('en-US')}`,\n ) ?? WorkIcon;\n return (\n <ListItem\n key={formatEntityRefTitle(entity)}\n className={classes.nested}\n {...(withLinks\n ? {\n component: EntityRefLink,\n entityRef: entity,\n button: withLinks as any,\n }\n : {})}\n >\n <ListItemIcon>\n <Icon />\n </ListItemIcon>\n <ListItemText primary={formatEntityRefTitle(entity)} />\n </ListItem>\n );\n })}\n </List>\n </Collapse>\n </React.Fragment>\n ))}\n </List>\n );\n};\n","/*\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, Typography } from '@material-ui/core';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React from 'react';\nimport { BackButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult } from '../useImportState';\nimport { Link } from '@backstage/core-components';\nimport partition from 'lodash/partition';\n\ntype Props = {\n prepareResult: PrepareResult;\n onReset: () => void;\n};\n\nexport const StepFinishImportLocation = ({ prepareResult, onReset }: Props) => {\n const continueButton = (\n <Grid container spacing={0}>\n <BackButton onClick={onReset}>Register another</BackButton>\n </Grid>\n );\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\n <Typography paragraph>\n Your entities will be imported as soon as the Pull Request is merged.\n </Typography>\n\n {continueButton}\n </>\n );\n }\n\n const [existingLocations, newLocations] = partition(\n prepareResult.locations,\n l => l.exists,\n );\n\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 {continueButton}\n </>\n );\n};\n","/*\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, Grid, TextField } from '@material-ui/core';\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\ntype Props = {\n onAnalysis: (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n ) => void;\n disablePullRequest?: boolean;\n analysisUrl?: 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 */\nexport const StepInitAnalyzeUrl = ({\n onAnalysis,\n analysisUrl = '',\n disablePullRequest = false,\n}: Props) => {\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) {\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=\"Repository URL\"\n placeholder=\"https://github.com/backstage/backstage/blob/master/catalog-info.yaml\"\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","/*\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, TextField } from '@material-ui/core';\nimport { TextFieldProps } from '@material-ui/core/TextField/TextField';\nimport { Autocomplete } from '@material-ui/lab';\nimport React from 'react';\nimport { Controller, FieldErrors } from 'react-hook-form';\n\ntype Props<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\nexport const AutocompleteTextField = <TFieldValue extends string>({\n name,\n options,\n required,\n errors,\n rules,\n loading = false,\n loadingText,\n helperText,\n errorHelperText,\n textFieldProps = {},\n}: Props<TFieldValue>) => {\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","/*\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 UnpackNestedValue,\n useForm,\n UseFormProps,\n UseFormReturn,\n} from 'react-hook-form';\n\ntype Props<TFieldValues extends Record<string, any>> = Pick<\n UseFormProps<TFieldValues>,\n 'defaultValues'\n> & {\n onSubmit: SubmitHandler<TFieldValues>;\n\n render: (\n props: Pick<\n UseFormReturn<TFieldValues>,\n 'formState' | 'register' | 'control' | 'setValue'\n > & {\n values: UnpackNestedValue<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 */\nexport const PreparePullRequestForm = <\n TFieldValues extends Record<string, any>,\n>({\n defaultValues,\n onSubmit,\n render,\n}: Props<TFieldValues>) => {\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","/*\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, CardContent, CardHeader } from '@material-ui/core';\nimport React from 'react';\nimport YAML from 'yaml';\nimport { CodeSnippet } from '@backstage/core-components';\nimport { trimEnd } from 'lodash';\n\ntype Props = {\n repositoryUrl: string;\n entities: Entity[];\n classes?: { card?: string; cardContent?: string };\n};\n\nexport const PreviewCatalogInfoComponent = ({\n repositoryUrl,\n entities,\n classes,\n}: Props) => {\n return (\n <Card variant=\"outlined\" className={classes?.card}>\n <CardHeader\n title={\n <code>{`${trimEnd(repositoryUrl, '/')}/catalog-info.yaml`}</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","/*\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, CardContent, CardHeader } from '@material-ui/core';\nimport React from 'react';\nimport { MarkdownContent } from '@backstage/core-components';\n\ntype Props = {\n title: string;\n description: string;\n classes?: { card?: string; cardContent?: string };\n};\n\nexport const PreviewPullRequestComponent = ({\n title,\n description,\n classes,\n}: 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","/*\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 {\n catalogApiRef,\n formatEntityRefTitle,\n} from '@backstage/plugin-catalog-react';\nimport { Box, FormHelperText, Grid, Typography } from '@material-ui/core';\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';\nimport YAML from 'yaml';\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\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\ntype Props = {\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\nexport const StepPrepareCreatePullRequest = ({\n analyzeResult,\n onPrepare,\n onGoBack,\n renderFormFields,\n}: Props) => {\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 {\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 => formatEntityRefTitle(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 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>catalog-info.yaml</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","/*\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 Checkbox,\n Grid,\n ListItem,\n ListItemIcon,\n ListItemText,\n Typography,\n} from '@material-ui/core';\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","/*\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, Grid, Typography } from '@material-ui/core';\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, useApi } from '@backstage/core-plugin-api';\nimport { Link } from '@backstage/core-components';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\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\n const appTitle = configApi.getOptional('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 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 presence:\n prepareResult.type === 'repository' ? 'optional' : 'required',\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 // 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]);\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","/*\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 Box,\n Checkbox,\n FormControlLabel,\n FormHelperText,\n StepLabel,\n TextField,\n Typography,\n} from '@material-ui/core';\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\nexport type 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 */\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","/*\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, StepContent, Stepper } from '@material-ui/core';\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\ntype Props = {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n};\n\nexport const ImportStepper = ({\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n}: Props) => {\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","/*\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';\nimport React from 'react';\nimport { ImportInfoCard } from '../ImportInfoCard';\nimport { ImportStepper } from '../ImportStepper';\n\nexport const DefaultImportPage = () => {\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptional('app.title') || 'Backstage';\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>\n Start tracking your component in {appTitle} by adding it to the\n software catalog.\n </SupportButton>\n </ContentHeader>\n\n <Grid container spacing={2} direction=\"row-reverse\">\n <Grid item xs={12} md={4} lg={6} xl={8}>\n <ImportInfoCard />\n </Grid>\n\n <Grid item xs={12} md={8} lg={6} xl={4}>\n <ImportStepper />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["useStyles","this"],"mappings":";;;;;;;;;;;;;;;;;;;;;;MAoBa,sBAAsB,aAA+B;AAAA,EAChE,IAAI;AAAA,EACJ,aAAa;AAAA;;MCHF,6BAA6B,CACxC,oBACA,aACG;AACH,QAAM,cAAc,mBAAmB,OAAO,MAAM;AACpD,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA;AAGT,QAAM,CAAE,MAAM,MAAM,SAAU,YAAY;AAC1C,SAAO;AAAA,IACL;AAAA,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,IAAC,SAAS;AAAA,IAAG,WAAU;AAAA,yCACnC,MAAD;AAAA,IAAM,MAAI;AAAA,IAAC,IAAI;AAAA,IAAI,IAAI;AAAA,IAAG,IAAI;AAAA,IAAG,IAAI;AAAA,yCAClC,gBAAD,4CAGD,MAAD;AAAA,IAAM,MAAI;AAAA,IAAC,IAAI;AAAA,IAAI,IAAI;AAAA,IAAG,IAAI;AAAA,IAAG,IAAI;AAAA,yCAClC,eAAD;AAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/api/CatalogImportApi.ts","../src/api/GitHub.ts","../src/api/CatalogImportClient.ts","../src/plugin.ts","../src/components/ImportInfoCard/ImportInfoCard.tsx","../src/components/useImportState.ts","../src/components/Buttons/index.tsx","../src/components/helpers.ts","../src/components/EntityListComponent/EntityListComponent.tsx","../src/components/StepFinishImportLocation/StepFinishImportLocation.tsx","../src/components/StepInitAnalyzeUrl/StepInitAnalyzeUrl.tsx","../src/components/StepPrepareCreatePullRequest/AutocompleteTextField.tsx","../src/components/StepPrepareCreatePullRequest/PreparePullRequestForm.tsx","../src/components/StepPrepareCreatePullRequest/PreviewCatalogInfoComponent.tsx","../src/components/StepPrepareCreatePullRequest/PreviewPullRequestComponent.tsx","../src/components/StepPrepareCreatePullRequest/StepPrepareCreatePullRequest.tsx","../src/components/StepPrepareSelectLocations/StepPrepareSelectLocations.tsx","../src/components/StepReviewLocation/StepReviewLocation.tsx","../src/components/ImportStepper/defaults.tsx","../src/components/ImportStepper/ImportStepper.tsx","../src/components/DefaultImportPage/DefaultImportPage.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 { EntityName } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { PartialEntity } from '../types';\n\nexport const catalogImportApiRef = createApiRef<CatalogImportApi>({\n id: 'plugin.catalog-import.service',\n description: 'Used by the catalog import plugin to make requests',\n});\n\n// result of the analyze state\nexport type AnalyzeResult =\n | {\n type: 'locations';\n locations: Array<{\n target: string;\n exists?: boolean;\n entities: EntityName[];\n }>;\n }\n | {\n type: 'repository';\n url: string;\n integrationType: string;\n generatedEntities: PartialEntity[];\n };\n\nexport interface CatalogImportApi {\n analyzeUrl(url: string): Promise<AnalyzeResult>;\n\n preparePullRequest?(): Promise<{\n title: string;\n body: string;\n }>;\n submitPullRequest(options: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }>;\n}\n","/*\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 { ScmIntegrationRegistry } from '@backstage/integration';\nimport parseGitUrl from 'git-url-parse';\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","/*\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 { EntityName } from '@backstage/catalog-model';\nimport {\n ConfigApi,\n DiscoveryApi,\n IdentityApi,\n} from '@backstage/core-plugin-api';\nimport {\n GitHubIntegrationConfig,\n ScmIntegrationRegistry,\n} from '@backstage/integration';\nimport { ScmAuthApi } from '@backstage/integration-react';\nimport { Octokit } from '@octokit/rest';\nimport { Base64 } from 'js-base64';\nimport { PartialEntity } from '../types';\nimport { AnalyzeResult, CatalogImportApi } from './CatalogImportApi';\nimport { getGithubIntegrationConfig } from './GitHub';\nimport { trimEnd } from 'lodash';\n\nexport class CatalogImportClient implements CatalogImportApi {\n private readonly discoveryApi: DiscoveryApi;\n private readonly identityApi: IdentityApi;\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 identityApi: IdentityApi;\n scmIntegrationsApi: ScmIntegrationRegistry;\n catalogApi: CatalogApi;\n configApi: ConfigApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.scmAuthApi = options.scmAuthApi;\n this.identityApi = options.identityApi;\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\n const ghConfig = getGithubIntegrationConfig(this.scmIntegrationsApi, url);\n if (!ghConfig) {\n const other = this.scmIntegrationsApi.byUrl(url);\n if (other) {\n throw new Error(\n `The ${other.title} integration only supports full URLs to catalog-info.yaml 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 GitHub URL because there was no configured integration that matched the given host name. You could try to paste the full URL to a catalog-info.yaml file instead.',\n );\n }\n\n // TODO: this could be part of the analyze-location endpoint\n const locations = await this.checkGitHubForExistingCatalogInfo({\n ...ghConfig,\n url,\n });\n\n if (locations.length > 0) {\n return {\n type: 'locations',\n locations,\n };\n }\n\n return {\n type: 'repository',\n integrationType: 'github',\n url: url,\n generatedEntities: await this.generateEntityDefinitions({\n repo: url,\n }),\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\n return {\n title: 'Add catalog-info.yaml 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/software-catalog-overview).`,\n };\n }\n\n async submitPullRequest({\n repositoryUrl,\n fileContent,\n title,\n body,\n }: {\n repositoryUrl: string;\n fileContent: string;\n title: string;\n body: string;\n }): Promise<{ link: string; location: string }> {\n const ghConfig = getGithubIntegrationConfig(\n this.scmIntegrationsApi,\n repositoryUrl,\n );\n\n if (ghConfig) {\n return await this.submitGitHubPrToRepo({\n ...ghConfig,\n repositoryUrl,\n fileContent,\n title,\n body,\n });\n }\n\n throw new Error('unimplemented!');\n }\n\n // TODO: this could be part of the catalog api\n private async generateEntityDefinitions({\n repo,\n }: {\n repo: string;\n }): Promise<PartialEntity[]> {\n const idToken = await this.identityApi.getIdToken();\n const response = await fetch(\n `${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,\n {\n headers: {\n 'Content-Type': 'application/json',\n ...(idToken && { Authorization: `Bearer ${idToken}` }),\n },\n method: 'POST',\n body: JSON.stringify({\n location: { type: 'url', target: repo },\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.generateEntities.map((x: any) => x.entity);\n }\n\n // TODO: this response should better be part of the analyze-locations response and scm-independent / implemented per scm\n private async checkGitHubForExistingCatalogInfo({\n url,\n owner,\n repo,\n githubIntegrationConfig,\n }: {\n url: string;\n owner: string;\n repo: string;\n githubIntegrationConfig: GitHubIntegrationConfig;\n }): Promise<\n Array<{\n target: string;\n entities: EntityName[];\n }>\n > {\n const { token } = await this.scmAuthApi.getCredentials({ url });\n const octo = new Octokit({\n auth: token,\n baseUrl: githubIntegrationConfig.apiBaseUrl,\n });\n const catalogFileName = 'catalog-info.yaml';\n const query = `repo:${owner}/${repo}+filename:${catalogFileName}`;\n\n const searchResult = await octo.search.code({ q: query }).catch(e => {\n throw new Error(\n formatHttpErrorMessage(\n \"Couldn't search repository for metadata file.\",\n e,\n ),\n );\n });\n const exists = searchResult.data.total_count > 0;\n if (exists) {\n const repoInformation = await octo.repos.get({ owner, repo }).catch(e => {\n throw new Error(formatHttpErrorMessage(\"Couldn't fetch repo data\", e));\n });\n const defaultBranch = repoInformation.data.default_branch;\n\n return await Promise.all(\n searchResult.data.items\n .map(i => `${trimEnd(url, '/')}/blob/${defaultBranch}/${i.path}`)\n .map(async target => {\n const result = await this.catalogApi.addLocation({\n type: 'url',\n target,\n dryRun: true,\n });\n return {\n target,\n exists: result.exists,\n entities: result.entities.map(e => ({\n kind: e.kind,\n namespace: e.metadata.namespace ?? 'default',\n name: e.metadata.name,\n })),\n };\n }),\n );\n }\n\n return [];\n }\n\n // TODO: extract this function and implement for non-github\n private async submitGitHubPrToRepo({\n owner,\n repo,\n title,\n body,\n fileContent,\n repositoryUrl,\n githubIntegrationConfig,\n }: {\n owner: string;\n repo: string;\n title: string;\n body: string;\n fileContent: string;\n repositoryUrl: string;\n githubIntegrationConfig: GitHubIntegrationConfig;\n }): Promise<{ link: string; location: string }> {\n const { token } = await this.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 = 'backstage-integration';\n const fileName = 'catalog-info.yaml';\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}\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","/*\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 identityApiRef,\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\nexport const catalogImportPlugin = createPlugin({\n id: 'catalog-import',\n apis: [\n createApiFactory({\n api: catalogImportApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n scmAuthApi: scmAuthApiRef,\n identityApi: identityApiRef,\n scmIntegrationsApi: scmIntegrationsApiRef,\n catalogApi: catalogApiRef,\n configApi: configApiRef,\n },\n factory: ({\n discoveryApi,\n scmAuthApi,\n identityApi,\n scmIntegrationsApi,\n catalogApi,\n configApi,\n }) =>\n new CatalogImportClient({\n discoveryApi,\n scmAuthApi,\n scmIntegrationsApi,\n identityApi,\n catalogApi,\n configApi,\n }),\n }),\n ],\n routes: {\n importPage: rootRouteRef,\n },\n});\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","/*\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, Typography } from '@material-ui/core';\nimport React from 'react';\nimport { catalogImportApiRef } from '../../api';\n\nexport const ImportInfoCard = () => {\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptional('app.title') || 'Backstage';\n const catalogImportApi = useApi(catalogImportApiRef);\n\n const integrations = configApi.getConfig('integrations');\n const hasGithubIntegration = integrations.has('github');\n\n return (\n <InfoCard\n title=\"Register an existing component\"\n deepLink={{\n title: 'Learn more about the Software Catalog',\n link: 'https://backstage.io/docs/features/software-catalog/software-catalog-overview',\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 variant=\"h6\">Link to an existing entity file</Typography>\n <Typography variant=\"subtitle2\" color=\"textSecondary\" paragraph>\n Example:{' '}\n <code>\n https://github.com/backstage/backstage/blob/master/catalog-info.yaml\n </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 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>https://github.com/backstage/backstage</code>\n </Typography>\n <Typography variant=\"body2\" paragraph>\n The wizard discovers all <code>catalog-info.yaml</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>catalog-info.yaml</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","/*\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, EntityName } from '@backstage/catalog-model';\nimport { useReducer } from 'react';\nimport { AnalyzeResult } from '../api';\n\n// the configuration of the stepper\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// result of the prepare state\nexport type PrepareResult =\n | {\n type: 'locations';\n locations: Array<{\n exists?: boolean;\n target: string;\n entities: EntityName[];\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: EntityName[];\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","/*\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 { Button, CircularProgress } from '@material-ui/core';\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","/*\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 { 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","/*\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, EntityName } from '@backstage/catalog-model';\nimport { useApp } from '@backstage/core-plugin-api';\nimport {\n EntityRefLink,\n formatEntityRefTitle,\n} from '@backstage/plugin-catalog-react';\nimport {\n Collapse,\n IconButton,\n List,\n ListItem,\n ListItemIcon,\n ListItemSecondaryAction,\n ListItemText,\n} from '@material-ui/core';\nimport { makeStyles } from '@material-ui/core/styles';\nimport ExpandLessIcon from '@material-ui/icons/ExpandLess';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport WorkIcon from '@material-ui/icons/Work';\nimport React, { useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n nested: {\n paddingLeft: theme.spacing(4),\n },\n}));\n\nfunction sortEntities(entities: Array<EntityName | Entity>) {\n return entities.sort((a, b) =>\n formatEntityRefTitle(a).localeCompare(formatEntityRefTitle(b)),\n );\n}\n\ntype Props = {\n locations: Array<{ target: string; entities: (Entity | EntityName)[] }>;\n locationListItemIcon: (target: string) => React.ReactElement;\n collapsed?: boolean;\n firstListItem?: React.ReactElement;\n onItemClick?: (target: string) => void;\n withLinks?: boolean;\n};\n\nexport const EntityListComponent = ({\n locations,\n collapsed = false,\n locationListItemIcon,\n onItemClick,\n firstListItem,\n withLinks = false,\n}: Props) => {\n const app = useApp();\n const classes = useStyles();\n\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 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?.call(this, 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 const Icon =\n app.getSystemIcon(\n `kind:${entity.kind.toLocaleLowerCase('en-US')}`,\n ) ?? WorkIcon;\n return (\n <ListItem\n key={formatEntityRefTitle(entity)}\n className={classes.nested}\n {...(withLinks\n ? {\n component: EntityRefLink,\n entityRef: entity,\n button: withLinks as any,\n }\n : {})}\n >\n <ListItemIcon>\n <Icon />\n </ListItemIcon>\n <ListItemText primary={formatEntityRefTitle(entity)} />\n </ListItem>\n );\n })}\n </List>\n </Collapse>\n </React.Fragment>\n ))}\n </List>\n );\n};\n","/*\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, Typography } from '@material-ui/core';\nimport LocationOnIcon from '@material-ui/icons/LocationOn';\nimport React from 'react';\nimport { BackButton } from '../Buttons';\nimport { EntityListComponent } from '../EntityListComponent';\nimport { PrepareResult } from '../useImportState';\nimport { Link } from '@backstage/core-components';\nimport partition from 'lodash/partition';\n\ntype Props = {\n prepareResult: PrepareResult;\n onReset: () => void;\n};\n\nexport const StepFinishImportLocation = ({ prepareResult, onReset }: Props) => {\n const continueButton = (\n <Grid container spacing={0}>\n <BackButton onClick={onReset}>Register another</BackButton>\n </Grid>\n );\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\n <Typography paragraph>\n Your entities will be imported as soon as the Pull Request is merged.\n </Typography>\n\n {continueButton}\n </>\n );\n }\n\n const [existingLocations, newLocations] = partition(\n prepareResult.locations,\n l => l.exists,\n );\n\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 {continueButton}\n </>\n );\n};\n","/*\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, Grid, TextField } from '@material-ui/core';\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\ntype Props = {\n onAnalysis: (\n flow: ImportFlows,\n url: string,\n result: AnalyzeResult,\n opts?: { prepareResult?: PrepareResult },\n ) => void;\n disablePullRequest?: boolean;\n analysisUrl?: 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 */\nexport const StepInitAnalyzeUrl = ({\n onAnalysis,\n analysisUrl = '',\n disablePullRequest = false,\n}: Props) => {\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=\"Repository URL\"\n placeholder=\"https://github.com/backstage/backstage/blob/master/catalog-info.yaml\"\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","/*\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, TextField } from '@material-ui/core';\nimport { TextFieldProps } from '@material-ui/core/TextField/TextField';\nimport { Autocomplete } from '@material-ui/lab';\nimport React from 'react';\nimport { Controller, FieldErrors } from 'react-hook-form';\n\ntype Props<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\nexport const AutocompleteTextField = <TFieldValue extends string>({\n name,\n options,\n required,\n errors,\n rules,\n loading = false,\n loadingText,\n helperText,\n errorHelperText,\n textFieldProps = {},\n}: Props<TFieldValue>) => {\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","/*\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 UnpackNestedValue,\n useForm,\n UseFormProps,\n UseFormReturn,\n} from 'react-hook-form';\n\ntype Props<TFieldValues extends Record<string, any>> = Pick<\n UseFormProps<TFieldValues>,\n 'defaultValues'\n> & {\n onSubmit: SubmitHandler<TFieldValues>;\n\n render: (\n props: Pick<\n UseFormReturn<TFieldValues>,\n 'formState' | 'register' | 'control' | 'setValue'\n > & {\n values: UnpackNestedValue<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 */\nexport const PreparePullRequestForm = <\n TFieldValues extends Record<string, any>,\n>({\n defaultValues,\n onSubmit,\n render,\n}: Props<TFieldValues>) => {\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","/*\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, CardContent, CardHeader } from '@material-ui/core';\nimport React from 'react';\nimport YAML from 'yaml';\nimport { CodeSnippet } from '@backstage/core-components';\nimport { trimEnd } from 'lodash';\n\ntype Props = {\n repositoryUrl: string;\n entities: Entity[];\n classes?: { card?: string; cardContent?: string };\n};\n\nexport const PreviewCatalogInfoComponent = ({\n repositoryUrl,\n entities,\n classes,\n}: Props) => {\n return (\n <Card variant=\"outlined\" className={classes?.card}>\n <CardHeader\n title={\n <code>{`${trimEnd(repositoryUrl, '/')}/catalog-info.yaml`}</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","/*\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, CardContent, CardHeader } from '@material-ui/core';\nimport React from 'react';\nimport { MarkdownContent } from '@backstage/core-components';\n\ntype Props = {\n title: string;\n description: string;\n classes?: { card?: string; cardContent?: string };\n};\n\nexport const PreviewPullRequestComponent = ({\n title,\n description,\n classes,\n}: 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","/*\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 formatEntityRefTitle,\n} from '@backstage/plugin-catalog-react';\nimport { Box, FormHelperText, Grid, Typography } from '@material-ui/core';\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';\nimport YAML from 'yaml';\nimport { AnalyzeResult, catalogImportApiRef } from '../../api';\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\ntype Props = {\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\nexport const StepPrepareCreatePullRequest = ({\n analyzeResult,\n onPrepare,\n onGoBack,\n renderFormFields,\n}: Props) => {\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 {\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 => formatEntityRefTitle(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>catalog-info.yaml</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","/*\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 Checkbox,\n Grid,\n ListItem,\n ListItemIcon,\n ListItemText,\n Typography,\n} from '@material-ui/core';\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","/*\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, Grid, Typography } from '@material-ui/core';\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, 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\n const appTitle = configApi.getOptional('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 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 presence:\n prepareResult.type === 'repository' ? 'optional' : 'required',\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]);\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","/*\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 Box,\n Checkbox,\n FormControlLabel,\n FormHelperText,\n StepLabel,\n TextField,\n Typography,\n} from '@material-ui/core';\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\nexport type 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 */\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","/*\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, StepContent, Stepper } from '@material-ui/core';\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\ntype Props = {\n initialUrl?: string;\n generateStepper?: (\n flow: ImportFlows,\n defaults: StepperProvider,\n ) => StepperProvider;\n variant?: InfoCardVariants;\n};\n\nexport const ImportStepper = ({\n initialUrl,\n generateStepper = defaultGenerateStepper,\n variant,\n}: Props) => {\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","/*\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';\nimport React from 'react';\nimport { ImportInfoCard } from '../ImportInfoCard';\nimport { ImportStepper } from '../ImportStepper';\n\nexport const DefaultImportPage = () => {\n const configApi = useApi(configApiRef);\n const appTitle = configApi.getOptional('app.title') || 'Backstage';\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>\n Start tracking your component in {appTitle} by adding it to the\n software catalog.\n </SupportButton>\n </ContentHeader>\n\n <Grid container spacing={2} direction=\"row-reverse\">\n <Grid item xs={12} md={4} lg={6} xl={8}>\n <ImportInfoCard />\n </Grid>\n\n <Grid item xs={12} md={8} lg={6} xl={4}>\n <ImportStepper />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["useStyles","this"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAoBa,sBAAsB,aAA+B;AAAA,EAChE,IAAI;AAAA,EACJ,aAAa;AAAA;;MCHF,6BAA6B,CACxC,oBACA,aACG;AACH,QAAM,cAAc,mBAAmB,OAAO,MAAM;AACpD,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA;AAGT,QAAM,EAAE,MAAM,MAAM,UAAU,YAAY;AAC1C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,yBAAyB,YAAY;AAAA;AAAA;;0BCGoB;AAAA,EAQ3D,YAAY,SAOT;AACD,SAAK,eAAe,QAAQ;AAC5B,SAAK,aAAa,QAAQ;AAC1B,SAAK,cAAc,QAAQ;AAC3B,SAAK,qBAAqB,QAAQ;AAClC,SAAK,aAAa,QAAQ;AAC1B,SAAK,YAAY,QAAQ;AAAA;AAAA,QAGrB,WAAW,KAAqC;AA3DxD;AA4DI,QACE,IAAI,IAAI,KAAK,SAAS,MAAM,0BACxB,IAAI,KAAK,aAAa,IAAI,YAA9B,mBAAuC,MAAM,aAC7C;AACA,YAAM,WAAW,MAAM,KAAK,WAAW,YAAY;AAAA,QACjD,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;AAAA;AAGV,aAAO;AAAA,QACL,MAAM;AAA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AAY,iBACxC,CAAC,iBAAiB,MAAM;AAG1B,QAAM,SAAS,CAAC,SAA4B;AAC1C,+CACG,MAAD,MACG,KAAK,+CACL,aAAD,MAAc,KAAK;AAAA;AAKzB,6CACG,UAAD;AAAA,IAAU;AAAA,yCACP,SAAD;AAAA,IACE,SAAS,EAAE,MAAM,QAAQ;AAAA,IACzB,YAAY,MAAM;AAAA,IAClB,aAAY;AAAA,KAEX,OACC,OAAO,QACL,OACA,EAAE,MAAM,EAAE,wBAGb,OACC,OAAO,QACL,OACA,EAAE,MAAM,EAAE,wBAGb,OACC,OAAO,OACL,OACA,EAAE,MAAM,EAAE,wBAGb,OACC,OAAO,OACL,OACA,EAAE,MAAM,EAAE;AAAA;;MCnET,oBAAoB,MAAM;AACrC,QAAM,YAAY,OAAO;AACzB,QAAM,WAAW,UAAU,YAAY,gBAAgB;AAEvD,6CACG,MAAD;AAAA,IAAM,SAAQ;AAAA,yCACX,QAAD;AAAA,IAAQ,OAAM;AAAA,0CACb,SAAD,0CACG,eAAD;AAAA,IAAe,OAAO,oCAAoC;AAAA,yCACvD,eAAD,MAAe,qCACqB,UAAS,gFAK9C,MAAD;AAAA,IAAM,WAAS;AAAA,IAAC,SAAS;AAAA,IAAG,WAAU;AAAA,yCACnC,MAAD;AAAA,IAAM,MAAI;AAAA,IAAC,IAAI;AAAA,IAAI,IAAI;AAAA,IAAG,IAAI;AAAA,IAAG,IAAI;AAAA,yCAClC,gBAAD,4CAGD,MAAD;AAAA,IAAM,MAAI;AAAA,IAAC,IAAI;AAAA,IAAI,IAAI;AAAA,IAAG,IAAI;AAAA,IAAG,IAAI;AAAA,yCAClC,eAAD;AAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-import",
|
|
3
3
|
"description": "A Backstage plugin the helps you import entities into your catalog",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.5",
|
|
5
5
|
"main": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -31,43 +31,45 @@
|
|
|
31
31
|
"clean": "backstage-cli clean"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@backstage/catalog-client": "^0.5.
|
|
35
|
-
"@backstage/catalog-model": "^0.9.
|
|
36
|
-
"@backstage/core-components": "^0.
|
|
37
|
-
"@backstage/core-plugin-api": "^0.
|
|
38
|
-
"@backstage/
|
|
39
|
-
"@backstage/integration
|
|
40
|
-
"@backstage/
|
|
34
|
+
"@backstage/catalog-client": "^0.5.2",
|
|
35
|
+
"@backstage/catalog-model": "^0.9.7",
|
|
36
|
+
"@backstage/core-components": "^0.8.0",
|
|
37
|
+
"@backstage/core-plugin-api": "^0.3.0",
|
|
38
|
+
"@backstage/errors": "^0.1.3",
|
|
39
|
+
"@backstage/integration": "^0.6.10",
|
|
40
|
+
"@backstage/integration-react": "^0.1.15",
|
|
41
|
+
"@backstage/plugin-catalog-react": "^0.6.5",
|
|
41
42
|
"@material-ui/core": "^4.12.2",
|
|
42
43
|
"@material-ui/icons": "^4.9.1",
|
|
43
44
|
"@material-ui/lab": "4.0.0-alpha.57",
|
|
44
45
|
"@octokit/rest": "^18.5.3",
|
|
45
|
-
"@types/react": "*",
|
|
46
46
|
"git-url-parse": "^11.6.0",
|
|
47
47
|
"js-base64": "^3.6.0",
|
|
48
48
|
"lodash": "^4.17.21",
|
|
49
|
-
"react": "^16.13.1",
|
|
50
|
-
"react-dom": "^16.13.1",
|
|
51
49
|
"react-hook-form": "^7.12.2",
|
|
52
50
|
"react-router": "6.0.0-beta.0",
|
|
53
51
|
"react-use": "^17.2.4",
|
|
54
52
|
"yaml": "^1.10.0"
|
|
55
53
|
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@types/react": "^16.13.1 || ^17.0.0",
|
|
56
|
+
"react": "^16.13.1 || ^17.0.0"
|
|
57
|
+
},
|
|
56
58
|
"devDependencies": {
|
|
57
|
-
"@backstage/cli": "^0.
|
|
58
|
-
"@backstage/core-app-api": "^0.
|
|
59
|
-
"@backstage/dev-utils": "^0.2.
|
|
60
|
-
"@backstage/test-utils": "^0.1.
|
|
59
|
+
"@backstage/cli": "^0.10.1",
|
|
60
|
+
"@backstage/core-app-api": "^0.2.0",
|
|
61
|
+
"@backstage/dev-utils": "^0.2.14",
|
|
62
|
+
"@backstage/test-utils": "^0.1.24",
|
|
61
63
|
"@testing-library/jest-dom": "^5.10.1",
|
|
62
64
|
"@testing-library/react": "^11.2.5",
|
|
63
65
|
"@testing-library/react-hooks": "^7.0.2",
|
|
64
66
|
"@testing-library/user-event": "^13.1.8",
|
|
65
67
|
"@types/jest": "^26.0.7",
|
|
66
68
|
"cross-fetch": "^3.0.6",
|
|
67
|
-
"msw": "^0.
|
|
69
|
+
"msw": "^0.35.0"
|
|
68
70
|
},
|
|
69
71
|
"files": [
|
|
70
72
|
"dist"
|
|
71
73
|
],
|
|
72
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "562be0b43016294e27af3ad024191bb86b13b1c1"
|
|
73
75
|
}
|