From 1a587df9a2400f5ec9737c54cff1744da5b6fcc4 Mon Sep 17 00:00:00 2001 From: Faran Javed Date: Fri, 11 Jul 2025 17:57:33 +0500 Subject: [PATCH 1/2] fix workspaces updated myorg endpoint --- client/packages/lowcoder/src/api/userApi.ts | 11 +++++++---- .../packages/lowcoder/src/constants/orgConstants.ts | 1 + .../lowcoder/src/pages/common/WorkspaceSection.tsx | 4 ++-- .../src/pages/setting/organization/orgList.tsx | 2 +- .../src/redux/reducers/uiReducers/usersReducer.ts | 3 +++ client/packages/lowcoder/src/redux/sagas/orgSagas.ts | 9 +++++---- .../packages/lowcoder/src/util/useWorkspaceManager.ts | 9 +++++---- 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/client/packages/lowcoder/src/api/userApi.ts b/client/packages/lowcoder/src/api/userApi.ts index 5955071a8..a65a72338 100644 --- a/client/packages/lowcoder/src/api/userApi.ts +++ b/client/packages/lowcoder/src/api/userApi.ts @@ -63,10 +63,13 @@ export type GetCurrentUserResponse = GenericApiResponse; export interface GetMyOrgsResponse extends ApiResponse { data: { data: Array<{ - orgId: string; - orgName: string; - createdAt?: number; - updatedAt?: number; + isCurrentOrg: boolean; + orgView: { + orgId: string; + orgName: string; + createdAt?: number; + updatedAt?: number; + }; }>; pageNum: number; pageSize: number; diff --git a/client/packages/lowcoder/src/constants/orgConstants.ts b/client/packages/lowcoder/src/constants/orgConstants.ts index d46d9957b..e2afb5c5f 100644 --- a/client/packages/lowcoder/src/constants/orgConstants.ts +++ b/client/packages/lowcoder/src/constants/orgConstants.ts @@ -56,6 +56,7 @@ export type Org = { createTime?: string; createdAt?: number; updatedAt?: number; + isCurrentOrg?: boolean; }; export type OrgAndRole = { diff --git a/client/packages/lowcoder/src/pages/common/WorkspaceSection.tsx b/client/packages/lowcoder/src/pages/common/WorkspaceSection.tsx index f1cb0709f..0bd8a4c54 100644 --- a/client/packages/lowcoder/src/pages/common/WorkspaceSection.tsx +++ b/client/packages/lowcoder/src/pages/common/WorkspaceSection.tsx @@ -242,11 +242,11 @@ export default function WorkspaceSectionComponent({ displayWorkspaces.map((org: Org) => ( handleOrgSwitch(org.id)} > {org.name} - {user.currentOrgId === org.id && } + {org.isCurrentOrg && } )) ) : ( diff --git a/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx b/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx index c60f492ea..a3cad4043 100644 --- a/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx +++ b/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx @@ -262,7 +262,7 @@ function OrganizationSetting() { dataIndex: "orgName", ellipsis: true, render: (_, record: any) => { - const isActiveOrg = record.id === user.currentOrgId; + const isActiveOrg = record.isCurrentOrg; return ( diff --git a/client/packages/lowcoder/src/redux/reducers/uiReducers/usersReducer.ts b/client/packages/lowcoder/src/redux/reducers/uiReducers/usersReducer.ts index 4146dfd62..3142ca13d 100644 --- a/client/packages/lowcoder/src/redux/reducers/uiReducers/usersReducer.ts +++ b/client/packages/lowcoder/src/redux/reducers/uiReducers/usersReducer.ts @@ -25,6 +25,8 @@ const initialState: UsersReduxState = { workspaces: { items: [], totalCount: 0, + currentOrg: null + } }; @@ -231,6 +233,7 @@ export interface UsersReduxState { workspaces: { items: Org[]; // Current page of workspaces totalCount: number; // Total workspaces available + currentOrg: Org | null; }; } diff --git a/client/packages/lowcoder/src/redux/sagas/orgSagas.ts b/client/packages/lowcoder/src/redux/sagas/orgSagas.ts index f427eeb92..dd64bf1c9 100644 --- a/client/packages/lowcoder/src/redux/sagas/orgSagas.ts +++ b/client/packages/lowcoder/src/redux/sagas/orgSagas.ts @@ -368,10 +368,11 @@ export function* fetchWorkspacesSaga(action: ReduxAction<{page: number, pageSize // Transform orgId/orgName to match Org interface const transformedItems = apiData.data.map(item => ({ - id: item.orgId, - name: item.orgName, - createdAt: item.createdAt, - updatedAt: item.updatedAt, + id: item.orgView.orgId, + name: item.orgView.orgName, + createdAt: item.orgView.createdAt, + updatedAt: item.orgView.updatedAt, + isCurrentOrg: item.isCurrentOrg, })); yield put({ diff --git a/client/packages/lowcoder/src/util/useWorkspaceManager.ts b/client/packages/lowcoder/src/util/useWorkspaceManager.ts index 59732ac53..5c5cafee0 100644 --- a/client/packages/lowcoder/src/util/useWorkspaceManager.ts +++ b/client/packages/lowcoder/src/util/useWorkspaceManager.ts @@ -91,10 +91,11 @@ export function useWorkspaceManager({ if (response.data.success) { const apiData = response.data.data; const transformedItems = apiData.data.map(item => ({ - id: item.orgId, - name: item.orgName, - createdAt: item.createdAt, - updatedAt: item.updatedAt, + id: item.orgView.orgId, + name: item.orgView.orgName, + createdAt: item.orgView.createdAt, + updatedAt: item.orgView.updatedAt, + isCurrentOrg: item.isCurrentOrg, })); dispatch({ From 53fb65d20e3ca1a1cfab04ed0305b714f445e1fc Mon Sep 17 00:00:00 2001 From: Faran Javed Date: Fri, 11 Jul 2025 18:04:46 +0500 Subject: [PATCH 2/2] fix orglist active org icon --- .../lowcoder/src/pages/setting/organization/orgList.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx b/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx index a3cad4043..0e9c8a01c 100644 --- a/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx +++ b/client/packages/lowcoder/src/pages/setting/organization/orgList.tsx @@ -211,6 +211,7 @@ function OrganizationSetting() { logoUrl: org.logoUrl || "", createdAt: org.createdAt, updatedAt: org.updatedAt, + isCurrentOrg: org.isCurrentOrg, })); @@ -307,7 +308,7 @@ function OrganizationSetting() { key: i, operation: ( - {item.id !== user.currentOrgId && ( + {!item.isCurrentOrg && (