[ADF-3719] added rendition when creating a shared link (#3968)

* [ADF-3719] i
nserted rendition generation for shared link nodes

* [ADF-3719] added rendition when creating a shared link

* [ADF-3719] added fake parameter to subscribe
This commit is contained in:
Vito
2018-11-15 14:41:17 +00:00
committed by Eugenio Romano
parent dfe8c84780
commit 465e55acb5
5 changed files with 141 additions and 11 deletions

View File

@@ -18,13 +18,14 @@
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TestBed, fakeAsync, async } from '@angular/core/testing';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
import { of } from 'rxjs';
import { of, empty } from 'rxjs';
import {
setupTestBed,
CoreModule,
SharedLinksApiService,
NodesApiService,
NotificationService
NotificationService,
RenditionsService
} from '@alfresco/adf-core';
import { ContentNodeShareModule } from './content-node-share.module';
import { ShareDialogComponent } from './content-node-share.dialog';
@@ -37,6 +38,7 @@ describe('ShareDialogComponent', () => {
openSnackMessage: jasmine.createSpy('openSnackMessage')
};
let sharedLinksApiService: SharedLinksApiService;
let renditionService: RenditionsService;
let nodesApiService: NodesApiService;
let fixture;
let component;
@@ -60,6 +62,7 @@ describe('ShareDialogComponent', () => {
fixture = TestBed.createComponent(ShareDialogComponent);
matDialog = TestBed.get(MatDialog);
sharedLinksApiService = TestBed.get(SharedLinksApiService);
renditionService = TestBed.get(RenditionsService);
nodesApiService = TestBed.get(NodesApiService);
component = fixture.componentInstance;
});
@@ -83,6 +86,7 @@ describe('ShareDialogComponent', () => {
spyOn(sharedLinksApiService, 'createSharedLinks').and.returnValue(of({
entry: { id: 'sharedId', sharedId: 'sharedId' }
}));
spyOn(renditionService, 'generateRenditionForNode').and.returnValue(empty());
component.data = {
node,
@@ -92,12 +96,14 @@ describe('ShareDialogComponent', () => {
fixture.detectChanges();
expect(sharedLinksApiService.createSharedLinks).toHaveBeenCalled();
expect(renditionService.generateRenditionForNode).toHaveBeenCalled();
expect(fixture.nativeElement.querySelector('input[formcontrolname="sharedUrl"]').value).toBe('some-url/sharedId');
expect(fixture.nativeElement.querySelector('.mat-slide-toggle').classList).toContain('mat-checked');
});
it(`should not toggle share action when file has 'sharedId' property`, async(() => {
spyOn(sharedLinksApiService, 'createSharedLinks');
spyOn(renditionService, 'generateRenditionForNode').and.returnValue(empty());
node.entry.properties['qshare:sharedId'] = 'sharedId';

View File

@@ -31,7 +31,8 @@ import { tap, skip } from 'rxjs/operators';
import {
SharedLinksApiService,
NodesApiService,
ContentService
ContentService,
RenditionsService
} from '@alfresco/adf-core';
import { SharedLinkEntry, MinimalNodeEntryEntity } from 'alfresco-js-api';
import { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
@@ -66,6 +67,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
private dialog: MatDialog,
private nodesApiService: NodesApiService,
private contentService: ContentService,
private renditionService: RenditionsService,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
@@ -94,6 +96,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
if (properties && !properties['qshare:sharedId']) {
this.createSharedLinks(this.data.node.entry.id);
} else {
this.sharedId = properties['qshare:sharedId'];
this.isFileShared = true;
@@ -157,6 +160,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
this.data.node.entry.properties['qshare:sharedId'] = this.sharedId;
this.isDisabled = false;
this.isFileShared = true;
this.renditionService.generateRenditionForNode(this.data.node.entry.id).subscribe(() => {});
this.updateForm();
}