Skip to content

Commit 7a69d65

Browse files
fix: fixed profile dropdown warnning
1 parent e8ca478 commit 7a69d65

File tree

2 files changed

+67
-47
lines changed

2 files changed

+67
-47
lines changed

client/packages/lowcoder/src/pages/common/profileDropdown.tsx

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { trans } from "i18n";
2626
import { showSwitchOrg } from "@lowcoder-ee/pages/common/customerService";
2727
import { checkIsMobile } from "util/commonUtils";
2828
import { selectSystemConfig } from "redux/selectors/configSelectors";
29+
import { ItemType } from "antd/es/menu/hooks/useItems";
2930

3031
const ProfileWrapper = styled.div`
3132
display: flex;
@@ -159,13 +160,10 @@ export default function ProfileDropdown(props: DropDownProps) {
159160
}
160161
};
161162

162-
const menu = (
163-
<DropdownMenu
164-
style={{ width: "192px" }}
165-
onClick={handleClick}
166-
expandIcon={<StyledPackUpIcon />}
167-
>
168-
<Menu.Item key="profile">
163+
let profileDropdownMenuItems:ItemType[] = [
164+
{
165+
key: 'profile',
166+
label: (
169167
<ProfileWrapper>
170168
<ProfileImage source={avatarUrl} userName={username} side={48} />
171169
<StyledNameLabel>
@@ -187,36 +185,61 @@ export default function ProfileDropdown(props: DropDownProps) {
187185
<OrgRoleLabel>{OrgRoleInfo[currentOrgRoleId].name}</OrgRoleLabel>
188186
)}
189187
</ProfileWrapper>
190-
</Menu.Item>
191-
{orgs && orgs.length > 0 && showSwitchOrg(props.user, sysConfig) && (
192-
<StyledDropdownSubMenu
193-
key="switchOrg"
194-
title={trans("profile.switchOrg")}
195-
popupOffset={[4, -12]}
196-
>
197-
<CommonTextLabel style={{ margin: "8px", color: "#B8B9BF" }}>
198-
{trans("profile.joinedOrg")}
199-
</CommonTextLabel>
200-
{orgs.map((org: Org) => {
201-
const MenuItem = (currentOrgId === org.id ? SelectDropMenuItem : Menu.Item) as React.ElementType;
202-
return (
203-
<MenuItem key={org.id} icon={currentOrgId === org.id && <CheckoutIcon />}>
204-
{org.name}
205-
</MenuItem>
206-
);
207-
})}
208-
{!checkIsMobile(window.innerWidth) && (
209-
<>
210-
<Menu.Divider />
211-
<Menu.Item key="newOrganization" icon={<AddIcon />}>
212-
{trans("profile.createOrg")}
213-
</Menu.Item>
214-
</>
215-
)}
216-
</StyledDropdownSubMenu>
217-
)}
218-
<Menu.Item key="logout">{trans("profile.logout")}</Menu.Item>
219-
</DropdownMenu>
188+
),
189+
},
190+
{
191+
key: 'logout',
192+
label: trans("profile.logout"),
193+
}
194+
]
195+
196+
if(orgs && orgs.length > 0 && showSwitchOrg(props.user, sysConfig)) {
197+
const switchOrgSubMenu = orgs.map((org: Org) => ({
198+
key: org.id,
199+
icon: currentOrgId === org.id && <CheckoutIcon />,
200+
label: org.name
201+
}))
202+
203+
let addWorkSpace:ItemType[] = [];
204+
if(!checkIsMobile(window.innerWidth)) {
205+
addWorkSpace = [
206+
{ type: 'divider'},
207+
{
208+
key: 'newOrganization',
209+
icon: <AddIcon />,
210+
label: trans("profile.createOrg")
211+
}
212+
]
213+
}
214+
215+
const switchOrgMenu = {
216+
key: 'switchOrg',
217+
label: trans("profile.switchOrg"),
218+
popupOffset: [4, -12],
219+
children: [
220+
{
221+
key: 'joinedOrg',
222+
label: (
223+
<CommonTextLabel style={{ margin: "8px", color: "#B8B9BF" }}>
224+
{trans("profile.joinedOrg")}
225+
</CommonTextLabel>
226+
),
227+
disabled: true,
228+
},
229+
...switchOrgSubMenu,
230+
...addWorkSpace,
231+
]
232+
}
233+
profileDropdownMenuItems.splice(1, 0, switchOrgMenu);
234+
}
235+
236+
const menu = (
237+
<DropdownMenu
238+
style={{ width: "192px" }}
239+
onClick={handleClick}
240+
expandIcon={<StyledPackUpIcon />}
241+
items={profileDropdownMenuItems}
242+
/>
220243
);
221244
return (
222245
<>

client/packages/lowcoder/src/pages/userAuth/formLogin.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,13 @@ export default function FormLogin() {
7171
<ConfirmButton loading={loading} disabled={!account || !password} onClick={onSubmit}>
7272
{trans("userAuth.login")}
7373
</ConfirmButton>
74-
{Boolean(invitationId) && (
75-
<>
76-
<Divider />
77-
<ThirdPartyAuth
78-
invitationId={invitationId}
79-
invitedOrganizationId={invitedOrganizationId}
80-
authGoal="login"
81-
/>
82-
</>
83-
)}
74+
75+
<Divider />
76+
<ThirdPartyAuth
77+
invitationId={invitationId}
78+
invitedOrganizationId={invitedOrganizationId}
79+
authGoal="login"
80+
/>
8481
</AccountLoginWrapper>
8582
<AuthBottomView>
8683
{systemConfig.form.enableRegister && (

0 commit comments

Comments
 (0)