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

fix[chat2db-client]: Fixed the problem of team collaboration button not displaying #1237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
38 changes: 15 additions & 23 deletions chat2db-client/src/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ const initNavConfig: INavItem[] = [
component: <Connection />,
name: i18n('connection.title'),
},
{
key: 'team',
icon: '\ue64b',
iconFontSize: 24,
isLoad: false,
component: <Team />,
name: i18n('team.title'),
},
{
key: 'github',
icon: '\ue885',
Expand Down Expand Up @@ -99,7 +107,6 @@ function MainPage() {
}, [mainPageActiveTab]);

useEffect(() => {
handleInitPage();
getConnectionList();
getConnectionEnvList();
}, []);
Expand All @@ -122,27 +129,6 @@ function MainPage() {
}
}, [activeNavKey]);

const handleInitPage = async () => {
const cloneNavConfig = [...navConfig];
if (userInfo) {
const hasTeamIcon = cloneNavConfig.find((i) => i.key === 'team');
if (userInfo.admin && !hasTeamIcon) {
cloneNavConfig.splice(3, 0, {
key: 'team',
icon: '\ue64b',
iconFontSize: 24,
isLoad: activeNavKey === 'team', // 如果当前是team,直接加载
component: <Team />,
name: i18n('team.title'),
});
}
if (!userInfo.admin && hasTeamIcon) {
cloneNavConfig.splice(3, 1);
}
}
setNavConfig([...cloneNavConfig]);
};

const switchingNav = (key: string) => {
if (key === 'github') {
window.open('https://github.com/chat2db/Chat2DB/', '_blank');
Expand Down Expand Up @@ -191,6 +177,12 @@ function MainPage() {
{(isMac === void 0) && <BrandLogo size={38} className={styles.brandLogo} />}
<ul className={styles.navList}>
{navConfig.map((item) => {
if (item.key === 'team') {
if (!userInfo || !userInfo.admin) {
return;
}
}

return (
<Tooltip key={item.key} placement="right" title={item.name}>
<li
Expand Down Expand Up @@ -225,4 +217,4 @@ function MainPage() {
);
}

export default MainPage;
export default MainPage;