mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-10-08 14:51:14 +00:00
extensions: wave 2 (#497)
* introduce "create folder" action * track opened folder via store * "create folder" action, support mulitple targets * fix card view colors and toolbar layouts * basic support for permissions * simplify create menu and add permissions * add toolbar separators for extension entries * "edit folder" extension command * minor code improvements
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<div class="layout">
|
||||
<adf-upload-drag-area
|
||||
[parentId]="node?.id"
|
||||
[disabled]="!permission.check(node, ['create'])">
|
||||
[disabled]="!canUpload">
|
||||
|
||||
<adf-sidenav-layout
|
||||
#sidenavManager="acaSidenavManager"
|
||||
|
@@ -25,10 +25,8 @@
|
||||
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { PeopleContentService, AppConfigService, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { LayoutComponent } from './layout.component';
|
||||
import { SidenavViewsManagerDirective } from './sidenav-views-manager.directive';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
@@ -36,17 +34,9 @@ import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
describe('LayoutComponent', () => {
|
||||
let fixture: ComponentFixture<LayoutComponent>;
|
||||
let component: LayoutComponent;
|
||||
let browsingFilesService: BrowsingFilesService;
|
||||
let appConfig: AppConfigService;
|
||||
let userPreference: UserPreferencesService;
|
||||
|
||||
const navItem = {
|
||||
label: 'some-label',
|
||||
route: {
|
||||
url: '/some-url'
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ AppTestingModule ],
|
||||
@@ -67,25 +57,10 @@ describe('LayoutComponent', () => {
|
||||
|
||||
fixture = TestBed.createComponent(LayoutComponent);
|
||||
component = fixture.componentInstance;
|
||||
browsingFilesService = TestBed.get(BrowsingFilesService);
|
||||
appConfig = TestBed.get(AppConfigService);
|
||||
userPreference = TestBed.get(UserPreferencesService);
|
||||
});
|
||||
|
||||
it('sets current node', () => {
|
||||
appConfig.config = {
|
||||
navigation: [navItem]
|
||||
};
|
||||
|
||||
const currentNode = <MinimalNodeEntryEntity>{ id: 'someId' };
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
browsingFilesService.onChangeParent.next(currentNode);
|
||||
|
||||
expect(component.node).toEqual(currentNode);
|
||||
});
|
||||
|
||||
describe('sidenav state', () => {
|
||||
it('should get state from configuration', () => {
|
||||
appConfig.config = {
|
||||
|
@@ -24,11 +24,14 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
import { Subject } from 'rxjs/Rx';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { NodePermissionService } from '../../common/services/node-permission.service';
|
||||
import { SidenavViewsManagerDirective } from './sidenav-views-manager.directive';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../store/states';
|
||||
import { currentFolder } from '../../store/selectors/app.selectors';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
@@ -38,14 +41,14 @@ import { SidenavViewsManagerDirective } from './sidenav-views-manager.directive'
|
||||
export class LayoutComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(SidenavViewsManagerDirective) manager: SidenavViewsManagerDirective;
|
||||
|
||||
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
||||
expandedSidenav: boolean;
|
||||
node: MinimalNodeEntryEntity;
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
canUpload = false;
|
||||
|
||||
constructor(
|
||||
private browsingFilesService: BrowsingFilesService,
|
||||
public permission: NodePermissionService) {}
|
||||
protected store: Store<AppStore>,
|
||||
private permission: NodePermissionService) {}
|
||||
|
||||
ngOnInit() {
|
||||
if (!this.manager.minimizeSidenav) {
|
||||
@@ -56,12 +59,16 @@ export class LayoutComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.manager.run(true);
|
||||
|
||||
this.subscriptions.concat([
|
||||
this.browsingFilesService.onChangeParent.subscribe((node: MinimalNodeEntryEntity) => this.node = node)
|
||||
]);
|
||||
this.store.select(currentFolder)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(node => {
|
||||
this.node = node;
|
||||
this.canUpload = this.permission.check(node, ['create']);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user