From 847b10dd6b0ac4f723b7b2b79378ed65290d5fc0 Mon Sep 17 00:00:00 2001 From: devinxl Date: Wed, 10 Apr 2024 18:19:48 +0800 Subject: [PATCH] refactor(dcellar-web-ui): rename variable from _path to _completeCommonPrefix --- apps/dcellar-web-ui/src/store/slices/object.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/dcellar-web-ui/src/store/slices/object.ts b/apps/dcellar-web-ui/src/store/slices/object.ts index 77deb815..6b2e252c 100644 --- a/apps/dcellar-web-ui/src/store/slices/object.ts +++ b/apps/dcellar-web-ui/src/store/slices/object.ts @@ -478,7 +478,7 @@ export const setupDummyFolder = }; export const setupListObjects = - (params: Partial, _path?: string) => + (params: Partial, _completeCommonPrefix?: string) => async (dispatch: AppDispatch, getState: GetState) => { const { objectCommonPrefix, currentBucketName, completeCommonPrefix, objectListPageRestored } = getState().object; @@ -486,8 +486,10 @@ export const setupListObjects = const _query = new URLSearchParams(params.query?.toString() || ''); _query.append('max-keys', '1000'); _query.append('delimiter', '/'); - const prefix = _path ? _path.split('/').slice(1).join('/') : objectCommonPrefix; - if (prefix) _query.append('prefix', prefix); + const commonPrefix = _completeCommonPrefix + ? _completeCommonPrefix.split('/').slice(1).join('/') + : objectCommonPrefix; + if (commonPrefix) _query.append('prefix', commonPrefix); // support any path list objects, bucketName & _path const payload = { bucketName: currentBucketName, @@ -502,8 +504,10 @@ export const setupListObjects = toast.error({ description: error }); return; } - dispatch(setObjectListTruncated({ path: _path || completeCommonPrefix, truncate })); - dispatch(setObjectList({ path: _path || completeCommonPrefix, list: res! })); + dispatch( + setObjectListTruncated({ path: _completeCommonPrefix || completeCommonPrefix, truncate }), + ); + dispatch(setObjectList({ path: _completeCommonPrefix || completeCommonPrefix, list: res! })); dispatch(setObjectListPageRestored(true)); if (!objectListPageRestored) { dispatch(setObjectListPage({ path: completeCommonPrefix, current: 0 }));