Merge branch 'master' of github.com:spotify/backstage into feat/backend-plugin
* 'master' of github.com:spotify/backstage: docs: clarify role of identity and SignInPage tests(register-component): update tests to use test-id for submit button feature(component-registration): allow SCM specification Fix identity typo Bump version of techdocs-core plugin in techdocs-container (#2539) TechDocs: adjust mkdocs extensions (#2516) comment to explain option Added toggled option for allowing longpath in windows through nodegit create-app: fix missing .gitignore file when scaffolded
This commit is contained in:
@@ -58,7 +58,7 @@ describe('Catalog Filter', () => {
|
||||
] as Entity[]),
|
||||
};
|
||||
|
||||
const indentityApi: Partial<IdentityApi> = {
|
||||
const identityApi: Partial<IdentityApi> = {
|
||||
getUserId: () => 'tools@example.com',
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ describe('Catalog Filter', () => {
|
||||
<ApiProvider
|
||||
apis={ApiRegistry.from([
|
||||
[catalogApiRef, catalogApi],
|
||||
[identityApiRef, indentityApi],
|
||||
[identityApiRef, identityApi],
|
||||
[storageApiRef, MockStorageApi.create()],
|
||||
])}
|
||||
>
|
||||
|
||||
+6
-2
@@ -41,7 +41,9 @@ describe('RegisterComponentForm', () => {
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
|
||||
const submit = (await rendered.getByRole('button')) as HTMLButtonElement;
|
||||
const submit = (await rendered.getByTestId(
|
||||
'registerComponentFormSubmit',
|
||||
)) as HTMLButtonElement;
|
||||
expect(submit.disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -54,7 +56,9 @@ describe('RegisterComponentForm', () => {
|
||||
target: { value: 'https://example.com/blob/master/component.yaml' },
|
||||
});
|
||||
});
|
||||
const submit = (await rendered.getByRole('button')) as HTMLButtonElement;
|
||||
const submit = (await rendered.getByTestId(
|
||||
'registerComponentFormSubmit',
|
||||
)) as HTMLButtonElement;
|
||||
|
||||
expect(submit.disabled).toBeFalsy();
|
||||
});
|
||||
|
||||
+30
-2
@@ -21,10 +21,13 @@ import {
|
||||
FormHelperText,
|
||||
LinearProgress,
|
||||
TextField,
|
||||
Select,
|
||||
MenuItem,
|
||||
InputLabel,
|
||||
} from '@material-ui/core';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import React, { FC } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { ComponentIdValidators } from '../../util/validate';
|
||||
|
||||
const useStyles = makeStyles<BackstageTheme>(theme => ({
|
||||
@@ -44,7 +47,7 @@ export type Props = {
|
||||
};
|
||||
|
||||
const RegisterComponentForm: FC<Props> = ({ onSubmit, submitting }) => {
|
||||
const { register, handleSubmit, errors, formState } = useForm({
|
||||
const { control, register, handleSubmit, errors, formState } = useForm({
|
||||
mode: 'onChange',
|
||||
});
|
||||
const classes = useStyles();
|
||||
@@ -84,8 +87,33 @@ const RegisterComponentForm: FC<Props> = ({ onSubmit, submitting }) => {
|
||||
</FormHelperText>
|
||||
)}
|
||||
</FormControl>
|
||||
|
||||
<FormControl variant="outlined">
|
||||
<InputLabel id="scmLabel">SCM Detection</InputLabel>
|
||||
<Controller
|
||||
control={control}
|
||||
name="scmType"
|
||||
defaultValue="AUTO"
|
||||
render={({ onChange, onBlur, value }) => (
|
||||
<Select
|
||||
labelId="scmLabel"
|
||||
id="scmSelect"
|
||||
label="scmLabel"
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
onBlur={onBlur}
|
||||
>
|
||||
<MenuItem value="AUTO">Auto-detect</MenuItem>
|
||||
<MenuItem value="gitlab">GitLab</MenuItem>
|
||||
<MenuItem value="bitbucket/api">Bitbucket</MenuItem>
|
||||
<MenuItem value="azure/api">Azure</MenuItem>
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
</FormControl>
|
||||
<Button
|
||||
id="registerComponentFormSubmit"
|
||||
data-testid="registerComponentFormSubmit"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
type="submit"
|
||||
|
||||
+5
-3
@@ -82,7 +82,7 @@ export const RegisterComponentPage = ({
|
||||
|
||||
const handleSubmit = async (formData: Record<string, string>) => {
|
||||
setFormState(FormStates.Submitting);
|
||||
const { componentLocation: target } = formData;
|
||||
const { scmType, componentLocation: target } = formData;
|
||||
try {
|
||||
const typeMapping = [
|
||||
{ url: /https:\/\/gitlab\.com\/.*/, type: 'gitlab' },
|
||||
@@ -91,8 +91,10 @@ export const RegisterComponentPage = ({
|
||||
{ url: /.*/, type: 'github' },
|
||||
];
|
||||
|
||||
const type = typeMapping.filter(item => item.url.test(target))[0].type;
|
||||
|
||||
const type =
|
||||
scmType === 'AUTO'
|
||||
? typeMapping.filter(item => item.url.test(target))[0].type
|
||||
: scmType;
|
||||
const data = await catalogApi.addLocation(type, target);
|
||||
|
||||
if (!isMounted()) return;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import parseGitUrl from 'git-url-parse';
|
||||
import { Clone, Repository } from 'nodegit';
|
||||
import NodeGit, { Clone, Repository } from 'nodegit';
|
||||
import fs from 'fs-extra';
|
||||
// @ts-ignore
|
||||
import defaultBranch from 'default-branch';
|
||||
@@ -26,6 +26,10 @@ import { InputError } from '@backstage/backend-common';
|
||||
import { RemoteProtocol } from './techdocs/stages/prepare/types';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
// Enables core.longpaths on windows to prevent crashing when checking out repos with long foldernames and/or deep nesting
|
||||
// @ts-ignore
|
||||
NodeGit.Libgit2.opts(28, 1);
|
||||
|
||||
export type ParsedLocationAnnotation = {
|
||||
type: RemoteProtocol;
|
||||
target: string;
|
||||
|
||||
Reference in New Issue
Block a user