Skip to content

Commit

Permalink
ACS-8586: Remove internal dependency on PipeModule (#10086)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika authored Aug 12, 2024
1 parent 9527f06 commit 58484dd
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ import { NodeAspectService } from '../../../aspect-list/services/node-aspect.ser
import { ContentMetadataService } from '../../services/content-metadata.service';
import { AllowableOperationsEnum } from '../../../common/models/allowable-operations.enum';
import { of } from 'rxjs';
import { AlfrescoApiService, AlfrescoApiServiceMock, AuthModule, PipeModule, TranslationMock, TranslationService } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock, AuthModule, TranslationMock, TranslationService } from '@alfresco/adf-core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { versionCompatibilityFactory } from '../../../version-compatibility/version-compatibility-factory';
import { VersionCompatibilityService } from '../../../version-compatibility';
import { MatDialogModule } from '@angular/material/dialog';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { CategoryService } from '../../../category';
import { TagService } from '../../../tag';
import { PropertyDescriptorsService } from '../../public-api';
Expand All @@ -59,9 +58,7 @@ describe('ContentMetadataCardComponent', () => {
AuthModule.forRoot({ useHash: true }),
HttpClientModule,
MatDialogModule,
PipeModule,
MatSnackBarModule,
MatTooltipModule,
ContentMetadataCardComponent
],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
CardViewBaseItemModel,
CardViewComponent,
NotificationService,
PipeModule,
TranslationMock,
TranslationService,
UpdateNotification
Expand All @@ -51,8 +50,6 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { MatDialogModule } from '@angular/material/dialog';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatChipHarness } from '@angular/material/chips/testing';

Expand Down Expand Up @@ -193,9 +190,6 @@ describe('ContentMetadataComponent', () => {
HttpClientModule,
MatDialogModule,
MatSnackBarModule,
MatProgressBarModule,
MatTooltipModule,
PipeModule,
ContentMetadataComponent
],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
* limitations under the License.
*/

import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Node } from '@alfresco/js-api';
import { CardViewDateItemModel, CardViewTextItemModel, FileSizePipe } from '@alfresco/adf-core';
import { CardViewDateItemModel, CardViewTextItemModel, FileSizePipe, TranslationService } from '@alfresco/adf-core';

