Просмотр исходного кода

[ui-core] Fix left assist panel to use configured default home paths for S3/ABFS/OFS (#4292)

Fix left assist panel Files section to respect configured default home paths
for S3, ABFS, and OFS storage instead of always defaulting to root.

The left assist panel was hardcoded to use '/' as the default path for S3,
ABFS, OFS, and GS, ignoring the configured remote_storage_home or
default_home_path settings. This caused issues in RAZ environments where
users don't have access to the storage root (e.g., s3a://).

Changes:
- Made rootPath a Knockout observable in AssistStoragePanel
- Fixed getRootFilePath() to properly decode the full path from connector.page
- Added logic to strip scheme prefix for ABFS/OFS (which have auto-prefixing)
- Updated reload() and goHome handlers to use rootPath instead of '/'
- Show home button for S3/ABFS when a default path is configured

Now the left assist panel correctly uses paths like:
- S3: s3a://bucket/user/path (from remote_storage_home or default_home_path)
- ABFS: abfs://container/user/path (from default_home_path)
- OFS: ofs://volume/bucket/path (from default_home_path)

This ensures consistency with the main filebrowser behavior and enables
S3 access in RAZ environments through the left assist panel.
Harsh Gupta 1 месяц назад
Родитель
Сommit
3a00479d66

+ 17 - 2
desktop/core/src/desktop/js/config/hueConfig.ts

@@ -126,7 +126,7 @@ export const filterEditorConnectors = (
   connectorTest: ConnectorTest<AppType.editor>
 ): EditorInterpreter[] => filterConnector(AppType.editor, connectorTest);
 
-const rootPathRegex = /.*%3A%2F%2F(.+)$/;
+const rootPathRegex = /.*view=(.+)$/;
 
 /**
  * This takes the initial path from the "browser" config, used in cases where the users can't access '/'
@@ -138,7 +138,22 @@ export const getRootFilePath = (connector: BrowserInterpreter): string => {
   }
   const match = connector.page.match(rootPathRegex);
   if (match) {
-    return match[1] + '/';
+    // Decode the URL-encoded path (e.g., s3a%3A%2F%2F -> s3a://)
+    const decodedPath = decodeURIComponent(match[1]);
+
+    // For ABFS and OFS, strip the scheme prefix as AssistStorageEntry adds it automatically
+    // S3 doesn't have auto-prefixing logic, so keep the full path
+    const abfsPrefix = 'abfs://';
+    if (connector.type === 'abfs' && decodedPath.startsWith(abfsPrefix)) {
+      return decodedPath.substring(abfsPrefix.length);
+    }
+
+    const ofsPrefix = 'ofs://';
+    if (connector.type === 'ofs' && decodedPath.startsWith(ofsPrefix)) {
+      return decodedPath.substring(ofsPrefix.length);
+    }
+
+    return decodedPath;
   }
 
   return '';

+ 14 - 12
desktop/core/src/desktop/js/ko/components/assist/ko.assistStoragePanel.js

@@ -50,9 +50,10 @@ const TEMPLATE = `
 
   <script type="text/html" id="assist-storage-header-actions">
     <div class="assist-db-header-actions">
-      <!-- ko if: source.type !== 's3' && source.type !== 'abfs' -->
-      <a class="inactive-action" href="javascript:void(0)" data-bind="click: goHome, attr: { title: I18n('Go to ' + window.USER_HOME_DIR) }"><i class="pointer fa fa-home"></i></a>
-      <!-- ko if: window.SHOW_UPLOAD_BUTTON -->
+      <!-- ko if: source.type === 'hdfs' || source.type === 'adls' || source.type === 'ofs' || source.type === 'gs' || ($parent.rootPath() && (source.type === 's3' || source.type === 'abfs')) -->
+      <a class="inactive-action" href="javascript:void(0)" data-bind="click: goHome, attr: { title: source.type === 'hdfs' ? I18n('Go to ' + window.USER_HOME_DIR) : I18n('Go to home') }"><i class="pointer fa fa-home"></i></a>
+      <!-- /ko -->
+      <!-- ko if: source.type !== 's3' && source.type !== 'abfs' && window.SHOW_UPLOAD_BUTTON -->
       <a class="inactive-action" data-bind="dropzone: {
             url: '/filebrowser/upload/file?dest=' + (source.type === 'adls' ? 'adl:' : '') + path,
             params: { dest: path },
@@ -68,7 +69,6 @@ const TEMPLATE = `
         )}"></i></div>
       </a>
       <!-- /ko -->
-      <!-- /ko -->
       <!-- ko if: source.type === 'abfs' && path !== '/' && window.SHOW_UPLOAD_BUTTON -->
       <a class="inactive-action" data-bind="dropzone: {
             url: '/filebrowser/upload/file?dest=' + abfsPath,
@@ -201,13 +201,13 @@ class AssistStoragePanel {
     this.activeSource = ko.observable(foundLastSource);
     this.loading = ko.observable();
     this.initialized = false;
-    this.rootPath = getRootFilePath(this.activeSource());
+    this.rootPath = ko.observable(getRootFilePath(this.activeSource()));
 
     this.selectedStorageEntry = ko.observable();
 
     this.activeSource.subscribe(newValue => {
       if (newValue) {
-        this.rootPath = getRootFilePath(this.activeSource());
+        this.rootPath(getRootFilePath(this.activeSource()));
         setInLocalStorage('assist.lastStorageSource', newValue.type);
         this.selectedStorageEntry(undefined);
         this.reload();
@@ -230,7 +230,7 @@ class AssistStoragePanel {
         this.activeSource().type === 'gs' ||
         this.activeSource().type === 'abfs' ||
         this.activeSource().type === 'ofs'
-          ? '/'
+          ? this.rootPath() || '/'
           : window.USER_HOME_DIR;
       this.loadPath(path);
       setInLocalStorage('assist.currentStoragePath_' + this.activeSource().type, path);
@@ -242,17 +242,18 @@ class AssistStoragePanel {
   loadPath(path) {
     this.loading(true);
     let relativePath = path;
-    if (this.rootPath) {
-      relativePath = relativePath.replace(this.rootPath, '/');
+    const rootPath = this.rootPath();
+    if (rootPath) {
+      relativePath = relativePath.replace(rootPath, '/');
     }
     const parts = relativePath.split('/');
     parts.shift();
 
     const currentEntry = new AssistStorageEntry({
       source: this.activeSource(),
-      rootPath: this.rootPath,
+      rootPath,
       definition: {
-        name: this.rootPath,
+        name: rootPath,
         type: 'dir'
       },
       parent: null
@@ -266,10 +267,11 @@ class AssistStoragePanel {
   }
 
   reload() {
+    const defaultPath = this.activeSource().type === 'hdfs' ? window.USER_HOME_DIR : (this.rootPath() || '/');
     this.loadPath(
       getFromLocalStorage(
         'assist.currentStoragePath_' + this.activeSource().type,
-        this.activeSource().type === 'hdfs' ? window.USER_HOME_DIR : '/'
+        defaultPath
       )
     );
   }