@@ -78,8 +78,7 @@ const Component: ProviderComponent = ({ onResult }) => {
|
||||
<form className={classes.form} onSubmit={handleSubmit(handleResult)}>
|
||||
<FormControl>
|
||||
<TextField
|
||||
{...register({ required: true })}
|
||||
name="userId"
|
||||
{...register('userId', { required: true })}
|
||||
label="User ID"
|
||||
margin="normal"
|
||||
error={Boolean(errors.userId)}
|
||||
@@ -90,18 +89,17 @@ const Component: ProviderComponent = ({ onResult }) => {
|
||||
</FormControl>
|
||||
<FormControl>
|
||||
<TextField
|
||||
name="idToken"
|
||||
label="ID Token (optional)"
|
||||
margin="normal"
|
||||
autoComplete="off"
|
||||
error={Boolean(errors.idToken)}
|
||||
inputRef={register({
|
||||
{...register('idToken', {
|
||||
required: false,
|
||||
validate: token =>
|
||||
!token ||
|
||||
ID_TOKEN_REGEX.test(token) ||
|
||||
'Token is not a valid OpenID Connect JWT Token',
|
||||
})}
|
||||
label="ID Token (optional)"
|
||||
margin="normal"
|
||||
autoComplete="off"
|
||||
error={Boolean(errors.idToken)}
|
||||
/>
|
||||
{errors.idToken && (
|
||||
<FormHelperText error>{errors.idToken.message}</FormHelperText>
|
||||
|
||||
@@ -52,7 +52,12 @@ export const StepInitAnalyzeUrl = ({
|
||||
const errorApi = useApi(errorApiRef);
|
||||
const catalogImportApi = useApi(catalogImportApiRef);
|
||||
|
||||
const { register, handleSubmit, errors, watch } = useForm<FormData>({
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
watch,
|
||||
} = useForm<FormData>({
|
||||
mode: 'onTouched',
|
||||
defaultValues: {
|
||||
url: analysisUrl,
|
||||
@@ -118,16 +123,7 @@ export const StepInitAnalyzeUrl = ({
|
||||
return (
|
||||
<form onSubmit={handleSubmit(handleResult)}>
|
||||
<TextField
|
||||
fullWidth
|
||||
id="url"
|
||||
name="url"
|
||||
label="Repository URL"
|
||||
placeholder="https://github.com/backstage/backstage/blob/master/catalog-info.yaml"
|
||||
helperText="Enter the full path to your entity file to start tracking your component"
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
error={Boolean(errors.url)}
|
||||
inputRef={register({
|
||||
{...register('url', {
|
||||
required: true,
|
||||
validate: {
|
||||
httpsValidator: (value: any) =>
|
||||
@@ -136,6 +132,14 @@ export const StepInitAnalyzeUrl = ({
|
||||
'Must start with http:// or https://.',
|
||||
},
|
||||
})}
|
||||
fullWidth
|
||||
id="url"
|
||||
label="Repository URL"
|
||||
placeholder="https://github.com/backstage/backstage/blob/master/catalog-info.yaml"
|
||||
helperText="Enter the full path to your entity file to start tracking your component"
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
error={Boolean(errors.url)}
|
||||
required
|
||||
/>
|
||||
|
||||
|
||||
+4
-11
@@ -18,12 +18,7 @@ import { CircularProgress, TextField } from '@material-ui/core';
|
||||
import { TextFieldProps } from '@material-ui/core/TextField/TextField';
|
||||
import { Autocomplete } from '@material-ui/lab';
|
||||
import React from 'react';
|
||||
import {
|
||||
Control,
|
||||
Controller,
|
||||
FieldErrors,
|
||||
UseControllerOptions,
|
||||
} from 'react-hook-form';
|
||||
import { Control, Controller, FieldErrors } from 'react-hook-form';
|
||||
|
||||
type Props<TFieldValue extends string> = {
|
||||
name: TFieldValue;
|
||||
@@ -32,7 +27,7 @@ type Props<TFieldValue extends string> = {
|
||||
|
||||
control?: Control<Record<string, any>>;
|
||||
errors?: FieldErrors<Record<TFieldValue, string>>;
|
||||
rules?: UseControllerOptions<Record<TFieldValue, any>>['rules'];
|
||||
rules?: React.ComponentProps<typeof Controller>['rules'];
|
||||
|
||||
loading?: boolean;
|
||||
loadingText?: string;
|
||||
@@ -61,16 +56,14 @@ export const AutocompleteTextField = <TFieldValue extends string>({
|
||||
name={name}
|
||||
control={control}
|
||||
rules={rules}
|
||||
render={({ value, onChange, onBlur }) => (
|
||||
render={({ field }) => (
|
||||
<Autocomplete
|
||||
loading={loading}
|
||||
loadingText={loadingText}
|
||||
options={options || []}
|
||||
onChange={(_: any, v: string | null) => onChange(v || '')}
|
||||
onBlur={onBlur}
|
||||
value={value}
|
||||
autoSelect
|
||||
freeSolo
|
||||
{...field}
|
||||
renderInput={params => (
|
||||
<TextField
|
||||
{...params}
|
||||
|
||||
+10
@@ -55,8 +55,18 @@ export const PreparePullRequestForm = <
|
||||
onSubmit,
|
||||
render,
|
||||
}: Props<TFieldValues>) => {
|
||||
<<<<<<< HEAD
|
||||
const { handleSubmit, watch, control, register, errors } =
|
||||
useForm<TFieldValues>({ mode: 'onTouched', defaultValues });
|
||||
=======
|
||||
const {
|
||||
handleSubmit,
|
||||
watch,
|
||||
control,
|
||||
register,
|
||||
formState: { errors },
|
||||
} = useForm<TFieldValues>({ mode: 'onTouched', defaultValues });
|
||||
>>>>>>> chore: fixing up some migrations
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
|
||||
Reference in New Issue
Block a user