diff --git a/cspell.json b/cspell.json
index ae003ba4bb..f86d5fc0dd 100644
--- a/cspell.json
+++ b/cspell.json
@@ -105,7 +105,6 @@
"requirednumbervisibility",
"rowspan",
"selectitem",
- "seperation",
"sharedlinks",
"sidenav",
"snackbar",
diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html
index b3d2ab9db9..cf7a533946 100644
--- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html
+++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.html
@@ -9,7 +9,7 @@
-
+
diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.scss b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.scss
index 05ec406de2..d28e1fecbe 100644
--- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.scss
+++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.scss
@@ -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 {
diff --git a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts
index 42e8c53eda..4c586cd9ba 100644
--- a/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts
+++ b/lib/content-services/src/lib/content-node-share/content-node-share.dialog.spec.ts
@@ -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);
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 84a1b60dd1..c327a05a32 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
@@ -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 = {
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 e37ad9ad2a..84951dca38 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
@@ -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 {
- 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 {
+ const promise = this.sharedLinksApi.createSharedLink(typeof nodeId === 'string' ? { nodeId } : nodeId, options);
return from(promise).pipe(
catchError((err) => of(err))