Skip to content

Commit

Permalink
feat: org management
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Info committed Dec 24, 2024
1 parent 4ce76d6 commit edd233a
Show file tree
Hide file tree
Showing 14 changed files with 571 additions and 152 deletions.
2 changes: 2 additions & 0 deletions packages/global/common/error/code/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export enum TeamErrEnum {
orgMemberNotExist = 'orgMemberNotExist',
orgMemberExist = 'orgMemberExist',
orgNotExist = 'orgNotExist',
orgMoveSameParent = 'orgMoveSameParent',
orgMoveToChildren = 'orgMoveToChildren',
orgParentNotExist = 'orgParentNotExist',
deletingOrgWithChildren = 'deletingOrgWithChildren',
deletingRootOrg = 'deletingRootOrg',
Expand Down
1 change: 0 additions & 1 deletion packages/global/support/user/team/org/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type postCreateOrgData = {
parentId: string;
description?: string;
avatar?: string;
ownerTmbId?: string;
};

type putUpdateOrgMembersData = {
Expand Down
4 changes: 2 additions & 2 deletions packages/global/support/user/team/org/type.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OrgMemberRole } from './constant';
import type { TeamPermission } from 'support/permission/user/controller';
import { ResourcePermissionType } from '../type';
import { TeamPermission } from 'support/permission/user/controller';
import type { OrgMemberRole } from './constant';

type OrgSchemaType = {
_id: string;
Expand Down
19 changes: 10 additions & 9 deletions packages/service/support/permission/org/controllers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { MongoOrgMemberModel } from './orgMemberSchema';
import { MongoOrgModel } from './orgSchema';
import { OrgMemberRole } from '@fastgpt/global/support/user/team/org/constant';
import type { AuthModeType, AuthResponseType } from '../type';
import { parseHeaderCert } from '../controller';
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
import { TeamPermission } from '@fastgpt/global/support/permission/user/controller';
import { getTmbInfoByTmbId } from '../../user/team/controller';
import { OrgMemberRole } from '@fastgpt/global/support/user/team/org/constant';
import type { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
import type { ClientSession } from 'mongoose';
import { getTmbInfoByTmbId } from '../../user/team/controller';
import { parseHeaderCert } from '../controller';
import type { AuthModeType, AuthResponseType } from '../type';
import { MongoOrgMemberModel } from './orgMemberSchema';
import { MongoOrgModel } from './orgSchema';

// if role1 > role2, return 1
// if role1 < role2, return -1
Expand Down Expand Up @@ -90,7 +90,7 @@ export const getOrgMemberRole = async ({
} else {
return role;
}
if (role == OrgMemberRole.owner) {
if (role === OrgMemberRole.owner) {
return role;
}
// Check the parent orgs
Expand All @@ -114,7 +114,8 @@ export const getOrgMemberRole = async ({
if (parentRole === OrgMemberRole.owner) {
role = parentRole;
break;
} else if (parentRole === OrgMemberRole.admin && role === OrgMemberRole.member) {
}
if (parentRole === OrgMemberRole.admin && role === OrgMemberRole.member) {
role = parentRole;
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/service/support/permission/org/orgSchema.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { TeamCollectionName } from '@fastgpt/global/support/user/team/constant';
import { OrgCollectionName } from '@fastgpt/global/support/user/team/org/constant';
import type { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
import { connectionMongo, getMongoModel } from '../../../common/mongo';
import { OrgMemberCollectionName } from './orgMemberSchema';
import { ResourcePermissionCollectionName } from '../schema';
import { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
import { OrgCollectionName } from '@fastgpt/global/support/user/team/org/constant';
import { OrgMemberCollectionName } from './orgMemberSchema';
const { Schema } = connectionMongo;

function requiredStringPath(this: OrgSchemaType) {
return typeof this.path === 'string' ? false : true;
return typeof this.path !== 'string';
}

export const OrgSchema = new Schema(
Expand Down
2 changes: 2 additions & 0 deletions packages/web/i18n/en/account_team.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"confirm_delete_group": "Confirm to delete group?",
"confirm_leave_team": "Confirmed to leave the team? \n \nAfter you log out, all your resources in the team (applications, knowledge bases, folders, managed groups, etc.) will be transferred to the team owner.",
"confirm_delete_org": "Confirm to delete organization?",
"confirm_delete_member": "Confirm to delete member?",
"create_group": "Create group",
"delete": "delete",
"edit_info": "Edit information",
Expand All @@ -15,6 +16,7 @@
"create_sub_org": "Create sub-organization",
"edit_org_info": "Edit organization information",
"move_org": "Move organization",
"move_member": "Move member",
"delete_org": "Delete organization",
"remark": "remark",
"label_sync": "Tag sync",
Expand Down
2 changes: 2 additions & 0 deletions packages/web/i18n/zh-CN/account_team.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"create_sub_org": "创建子组织",
"edit_org_info": "编辑组织信息",
"move_org": "移动组织",
"move_member": "移动成员",
"delete_org": "删除组织",
"confirm_delete_org": "确认删除组织?",
"confirm_delete_member": "确认删除成员?",

"transfer_ownership": "转让所有者",
"delete": "删除",
Expand Down
2 changes: 2 additions & 0 deletions packages/web/i18n/zh-Hant/account_team.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"confirm_delete_group": "確認刪除群組?",
"confirm_leave_team": "確認離開該團隊? \n \n退出後,您在該團隊所有的資源( 應用程式、知識庫、資料夾、管理的群組等)均轉讓給團隊所有者。",
"confirm_delete_org": "確認刪除組織?",
"confirm_delete_member": "確認刪除成員?",
"create_group": "建立群組",
"delete": "刪除",
"edit_info": "編輯訊息",
Expand All @@ -15,6 +16,7 @@
"create_sub_org": "建立子組織",
"edit_org_info": "編輯組織訊息",
"move_org": "移動組織",
"move_member": "移動成員",
"delete_org": "刪除組織",
"remark": "備註",
"label_sync": "標籤同步",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function OrgInfoModal({
setValue('name', editOrg?.name ?? '');
setValue('avatar', editOrg?.avatar);
setValue('description', editOrg?.description);
console.log(editOrg);
}, [editOrg, setValue]);

const { run: onCreate, loading: isLoadingCreate } = useRequest2(
Expand Down
Loading

0 comments on commit edd233a

Please sign in to comment.