diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx
index cd3ae4ff40..0454da74e1 100644
--- a/packages/app/src/App.tsx
+++ b/packages/app/src/App.tsx
@@ -68,6 +68,7 @@ const catalogRouteRef = createRouteRef({
const AppRoutes = () => (
+ } />
}
@@ -83,7 +84,6 @@ const AppRoutes = () => (
path="/register-component"
element={}
/>
- } />
} />
{...deprecatedAppRoutes}
diff --git a/plugins/catalog-import/README.md b/plugins/catalog-import/README.md
index 682212d98d..1dc0d7cf89 100644
--- a/plugins/catalog-import/README.md
+++ b/plugins/catalog-import/README.md
@@ -1,7 +1,21 @@
-# Register component plugin
+# Catalog import plugin
-Welcome to the import-component plugin!
+Welcome to the catalog-import plugin!
-This plugin allows you to create a component-config YAML file for your repository.
+This plugin allows you to bootstrap a component-config YAML file for your repository and open a pull request to add it.
-When installed it is accessible on [localhost:3000/import-component](localhost:3000/import-component).
+When installed it is accessible on [localhost:3000/catalog-import](localhost:3000/catalog-import).
+
+
+
+## Running
+
+Just run the backstage.
+
+```
+yarn start && yarn --cwd packages/backend start
+```
+
+## Usage
+
+Pretty straightforward, navigate to [localhost:3000/catalog-import](localhost:3000/catalog-import) and enter your repo's URL.
diff --git a/plugins/catalog-import/src/api/CatalogImportApi.ts b/plugins/catalog-import/src/api/CatalogImportApi.ts
index 58d1f87f00..28749d02cb 100644
--- a/plugins/catalog-import/src/api/CatalogImportApi.ts
+++ b/plugins/catalog-import/src/api/CatalogImportApi.ts
@@ -13,25 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * Copyright 2020 Roadie AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
import { createApiRef } from '@backstage/core';
-import { Entity } from '@backstage/catalog-model';
-import { RecursivePartial } from '../util/types';
+import { PartialEntity } from '../util/types';
export const catalogImportApiRef = createApiRef({
id: 'plugin.catalogimport.service',
@@ -52,5 +36,5 @@ export interface CatalogImportApi {
}): Promise<{ errorMessage: string | null }>;
generateEntityDefinitions(options: {
repo: string;
- }): Promise[]>;
+ }): Promise;
}
diff --git a/plugins/catalog-import/src/api/CatalogImportClient.ts b/plugins/catalog-import/src/api/CatalogImportClient.ts
index d67febe2c8..2da0ff02a7 100644
--- a/plugins/catalog-import/src/api/CatalogImportClient.ts
+++ b/plugins/catalog-import/src/api/CatalogImportClient.ts
@@ -13,28 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * Copyright 2020 Roadie AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
import { Octokit } from '@octokit/rest';
-import { Entity } from '@backstage/catalog-model';
import { DiscoveryApi } from '@backstage/core';
import { CatalogImportApi } from './CatalogImportApi';
import { AnalyzeLocationResponse } from '@backstage/plugin-catalog-backend';
-import { RecursivePartial } from '../util/types';
+import { PartialEntity } from '../util/types';
export const API_BASE_URL = '/api/catalog/locations';
@@ -49,7 +33,7 @@ export class CatalogImportClient implements CatalogImportApi {
repo,
}: {
repo: string;
- }): Promise[]> {
+ }): Promise {
const response = await fetch(
`${await this.discoveryApi.getBaseUrl('catalog')}/analyze-location`,
{
@@ -117,7 +101,7 @@ export class CatalogImportClient implements CatalogImportApi {
await octo.repos.createOrUpdateFileContents({
owner,
repo,
- path: 'backstage.yaml',
+ path: 'catalog-info.yaml',
message: 'Add backstage.yaml config file',
content: btoa(fileContent),
branch: 'backstage-integration',
@@ -125,7 +109,7 @@ export class CatalogImportClient implements CatalogImportApi {
const pullRequestRespone = await octo.pulls.create({
owner,
repo,
- title: 'Add backstage.yaml config file',
+ title: 'Add catalog-info.yaml config file',
head: 'backstage-integration',
base: 'master',
});
diff --git a/plugins/catalog-import/src/api/index.ts b/plugins/catalog-import/src/api/index.ts
index 9ebc110843..078342d284 100644
--- a/plugins/catalog-import/src/api/index.ts
+++ b/plugins/catalog-import/src/api/index.ts
@@ -13,22 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * Copyright 2020 Roadie AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
export * from './CatalogImportApi';
export * from './CatalogImportClient';
-export * from './types';
diff --git a/plugins/catalog-import/src/api/types.ts b/plugins/catalog-import/src/api/types.ts
deleted file mode 100644
index c18d0cf547..0000000000
--- a/plugins/catalog-import/src/api/types.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2020 Spotify AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * Copyright 2020 Roadie AB
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export type GithubRepoDto = {
- full_name: string;
- private: boolean;
- description: string;
- html_url: string;
- language: string;
-};
diff --git a/plugins/catalog-import/src/assets/catalog-import-screenshot.png b/plugins/catalog-import/src/assets/catalog-import-screenshot.png
new file mode 100644
index 0000000000..7ba8ae9eb5
Binary files /dev/null and b/plugins/catalog-import/src/assets/catalog-import-screenshot.png differ
diff --git a/plugins/catalog-import/src/components/ImportComponentPage/ComponentConfigDisplay.tsx b/plugins/catalog-import/src/components/ComponentConfigDisplay.tsx
similarity index 73%
rename from plugins/catalog-import/src/components/ImportComponentPage/ComponentConfigDisplay.tsx
rename to plugins/catalog-import/src/components/ComponentConfigDisplay.tsx
index 22d3dac322..1fe1543bdd 100644
--- a/plugins/catalog-import/src/components/ImportComponentPage/ComponentConfigDisplay.tsx
+++ b/plugins/catalog-import/src/components/ComponentConfigDisplay.tsx
@@ -13,32 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
- * Copyright 2020 RoadieHQ
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
import React, { useCallback, useState } from 'react';
import { Button, CircularProgress, Grid, Tooltip } from '@material-ui/core';
import Alert from '@material-ui/lab/Alert';
-import { useGithubRepos } from './useGithubRepos';
-import { Entity } from '@backstage/catalog-model';
-import { RecursivePartial } from '../../util/types';
+import { useGithubRepos } from '../util/useGithubRepos';
+import { ConfigSpec } from './ImportComponentPage';
type Props = {
nextStep: () => void;
- configFile: { repo: string; config: RecursivePartial[] };
+ configFile: ConfigSpec;
savePRLink: (PRLink: string) => void;
};
diff --git a/plugins/catalog-import/src/components/ImportComponentForm/ImportComponentForm.tsx b/plugins/catalog-import/src/components/ImportComponentForm.tsx
similarity index 60%
rename from plugins/catalog-import/src/components/ImportComponentForm/ImportComponentForm.tsx
rename to plugins/catalog-import/src/components/ImportComponentForm.tsx
index 876d198d5c..5b26c27d09 100644
--- a/plugins/catalog-import/src/components/ImportComponentForm/ImportComponentForm.tsx
+++ b/plugins/catalog-import/src/components/ImportComponentForm.tsx
@@ -14,25 +14,21 @@
* limitations under the License.
*/
-import { Entity } from '@backstage/catalog-model';
import { errorApiRef, useApi } from '@backstage/core';
import { BackstageTheme } from '@backstage/theme';
import {
Button,
FormControl,
FormHelperText,
- InputLabel,
- MenuItem,
- Select,
TextField,
} from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import React from 'react';
-import { Controller, useForm } from 'react-hook-form';
+import { useForm } from 'react-hook-form';
import { useMountedState } from 'react-use';
-import { RecursivePartial } from '../../util/types';
-import { ComponentIdValidators } from '../../util/validate';
-import { useGithubRepos } from '../ImportComponentPage/useGithubRepos';
+import { ComponentIdValidators } from '../util/validate';
+import { useGithubRepos } from '../util/useGithubRepos';
+import { ConfigSpec } from './ImportComponentPage';
const useStyles = makeStyles(theme => ({
form: {
@@ -43,21 +39,15 @@ const useStyles = makeStyles(theme => ({
submit: {
marginTop: theme.spacing(1),
},
- select: {
- minWidth: 120,
- },
}));
type Props = {
nextStep: () => void;
- saveConfig: (configFile: {
- repo: string;
- config: RecursivePartial[];
- }) => void;
+ saveConfig: (configFile: ConfigSpec) => void;
};
export const RegisterComponentForm = ({ nextStep, saveConfig }: Props) => {
- const { control, register, handleSubmit, errors, formState } = useForm({
+ const { register, handleSubmit, errors, formState } = useForm({
mode: 'onChange',
});
const classes = useStyles();
@@ -71,22 +61,9 @@ export const RegisterComponentForm = ({ nextStep, saveConfig }: Props) => {
const onSubmit = async (formData: Record) => {
const { componentLocation: target } = formData;
try {
- // const typeMapping = [
- // { url: /^https:\/\/gitlab\.com\/.*/, type: 'gitlab/api' },
- // { url: /^https:\/\/bitbucket\.org\/.*/, type: 'bitbucket/api' },
- // { url: /^https:\/\/dev\.azure\.com\/.*/, type: 'azure/api' },
- // { url: /.*/, type: 'github' },
- // ];
-
- // const type =
- // scmType === 'AUTO'
- // ? typeMapping.filter(item => item.url.test(target))[0].type
- // : scmType;
-
if (!isMounted()) return;
const repo = target.split('/').slice(-2).join('/');
-
const config = await generateEntityDefinitions(repo);
saveConfig({
repo,
@@ -103,20 +80,18 @@ export const RegisterComponentForm = ({ nextStep, saveConfig }: Props) => {
autoComplete="off"
onSubmit={handleSubmit(onSubmit)}
className={classes.form}
- data-testid="register-form"
>
{
)}
-
- Host type
- (
-
- )}
- />
-