From 18b4c1bc8a81def67c25a3194d6df4bb7ac04710 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Mon, 26 Nov 2018 18:20:30 +0000 Subject: [PATCH] [ACA-2022] navigation fixes (#830) * navigation fixes * test fixes --- e2e/suites/list-views/empty-list.test.ts | 2 +- e2e/suites/list-views/permissions.test.ts | 6 ++-- .../location-link/location-link.component.ts | 10 ++++-- src/app/store/effects/router.effects.ts | 33 +++++++++++++------ src/assets/i18n/en.json | 2 ++ 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts index a67746587..f4a79da48 100755 --- a/e2e/suites/list-views/empty-list.test.ts +++ b/e2e/suites/list-views/empty-list.test.ts @@ -77,7 +77,7 @@ describe('Empty list views', () => { await page.clickRecentFiles(); expect(await dataTable.isEmptyList()).toBe(true, 'list is not empty'); expect(await dataTable.getEmptyStateTitle()).toContain('No recent files'); - expect(await dataTable.getEmptyStateSubtitle()).toContain('Items you upload or edit in the last 30 days are shown here.'); + expect(await dataTable.getEmptyStateSubtitle()).toContain('Items you uploaded or edited in the last 30 days are shown here.'); }); it('empty Favorites - [C280133]', async () => { diff --git a/e2e/suites/list-views/permissions.test.ts b/e2e/suites/list-views/permissions.test.ts index 44c0be41b..a4e1fb82e 100755 --- a/e2e/suites/list-views/permissions.test.ts +++ b/e2e/suites/list-views/permissions.test.ts @@ -131,19 +131,19 @@ describe('Special permissions', () => { it(`on Recent Files - [C213178]`, async () => { await page.clickRecentFilesAndWait(); expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); - expect(await dataTable.getItemLocation(fileName)).toEqual(''); + expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); }); it(`on Favorites - [C213672]`, async () => { await page.clickFavoritesAndWait(); expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); - expect(await dataTable.getItemLocation(fileName)).toEqual(''); + expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); }); it(`on Shared Files - [C213668]`, async () => { await page.clickSharedFilesAndWait(); expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items'); - expect(await dataTable.getItemLocation(fileName)).toEqual(''); + expect(await dataTable.getItemLocation(fileName)).toEqual('Unknown'); }); }); }); diff --git a/src/app/components/common/location-link/location-link.component.ts b/src/app/components/common/location-link/location-link.component.ts index e7bba312a..018e21e32 100644 --- a/src/app/components/common/location-link/location-link.component.ts +++ b/src/app/components/common/location-link/location-link.component.ts @@ -43,7 +43,7 @@ import { ContentApiService } from '../../../services/content-api.service'; selector: 'aca-location-link', template: ` - {{ displayText | async }} + {{ displayText | async | translate }} `, changeDetection: ChangeDetectionStrategy.OnPush, @@ -53,7 +53,7 @@ import { ContentApiService } from '../../../services/content-api.service'; export class LocationLinkComponent implements OnInit { private _path: PathInfo; - nodeLocation$ = new BehaviorSubject(null); + nodeLocation$ = new BehaviorSubject(''); @Input() context: any; @@ -93,6 +93,8 @@ export class LocationLinkComponent implements OnInit { if (path && path.name && path.elements) { this.displayText = this.getDisplayText(path); this._path = path; + } else { + this.displayText = of('APP.BROWSE.SEARCH.UNKNOWN_LOCATION'); } } } @@ -142,6 +144,10 @@ export class LocationLinkComponent implements OnInit { // todo: review once 5.2.3 is out private getTooltip(path: PathInfo) { + if (!path) { + return; + } + let result: string = null; const elements = path.elements.map(e => Object.assign({}, e)); diff --git a/src/app/store/effects/router.effects.ts b/src/app/store/effects/router.effects.ts index e99a73a56..82136d7bd 100644 --- a/src/app/store/effects/router.effects.ts +++ b/src/app/store/effects/router.effects.ts @@ -36,12 +36,19 @@ import { NavigateToFolder, NAVIGATE_FOLDER, NavigateUrlAction, - NAVIGATE_URL + NAVIGATE_URL, + SnackbarErrorAction } from '../actions'; +import { AppStore } from '../states/app.state'; +import { Store } from '@ngrx/store'; @Injectable() export class RouterEffects { - constructor(private actions$: Actions, private router: Router) {} + constructor( + private store: Store, + private actions$: Actions, + private router: Router + ) {} @Effect({ dispatch: false }) navigateUrl$ = this.actions$.pipe( @@ -97,11 +104,13 @@ export class RouterEffects { // parent.id could be 'Site' folder or child as 'documentLibrary' link = [area, parent.name === 'Sites' ? {} : id]; } - } - setTimeout(() => { - this.router.navigate(link); - }, 10); + setTimeout(() => { + this.router.navigate(link); + }, 10); + } else { + this.router.navigate(['/personal-files', node.id]); + } } private navigateToParentFolder(node: MinimalNodeEntryEntity) { @@ -120,11 +129,15 @@ export class RouterEffects { // parent.id could be 'Site' folder or child as 'documentLibrary' link = [area, parent.name === 'Sites' ? {} : parent.id]; } - } - setTimeout(() => { - this.router.navigate(link); - }, 10); + setTimeout(() => { + this.router.navigate(link); + }, 10); + } else { + this.store.dispatch( + new SnackbarErrorAction('APP.MESSAGES.ERRORS.CANNOT_NAVIGATE_LOCATION') + ); + } } private isLibraryContent(path: PathInfoEntity): boolean { diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 405eaf18b..cf27c22b5 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -168,6 +168,7 @@ "LOCATION": "Location", "SIZE": "Size" }, + "UNKNOWN_LOCATION": "Unknown", "NO_RESULTS": "Your search returned 0 results" }, "SEARCH_LIBRARIES": { @@ -250,6 +251,7 @@ }, "MESSAGES": { "ERRORS":{ + "CANNOT_NAVIGATE_LOCATION": "Cannot navigate location", "MISSING_CONTENT": "This item no longer exists or you don't have permission to view it.", "GENERIC": "The action was unsuccessful. Try again or contact your IT Team.", "CONFLICT": "This name is already in use, try a different name.",