This is an automated email from the ASF dual-hosted git repository.

jerryshao pushed a commit to branch branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-1.3 by this push:
     new 1da53b0c27 [Cherry-pick to branch-1.3] [#12289] web-v2(UI): fix about 
retains the previous sub-path when switching filesets (#12292) (#12340)
1da53b0c27 is described below

commit 1da53b0c2733fe8dbd6c185bb7f748166d75570d
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Aug 3 21:50:49 2026 +0800

    [Cherry-pick to branch-1.3] [#12289] web-v2(UI): fix about retains the 
previous sub-path when switching filesets (#12292) (#12340)
    
    **Cherry-pick Information:**
    - Original commit: f350927f9626cfd1eed3102da5ef31d5f0c406fb
    - Target branch: `branch-1.3`
    - Status: ✅ Clean cherry-pick (no conflicts)
    
    Co-authored-by: Qian Xia <[email protected]>
---
 web-v2/web/src/app/catalogs/page.js                |  1 +
 .../entitiesContent/FilesetDetailsPage.js          |  3 +-
 .../rightContent/entitiesContent/ListFiles.js      | 42 +++++++++++++---------
 3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/web-v2/web/src/app/catalogs/page.js 
b/web-v2/web/src/app/catalogs/page.js
index 9e8b2e5b3a..9aeecc3705 100644
--- a/web-v2/web/src/app/catalogs/page.js
+++ b/web-v2/web/src/app/catalogs/page.js
@@ -253,6 +253,7 @@ const CatalogsListPage = () => {
               case 'fileset':
                 store.filesets.length === 0 &&
                   (await dispatch(fetchFilesets({ init: true, page: 'schemas', 
metalake, catalog, schema })))
+                await dispatch(resetActivatedDetails())
                 await dispatch(setActivatedDetailsLoading(true))
                 await dispatch(getFilesetDetails({ init: true, metalake, 
catalog, schema, fileset }))
                 await dispatch(setActivatedDetailsLoading(false))
diff --git 
a/web-v2/web/src/app/catalogs/rightContent/entitiesContent/FilesetDetailsPage.js
 
b/web-v2/web/src/app/catalogs/rightContent/entitiesContent/FilesetDetailsPage.js
index ad34e2136c..f6289ac64d 100644
--- 
a/web-v2/web/src/app/catalogs/rightContent/entitiesContent/FilesetDetailsPage.js
+++ 
b/web-v2/web/src/app/catalogs/rightContent/entitiesContent/FilesetDetailsPage.js
@@ -265,9 +265,10 @@ export default function FilesetDetailsPage({ ...props }) {
         </Space>
       </Spin>
       <Tabs items={tabOptions} activeKey={activeTab} onChange={setActiveTab} />
-      {activeTab === 'files' && (
+      {activeTab === 'files' && !store.activatedDetailsLoading && (
         <div data-refer='tab-files-panel'>
           <ListFiles
+            key={`${catalog}.${schema}.${fileset}`}
             metalake={currentMetalake}
             catalog={catalog}
             schema={schema}
diff --git 
a/web-v2/web/src/app/catalogs/rightContent/entitiesContent/ListFiles.js 
b/web-v2/web/src/app/catalogs/rightContent/entitiesContent/ListFiles.js
index 3fd84ba3f9..ed6cc4d84d 100644
--- a/web-v2/web/src/app/catalogs/rightContent/entitiesContent/ListFiles.js
+++ b/web-v2/web/src/app/catalogs/rightContent/entitiesContent/ListFiles.js
@@ -41,11 +41,28 @@ const ListFiles = ({ metalake, catalog, schema, fileset, 
storageLocations, defau
   const store = useAppSelector(state => state.metalakes)
   const dispatch = useAppDispatch()
 
+  // Sync currentLocation with storageLocations/defaultLocationName.
+  // When currentLocation is undefined or no longer exists in
+  // storageLocations, derive the correct value from props.
   useEffect(() => {
-    if (defaultLocationName) {
+    if (!storageLocations || Object.keys(storageLocations).length === 0) {
+      setCurrentLocation(undefined)
+
+      return
+    }
+
+    // If currentLocation is valid in current storageLocations, keep it
+    if (currentLocation && storageLocations[currentLocation]) {
+      return
+    }
+
+    // Otherwise, derive from props
+    if (defaultLocationName && storageLocations[defaultLocationName]) {
       setCurrentLocation(defaultLocationName)
+    } else {
+      setCurrentLocation(Object.keys(storageLocations)[0])
     }
-  }, [defaultLocationName])
+  }, [currentLocation, defaultLocationName, storageLocations])
 
   useEffect(() => {
     if (sub_path) {
@@ -56,7 +73,7 @@ const ListFiles = ({ metalake, catalog, schema, fileset, 
storageLocations, defau
   }, [sub_path])
 
   useEffect(() => {
-    if (metalake && catalog && schema && fileset) {
+    if (metalake && catalog && schema && fileset && currentLocation && 
storageLocations?.[currentLocation]) {
       dispatch(
         getFilesetFiles({
           metalake,
@@ -149,25 +166,16 @@ const ListFiles = ({ metalake, catalog, schema, fileset, 
storageLocations, defau
     return { columns, minWidth: 100 }
   }, [columns])
 
-  if (!storageLocations || Object.keys(storageLocations).length === 0) {
-    return <p>No storage locations configured</p>
-  }
-
-  if (!currentLocation && defaultLocationName) {
-    setCurrentLocation(defaultLocationName)
-
+  if (!storageLocations) {
     return <Spin />
   }
 
-  if (!currentLocation && Object.keys(storageLocations).length > 0) {
-    const firstLocation = Object.keys(storageLocations)[0]
-    setCurrentLocation(firstLocation)
-
-    return <Spin />
+  if (Object.keys(storageLocations).length === 0) {
+    return <Text type='secondary'>No storage locations configured</Text>
   }
 
-  if (!currentLocation) {
-    return <p>Please select a storage location</p>
+  if (!currentLocation || !storageLocations[currentLocation]) {
+    return <Spin />
   }
 
   const displayedFiles = [...store.tableData] || []

Reply via email to