mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1830] create menu enhancements (#670)
* nested menus for create button * evaluate sub-menu permissions * demo plugin * "create library" action * unit tests and proper effect name
This commit is contained in:
@@ -41,6 +41,8 @@ import { LibrariesComponent } from './libraries.component';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
import { ContentApiService } from '../../services/content-api.service';
|
||||
import { ExperimentalDirective } from '../../directives/experimental.directive';
|
||||
import { EffectsModule } from '@ngrx/effects';
|
||||
import { LibraryEffects } from 'src/app/store/effects';
|
||||
|
||||
describe('LibrariesComponent', () => {
|
||||
let fixture: ComponentFixture<LibrariesComponent>;
|
||||
@@ -69,7 +71,7 @@ describe('LibrariesComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppTestingModule],
|
||||
imports: [AppTestingModule, EffectsModule.forRoot([LibraryEffects])],
|
||||
declarations: [
|
||||
DataTableComponent,
|
||||
TimeAgoPipe,
|
||||
@@ -153,13 +155,8 @@ describe('LibrariesComponent', () => {
|
||||
});
|
||||
|
||||
describe('Node navigation', () => {
|
||||
let routerSpy;
|
||||
|
||||
beforeEach(() => {
|
||||
routerSpy = spyOn(router, 'navigate');
|
||||
});
|
||||
|
||||
it('does not navigate when id is not passed', () => {
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
component.navigate(null);
|
||||
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
@@ -167,11 +164,12 @@ describe('LibrariesComponent', () => {
|
||||
|
||||
it('navigates to node id', () => {
|
||||
const document = { id: 'documentId' };
|
||||
spyOn(router, 'navigate').and.stub();
|
||||
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: document }));
|
||||
|
||||
component.navigate(node.id);
|
||||
|
||||
expect(routerSpy.calls.argsFor(0)[0]).toEqual(['./', document.id]);
|
||||
expect(router.navigate).toHaveBeenCalledWith(['libraries', 'documentId']);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -24,18 +24,15 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { ShareDataRow } from '@alfresco/adf-content-services';
|
||||
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
||||
|
||||
import { PageComponent } from '../page.component';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../store/states/app.state';
|
||||
import { SiteEntry } from 'alfresco-js-api';
|
||||
import { ContentManagementService } from '../../services/content-management.service';
|
||||
import { ContentApiService } from '../../services/content-api.service';
|
||||
import { AppExtensionService } from '../../extensions/extension.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { NavigateLibraryAction } from 'src/app/store/actions';
|
||||
|
||||
@Component({
|
||||
templateUrl: './libraries.component.html'
|
||||
@@ -44,12 +41,9 @@ export class LibrariesComponent extends PageComponent implements OnInit {
|
||||
isSmallScreen = false;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
content: ContentManagementService,
|
||||
private contentApi: ContentApiService,
|
||||
store: Store<AppStore>,
|
||||
extensions: AppExtensionService,
|
||||
private router: Router,
|
||||
private breakpointObserver: BreakpointObserver
|
||||
) {
|
||||
super(store, extensions, content);
|
||||
@@ -60,9 +54,6 @@ export class LibrariesComponent extends PageComponent implements OnInit {
|
||||
|
||||
this.subscriptions.push(
|
||||
this.content.libraryDeleted.subscribe(() => this.reload()),
|
||||
this.content.libraryCreated.subscribe((node: SiteEntry) => {
|
||||
this.navigate(node.entry.guid);
|
||||
}),
|
||||
|
||||
this.breakpointObserver
|
||||
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
||||
@@ -101,15 +92,6 @@ export class LibrariesComponent extends PageComponent implements OnInit {
|
||||
}
|
||||
|
||||
navigate(libraryId: string) {
|
||||
if (libraryId) {
|
||||
this.contentApi
|
||||
.getNode(libraryId, { relativePath: '/documentLibrary' })
|
||||
.pipe(map(node => node.entry))
|
||||
.subscribe(documentLibrary => {
|
||||
this.router.navigate(['./', documentLibrary.id], {
|
||||
relativeTo: this.route
|
||||
});
|
||||
});
|
||||
}
|
||||
this.store.dispatch(new NavigateLibraryAction(libraryId));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user