[ADF-1794] Document List - users can see sites they are not members of (#2552)

* member sites

* SitePaging type
This commit is contained in:
Cilibiu Bogdan
2017-10-27 00:54:49 +03:00
committed by Eugenio Romano
parent 71e0204e01
commit d019dab147
6 changed files with 94 additions and 3 deletions

View File

@@ -892,7 +892,7 @@ describe('DocumentList', () => {
});
it('should not perform navigation for virtual sources', () => {
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-favorites-', '-recent-'];
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-'];
const node = new FolderNode('folder');
documentList.currentFolderId = 'node-id';
@@ -927,6 +927,14 @@ describe('DocumentList', () => {
expect(sitesApi.getSites).toHaveBeenCalled();
});
it('should fetch user membership sites', () => {
const peopleApi = apiService.getInstance().core.peopleApi;
spyOn(peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve());
documentList.loadFolderByNodeId('-mysites-');
expect(peopleApi.getSiteMembership).toHaveBeenCalled();
});
it('should fetch favorites', () => {
const favoritesApi = apiService.getInstance().core.favoritesApi;
spyOn(favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(null));

View File

@@ -19,7 +19,7 @@ import {
AfterContentInit, Component, ContentChild, ElementRef, EventEmitter, HostListener, Input, NgZone,
OnChanges, OnInit, Output, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation
} from '@angular/core';
import { DeletedNodesPaging, MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination, PersonEntry } from 'alfresco-js-api';
import { DeletedNodesPaging, MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination, PersonEntry, SitePaging } from 'alfresco-js-api';
import { AlfrescoApiService, AppConfigService, DataColumnListComponent, UserPreferencesService } from 'ng2-alfresco-core';
import { DataCellEvent, DataColumn, DataRowActionEvent, DataSorting, DataTableComponent, ObjectDataColumn } from 'ng2-alfresco-datatable';
import { Observable, Subject } from 'rxjs/Rx';
@@ -420,6 +420,8 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
this.loadSharedLinks();
} else if (nodeId === '-sites-') {
this.loadSites();
} else if (nodeId === '-mysites-') {
this.loadMemberSites();
} else if (nodeId === '-favorites-') {
this.loadFavorites();
} else if (nodeId === '-recent-') {
@@ -513,6 +515,28 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
});
}
private loadMemberSites(): void {
const options = {
include: [ 'properties' ],
maxItems: this.pageSize,
skipCount: this.skipCount
};
this.apiService.peopleApi.getSiteMembership('-me-', options).then((result: SitePaging) => {
let page: NodePaging = {
list: {
entries: result.list.entries
.map(({ entry: { site }}: any) => ({
entry: site
})),
pagination: result.list.pagination
}
};
this.onPageLoaded(page);
});
}
private loadFavorites(): void {
const options = {
maxItems: this.pageSize,
@@ -773,7 +797,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
}
isCustomSource(folderId: string): boolean {
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-favorites-', '-recent-'];
const sources = ['-trashcan-', '-sharedlinks-', '-sites-', '-mysites-', '-favorites-', '-recent-'];
if (sources.indexOf(folderId) > -1) {
return true;

View File

@@ -78,6 +78,27 @@ export let presetsDefaultModel = {
sortable: true
}
],
'-mysites-': [
{
key: '$thumbnail',
type: 'image',
srTitle: 'ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL',
sortable: false
},
{
key: 'title',
type: 'text',
title: 'ADF-DOCUMENT-LIST.LAYOUT.NAME',
cssClass: 'full-width ellipsis-cell',
sortable: true
},
{
key: 'visibility',
type: 'text',
title: 'ADF-DOCUMENT-LIST.LAYOUT.STATUS',
sortable: true
}
],
'-favorites-': [
{
key: '$thumbnail',