review comments addressed

This commit is contained in:
Jatin_Chugh
2023-06-07 10:45:59 +05:30
parent be3d942d01
commit 5e07676df7
2 changed files with 15 additions and 15 deletions
@@ -45,11 +45,11 @@ describe('ShareDialogComponent', () => {
let component: ShareDialogComponent; let component: ShareDialogComponent;
let appConfigService: AppConfigService; let appConfigService: AppConfigService;
const getShareToggleId = '[data-automation-id="adf-share-toggle"]'; const shareToggleId = '[data-automation-id="adf-share-toggle"]';
const getShareToggleLinkedClasses = (): DOMTokenList => fixture.nativeElement.querySelector(getShareToggleId).classList; const getShareToggleLinkedClasses = (): DOMTokenList => fixture.nativeElement.querySelector(shareToggleId).classList;
const clickShareToggleButton = () => fixture.nativeElement.querySelector(`${getShareToggleId} label`) const clickShareToggleButton = () => fixture.nativeElement.querySelector(`${shareToggleId} label`)
.dispatchEvent(new MouseEvent('click')); .dispatchEvent(new MouseEvent('click'));
setupTestBed({ setupTestBed({
@@ -64,7 +64,6 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
}); });
type: DatePickerType = 'datetime'; type: DatePickerType = 'datetime';
maxDebounceTime = 500; maxDebounceTime = 500;
expiryDate: Date;
isExpiryDateToggleChecked: boolean; isExpiryDateToggleChecked: boolean;
@ViewChild('slideToggleExpirationDate', {static: true}) @ViewChild('slideToggleExpirationDate', {static: true})
@@ -188,10 +187,10 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
}); });
} }
private createSharedLinks(nodeId: string | SharedLinkBodyCreate) { private createSharedLinks(sharedLinkParams: string | SharedLinkBodyCreate) {
this.isDisabled = true; this.isDisabled = true;
this.sharedLinksApiService.createSharedLinks(nodeId).subscribe( this.sharedLinksApiService.createSharedLinks(sharedLinkParams).subscribe(
(sharedLink: SharedLinkEntry) => { (sharedLink: SharedLinkEntry) => {
if (sharedLink.entry) { if (sharedLink.entry) {
this.sharedId = sharedLink.entry.id; this.sharedId = sharedLink.entry.id;
@@ -266,18 +265,18 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
private updateForm(): Date { private updateForm(): Date {
const {entry} = this.data.node; const {entry} = this.data.node;
this.expiryDate = null; let expiryDate = null;
if (entry && entry.properties) { if (entry && entry.properties) {
this.expiryDate = entry.properties['qshare:expiryDate']; expiryDate = entry.properties['qshare:expiryDate'];
} }
this.form.setValue({ this.form.setValue({
sharedUrl: `${this.baseShareUrl}${this.sharedId}`, sharedUrl: `${this.baseShareUrl}${this.sharedId}`,
time: this.expiryDate ? moment(this.expiryDate).local() : null time: expiryDate ? moment(expiryDate).local() : null
}, { emitEvent: false }); }, { emitEvent: false });
return this.expiryDate; return expiryDate;
} }
private updateNode(date: moment.Moment) { private updateNode(date: moment.Moment) {
@@ -304,16 +303,17 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
} }
} }
private sharedLinkWithExpirySettings(expiryDate) { private sharedLinkWithExpirySettings(expiryDate: Date | string) {
const lastIndex = expiryDate?.lastIndexOf(':'); if (typeof expiryDate === 'string') {
expiryDate = expiryDate?.substring(0, lastIndex) + expiryDate?.substring(lastIndex + 1, expiryDate?.length); const lastIndex = expiryDate?.lastIndexOf(':');
expiryDate = expiryDate?.substring(0, lastIndex) + expiryDate?.substring(lastIndex + 1, expiryDate?.length);
}
const nodeObject = { const nodeObject = {
nodeId: this.data.node.entry.id, nodeId: this.data.node.entry.id,
expiresAt: expiryDate expiresAt: expiryDate as Date
}; };
this.createSharedLinks(nodeObject); this.createSharedLinks(nodeObject);
} }
private updateEntryExpiryDate(date: moment.Moment) { private updateEntryExpiryDate(date: moment.Moment) {