diff --git a/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesDrawer.tsx b/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesDrawer.tsx index 19e58c8d9b4..70bc6ed890c 100644 --- a/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesDrawer.tsx +++ b/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesDrawer.tsx @@ -65,7 +65,8 @@ export const AddRepositoriesDrawer = ({ orgData: AddRepositoryData; }) => { const classes = useStyles(); - const { values } = useFormikContext(); + const { values, status, setStatus } = + useFormikContext(); const [searchString, setSearchString] = useState(''); const [selectedRepos, setSelectedRepos] = useState({}); @@ -75,6 +76,13 @@ export const AddRepositoriesDrawer = ({ const handleSelectRepoFromDrawer = (selected: AddedRepositories) => { onSelect(selected, orgData?.orgName || ''); + const newStatus = { ...(status?.errors || {}) }; + Object.keys(newStatus).forEach(s => { + if (!Object.keys(selected).find(sel => sel === s)) { + delete newStatus[s]; + } + }); + setStatus({ ...status, errors: newStatus }); onClose(); }; diff --git a/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesForm.tsx b/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesForm.tsx index 4e800601d70..fec7bb3c6ba 100644 --- a/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesForm.tsx +++ b/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesForm.tsx @@ -4,7 +4,12 @@ import { WarningPanel } from '@backstage/core-components'; import { makeStyles } from '@material-ui/core'; import FormControl from '@mui/material/FormControl'; +import { useFormikContext } from 'formik'; +import { useDrawer } from '@janus-idp/shared-react'; + +import { AddRepositoriesFormValues, PullRequestPreviewData } from '../../types'; +import { PreviewFileSidebar } from '../PreviewFile/PreviewFile'; // import HelpIcon from '@mui/icons-material/HelpOutline'; // import FormControlLabel from '@mui/material/FormControlLabel'; // import Radio from '@mui/material/Radio'; @@ -47,6 +52,23 @@ export const AddRepositoriesForm = ({ error: { message: string; title: string } | null; }) => { const styles = useStyles(); + const { openDrawer, setOpenDrawer, drawerData } = useDrawer(); + const { setFieldValue, values } = + useFormikContext(); + + const closeDrawer = () => { + setOpenDrawer(false); + }; + + const handleSave = (pullRequest: PullRequestPreviewData, _event: any) => { + Object.keys(pullRequest).forEach(pr => { + setFieldValue( + `repositories.${pr}.catalogInfoYaml.prTemplate`, + pullRequest[pr], + ); + }); + setOpenDrawer(false); + }; return ( <> @@ -99,6 +121,15 @@ export const AddRepositoriesForm = ({
+ {openDrawer && ( + + )} ); }; diff --git a/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesFormFooter.tsx b/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesFormFooter.tsx index dc2953b19ec..1d47d75a434 100644 --- a/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesFormFooter.tsx +++ b/plugins/bulk-import/src/components/AddRepositories/AddRepositoriesFormFooter.tsx @@ -2,8 +2,7 @@ import React from 'react'; import { Link } from '@backstage/core-components'; -import { makeStyles } from '@material-ui/core'; -import Button from '@mui/material/Button'; +import { Button, makeStyles } from '@material-ui/core'; import CircularProgress from '@mui/material/CircularProgress'; import Tooltip from '@mui/material/Tooltip'; import { useFormikContext } from 'formik'; @@ -36,7 +35,7 @@ const useStyles = makeStyles(theme => ({ paddingTop: '24px', paddingBottom: '24px', paddingLeft: '24px', - backgroundColor: theme.palette.background.paper, + backgroundColor: theme.palette.background.default, width: '100%', borderTopStyle: 'groove', border: theme.palette.divider, @@ -68,6 +67,7 @@ export const AddRepositoriesFormFooter = () => { const submitButton = (