diff --git a/app/src/app/content-plugin/components/common/toggle-shared/toggle-shared.component.ts b/app/src/app/content-plugin/components/common/toggle-shared/toggle-shared.component.ts index cffb9a992..a3f920fda 100644 --- a/app/src/app/content-plugin/components/common/toggle-shared/toggle-shared.component.ts +++ b/app/src/app/content-plugin/components/common/toggle-shared/toggle-shared.component.ts @@ -58,8 +58,7 @@ export class ToggleSharedComponent implements OnInit { editSharedNode(selection: SelectionState, focusedElementOnCloseSelector: string) { this.store.dispatch( - new ShareNodeAction({ - ...selection.first, + new ShareNodeAction(selection.first, { focusedElementOnCloseSelector }) ); diff --git a/app/src/app/content-plugin/store/effects/download.effects.spec.ts b/app/src/app/content-plugin/store/effects/download.effects.spec.ts index df81df9a4..ced9e3ba1 100644 --- a/app/src/app/content-plugin/store/effects/download.effects.spec.ts +++ b/app/src/app/content-plugin/store/effects/download.effects.spec.ts @@ -75,7 +75,7 @@ describe('DownloadEffects', () => { new BehaviorSubject(null) ); store.dispatch( - new DownloadNodesAction({ + new DownloadNodesAction([], { focusedElementOnCloseSelector: elementToFocusSelector }) ); @@ -104,7 +104,7 @@ describe('DownloadEffects', () => { new BehaviorSubject(null) ); store.dispatch( - new DownloadNodesAction({ + new DownloadNodesAction([], { focusedElementOnCloseSelector: '' }) ); diff --git a/app/src/app/content-plugin/store/effects/download.effects.ts b/app/src/app/content-plugin/store/effects/download.effects.ts index e7bcb0846..782217bd2 100644 --- a/app/src/app/content-plugin/store/effects/download.effects.ts +++ b/app/src/app/content-plugin/store/effects/download.effects.ts @@ -31,7 +31,7 @@ import { MatDialog } from '@angular/material/dialog'; import { Actions, ofType, createEffect } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { map, take } from 'rxjs/operators'; -import { ContentApiService, ModalConfiguration } from '@alfresco/aca-shared'; +import { ContentApiService } from '@alfresco/aca-shared'; import { ContentUrlService } from '../../services/content-url.service'; @Injectable() @@ -49,7 +49,7 @@ export class DownloadEffects { this.actions$.pipe( ofType(NodeActionTypes.Download), map((action) => { - if (Array.isArray(action.payload) && action.payload?.length > 0) { + if (action.payload?.length > 0) { this.downloadNodes(action.payload); } else { this.store @@ -64,7 +64,7 @@ export class DownloadEffects { if (version) { this.downloadFileVersion(selection.nodes[0].entry, version.entry); } else { - this.downloadNodes(selection.nodes, (action.payload as ModalConfiguration)?.focusedElementOnCloseSelector); + this.downloadNodes(selection.nodes, action.configuration?.focusedElementOnCloseSelector); } }); } diff --git a/app/src/app/content-plugin/store/effects/library.effects.ts b/app/src/app/content-plugin/store/effects/library.effects.ts index ad12e7732..e6ab9c50d 100644 --- a/app/src/app/content-plugin/store/effects/library.effects.ts +++ b/app/src/app/content-plugin/store/effects/library.effects.ts @@ -39,7 +39,7 @@ import { Injectable } from '@angular/core'; import { Actions, ofType, createEffect } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { map, mergeMap, take } from 'rxjs/operators'; -import { ContentApiService, ModalConfiguration } from '@alfresco/aca-shared'; +import { ContentApiService } from '@alfresco/aca-shared'; import { ContentManagementService } from '../../services/content-management.service'; @Injectable() @@ -56,7 +56,7 @@ export class LibraryEffects { this.actions$.pipe( ofType(LibraryActionTypes.Delete), map((action) => { - if (typeof action?.payload === 'string') { + if (action.payload) { this.content.deleteLibrary(action.payload); } else { this.store @@ -78,7 +78,7 @@ export class LibraryEffects { this.actions$.pipe( ofType(LibraryActionTypes.Leave), map((action) => { - if (typeof action.payload === 'string') { + if (action.payload) { this.content.leaveLibrary(action.payload); } else { this.store @@ -86,7 +86,7 @@ export class LibraryEffects { .pipe(take(1)) .subscribe((selection) => { if (selection && selection.library) { - this.content.leaveLibrary(selection.library.entry.id, (action.payload as ModalConfiguration)?.focusedElementOnCloseSelector); + this.content.leaveLibrary(selection.library.entry.id, action.configuration?.focusedElementOnCloseSelector); } }); } diff --git a/app/src/app/content-plugin/store/effects/node.effects.ts b/app/src/app/content-plugin/store/effects/node.effects.ts index 4b8fa9b5a..e3e279e5e 100644 --- a/app/src/app/content-plugin/store/effects/node.effects.ts +++ b/app/src/app/content-plugin/store/effects/node.effects.ts @@ -54,7 +54,6 @@ import { } from '@alfresco/aca-shared/store'; import { ContentManagementService } from '../../services/content-management.service'; import { ViewUtilService } from '@alfresco/adf-core'; -import { ModalConfiguration } from '@alfresco/aca-shared'; @Injectable() export class NodeEffects { @@ -70,15 +69,15 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.Share), map((action) => { - if (action.payload?.entry) { - this.contentService.shareNode(action.payload, action.payload?.focusedElementOnCloseSelector); + if (action.payload) { + this.contentService.shareNode(action.payload, action.configuration?.focusedElementOnCloseSelector); } else { this.store .select(getAppSelection) .pipe(take(1)) .subscribe((selection) => { if (selection && selection.file) { - this.contentService.shareNode(selection.file, action.payload?.focusedElementOnCloseSelector); + this.contentService.shareNode(selection.file, action.configuration?.focusedElementOnCloseSelector); } }); } @@ -216,7 +215,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.EditFolder), map((action) => { - if (action.payload?.entry) { + if (action.payload) { this.contentService.editFolder(action.payload); } else { this.store @@ -224,7 +223,7 @@ export class NodeEffects { .pipe(take(1)) .subscribe((selection) => { if (selection && selection.folder) { - this.contentService.editFolder(selection.folder, action.payload?.focusedElementOnCloseSelector); + this.contentService.editFolder(selection.folder, action.configuration?.focusedElementOnCloseSelector); } }); } @@ -238,7 +237,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.Copy), map((action) => { - if (Array.isArray(action.payload) && action.payload?.length > 0) { + if (action.payload?.length > 0) { this.contentService.copyNodes(action.payload); } else { this.store @@ -246,7 +245,7 @@ export class NodeEffects { .pipe(take(1)) .subscribe((selection) => { if (selection && !selection.isEmpty) { - this.contentService.copyNodes(selection.nodes, (action.payload as ModalConfiguration)?.focusedElementOnCloseSelector); + this.contentService.copyNodes(selection.nodes, action.configuration?.focusedElementOnCloseSelector); } }); } @@ -260,7 +259,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.Move), map((action) => { - if (Array.isArray(action.payload) && action.payload?.length > 0) { + if (action.payload?.length > 0) { this.contentService.moveNodes(action.payload); } else { this.store @@ -268,7 +267,7 @@ export class NodeEffects { .pipe(take(1)) .subscribe((selection) => { if (selection && !selection.isEmpty) { - this.contentService.moveNodes(selection.nodes, (action.payload as ModalConfiguration)?.focusedElementOnCloseSelector); + this.contentService.moveNodes(selection.nodes, action.configuration?.focusedElementOnCloseSelector); } }); } @@ -282,7 +281,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.ManagePermissions), map((action) => { - if (action?.payload?.entry) { + if (action?.payload) { const route = 'personal-files/details'; this.store.dispatch(new NavigateRouteAction([route, action.payload.entry.id, 'permissions'])); } else { @@ -306,7 +305,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.ExpandInfoDrawer), map((action) => { - if (action?.payload?.entry) { + if (action?.payload) { const route = 'personal-files/details'; this.store.dispatch(new NavigateRouteAction([route, action.payload.entry.id])); } else { @@ -330,7 +329,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.ManageVersions), map((action) => { - if (action?.payload?.entry) { + if (action?.payload) { this.contentService.manageVersions(action.payload); } else { this.store @@ -338,7 +337,7 @@ export class NodeEffects { .pipe(take(1)) .subscribe((selection) => { if (selection && selection.file) { - this.contentService.manageVersions(selection.file, action.payload?.focusedElementOnCloseSelector); + this.contentService.manageVersions(selection.file, action.configuration?.focusedElementOnCloseSelector); } }); } @@ -396,7 +395,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.ChangeAspects), map((action) => { - if (action?.payload?.entry) { + if (action?.payload) { this.contentService.manageAspects(action.payload); } else { this.store @@ -404,7 +403,7 @@ export class NodeEffects { .pipe(take(1)) .subscribe((selection) => { if (selection && !selection.isEmpty) { - this.contentService.manageAspects(selection.nodes[0], action.payload?.focusedElementOnCloseSelector); + this.contentService.manageAspects(selection.nodes[0], action.configuration?.focusedElementOnCloseSelector); } }); } @@ -430,7 +429,7 @@ export class NodeEffects { this.actions$.pipe( ofType(NodeActionTypes.ManageRules), map((action) => { - if (action?.payload?.entry) { + if (action?.payload) { this.store.dispatch(new NavigateRouteAction(['nodes', action.payload.entry.id, 'rules'])); } else { this.store diff --git a/app/src/app/content-plugin/store/effects/upload.effects.ts b/app/src/app/content-plugin/store/effects/upload.effects.ts index 6ce394063..c77888028 100644 --- a/app/src/app/content-plugin/store/effects/upload.effects.ts +++ b/app/src/app/content-plugin/store/effects/upload.effects.ts @@ -41,7 +41,6 @@ import { of } from 'rxjs'; import { catchError, map, take } from 'rxjs/operators'; import { ContentManagementService } from '../../services/content-management.service'; import { MinimalNodeEntryEntity } from '@alfresco/js-api'; -import { ModalConfiguration } from '@alfresco/aca-shared'; @Injectable() export class UploadEffects { @@ -116,15 +115,12 @@ export class UploadEffects { this.actions$.pipe( ofType(UploadActionTypes.UploadFileVersion), map((action) => { - if (action?.payload instanceof CustomEvent) { + if (action?.payload) { const node = action?.payload?.detail?.data?.node?.entry; const file: any = action?.payload?.detail?.files[0]?.file; this.contentService.versionUpdateDialog(node, file); - } else if (!action?.payload || !(action.payload instanceof CustomEvent)) { - this.registerFocusingElementAfterModalClose( - this.fileVersionInput, - (action?.payload as ModalConfiguration)?.focusedElementOnCloseSelector - ); + } else if (!action?.payload) { + this.registerFocusingElementAfterModalClose(this.fileVersionInput, action.configuration?.focusedElementOnCloseSelector); this.fileVersionInput.click(); } }) diff --git a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts index 5dbaabf46..2cd3f811e 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts @@ -287,7 +287,8 @@ describe('AppExtensionService', () => { service.runActionById('aca:actions/create-folder'); expect(store.dispatch).toHaveBeenCalledWith({ type: 'CREATE_FOLDER', - payload: 'folder-name' + payload: 'folder-name', + configuration: undefined } as Action); }); diff --git a/projects/aca-shared/src/lib/services/app.extension.service.ts b/projects/aca-shared/src/lib/services/app.extension.service.ts index 71e044973..4074f51e9 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.ts @@ -57,6 +57,7 @@ import { ViewerRules } from '../models/viewer.rules'; import { SettingsGroupRef } from '../models/types'; import { NodePermissionService } from '../services/node-permission.service'; import { filter, map } from 'rxjs/operators'; +import { ModalConfiguration } from '@alfresco/aca-shared'; @Injectable({ providedIn: 'root' @@ -498,7 +499,7 @@ export class AppExtensionService implements RuleContext { return false; } - runActionById(id: string, additionalPayload?: { [key: string]: any }) { + runActionById(id: string, additionalPayload?: ModalConfiguration) { const action = this.extensions.getActionById(id); if (action) { const { type, payload } = action; @@ -509,18 +510,13 @@ export class AppExtensionService implements RuleContext { this.store.dispatch({ type, - payload: - typeof expression === 'object' - ? { - ...expression, - ...additionalPayload - } - : expression + payload: expression, + configuration: additionalPayload }); } else { this.store.dispatch({ type: id, - payload: additionalPayload + configuration: additionalPayload }); } } diff --git a/projects/aca-shared/store/src/actions/library.actions.ts b/projects/aca-shared/store/src/actions/library.actions.ts index 51d3e4e7d..69cff9a4e 100644 --- a/projects/aca-shared/store/src/actions/library.actions.ts +++ b/projects/aca-shared/store/src/actions/library.actions.ts @@ -60,5 +60,5 @@ export class UpdateLibraryAction implements Action { export class LeaveLibraryAction implements Action { readonly type = LibraryActionTypes.Leave; - constructor(public payload?: string | ModalConfiguration) {} + constructor(public payload?: string, public configuration?: ModalConfiguration) {} } diff --git a/projects/aca-shared/store/src/actions/node.actions.ts b/projects/aca-shared/store/src/actions/node.actions.ts index 3def3199a..eca093b9b 100644 --- a/projects/aca-shared/store/src/actions/node.actions.ts +++ b/projects/aca-shared/store/src/actions/node.actions.ts @@ -85,7 +85,7 @@ export class PurgeDeletedNodesAction implements Action { export class DownloadNodesAction implements Action { readonly type = NodeActionTypes.Download; - constructor(public payload: MinimalNodeEntity[] | ModalConfiguration = []) {} + constructor(public payload: MinimalNodeEntity[] = [], public configuration?: ModalConfiguration) {} } export class CreateFolderAction implements Action { @@ -97,13 +97,13 @@ export class CreateFolderAction implements Action { export class EditFolderAction implements Action { readonly type = NodeActionTypes.EditFolder; - constructor(public payload: MinimalNodeEntity & ModalConfiguration) {} + constructor(public payload: MinimalNodeEntity, public configuration?: ModalConfiguration) {} } export class ShareNodeAction implements Action { readonly type = NodeActionTypes.Share; - constructor(public payload: MinimalNodeEntity & ModalConfiguration) {} + constructor(public payload: MinimalNodeEntity, public configuration?: ModalConfiguration) {} } export class UnshareNodesAction implements Action { @@ -115,13 +115,13 @@ export class UnshareNodesAction implements Action { export class CopyNodesAction implements Action { readonly type = NodeActionTypes.Copy; - constructor(public payload: Array | ModalConfiguration) {} + constructor(public payload: Array, public configuration?: ModalConfiguration) {} } export class MoveNodesAction implements Action { readonly type = NodeActionTypes.Move; - constructor(public payload: Array | ModalConfiguration) {} + constructor(public payload: Array, public configuration?: ModalConfiguration) {} } export class ManagePermissionsAction implements Action { @@ -144,7 +144,7 @@ export class PrintFileAction implements Action { export class ManageVersionsAction implements Action { readonly type = NodeActionTypes.ManageVersions; - constructor(public payload: MinimalNodeEntity & ModalConfiguration) {} + constructor(public payload: MinimalNodeEntity, public configuration?: ModalConfiguration) {} } export class EditOfflineAction implements Action { @@ -173,7 +173,7 @@ export class RemoveFavoriteAction implements Action { export class ManageAspectsAction implements Action { readonly type = NodeActionTypes.ChangeAspects; - constructor(public payload: MinimalNodeEntity & ModalConfiguration) {} + constructor(public payload: MinimalNodeEntity, public configuration?: ModalConfiguration) {} } export class ManageRulesAction implements Action { diff --git a/projects/aca-shared/store/src/actions/upload.actions.ts b/projects/aca-shared/store/src/actions/upload.actions.ts index 9bfaaaf09..a9975f407 100644 --- a/projects/aca-shared/store/src/actions/upload.actions.ts +++ b/projects/aca-shared/store/src/actions/upload.actions.ts @@ -47,5 +47,5 @@ export class UploadFolderAction implements Action { export class UploadFileVersionAction implements Action { readonly type = UploadActionTypes.UploadFileVersion; - constructor(public payload: CustomEvent | ModalConfiguration) {} + constructor(public payload: CustomEvent, public configuration?: ModalConfiguration) {} }