review comments addressed

This commit is contained in:
Jatin_Chugh 2023-05-09 18:02:30 +05:30
parent d6a8379f42
commit be3d942d01
6 changed files with 32 additions and 56 deletions

View File

@ -105,7 +105,6 @@
"requirednumbervisibility",
"rowspan",
"selectitem",
"seperation",
"sharedlinks",
"sidenav",
"snackbar",

View File

@ -9,7 +9,7 @@
</div>
<mat-dialog-content>
<hr class="adf-share-link__seperation-line" />
<hr class="adf-share-link__separation-line" />
<form [formGroup]="form" class="adf-share-link__form">
@ -34,7 +34,6 @@
<mat-form-field class="adf-full-width adf-float-label" floatLabel='always'>
<mat-label>{{ 'SHARE.EXPIRATION-PLACEHOLDER' | translate }}</mat-label>
<mat-datetimepicker-toggle
#matDatetimepickerToggle="matDatetimepickerToggle"
[disabled]="time.disabled"
[for]="datetimePicker"
matSuffix
@ -110,7 +109,7 @@
</form>
<hr class="adf-share-link__seperation-line" />
<hr class="adf-share-link__separation-line" />
</mat-dialog-content>
<div mat-dialog-actions>

View File

@ -60,7 +60,7 @@
color: var(--adf-theme-foreground-text-color-087);
}
&__seperation-line {
&__separation-line {
border: 1px solid var(--theme-grey-background-color);
margin: 8px -24px 8px;
}
@ -129,7 +129,7 @@
}
.mat-dialog-container {
padding: 0px;
padding: 0;
}
.mat-form-field-appearance-legacy .mat-form-field-underline {

View File

@ -45,6 +45,13 @@ describe('ShareDialogComponent', () => {
let component: ShareDialogComponent;
let appConfigService: AppConfigService;
const getShareToggleId = '[data-automation-id="adf-share-toggle"]';
const getShareToggleLinkedClasses = (): DOMTokenList => fixture.nativeElement.querySelector(getShareToggleId).classList;
const clickShareToggleButton = () => fixture.nativeElement.querySelector(`${getShareToggleId} label`)
.dispatchEvent(new MouseEvent('click'));
setupTestBed({
imports: [
TranslateModule.forRoot(),
@ -137,7 +144,7 @@ describe('ShareDialogComponent', () => {
expect(sharedLinksApiService.createSharedLinks).toHaveBeenCalled();
expect(renditionService.getNodeRendition).toHaveBeenCalled();
expect(fixture.nativeElement.querySelector('input[formcontrolname="sharedUrl"]').value).toBe('some-url/sharedId');
expect(fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"]').classList).toContain('mat-checked');
expect(getShareToggleLinkedClasses()).toContain('mat-checked');
});
it(`should not toggle share action when file has 'sharedId' property`, async () => {
@ -160,7 +167,7 @@ describe('ShareDialogComponent', () => {
expect(sharedLinksApiService.createSharedLinks).not.toHaveBeenCalled();
expect(fixture.nativeElement.querySelector('input[formcontrolname="sharedUrl"]').value).toBe('some-url/sharedId');
expect(fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"]').classList).toContain('mat-checked');
expect(getShareToggleLinkedClasses()).toContain('mat-checked');
});
it('should open a confirmation dialog when unshare button is triggered', () => {
@ -176,8 +183,7 @@ describe('ShareDialogComponent', () => {
fixture.detectChanges();
fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"] label')
.dispatchEvent(new MouseEvent('click'));
clickShareToggleButton();
fixture.detectChanges();
@ -196,8 +202,7 @@ describe('ShareDialogComponent', () => {
fixture.detectChanges();
fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"] label')
.dispatchEvent(new MouseEvent('click'));
clickShareToggleButton();
fixture.detectChanges();
@ -216,8 +221,7 @@ describe('ShareDialogComponent', () => {
fixture.detectChanges();
fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"] label')
.dispatchEvent(new MouseEvent('click'));
clickShareToggleButton();
fixture.detectChanges();
@ -235,7 +239,7 @@ describe('ShareDialogComponent', () => {
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"]').classList).toContain('mat-disabled');
expect(getShareToggleLinkedClasses()).toContain('mat-disabled');
});
it('should delete the current link generated with expiry date and generate a new link without expiry date when toggle is unchecked', async () => {
@ -251,7 +255,6 @@ describe('ShareDialogComponent', () => {
baseShareUrl: 'some-url/'
};
fixture.detectChanges();
component.form.controls['time'].setValue(moment());
@ -283,7 +286,6 @@ describe('ShareDialogComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
expect(fixture.nativeElement.querySelector('.mat-slide-toggle[data-automation-id="adf-expire-toggle"]')
.classList).toContain('mat-disabled');
expect(fixture.nativeElement.querySelector('[data-automation-id="adf-slide-toggle-checked"]')).toBe(null);
@ -304,7 +306,7 @@ describe('ShareDialogComponent', () => {
};
});
it('it should update node with input date and end of day time when type is `date`', fakeAsync(() => {
it('should update node with input date and end of day time when type is `date`', fakeAsync(() => {
const dateTimePickerType = 'date';
const date = moment('2525-01-01 13:00:00');
spyOn(appConfigService, 'get').and.callFake(() => dateTimePickerType as any);
@ -328,7 +330,7 @@ describe('ShareDialogComponent', () => {
});
}));
it('it should update node with input date and time when type is `datetime`', fakeAsync (() => {
it('should update node with input date and time when type is `datetime`', fakeAsync(() => {
const dateTimePickerType = 'datetime';
const date = moment('2525-01-01 13:00:00');
spyOn(appConfigService, 'get').and.returnValue(dateTimePickerType);

View File

@ -33,7 +33,7 @@ import {
import { ContentService } from '../common/services/content.service';
import { SharedLinksApiService } from './services/shared-links-api.service';
import { SharedLinkEntry } from '@alfresco/js-api';
import { SharedLinkBodyCreate, SharedLinkEntry } from '@alfresco/js-api';
import { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
import moment from 'moment';
import { ContentNodeShareSettings } from './content-node-share.settings';
@ -42,11 +42,6 @@ import { RenditionService } from '../common/services/rendition.service';
type DatePickerType = 'date' | 'time' | 'month' | 'datetime';
export interface NodeOptions {
nodeId: string;
expiresAt?: string;
}
@Component({
selector: 'adf-share-dialog',
templateUrl: './content-node-share.dialog.html',
@ -60,16 +55,16 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
sharedId: string;
fileName: string;
baseShareUrl: string;
isFileShared: boolean = false;
isDisabled: boolean = false;
isLinkWithExpiryDate: boolean = false;
isFileShared = false;
isDisabled = false;
isLinkWithExpiryDate = false;
form: UntypedFormGroup = new UntypedFormGroup({
sharedUrl: new UntypedFormControl(''),
time: new UntypedFormControl({value: '', disabled: true})
});
type: DatePickerType = 'datetime';
maxDebounceTime = 500;
expiryDate: string;
expiryDate: Date;
isExpiryDateToggleChecked: boolean;
@ViewChild('slideToggleExpirationDate', {static: true})
@ -107,15 +102,8 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
this.isFileShared = true;
const expiryDate = this.updateForm();
if (expiryDate !== null && expiryDate !== undefined) {
this.time.enable();
this.isLinkWithExpiryDate = true;
this.isExpiryDateToggleChecked = true;
} else {
this.time.disable();
this.isExpiryDateToggleChecked = false;
this.isLinkWithExpiryDate = false;
}
this.isExpiryDateToggleChecked = this.isLinkWithExpiryDate = expiryDate !== null && expiryDate !== undefined;
this.isLinkWithExpiryDate ? this.time.enable() : this.time.disable();
}
}
@ -171,8 +159,6 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
}
onDatetimepickerClosed() {
this.dateTimePickerInput.nativeElement.blur();
if (!this.time.value) {
this.slideToggleExpirationDate.checked = false;
}
@ -202,7 +188,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
});
}
private createSharedLinks(nodeId: string | NodeOptions) {
private createSharedLinks(nodeId: string | SharedLinkBodyCreate) {
this.isDisabled = true;
this.sharedLinksApiService.createSharedLinks(nodeId).subscribe(
@ -278,7 +264,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
});
}
private updateForm(): string {
private updateForm(): Date {
const {entry} = this.data.node;
this.expiryDate = null;
@ -318,7 +304,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
}
}
private sharedLinkWithExpirySettings(expiryDate: string) {
private sharedLinkWithExpirySettings(expiryDate) {
const lastIndex = expiryDate?.lastIndexOf(':');
expiryDate = expiryDate?.substring(0, lastIndex) + expiryDate?.substring(lastIndex + 1, expiryDate?.length);
const nodeObject = {

View File

@ -16,15 +16,11 @@
*/
import { Injectable } from '@angular/core';
import { NodePaging, SharedLinkEntry, SharedlinksApi } from '@alfresco/js-api';
import { NodePaging, SharedLinkBodyCreate, SharedLinkEntry, SharedlinksApi } from '@alfresco/js-api';
import { Observable, from, of, Subject } from 'rxjs';
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
import { catchError } from 'rxjs/operators';
interface NodeOptions {
nodeId: string;
expiresAt?: string;
}
@Injectable({
providedIn: 'root'
})
@ -69,14 +65,8 @@ export class SharedLinksApiService {
* @param options Options supported by JS-API
* @returns The shared link just created
*/
createSharedLinks(nodeId: string | NodeOptions, options: any = {}): Observable<SharedLinkEntry> {
let nodeOptions;
if (typeof nodeId === 'string') {
nodeOptions = { nodeId };
} else {
nodeOptions = nodeId;
}
const promise = this.sharedLinksApi.createSharedLink( nodeOptions , options);
createSharedLinks(nodeId: string | SharedLinkBodyCreate, options: any = {}): Observable<SharedLinkEntry> {
const promise = this.sharedLinksApi.createSharedLink(typeof nodeId === 'string' ? { nodeId } : nodeId, options);
return from(promise).pipe(
catchError((err) => of(err))