mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 02:12:38 +00:00
Team group (#2864)
* 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>
This commit is contained in:
64
projects/app/src/pages/api/admin/initv4811.ts
Normal file
64
projects/app/src/pages/api/admin/initv4811.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@fastgpt/service/common/response';
|
||||
import { connectToDatabase } from '@/service/mongo';
|
||||
import { authCert } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { MongoAppVersion } from '@fastgpt/service/core/app/version/schema';
|
||||
import { FastGPTProUrl } from '@fastgpt/service/common/system/constants';
|
||||
import { POST } from '@fastgpt/service/common/api/plusRequest';
|
||||
import { MongoTeam } from '@fastgpt/service/support/user/team/teamSchema';
|
||||
import { MongoMemberGroupModel } from '@fastgpt/service/support/permission/memberGroup/memberGroupSchema';
|
||||
import { delay } from '@fastgpt/global/common/system/utils';
|
||||
import { DefaultGroupName } from '@fastgpt/global/support/user/team/group/constant';
|
||||
|
||||
/*
|
||||
1. 给每个 team 创建一个默认的 group
|
||||
*/
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
await connectToDatabase();
|
||||
await authCert({ req, authRoot: true });
|
||||
|
||||
const teamList = await MongoTeam.find({}, '_id');
|
||||
console.log('Total team', teamList.length);
|
||||
let success = 0;
|
||||
|
||||
async function createGroup(teamId: string) {
|
||||
try {
|
||||
await MongoMemberGroupModel.updateOne(
|
||||
{
|
||||
teamId,
|
||||
name: DefaultGroupName
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
teamId: teamId,
|
||||
name: DefaultGroupName
|
||||
}
|
||||
},
|
||||
{
|
||||
upsert: true
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
await delay(500);
|
||||
return createGroup(teamId);
|
||||
}
|
||||
}
|
||||
for await (const team of teamList) {
|
||||
await createGroup(team._id);
|
||||
console.log(++success);
|
||||
}
|
||||
|
||||
jsonRes(res, {
|
||||
message: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
jsonRes(res, {
|
||||
code: 500,
|
||||
error
|
||||
});
|
||||
}
|
||||
}
|
@@ -7,8 +7,7 @@ import {
|
||||
Input,
|
||||
Textarea,
|
||||
ModalFooter,
|
||||
ModalBody,
|
||||
useDisclosure
|
||||
ModalBody
|
||||
} from '@chakra-ui/react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { AppSchema } from '@fastgpt/global/core/app/type.d';
|
||||
@@ -35,10 +34,10 @@ 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';
|
||||
import { PermissionValueType } from '@fastgpt/global/support/permission/type';
|
||||
|
||||
const InfoModal = ({ onClose }: { onClose: () => void }) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -61,7 +60,6 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => {
|
||||
defaultValues: appDetail
|
||||
});
|
||||
const avatar = getValues('avatar');
|
||||
const name = getValues('name');
|
||||
|
||||
// submit config
|
||||
const { runAsync: saveSubmitSuccess, loading: btnLoading } = useRequest2(
|
||||
@@ -129,31 +127,33 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => {
|
||||
[setValue, t, toast]
|
||||
);
|
||||
|
||||
const onUpdateCollaborators = async ({ tmbIds, permission }: UpdateClbPermissionProps) => {
|
||||
await postUpdateAppCollaborators({
|
||||
tmbIds,
|
||||
const onUpdateCollaborators = ({
|
||||
members,
|
||||
permission
|
||||
}: {
|
||||
members: string[];
|
||||
permission: PermissionValueType;
|
||||
}) => {
|
||||
return postUpdateAppCollaborators({
|
||||
members,
|
||||
permission,
|
||||
appId: appDetail._id
|
||||
});
|
||||
};
|
||||
|
||||
const onDelCollaborator = async (tmbId: string) => {
|
||||
await deleteAppCollaborators({
|
||||
const onDelCollaborator = (tmbId: string) => {
|
||||
return deleteAppCollaborators({
|
||||
appId: appDetail._id,
|
||||
tmbId
|
||||
});
|
||||
};
|
||||
|
||||
const { runAsync: resumeInheritPermission } = useRequest2(
|
||||
() => resumeInheritPer(appDetail._id),
|
||||
// () => putAppById(appDetail._id, { inheritPermission: true }),
|
||||
{
|
||||
errorToast: t('common:resume_failed'),
|
||||
onSuccess: () => {
|
||||
reloadApp();
|
||||
}
|
||||
const { runAsync: resumeInheritPermission } = useRequest2(() => resumeInheritPer(appDetail._id), {
|
||||
errorToast: t('common:resume_failed'),
|
||||
onSuccess: () => {
|
||||
reloadApp();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<MyModal
|
||||
@@ -223,7 +223,14 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => {
|
||||
permission={appDetail.permission}
|
||||
onGetCollaboratorList={() => getCollaboratorList(appDetail._id)}
|
||||
permissionList={AppPermissionList}
|
||||
onUpdateCollaborators={onUpdateCollaborators}
|
||||
onUpdateCollaborators={(props) => {
|
||||
if (props.members) {
|
||||
return onUpdateCollaborators({
|
||||
permission: props.permission,
|
||||
members: props.members
|
||||
});
|
||||
}
|
||||
}}
|
||||
onDelOneCollaborator={onDelCollaborator}
|
||||
refreshDeps={[appDetail.inheritPermission]}
|
||||
isInheritPermission={appDetail.inheritPermission}
|
||||
|
@@ -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({
|
||||
tmbIds,
|
||||
members,
|
||||
permission,
|
||||
appId: editPerApp._id
|
||||
});
|
||||
|
@@ -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({
|
||||
tmbIds,
|
||||
members,
|
||||
permission,
|
||||
appId: folderDetail._id
|
||||
});
|
||||
|
@@ -178,6 +178,7 @@ const TagManageModal = ({ onClose }: { onClose: () => void }) => {
|
||||
isOpen
|
||||
onClose={onClose}
|
||||
iconSrc="core/dataset/tag"
|
||||
iconColor={'primary.600'}
|
||||
title={t('dataset:tag.manage')}
|
||||
w={'580px'}
|
||||
h={'600px'}
|
||||
|
@@ -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({
|
||||
tmbIds,
|
||||
members,
|
||||
permission,
|
||||
datasetId: editPerDataset._id
|
||||
});
|
||||
|
@@ -1,14 +1,5 @@
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Flex,
|
||||
Image,
|
||||
Button,
|
||||
useDisclosure,
|
||||
InputGroup,
|
||||
InputLeftElement,
|
||||
Input
|
||||
} from '@chakra-ui/react';
|
||||
import { Box, Flex, Button, InputGroup, InputLeftElement, Input } from '@chakra-ui/react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { serviceSideProps } from '@/web/common/utils/i18n';
|
||||
@@ -249,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({
|
||||
tmbIds,
|
||||
members,
|
||||
permission,
|
||||
datasetId: folderDetail._id
|
||||
});
|
||||
|
Reference in New Issue
Block a user