refactor: extract BaseRepoBranchPickerProps
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
+3
-7
@@ -21,7 +21,7 @@ import TextField from '@material-ui/core/TextField';
|
||||
import Autocomplete from '@material-ui/lab/Autocomplete';
|
||||
import useDebounce from 'react-use/esm/useDebounce';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import { RepoBranchPickerState } from './types';
|
||||
import { BaseRepoBranchPickerProps } from './types';
|
||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
|
||||
/**
|
||||
@@ -37,13 +37,9 @@ export const BitbucketRepoBranchPicker = ({
|
||||
rawErrors,
|
||||
accessToken,
|
||||
required,
|
||||
}: {
|
||||
onChange: (state: RepoBranchPickerState) => void;
|
||||
state: RepoBranchPickerState;
|
||||
rawErrors: string[];
|
||||
}: BaseRepoBranchPickerProps<{
|
||||
accessToken?: string;
|
||||
required?: boolean;
|
||||
}) => {
|
||||
}>) => {
|
||||
const { host, workspace, repository, branch } = state;
|
||||
|
||||
const [availableBranches, setAvailableBranches] = useState<string[]>([]);
|
||||
|
||||
+2
-7
@@ -20,7 +20,7 @@ import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
|
||||
import { RepoBranchPickerState } from './types';
|
||||
import { BaseRepoBranchPickerProps } from './types';
|
||||
|
||||
/**
|
||||
* The underlying component that is rendered in the form for the `DefaultRepoBranchPicker`
|
||||
@@ -34,12 +34,7 @@ export const DefaultRepoBranchPicker = ({
|
||||
state,
|
||||
rawErrors,
|
||||
required,
|
||||
}: {
|
||||
onChange: (state: RepoBranchPickerState) => void;
|
||||
state: RepoBranchPickerState;
|
||||
rawErrors: string[];
|
||||
required?: boolean;
|
||||
}) => {
|
||||
}: BaseRepoBranchPickerProps) => {
|
||||
const { branch } = state;
|
||||
|
||||
return (
|
||||
|
||||
@@ -20,3 +20,10 @@ export interface RepoBranchPickerState {
|
||||
repository?: string;
|
||||
branch?: string;
|
||||
}
|
||||
|
||||
export type BaseRepoBranchPickerProps<T extends {} = {}> = T & {
|
||||
onChange: (state: RepoBranchPickerState) => void;
|
||||
state: RepoBranchPickerState;
|
||||
rawErrors: string[];
|
||||
required?: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user