@@ -26,6 +26,7 @@ import { trans } from "i18n";
2626import { showSwitchOrg } from "@lowcoder-ee/pages/common/customerService" ;
2727import { checkIsMobile } from "util/commonUtils" ;
2828import { selectSystemConfig } from "redux/selectors/configSelectors" ;
29+ import { ItemType } from "antd/es/menu/hooks/useItems" ;
2930
3031const 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 < >
0 commit comments