[ACA-3379] Routing & skeleton for manage rules screen (#2575)

* [ACA-3379] Routing & skeleton for manage rules screen

* Linting

* Update routing so it's no longer lazy loaded

* Reverted to using lazy-loaded routes

* Remove action visibility from favourites, update e2e test data
This commit is contained in:
Thomas Hunter
2022-08-02 12:46:47 +01:00
committed by GitHub
parent 655da5aa2d
commit 30eebfa1e2
11 changed files with 95 additions and 35 deletions

View File

@@ -8,7 +8,8 @@
"loginRoute": "login",
"plugins": {
"aosPlugin": ${APP_CONFIG_PLUGIN_AOS},
"contentService": ${APP_CONFIG_PLUGIN_CONTENT_SERVICE}
"contentService": ${APP_CONFIG_PLUGIN_CONTENT_SERVICE},
"folderRules": ${APP_CONFIG_PLUGIN_FOLDER_RULES}
},
"oauth2": {
"host": "${APP_CONFIG_OAUTH2_HOST}",

View File

@@ -548,6 +548,15 @@ export const APP_ROUTES: Routes = [
}
]
},
{
path: 'nodes/:nodeId',
children: [
{
path: '',
loadChildren: () => import('@alfresco/aca-folder-rules').then((m) => m.AcaFolderRulesModule)
}
]
},
{
path: '**',
component: GenericErrorComponent

View File

@@ -74,7 +74,6 @@ import { forkJoin, Observable, of, zip } from 'rxjs';
import { catchError, map, mergeMap, take, tap } from 'rxjs/operators';
import { NodeActionsService } from './node-actions.service';
import { Router } from '@angular/router';
import { EditRuleDialogSmartComponent } from '@alfresco/aca-folder-rules';
interface RestoredNode {
status: number;
@@ -1079,13 +1078,4 @@ export class ContentManagementService {
.onAction()
.subscribe(() => this.undoMoveNodes(moveResponse, initialParentId));
}
manageRules(node: any) {
if (node && node.entry) {
this.dialogRef.open(EditRuleDialogSmartComponent, {
minWidth: '70%',
panelClass: 'aca-edit-rule-dialog-container'
});
}
}
}

View File

@@ -428,14 +428,14 @@ export class NodeEffects {
ofType<ManageRulesAction>(NodeActionTypes.ManageRules),
map((action) => {
if (action && action.payload) {
this.contentService.manageRules(action.payload);
this.store.dispatch(new NavigateRouteAction(['nodes', action.payload.entry.id, 'rules']));
} else {
this.store
.select(getAppSelection)
.pipe(take(1))
.subscribe((selection) => {
if (selection && !selection.isEmpty) {
this.contentService.manageRules(selection.nodes[0]);
this.store.dispatch(new NavigateRouteAction(['nodes', selection.first.entry.id, 'rules']));
}
});
}

View File

@@ -596,6 +596,18 @@
"visible": "canManagePermissions"
}
},
{
"id": "app.toolbar.rules",
"title": "ACA_FOLDER_RULES.ACTIONS.MANAGE_RULES",
"icon": "gavel",
"order": 1300,
"actions": {
"click": "MANAGE_RULES"
},
"rules": {
"visible": "rules.canManageFolderRules"
}
},
{
"id": "app.toolbar.deleteLibrary",
"order": 100,
@@ -813,6 +825,18 @@
"visible": "canManagePermissions"
}
},
{
"id": "app.context.menu.rules",
"title": "ACA_FOLDER_RULES.ACTIONS.MANAGE_RULES",
"icon": "gavel",
"order": 1600,
"actions": {
"click": "MANAGE_RULES"
},
"rules": {
"visible": "rules.canManageFolderRules"
}
},
{
"id": "app.context.menu.joinLibrary",
"type": "custom",

View File

@@ -808,20 +808,20 @@ export const folder2InTrash = {
// ---- folders ---
const folderContextMenu = ['Download', 'Edit', 'Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions'];
const folderFavContextMenu = ['Download', 'Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions'];
const folderContextMenu = ['Download', 'Edit', 'Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage rules'];
const folderFavContextMenu = ['Download', 'Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage rules'];
const folderToolbarPrimary = ['Download', 'View Details', 'More Actions'];
const folderToolbarMore = ['Edit', 'Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions'];
const folderFavToolbarMore = ['Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions'];
const folderToolbarMore = ['Edit', 'Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage rules'];
const folderFavToolbarMore = ['Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Edit Aspects', 'Permissions', 'Manage rules'];
const favoritesFolderFavContextMenu = ['Download', 'Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete'];
const favoritesFolderFavToolbarMore = ['Edit', 'Remove Favorite', 'Move', 'Copy', 'Delete'];
const searchFolderContextMenu = ['Download', 'Edit', 'Favorite', 'Copy', 'Edit Aspects', 'Permissions'];
const searchFolderContextMenu = ['Download', 'Edit', 'Favorite', 'Copy', 'Edit Aspects', 'Permissions', 'Manage rules'];
const searchFolderToolbarPrimary = ['Download', 'View Details', 'More Actions'];
const searchFolderToolbarMore = ['Edit', 'Favorite', 'Copy', 'Edit Aspects', 'Permissions'];
const searchFolderFavContextMenu = ['Download', 'Edit', 'Remove Favorite', 'Copy', 'Edit Aspects', 'Permissions'];
const searchFolderFavToolbarMore = ['Edit', 'Remove Favorite', 'Copy', 'Edit Aspects', 'Permissions'];
const searchFolderToolbarMore = ['Edit', 'Favorite', 'Copy', 'Edit Aspects', 'Permissions', 'Manage rules'];
const searchFolderFavContextMenu = ['Download', 'Edit', 'Remove Favorite', 'Copy', 'Edit Aspects', 'Permissions', 'Manage rules'];
const searchFolderFavToolbarMore = ['Edit', 'Remove Favorite', 'Copy', 'Edit Aspects', 'Permissions', 'Manage rules'];
export const folder = {
name: `folderActions-${random}`,

View File

@@ -1,10 +1,7 @@
{
"ACA_FOLDER_RULES": {
"MENU": {
"CREATE_RULES": "Create rules",
"CREATE_RULES_DESC": "[tbd] Creates new rules",
"LINK_RULES": "Link to rules set",
"LINK_RULES_DESC": "[tbd] Link to existing rules"
"ACTIONS": {
"MANAGE_RULES": "Manage rules"
},
"EDIT_RULE_DIALOG": {
"CANCEL": "Cancel",

View File

@@ -28,22 +28,30 @@ import { ExtensionService, provideExtensionConfig } from '@alfresco/adf-extensio
import { NgModule } from '@angular/core';
import * as rules from './folder-rules.rules';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { EditRuleDialogSmartComponent } from './rule-details/edit-rule-dialog.smart-component';
import { ManageRulesSmartComponent } from './manage-rules/manage-rules.smart-component';
import { RuleDetailsUiComponent } from './rule-details/rule-details.ui-component';
const routes: Routes = [
{
path: 'rules',
component: ManageRulesSmartComponent
}
];
@NgModule({
providers: [provideExtensionConfig(['folder-rules.plugin.json'])],
imports: [CommonModule, CoreModule.forChild()],
declarations: [EditRuleDialogSmartComponent, RuleDetailsUiComponent]
imports: [CommonModule, RouterModule.forChild(routes), CoreModule.forChild()],
declarations: [EditRuleDialogSmartComponent, ManageRulesSmartComponent, RuleDetailsUiComponent]
})
export class AcaFolderRulesModule {
constructor(translation: TranslationService, extensions: ExtensionService) {
translation.addTranslationFolder('aca-folder-rules', 'assets/aca-folder-rules');
extensions.setEvaluators({
'rules.canCreateFolderRule': rules.canCreateFolderRule,
'rules.canLinkFolderRule': rules.canLinkFolderRule
'rules.canManageFolderRules': rules.canManageFolderRules
});
}
}

View File

@@ -23,11 +23,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { AcaRuleContext, hasFolderSelected, canEditFolder } from '@alfresco/aca-shared/rules';
import { AcaRuleContext, hasFolderSelected, canEditFolder, isNotFavorites } from '@alfresco/aca-shared/rules';
export const isFolderRulesEnabled = (context: AcaRuleContext) => context.appConfig.get<boolean>('plugins.folderRules', false);
export const isFolderRulesAllowed = (context: AcaRuleContext) =>
isFolderRulesEnabled(context) && canEditFolder(context) && hasFolderSelected(context);
isFolderRulesEnabled(context) && canEditFolder(context) && hasFolderSelected(context) && isNotFavorites(context);
export const canCreateFolderRule = (context: AcaRuleContext): boolean => isFolderRulesAllowed(context);
export const canLinkFolderRule = (context: AcaRuleContext): boolean => isFolderRulesAllowed(context);
export const canManageFolderRules = (context: AcaRuleContext): boolean => isFolderRulesAllowed(context);

View File

@@ -0,0 +1,32 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component } from '@angular/core';
@Component({
selector: 'aca-manage-rules',
template: `<div>This is the Manage Rules component</div>`
})
export class ManageRulesSmartComponent {}

View File

@@ -24,4 +24,4 @@
*/
export * from './lib/folder-rules.module';
export { EditRuleDialogSmartComponent } from './lib/rule-details/edit-rule-dialog.smart-component';
export { ManageRulesSmartComponent } from './lib/manage-rules/manage-rules.smart-component';