Skip to content

Commit db7510c

Browse files
FinleyGec121914yu
authored andcommitted
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
1 parent b87cc35 commit db7510c

File tree

21 files changed

+413
-364
lines changed

21 files changed

+413
-364
lines changed

packages/global/support/permission/memberGroup/type.d.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,23 @@ type GroupMemberSchemaType = {
1919
type MemberGroupType = MemberGroupSchemaType & {
2020
members: {
2121
tmbId: string;
22-
role: `${GroupMemberRole}`;
23-
}[]; // we can get tmb's info from other api. there is no need but only need to get tmb's id
24-
permission: TeamPermission;
22+
name: string;
23+
avatar: string;
24+
}[];
25+
count: number;
26+
owner: {
27+
tmbId: string;
28+
name: string;
29+
avatar: string;
30+
};
31+
canEdit: boolean;
2532
};
2633

2734
type MemberGroupListType = MemberGroupType[];
35+
36+
type GroupMemberItemType = {
37+
tmbId: string;
38+
name: string;
39+
avatar: string;
40+
role: `${GroupMemberRole}`;
41+
};

packages/global/support/user/team/org/type.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { TeamPermission } from 'support/permission/user/controller';
22
import { ResourcePermissionType } from '../type';
3+
import { SourceMemberType } from 'support/user/type';
34

45
type OrgSchemaType = {
56
_id: string;
@@ -23,4 +24,5 @@ type OrgType = Omit<OrgSchemaType, 'avatar'> & {
2324
avatar: string;
2425
permission: TeamPermission;
2526
members: OrgMemberSchemaType[];
27+
total: number; // members + children orgs
2628
};

packages/global/support/user/team/type.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export type TeamMemberItemType = {
8282
contact?: string;
8383
createTime: Date;
8484
updateTime?: Date;
85+
orgs?: string[]; // full path name, pattern: /teamName/orgname1/orgname2
8586
};
8687

8788
export type TeamTagItemType = {

packages/service/support/permission/memberGroup/memberGroupSchema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { TeamCollectionName } from '@fastgpt/global/support/user/team/constant';
22
import { connectionMongo, getMongoModel } from '../../../common/mongo';
33
import { MemberGroupSchemaType } from '@fastgpt/global/support/permission/memberGroup/type';
4+
import { GroupMemberCollectionName } from './groupMemberSchema';
45
const { Schema } = connectionMongo;
56

67
export const MemberGroupCollectionName = 'team_member_groups';

packages/service/support/permission/org/controllers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ export async function createRootOrg({
9090
path: ''
9191
}
9292
],
93-
{ session }
93+
{ session, ordered: true }
9494
);
9595
}

packages/web/components/common/Avatar/AvatarGroup.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ import { Box, Flex } from '@chakra-ui/react';
1010
* @param [groupId] - group id to make the key unique
1111
* @returns
1212
*/
13-
function AvatarGroup({ avatars, max = 3 }: { max?: number; avatars: string[] }) {
13+
function AvatarGroup({
14+
avatars,
15+
max = 3,
16+
total
17+
}: {
18+
max?: number;
19+
avatars: string[];
20+
total?: number;
21+
}) {
22+
const remain = total ?? avatars.length - max;
1423
return (
1524
<Flex position="relative">
1625
{avatars.slice(0, max).map((avatar, index) => (
@@ -24,10 +33,10 @@ function AvatarGroup({ avatars, max = 3 }: { max?: number; avatars: string[] })
2433
borderRadius={'50%'}
2534
/>
2635
))}
27-
{avatars.length > max && (
36+
{remain > 0 && (
2837
<Box
2938
position="relative"
30-
left={`${(max - 1) * 15}px`}
39+
left={`${(max - 1) * 15 + 15}px`}
3140
w={'24px'}
3241
h={'24px'}
3342
borderRadius="50%"
@@ -37,7 +46,7 @@ function AvatarGroup({ avatars, max = 3 }: { max?: number; avatars: string[] })
3746
fontSize="sm"
3847
color="myGray.500"
3948
>
40-
+{avatars.length - max}
49+
+{String(remain)}
4150
</Box>
4251
)}
4352
</Flex>

0 commit comments

Comments
 (0)