瀏覽代碼

[ui-storagebrowser] port APIs to public and fixes the chunk upload (#3967)

* [ui-storagebrowser] port APIs to public

* [ui-storagebrowser] fixes the chunk upload variables
Ram Prasad Agarwal 10 月之前
父節點
當前提交
bd8e80cf93

+ 1 - 1
desktop/core/src/desktop/js/apps/storageBrowser/StorageDirectoryPage/StorageBrowserActions/StorageBrowserActions.tsx

@@ -84,7 +84,7 @@ const StorageBrowserActions = ({
 
   const downloadFile = () => {
     huePubSub.publish('hue.global.info', { message: t('Downloading your file, Please wait...') });
-    location.href = `${DOWNLOAD_API_URL}${selectedFiles[0]?.path}`;
+    location.href = `${DOWNLOAD_API_URL}?path=${selectedFiles[0]?.path}`;
   };
 
   const onActionClick = (actionType: ActionType) => () => {

+ 2 - 2
desktop/core/src/desktop/js/apps/storageBrowser/StorageFilePage/StorageFilePage.test.tsx

@@ -200,7 +200,7 @@ describe('StorageFilePage', () => {
     });
 
     const downloadLink = screen.getByRole('link', { name: 'Download' });
-    expect(downloadLink).toHaveAttribute('href', `${DOWNLOAD_API_URL}${mockFileStats.path}`);
+    expect(downloadLink).toHaveAttribute('href', `${DOWNLOAD_API_URL}?path=${mockFileStats.path}`);
   });
 
   it('should download a file when download button is clicked', async () => {
@@ -216,7 +216,7 @@ describe('StorageFilePage', () => {
     });
 
     const downloadLink = screen.getByRole('link', { name: 'Download' });
-    expect(downloadLink).toHaveAttribute('href', `${DOWNLOAD_API_URL}${mockFileStats.path}`);
+    expect(downloadLink).toHaveAttribute('href', `${DOWNLOAD_API_URL}?path=${mockFileStats.path}`);
   });
 
   it('should not render the download button when show_download_button is false', () => {

+ 3 - 2
desktop/core/src/desktop/js/apps/storageBrowser/StorageFilePage/StorageFilePage.tsx

@@ -115,7 +115,8 @@ const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps
     huePubSub.publish('hue.global.info', { message: t('Downloading your file, Please wait...') });
   };
 
-  const filePreviewUrl = `${DOWNLOAD_API_URL}${fileStats.path}?disposition=inline`;
+  const fileDownloadUrl = `${DOWNLOAD_API_URL}?path=${fileStats.path}`;
+  const filePreviewUrl = `${fileDownloadUrl}&&disposition=inline`;
 
   const isEditingEnabled =
     !isEditing &&
@@ -192,7 +193,7 @@ const StorageFilePage = ({ fileName, fileStats, onReload }: StorageFilePageProps
                   </>
                 )}
                 {config?.storage_browser.enable_file_download_button && (
-                  <a href={`${DOWNLOAD_API_URL}${fileStats.path}`}>
+                  <a href={fileDownloadUrl}>
                     <PrimaryButton
                       data-testid="preview--download--button"
                       data-event=""

+ 1 - 1
desktop/core/src/desktop/js/jquery/plugins/jquery.filechooser.js

@@ -807,7 +807,7 @@ let num_of_pending_uploads = 0;
 
 function initUploader(path, _parent, el, labels) {
   let uploader;
-  if (window.getLastKnownConfig().hue_config.enable_chunked_file_uploader) {
+  if (window.getLastKnownConfig().storage_browser.enable_chunked_file_upload) {
     const action = '/filebrowser/upload/chunks/';
     const qqTemplate = document.createElement('div');
     qqTemplate.id = 'qq-template';

+ 14 - 14
desktop/core/src/desktop/js/reactComponents/FileChooser/api.ts

@@ -18,25 +18,25 @@ export const FILESYSTEMS_API_URL = '/api/v1/storage/filesystems';
 export const FILE_STATS_API_URL = '/api/v1/storage/stat';
 export const LIST_DIRECTORY_API_URL = '/api/v1/storage/list';
 export const FILE_PREVIEW_API_URL = '/api/v1/storage/display';
-export const DOWNLOAD_API_URL = '/filebrowser/download=';
+export const DOWNLOAD_API_URL = '/api/v1/storage/download';
 export const CONTENT_SUMMARY_API_URL = '/api/v1/storage/content_summary';
 export const SAVE_FILE_API_URL = '/api/v1/storage/save';
-export const UPLOAD_FILE_URL = '/filebrowser/upload/file';
-export const CHUNK_UPLOAD_URL = '/filebrowser/upload/chunks/file';
-export const CHUNK_UPLOAD_COMPLETE_URL = '/filebrowser/upload/complete';
-export const CREATE_FILE_API_URL = '/api/v1/storage/create/file/';
-export const CREATE_DIRECTORY_API_URL = '/api/v1/storage/create/directory/';
-export const RENAME_API_URL = '/api/v1/storage/rename/';
-export const SET_REPLICATION_API_URL = '/api/v1/storage/replication/';
-export const DELETION_API_URL = '/api/v1/storage/delete/';
+export const UPLOAD_FILE_URL = '/api/v1/storage/upload/file';
+export const CHUNK_UPLOAD_URL = '/api/v1/storage/upload/chunks';
+export const CHUNK_UPLOAD_COMPLETE_URL = '/api/v1/storage/upload/complete';
+export const CREATE_FILE_API_URL = '/api/v1/storage/create/file';
+export const CREATE_DIRECTORY_API_URL = '/api/v1/storage/create/directory';
+export const RENAME_API_URL = '/api/v1/storage/rename';
+export const SET_REPLICATION_API_URL = '/api/v1/storage/replication';
+export const DELETION_API_URL = '/api/v1/storage/delete';
 export const BULK_DELETION_API_URL = '/api/v1/storage/delete/bulk';
 export const COMPRESS_API_URL = '/api/v1/storage/compress';
 export const EXTRACT_API_URL = '/api/v1/storage/extract_archive';
-export const COPY_API_URL = '/api/v1/storage/copy/';
-export const BULK_COPY_API_URL = '/api/v1/storage/copy/bulk/';
-export const MOVE_API_URL = '/api/v1/storage/move/';
-export const BULK_MOVE_API_URL = '/api/v1/storage/move/bulk/';
-export const UPLOAD_AVAILABLE_SPACE_URL = '/api/v1/taskserver/upload/available_space/';
+export const COPY_API_URL = '/api/v1/storage/copy';
+export const BULK_COPY_API_URL = '/api/v1/storage/copy/bulk';
+export const MOVE_API_URL = '/api/v1/storage/move';
+export const BULK_MOVE_API_URL = '/api/v1/storage/move/bulk';
+export const UPLOAD_AVAILABLE_SPACE_URL = '/api/v1/taskserver/upload/available_space';
 
 export interface ApiFileSystem {
   file_system: string;

+ 3 - 3
desktop/core/src/desktop/static/desktop/js/listdir-inline.js

@@ -383,7 +383,7 @@ var FileBrowserModel = function (files, page, breadcrumbs, currentDirPath) {
   });
 
   self.isTaskServerEnabled = ko.computed(function() {
-    return window.getLastKnownConfig().hue_config.enable_chunked_file_uploader && window.getLastKnownConfig().hue_config.enable_task_server;
+    return window.getLastKnownConfig().storage_browser.enable_chunked_file_upload && window.getLastKnownConfig().hue_config.enable_task_server;
   });
 
   self.scheme = ko.pureComputed(function () {
@@ -1393,7 +1393,7 @@ var FileBrowserModel = function (files, page, breadcrumbs, currentDirPath) {
       var uploader; 
       var scheduleUpload;
       
-      if ((window.getLastKnownConfig().hue_config.enable_chunked_file_uploader) && (window.getLastKnownConfig().hue_config.enable_task_server))  {
+      if ((window.getLastKnownConfig().storage_browser.enable_chunked_file_upload) && (window.getLastKnownConfig().hue_config.enable_task_server))  {
         
         self.pendingUploads(0);
         var action = "/filebrowser/upload/chunks/";
@@ -1517,7 +1517,7 @@ var FileBrowserModel = function (files, page, breadcrumbs, currentDirPath) {
         });
       }
       // Chunked Fileuploader without Taskserver
-      else if ((window.getLastKnownConfig().hue_config.enable_chunked_file_uploader) && !(window.getLastKnownConfig().hue_config.enable_task_server)) {
+      else if ((window.getLastKnownConfig().storage_browser.enable_chunked_file_upload) && !(window.getLastKnownConfig().hue_config.enable_task_server)) {
         self.pendingUploads(0);
         var action = "/filebrowser/upload/chunks/";
         uploader = new qq.FileUploader({