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:
@@ -28,7 +28,8 @@ import {
|
|||||||
AlfrescoApiService, AuthenticationService, AppConfigService, AppConfigValues, ContentService, TranslationService,
|
AlfrescoApiService, AuthenticationService, AppConfigService, AppConfigValues, ContentService, TranslationService,
|
||||||
FileUploadEvent, FolderCreatedEvent, LogService, NotificationService,
|
FileUploadEvent, FolderCreatedEvent, LogService, NotificationService,
|
||||||
UploadService, DataColumn, DataRow, UserPreferencesService,
|
UploadService, DataColumn, DataRow, UserPreferencesService,
|
||||||
PaginationComponent, FormValues, DisplayMode, InfinitePaginationComponent, HighlightDirective
|
PaginationComponent, FormValues, DisplayMode, InfinitePaginationComponent, HighlightDirective,
|
||||||
|
SharedLinksApiService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -217,7 +218,8 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Optional() private route: ActivatedRoute,
|
@Optional() private route: ActivatedRoute,
|
||||||
public authenticationService: AuthenticationService,
|
public authenticationService: AuthenticationService,
|
||||||
public alfrescoApiService: AlfrescoApiService,
|
public alfrescoApiService: AlfrescoApiService,
|
||||||
private contentMetadataService: ContentMetadataService) {
|
private contentMetadataService: ContentMetadataService,
|
||||||
|
private sharedLinksApiService: SharedLinksApiService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
showFile(event) {
|
showFile(event) {
|
||||||
@@ -275,6 +277,12 @@ export class FilesComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
.subscribe((err: { message: string }) => {
|
.subscribe((err: { message: string }) => {
|
||||||
this.notificationService.showError(err.message);
|
this.notificationService.showError(err.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.sharedLinksApiService.error
|
||||||
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
|
.subscribe((err: { message: string }) => {
|
||||||
|
this.notificationService.showError(err.message);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import CONSTANTS = require('../../util/constants');
|
import CONSTANTS = require('../../util/constants');
|
||||||
import { StringUtil, BrowserActions } from '@alfresco/adf-testing';
|
import { StringUtil, BrowserActions, NotificationHistoryPage } from '@alfresco/adf-testing';
|
||||||
import { NavigationBarPage } from '../../pages/adf/navigationBarPage';
|
import { NavigationBarPage } from '../../pages/adf/navigationBarPage';
|
||||||
import { LoginPage, ErrorPage } from '@alfresco/adf-testing';
|
import { LoginPage, ErrorPage } from '@alfresco/adf-testing';
|
||||||
import { ContentServicesPage } from '../../pages/adf/contentServicesPage';
|
import { ContentServicesPage } from '../../pages/adf/contentServicesPage';
|
||||||
@@ -35,6 +35,7 @@ describe('Unshare file', () => {
|
|||||||
const contentListPage = contentServicesPage.getDocumentList();
|
const contentListPage = contentServicesPage.getDocumentList();
|
||||||
const navBar = new NavigationBarPage();
|
const navBar = new NavigationBarPage();
|
||||||
const errorPage = new ErrorPage();
|
const errorPage = new ErrorPage();
|
||||||
|
const notificationHistoryPage = new NotificationHistoryPage();
|
||||||
const shareDialog = new ShareDialog();
|
const shareDialog = new ShareDialog();
|
||||||
const siteName = `PRIVATE-TEST-SITE-${StringUtil.generateRandomString(5)}`;
|
const siteName = `PRIVATE-TEST-SITE-${StringUtil.generateRandomString(5)}`;
|
||||||
|
|
||||||
@@ -171,9 +172,12 @@ describe('Unshare file', () => {
|
|||||||
contentServicesPage.clickShareButton();
|
contentServicesPage.clickShareButton();
|
||||||
shareDialog.checkDialogIsDisplayed();
|
shareDialog.checkDialogIsDisplayed();
|
||||||
shareDialog.shareToggleButtonIsChecked();
|
shareDialog.shareToggleButtonIsChecked();
|
||||||
shareDialog.shareToggleButtonIsDisabled();
|
|
||||||
shareDialog.clickUnShareFile();
|
shareDialog.clickUnShareFile();
|
||||||
shareDialog.confirmationDialogIsNotDisplayed();
|
shareDialog.confirmationDialogIsDisplayed();
|
||||||
|
shareDialog.clickConfirmationDialogRemoveButton();
|
||||||
|
shareDialog.checkDialogIsDisplayed();
|
||||||
|
shareDialog.shareToggleButtonIsChecked();
|
||||||
|
notificationHistoryPage.checkNotifyContains(`You don't have permission to unshare this file`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -52,4 +52,4 @@
|
|||||||
{{ 'SHARE.CLOSE' | translate }}
|
{{ 'SHARE.CLOSE' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -42,6 +42,7 @@ import {
|
|||||||
import { SharedLinkEntry, Node } from '@alfresco/js-api';
|
import { SharedLinkEntry, Node } from '@alfresco/js-api';
|
||||||
import { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
|
import { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
|
||||||
import moment from 'moment-es6';
|
import moment from 'moment-es6';
|
||||||
|
import { ContentNodeShareSettings } from './content-node-share.settings';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-share-dialog',
|
selector: 'adf-share-dialog',
|
||||||
@@ -82,7 +83,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
private nodesApiService: NodesApiService,
|
private nodesApiService: NodesApiService,
|
||||||
private contentService: ContentService,
|
private contentService: ContentService,
|
||||||
private renditionService: RenditionsService,
|
private renditionService: RenditionsService,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any
|
@Inject(MAT_DIALOG_DATA) public data: ContentNodeShareSettings
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -113,7 +114,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
this.baseShareUrl = this.data.baseShareUrl;
|
this.baseShareUrl = this.data.baseShareUrl;
|
||||||
const properties = this.data.node.entry.properties;
|
const properties = this.data.node.entry.properties;
|
||||||
|
|
||||||
if (properties && !properties['qshare:sharedId']) {
|
if (!properties || !properties['qshare:sharedId']) {
|
||||||
this.createSharedLinks(this.data.node.entry.id);
|
this.createSharedLinks(this.data.node.entry.id);
|
||||||
} else {
|
} else {
|
||||||
this.sharedId = properties['qshare:sharedId'];
|
this.sharedId = properties['qshare:sharedId'];
|
||||||
@@ -141,10 +142,13 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get canUpdate() {
|
get canUpdate() {
|
||||||
return this.contentService.hasAllowableOperations(
|
const { entry } = this.data.node;
|
||||||
this.data.node.entry,
|
|
||||||
'update'
|
if (entry && entry.allowableOperations) {
|
||||||
);
|
return this.contentService.hasAllowableOperations(entry, 'update');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onToggleExpirationDate(slideToggle: MatSlideToggleChange) {
|
onToggleExpirationDate(slideToggle: MatSlideToggleChange) {
|
||||||
@@ -195,9 +199,13 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
(sharedLink: SharedLinkEntry) => {
|
(sharedLink: SharedLinkEntry) => {
|
||||||
if (sharedLink.entry) {
|
if (sharedLink.entry) {
|
||||||
this.sharedId = sharedLink.entry.id;
|
this.sharedId = sharedLink.entry.id;
|
||||||
this.data.node.entry.properties[
|
if (this.data.node.entry.properties) {
|
||||||
'qshare:sharedId'
|
this.data.node.entry.properties['qshare:sharedId'] = this.sharedId;
|
||||||
] = this.sharedId;
|
} else {
|
||||||
|
this.data.node.entry.properties = {
|
||||||
|
'qshare:sharedId': this.sharedId
|
||||||
|
};
|
||||||
|
}
|
||||||
this.isDisabled = false;
|
this.isDisabled = false;
|
||||||
this.isFileShared = true;
|
this.isFileShared = true;
|
||||||
this.renditionService
|
this.renditionService
|
||||||
@@ -217,21 +225,20 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
deleteSharedLink(sharedId: string) {
|
deleteSharedLink(sharedId: string) {
|
||||||
this.isDisabled = true;
|
this.isDisabled = true;
|
||||||
|
|
||||||
this.sharedLinksApiService.deleteSharedLink(sharedId).subscribe(
|
this.sharedLinksApiService
|
||||||
(response: any) => {
|
.deleteSharedLink(sharedId)
|
||||||
|
.subscribe((response: any) => {
|
||||||
if (response instanceof Error) {
|
if (response instanceof Error) {
|
||||||
this.isDisabled = false;
|
this.isDisabled = false;
|
||||||
this.isFileShared = true;
|
this.isFileShared = true;
|
||||||
this.handleError(response);
|
this.handleError(response);
|
||||||
} else {
|
} else {
|
||||||
this.data.node.entry.properties['qshare:sharedId'] = null;
|
if (this.data.node.entry.properties) {
|
||||||
this.data.node.entry.properties['qshare:expiryDate'] = null;
|
this.data.node.entry.properties['qshare:sharedId'] = null;
|
||||||
|
this.data.node.entry.properties['qshare:expiryDate'] = null;
|
||||||
|
}
|
||||||
this.dialogRef.close(false);
|
this.dialogRef.close(false);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.isDisabled = false;
|
|
||||||
this.isFileShared = false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -256,7 +263,11 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private updateForm() {
|
private updateForm() {
|
||||||
const { entry } = this.data.node;
|
const { entry } = this.data.node;
|
||||||
const expiryDate = entry.properties['qshare:expiryDate'];
|
let expiryDate = null;
|
||||||
|
|
||||||
|
if (entry && entry.properties) {
|
||||||
|
expiryDate = entry.properties['qshare:expiryDate'];
|
||||||
|
}
|
||||||
|
|
||||||
this.form.setValue({
|
this.form.setValue({
|
||||||
sharedUrl: `${this.baseShareUrl}${this.sharedId}`,
|
sharedUrl: `${this.baseShareUrl}${this.sharedId}`,
|
||||||
@@ -277,8 +288,10 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
private updateEntryExpiryDate(date: moment.Moment) {
|
private updateEntryExpiryDate(date: moment.Moment) {
|
||||||
const { properties } = this.data.node.entry;
|
const { properties } = this.data.node.entry;
|
||||||
|
|
||||||
properties['qshare:expiryDate'] = date
|
if (properties) {
|
||||||
? date.local()
|
properties['qshare:expiryDate'] = date
|
||||||
: null;
|
? date.local()
|
||||||
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,9 +17,11 @@
|
|||||||
|
|
||||||
import { Directive, Input, HostListener, OnChanges, NgZone } from '@angular/core';
|
import { Directive, Input, HostListener, OnChanges, NgZone } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material';
|
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 { ShareDialogComponent } from './content-node-share.dialog';
|
||||||
|
import { Observable, from } from 'rxjs';
|
||||||
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[adf-share]',
|
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) {
|
shareNode(nodeEntry: NodeEntry) {
|
||||||
if (nodeEntry && nodeEntry.entry && nodeEntry.entry.isFile) {
|
if (nodeEntry && nodeEntry.entry && nodeEntry.entry.isFile) {
|
||||||
this.dialog.open(ShareDialogComponent, {
|
// shared and favorite
|
||||||
width: '600px',
|
const nodeId = nodeEntry.entry['nodeId'] || nodeEntry.entry['guid'];
|
||||||
panelClass: 'adf-share-link-dialog',
|
|
||||||
data: {
|
if (nodeId) {
|
||||||
node: nodeEntry,
|
this.getNodeInfo(nodeId).subscribe((entry) => {
|
||||||
baseShareUrl: this.baseShareUrl
|
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() {
|
ngOnChanges() {
|
||||||
this.zone.onStable.subscribe(() => {
|
this.zone.onStable.subscribe(() => {
|
||||||
if (this.node && this.node.entry) {
|
if (this.node && this.node.entry) {
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { NodeEntry } from '@alfresco/js-api';
|
||||||
|
|
||||||
|
export interface ContentNodeShareSettings {
|
||||||
|
baseShareUrl: string;
|
||||||
|
node: NodeEntry;
|
||||||
|
}
|
@@ -15,6 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export * from './content-node-share.settings';
|
||||||
export * from './content-node-share.dialog';
|
export * from './content-node-share.dialog';
|
||||||
export * from './content-node-share.directive';
|
export * from './content-node-share.directive';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user