mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
wip: Move Add Model from Modal to new Panel
This commit is contained in:
parent
de7b059e67
commit
2f8f558df3
@ -1,10 +1,55 @@
|
|||||||
import { Flex } from '@chakra-ui/react';
|
import { Divider, Flex } from '@chakra-ui/react';
|
||||||
import AddModel from 'features/ui/components/tabs/ModelManager/subpanels/AddModelsPanel/AddModel';
|
import { RootState } from 'app/store/store';
|
||||||
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
|
import IAIButton from 'common/components/IAIButton';
|
||||||
|
import { setAddNewModelUIOption } from 'features/ui/store/uiSlice';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import AddCheckpointModel from './AddModelsPanel/AddCheckpointModel';
|
||||||
|
import AddDiffusersModel from './AddModelsPanel/AddDiffusersModel';
|
||||||
|
|
||||||
export default function AddModelsPanel() {
|
export default function AddModelsPanel() {
|
||||||
|
const addNewModelUIOption = useAppSelector(
|
||||||
|
(state: RootState) => state.ui.addNewModelUIOption
|
||||||
|
);
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex>
|
<Flex flexDirection="column" gap={4}>
|
||||||
<AddModel />
|
<Flex columnGap={4}>
|
||||||
|
<IAIButton
|
||||||
|
onClick={() => dispatch(setAddNewModelUIOption('ckpt'))}
|
||||||
|
sx={{
|
||||||
|
backgroundColor:
|
||||||
|
addNewModelUIOption == 'ckpt' ? 'accent.700' : 'base.700',
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor:
|
||||||
|
addNewModelUIOption == 'ckpt' ? 'accent.700' : 'base.600',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('modelManager.addCheckpointModel')}
|
||||||
|
</IAIButton>
|
||||||
|
<IAIButton
|
||||||
|
onClick={() => dispatch(setAddNewModelUIOption('diffusers'))}
|
||||||
|
sx={{
|
||||||
|
backgroundColor:
|
||||||
|
addNewModelUIOption == 'diffusers' ? 'accent.700' : 'base.700',
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor:
|
||||||
|
addNewModelUIOption == 'diffusers' ? 'accent.700' : 'base.600',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('modelManager.addDiffuserModel')}
|
||||||
|
</IAIButton>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
{addNewModelUIOption == 'ckpt' && <AddCheckpointModel />}
|
||||||
|
{addNewModelUIOption == 'diffusers' && <AddDiffusersModel />}
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ export default function AddDiffusersModel() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex>
|
<Flex overflow="scroll" maxHeight={window.innerHeight - 270}>
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={addModelFormValues}
|
initialValues={addModelFormValues}
|
||||||
onSubmit={addModelFormSubmitHandler}
|
onSubmit={addModelFormSubmitHandler}
|
||||||
|
@ -1,125 +0,0 @@
|
|||||||
import {
|
|
||||||
Button,
|
|
||||||
Flex,
|
|
||||||
Modal,
|
|
||||||
ModalBody,
|
|
||||||
ModalCloseButton,
|
|
||||||
ModalContent,
|
|
||||||
ModalFooter,
|
|
||||||
ModalHeader,
|
|
||||||
ModalOverlay,
|
|
||||||
Text,
|
|
||||||
useDisclosure,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
|
|
||||||
import IAIButton from 'common/components/IAIButton';
|
|
||||||
|
|
||||||
import { FaArrowLeft, FaPlus } from 'react-icons/fa';
|
|
||||||
|
|
||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import type { RootState } from 'app/store/store';
|
|
||||||
import { setAddNewModelUIOption } from 'features/ui/store/uiSlice';
|
|
||||||
import AddCheckpointModel from './AddCheckpointModel';
|
|
||||||
import AddDiffusersModel from './AddDiffusersModel';
|
|
||||||
import IAIIconButton from 'common/components/IAIIconButton';
|
|
||||||
|
|
||||||
function AddModelBox({
|
|
||||||
text,
|
|
||||||
onClick,
|
|
||||||
}: {
|
|
||||||
text: string;
|
|
||||||
onClick?: () => void;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<Flex
|
|
||||||
position="relative"
|
|
||||||
width="50%"
|
|
||||||
height={40}
|
|
||||||
justifyContent="center"
|
|
||||||
alignItems="center"
|
|
||||||
onClick={onClick}
|
|
||||||
as={Button}
|
|
||||||
>
|
|
||||||
<Text fontWeight="bold">{text}</Text>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AddModel() {
|
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
||||||
|
|
||||||
const addNewModelUIOption = useAppSelector(
|
|
||||||
(state: RootState) => state.ui.addNewModelUIOption
|
|
||||||
);
|
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
|
||||||
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const addModelModalClose = () => {
|
|
||||||
onClose();
|
|
||||||
dispatch(setAddNewModelUIOption(null));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<IAIButton
|
|
||||||
aria-label={t('modelManager.addNewModel')}
|
|
||||||
tooltip={t('modelManager.addNewModel')}
|
|
||||||
onClick={onOpen}
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
<Flex columnGap={2} alignItems="center">
|
|
||||||
<FaPlus />
|
|
||||||
{t('modelManager.addNew')}
|
|
||||||
</Flex>
|
|
||||||
</IAIButton>
|
|
||||||
|
|
||||||
<Modal
|
|
||||||
isOpen={isOpen}
|
|
||||||
onClose={addModelModalClose}
|
|
||||||
size="3xl"
|
|
||||||
closeOnOverlayClick={false}
|
|
||||||
>
|
|
||||||
<ModalOverlay />
|
|
||||||
<ModalContent margin="auto">
|
|
||||||
<ModalHeader>{t('modelManager.addNewModel')} </ModalHeader>
|
|
||||||
{addNewModelUIOption !== null && (
|
|
||||||
<IAIIconButton
|
|
||||||
aria-label={t('common.back')}
|
|
||||||
tooltip={t('common.back')}
|
|
||||||
onClick={() => dispatch(setAddNewModelUIOption(null))}
|
|
||||||
position="absolute"
|
|
||||||
variant="ghost"
|
|
||||||
zIndex={1}
|
|
||||||
size="sm"
|
|
||||||
insetInlineEnd={12}
|
|
||||||
top={2}
|
|
||||||
icon={<FaArrowLeft />}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<ModalCloseButton />
|
|
||||||
<ModalBody>
|
|
||||||
{addNewModelUIOption == null && (
|
|
||||||
<Flex columnGap={4}>
|
|
||||||
<AddModelBox
|
|
||||||
text={t('modelManager.addCheckpointModel')}
|
|
||||||
onClick={() => dispatch(setAddNewModelUIOption('ckpt'))}
|
|
||||||
/>
|
|
||||||
<AddModelBox
|
|
||||||
text={t('modelManager.addDiffuserModel')}
|
|
||||||
onClick={() => dispatch(setAddNewModelUIOption('diffusers'))}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
{addNewModelUIOption == 'ckpt' && <AddCheckpointModel />}
|
|
||||||
{addNewModelUIOption == 'diffusers' && <AddDiffusersModel />}
|
|
||||||
</ModalBody>
|
|
||||||
<ModalFooter />
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user