@@ -22,6 +22,13 @@ export default class extends Controller {
2222 windowSize : { type : Number , default : 20 } ,
2323 addToChatLabel : { type : String , default : "Add to chat" } ,
2424 openInNewTabLabel : { type : String , default : "Open in new tab" } ,
25+ uploadProcessingLabel : { type : String , default : "New images are being processed..." } ,
26+ refreshPromptLabel : { type : String , default : "New images are available. Refresh the asset list now?" } ,
27+ uploadProcessingDelayedErrorLabel : {
28+ type : String ,
29+ default : "Upload completed. New images are still processing. Please try again shortly." ,
30+ } ,
31+ uploadPartialFailureLabel : { type : String , default : "%errorCount% of %total% uploads failed." } ,
2532 // Upload configuration (optional - if not set, upload is disabled)
2633 uploadUrl : { type : String , default : "" } ,
2734 uploadCsrfToken : { type : String , default : "" } ,
@@ -49,6 +56,10 @@ export default class extends Controller {
4956 declare readonly windowSizeValue : number ;
5057 declare readonly addToChatLabelValue : string ;
5158 declare readonly openInNewTabLabelValue : string ;
59+ declare readonly uploadProcessingLabelValue : string ;
60+ declare readonly refreshPromptLabelValue : string ;
61+ declare readonly uploadProcessingDelayedErrorLabelValue : string ;
62+ declare readonly uploadPartialFailureLabelValue : string ;
5263 declare readonly uploadUrlValue : string ;
5364 declare readonly uploadCsrfTokenValue : string ;
5465 declare readonly workspaceIdValue : string ;
@@ -253,14 +264,14 @@ export default class extends Controller {
253264 if ( waitSucceeded ) {
254265 this . markRefreshAvailable ( ) ;
255266 } else {
256- this . showUploadError ( "Upload completed. New images are still processing. Please try again shortly." ) ;
267+ this . showUploadError ( this . uploadProcessingDelayedErrorLabelValue ) ;
257268 }
258269 }
259270
260271 if ( errorCount > 0 && successCount === 0 ) {
261- this . showUploadError ( "Upload failed. Please try again." ) ;
272+ this . showUploadError ( this . getUploadErrorFallbackLabel ( ) ) ;
262273 } else if ( errorCount > 0 ) {
263- this . showUploadError ( ` ${ errorCount } of ${ total } uploads failed.` ) ;
274+ this . showUploadError ( this . formatUploadPartialFailureLabel ( errorCount , total ) ) ;
264275 }
265276
266277 this . isUploading = false ;
@@ -539,8 +550,8 @@ export default class extends Controller {
539550 if ( this . hasUploadProcessingMessageTarget ) {
540551 this . uploadProcessingMessageTarget . textContent =
541552 this . uploadProcessingMode === "refreshPrompt"
542- ? "Neue Bilder sind verfügbar. Bildliste jetzt aktualisieren?"
543- : "Neue Bilder werden verarbeitet..." ;
553+ ? this . refreshPromptLabelValue
554+ : this . uploadProcessingLabelValue ;
544555 }
545556
546557 if ( this . hasUploadRefreshActionsTarget ) {
@@ -554,6 +565,22 @@ export default class extends Controller {
554565 setTimeout ( ( ) => this . showUploadStatus ( "none" ) , 3000 ) ;
555566 }
556567
568+ private formatUploadPartialFailureLabel ( errorCount : number , total : number ) : string {
569+ return this . uploadPartialFailureLabelValue
570+ . replaceAll ( "%errorCount%" , String ( errorCount ) )
571+ . replaceAll ( "%total%" , String ( total ) ) ;
572+ }
573+
574+ private getUploadErrorFallbackLabel ( ) : string {
575+ if ( this . hasUploadErrorTarget ) {
576+ const textEl = this . uploadErrorTarget . querySelector ( "[data-error-text]" ) ;
577+ if ( textEl && textEl . textContent !== null && textEl . textContent !== "" ) {
578+ return textEl . textContent ;
579+ }
580+ }
581+ return "Upload failed. Please try again." ;
582+ }
583+
557584 private normalizeManifestData ( data : { urls ?: string [ ] ; revision ?: string } ) : { urls : string [ ] ; revision : string } {
558585 const urls = data . urls ?? [ ] ;
559586 const revision = data . revision ?? this . computeManifestRevision ( urls ) ;
0 commit comments