Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api-goldens/element-ng/file-uploader/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ export class SiFileUploaderModule {

// @public (undocumented)
export interface UploadFile {
// (undocumented)
errorParams?: Record<string, unknown>;
// (undocumented)
errorText?: TranslatableString;
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,15 @@ describe('SiFileDropzoneComponent', () => {
});

it('should reject files that exceeds "maxFileSize" parameter', async () => {
maxFileSize.set(1000);
errorTextFileMaxSize.set('File exceeds allowed maximum size');
maxFileSize.set(1024);
errorTextFileMaxSize.set('File exceeds allowed maximum size of {{maxFileSize}}');
await fixture.whenStable();
dropFiles(createFileListWithFileSizeOf1200Bytes(['notMatching.fmwr']));
await fixture.whenStable();
const files = getFiles();
expect(files[0].status).toBe('invalid');
expect(files[0].errorText).toBe('File exceeds allowed maximum size');
expect(files[0].errorText).toBe('File exceeds allowed maximum size of {{maxFileSize}}');
expect(files[0].errorParams).toEqual({ maxFileSize: '1KB' });
});

it('should accept files that less than or equal to "maxFileSize" parameter', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ export class SiFileDropzoneComponent {
*
* @defaultValue
* ```
* t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`)
* t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size of {{maxFileSize}}`)
* ```
*/
readonly errorTextFileMaxSize = input(
t(
() =>
$localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`
$localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size of {{maxFileSize}}`
)
);
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ export class SiFileUploadDirective {
*
* @defaultValue
* ```
* t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`)
* t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size of {{maxFileSize}}`)
Comment thread
spike-rabbit marked this conversation as resolved.
* ```
*/
readonly errorTextFileMaxSize = input(
t(
() =>
$localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`
$localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size of {{maxFileSize}}`
)
);

Expand Down Expand Up @@ -253,6 +253,7 @@ export class SiFileUploadDirective {
} else if (!this.verifyFileSize(uploadFile.file.size)) {
uploadFile.status = 'invalid';
uploadFile.errorText = this.errorTextFileMaxSize();
uploadFile.errorParams = { maxFileSize: this.fileSizeToString(this.maxFileSize()!) };
}
return uploadFile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
class="icon-sm"
[status]="file.status === 'invalid' ? 'warning' : 'danger'"
/>
{{ file.errorText | translate }}
{{ file.errorText | translate: file.errorParams }}
@if (file.httpErrorText) {
: {{ file.httpErrorText }}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ describe('SiFileUploaderComponent', () => {
});

it('should reject files that exceeds "maxFileSize" parameter', async () => {
maxFileSize.set(1000);
errorTextFileMaxSize.set('File exceeds allowed maximum size');
maxFileSize.set(1024);
errorTextFileMaxSize.set('File exceeds allowed maximum size of {{maxFileSize}}');
await handleFiles(createFileListWithFileSizeOf1200Bytes(['notMatching.fmwr']));
expect(getError()!).toHaveTextContent('File exceeds allowed maximum size');
expect(getError()!).toHaveTextContent('File exceeds allowed maximum size of 1KB');
});

it('should accept files that less than or equal to "maxFileSize" parameter', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ export class SiFileUploaderComponent implements OnChanges {
*
* @defaultValue
* ```
* t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`)
* t(() => $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size of {{maxFileSize}}`)
* ```
*/
readonly errorTextFileMaxSize = input(
t(
() =>
$localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`
$localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size of {{maxFileSize}}`
)
);
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export interface UploadFile {
fileName: string;
size: string;
errorText?: TranslatableString;
errorParams?: Record<string, unknown>;
progress: number;
}
Loading