Browse Source

[ui-storagebrowser] fixes the regular file upload for new storage brwoser (#3960)

Ram Prasad Agarwal 10 months ago
parent
commit
1009872820

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

@@ -72,7 +72,7 @@ describe('CreateAndUploadAction', () => {
     const newButton = screen.getByText('New');
     await act(async () => fireEvent.click(newButton));
 
-    const newUploadButton = screen.getByText('New Upload');
+    const newUploadButton = screen.getByText('Upload File');
     fireEvent.click(newUploadButton);
 
     // Check if the upload modal is opened

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

@@ -116,7 +116,7 @@ const CreateAndUploadAction = ({
         {
           icon: <ImportIcon />,
           key: ActionType.uploadFile,
-          label: t('New Upload'),
+          label: t('Upload File'),
           onClick: onActionClick(ActionType.uploadFile)
         }
       ]

+ 2 - 2
desktop/core/src/desktop/js/reactComponents/DragAndDrop/DragAndDrop.test.tsx

@@ -29,7 +29,7 @@ describe('DragAndDrop', () => {
   it('should render the initial message when not dragging and children not present', () => {
     const { getByText } = render(<DragAndDrop onDrop={mockOnFilesDrop} />);
 
-    expect(getByText('Drag and Drop files or browse')).toBeInTheDocument();
+    expect(getByText('Drag and Drop files')).toBeInTheDocument();
   });
 
   it('should render children when provided and not dragging', () => {
@@ -49,7 +49,7 @@ describe('DragAndDrop', () => {
       </DragAndDrop>
     );
 
-    expect(queryByText('Drag and Drop files or browse')).not.toBeInTheDocument();
+    expect(queryByText('Drag and Drop files')).not.toBeInTheDocument();
     expect(getByText('Custom Child Element')).toBeInTheDocument();
   });
 

+ 2 - 2
desktop/core/src/desktop/js/reactComponents/DragAndDrop/DragAndDrop.tsx

@@ -41,9 +41,9 @@ const DragAndDrop = ({ children, onDrop }: DragAndDropProps): JSX.Element => {
         {!isDragActive && !children && (
           <div className="drag-drop__message">
             <div className="drag-drop__message__select-file">
-              <ImportIcon /> {t('Select files')}
+              <ImportIcon /> {t('Browse file')}
             </div>
-            <div>{t('Drag and Drop files or browse')}</div>
+            <div>{t('Drag and Drop files')}</div>
           </div>
         )}
         {!isDragActive && children}

+ 3 - 5
desktop/core/src/desktop/js/utils/hooks/useFileUpload/useRegularUpload.ts

@@ -40,7 +40,7 @@ const useRegularUpload = ({
   onStatusUpdate,
   onComplete
 }: UploadQueueOptions): UseUploadQueueResponse => {
-  const { save } = useSaveData(undefined, {
+  const { save } = useSaveData(UPLOAD_FILE_URL, {
     postOptions: {
       qsEncodeData: false,
       headers: {
@@ -52,13 +52,11 @@ const useRegularUpload = ({
   const processUploadItem = async (item: UploadItem) => {
     onStatusUpdate(item, FileUploadStatus.Uploading);
 
-    const url = `${UPLOAD_FILE_URL}?dest=${item.filePath}`;
-
     const payload = new FormData();
-    payload.append('hdfs_file', item.file);
+    payload.append('file', item.file);
+    payload.append('destination_path', item.filePath);
 
     return save(payload, {
-      url,
       onSuccess: () => {
         onStatusUpdate(item, FileUploadStatus.Uploaded);
       },