chore: extract BaseRepoUrlPickerProps
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
@@ -19,16 +19,15 @@ import FormControl from '@material-ui/core/FormControl';
|
||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
import { BaseRepoUrlPickerProps } from './types';
|
||||
import { Select, SelectItem } from '@backstage/core-components';
|
||||
|
||||
export const AzureRepoPicker = (props: {
|
||||
allowedOrganizations?: string[];
|
||||
allowedProject?: string[];
|
||||
rawErrors: string[];
|
||||
state: RepoUrlPickerState;
|
||||
onChange: (state: RepoUrlPickerState) => void;
|
||||
}) => {
|
||||
export const AzureRepoPicker = (
|
||||
props: BaseRepoUrlPickerProps<{
|
||||
allowedOrganizations?: string[];
|
||||
allowedProject?: string[];
|
||||
}>,
|
||||
) => {
|
||||
const {
|
||||
allowedOrganizations = [],
|
||||
allowedProject = [],
|
||||
|
||||
@@ -17,7 +17,7 @@ import React, { useEffect, useState } from 'react';
|
||||
import FormControl from '@material-ui/core/FormControl';
|
||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import { Select, SelectItem } from '@backstage/core-components';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
import { BaseRepoUrlPickerProps } from './types';
|
||||
import Autocomplete from '@material-ui/lab/Autocomplete';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import useDebounce from 'react-use/esm/useDebounce';
|
||||
@@ -33,14 +33,13 @@ import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';
|
||||
* @param allowedProjects - Allowed projects for the Bitbucket cloud repository
|
||||
*
|
||||
*/
|
||||
export const BitbucketRepoPicker = (props: {
|
||||
allowedOwners?: string[];
|
||||
allowedProjects?: string[];
|
||||
onChange: (state: RepoUrlPickerState) => void;
|
||||
state: RepoUrlPickerState;
|
||||
rawErrors: string[];
|
||||
accessToken?: string;
|
||||
}) => {
|
||||
export const BitbucketRepoPicker = (
|
||||
props: BaseRepoUrlPickerProps<{
|
||||
allowedOwners?: string[];
|
||||
allowedProjects?: string[];
|
||||
accessToken?: string;
|
||||
}>,
|
||||
) => {
|
||||
const {
|
||||
allowedOwners = [],
|
||||
allowedProjects = [],
|
||||
|
||||
@@ -18,13 +18,9 @@ import FormControl from '@material-ui/core/FormControl';
|
||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
import { BaseRepoUrlPickerProps } from './types';
|
||||
|
||||
export const GerritRepoPicker = (props: {
|
||||
onChange: (state: RepoUrlPickerState) => void;
|
||||
state: RepoUrlPickerState;
|
||||
rawErrors: string[];
|
||||
}) => {
|
||||
export const GerritRepoPicker = (props: BaseRepoUrlPickerProps) => {
|
||||
const { onChange, rawErrors, state } = props;
|
||||
const { workspace, owner } = state;
|
||||
return (
|
||||
|
||||
@@ -19,15 +19,14 @@ import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
import { Select, SelectItem } from '@backstage/core-components';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
import { BaseRepoUrlPickerProps } from './types';
|
||||
|
||||
export const GiteaRepoPicker = (props: {
|
||||
allowedOwners?: string[];
|
||||
allowedRepos?: string[];
|
||||
state: RepoUrlPickerState;
|
||||
onChange: (state: RepoUrlPickerState) => void;
|
||||
rawErrors: string[];
|
||||
}) => {
|
||||
export const GiteaRepoPicker = (
|
||||
props: BaseRepoUrlPickerProps<{
|
||||
allowedOwners?: string[];
|
||||
allowedRepos?: string[];
|
||||
}>,
|
||||
) => {
|
||||
const { allowedOwners = [], state, onChange, rawErrors } = props;
|
||||
const ownerItems: SelectItem[] = allowedOwners
|
||||
? allowedOwners.map(i => ({ label: i, value: i }))
|
||||
|
||||
@@ -19,14 +19,13 @@ import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
import { Select, SelectItem } from '@backstage/core-components';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
import { BaseRepoUrlPickerProps } from './types';
|
||||
|
||||
export const GithubRepoPicker = (props: {
|
||||
allowedOwners?: string[];
|
||||
rawErrors: string[];
|
||||
state: RepoUrlPickerState;
|
||||
onChange: (state: RepoUrlPickerState) => void;
|
||||
}) => {
|
||||
export const GithubRepoPicker = (
|
||||
props: BaseRepoUrlPickerProps<{
|
||||
allowedOwners?: string[];
|
||||
}>,
|
||||
) => {
|
||||
const { allowedOwners = [], rawErrors, state, onChange } = props;
|
||||
const ownerItems: SelectItem[] = allowedOwners
|
||||
? allowedOwners.map(i => ({ label: i, value: i }))
|
||||
|
||||
@@ -19,15 +19,14 @@ import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import InputLabel from '@material-ui/core/InputLabel';
|
||||
import { Select, SelectItem } from '@backstage/core-components';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
import { BaseRepoUrlPickerProps } from './types';
|
||||
|
||||
export const GitlabRepoPicker = (props: {
|
||||
allowedOwners?: string[];
|
||||
allowedRepos?: string[];
|
||||
state: RepoUrlPickerState;
|
||||
onChange: (state: RepoUrlPickerState) => void;
|
||||
rawErrors: string[];
|
||||
}) => {
|
||||
export const GitlabRepoPicker = (
|
||||
props: BaseRepoUrlPickerProps<{
|
||||
allowedOwners?: string[];
|
||||
allowedRepos?: string[];
|
||||
}>,
|
||||
) => {
|
||||
const { allowedOwners = [], state, onChange, rawErrors } = props;
|
||||
const ownerItems: SelectItem[] = allowedOwners
|
||||
? allowedOwners.map(i => ({ label: i, value: i }))
|
||||
|
||||
@@ -22,3 +22,9 @@ export interface RepoUrlPickerState {
|
||||
project?: string;
|
||||
availableRepos?: string[];
|
||||
}
|
||||
|
||||
export type BaseRepoUrlPickerProps<T extends {} = {}> = T & {
|
||||
onChange: (state: RepoUrlPickerState) => void;
|
||||
state: RepoUrlPickerState;
|
||||
rawErrors: string[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user