From 642af1f4885b7eaf51fa0750803c54e403f9f2fa Mon Sep 17 00:00:00 2001 From: Jatin_Chugh Date: Mon, 29 May 2023 19:36:40 +0530 Subject: [PATCH] review comments for date-fns addressed --- .../content-node-share.dialog.ts | 21 +++++++++---------- .../services/shared-links-api.service.ts | 5 +++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts index 209aa20590..3236789ab9 100644 --- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts +++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.ts @@ -38,9 +38,7 @@ import { ConfirmDialogComponent } from '../dialogs/confirm.dialog'; import { ContentNodeShareSettings } from './content-node-share.settings'; import { takeUntil, debounceTime } from 'rxjs/operators'; import { RenditionService } from '../common/services/rendition.service'; -import { format } from 'date-fns'; -import add from 'date-fns/add'; -import endOfDay from 'date-fns/endOfDay'; +import { format, add, endOfDay } from 'date-fns'; type DatePickerType = 'date' | 'time' | 'month' | 'datetime'; @@ -117,7 +115,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy { .subscribe(value => this.onTimeChanged(value)); } - onTimeChanged(date: Date | string) { + onTimeChanged(date: Date) { this.updateNode(date); } @@ -160,6 +158,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy { } onDatetimepickerClosed() { + this.dateTimePickerInput.nativeElement.blur(); if (!this.time.value) { this.slideToggleExpirationDate.checked = false; } @@ -189,10 +188,10 @@ export class ShareDialogComponent implements OnInit, OnDestroy { }); } - private createSharedLinks(sharedLinkParams: string | SharedLinkBodyCreate) { + private createSharedLinks(nodeId: string, sharedLinkWithExpirySettings?: SharedLinkBodyCreate) { this.isDisabled = true; - this.sharedLinksApiService.createSharedLinks(sharedLinkParams).subscribe( + this.sharedLinksApiService.createSharedLinks(nodeId, sharedLinkWithExpirySettings).subscribe( (sharedLink: SharedLinkEntry) => { if (sharedLink.entry) { this.sharedId = sharedLink.entry.id; @@ -281,7 +280,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy { return expiryDate; } - private updateNode(date: Date | string) { + private updateNode(date: Date) { let expiryDate: Date | string; if (date) { if (this.type === 'date') { @@ -302,7 +301,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy { this.isFileShared = true; this.handleError(response); } else { - this.sharedLinkWithExpirySettings(expiryDate); + this.sharedLinkWithExpirySettings(expiryDate as Date); this.isLinkWithExpiryDate = true; this.updateEntryExpiryDate(date); } @@ -310,15 +309,15 @@ export class ShareDialogComponent implements OnInit, OnDestroy { } } - private sharedLinkWithExpirySettings(expiryDate: Date | string) { + private sharedLinkWithExpirySettings(expiryDate: Date) { const nodeObject: SharedLinkBodyCreate = { nodeId: this.data.node.entry.id, expiresAt: expiryDate as Date }; - this.createSharedLinks(nodeObject); + this.createSharedLinks(this.data.node.entry.id, nodeObject); } - private updateEntryExpiryDate(date: Date | string) { + private updateEntryExpiryDate(date: Date) { const {properties} = this.data.node.entry; if (properties) { diff --git a/lib/content-services/src/lib/content-node-share/services/shared-links-api.service.ts b/lib/content-services/src/lib/content-node-share/services/shared-links-api.service.ts index 84951dca38..aa113d1cae 100644 --- a/lib/content-services/src/lib/content-node-share/services/shared-links-api.service.ts +++ b/lib/content-services/src/lib/content-node-share/services/shared-links-api.service.ts @@ -62,11 +62,12 @@ export class SharedLinksApiService { * Creates a shared link available to the current user. * * @param nodeId ID of the node to link to + * @param sharedLinkWithExpirySettings shared link with nodeId and expiryDate * @param options Options supported by JS-API * @returns The shared link just created */ - createSharedLinks(nodeId: string | SharedLinkBodyCreate, options: any = {}): Observable { - const promise = this.sharedLinksApi.createSharedLink(typeof nodeId === 'string' ? { nodeId } : nodeId, options); + createSharedLinks(nodeId: string, sharedLinkWithExpirySettings?: SharedLinkBodyCreate, options: any = {}): Observable { + const promise = this.sharedLinksApi.createSharedLink(sharedLinkWithExpirySettings? sharedLinkWithExpirySettings : { nodeId }, options); return from(promise).pipe( catchError((err) => of(err))