[AAE-11830] Changes required to address comment in APPS ()

This commit is contained in:
AleksanderSklorz 2022-12-16 14:32:05 +01:00 committed by GitHub
parent 90493c0056
commit a189ccd676
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 54 deletions

@ -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
})
);

@ -75,7 +75,7 @@ describe('DownloadEffects', () => {
new BehaviorSubject<VersionEntry>(null)
);
store.dispatch(
new DownloadNodesAction({
new DownloadNodesAction([], {
focusedElementOnCloseSelector: elementToFocusSelector
})
);
@ -104,7 +104,7 @@ describe('DownloadEffects', () => {
new BehaviorSubject<VersionEntry>(null)
);
store.dispatch(
new DownloadNodesAction({
new DownloadNodesAction([], {
focusedElementOnCloseSelector: ''
})
);

@ -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<DownloadNodesAction>(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);
}
});
}

@ -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<DeleteLibraryAction>(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<LeaveLibraryAction>(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);
}
});
}

@ -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<ShareNodeAction>(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<EditFolderAction>(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<CopyNodesAction>(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<MoveNodesAction>(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<ManagePermissionsAction>(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<ExpandInfoDrawerAction>(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<ManageVersionsAction>(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<ManageAspectsAction>(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<ManageRulesAction>(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

@ -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<UploadFileVersionAction>(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();
}
})

@ -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);
});

@ -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
});
}
}

@ -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) {}
}

@ -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<MinimalNodeEntity> | ModalConfiguration) {}
constructor(public payload: Array<MinimalNodeEntity>, public configuration?: ModalConfiguration) {}
}
export class MoveNodesAction implements Action {
readonly type = NodeActionTypes.Move;
constructor(public payload: Array<MinimalNodeEntity> | ModalConfiguration) {}
constructor(public payload: Array<MinimalNodeEntity>, 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 {

@ -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) {}
}