[ACA-2193] Lock node - unlock after new version is uploaded (#924)

* unlock node api call

* unlock action and effect

* unlock node after version upload

* check if locked

* clear version input on dialog cancel event

* update viewer on node version upload

* update viewer on file upload delete

* test

* update tests

* update tests

* rename evaluators

* update docs
This commit is contained in:
Cilibiu Bogdan
2019-02-10 15:56:02 +02:00
committed by Denys Vuika
parent 65e0a1138c
commit 894a928187
13 changed files with 278 additions and 54 deletions

View File

@@ -25,11 +25,19 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import {
TestBed,
ComponentFixture,
async,
fakeAsync,
tick
} from '@angular/core/testing';
import {
UserPreferencesService,
AppConfigPipe,
NodeFavoriteDirective
NodeFavoriteDirective,
UploadService,
AlfrescoApiService
} from '@alfresco/adf-core';
import { PreviewComponent } from './preview.component';
import { of, throwError } from 'rxjs';
@@ -38,6 +46,7 @@ import { ExperimentalDirective } from '../../directives/experimental.directive';
import { NodeEffects } from '../../store/effects/node.effects';
import { AppTestingModule } from '../../testing/app-testing.module';
import { ContentApiService } from '../../services/content-api.service';
import { ContentManagementService } from '../../services/content-management.service';
describe('PreviewComponent', () => {
let fixture: ComponentFixture<PreviewComponent>;
@@ -46,10 +55,14 @@ describe('PreviewComponent', () => {
let route: ActivatedRoute;
let preferences: UserPreferencesService;
let contentApi: ContentApiService;
let uploadService: UploadService;
let alfrescoApiService: AlfrescoApiService;
let contentManagementService: ContentManagementService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule, EffectsModule.forRoot([NodeEffects])],
providers: [AlfrescoApiService, ContentManagementService],
declarations: [
AppConfigPipe,
PreviewComponent,
@@ -66,6 +79,9 @@ describe('PreviewComponent', () => {
route = TestBed.get(ActivatedRoute);
preferences = TestBed.get(UserPreferencesService);
contentApi = TestBed.get(ContentApiService);
uploadService = TestBed.get(UploadService);
alfrescoApiService = TestBed.get(AlfrescoApiService);
contentManagementService = TestBed.get(ContentManagementService);
});
it('should extract the property path root', () => {
@@ -697,4 +713,29 @@ describe('PreviewComponent', () => {
const ids = await component.getFileIds('recent-files');
expect(ids).toEqual(['node2', 'node1']);
});
it('should return to parent folder on nodesDeleted event', async(() => {
spyOn(component, 'navigateToFileLocation');
fixture.detectChanges();
contentManagementService.nodesDeleted.next();
expect(component.navigateToFileLocation).toHaveBeenCalled();
}));
it('should return to parent folder on fileUploadDeleted event', async(() => {
spyOn(component, 'navigateToFileLocation');
fixture.detectChanges();
uploadService.fileUploadDeleted.next();
expect(component.navigateToFileLocation).toHaveBeenCalled();
}));
it('should emit nodeUpdated event on fileUploadComplete event', fakeAsync(() => {
spyOn(alfrescoApiService.nodeUpdated, 'next');
fixture.detectChanges();
uploadService.fileUploadComplete.next(<any>{ data: { entry: {} } });
tick(300);
expect(alfrescoApiService.nodeUpdated.next).toHaveBeenCalled();
}));
});

View File

@@ -38,7 +38,13 @@ import {
UrlSegment,
PRIMARY_OUTLET
} from '@angular/router';
import { UserPreferencesService, ObjectUtils } from '@alfresco/adf-core';
import { debounceTime } from 'rxjs/operators';
import {
UserPreferencesService,
ObjectUtils,
UploadService,
AlfrescoApiService
} from '@alfresco/adf-core';
import { Store } from '@ngrx/store';
import { AppStore } from '../../store/states/app.state';
import { SetSelectedNodesAction } from '../../store/actions';
@@ -84,6 +90,8 @@ export class PreviewComponent extends PageComponent
private appDataService: AppDataService,
private route: ActivatedRoute,
private router: Router,
private apiService: AlfrescoApiService,
private uploadService: UploadService,
store: Store<AppStore>,
extensions: AppExtensionService,
content: ContentManagementService
@@ -122,7 +130,15 @@ export class PreviewComponent extends PageComponent
this.subscriptions = this.subscriptions.concat([
this.content.nodesDeleted.subscribe(() =>
this.navigateToFileLocation(true)
)
),
this.uploadService.fileUploadDeleted.subscribe(() =>
this.navigateToFileLocation(true)
),
this.uploadService.fileUploadComplete
.pipe(debounceTime(300))
.subscribe(file => this.apiService.nodeUpdated.next(file.data.entry))
]);
this.openWith = this.extensions.openWithActions;