mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00

* feat(member-group): Team (#2616) * feat: member-group schema define * feat(fe): create group * feat: add group edit modal * feat(fe): add avatar group component * feat: edit group fix: permission select menu style * feat: bio-mode support for select-member component * fix: avatar group key unique * feat: group manage * feat: divide member into group and clbs * feat: finish team permission * chore: adjust * fix: get clbs * perf: groups code * pref: member group for team (#2706) * chore: fe adjust fix: remove the member from groups when removing from team feat: change the groups avatar when updating the team's avatar * chore: DefaultGroupName as a constant string '' * fix: create default group when create team for root * feat: comment * feat: 4811 init * pref: member group for team (#2732) * chore: default group name * feat: get default group when get by tmbid * feat(fe): adjust * member ui * fix: delete group (#2736) * perf: init4811 * pref: member group (#2818) * fix: update clb per then refetch clb list * fix: calculate group permission * feat(fe): group tag * refactor(fe): team and group manage * feat: manage group member * feat: add group transfer owner modal * feat: group manage member * chore: adjust the file structure * pref: member group * chore: adjust fe style * fix: ts error * chore: fe adjust * chore: fe adjust * chore: adjust * chore: adjust the code * perf: i18n and schema name * pref: member-group (#2862) * feat: group list ordered by updateTime * fix: transfer ownership of group when deleting member * fix: i18n fix * feat: can not set member as admin/owner when user is not active * fix: GroupInfoModal hover input do not change color * fix(fe): searchinput do not scroll * perf: team group ui * doc * remove enum --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
105 lines
2.7 KiB
TypeScript
105 lines
2.7 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
import { Box, Flex, Grid } from '@chakra-ui/react';
|
|
import type { FlexProps, GridProps } from '@chakra-ui/react';
|
|
import { useTranslation } from 'next-i18next';
|
|
import Avatar from '../Avatar';
|
|
|
|
type Props<ValueType = string> = Omit<GridProps, 'onChange'> & {
|
|
list: { icon?: string; label: string | React.ReactNode; value: ValueType }[];
|
|
value: ValueType;
|
|
size?: 'sm' | 'md' | 'lg';
|
|
inlineStyles?: FlexProps;
|
|
activeColor?: string;
|
|
defaultColor?: string;
|
|
onChange: (value: ValueType) => void;
|
|
};
|
|
|
|
const LightRowTabs = <ValueType = string,>({
|
|
list,
|
|
size = 'md',
|
|
value,
|
|
activeColor = 'primary.600',
|
|
defaultColor = 'transparent',
|
|
onChange,
|
|
inlineStyles,
|
|
...props
|
|
}: Props<ValueType>) => {
|
|
const { t } = useTranslation();
|
|
const sizeMap = useMemo(() => {
|
|
switch (size) {
|
|
case 'sm':
|
|
return {
|
|
fontSize: 'xs',
|
|
outP: '3px',
|
|
inlineP: 1
|
|
};
|
|
case 'md':
|
|
return {
|
|
fontSize: 'sm',
|
|
outP: '4px',
|
|
inlineP: 1
|
|
};
|
|
case 'lg':
|
|
return {
|
|
fontSize: ['sm', 'md'],
|
|
outP: '5px',
|
|
inlineP: 2
|
|
};
|
|
}
|
|
}, [size]);
|
|
|
|
return (
|
|
<Box overflow={'auto'}>
|
|
<Grid
|
|
gridTemplateColumns={`repeat(${list.length},1fr)`}
|
|
p={sizeMap.outP}
|
|
borderRadius={'sm'}
|
|
fontSize={sizeMap.fontSize}
|
|
userSelect={'none'}
|
|
display={'inline-grid'}
|
|
{...props}
|
|
>
|
|
{list.map((item) => (
|
|
<Flex
|
|
key={item.value as string}
|
|
py={sizeMap.inlineP}
|
|
alignItems={'center'}
|
|
justifyContent={'center'}
|
|
borderBottom={'2px solid'}
|
|
borderColor={defaultColor}
|
|
px={1}
|
|
whiteSpace={'nowrap'}
|
|
_hover={{
|
|
color: activeColor
|
|
}}
|
|
{...(value === item.value
|
|
? {
|
|
color: activeColor,
|
|
cursor: 'default',
|
|
fontWeight: 'bold',
|
|
borderBottomColor: activeColor
|
|
}
|
|
: {
|
|
cursor: 'pointer'
|
|
})}
|
|
onClick={() => {
|
|
if (value === item.value) return;
|
|
onChange(item.value);
|
|
}}
|
|
{...inlineStyles}
|
|
>
|
|
{item.icon && (
|
|
<>
|
|
<Avatar src={item.icon} alt={''} w={'1.25rem'} borderRadius={'sm'} mr={1} />
|
|
</>
|
|
)}
|
|
<Box>{typeof item.label === 'string' ? t(item.label as any) : item.label}</Box>
|
|
</Flex>
|
|
))}
|
|
</Grid>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default LightRowTabs;
|