mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
pre angular 15 cleanup (#8961)
* pre angular 15 cleanup * [ci:force] update test * [ci:force] various updates as per migration * [ci:force] port more changes * [ci:force] migrate tests * [ci:force] migrate formatting * migrate changes * rollback storybook
This commit is contained in:
@@ -504,12 +504,16 @@ describe('CategoriesManagementComponent', () => {
|
||||
describe('Errors', () => {
|
||||
it('should display validation error when searching for empty category', fakeAsync(() => {
|
||||
typeCategory(' ');
|
||||
component.categoryNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getFirstError()).toBe('CATEGORIES_MANAGEMENT.ERRORS.EMPTY_CATEGORY');
|
||||
}));
|
||||
|
||||
it('should show error for required', fakeAsync(() => {
|
||||
typeCategory('');
|
||||
component.categoryNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getFirstError()).toBe('CATEGORIES_MANAGEMENT.ERRORS.REQUIRED');
|
||||
}));
|
||||
@@ -534,6 +538,7 @@ describe('CategoriesManagementComponent', () => {
|
||||
it('should show error for required when not typed anything and blur input', fakeAsync(() => {
|
||||
typeCategory('');
|
||||
getCategoryControlInput().blur();
|
||||
component.categoryNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(getFirstError()).toBe('CATEGORIES_MANAGEMENT.ERRORS.REQUIRED');
|
||||
|
@@ -116,7 +116,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
displayCategories = false;
|
||||
|
||||
private _assignedTags: string[] = [];
|
||||
private assignedTagsEntries: TagEntry[];
|
||||
private assignedTagsEntries: TagEntry[] = [];
|
||||
private _editable = false;
|
||||
private _tagsCreatorMode = TagsCreatorMode.CREATE_AND_ASSIGN;
|
||||
private _tags: string[] = [];
|
||||
@@ -318,7 +318,7 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||
this._saving = false;
|
||||
return of(null);
|
||||
}))
|
||||
.subscribe((result) => {
|
||||
.subscribe((result: any) => {
|
||||
if (result) {
|
||||
this.updateUndefinedNodeProperties(result.updatedNode);
|
||||
if (this.hasContentTypeChanged(this.changedProperties)) {
|
||||
|
@@ -80,7 +80,7 @@ describe('PropertyDescriptorLoaderService', () => {
|
||||
expect(data['exif:exif']).toBe(exifResponse);
|
||||
expect(data['cm:content']).toBe(contentResponse);
|
||||
},
|
||||
complete: done
|
||||
complete: () => done()
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -296,7 +296,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
const adfUploadButton = fixture.debugElement.query(By.css('adf-upload-button'));
|
||||
|
||||
expect(adfUploadButton).not.toBeNull();
|
||||
expect(adfUploadButton.nativeElement.innerText).toEqual('file_uploadFORM.FIELD.UPLOAD');
|
||||
expect(adfUploadButton.nativeElement.textContent).toEqual('file_uploadFORM.FIELD.UPLOAD');
|
||||
});
|
||||
|
||||
it('should be able to disable UploadButton if showingSearch set to true', () => {
|
||||
|
@@ -31,7 +31,7 @@
|
||||
[style.display]="isExpiryDateToggleChecked ? 'block' : 'none'"
|
||||
data-automation-id="adf-slide-toggle-checked"
|
||||
class="adf-share-link__date-time-container">
|
||||
<mat-form-field class="adf-full-width adf-float-label" floatLabel='never'>
|
||||
<mat-form-field class="adf-full-width adf-float-label">
|
||||
<mat-label>{{ 'SHARE.EXPIRATION-PLACEHOLDER' | translate }}</mat-label>
|
||||
<mat-datepicker-toggle
|
||||
[disabled]="time.disabled"
|
||||
@@ -74,7 +74,6 @@
|
||||
</div>
|
||||
<mat-form-field
|
||||
class="adf-full-width adf-float-label"
|
||||
floatLabel='never'
|
||||
[ngClass]="isLinkWithExpiryDate? 'adf-share-link__border-color' : ''">
|
||||
<input
|
||||
#sharedLinkInput
|
||||
|
@@ -18,13 +18,7 @@
|
||||
import { Component, Inject, OnInit, ViewEncapsulation, ViewChild, OnDestroy } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
|
||||
import {
|
||||
UntypedFormGroup,
|
||||
UntypedFormControl,
|
||||
AbstractControl,
|
||||
Validators,
|
||||
ValidationErrors
|
||||
} from '@angular/forms';
|
||||
import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { Subject } from 'rxjs';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
import { SharedLinksApiService } from './services/shared-links-api.service';
|
||||
@@ -44,9 +38,8 @@ type DatePickerType = 'date' | 'time' | 'month' | 'datetime';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
private minDateValidator = (control: AbstractControl): ValidationErrors | null => {
|
||||
return isBefore(endOfDay(new Date(control.value)), this.minDate) ? {invalidDate: true} : null;
|
||||
};
|
||||
private minDateValidator = (control: AbstractControl): any =>
|
||||
isBefore(endOfDay(new Date(control.value)), this.minDate) ? { invalidDate: true } : null;
|
||||
|
||||
minDate = add(new Date(), { days: 1 });
|
||||
sharedId: string;
|
||||
@@ -55,9 +48,9 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
isFileShared = false;
|
||||
isDisabled = false;
|
||||
isLinkWithExpiryDate = false;
|
||||
form: UntypedFormGroup = new UntypedFormGroup({
|
||||
sharedUrl: new UntypedFormControl(''),
|
||||
time: new UntypedFormControl({value: '', disabled: true}, [Validators.required, this.minDateValidator])
|
||||
form: FormGroup = new FormGroup({
|
||||
sharedUrl: new FormControl(''),
|
||||
time: new FormControl({ value: '', disabled: true }, [Validators.required, this.minDateValidator])
|
||||
});
|
||||
type: DatePickerType = 'date';
|
||||
maxDebounceTime = 500;
|
||||
|
@@ -161,7 +161,7 @@ describe('Confirm Dialog Component', () => {
|
||||
By.css('[data-automation-id="adf-confirm-dialog-confirm-all"]')
|
||||
);
|
||||
expect(thirdOptionElement).not.toBeNull();
|
||||
expect(thirdOptionElement.nativeElement.innerText).toBe('YES ALL');
|
||||
expect(thirdOptionElement.nativeElement.innerText.toUpperCase()).toBe('YES ALL');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -341,7 +341,7 @@ describe('DocumentList', () => {
|
||||
documentList.executeContentAction(node, action);
|
||||
|
||||
expect(action.execute).not.toHaveBeenCalled();
|
||||
deleteObservable.next();
|
||||
deleteObservable.next(undefined);
|
||||
expect(action.execute).toHaveBeenCalledWith(node);
|
||||
});
|
||||
|
||||
|
@@ -21,7 +21,7 @@ import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { MatOptionModule, MatRippleModule } from '@angular/material/core';
|
||||
import { MatRippleModule, MatOptionModule } from '@angular/material/core';
|
||||
import { MatDatepickerModule } from '@angular/material/datepicker';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatExpansionModule } from '@angular/material/expansion';
|
||||
|
@@ -83,7 +83,7 @@ describe('AddPermissionDialog', () => {
|
||||
it('should show the INJECTED title', () => {
|
||||
const titleElement = fixture.debugElement.query(By.css('#add-permission-dialog-title'));
|
||||
expect(titleElement).not.toBeNull();
|
||||
expect(titleElement.nativeElement.innerText).toBe('dead or alive you are coming with me');
|
||||
expect(titleElement.nativeElement.innerText.trim()).toBe('dead or alive you are coming with me');
|
||||
});
|
||||
|
||||
it('should close the dialog when close button is clicked', () => {
|
||||
@@ -128,7 +128,7 @@ describe('AddPermissionDialog', () => {
|
||||
await fixture.whenStable();
|
||||
|
||||
const selectBox = fixture.debugElement.query(By.css(('[id="adf-select-role-permission"] .mat-select-trigger')));
|
||||
selectBox.triggerEventHandler('click', null);
|
||||
selectBox.nativeElement.dispatchEvent(new Event('click'));
|
||||
fixture.detectChanges();
|
||||
|
||||
const options = fixture.debugElement.queryAll(By.css('mat-option'));
|
||||
@@ -171,7 +171,7 @@ describe('AddPermissionDialog', () => {
|
||||
await fixture.whenStable();
|
||||
|
||||
const selectBox = fixture.debugElement.query(By.css(('[id="adf-bulk-select-role-permission"] .mat-select-trigger')));
|
||||
selectBox.triggerEventHandler('click', null);
|
||||
selectBox.nativeElement.dispatchEvent(new Event('click'));
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@@ -213,7 +213,7 @@ describe('AddPermissionDialog', () => {
|
||||
await fixture.whenStable();
|
||||
|
||||
const selectBox = fixture.debugElement.query(By.css(('[id="adf-select-role-permission"] .mat-select-trigger')));
|
||||
selectBox.triggerEventHandler('click', null);
|
||||
selectBox.nativeElement.dispatchEvent(new Event('click'));
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
@@ -41,7 +41,7 @@
|
||||
<mat-list-option id="adf-add-permission-group-everyone"
|
||||
class="adf-list-option-item"
|
||||
#eveyone
|
||||
disableRipple
|
||||
[disableRipple]="true"
|
||||
[value]="EVERYONE">
|
||||
<adf-user-icon-column [node]="EVERYONE" id="add-group-icon" [selected]="eveyone.selected"></adf-user-icon-column>
|
||||
<p class="adf-result-name">
|
||||
@@ -50,7 +50,7 @@
|
||||
</mat-list-option>
|
||||
|
||||
<mat-list-option *ngFor="let item of data?.list?.entries; let idx = index"
|
||||
disableRipple
|
||||
[disableRipple]="true"
|
||||
[value]="item"
|
||||
class="adf-list-option-item"
|
||||
id="result_option_{{idx}}"
|
||||
|
@@ -21,7 +21,7 @@ import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
import { fakeAuthorityListResult, fakeNameListResult } from '../../../mock/add-permission.component.mock';
|
||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||
import { SearchService } from '../../../search/services/search.service';
|
||||
import { SearchService } from '../../../search/services/search.service';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatIconTestingModule } from '@angular/material/icon/testing';
|
||||
|
@@ -82,7 +82,7 @@ export class PermissionListService {
|
||||
|
||||
toggleInherited(change: MatSlideToggleChange) {
|
||||
if (this.contentService.hasAllowableOperations(this.node, AllowableOperationsEnum.UPDATEPERMISSIONS)) {
|
||||
let updateLocalPermission$ = of(null);
|
||||
let updateLocalPermission$: Observable<Node> = of(null);
|
||||
const nodeBody = {
|
||||
permissions: {
|
||||
isInheritanceEnabled: !this.node.permissions.isInheritanceEnabled
|
||||
|
@@ -72,7 +72,7 @@ export class PopOverDirective implements OnInit, OnDestroy, AfterViewInit {
|
||||
ngOnDestroy(): void {
|
||||
this.element.nativeElement.removeEventListener('keydown', this.preventDefaultForEnter);
|
||||
this.detachOverlay();
|
||||
this.destroy$.next();
|
||||
this.destroy$.next(undefined);
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
|
@@ -422,7 +422,7 @@ export class SearchFacetFiltersService implements OnDestroy {
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.next(undefined);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,7 @@ describe('TagService', () => {
|
||||
});
|
||||
|
||||
describe('createTags', () => {
|
||||
it('should call createTags on tagsApi', () => {
|
||||
it('should call createTags on tagsApi', (done) => {
|
||||
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve([]));
|
||||
const tag1 = new TagBody();
|
||||
tag1.tag = 'Some tag 1';
|
||||
@@ -98,7 +98,9 @@ describe('TagService', () => {
|
||||
tag2.tag = 'Some tag 2';
|
||||
const tags = [tag1, tag2];
|
||||
service.createTags(tags);
|
||||
|
||||
expect(service.tagsApi.createTags).toHaveBeenCalledWith(tags);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should emit refresh when tags creation is success', fakeAsync(() => {
|
||||
|
@@ -381,12 +381,15 @@ describe('TagsCreatorComponent', () => {
|
||||
|
||||
it('should show error for only spaces', fakeAsync(() => {
|
||||
typeTag(' ');
|
||||
component.tagNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
const error = getFirstError();
|
||||
expect(error).toBe('TAG.TAGS_CREATOR.ERRORS.EMPTY_TAG');
|
||||
}));
|
||||
|
||||
it('should show error for only spaces if tags are changed', fakeAsync(() => {
|
||||
typeTag(' ');
|
||||
component.tagNameControl.markAsTouched();
|
||||
component.tags = ['new tag 1', 'new tag 2'];
|
||||
fixture.detectChanges();
|
||||
expect(getFirstError()).toBe('TAG.TAGS_CREATOR.ERRORS.EMPTY_TAG');
|
||||
@@ -394,12 +397,15 @@ describe('TagsCreatorComponent', () => {
|
||||
|
||||
it('should show error for required', fakeAsync(() => {
|
||||
typeTag('');
|
||||
component.tagNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
const error = getFirstError();
|
||||
expect(error).toBe('TAG.TAGS_CREATOR.ERRORS.REQUIRED');
|
||||
}));
|
||||
|
||||
it('should not show error for required if tags are changed', fakeAsync(() => {
|
||||
typeTag('');
|
||||
component.tagNameControl.markAsTouched();
|
||||
component.tags = ['new tag 1', 'new tag 2'];
|
||||
fixture.detectChanges();
|
||||
expect(getFirstError()).toBeUndefined();
|
||||
@@ -443,10 +449,7 @@ describe('TagsCreatorComponent', () => {
|
||||
|
||||
it('should error for required when not typed anything and blur input', fakeAsync(() => {
|
||||
component.tagNameControlVisible = true;
|
||||
fixture.detectChanges();
|
||||
tick(100);
|
||||
|
||||
getNameInput().blur();
|
||||
component.tagNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
|
||||
const error = getFirstError();
|
||||
@@ -600,6 +603,8 @@ describe('TagsCreatorComponent', () => {
|
||||
);
|
||||
|
||||
typeTag('Tag');
|
||||
component.tagNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
|
||||
const tagElements = getExistingTags();
|
||||
expect(tagElements).toEqual([tag1, tag2]);
|
||||
@@ -782,6 +787,8 @@ describe('TagsCreatorComponent', () => {
|
||||
|
||||
it('should be displayed when existing tags are loading', fakeAsync(() => {
|
||||
typeTag('tag', 0);
|
||||
component.tagNameControl.markAsTouched();
|
||||
fixture.detectChanges();
|
||||
|
||||
const spinner = getSpinner();
|
||||
expect(spinner).toBeTruthy();
|
||||
|
@@ -104,9 +104,9 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
if (this.filesUploadingList.length && !this.isDialogActive) {
|
||||
this.isDialogActive = true;
|
||||
this.dialogActive.next();
|
||||
this.dialogActive.next(undefined);
|
||||
} else {
|
||||
this.dialogActive.next();
|
||||
this.dialogActive.next(undefined);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -159,7 +159,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
this.isConfirmation = !this.isConfirmation;
|
||||
|
||||
if (!this.isConfirmation) {
|
||||
this.dialogActive.next();
|
||||
this.dialogActive.next(undefined);
|
||||
}
|
||||
|
||||
if (this.isDialogMinimized) {
|
||||
@@ -172,7 +172,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
cancelAllUploads() {
|
||||
this.toggleConfirmation();
|
||||
this.dialogActive.next();
|
||||
this.dialogActive.next(undefined);
|
||||
this.uploadList.cancelAllFiles();
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ import { DiscoveryApiService } from '../common/services/discovery-api.service';
|
||||
export class VersionCompatibilityService {
|
||||
private acsVersion: VersionInfo;
|
||||
|
||||
acsVersionInitialized$ = new ReplaySubject();
|
||||
acsVersionInitialized$ = new ReplaySubject<void>();
|
||||
|
||||
constructor(private discoveryApiService: DiscoveryApiService) {
|
||||
this.discoveryApiService.ecmProductInfo$
|
||||
@@ -37,7 +37,7 @@ export class VersionCompatibilityService {
|
||||
|
||||
private initializeAcsVersion(acsVersion: VersionInfo) {
|
||||
this.acsVersion = acsVersion;
|
||||
this.acsVersionInitialized$.next();
|
||||
this.acsVersionInitialized$.next(undefined);
|
||||
}
|
||||
|
||||
getAcsVersion(): VersionInfo {
|
||||
|
@@ -75,7 +75,7 @@ describe('VersionUploadComponent', () => {
|
||||
expect(component.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
uploadService.fileUploadStarting.next();
|
||||
uploadService.fileUploadStarting.next(undefined);
|
||||
});
|
||||
|
||||
it('should enable upload button on error', () => {
|
||||
|
@@ -36,7 +36,7 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
|
||||
comment: string;
|
||||
uploadVersion: boolean = false;
|
||||
disabled: boolean = false;
|
||||
onDestroy$ = new Subject();
|
||||
onDestroy$ = new Subject<void>();
|
||||
majorVersion = '2.0';
|
||||
minorVersion = '1.1';
|
||||
|
||||
@@ -133,7 +133,7 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next();
|
||||
this.onDestroy$.next(undefined);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
|
@@ -170,7 +170,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
|
||||
/** Emitted when the shared link used is not valid. */
|
||||
@Output()
|
||||
invalidSharedLink = new EventEmitter();
|
||||
invalidSharedLink = new EventEmitter<void>();
|
||||
|
||||
/** Emitted when user clicks 'Navigate Before' ("<") button. */
|
||||
@Output()
|
||||
@@ -272,7 +272,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
await this.setUpSharedLinkFile(sharedLinkEntry);
|
||||
} catch (error) {
|
||||
this.logService.error('This sharedLink does not exist');
|
||||
this.invalidSharedLink.next();
|
||||
this.invalidSharedLink.next(undefined);
|
||||
this.mimeType = 'invalid-link';
|
||||
this.urlFileContent = 'invalid-file';
|
||||
}
|
||||
|
Reference in New Issue
Block a user