@Injectable({
providedIn: 'root'
})
export class BasicPropertiesService {

constructor(private fileSizePipe: FileSizePipe) {
}
private translationService = inject(TranslationService);

getProperties(node: Node) {
const sizeInBytes = node.content ? node.content.sizeInBytes : '';
Expand Down Expand Up @@ -63,7 +62,7 @@ export class BasicPropertiesService {
label: 'CORE.METADATA.BASIC.SIZE',
value: sizeInBytes,
key: 'content.sizeInBytes',
pipes: [{ pipe: this.fileSizePipe }],
pipes: [{ pipe: new FileSizePipe(this.translationService) }],
editable: false
}),
new CardViewTextItemModel({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import {
CardViewItemProperties,
CardViewItem,
Expand All @@ -30,7 +30,8 @@ import {
MultiValuePipe,
AppConfigService,
DecimalNumberPipe,
LogService
LogService,
UserPreferencesService
} from '@alfresco/adf-core';
import { Property, CardViewGroup, OrganisedPropertyGroup } from '../interfaces/content-metadata.interfaces';
import { of } from 'rxjs';
Expand All @@ -52,14 +53,13 @@ export const RECOGNISED_ECM_TYPES = [D_TEXT, D_MLTEXT, D_DATE, D_DATETIME, D_INT
providedIn: 'root'
})
export class PropertyGroupTranslatorService {
private userPreferenceService = inject(UserPreferencesService);
private appConfig = inject(AppConfigService);
private logService = inject(LogService);

valueSeparator: string;

constructor(
private multiValuePipe: MultiValuePipe,
private decimalNumberPipe: DecimalNumberPipe,
private appConfig: AppConfigService,
private logService: LogService
) {
constructor() {
this.valueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator');
}

Expand Down Expand Up @@ -137,7 +137,7 @@ export class PropertyGroupTranslatorService {
cardViewItemProperty = new CardViewIntItemModel(
Object.assign(propertyDefinition, {
multivalued: isMultiValued,
pipes: [{ pipe: this.multiValuePipe, params: [this.valueSeparator] }]
pipes: [{ pipe: new MultiValuePipe(), params: [this.valueSeparator] }]
})
);
break;
Expand All @@ -146,7 +146,7 @@ export class PropertyGroupTranslatorService {
cardViewItemProperty = new CardViewLongItemModel(
Object.assign(propertyDefinition, {
multivalued: isMultiValued,
pipes: [{ pipe: this.multiValuePipe, params: [this.valueSeparator] }]
pipes: [{ pipe: new MultiValuePipe(), params: [this.valueSeparator] }]
})
);
break;
Expand All @@ -156,7 +156,10 @@ export class PropertyGroupTranslatorService {
cardViewItemProperty = new CardViewFloatItemModel(
Object.assign(propertyDefinition, {
multivalued: isMultiValued,
pipes: [{ pipe: this.decimalNumberPipe }, { pipe: this.multiValuePipe, params: [this.valueSeparator] }]
pipes: [
{ pipe: new DecimalNumberPipe(this.userPreferenceService, this.appConfig) },
{ pipe: new MultiValuePipe(), params: [this.valueSeparator] }
]
})
);
break;
Expand All @@ -165,7 +168,7 @@ export class PropertyGroupTranslatorService {
cardViewItemProperty = new CardViewDateItemModel(
Object.assign(propertyDefinition, {
multivalued: isMultiValued,
pipes: [{ pipe: this.multiValuePipe, params: [this.valueSeparator] }]
pipes: [{ pipe: new MultiValuePipe(), params: [this.valueSeparator] }]
})
);
break;
Expand All @@ -174,7 +177,7 @@ export class PropertyGroupTranslatorService {
cardViewItemProperty = new CardViewDatetimeItemModel(
Object.assign(propertyDefinition, {
multivalued: isMultiValued,
pipes: [{ pipe: this.multiValuePipe, params: [this.valueSeparator] }]
pipes: [{ pipe: new MultiValuePipe(), params: [this.valueSeparator] }]
})
);
break;
Expand All @@ -189,7 +192,7 @@ export class PropertyGroupTranslatorService {
Object.assign(propertyDefinition, {
multivalued: isMultiValued,
multiline: isMultiValued,
pipes: [{ pipe: this.multiValuePipe, params: [this.valueSeparator] }]
pipes: [{ pipe: new MultiValuePipe(), params: [this.valueSeparator] }]
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import { NgModule } from '@angular/core';
import { DownloadZipDialogComponent } from './download-zip.dialog';
import { PipeModule } from '@alfresco/adf-core';
import { MatDialogModule } from '@angular/material/dialog';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatButtonModule } from '@angular/material/button';
Expand All @@ -26,14 +25,7 @@ import { CommonModule } from '@angular/common';

@NgModule({
declarations: [DownloadZipDialogComponent],
imports: [
CommonModule,
PipeModule,
MatDialogModule,
MatProgressBarModule,
MatButtonModule,
TranslateModule
],
imports: [CommonModule, MatDialogModule, MatProgressBarModule, MatButtonModule, TranslateModule],
exports: [DownloadZipDialogComponent]
})
export class DownloadZipDialogModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatChipHarness, MatChipListboxHarness } from '@angular/material/chips/testing';
import { MatButtonHarness } from '@angular/material/button/testing';
import { MatIconHarness } from '@angular/material/icon/testing';
import { MatChipsModule } from '@angular/material/chips';
import { MatMenuModule } from '@angular/material/menu';
import { MatButtonModule } from '@angular/material/button';
import { TranslateModule } from '@ngx-translate/core';
import { CoreTestingModule } from '@alfresco/adf-core';

describe('CardViewArrayItemComponent', () => {
let loader: HarnessLoader;
Expand All @@ -54,7 +51,7 @@ describe('CardViewArrayItemComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), MatMenuModule, MatButtonModule, MatChipsModule]
imports: [CoreTestingModule, CardViewArrayItemComponent]
});
fixture = TestBed.createComponent(CardViewArrayItemComponent);
service = TestBed.inject(CardViewUpdateService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,14 @@ import { CardViewUpdateService } from '../../services/card-view-update.service';
import { CardViewDateItemComponent } from './card-view-dateitem.component';
import { ClipboardService } from '../../../clipboard/clipboard.service';
import { CardViewDatetimeItemModel } from '../../models/card-view-datetimeitem.model';
import { TranslateModule } from '@ngx-translate/core';
import { AppConfigService } from '../../../app-config/app-config.service';
import { MatDatetimepickerInputEvent } from '@mat-datetimepicker/core';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatChipHarness } from '@angular/material/chips/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { TranslationMock } from '../../../mock';
import { TranslationService } from '../../../translation';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatDialogModule } from '@angular/material/dialog';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { addMinutes } from 'date-fns';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { CoreTestingModule } from '@alfresco/adf-core';

describe('CardViewDateItemComponent', () => {
let loader: HarnessLoader;
Expand All @@ -46,16 +39,7 @@ describe('CardViewDateItemComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
NoopAnimationsModule,
HttpClientTestingModule,
MatSnackBarModule,
MatDatepickerModule,
MatDialogModule,
MatTooltipModule
],
providers: [ClipboardService, { provide: TranslationService, useClass: TranslationMock }]
imports: [CoreTestingModule, MatSnackBarModule, CardViewDateItemComponent]
});
appConfigService = TestBed.inject(AppConfigService);
appConfigService.config.dateValues = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { By } from '@angular/platform-browser';
import { CardViewKeyValuePairsItemModel } from '../../models/card-view-keyvaluepairs.model';
import { CardViewKeyValuePairsItemComponent } from './card-view-keyvaluepairsitem.component';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { TranslateModule } from '@ngx-translate/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { CoreTestingModule } from '@alfresco/adf-core';

describe('CardViewKeyValuePairsItemComponent', () => {
let fixture: ComponentFixture<CardViewKeyValuePairsItemComponent>;
Expand All @@ -32,8 +31,7 @@ describe('CardViewKeyValuePairsItemComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, TranslateModule.forRoot(), CardViewKeyValuePairsItemComponent],
providers: [CardViewUpdateService]
imports: [CoreTestingModule, CardViewKeyValuePairsItemComponent]
});
fixture = TestBed.createComponent(CardViewKeyValuePairsItemComponent);
cardViewUpdateService = TestBed.inject(CardViewUpdateService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { By } from '@angular/platform-browser';
import { CardViewMapItemModel } from '../../models/card-view-mapitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { CardViewMapItemComponent } from './card-view-mapitem.component';
import { TranslateModule } from '@ngx-translate/core';
import { CoreTestingModule } from '@alfresco/adf-core';

describe('CardViewMapItemComponent', () => {
let service: CardViewUpdateService;
Expand All @@ -33,7 +33,7 @@ describe('CardViewMapItemComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()]
imports: [CoreTestingModule, CardViewMapItemComponent]
});
fixture = TestBed.createComponent(CardViewMapItemComponent);
service = TestBed.inject(CardViewUpdateService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatSelectHarness } from '@angular/material/select/testing';
import { MatFormFieldHarness } from '@angular/material/form-field/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MatSelectModule } from '@angular/material/select';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateModule } from '@ngx-translate/core';
import { CoreTestingModule } from '@alfresco/adf-core';

describe('CardViewSelectItemComponent', () => {
let loader: HarnessLoader;
Expand Down Expand Up @@ -62,7 +59,7 @@ describe('CardViewSelectItemComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, TranslateModule.forRoot(), HttpClientTestingModule, MatSelectModule]
imports: [CoreTestingModule, CardViewSelectItemComponent]
});
fixture = TestBed.createComponent(CardViewSelectItemComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { CardViewItemFloatValidator } from '../../validators/card-view-item-floa
import { CardViewItemIntValidator } from '../../validators/card-view-item-int.validator';
import { CardViewIntItemModel } from '../../models/card-view-intitem.model';
import { CardViewFloatItemModel } from '../../models/card-view-floatitem.model';
import { MatChipInputEvent, MatChipsModule } from '@angular/material/chips';
import { MatChipInputEvent } from '@angular/material/chips';
import { ClipboardService } from '../../../clipboard/clipboard.service';
import { DebugElement, SimpleChange } from '@angular/core';
import { CardViewItemValidator } from '../../interfaces/card-view-item-validator.interface';
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('CardViewTextItemComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule, MatChipsModule]
imports: [CoreTestingModule, CardViewTextItemComponent]
});
fixture = TestBed.createComponent(CardViewTextItemComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { By } from '@angular/platform-browser';
import { CardViewDateItemModel } from '../../models/card-view-dateitem.model';
import { CardViewTextItemModel } from '../../models/card-view-textitem.model';
import { CardViewComponent } from './card-view.component';
import { TranslateModule } from '@ngx-translate/core';
import { CardViewSelectItemModel } from '../../models/card-view-selectitem.model';
import { of } from 'rxjs';
import { CardViewSelectItemOption } from '../../interfaces/card-view-selectitem-properties.interface';
Expand All @@ -29,36 +28,19 @@ import { CardViewItemDispatcherComponent } from '../card-view-item-dispatcher/ca
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { MatSelectHarness } from '@angular/material/select/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { TranslationService } from '../../../translation';
import { TranslationMock } from '../../../mock';
import { MatTooltipModule } from '@angular/material/tooltip';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatDialogModule } from '@angular/material/dialog';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatSelectModule } from '@angular/material/select';
import { CoreTestingModule } from '@alfresco/adf-core';

describe('CardViewComponent', () => {
let loader: HarnessLoader;
let fixture: ComponentFixture<CardViewComponent>;
let component: CardViewComponent;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
NoopAnimationsModule,
MatSnackBarModule,
MatTooltipModule,
MatDialogModule,
MatDatepickerModule,
MatSelectModule,
HttpClientTestingModule,
CardViewComponent
],
providers: [{ provide: TranslationService, useClass: TranslationMock }]
}).compileComponents();
beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule, MatSnackBarModule, MatDialogModule, CardViewComponent]
});

fixture = TestBed.createComponent(CardViewComponent);
component = fixture.componentInstance;
Expand Down
Loading

0 comments on commit 58484dd

Please sign in to comment.