mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 12:20:34 +00:00
pref: member/org/gourp list (#4295)
* refactor: org api * refactor: org api * pref: member/org/group list * feat: change group owner api * fix: manage org member * pref: member search
This commit is contained in:
@@ -19,9 +19,23 @@ type GroupMemberSchemaType = {
|
||||
type MemberGroupType = MemberGroupSchemaType & {
|
||||
members: {
|
||||
tmbId: string;
|
||||
role: `${GroupMemberRole}`;
|
||||
}[]; // we can get tmb's info from other api. there is no need but only need to get tmb's id
|
||||
permission: TeamPermission;
|
||||
name: string;
|
||||
avatar: string;
|
||||
}[];
|
||||
count: number;
|
||||
owner: {
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
};
|
||||
canEdit: boolean;
|
||||
};
|
||||
|
||||
type MemberGroupListType = MemberGroupType[];
|
||||
|
||||
type GroupMemberItemType = {
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
role: `${GroupMemberRole}`;
|
||||
};
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import type { TeamPermission } from 'support/permission/user/controller';
|
||||
import { ResourcePermissionType } from '../type';
|
||||
import { SourceMemberType } from 'support/user/type';
|
||||
|
||||
type OrgSchemaType = {
|
||||
_id: string;
|
||||
@@ -23,4 +24,5 @@ type OrgType = Omit<OrgSchemaType, 'avatar'> & {
|
||||
avatar: string;
|
||||
permission: TeamPermission;
|
||||
members: OrgMemberSchemaType[];
|
||||
total: number; // members + children orgs
|
||||
};
|
||||
|
1
packages/global/support/user/team/type.d.ts
vendored
1
packages/global/support/user/team/type.d.ts
vendored
@@ -82,6 +82,7 @@ export type TeamMemberItemType = {
|
||||
contact?: string;
|
||||
createTime: Date;
|
||||
updateTime?: Date;
|
||||
orgs?: string[]; // full path name, pattern: /teamName/orgname1/orgname2
|
||||
};
|
||||
|
||||
export type TeamTagItemType = {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { TeamCollectionName } from '@fastgpt/global/support/user/team/constant';
|
||||
import { connectionMongo, getMongoModel } from '../../../common/mongo';
|
||||
import { MemberGroupSchemaType } from '@fastgpt/global/support/permission/memberGroup/type';
|
||||
import { GroupMemberCollectionName } from './groupMemberSchema';
|
||||
const { Schema } = connectionMongo;
|
||||
|
||||
export const MemberGroupCollectionName = 'team_member_groups';
|
||||
|
@@ -90,6 +90,6 @@ export async function createRootOrg({
|
||||
path: ''
|
||||
}
|
||||
],
|
||||
{ session }
|
||||
{ session, ordered: true }
|
||||
);
|
||||
}
|
||||
|
@@ -10,7 +10,16 @@ import { Box, Flex } from '@chakra-ui/react';
|
||||
* @param [groupId] - group id to make the key unique
|
||||
* @returns
|
||||
*/
|
||||
function AvatarGroup({ avatars, max = 3 }: { max?: number; avatars: string[] }) {
|
||||
function AvatarGroup({
|
||||
avatars,
|
||||
max = 3,
|
||||
total
|
||||
}: {
|
||||
max?: number;
|
||||
avatars: string[];
|
||||
total?: number;
|
||||
}) {
|
||||
const remain = total ?? avatars.length - max;
|
||||
return (
|
||||
<Flex position="relative">
|
||||
{avatars.slice(0, max).map((avatar, index) => (
|
||||
@@ -24,10 +33,10 @@ function AvatarGroup({ avatars, max = 3 }: { max?: number; avatars: string[] })
|
||||
borderRadius={'50%'}
|
||||
/>
|
||||
))}
|
||||
{avatars.length > max && (
|
||||
{remain > 0 && (
|
||||
<Box
|
||||
position="relative"
|
||||
left={`${(max - 1) * 15}px`}
|
||||
left={`${(max - 1) * 15 + 15}px`}
|
||||
w={'24px'}
|
||||
h={'24px'}
|
||||
borderRadius="50%"
|
||||
@@ -37,7 +46,7 @@ function AvatarGroup({ avatars, max = 3 }: { max?: number; avatars: string[] })
|
||||
fontSize="sm"
|
||||
color="myGray.500"
|
||||
>
|
||||
+{avatars.length - max}
|
||||
+{String(remain)}
|
||||
</Box>
|
||||
)}
|
||||
</Flex>
|
||||
|
Reference in New Issue
Block a user