diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html
index 4ada6c925e..459ec8b8da 100644
--- a/demo-shell/src/app/components/files/files.component.html
+++ b/demo-shell/src/app/components/files/files.component.html
@@ -29,7 +29,7 @@
diff --git a/demo-shell/src/app/components/files/files.component.ts b/demo-shell/src/app/components/files/files.component.ts
index 1a846b02a6..e52f360c7b 100644
--- a/demo-shell/src/app/components/files/files.component.ts
+++ b/demo-shell/src/app/components/files/files.component.ts
@@ -365,8 +365,8 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
}
}
- getSiteContent(site: SiteEntry) {
- this.currentFolderId = site && site.entry.guid ? site.entry.guid : DEFAULT_FOLDER_TO_SHOW;
+ onSiteChange(site: SiteEntry) {
+ this.currentFolderId = site.entry.guid;
}
getDocumentListCurrentFolderId() {
diff --git a/lib/content-services/site-dropdown/sites-dropdown.component.html b/lib/content-services/site-dropdown/sites-dropdown.component.html
index 5539e10793..716a1ccfa5 100644
--- a/lib/content-services/site-dropdown/sites-dropdown.component.html
+++ b/lib/content-services/site-dropdown/sites-dropdown.component.html
@@ -1,6 +1,7 @@
- {{'DROPDOWN.MY_FILES_OPTION' | translate}}
{{ site.entry.title | translate}}
diff --git a/lib/content-services/site-dropdown/sites-dropdown.component.spec.ts b/lib/content-services/site-dropdown/sites-dropdown.component.spec.ts
index b9f403a98f..93cc7b569c 100644
--- a/lib/content-services/site-dropdown/sites-dropdown.component.spec.ts
+++ b/lib/content-services/site-dropdown/sites-dropdown.component.spec.ts
@@ -23,48 +23,13 @@ import { DropdownSitesComponent } from './sites-dropdown.component';
declare let jasmine: any;
-let sitesList = {
- 'list': {
- 'pagination': {
- 'count': 2,
- 'hasMoreItems': false,
- 'totalItems': 2,
- 'skipCount': 0,
- 'maxItems': 100
- },
- 'entries': [
- {
- 'entry': {
- 'role': 'SiteManager',
- 'visibility': 'PUBLIC',
- 'guid': 'fake-1',
- 'description': 'fake-test-site',
- 'id': 'fake-test-site',
- 'preset': 'site-dashboard',
- 'title': 'fake-test-site'
- }
- },
- {
- 'entry': {
- 'role': 'SiteManager',
- 'visibility': 'PUBLIC',
- 'guid': 'fake-2',
- 'description': 'This is a Sample Alfresco Team site.',
- 'id': 'swsdp',
- 'preset': 'site-dashboard',
- 'title': 'fake-test-2'
- }
- }
- ]
- }
-};
-
describe('DropdownSitesComponent', () => {
let component: any;
let fixture: ComponentFixture;
let debug: DebugElement;
let element: HTMLElement;
+ let sitesList: any;
beforeEach(async(() => {
@@ -83,6 +48,42 @@ describe('DropdownSitesComponent', () => {
debug = fixture.debugElement;
element = fixture.nativeElement;
component = fixture.componentInstance;
+
+ sitesList = {
+ 'list': {
+ 'pagination': {
+ 'count': 2,
+ 'hasMoreItems': false,
+ 'totalItems': 2,
+ 'skipCount': 0,
+ 'maxItems': 100
+ },
+ 'entries': [
+ {
+ 'entry': {
+ 'role': 'SiteManager',
+ 'visibility': 'PUBLIC',
+ 'guid': 'fake-1',
+ 'description': 'fake-test-site',
+ 'id': 'fake-test-site',
+ 'preset': 'site-dashboard',
+ 'title': 'fake-test-site'
+ }
+ },
+ {
+ 'entry': {
+ 'role': 'SiteManager',
+ 'visibility': 'PUBLIC',
+ 'guid': 'fake-2',
+ 'description': 'This is a Sample Alfresco Team site.',
+ 'id': 'swsdp',
+ 'preset': 'site-dashboard',
+ 'title': 'fake-test-2'
+ }
+ }
+ ]
+ }
+ };
});
describe('Rendering tests', () => {
@@ -128,13 +129,14 @@ describe('DropdownSitesComponent', () => {
responseText: sitesList
});
- openSelectbox();
-
fixture.whenStable().then(() => {
fixture.detectChanges();
- expect(window.document.querySelector('[data-automation-id="site-my-files-option"]')).not.toBeNull();
+ debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
+ fixture.detectChanges();
+ let options: any = debug.queryAll(By.css('mat-option'));
+ expect(options[0].nativeElement.innerText).toContain('DROPDOWN.MY_FILES_OPTION');
});
- }));
+ });
it('should hide the "My files" option if the developer desires that way', async(() => {
component.hideMyFiles = true;
@@ -145,11 +147,12 @@ describe('DropdownSitesComponent', () => {
responseText: sitesList
});
- openSelectbox();
-
fixture.whenStable().then(() => {
fixture.detectChanges();
- expect(window.document.querySelector('[data-automation-id="site-my-files-option"]')).toBeNull();
+ debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
+ fixture.detectChanges();
+ let options: any = debug.queryAll(By.css('mat-option'));
+ expect(options[0].nativeElement.innerText).not.toContain('DROPDOWN.MY_FILES_OPTION');
});
}));
@@ -219,12 +222,12 @@ describe('DropdownSitesComponent', () => {
});
component.change.subscribe(() => {
- expect(options[1].nativeElement.innerText).toContain('PERSONAL_FILES');
- expect(options[2].nativeElement.innerText).toContain('FILE_LIBRARIES');
+ expect(options[2].nativeElement.innerText).toContain('PERSONAL_FILES');
+ expect(options[3].nativeElement.innerText).toContain('FILE_LIBRARIES');
});
}));
- it('should load sites by default', (done) => {
+ it('should load sites by default', async(() => {
fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
@@ -232,23 +235,15 @@ describe('DropdownSitesComponent', () => {
responseText: sitesList
});
- openSelectbox();
-
- let options: any = [];
fixture.whenStable().then(() => {
fixture.detectChanges();
- options = debug.queryAll(By.css('mat-option'));
- options[0].triggerEventHandler('click', null);
+ debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
fixture.detectChanges();
- });
-
- component.change.subscribe(() => {
+ let options: any = debug.queryAll(By.css('mat-option'));
expect(options[1].nativeElement.innerText).toContain('fake-test-site');
expect(options[2].nativeElement.innerText).toContain('fake-test-2');
-
- done();
});
- });
+ }));
it('should raise an event when a site is selected', (done) => {
fixture.detectChanges();
diff --git a/lib/content-services/site-dropdown/sites-dropdown.component.ts b/lib/content-services/site-dropdown/sites-dropdown.component.ts
index 003297ad11..e57964c7da 100644
--- a/lib/content-services/site-dropdown/sites-dropdown.component.ts
+++ b/lib/content-services/site-dropdown/sites-dropdown.component.ts
@@ -18,7 +18,6 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
import { SitesService } from '@alfresco/adf-core';
import { SitePaging, SiteEntry } from 'alfresco-js-api';
-import { Observable } from 'rxjs/Observable';
@Component({
selector: 'adf-sites-dropdown',
@@ -57,18 +56,14 @@ export class DropdownSitesComponent implements OnInit {
selected: SiteEntry = null;
- public MY_FILES_VALUE = 'default';
+ public MY_FILES_VALUE = '-my-';
constructor(private sitesService: SitesService) {
}
ngOnInit() {
if (!this.siteList) {
- this.setDefaultSiteList().subscribe((result) => {
- this.selected = this.siteList.list.entries.find(site => site.entry.id === this.value);
- },
- (error) => {
- });
+ this.setDefaultSiteList();
}
}
@@ -77,16 +72,25 @@ export class DropdownSitesComponent implements OnInit {
this.change.emit(event.value);
}
- private setDefaultSiteList(): Observable {
- let sitesObservable = this.sitesService.getSites();
-
- sitesObservable.subscribe((result) => {
+ private setDefaultSiteList() {
+ this.sitesService.getSites().subscribe((result) => {
this.siteList = result;
+
+ if (!this.hideMyFiles) {
+ let myItem = { entry: { id: '-my-', guid: '-my-', title: 'DROPDOWN.MY_FILES_OPTION' } };
+
+ this.siteList.list.entries.unshift(myItem);
+
+ if (!this.value) {
+ this.value = '-my-';
+ }
+ }
+
+ this.selected = this.siteList.list.entries.find(site => site.entry.id === this.value);
},
(error) => {
});
- return sitesObservable;
}
}
diff --git a/lib/core/core.module.ts b/lib/core/core.module.ts
index 97ef67c580..953e130f36 100644
--- a/lib/core/core.module.ts
+++ b/lib/core/core.module.ts
@@ -80,7 +80,6 @@ export function createTranslateLoader(http: HttpClient, logService: LogService)
return new TranslateLoaderService(http, logService);
}
-
export function providers() {
return [
AuthenticationService,