@@ -21,6 +21,8 @@ import CaratDownIcon from '@cloudera/cuix-core/icons/react/CaratDownIcon';
2121import { BorderlessButton } from 'cuix/dist/components/Button' ;
2222import CaratUpIcon from '@cloudera/cuix-core/icons/react/CaratUpIcon' ;
2323import Modal from 'cuix/dist/components/Modal' ;
24+ import { TFunction } from 'i18next' ;
25+
2426import { i18nReact } from '../../utils/i18nReact' ;
2527import { RegularFile , FileStatus } from '../../utils/hooks/useFileUpload/types' ;
2628import useFileUpload from '../../utils/hooks/useFileUpload/useFileUpload' ;
@@ -66,17 +68,26 @@ const getCountByStatus = (uploadQueue: RegularFile[]) => {
6668 ) ;
6769} ;
6870
69- const getHeaderText = (
70- uploadQueue : RegularFile [ ] ,
71- uploadCountByStatus : { uploaded : number ; pending : number ; failed : number }
72- ) => {
73- const fileText = uploadQueue . length > 1 ? 'files' : 'file' ;
74- const uploadedText = `{{uploaded}} ${ fileText } uploaded` ;
75- const pendingText = uploadCountByStatus . pending > 0 ? `{{pending}} ${ fileText } remaining` : '' ;
76- const failedText = uploadCountByStatus . failed > 0 ? `, {{failed}} failed` : '' ;
71+ const getHeaderText = ( t : TFunction , uploadQueue : RegularFile [ ] ) => {
72+ const uploadCountByStatus = getCountByStatus ( uploadQueue ) ;
73+ const fileText = uploadQueue . length > 1 ? t ( 'files' ) : t ( 'file' ) ;
74+ const failedText =
75+ uploadCountByStatus . failed > 0
76+ ? t ( ', {{failed}} failed' , { failed : uploadCountByStatus . failed } )
77+ : '' ;
78+
79+ const pendingText = t ( '{{pending}} {{fileText}} remaining' , {
80+ pending : uploadCountByStatus . pending ,
81+ fileText
82+ } ) ;
7783 if ( uploadCountByStatus . pending > 0 ) {
7884 return `${ pendingText } ${ failedText } ` ;
7985 }
86+
87+ const uploadedText = t ( '{{uploaded}} {{fileText}} uploaded' , {
88+ uploaded : uploadQueue . length ,
89+ fileText
90+ } ) ;
8091 return `${ uploadedText } ${ failedText } ` ;
8192} ;
8293
@@ -160,7 +171,7 @@ const FileUploadQueue = (): JSX.Element => {
160171 const handleFileUploadStart = async ( data ?: FileUploadEvent ) => {
161172 const newFiles = data ?. files ?? [ ] ;
162173 if ( newFiles . length === 0 ) {
163- huePubSub . publish ( 'hue.global.error' , { message : 'Something went wrong!' } ) ;
174+ huePubSub . publish ( 'hue.global.error' , { message : t ( 'No new files to upload!' ) } ) ;
164175 return ;
165176 }
166177
@@ -190,9 +201,6 @@ const FileUploadQueue = (): JSX.Element => {
190201 setConflictingFiles ( [ ] ) ;
191202 } ;
192203
193- const uploadCountByStatus = getCountByStatus ( uploadQueue ) ;
194- const headerText = getHeaderText ( uploadQueue , uploadCountByStatus ) ;
195-
196204 if ( ! uploadQueue . length && conflictingFiles . length === 0 ) {
197205 return < > </ > ;
198206 }
@@ -234,7 +242,7 @@ const FileUploadQueue = (): JSX.Element => {
234242
235243 < div className = "hue-upload-queue-container antd cuix" >
236244 < div className = "hue-upload-queue-container__header" >
237- { t ( headerText , uploadCountByStatus ) }
245+ { getHeaderText ( t , uploadQueue ) }
238246 < div className = "hue-upload-queue-container__header__button-group" >
239247 < BorderlessButton
240248 onClick = { ( ) => setExpandQueue ( ! expandQueue ) }
0 commit comments