diff --git a/e2e/content-services/version/version-permissions.e2e.ts b/e2e/content-services/version/version-permissions.e2e.ts index 7fa29189b1..2f016bd3de 100644 --- a/e2e/content-services/version/version-permissions.e2e.ts +++ b/e2e/content-services/version/version-permissions.e2e.ts @@ -123,6 +123,7 @@ describe('Version component permissions', () => { }); afterAll(async () => { + await apiService.getInstance().login(browser.params.testConfig.admin.email, browser.params.testConfig.admin.password); await apiService.getInstance().core.sitesApi.deleteSite(site.entry.id, { permanent: true }); }); diff --git a/e2e/protractor.excludes.json b/e2e/protractor.excludes.json index 94f2b52c2e..595cbb08a3 100644 --- a/e2e/protractor.excludes.json +++ b/e2e/protractor.excludes.json @@ -1,5 +1,4 @@ { - "C277201": "Investigate after NG10", "C362240": "Include once ADF starts using ACS 7 , https://issues.alfresco.com/jira/browse/ADF-5182", "C362241": "Include once ADF starts using ACS 7, https://issues.alfresco.com/jira/browse/ADF-5182", "C362242": "Include once ADF starts using ACS 7, https://issues.alfresco.com/jira/browse/ADF-5182", diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts index 4ccdaf9341..34d4e3d9e6 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts @@ -74,7 +74,8 @@ describe('DocumentList', () => { beforeEach(() => { eventMock = { - preventDefault: function () {} + preventDefault: function () { + } }; fixture = TestBed.createComponent(DocumentListComponent); @@ -278,7 +279,7 @@ describe('DocumentList', () => { documentList.executeContentAction(node, action); expect(action.handler).toHaveBeenCalledWith(node, documentList, undefined); - }); + }); it('should call action handler with node and permission', () => { const node = new FileNode(); @@ -457,7 +458,7 @@ describe('DocumentList', () => { expect(actions.length).toBe(1); expect(actions[0].title).toEqual('FileAction'); expect(actions[0].disabled).toBe(true); - }); + }); it('should not display hidden content actions', () => { documentList.actions = [ @@ -546,7 +547,7 @@ describe('DocumentList', () => { expect(actions.length).toBe(1); expect(actions[0].title).toEqual('FileAction'); expect(actions[0].disabled).toBeFalsy(); - }); + }); it('should disable the action if there is no permission for the folder and disableWithNoPermission true', () => { const documentMenu = new ContentActionModel({ @@ -566,7 +567,7 @@ describe('DocumentList', () => { expect(actions.length).toBe(1); expect(actions[0].title).toEqual('FolderAction'); expect(actions[0].disabled).toBe(true); - }); + }); it('should not disable the action if there is the right permission for the file', () => { const documentMenu = new ContentActionModel({ @@ -830,7 +831,7 @@ describe('DocumentList', () => { documentList.onNodeClick(null); expect(documentList.loadFolder).not.toHaveBeenCalled(); - }); + }); it('should display folder content only on folder node click', () => { expect(documentList.navigate).toBe(true); @@ -1180,13 +1181,15 @@ describe('DocumentList', () => { documentList.onNodeDblClick(node); }); - it('should load folder by ID on init', () => { + it('should load folder by ID on init', async () => { spyOn(documentList, 'loadFolder').and.returnValue(Promise.resolve()); - documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692'; - fixture.detectChanges(); + documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, '1d26e465-dea3-42f3-b415-faa8364b9692', true) }); + + await fixture.whenStable(); + expect(documentList.loadFolder).toHaveBeenCalled(); }); @@ -1442,13 +1445,13 @@ describe('DocumentList', () => { documentList.includeFields = ['test-include']; documentList.currentFolderId = 'fake-id'; - fixture.detectChanges(); + documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) }); expect(documentListService.getFolder).toHaveBeenCalledWith(null, { where: undefined, maxItems: 25, skipCount: 0, - orderBy: ['isFolder DESC', 'name asc' ], + orderBy: ['isFolder DESC', 'name asc'], rootFolderId: 'fake-id' }, ['test-include']); }); @@ -1458,13 +1461,13 @@ describe('DocumentList', () => { documentList.where = '(isFolder=true)'; documentList.currentFolderId = 'fake-id'; - fixture.detectChanges(); + documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) }); expect(documentListService.getFolder).toHaveBeenCalledWith(null, { where: '(isFolder=true)', maxItems: 25, skipCount: 0, - orderBy: ['isFolder DESC', 'name asc' ], + orderBy: ['isFolder DESC', 'name asc'], rootFolderId: 'fake-id' }, ['test-include']); }); @@ -1472,15 +1475,15 @@ describe('DocumentList', () => { it('should add orderBy in the server request', () => { documentList.includeFields = ['test-include']; documentList.sorting = ['size', 'DESC']; - documentList.currentFolderId = 'fake-id'; documentList.where = null; + documentList.currentFolderId = 'fake-id'; - fixture.detectChanges(); + documentList.ngOnChanges({ currentFolderId: new SimpleChange(undefined, 'fake-id', true) }); expect(documentListService.getFolder).toHaveBeenCalledWith(null, { maxItems: 25, skipCount: 0, - where: undefined, + where: null, orderBy: ['isFolder DESC', 'size DESC'], rootFolderId: 'fake-id' }, ['test-include']); @@ -1494,15 +1497,23 @@ describe('DocumentList', () => { skipCount: 10 }); + expect(documentListService.getFolder).toHaveBeenCalledWith(null, Object({ + maxItems: 10, + skipCount: 10, + orderBy: ['name ASC'], + rootFolderId: 'no-node', + where: undefined + }), undefined); + documentList.onNodeClick(folder); - expect(documentListService.getFolder).toHaveBeenCalledWith(null, { + expect(documentListService.getFolder).toHaveBeenCalledWith(null, Object({ maxItems: 25, skipCount: 0, - orderBy: ['isFolder DESC', 'name asc' ], + orderBy: ['name ASC'], rootFolderId: 'folder-id', where: undefined - }, undefined); + }), undefined); }); }); diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index a10f09bac7..079c7faefe 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -233,7 +233,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte this._rowFilter = rowFilter; if (this.data) { this.data.setFilter(this._rowFilter); - if (this._currentFolderId) { + if (this.currentFolderId) { this.reload(); } } @@ -255,31 +255,9 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte @Input() stickyHeader: boolean = false; - _currentFolderId: string = null; - /** The ID of the folder node to display or a reserved string alias for special sources */ @Input() - set currentFolderId(currentFolderId: string) { - if (this._currentFolderId !== currentFolderId) { - this._currentFolderId = currentFolderId; - if (this.sorting) { - const [key, direction] = this.sorting; - this.orderBy = this.buildOrderByArray(key, direction); - } - if (this.data) { - this.data.loadPage(null, false); - this.resetNewFolderPagination(); - } - - if (this._currentFolderId) { - this.loadFolder(); - } - } - } - - get currentFolderId(): string { - return this._currentFolderId; - } + currentFolderId: string = null; /** The Document list will show all the nodes contained in the NodePaging entity */ @Input() @@ -461,15 +439,15 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte const columns = this.data.getColumns(); if (!columns || columns.length === 0) { - this.setupDefaultColumns(this._currentFolderId); + this.setupDefaultColumns(this.currentFolderId); } } ngOnChanges(changes: SimpleChanges) { this.resetSelection(); - if (changes.sorting && changes.sorting.currentValue) { - const [key, direction] = changes.sorting.currentValue; + if (this.sorting) { + const [key, direction] = this.sorting; this.orderBy = this.buildOrderByArray(key, direction); } @@ -489,6 +467,19 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte } } + if (changes['currentFolderId']?.currentValue !== changes['currentFolderId']?.previousValue) { + if (this.data) { + this.data.loadPage(null, false); + this.resetNewFolderPagination(); + } + + if (changes['currentFolderId'].currentValue) { + + this.loadFolder(); + } + + } + if (this.data) { if (changes.node && changes.node.currentValue) { const merge = this._pagination ? this._pagination.merge : false; @@ -597,15 +588,15 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte navigateTo(node: Node | string): boolean { if (typeof node === 'string') { this.resetNewFolderPagination(); - this._currentFolderId = node; + this.currentFolderId = node; this.folderChange.emit(new NodeEntryEvent( {id: node})); this.reload(); return true; } else { if (this.canNavigateFolder(node)) { this.resetNewFolderPagination(); - this._currentFolderId = this.getNodeFolderDestinationId(node); - this.folderChange.emit(new NodeEntryEvent( {id: this._currentFolderId})); + this.currentFolderId = this.getNodeFolderDestinationId(node); + this.folderChange.emit(new NodeEntryEvent( {id: this.currentFolderId})); this.reload(); return true; } @@ -623,7 +614,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte } updateCustomSourceData(nodeId: string): void { - this._currentFolderId = nodeId; + this.currentFolderId = nodeId; } /** @@ -662,20 +653,19 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte } loadFolder() { - if (!this._pagination.merge) { this.setLoadingState(true); } if (!this.hasCustomLayout) { - this.setupDefaultColumns(this._currentFolderId); + this.setupDefaultColumns(this.currentFolderId); } - if (this.documentListService.isCustomSourceService(this._currentFolderId)) { - this.updateCustomSourceData(this._currentFolderId); + if (this.documentListService.isCustomSourceService(this.currentFolderId)) { + this.updateCustomSourceData(this.currentFolderId); } - this.documentListService.loadFolderByNodeId(this._currentFolderId, this._pagination, this.includeFields, this.where, this.orderBy) + this.documentListService.loadFolderByNodeId(this.currentFolderId, this._pagination, this.includeFields, this.where, this.orderBy) .subscribe((documentNode: DocumentLoaderNode) => { if (documentNode.currentNode) { this.folderNode = documentNode.currentNode.entry; diff --git a/nx.json b/nx.json index 3b356aa30b..dde06ca1d0 100644 --- a/nx.json +++ b/nx.json @@ -1,5 +1,5 @@ { - "npmScope": "my-company", + "npmScope": "adf", "implicitDependencies": { "angular.json": "*", "package.json": "*", @@ -7,9 +7,7 @@ "tslint.json": "*", "nx.json": "*", ".travis.yml": "*", - "e2e/protractor.excludes.json": [ - "demoshell-e2e" - ] + "e2e/protractor.excludes.json": "*" }, "projects": { "demoshell": {