@@ -17,9 +17,9 @@ import {
17
17
SearchIcon ,
18
18
} from "lowcoder-design" ;
19
19
import ProfileSettingModal from "pages/setting/profile" ;
20
- import React , { useEffect , useMemo , useState } from "react" ;
20
+ import React , { useMemo , useState } from "react" ;
21
21
import { useDispatch , useSelector } from "react-redux" ;
22
- import { createOrgAction , fetchWorkspacesAction , switchOrg } from "redux/reduxActions/orgActions" ;
22
+ import { createOrgAction , switchOrg } from "redux/reduxActions/orgActions" ;
23
23
import styled from "styled-components" ;
24
24
import history from "util/history" ;
25
25
import ProfileImage from "pages/common/profileImage" ;
@@ -30,7 +30,6 @@ import { showSwitchOrg } from "@lowcoder-ee/pages/common/customerService";
30
30
import { checkIsMobile } from "util/commonUtils" ;
31
31
import { selectSystemConfig } from "redux/selectors/configSelectors" ;
32
32
import type { ItemType } from "antd/es/menu/interface" ;
33
- import { getCurrentOrg , getWorkspaces } from "@lowcoder-ee/redux/selectors/orgSelectors" ;
34
33
35
34
const { Item } = Menu ;
36
35
@@ -220,29 +219,24 @@ type DropDownProps = {
220
219
} ;
221
220
222
221
export default function ProfileDropdown ( props : DropDownProps ) {
223
- const { avatarUrl, username, currentOrgId } = props . user ;
222
+ const { avatarUrl, username, orgs , currentOrgId } = props . user ;
224
223
const currentOrgRoleId = props . user . orgRoleMap . get ( currentOrgId ) ;
225
- const currentOrg = useSelector ( getCurrentOrg ) ;
226
- const workspaces = useSelector ( getWorkspaces ) ;
224
+ const currentOrg = useMemo (
225
+ ( ) => props . user . orgs . find ( ( o ) => o . id === currentOrgId ) ,
226
+ [ props . user , currentOrgId ]
227
+ ) ;
227
228
const settingModalVisible = useSelector ( isProfileSettingModalVisible ) ;
228
229
const sysConfig = useSelector ( selectSystemConfig ) ;
229
230
const dispatch = useDispatch ( ) ;
230
231
const [ searchTerm , setSearchTerm ] = useState ( "" ) ;
231
232
const [ dropdownVisible , setDropdownVisible ] = useState ( false ) ;
232
233
233
- // Load workspaces when dropdown opens
234
- useEffect ( ( ) => {
235
- if ( dropdownVisible && workspaces . items . length === 0 ) {
236
- dispatch ( fetchWorkspacesAction ( 1 ) ) ;
237
- }
238
- } , [ dropdownVisible ] ) ;
239
- // Use workspaces.items instead of props.user.orgs
240
234
const filteredOrgs = useMemo ( ( ) => {
241
- if ( ! searchTerm . trim ( ) ) return workspaces . items ;
242
- return workspaces . items . filter ( org =>
235
+ if ( ! searchTerm . trim ( ) ) return orgs ;
236
+ return orgs . filter ( org =>
243
237
org . name . toLowerCase ( ) . includes ( searchTerm . toLowerCase ( ) )
244
238
) ;
245
- } , [ workspaces . items , searchTerm ] ) ;
239
+ } , [ orgs , searchTerm ] ) ;
246
240
247
241
const handleProfileClick = ( ) => {
248
242
if ( checkIsMobile ( window . innerWidth ) ) {
@@ -272,7 +266,7 @@ export default function ProfileDropdown(props: DropDownProps) {
272
266
} ;
273
267
274
268
const handleCreateOrg = ( ) => {
275
- dispatch ( createOrgAction ( workspaces . items ) ) ;
269
+ dispatch ( createOrgAction ( orgs ) ) ;
276
270
history . push ( ORGANIZATION_SETTING ) ;
277
271
setDropdownVisible ( false ) ;
278
272
} ;
@@ -299,11 +293,11 @@ export default function ProfileDropdown(props: DropDownProps) {
299
293
</ ProfileSection >
300
294
301
295
{ /* Workspaces Section */ }
302
- { workspaces . items . length > 0 && showSwitchOrg ( props . user , sysConfig ) && (
296
+ { orgs && orgs . length > 0 && showSwitchOrg ( props . user , sysConfig ) && (
303
297
< WorkspaceSection >
304
298
< SectionHeader > { trans ( "profile.switchOrg" ) } </ SectionHeader >
305
299
306
- { workspaces . items . length > 3 && (
300
+ { orgs . length > 3 && (
307
301
< SearchContainer >
308
302
< StyledSearchInput
309
303
placeholder = "Search workspaces..."
0 commit comments