[AAE-7242] fix eslint warnings for content services project (#7505)

* fix eslint warnings for content services project

* fix typing issues
This commit is contained in:
Denys Vuika
2022-02-17 15:23:38 +00:00
committed by GitHub
parent bca5a783ab
commit 9f72e30fbc
158 changed files with 2604 additions and 2715 deletions

View File

@@ -26,17 +26,17 @@ import { ContentTestingModule } from '../testing/content.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { NodeAction } from '../document-list/models/node-action.enum';
const fakeNodeEntry: NodeEntry = <NodeEntry> {
const fakeNodeEntry = {
entry: {
id: 'fake',
name: 'fake-name'
}
};
} as NodeEntry;
const fakeNode: Node = <Node> {
const fakeNode = {
id: 'fake',
name: 'fake-name'
};
} as Node;
const fakeSiteList: SitePaging = new SitePaging({
list: {
@@ -94,10 +94,10 @@ describe('ContentNodeDialogService', () => {
});
it('should not open the lock node dialog if have no permission', () => {
const testNode: Node = <Node> {
const testNode = {
id: 'fake',
isFile: false
};
} as Node;
service.openLockNodeDialog(testNode).subscribe(() => {
}, (error) => {
@@ -143,26 +143,26 @@ describe('ContentNodeDialogService', () => {
}));
describe('for the copy/move dialog', () => {
const siteNode: Node = <Node> {
const siteNode: Node = {
id: 'site-node-id',
nodeType: 'st:site'
};
const sites: Node = <Node> {
} as Node;
const sites: Node = {
id: 'sites-id',
nodeType: 'st:sites'
};
const site: Site = <Site> {
} as Node;
const site: Site = {
id: 'site-id',
guid: 'any-guid'
};
const nodeEntryWithRightPermissions: Node = <Node> {
} as Site;
const nodeEntryWithRightPermissions: Node = {
id: 'node-id',
allowableOperations: ['create']
};
const nodeEntryNoPermissions: Node = <Node> {
} as Node;
const nodeEntryNoPermissions: Node = {
id: 'node-id',
allowableOperations: []
};
} as Node;
const siteFixture = [
{

View File

@@ -57,17 +57,17 @@ export class ContentNodeDialogService {
/**
* Opens a file browser at a chosen folder location.
* shows files and folders in the dialog search result.
*
* @param folderNodeId ID of the folder to use
* @returns Information about the selected file(s)
*/
openFileBrowseDialogByFolderId(folderNodeId: string): Observable<Node[]> {
return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((nodeEntry: NodeEntry) => {
return this.openUploadFileDialog(NodeAction.CHOOSE, nodeEntry.entry, true);
}));
return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((nodeEntry: NodeEntry) => this.openUploadFileDialog(NodeAction.CHOOSE, nodeEntry.entry, true)));
}
/**
* Opens a lock node dialog.
*
* @param contentEntry Node to lock
* @returns Error/status message (if any)
*/
@@ -95,17 +95,17 @@ export class ContentNodeDialogService {
/**
* Opens a file browser at a chosen site location.
* shows files and folders in the dialog search result.
*
* @returns Information about the selected file(s)
*/
openFileBrowseDialogBySite(): Observable<Node[]> {
return this.siteService.getSites().pipe(switchMap((response: SitePaging) => {
return this.openFileBrowseDialogByFolderId(response.list.entries[0].entry.guid);
}));
return this.siteService.getSites().pipe(switchMap((response: SitePaging) => this.openFileBrowseDialogByFolderId(response.list.entries[0].entry.guid)));
}
/**
* Opens a file browser at a default myFile location.
* shows files and folders in the dialog search result.
*
* @returns Information about the selected file(s)
*/
openFileBrowseDialogByDefaultLocation(): Observable<Node[]> {
@@ -114,6 +114,7 @@ export class ContentNodeDialogService {
/**
* Opens a folder browser at a chosen site location.
*
* @returns Information about the selected folder(s)
*/
openFolderBrowseDialogBySite(): Observable<Node[]> {
@@ -122,17 +123,17 @@ export class ContentNodeDialogService {
/**
* Opens a folder browser at a chosen folder location.
*
* @param folderNodeId ID of the folder to use
* @returns Information about the selected folder(s)
*/
openFolderBrowseDialogByFolderId(folderNodeId: string): Observable<Node[]> {
return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((node: NodeEntry) => {
return this.openUploadFolderDialog(NodeAction.CHOOSE, node.entry);
}));
return this.documentListService.getFolderNode(folderNodeId).pipe(switchMap((node: NodeEntry) => this.openUploadFolderDialog(NodeAction.CHOOSE, node.entry)));
}
/**
* Opens a dialog to copy or move an item to a new location.
*
* @param action Name of the action (eg, "Copy" or "Move") to show in the title
* @param contentEntry Item to be copied or moved
* @param permission Permission for the operation
@@ -153,7 +154,7 @@ export class ContentNodeDialogService {
where: '(isFolder=true)',
isSelectionValid: this.isCopyMoveSelectionValid.bind(this),
excludeSiteContent: excludeSiteContent || ContentNodeDialogService.nonDocumentSiteContent,
select: select
select
};
const dialogRef = this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '630px');
@@ -168,6 +169,7 @@ export class ContentNodeDialogService {
/**
* Gets the translation of the dialog title.
*
* @param action Name of the action to display in the dialog title
* @param name Name of the item on which the action is being performed
* @returns Translated version of the title
@@ -178,6 +180,7 @@ export class ContentNodeDialogService {
/**
* Opens a dialog to choose folders to upload.
*
* @param action Name of the action to show in the title
* @param contentEntry Item to upload
* @returns Information about the chosen folder(s)
@@ -193,7 +196,7 @@ export class ContentNodeDialogService {
imageResolver: this.imageResolver.bind(this),
isSelectionValid: this.hasAllowableOperationsOnNodeFolder.bind(this),
where: '(isFolder=true)',
select: select
select
};
const dialogRef = this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '630px');
@@ -204,6 +207,7 @@ export class ContentNodeDialogService {
/**
* Opens a dialog to choose a file to upload.
*
* @param action Name of the action to show in the title
* @param contentEntry Item to upload
* @param showFilesInResult Show files in dialog search result
@@ -219,7 +223,7 @@ export class ContentNodeDialogService {
currentFolderId: contentEntry.id,
imageResolver: this.imageResolver.bind(this),
isSelectionValid: (entry: Node) => entry.isFile,
select: select,
select,
showFilesInResult
};

View File

@@ -69,16 +69,16 @@ describe('ContentNodeSelectorPanelComponent', () => {
let thumbnailService: ThumbnailService;
let contentService: ContentService;
function typeToSearchBox(searchTerm = 'string-to-search') {
const typeToSearchBox = (searchTerm = 'string-to-search') => {
const searchInput = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-search-input"]'));
searchInput.nativeElement.value = searchTerm;
component.searchInput.setValue(searchTerm);
fixture.detectChanges();
}
};
function triggerSearchResults(searchResults: ResultSetPaging) {
const triggerSearchResults = (searchResults: ResultSetPaging) => {
component.queryBuilderService.executed.next(searchResults);
}
};
setupTestBed({
imports: [
@@ -122,12 +122,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
beforeEach(() => {
documentListService = TestBed.inject(DocumentListService);
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({
list: {
entries: [<SiteEntry> { entry: { guid: 'namek', id: 'namek' } },
<SiteEntry> { entry: { guid: 'blog', id: 'blog' } }]
entries: [
{ entry: { guid: 'namek', id: 'namek' } },
{ entry: { guid: 'blog', id: 'blog' } }
]
}
})));
@@ -140,7 +142,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
});
it('should trigger the select event when selection has been made', (done) => {
const expectedNode = <Node> { id: 'fakeid'};
const expectedNode = { id: 'fakeid'} as Node;
component.select.subscribe((nodes) => {
expect(nodes.length).toBe(1);
expect(nodes[0]).toBe(expectedNode);
@@ -155,14 +157,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
fixture.detectChanges();
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
.toBe(false, 'did not filter out blog');
});
it('should still be able to filter out the exclude site content after rowFilter changes', () => {
const filterFunction1 = () => {
return true;
};
const filterFunction1 = () => true;
const filterFunction2 = (row: ShareDataRow) => {
const node: Node = row.node.entry;
return node.isFile;
@@ -177,12 +177,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
properties: { 'st:componentId': 'blog' },
isFile: true
});
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
.toBe(false, 'did not filter out blog with filterFunction1');
component.rowFilter = filterFunction2;
fixture.detectChanges();
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null))
.toBe(false, 'did not filter out blog with filterFunction2');
});
@@ -190,7 +190,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
fixture.detectChanges();
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
expect(component.rowFilter(<any> { node: { entry: testSiteContent } }, null, null)).toBe(true);
expect(component.rowFilter({ node: { entry: testSiteContent } } as any, null, null)).toBe(true);
});
it('should render search input by default', () => {
@@ -227,7 +227,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
beforeEach(() => {
documentListService = TestBed.inject(DocumentListService);
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolderNode').and.returnValue(of({ entry: { path: { elements: [] } } }));
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
@@ -305,7 +305,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
component.onFolderChange(nodeEntryEvent);
fixture.detectChanges();
const chosenNode = <Node> { path: { elements: [] } };
const chosenNode = { path: { elements: [] } } as Node;
component.onCurrentSelection([ { entry: chosenNode } ]);
fixture.detectChanges();
@@ -328,14 +328,12 @@ describe('ContentNodeSelectorPanelComponent', () => {
});
it('should make changes to breadcrumb folderNode if breadcrumbTransform is defined', (done) => {
const transformedFolderNode = <Node> {
const transformedFolderNode = {
id: 'trans-node',
name: 'trans-node-name',
path: { elements: [{ id: 'testId', name: 'testName' }] }
};
component.breadcrumbTransform = (() => {
return transformedFolderNode;
});
component.breadcrumbTransform = (() => transformedFolderNode);
fixture.detectChanges();
fixture.whenStable().then(() => {
@@ -387,11 +385,11 @@ describe('ContentNodeSelectorPanelComponent', () => {
describe('Search functionality', () => {
let getCorrespondingNodeIdsSpy;
let customResourcesService: CustomResourcesService;
const entry: Node = <Node> { id: 'fakeid'};
const entry: Node = { id: 'fakeid'} as Node;
beforeEach(() => {
const documentListService = TestBed.inject(DocumentListService);
const expectedDefaultFolderNode = <NodeEntry> { entry: { path: { elements: [] } } };
const expectedDefaultFolderNode = { entry: { path: { elements: [] } } };
component.isSelectionValid = (node: Node) => node.isFile;
spyOn(documentListService, 'getFolderNode').and.returnValue(of(expectedDefaultFolderNode));
@@ -506,7 +504,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
}));
it('should update the breadcrumb when changing to a custom site', async () => {
component.siteChanged(<SiteEntry> { entry: { guid: '-mysites-', title: 'My Sites' } });
component.siteChanged({ entry: { guid: '-mysites-', title: 'My Sites' } } as SiteEntry);
expect(component.breadcrumbFolderTitle).toBe('My Sites');
});
@@ -518,7 +516,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(searchSpy.calls.count()).toBe(1, 'Search count should be one after only one search');
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
const expectedQueryBody = mockQueryBody;
expectedQueryBody.filterQueries = [ { query: `ANCESTOR:'workspace://SpacesStore/namek'`} ];
@@ -528,7 +526,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
}));
it('should create the query with the right parameters on changing the site selectBox value from a custom dropdown menu', fakeAsync(() => {
component.dropdownSiteList = <SitePaging> { list: { entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }] } };
component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging;
fixture.detectChanges();
typeToSearchBox('search-term');
@@ -537,7 +535,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(searchSpy.calls.count()).toBe(1);
component.siteChanged(<SiteEntry> { entry: { guid: '-sites-' } });
component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry);
const expectedQueryBodyWithSiteChange = mockQueryBody;
expectedQueryBodyWithSiteChange.filterQueries = [
@@ -555,26 +553,26 @@ describe('ContentNodeSelectorPanelComponent', () => {
tick(debounceSearch);
component.siteChanged(<SiteEntry> { entry: { guid: '-sites-' } });
component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry);
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1, 'getCorrespondingNodeIdsSpy calls count should be one after the site changes to known alias \'-sites\-');
expect(getCorrespondingNodeIdsSpy.calls.mostRecent().args[0]).toEqual('-sites-');
}));
it('should get the corresponding node ids on search when a known alias is selected from CUSTOM dropdown', fakeAsync(() => {
component.dropdownSiteList = <SitePaging> { list: { entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }] } };
component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging;
fixture.detectChanges();
typeToSearchBox('vegeta');
tick(debounceSearch);
component.siteChanged(<SiteEntry> { entry: { guid: '-sites-' } });
component.siteChanged({ entry: { guid: '-sites-' } } as SiteEntry);
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(1);
expect(getCorrespondingNodeIdsSpy.calls.mostRecent().args[0]).toEqual('-sites-');
}));
it('should NOT get the corresponding node ids on search when NOTHING is selected from dropdown', fakeAsync(() => {
component.dropdownSiteList = <SitePaging> { list: { entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }] } };
component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging;
fixture.detectChanges();
typeToSearchBox('vegeta');
@@ -590,13 +588,13 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called');
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
expect(getCorrespondingNodeIdsSpy).not.toHaveBeenCalled();
}));
it('should NOT get the corresponding node ids on search when NO known alias is selected from CUSTOM dropdown', fakeAsync(() => {
component.dropdownSiteList = <SitePaging> { list: { entries: [<SiteEntry> { entry: { guid: '-sites-' } }, <SiteEntry> { entry: { guid: 'namek' } }] } };
component.dropdownSiteList = { list: { entries: [{ entry: { guid: '-sites-' } }, { entry: { guid: 'namek' } }] } } as SitePaging;
fixture.detectChanges();
typeToSearchBox('vegeta');
@@ -604,7 +602,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(getCorrespondingNodeIdsSpy.calls.count()).toBe(0, 'getCorrespondingNodeIdsSpy should not be called');
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
expect(getCorrespondingNodeIdsSpy).not.toHaveBeenCalled();
}));
@@ -730,7 +728,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
component.queryBuilderService.userQuery = 'search-term*';
component.currentFolderId = 'my-root-id';
component.restrictRootToCurrentFolderId = true;
component.siteChanged(<SiteEntry> { entry: { guid: 'my-site-id' } });
component.siteChanged({ entry: { guid: 'my-site-id' } } as SiteEntry);
const expectedQueryBodyWithSiteChange = mockQueryBody;
expectedQueryBodyWithSiteChange.filterQueries = [
@@ -799,7 +797,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(searchSpy.calls.count()).toBe(1);
component.siteChanged(<SiteEntry> { entry: { guid: 'namek' } });
component.siteChanged({ entry: { guid: 'namek' } } as SiteEntry);
expect(searchSpy.calls.count()).toBe(2);
@@ -833,14 +831,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
})
}
}))
.toBe(filter(<ShareDataRow> {
.toBe(filter({
node: {
entry: new Node({
name: 'impossible-name',
id: 'name'
})
}
}));
} as ShareDataRow));
});
it('should pass through the excludeSiteContent to the rowFilter of the documentList', () => {
@@ -853,7 +851,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(documentList.componentInstance.rowFilter).toBeTruthy('Document list should have had a rowFilter');
const testSiteContent = new Node({ id: 'blog-id', properties: { 'st:componentId': 'blog' } });
expect(documentList.componentInstance.rowFilter(<any> { node: { entry: testSiteContent } }, null, null))
expect(documentList.componentInstance.rowFilter({ node: { entry: testSiteContent } }, null, null))
.toBe(false);
});
@@ -948,13 +946,13 @@ describe('ContentNodeSelectorPanelComponent', () => {
}));
it('should set the folderIdToShow to the default "currentFolderId" if siteId is undefined', (done) => {
component.siteChanged(<SiteEntry> { entry: { guid: 'Kame-Sennin Muten Roshi' } });
component.siteChanged({ entry: { guid: 'Kame-Sennin Muten Roshi' } } as SiteEntry);
fixture.detectChanges();
let documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
expect(documentList.componentInstance.currentFolderId).toBe('Kame-Sennin Muten Roshi');
component.siteChanged(<SiteEntry> { entry: { guid: undefined } });
component.siteChanged({ entry: { guid: undefined } } as SiteEntry);
fixture.detectChanges();
documentList = fixture.debugElement.query(By.css('[data-automation-id="content-node-selector-document-list"]'));
@@ -990,7 +988,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
expect(searchSpy).not.toHaveBeenCalled();
});
it('should set its loading state to true to perform a new search', async() => {
it('should set its loading state to true to perform a new search', async () => {
component.prepareDialogForNewSearch(mockQueryBody);
fixture.detectChanges();
await fixture.whenStable();
@@ -1035,18 +1033,16 @@ describe('ContentNodeSelectorPanelComponent', () => {
describe('Chosen node', () => {
const entry: Node = <Node> { id: 'fakeid'};
const nodePage: NodePaging = <NodePaging> { list: { pagination: {} } };
const entry: Node = { id: 'fakeid'} as Node;
const nodePage: NodePaging = { list: { pagination: {} } };
let hasAllowableOperations;
const fakeFolderNode = <Node> { id: 'fakeNodeId', isFolder: true };
const fakeFolderNode = { id: 'fakeNodeId', isFolder: true } as Node;
function returnHasPermission(): boolean {
return hasAllowableOperations;
}
const returnHasPermission = (): boolean => hasAllowableOperations;
beforeEach(() => {
const schema = [<DataColumn> {}];
const rows = [<DataRow> {}, <DataRow> {}];
const schema = [{}] as DataColumn[];
const rows = [{}, {}] as DataRow[];
component.documentList.data = new ShareDataTableAdapter(thumbnailService, contentService, schema);
spyOn(component.documentList.data, 'getRows').and.returnValue(rows);
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
@@ -1140,7 +1136,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
component.documentList.ready.emit(nodePage);
});
it('should NOT be null after clicking on a node (with the right permissions) in the list (onNodeSelect)', async() => {
it('should NOT be null after clicking on a node (with the right permissions) in the list (onNodeSelect)', async () => {
hasAllowableOperations = true;
component.select.subscribe((nodes) => {
@@ -1186,7 +1182,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
it('should be empty when the chosenNode is reset', async () => {
hasAllowableOperations = true;
component.onCurrentSelection([{ entry: <Node> {} }]);
component.onCurrentSelection([{ entry: {} as Node }]);
component.select.subscribe((nodes) => {
expect(nodes).toBeDefined();
@@ -1235,7 +1231,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
it('should be null when the chosenNode is reset', async () => {
fixture.detectChanges();
component.onCurrentSelection([{ entry: <Node> {} }]);
component.onCurrentSelection([{ entry: {} as Node }]);
component.select.subscribe((nodes) => {
expect(nodes).toBeDefined();
@@ -1272,7 +1268,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
it('should be null when the chosenNode is reset', async () => {
fixture.detectChanges();
component.onCurrentSelection([{ entry: <Node> {} }]);
component.onCurrentSelection([{ entry: {} as Node }]);
component.select.subscribe((nodes) => {
expect(nodes).toBeDefined();
@@ -1303,7 +1299,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
const isUploadingSpy = spyOn(uploadService, 'isUploading').and.returnValue(true);
const documentListReloadSpy = spyOn(component.documentList, 'reloadWithoutResettingSelection');
const fakeFileModels = [new FileModel(<File> { name: 'fake-name', size: 100 }), new FileModel(<File> { name: 'fake-name-2', size: 200 })];
const fakeFileModels = [new FileModel({ name: 'fake-name', size: 100 } as File), new FileModel({ name: 'fake-name-2', size: 200 } as File)];
const fileUploadCompleteEvent = new FileUploadCompleteEvent(fakeFileModels[0], 1, fakeFileModels[0], 0);
uploadService.fileUploadComplete.next(fileUploadCompleteEvent);
@@ -1330,8 +1326,8 @@ describe('ContentNodeSelectorPanelComponent', () => {
const documentListUnselectRowSpy = spyOn(component.documentList, 'unselectRowFromNodeId');
const documentListReloadSpy = spyOn(component.documentList, 'reloadWithoutResettingSelection');
const fakeFileModel = new FileModel(<File> { name: 'fake-name', size: 10000000 });
const fakeNodes = [<Node> { id: 'fakeNodeId' }, <Node> { id: 'fakeNodeId2' }];
const fakeFileModel = new FileModel({ name: 'fake-name', size: 10000000 } as File);
const fakeNodes = [{ id: 'fakeNodeId' }, { id: 'fakeNodeId2' }] as Node[];
fakeFileModel.data = { entry: fakeNodes[0] };
fakeFileModel.status = FileUploadStatus.Deleted;
@@ -1375,7 +1371,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
contentNodeSelectorPanelService.customModels = undefined;
});
it ('should search panel be collapsed by default and expand when clicking the filter button', async() => {
it ('should search panel be collapsed by default and expand when clicking the filter button', async () => {
contentNodeSelectorPanelService.customModels = [mockContentModelTextProperty];
fixture.detectChanges();

View File

@@ -62,7 +62,7 @@ export const defaultValidation = () => true;
templateUrl: './content-node-selector-panel.component.html',
styleUrls: ['./content-node-selector-panel.component.scss'],
encapsulation: ViewEncapsulation.None,
host: { 'class': 'adf-content-node-selector-panel' },
host: { class: 'adf-content-node-selector-panel' },
providers: [{
provide: SEARCH_QUERY_SERVICE_TOKEN,
useClass: SearchQueryBuilderService
@@ -70,6 +70,7 @@ export const defaultValidation = () => true;
})
export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
// eslint-disable-next-line @typescript-eslint/naming-convention
DEFAULT_PAGINATION: Pagination = new Pagination({
maxItems: 25,
skipCount: 0
@@ -418,10 +419,8 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
if (!filter) {
filter = () => true;
}
this._rowFilter = (value: ShareDataRow, index: number, array: ShareDataRow[]) => {
return filter(value, index, array) &&
this._rowFilter = (value: ShareDataRow, index: number, array: ShareDataRow[]) => filter(value, index, array) &&
!this.isExcludedSiteContent(value);
};
}
private isExcludedSiteContent(row: ShareDataRow): boolean {

View File

@@ -26,7 +26,6 @@ import { of } from 'rxjs';
import { ContentTestingModule } from '../testing/content.testing.module';
import { DocumentListService } from '../document-list/services/document-list.service';
import { DocumentListComponent } from '../document-list/components/document-list.component';
import { ShareDataRow } from '../document-list';
import { TranslateModule } from '@ngx-translate/core';
import { UploadModule } from '../upload';
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
@@ -111,19 +110,19 @@ describe('ContentNodeSelectorComponent', () => {
fixture.destroy();
});
function enableLocalUpload() {
const enableLocalUpload = () => {
component.data.showLocalUploadButton = true;
component.hasAllowableOperations = true;
component.showingSearch = false;
component.isLoading = false;
}
};
function selectTabByIndex(tabIndex: number) {
const selectTabByIndex = (tabIndex: number) => {
const uploadFromLocalTab = fixture.debugElement.queryAll(By.css('.mat-tab-label'))[tabIndex];
const attributes = uploadFromLocalTab.nativeNode.attributes as NamedNodeMap;
const tabPositionInSet = Number(attributes.getNamedItem('aria-posinset').value) - 1;
component.onTabSelectionChange(tabPositionInSet);
}
};
describe('Data injecting with the "Material dialog way"', () => {
@@ -157,7 +156,7 @@ describe('ContentNodeSelectorComponent', () => {
})
}
}))
.toBe(data.rowFilter(<ShareDataRow> {
.toBe(data.rowFilter({
node: {
entry: new Node({
name: 'impossible-name',
@@ -433,7 +432,7 @@ describe('ContentNodeSelectorComponent', () => {
});
it('should uploadStarted become true when the first upload gets started', () => {
const fileUploadEvent = new FileUploadEvent(new FileModel(<File> { name: 'fake-name', size: 100 }));
const fileUploadEvent = new FileUploadEvent(new FileModel({ name: 'fake-name', size: 100 } as File));
uploadService.fileUploadStarting.next(fileUploadEvent);
expect(component.uploadStarted).toBe(true);

View File

@@ -153,11 +153,11 @@ export class ContentNodeSelectorComponent implements OnInit {
this.selectedTabIndex = tabIndex;
}
isFileServerTabSelected (): boolean {
isFileServerTabSelected(): boolean {
return this.selectedTabIndex === 0;
}
isLocalUploadTabSelected (): boolean {
isLocalUploadTabSelected(): boolean {
return this.selectedTabIndex === 1;
}

View File

@@ -35,8 +35,8 @@ describe('NameLocationCellComponent', () => {
fixture = TestBed.createComponent(NameLocationCellComponent);
component = fixture.componentInstance;
rowData = <DataRow> {
getValue(key): any {
rowData = {
getValue: (key): any => {
if (key === 'name') {
return 'file-name';
} else if (key === 'path') {
@@ -44,7 +44,7 @@ describe('NameLocationCellComponent', () => {
}
return undefined;
}
};
} as DataRow;
component.row = rowData;
fixture.detectChanges();
});