[ACS-7679] Reduce the usage of AppConfigService in components and tests (#9563)

* remove unused app config setting

* remove unused app config setting

* remove unnecessary app config service reference

* remove unnecessary app config service reference

* remove unnecessary app config service reference

* remove unnecessary app config service reference

* remove unnecessary app config service reference

* support input params for the viewer; optional configuration

* remove useless imports [ci:force]

* fix imports [ci:force]
This commit is contained in:
Denys Vuika
2024-04-18 07:26:55 -04:00
committed by GitHub
parent 99ae729314
commit 4132517ba7
12 changed files with 51 additions and 128 deletions

View File

@@ -17,14 +17,12 @@
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { NodeEntry, Node, SitePaging, Site } from '@alfresco/js-api';
import { AppConfigService } from '@alfresco/adf-core';
import { DocumentListService } from '../document-list/services/document-list.service';
import { DocumentListService, NodeAction } from '../document-list';
import { ContentNodeDialogService } from './content-node-dialog.service';
import { MatDialog } from '@angular/material/dialog';
import { Subject, of } from 'rxjs';
import { ContentTestingModule } from '../testing/content.testing.module';
import { NodeAction } from '../document-list/models/node-action.enum';
import { SitesService } from '../common/services/sites.service';
import { SitesService } from '../common';
const fakeNodeEntry = {
entry: {
@@ -71,9 +69,6 @@ describe('ContentNodeDialogService', () => {
TestBed.configureTestingModule({
imports: [ContentTestingModule]
});
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
service = TestBed.inject(ContentNodeDialogService);
documentListService = TestBed.inject(DocumentListService);
materialDialog = TestBed.inject(MatDialog);

View File

@@ -19,12 +19,8 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Node, NodeEntry, NodePaging, ResultSetPaging, Site, SiteEntry, SitePaging, SitePagingList, UserInfo } from '@alfresco/js-api';
import { AppConfigService, DataRow, ThumbnailService, DataColumn } from '@alfresco/adf-core';
import { ContentService } from '../common/services/content.service';
import { UploadService } from '../common/services/upload.service';
import { NodesApiService } from '../common/services/nodes-api.service';
import { FileModel, FileUploadStatus } from '../common/models/file.model';
import { FileUploadCompleteEvent } from '../common/events/file.event';
import { DataRow, ThumbnailService, DataColumn } from '@alfresco/adf-core';
import { ContentService, UploadService, NodesApiService, SitesService, FileModel, FileUploadStatus, FileUploadCompleteEvent } from '../common';
import { of, throwError } from 'rxjs';
import { DropdownBreadcrumbComponent } from '../breadcrumb';
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
@@ -35,7 +31,6 @@ import { NodeEntryEvent, ShareDataRow, ShareDataTableAdapter } from '../document
import { SearchQueryBuilderService } from '../search';
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
import { mockContentModelTextProperty } from '../mock/content-model.mock';
import { SitesService } from '../common/services/sites.service';
const fakeResultSetPaging: ResultSetPaging = {
list: {
@@ -732,32 +727,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
});
});
describe('Sorting', () => {
let appConfigService: AppConfigService;
beforeEach(() => {
appConfigService = TestBed.inject(AppConfigService);
});
it('should read the sorting value from appConfig json in case it is present', async () => {
const fakeSortingConfig = ['fakeKey', 'fakeAsc'];
appConfigService.config = Object.assign(appConfigService.config, {
'adf-content-node-selector': { sorting: fakeSortingConfig }
});
fixture.detectChanges();
expect(component.sorting).toEqual(fakeSortingConfig);
});
it('should take default sorting when there is no content node selector sorting config in appConfig json', async () => {
appConfigService.config = null;
fixture.detectChanges();
expect(component.sorting).toEqual(['createdAt', 'desc']);
});
});
describe('Selected nodes counter', () => {
it('should getSelectedCount return 0 by default', () => {
expect(component.getSelectedCount()).toBe(0);

View File

@@ -22,26 +22,22 @@ import {
UserPreferenceValues,
InfinitePaginationComponent,
PaginatedComponent,
AppConfigService,
DataSorting,
ShowHeaderMode
} from '@alfresco/adf-core';
import { NodesApiService } from '../common/services/nodes-api.service';
import { UploadService } from '../common/services/upload.service';
import { FileUploadCompleteEvent, FileUploadDeleteEvent } from '../common/events/file.event';
import { NodesApiService, UploadService, FileUploadCompleteEvent, FileUploadDeleteEvent, SitesService } from '../common';
import { UntypedFormControl } from '@angular/forms';
import { Node, NodePaging, Pagination, SiteEntry, SitePaging, NodeEntry, SearchRequest, RequestScope } from '@alfresco/js-api';
import { DocumentListComponent } from '../document-list/components/document-list.component';
import { RowFilter } from '../document-list/data/row-filter.model';
import { ImageResolver } from '../document-list/data/image-resolver.model';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { CustomResourcesService } from '../document-list/services/custom-resources.service';
import { ShareDataRow } from '../document-list/data/share-data-row.model';
import { Subject } from 'rxjs';
import { SearchQueryBuilderService } from '../search/services/search-query-builder.service';
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
import { NodeEntryEvent } from '../document-list/components/node.event';
import { SitesService } from '../common/services/sites.service';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { SearchQueryBuilderService } from '../search';
import { ContentNodeSelectorPanelService } from './content-node-selector-panel.service';
export type ValidationFunction = (entry: Node) => boolean;
@@ -262,7 +258,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
preselectedNodes: NodeEntry[] = [];
currentUploadBatch: NodeEntry[] = [];
sorting: string[] | DataSorting;
sorting: string[] | DataSorting = ['createdAt', 'desc'];
searchPanelExpanded: boolean = false;
@@ -275,7 +271,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
private nodesApiService: NodesApiService,
private uploadService: UploadService,
private sitesService: SitesService,
private appConfigService: AppConfigService,
private contentNodeSelectorPanelService: ContentNodeSelectorPanelService
) {}
@@ -347,8 +342,6 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
this.documentList.$folderNode.pipe(takeUntil(this.onDestroy$)).subscribe((currentNode: Node) => {
this.currentFolder.emit(currentNode);
});
this.sorting = this.appConfigService.get('adf-content-node-selector.sorting', ['createdAt', 'desc']);
}
ngOnDestroy() {