Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5d372a

Browse files
committed
test
1 parent 35b7c68 commit a5d372a

File tree

4 files changed

+12
-67
lines changed

4 files changed

+12
-67
lines changed

‎client/packages/lowcoder/src/constants/reduxActionConstants.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ export const ReduxActionTypes = {
1414
/* workspace RELATED */
1515
FETCH_WORKSPACES_INIT: "FETCH_WORKSPACES_INIT",
1616
FETCH_WORKSPACES_SUCCESS: "FETCH_WORKSPACES_SUCCESS",
17-
FETCH_WORKSPACES_ERROR: "FETCH_WORKSPACES_ERROR",
18-
LOAD_MORE_WORKSPACES_SUCCESS: "LOAD_MORE_WORKSPACES_SUCCESS",
19-
SEARCH_WORKSPACES_INIT: "SEARCH_WORKSPACES_INIT",
17+
2018

2119

2220
/* plugin RELATED */

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

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ const initialState: UsersReduxState = {
2424
apiKeys: [],
2525
workspaces: {
2626
items: [],
27-
currentPage: 1,
28-
pageSize: 20,
2927
totalCount: 0,
30-
hasMore: false,
31-
loading: false,
32-
searchQuery: ""
3328
}
3429
};
3530

@@ -202,51 +197,19 @@ const usersReducer = createReducer(initialState, {
202197
}),
203198

204199

205-
[ReduxActionTypes.FETCH_WORKSPACES_INIT]: (state: UsersReduxState) => ({
206-
...state,
207-
workspaces: {
208-
...state.workspaces,
209-
loading: true
210-
}
211-
}),
212-
213200
[ReduxActionTypes.FETCH_WORKSPACES_SUCCESS]: (
214201
state: UsersReduxState,
215-
action: ReduxAction<any>
216-
) => ({
217-
...state,
218-
workspaces: {
219-
items: action.payload.items,
220-
currentPage: action.payload.currentPage,
221-
pageSize: action.payload.pageSize,
222-
totalCount: action.payload.totalCount,
223-
hasMore: action.payload.hasMore,
224-
loading: false,
225-
searchQuery: action.payload.searchQuery
226-
}
227-
}),
228-
229-
[ReduxActionTypes.LOAD_MORE_WORKSPACES_SUCCESS]: (
230-
state: UsersReduxState,
231-
action: ReduxAction<any>
202+
action: ReduxAction<{ items: Org[], totalCount: number, isLoadMore?: boolean }>
232203
) => ({
233204
...state,
234205
workspaces: {
235-
...state.workspaces,
236-
items: [...state.workspaces.items, ...action.payload.items], // Append new items
237-
currentPage: action.payload.currentPage,
238-
hasMore: action.payload.hasMore,
239-
loading: false
206+
items: action.payload.isLoadMore
207+
? [...state.workspaces.items, ...action.payload.items] // Append for load more
208+
: action.payload.items, // Replace for new search/initial load
209+
totalCount: action.payload.totalCount
240210
}
241211
}),
242212

243-
[ReduxActionTypes.FETCH_WORKSPACES_ERROR]: (state: UsersReduxState) => ({
244-
...state,
245-
workspaces: {
246-
...state.workspaces,
247-
loading: false
248-
}
249-
}),
250213
});
251214

252215
export interface UsersReduxState {
@@ -267,12 +230,7 @@ export interface UsersReduxState {
267230
// NEW: Separate workspace state
268231
workspaces: {
269232
items: Org[]; // Current page of workspaces
270-
currentPage: number; // Which page we're on
271-
pageSize: number; // Items per page (e.g., 20)
272233
totalCount: number; // Total workspaces available
273-
hasMore: boolean; // Are there more pages?
274-
loading: boolean; // Loading state
275-
searchQuery: string; // Current search term
276234
};
277235
}
278236

‎client/packages/lowcoder/src/redux/reduxActions/orgActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ export const fetchLastMonthAPIUsageActionSuccess = (payload: OrgLastMonthAPIUsag
193193
};
194194
};
195195

196-
export const fetchWorkspacesAction = (page: number = 1, search?: string) => ({
196+
export const fetchWorkspacesAction = (page: number = 1, search?: string, isLoadMore?: boolean) => ({
197197
type: ReduxActionTypes.FETCH_WORKSPACES_INIT,
198-
payload: { page, search }
198+
payload: { page, search, isLoadMore }
199199
});
200200

201201
export const loadMoreWorkspacesAction = (page: number, search?: string) => ({

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -341,36 +341,25 @@ export function* fetchWorkspacesSaga(action: ReduxAction<{page: number, search?:
341341

342342
if (validateResponse(response)) {
343343
const apiData = response.data.data;
344-
console.log("apiData", apiData);
345-
const hasMore = (apiData.pageNum * apiData.pageSize) < apiData.total;
346344

347345
// Transform orgId/orgName to match Org interface
348346
const transformedItems = apiData.data.map(item => ({
349347
id: item.orgId,
350348
name: item.orgName,
351-
// Add other Org properties if needed (logoUrl, etc.)
352349
}));
353350

354-
const actionType = isLoadMore
355-
? ReduxActionTypes.LOAD_MORE_WORKSPACES_SUCCESS
356-
: ReduxActionTypes.FETCH_WORKSPACES_SUCCESS;
357-
358351
yield put({
359-
type: actionType,
352+
type: ReduxActionTypes.FETCH_WORKSPACES_SUCCESS,
360353
payload: {
361354
items: transformedItems,
362355
totalCount: apiData.total,
363-
currentPage: apiData.pageNum,
364-
pageSize: apiData.pageSize,
365-
hasMore: hasMore,
366-
searchQuery: search || ""
356+
isLoadMore: isLoadMore || false
367357
}
368358
});
369359
}
370360
} catch (error: any) {
371-
yield put({
372-
type: ReduxActionTypes.FETCH_WORKSPACES_ERROR,
373-
});
361+
// Handle error in component instead of Redux
362+
console.error('Error fetching workspaces:', error);
374363
}
375364
}
376365

0 commit comments

Comments
 (0)