Skip to content

Commit 34c6351

Browse files
Merge pull request #1859 from iamfaran/fix/myorg-endpoint
[Fix]: For the new structure /myorg endpoint
2 parents f9128ea + 53fb65d commit 34c6351

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

client/packages/lowcoder/src/api/userApi.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ export type GetCurrentUserResponse = GenericApiResponse<CurrentUser>;
6363
export interface GetMyOrgsResponse extends ApiResponse {
6464
data: {
6565
data: Array<{
66-
orgId: string;
67-
orgName: string;
68-
createdAt?: number;
69-
updatedAt?: number;
66+
isCurrentOrg: boolean;
67+
orgView: {
68+
orgId: string;
69+
orgName: string;
70+
createdAt?: number;
71+
updatedAt?: number;
72+
};
7073
}>;
7174
pageNum: number;
7275
pageSize: number;

client/packages/lowcoder/src/constants/orgConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export type Org = {
5656
createTime?: string;
5757
createdAt?: number;
5858
updatedAt?: number;
59+
isCurrentOrg?: boolean;
5960
};
6061

6162
export type OrgAndRole = {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ export default function WorkspaceSectionComponent({
242242
displayWorkspaces.map((org: Org) => (
243243
<WorkspaceItem
244244
key={org.id}
245-
$isActive={user.currentOrgId === org.id}
245+
$isActive={org.isCurrentOrg}
246246
onClick={() => handleOrgSwitch(org.id)}
247247
>
248248
<WorkspaceName title={org.name}>{org.name}</WorkspaceName>
249-
{user.currentOrgId === org.id && <ActiveIcon />}
249+
{org.isCurrentOrg && <ActiveIcon />}
250250
</WorkspaceItem>
251251
))
252252
) : (

client/packages/lowcoder/src/pages/setting/organization/orgList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ function OrganizationSetting() {
211211
logoUrl: org.logoUrl || "",
212212
createdAt: org.createdAt,
213213
updatedAt: org.updatedAt,
214+
isCurrentOrg: org.isCurrentOrg,
214215
}));
215216

216217

@@ -262,7 +263,7 @@ function OrganizationSetting() {
262263
dataIndex: "orgName",
263264
ellipsis: true,
264265
render: (_, record: any) => {
265-
const isActiveOrg = record.id === user.currentOrgId;
266+
const isActiveOrg = record.isCurrentOrg;
266267
return (
267268
<OrgName>
268269
<StyledOrgLogo source={record.logoUrl} orgName={record.orgName} />
@@ -307,7 +308,7 @@ function OrganizationSetting() {
307308
key: i,
308309
operation: (
309310
<OperationWrapper>
310-
{item.id !== user.currentOrgId && (
311+
{!item.isCurrentOrg && (
311312
<SwitchBtn
312313
className={"home-datasource-edit-button"}
313314
buttonType={"blue"}

client/packages/lowcoder/src/redux/reducers/uiReducers/usersReducer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const initialState: UsersReduxState = {
2525
workspaces: {
2626
items: [],
2727
totalCount: 0,
28+
currentOrg: null
29+
2830
}
2931
};
3032

@@ -231,6 +233,7 @@ export interface UsersReduxState {
231233
workspaces: {
232234
items: Org[]; // Current page of workspaces
233235
totalCount: number; // Total workspaces available
236+
currentOrg: Org | null;
234237
};
235238
}
236239

client/packages/lowcoder/src/redux/sagas/orgSagas.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,11 @@ export function* fetchWorkspacesSaga(action: ReduxAction<{page: number, pageSize
368368

369369
// Transform orgId/orgName to match Org interface
370370
const transformedItems = apiData.data.map(item => ({
371-
id: item.orgId,
372-
name: item.orgName,
373-
createdAt: item.createdAt,
374-
updatedAt: item.updatedAt,
371+
id: item.orgView.orgId,
372+
name: item.orgView.orgName,
373+
createdAt: item.orgView.createdAt,
374+
updatedAt: item.orgView.updatedAt,
375+
isCurrentOrg: item.isCurrentOrg,
375376
}));
376377

377378
yield put({

client/packages/lowcoder/src/util/useWorkspaceManager.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ export function useWorkspaceManager({
9191
if (response.data.success) {
9292
const apiData = response.data.data;
9393
const transformedItems = apiData.data.map(item => ({
94-
id: item.orgId,
95-
name: item.orgName,
96-
createdAt: item.createdAt,
97-
updatedAt: item.updatedAt,
94+
id: item.orgView.orgId,
95+
name: item.orgView.orgName,
96+
createdAt: item.orgView.createdAt,
97+
updatedAt: item.orgView.updatedAt,
98+
isCurrentOrg: item.isCurrentOrg,
9899
}));
99100

100101
dispatch({

0 commit comments

Comments
 (0)