Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AAE-11830] Changes required to address comment in APPS #2848

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('DownloadEffects', () => {
new BehaviorSubject<VersionEntry>(null)
);
store.dispatch(
new DownloadNodesAction({
new DownloadNodesAction([], {
focusedElementOnCloseSelector: elementToFocusSelector
})
);
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('DownloadEffects', () => {
new BehaviorSubject<VersionEntry>(null)
);
store.dispatch(
new DownloadNodesAction({
new DownloadNodesAction([], {
focusedElementOnCloseSelector: ''
})
);
Expand Down
6 changes: 3 additions & 3 deletions app/src/app/content-plugin/store/effects/download.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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);
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/app/content-plugin/store/effects/library.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -78,15 +78,15 @@ 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
.select(getAppSelection)
.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);
}
});
}
Expand Down
33 changes: 16 additions & 17 deletions app/src/app/content-plugin/store/effects/node.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
});
}
Expand Down Expand Up @@ -216,15 +215,15 @@ 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
.select(getAppSelection)
.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);
}
});
}
Expand All @@ -238,15 +237,15 @@ 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
.select(getAppSelection)
.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);
}
});
}
Expand All @@ -260,15 +259,15 @@ 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
.select(getAppSelection)
.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);
}
});
}
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -330,15 +329,15 @@ 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
.select(getAppSelection)
.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);
}
});
}
Expand Down Expand Up @@ -396,15 +395,15 @@ 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
.select(getAppSelection)
.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);
}
});
}
Expand All @@ -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
Expand Down
10 changes: 3 additions & 7 deletions app/src/app/content-plugin/store/effects/upload.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
14 changes: 5 additions & 9 deletions projects/aca-shared/src/lib/services/app.extension.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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;
Expand All @@ -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
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion projects/aca-shared/store/src/actions/library.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
14 changes: 7 additions & 7 deletions projects/aca-shared/store/src/actions/node.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion projects/aca-shared/store/src/actions/upload.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}