Posting addLocation
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
import { CatalogApi } from './types';
|
||||
import { DescriptorEnvelope } from '../types';
|
||||
import {} from '@backstage/catalog-model';
|
||||
|
||||
export class CatalogClient implements CatalogApi {
|
||||
private apiOrigin: string;
|
||||
@@ -44,6 +43,7 @@ export class CatalogClient implements CatalogApi {
|
||||
throw new Error(`'Entity not found: ${name}`);
|
||||
}
|
||||
|
||||
// TODO: Types for the type param
|
||||
async addLocation(type: string, target: string): Promise<{}> {
|
||||
const response = await fetch(
|
||||
`${this.apiOrigin}${this.basePath}/locations`,
|
||||
|
||||
+10
-9
@@ -23,22 +23,23 @@ import {
|
||||
Content,
|
||||
ContentHeader,
|
||||
SupportButton,
|
||||
useApi,
|
||||
} from '@backstage/core';
|
||||
import RegisterComponentForm from '../RegisterComponentForm';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog';
|
||||
|
||||
const RegisterComponentPage: FC<{}> = () => {
|
||||
const catalogApi = useApi(catalogApiRef);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (isSubmitting) {
|
||||
setTimeout(() => {
|
||||
setIsSubmitting(false);
|
||||
}, 4000);
|
||||
}
|
||||
}, [isSubmitting]);
|
||||
|
||||
const onSubmit = () => {
|
||||
const onSubmit = async (formData: { componentIdInput: string }) => {
|
||||
setIsSubmitting(true);
|
||||
|
||||
const { componentIdInput: target } = formData;
|
||||
|
||||
const location = await catalogApi.addLocation('github', target);
|
||||
|
||||
setIsSubmitting(false);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user