Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Team org ui #3499

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docSite/content/zh-cn/docs/development/upgrading/4818.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: 'V4.8.18(进行中)'
description: 'FastGPT V4.8.18 更新说明'
icon: 'upgrade'
draft: false
toc: true
weight: 806
---

## 完整更新内容

1.
2. 新增 - 支持组织架构权限模式
10 changes: 2 additions & 8 deletions packages/global/support/user/team/org/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@ export type putUpdateOrgData = {
description?: string;
};

export type putMoveOrgData = {
export type putMoveOrgType = {
orgId: string;
parentId: string;
};

export type putMoveOrgMemberData = {
orgId: string;
tmbId: string;
newOrgId: string;
targetOrgId: string;
};

// type putChnageOrgOwnerData = {
Expand Down
1 change: 1 addition & 0 deletions packages/global/support/user/team/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type TeamMemberWithTeamAndUserSchema = TeamMemberSchema & {
export type TeamTmbItemType = {
userId: string;
teamId: string;
teamAvatar?: string;
teamName: string;
memberName: string;
avatar: string;
Expand Down
39 changes: 12 additions & 27 deletions packages/service/support/permission/auth/org.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { TeamPermission } from '@fastgpt/global/support/permission/user/controller';
import { AuthModeType, AuthResponseType } from '../type';
import { parseHeaderCert } from '../controller';
import { getTmbInfoByTmbId } from '../../user/team/controller';
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
import { authUserPer } from '../user/auth';
import { ManagePermissionVal } from '@fastgpt/global/support/permission/constant';

/*
Team manager can control org
*/
export const authOrgMember = async ({
orgIds,
req,
authToken = false,
authRoot = false,
authApiKey = false
...props
}: {
orgIds: string | string[];
} & AuthModeType): Promise<AuthResponseType> => {
const result = await parseHeaderCert({ req, authToken, authApiKey, authRoot });
const { teamId, tmbId, isRoot } = result;
const result = await authUserPer({
...props,
per: ManagePermissionVal
});
const { teamId, tmbId, isRoot, tmb } = result;

if (isRoot) {
return {
teamId,
Expand All @@ -28,13 +32,6 @@ export const authOrgMember = async ({
};
}

if (!Array.isArray(orgIds)) {
orgIds = [orgIds];
}

// const promises = orgIds.map((orgId) => getOrgMemberRole({ orgId, tmbId }));

const tmb = await getTmbInfoByTmbId({ tmbId });
if (tmb.permission.hasManagePer) {
return {
...result,
Expand All @@ -43,16 +40,4 @@ export const authOrgMember = async ({
}

return Promise.reject(TeamErrEnum.unAuthTeam);

// const targetRole = OrgMemberRole[role];
// for (const orgRole of orgRoles) {
// if (!orgRole || checkOrgRole(orgRole, targetRole)) {
// return Promise.reject(TeamErrEnum.unAuthTeam);
// }
// }

// return {
// ...result,
// permission: tmb.permission
// };
};
15 changes: 1 addition & 14 deletions packages/service/support/permission/org/controllers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
import type {
OrgMemberSchemaType,
OrgSchemaType
} from '@fastgpt/global/support/user/team/org/type';
import type { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
import type { ClientSession } from 'mongoose';
import { MongoOrgModel } from './orgSchema';
import { MongoOrgMemberModel } from './orgMemberSchema';
Expand Down Expand Up @@ -36,16 +33,6 @@ import { MongoOrgMemberModel } from './orgMemberSchema';
// return compareRole(role, targetRole) >= 0;
// };

export const getOrgsByTeamId = async (teamId: string) => {
const orgs = await MongoOrgModel.find({
teamId
})
.populate<{ members: OrgMemberSchemaType }>('members')
.lean();

return orgs;
};

export const getOrgsByTmbId = async ({ teamId, tmbId }: { teamId: string; tmbId: string }) =>
MongoOrgMemberModel.find({ teamId, tmbId }, 'orgId').lean();

Expand Down
13 changes: 4 additions & 9 deletions packages/service/support/permission/org/orgSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,10 @@ OrgSchema.virtual('permission', {
});

try {
OrgSchema.index(
{
teamId: 1,
path: 1
},
{
unique: true
}
);
OrgSchema.index({
teamId: 1,
path: 1
});
} catch (error) {
console.log(error);
}
Expand Down
1 change: 1 addition & 0 deletions packages/service/support/user/team/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async function getTeamMember(match: Record<string, any>): Promise<TeamTmbItemTyp
return {
userId: String(tmb.userId),
teamId: String(tmb.teamId),
teamAvatar: tmb.team.avatar,
teamName: tmb.team.name,
memberName: tmb.name,
avatar: tmb.team.avatar,
Expand Down
16 changes: 16 additions & 0 deletions projects/app/public/js/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ function embedChatbot() {

document.body.appendChild(iframe);

const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes' && mutation.attributeName === 'data-bot-src') {
const newBotSrc = script.getAttribute('data-bot-src');
if (newBotSrc) {
iframe.src = newBotSrc;
}
}
});
});
observer.observe(script, {
attributes: true,
attributeFilter: ['data-bot-src']
});

let chatBtnDragged = false;
let chatBtnDown = false;
let chatBtnMouseX;
Expand Down Expand Up @@ -96,3 +111,4 @@ function embedChatbot() {
document.body.appendChild(ChatBtn);
}
window.addEventListener('load', embedChatbot);

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import MemberTag from '../../../../../components/support/user/team/Info/MemberTa
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import dynamic from 'next/dynamic';
import { useState } from 'react';
import IconButton from '../OrgManage/IconButton';

const ChangeOwnerModal = dynamic(() => import('./GroupTransferOwnerModal'));

Expand Down Expand Up @@ -157,7 +158,7 @@ function MemberTable({
<Td>
{hasGroupManagePer(group) && group.name !== DefaultGroupName && (
<MyMenu
Button={<MyIcon name={'edit'} cursor={'pointer'} w="1rem" />}
Button={<IconButton name={'more'} />}
menuList={[
{
children: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { IconProps } from '@chakra-ui/react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import type { IconNameType } from '@fastgpt/web/components/common/Icon/type';

function IconButton({ name, onClick }: { name: IconNameType; onClick: () => void }) {
function IconButton({
name,
w = '1rem',
h = '1rem',
...props
}: {
name: IconNameType;
} & IconProps) {
return (
<MyIcon
name={name}
w={'1rem'}
h={'1rem'}
w={w}
h={h}
transition={'background 0.1s'}
cursor={'pointer'}
p="1"
Expand All @@ -15,7 +23,7 @@ function IconButton({ name, onClick }: { name: IconNameType; onClick: () => void
bg: 'myGray.05',
color: 'primary.600'
}}
onClick={onClick}
{...props}
/>
);
}
Expand Down
Loading
Loading