Skip to content

Commit

Permalink
chore: adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
FinleyGe committed Sep 13, 2024
1 parent 50fc1d6 commit b1e4ea6
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TeamMemberSchema } from '@fastgpt/global/support/user/team/type';
import { PerResourceTypeEnum } from '@fastgpt/global/support/permission/constant';
import { MongoResourcePermission } from '../schema';
import { MongoMemberGroupModel } from './memberGroupSchema';
import { getMaxGroupPer } from '../controller';

export const getGroupsByTmbId = async (tmbId: string) => {
return (
Expand Down Expand Up @@ -75,13 +76,11 @@ export const getGroupPermission = async <T extends `${PerResourceTypeEnum}`>({
$in: groupIds
},
resourceType,
resourceId: resourceType === 'team' ? undefined : resourceId,
resourceId,
teamId
})
).map((item) => item.permission);
const maxPermission = groupPermissions.length > 0 ? Math.max(...groupPermissions) : undefined;

return maxPermission;
return getMaxGroupPer(groupPermissions);
};

/** Get all groups of a team */
Expand Down
2 changes: 1 addition & 1 deletion packages/service/support/user/team/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function getTeamMember(match: Record<string, any>): Promise<TeamTmbItemTyp
defaultTeam: tmb.defaultTeam,
lafAccount: tmb.teamId.lafAccount,
permission: new TeamPermission({
per: tmbPer?.permission || maxGroupPer || TeamDefaultPermissionVal,
per: tmbPer?.permission ?? maxGroupPer ?? TeamDefaultPermissionVal,
isOwner: tmb.role === TeamMemberRoleEnum.owner
}),
notificationAccount: tmb.teamId.notificationAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type MemberManagerInputPropsType = {
permission: Permission;
onGetCollaboratorList: () => Promise<CollaboratorItemType[]>;
permissionList: PermissionListType;
onUpdateCollaborators: (props: any) => any;
onUpdateCollaborators: (props: UpdateClbPermissionProps) => any; // TODO: type
onDelOneCollaborator: (tmbId: string) => any;
refreshDeps?: any[];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const TeamModalContextProvider = ({ children }: { children: ReactNode })
refresh: refetchGroups
} = useRequest2(() => getGroupList(), {
manual: false,
refreshDeps: [userInfo?._id]
refreshDeps: [userInfo?.team?.teamId]
});

const isLoading =
Expand Down
8 changes: 6 additions & 2 deletions projects/app/src/pages/app/detail/components/InfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
} from '@fastgpt/global/support/permission/app/constant';
import DefaultPermissionList from '@/components/support/permission/DefaultPerList';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { UpdateClbPermissionProps } from '@fastgpt/global/support/permission/collaborator';
import { resumeInheritPer } from '@/web/core/app/api';
import { useI18n } from '@/web/context/I18n';
import ResumeInherit from '@/components/support/permission/ResumeInheritText';
Expand Down Expand Up @@ -228,7 +227,12 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => {
permission={appDetail.permission}
onGetCollaboratorList={() => getCollaboratorList(appDetail._id)}
permissionList={AppPermissionList}
onUpdateCollaborators={onUpdateCollaborators}
onUpdateCollaborators={(props) =>
onUpdateCollaborators({
permission: props.permission,
members: props.members ?? [] // TODO: remove the default value after group is ready
})
}
onDelOneCollaborator={onDelCollaborator}
refreshDeps={[appDetail.inheritPermission]}
isInheritPermission={appDetail.inheritPermission}
Expand Down
6 changes: 3 additions & 3 deletions projects/app/src/pages/app/list/components/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ const ListItem = () => {
onGetCollaboratorList: () => getCollaboratorList(editPerApp._id),
permissionList: AppPermissionList,
onUpdateCollaborators: ({
tmbIds,
members = [], // TODO: remove the default value after group is ready
permission
}: {
tmbIds: string[];
members?: string[];
permission: number;
}) => {
return postUpdateAppCollaborators({
members: tmbIds,
members,
permission,
appId: editPerApp._id
});
Expand Down
6 changes: 3 additions & 3 deletions projects/app/src/pages/app/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ const MyApps = () => {
onGetCollaboratorList: () => getCollaboratorList(folderDetail._id),
permissionList: AppPermissionList,
onUpdateCollaborators: ({
tmbIds,
members = [], // TODO: remove the default value after group is ready
permission
}: {
tmbIds: string[];
members?: string[];
permission: number;
}) => {
return postUpdateAppCollaborators({
members: tmbIds,
members,
permission,
appId: folderDetail._id
});
Expand Down
6 changes: 3 additions & 3 deletions projects/app/src/pages/dataset/list/component/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,14 @@ function List() {
onGetCollaboratorList: () => getCollaboratorList(editPerDataset._id),
permissionList: DatasetPermissionList,
onUpdateCollaborators: ({
tmbIds,
members = [], // TODO: remove default value after group is ready
permission
}: {
tmbIds: string[];
members?: string[];
permission: number;
}) => {
return postUpdateDatasetCollaborators({
members: tmbIds,
members,
permission,
datasetId: editPerDataset._id
});
Expand Down
6 changes: 3 additions & 3 deletions projects/app/src/pages/dataset/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ const Dataset = () => {
onGetCollaboratorList: () => getCollaboratorList(folderDetail._id),
permissionList: DatasetPermissionList,
onUpdateCollaborators: ({
tmbIds,
members = [], // TODO: remove the default value after group is ready
permission
}: {
tmbIds: string[];
members?: string[];
permission: number;
}) => {
return postUpdateDatasetCollaborators({
members: tmbIds,
members,
permission,
datasetId: folderDetail._id
});
Expand Down

0 comments on commit b1e4ea6

Please sign in to comment.