v4.6.2-alpah (#511)

This commit is contained in:
Archer
2023-11-24 15:29:43 +08:00
committed by GitHub
parent 60f752629f
commit 9cb4280a16
208 changed files with 5396 additions and 3500 deletions

View File

@@ -104,98 +104,99 @@ const SelectCollections = ({
w={'100%'}
h={['90vh', '80vh']}
isCentered
iconSrc="/imgs/modal/move.svg"
title={
<Box>
<ParentPaths
paths={paths.map((path, i) => ({
parentId: path.parentId,
parentName: path.parentName
}))}
FirstPathDom={
<>
<Box fontWeight={'bold'} fontSize={['sm', 'lg']}>
{title || type === 'folder'
? t('common.Select One Folder')
: t('dataset.collections.Select Collection')}
</Box>
{!!tip && (
<Box fontSize={'sm'} color={'myGray.500'}>
{tip}
</Box>
)}
</>
}
onClick={(e) => {
setParentId(e);
}}
/>
</Box>
}
>
<Flex flexDirection={'column'} flex={'1 0 0'}>
<Box flex={'1 0 0'} px={4} py={2}>
<Flex flexDirection={'column'} h={'100%'} position={'relative'}>
<Box>
<ParentPaths
paths={paths.map((path, i) => ({
parentId: path.parentId,
parentName: path.parentName
}))}
FirstPathDom={
<>
<Box fontWeight={'bold'} fontSize={['sm', 'lg']}>
{title || type === 'folder'
? t('common.Select One Folder')
: t('dataset.collections.Select Collection')}
</Box>
{!!tip && (
<Box fontSize={'sm'} color={'myGray.500'}>
{tip}
<Box flex={'1 0 0'} px={4} py={2} position={'relative'}>
<Grid
gridTemplateColumns={['repeat(1,1fr)', 'repeat(2,1fr)', 'repeat(3,1fr)']}
gridGap={3}
userSelect={'none'}
overflowY={'auto'}
mt={2}
>
{collections.map((item) =>
(() => {
const selected = selectedDatasetCollectionIds.includes(item._id);
return (
<Card
key={item._id}
p={3}
border={theme.borders.base}
boxShadow={'sm'}
cursor={'pointer'}
_hover={{
boxShadow: 'md'
}}
{...(selected
? {
bg: 'myBlue.300'
}
: {})}
onClick={() => {
if (item.type === DatasetCollectionTypeEnum.folder) {
setParentId(item._id);
} else {
let result: string[] = [];
if (max === 1) {
result = [item._id];
} else if (selected) {
result = selectedDatasetCollectionIds.filter((id) => id !== item._id);
} else if (selectedDatasetCollectionIds.length < max) {
result = [...selectedDatasetCollectionIds, item._id];
}
setSelectedDatasetCollectionIds(result);
onChange && onChange({ parentId, collectionIds: result });
}
}}
>
<Flex alignItems={'center'} h={'38px'}>
<Image src={item.icon} w={'18px'} alt={''} />
<Box ml={3} fontSize={'sm'}>
{item.name}
</Box>
)}
</>
}
onClick={(e) => {
setParentId(e);
}}
/>
</Box>
<Box flex={'1 0 0'} overflowY={'auto'} mt={2}>
<Grid
gridTemplateColumns={['repeat(1,1fr)', 'repeat(2,1fr)', 'repeat(3,1fr)']}
gridGap={3}
userSelect={'none'}
>
{collections.map((item) =>
(() => {
const selected = selectedDatasetCollectionIds.includes(item._id);
return (
<Card
key={item._id}
p={3}
border={theme.borders.base}
boxShadow={'sm'}
cursor={'pointer'}
_hover={{
boxShadow: 'md'
}}
{...(selected
? {
bg: 'myBlue.300'
}
: {})}
onClick={() => {
if (item.type === DatasetCollectionTypeEnum.folder) {
setParentId(item._id);
} else {
let result: string[] = [];
if (max === 1) {
result = [item._id];
} else if (selected) {
result = selectedDatasetCollectionIds.filter((id) => id !== item._id);
} else if (selectedDatasetCollectionIds.length < max) {
result = [...selectedDatasetCollectionIds, item._id];
}
setSelectedDatasetCollectionIds(result);
onChange && onChange({ parentId, collectionIds: result });
}
}}
>
<Flex alignItems={'center'} h={'38px'}>
<Image src={item.icon} w={'18px'} alt={''} />
<Box ml={3} fontSize={'sm'}>
{item.name}
</Box>
</Flex>
</Card>
);
})()
)}
</Grid>
{collections.length === 0 && (
<Flex mt={'10vh'} flexDirection={'column'} alignItems={'center'}>
<MyIcon name="empty" w={'48px'} h={'48px'} color={'transparent'} />
<Box mt={2} color={'myGray.500'}>
{t('common.folder.No Folder')}
</Box>
</Flex>
)}
</Box>
<Loading loading={isLoading} fixed={false} />
</Flex>
</Flex>
</Card>
);
})()
)}
</Grid>
{collections.length === 0 && (
<Flex mt={'20vh'} flexDirection={'column'} alignItems={'center'}>
<MyIcon name="empty" w={'48px'} h={'48px'} color={'transparent'} />
<Box mt={2} color={'myGray.500'}>
{t('common.folder.No Folder')}
</Box>
</Flex>
)}
<Loading loading={isLoading} fixed={false} />
</Box>
{CustomFooter ? (
<>{CustomFooter}</>