mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-02 17:35:08 +00:00
review comments addressed
This commit is contained in:
parent
d6a8379f42
commit
be3d942d01
@ -105,7 +105,6 @@
|
|||||||
"requirednumbervisibility",
|
"requirednumbervisibility",
|
||||||
"rowspan",
|
"rowspan",
|
||||||
"selectitem",
|
"selectitem",
|
||||||
"seperation",
|
|
||||||
"sharedlinks",
|
"sharedlinks",
|
||||||
"sidenav",
|
"sidenav",
|
||||||
"snackbar",
|
"snackbar",
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-dialog-content>
|
<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">
|
<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-form-field class="adf-full-width adf-float-label" floatLabel='always'>
|
||||||
<mat-label>{{ 'SHARE.EXPIRATION-PLACEHOLDER' | translate }}</mat-label>
|
<mat-label>{{ 'SHARE.EXPIRATION-PLACEHOLDER' | translate }}</mat-label>
|
||||||
<mat-datetimepicker-toggle
|
<mat-datetimepicker-toggle
|
||||||
#matDatetimepickerToggle="matDatetimepickerToggle"
|
|
||||||
[disabled]="time.disabled"
|
[disabled]="time.disabled"
|
||||||
[for]="datetimePicker"
|
[for]="datetimePicker"
|
||||||
matSuffix
|
matSuffix
|
||||||
@ -110,7 +109,7 @@
|
|||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<hr class="adf-share-link__seperation-line" />
|
<hr class="adf-share-link__separation-line" />
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
|
|
||||||
<div mat-dialog-actions>
|
<div mat-dialog-actions>
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
color: var(--adf-theme-foreground-text-color-087);
|
color: var(--adf-theme-foreground-text-color-087);
|
||||||
}
|
}
|
||||||
|
|
||||||
&__seperation-line {
|
&__separation-line {
|
||||||
border: 1px solid var(--theme-grey-background-color);
|
border: 1px solid var(--theme-grey-background-color);
|
||||||
margin: 8px -24px 8px;
|
margin: 8px -24px 8px;
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mat-dialog-container {
|
.mat-dialog-container {
|
||||||
padding: 0px;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mat-form-field-appearance-legacy .mat-form-field-underline {
|
.mat-form-field-appearance-legacy .mat-form-field-underline {
|
||||||
|
@ -45,6 +45,13 @@ describe('ShareDialogComponent', () => {
|
|||||||
let component: ShareDialogComponent;
|
let component: ShareDialogComponent;
|
||||||
let appConfigService: AppConfigService;
|
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({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
@ -137,7 +144,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
expect(sharedLinksApiService.createSharedLinks).toHaveBeenCalled();
|
expect(sharedLinksApiService.createSharedLinks).toHaveBeenCalled();
|
||||||
expect(renditionService.getNodeRendition).toHaveBeenCalled();
|
expect(renditionService.getNodeRendition).toHaveBeenCalled();
|
||||||
expect(fixture.nativeElement.querySelector('input[formcontrolname="sharedUrl"]').value).toBe('some-url/sharedId');
|
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 () => {
|
it(`should not toggle share action when file has 'sharedId' property`, async () => {
|
||||||
@ -160,7 +167,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
|
|
||||||
expect(sharedLinksApiService.createSharedLinks).not.toHaveBeenCalled();
|
expect(sharedLinksApiService.createSharedLinks).not.toHaveBeenCalled();
|
||||||
expect(fixture.nativeElement.querySelector('input[formcontrolname="sharedUrl"]').value).toBe('some-url/sharedId');
|
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', () => {
|
it('should open a confirmation dialog when unshare button is triggered', () => {
|
||||||
@ -176,8 +183,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"] label')
|
clickShareToggleButton();
|
||||||
.dispatchEvent(new MouseEvent('click'));
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -196,8 +202,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"] label')
|
clickShareToggleButton();
|
||||||
.dispatchEvent(new MouseEvent('click'));
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -216,8 +221,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
fixture.nativeElement.querySelector('[data-automation-id="adf-share-toggle"] label')
|
clickShareToggleButton();
|
||||||
.dispatchEvent(new MouseEvent('click'));
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
@ -235,7 +239,7 @@ describe('ShareDialogComponent', () => {
|
|||||||
|
|
||||||
fixture.detectChanges();
|
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 () => {
|
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/'
|
baseShareUrl: 'some-url/'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
component.form.controls['time'].setValue(moment());
|
component.form.controls['time'].setValue(moment());
|
||||||
@ -283,7 +286,6 @@ describe('ShareDialogComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
|
|
||||||
expect(fixture.nativeElement.querySelector('.mat-slide-toggle[data-automation-id="adf-expire-toggle"]')
|
expect(fixture.nativeElement.querySelector('.mat-slide-toggle[data-automation-id="adf-expire-toggle"]')
|
||||||
.classList).toContain('mat-disabled');
|
.classList).toContain('mat-disabled');
|
||||||
expect(fixture.nativeElement.querySelector('[data-automation-id="adf-slide-toggle-checked"]')).toBe(null);
|
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 dateTimePickerType = 'date';
|
||||||
const date = moment('2525-01-01 13:00:00');
|
const date = moment('2525-01-01 13:00:00');
|
||||||
spyOn(appConfigService, 'get').and.callFake(() => dateTimePickerType as any);
|
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 dateTimePickerType = 'datetime';
|
||||||
const date = moment('2525-01-01 13:00:00');
|
const date = moment('2525-01-01 13:00:00');
|
||||||
spyOn(appConfigService, 'get').and.returnValue(dateTimePickerType);
|
spyOn(appConfigService, 'get').and.returnValue(dateTimePickerType);
|
||||||
|
@ -33,7 +33,7 @@ import {
|
|||||||
import { ContentService } from '../common/services/content.service';
|
import { ContentService } from '../common/services/content.service';
|
||||||
|
|
||||||
import { SharedLinksApiService } from './services/shared-links-api.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 { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { ContentNodeShareSettings } from './content-node-share.settings';
|
import { ContentNodeShareSettings } from './content-node-share.settings';
|
||||||
@ -42,11 +42,6 @@ import { RenditionService } from '../common/services/rendition.service';
|
|||||||
|
|
||||||
type DatePickerType = 'date' | 'time' | 'month' | 'datetime';
|
type DatePickerType = 'date' | 'time' | 'month' | 'datetime';
|
||||||
|
|
||||||
export interface NodeOptions {
|
|
||||||
nodeId: string;
|
|
||||||
expiresAt?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-share-dialog',
|
selector: 'adf-share-dialog',
|
||||||
templateUrl: './content-node-share.dialog.html',
|
templateUrl: './content-node-share.dialog.html',
|
||||||
@ -60,16 +55,16 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
sharedId: string;
|
sharedId: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
baseShareUrl: string;
|
baseShareUrl: string;
|
||||||
isFileShared: boolean = false;
|
isFileShared = false;
|
||||||
isDisabled: boolean = false;
|
isDisabled = false;
|
||||||
isLinkWithExpiryDate: boolean = false;
|
isLinkWithExpiryDate = false;
|
||||||
form: UntypedFormGroup = new UntypedFormGroup({
|
form: UntypedFormGroup = new UntypedFormGroup({
|
||||||
sharedUrl: new UntypedFormControl(''),
|
sharedUrl: new UntypedFormControl(''),
|
||||||
time: new UntypedFormControl({value: '', disabled: true})
|
time: new UntypedFormControl({value: '', disabled: true})
|
||||||
});
|
});
|
||||||
type: DatePickerType = 'datetime';
|
type: DatePickerType = 'datetime';
|
||||||
maxDebounceTime = 500;
|
maxDebounceTime = 500;
|
||||||
expiryDate: string;
|
expiryDate: Date;
|
||||||
isExpiryDateToggleChecked: boolean;
|
isExpiryDateToggleChecked: boolean;
|
||||||
|
|
||||||
@ViewChild('slideToggleExpirationDate', {static: true})
|
@ViewChild('slideToggleExpirationDate', {static: true})
|
||||||
@ -107,15 +102,8 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
this.isFileShared = true;
|
this.isFileShared = true;
|
||||||
|
|
||||||
const expiryDate = this.updateForm();
|
const expiryDate = this.updateForm();
|
||||||
if (expiryDate !== null && expiryDate !== undefined) {
|
this.isExpiryDateToggleChecked = this.isLinkWithExpiryDate = expiryDate !== null && expiryDate !== undefined;
|
||||||
this.time.enable();
|
this.isLinkWithExpiryDate ? this.time.enable() : this.time.disable();
|
||||||
this.isLinkWithExpiryDate = true;
|
|
||||||
this.isExpiryDateToggleChecked = true;
|
|
||||||
} else {
|
|
||||||
this.time.disable();
|
|
||||||
this.isExpiryDateToggleChecked = false;
|
|
||||||
this.isLinkWithExpiryDate = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,8 +159,6 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDatetimepickerClosed() {
|
onDatetimepickerClosed() {
|
||||||
this.dateTimePickerInput.nativeElement.blur();
|
|
||||||
|
|
||||||
if (!this.time.value) {
|
if (!this.time.value) {
|
||||||
this.slideToggleExpirationDate.checked = false;
|
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.isDisabled = true;
|
||||||
|
|
||||||
this.sharedLinksApiService.createSharedLinks(nodeId).subscribe(
|
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;
|
const {entry} = this.data.node;
|
||||||
this.expiryDate = null;
|
this.expiryDate = null;
|
||||||
|
|
||||||
@ -318,7 +304,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sharedLinkWithExpirySettings(expiryDate: string) {
|
private sharedLinkWithExpirySettings(expiryDate) {
|
||||||
const lastIndex = expiryDate?.lastIndexOf(':');
|
const lastIndex = expiryDate?.lastIndexOf(':');
|
||||||
expiryDate = expiryDate?.substring(0, lastIndex) + expiryDate?.substring(lastIndex + 1, expiryDate?.length);
|
expiryDate = expiryDate?.substring(0, lastIndex) + expiryDate?.substring(lastIndex + 1, expiryDate?.length);
|
||||||
const nodeObject = {
|
const nodeObject = {
|
||||||
|
@ -16,15 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
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 { Observable, from, of, Subject } from 'rxjs';
|
||||||
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
||||||
import { catchError } from 'rxjs/operators';
|
import { catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
interface NodeOptions {
|
|
||||||
nodeId: string;
|
|
||||||
expiresAt?: string;
|
|
||||||
}
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@ -69,14 +65,8 @@ export class SharedLinksApiService {
|
|||||||
* @param options Options supported by JS-API
|
* @param options Options supported by JS-API
|
||||||
* @returns The shared link just created
|
* @returns The shared link just created
|
||||||
*/
|
*/
|
||||||
createSharedLinks(nodeId: string | NodeOptions, options: any = {}): Observable<SharedLinkEntry> {
|
createSharedLinks(nodeId: string | SharedLinkBodyCreate, options: any = {}): Observable<SharedLinkEntry> {
|
||||||
let nodeOptions;
|
const promise = this.sharedLinksApi.createSharedLink(typeof nodeId === 'string' ? { nodeId } : nodeId, options);
|
||||||
if (typeof nodeId === 'string') {
|
|
||||||
nodeOptions = { nodeId };
|
|
||||||
} else {
|
|
||||||
nodeOptions = nodeId;
|
|
||||||
}
|
|
||||||
const promise = this.sharedLinksApi.createSharedLink( nodeOptions , options);
|
|
||||||
|
|
||||||
return from(promise).pipe(
|
return from(promise).pipe(
|
||||||
catchError((err) => of(err))
|
catchError((err) => of(err))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user