mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4640] share dialog fixes (#4830)
* unshare fixes and error notifications * fix disabled toggles issue * code fixes and separate interface * remove 'isFavorite' include * safety checks for properties * update e2e * refactor test after functionality change * fix issue with the missing properties * safety checks
This commit is contained in:
@@ -17,9 +17,11 @@
|
||||
|
||||
import { Directive, Input, HostListener, OnChanges, NgZone } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { NodeEntry, Node } from '@alfresco/js-api';
|
||||
|
||||
import { ShareDialogComponent } from './content-node-share.dialog';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
|
||||
@Directive({
|
||||
selector: '[adf-share]',
|
||||
@@ -46,22 +48,46 @@ export class NodeSharedDirective implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
constructor(private dialog: MatDialog, private zone: NgZone) {
|
||||
constructor(
|
||||
private dialog: MatDialog,
|
||||
private zone: NgZone,
|
||||
private alfrescoApiService: AlfrescoApiService) {
|
||||
}
|
||||
|
||||
shareNode(nodeEntry: NodeEntry) {
|
||||
if (nodeEntry && nodeEntry.entry && nodeEntry.entry.isFile) {
|
||||
this.dialog.open(ShareDialogComponent, {
|
||||
width: '600px',
|
||||
panelClass: 'adf-share-link-dialog',
|
||||
data: {
|
||||
node: nodeEntry,
|
||||
baseShareUrl: this.baseShareUrl
|
||||
}
|
||||
});
|
||||
// shared and favorite
|
||||
const nodeId = nodeEntry.entry['nodeId'] || nodeEntry.entry['guid'];
|
||||
|
||||
if (nodeId) {
|
||||
this.getNodeInfo(nodeId).subscribe((entry) => {
|
||||
this.openShareLinkDialog({ entry });
|
||||
});
|
||||
} else {
|
||||
this.openShareLinkDialog(nodeEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getNodeInfo(nodeId: string): Observable<Node> {
|
||||
const options = {
|
||||
include: ['allowableOperations']
|
||||
};
|
||||
|
||||
return from(this.alfrescoApiService.nodesApi.getNodeInfo(nodeId, options));
|
||||
}
|
||||
|
||||
private openShareLinkDialog(node: NodeEntry) {
|
||||
this.dialog.open(ShareDialogComponent, {
|
||||
width: '600px',
|
||||
panelClass: 'adf-share-link-dialog',
|
||||
data: {
|
||||
node,
|
||||
baseShareUrl: this.baseShareUrl
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.zone.onStable.subscribe(() => {
|
||||
if (this.node && this.node.entry) {
|
||||
|
Reference in New Issue
Block a user