mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-2710] removed default shared link creation at the opening (#3430)
This commit is contained in:
@@ -27,6 +27,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
|
|
||||||
let fixture: ComponentFixture<ShareDialogComponent>;
|
let fixture: ComponentFixture<ShareDialogComponent>;
|
||||||
let spyCreate: any;
|
let spyCreate: any;
|
||||||
|
let spyDelete: any;
|
||||||
let component: ShareDialogComponent;
|
let component: ShareDialogComponent;
|
||||||
let sharedLinksApiService: SharedLinksApiService;
|
let sharedLinksApiService: SharedLinksApiService;
|
||||||
const dialogRef = {
|
const dialogRef = {
|
||||||
@@ -54,6 +55,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
spyCreate = spyOn(sharedLinksApiService, 'createSharedLinks').and.returnValue(Observable.of({ entry: { id: 'test-sharedId' } }));
|
spyCreate = spyOn(sharedLinksApiService, 'createSharedLinks').and.returnValue(Observable.of({ entry: { id: 'test-sharedId' } }));
|
||||||
|
spyDelete = spyOn(sharedLinksApiService, 'deleteSharedLink').and.returnValue(Observable.of({}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init the dialog with the file name and baseShareUrl', async(() => {
|
it('should init the dialog with the file name and baseShareUrl', async(() => {
|
||||||
@@ -83,7 +85,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
expect(spyCreate).not.toHaveBeenCalled();
|
expect(spyCreate).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create the public link if is not present in the node', () => {
|
it('should not create the public link if is not present in the node', () => {
|
||||||
component.data = {
|
component.data = {
|
||||||
node: { entry: { properties: {}, name: 'example-name' } },
|
node: { entry: { properties: {}, name: 'example-name' } },
|
||||||
baseShareUrl: 'baseShareUrl-example'
|
baseShareUrl: 'baseShareUrl-example'
|
||||||
@@ -91,20 +93,34 @@ describe('ShareDialogComponent', () => {
|
|||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
expect(spyCreate).toHaveBeenCalled();
|
expect(spyCreate).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the data structure after created the link', async(() => {
|
it('should be able to delete the shared link', async(() => {
|
||||||
component.data = {
|
component.data = {
|
||||||
node: { entry: { name: 'example-name', properties: {} } },
|
node: { entry: { name: 'example-name', properties: { 'qshare:sharedId': 'example-link' } } },
|
||||||
baseShareUrl: 'baseShareUrl-example'
|
baseShareUrl: 'baseShareUrl-example'
|
||||||
};
|
};
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
fixture.nativeElement.querySelector('#adf-share-toggle-input').click();
|
||||||
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(component.data.node.entry.properties['qshare:sharedId']).toBe('test-sharedId');
|
expect(spyDelete).toHaveBeenCalled();
|
||||||
|
expect(component.data.node.entry.properties['qshare:sharedId']).toBeNull();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should show the toggle disabled when the shareid property is null', async(() => {
|
||||||
|
component.data = {
|
||||||
|
node: { entry: { name: 'example-name', properties: { 'qshare:sharedId': null } } },
|
||||||
|
baseShareUrl: 'baseShareUrl-example'
|
||||||
|
};
|
||||||
|
component.ngOnInit();
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
expect(fixture.nativeElement.querySelector('#adf-share-toggle')).not.toBeNull();
|
||||||
|
expect(fixture.nativeElement.querySelector('#adf-share-toggle.mat-checked')).toBeNull();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@@ -52,7 +52,8 @@ export class ShareDialogComponent implements OnInit {
|
|||||||
this.sharedId = this.data.node.entry.properties['qshare:sharedId'];
|
this.sharedId = this.data.node.entry.properties['qshare:sharedId'];
|
||||||
this.isFileShared = true;
|
this.isFileShared = true;
|
||||||
} else {
|
} else {
|
||||||
this.createSharedLinks(this.data.node.entry.id);
|
this.isFileShared = false;
|
||||||
|
this.isDisabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,6 +88,7 @@ export class ShareDialogComponent implements OnInit {
|
|||||||
|
|
||||||
deleteSharedLink(sharedId: string) {
|
deleteSharedLink(sharedId: string) {
|
||||||
this.sharedLinksApiService.deleteSharedLink(sharedId).subscribe(() => {
|
this.sharedLinksApiService.deleteSharedLink(sharedId).subscribe(() => {
|
||||||
|
this.data.node.entry.properties['qshare:sharedId'] = null;
|
||||||
this.isFileShared = false;
|
this.isFileShared = false;
|
||||||
this.isDisabled = false;
|
this.isDisabled = false;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user