diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.spec.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.spec.ts index eee7a8e2fe2f..e32dfde93779 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.spec.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.spec.ts @@ -290,6 +290,23 @@ describe('DotBinaryFieldEditorComponent', () => { expect(component.form.valid).toBe(false); })); + it('should set form as valid when there is no extension', fakeAsync(() => { + dotBinaryFieldValidatorService.setAccept([]); + spectator.detectChanges(); + + const spy = jest.spyOn(component.name, 'setErrors'); + + component.form.setValue({ + name: 'testNoExtension', + content: 'test' + }); + + tick(1000); + + expect(spy).not.toHaveBeenCalled(); + expect(component.form.valid).toBe(true); + })); + afterEach(() => { jest.restoreAllMocks(); }); diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts index c826cfdbbed1..ad83b373a4c7 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.ts @@ -68,7 +68,7 @@ export class DotBinaryFieldEditorComponent implements OnInit, OnChanges { @Output() readonly cancel = new EventEmitter(); @ViewChild('editorRef', { static: true }) editorRef!: MonacoEditorComponent; readonly form = new FormGroup({ - name: new FormControl('', [Validators.required, Validators.pattern(/^[^.]+\.[^.]+$/)]), + name: new FormControl('', [Validators.required]), content: new FormControl('') }); mimeType = ''; @@ -189,7 +189,7 @@ export class DotBinaryFieldEditorComponent implements OnInit, OnChanges { this.updateLanguageForFileExtension(fileExtension); } - this.validateFileType(fileExtension); + this.validateFileType(); this.cd.detectChanges(); } @@ -210,13 +210,12 @@ export class DotBinaryFieldEditorComponent implements OnInit, OnChanges { this.updateEditorLanguage(id); } - private validateFileType(fileExtension: string) { + private validateFileType() { const isValidType = this.dotBinaryFieldValidatorService.isValidType({ extension: this.extension, mimeType: this.mimeType }); - - if (fileExtension && !isValidType) { + if (!isValidType) { this.name.setErrors({ invalidExtension: this.invalidFileMessage }); } } diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts index 10f1c18a9409..bf8c1482042f 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts @@ -99,7 +99,9 @@ export const FileFieldStore = signalStore( }); }, /** - * setAcceptedFiles is used to set accepted files + * Sets the maximum file size allowed for uploads. + * + * @param {number} maxFileSize - The maximum file size. */ setMaxSizeFile: (maxFileSize: number) => { patchState(store, {