Rollback visibility rules cleanup (#4426)

* Revert "[ACS-9369] Updated rule-migration-guide.md to include missed rule (#4420)"

This reverts commit b3e2af7f0f.

* Revert "[ACS-9369] Resolved issues where visibility rules with a single element array would log errors (#4416)"

This reverts commit 4e33f1126d.

* Revert "[ACS-8694] Cleanup of visibility rules for extensions in ACA (#4140)"

This reverts commit f1c4dcf45d.
This commit is contained in:
swapnil-verma-gl
2025-03-03 16:56:13 +05:30
committed by GitHub
parent 4e37f194ac
commit 2efea8c6d8
18 changed files with 1130 additions and 930 deletions

View File

@@ -15,9 +15,7 @@
"id": "app.toolbar.rules.separator",
"type": "separator",
"rules": {
"visible": [
"app.selection.folder"
]
"visible": "app.selection.folder"
}
},
{
@@ -26,9 +24,7 @@
"description": "ACA_FOLDER_RULES.MENU.CREATE_RULES_DESC",
"icon": "add",
"rules": {
"visible": [
"rules.canCreateFolderRule"
]
"visible": "rules.canCreateFolderRule"
}
},
{
@@ -37,9 +33,7 @@
"description": "ACA_FOLDER_RULES.MENU.LINK_RULES_DESC",
"icon": "link",
"rules": {
"visible": [
"rules.canLinkFolderRule"
]
"visible": "rules.canLinkFolderRule"
}
}
]
@@ -51,9 +45,7 @@
"id": "app.toolbar.rules.separator",
"type": "separator",
"rules": {
"visible": [
"app.selection.folder"
]
"visible": "app.selection.folder"
}
},
{
@@ -62,9 +54,7 @@
"description": "ACA_FOLDER_RULES.MENU.CREATE_RULES_DESC",
"icon": "add",
"rules": {
"visible": [
"rules.canCreateFolderRule"
]
"visible": "rules.canCreateFolderRule"
}
},
{
@@ -73,9 +63,7 @@
"description": "ACA_FOLDER_RULES.MENU.LINK_RULES_DESC",
"icon": "link",
"rules": {
"visible": [
"rules.canLinkFolderRule"
]
"visible": "rules.canLinkFolderRule"
}
}
]

View File

@@ -77,7 +77,7 @@ export class AcaFolderRulesModule {
translation.addTranslationFolder('folder-rules', 'assets/folder-rules');
extensions.setEvaluators({
'rules.isFolderRulesEnabled': rules.isFolderRulesEnabled
'rules.canManageFolderRules': rules.canManageFolderRules
});
}
}

View File

@@ -22,7 +22,9 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { isFolderRulesEnabled } from './folder-rules.rules';
import { AcaRuleContext } from '@alfresco/aca-shared/rules';
import { canManageFolderRules, isFolderRulesEnabled } from './folder-rules.rules';
import { NodeEntry } from '@alfresco/js-api';
describe('Folder Rules Visibility Rules', () => {
describe('isFolderRulesEnabled', () => {
@@ -48,4 +50,44 @@ describe('Folder Rules Visibility Rules', () => {
expect(result).toEqual(false);
});
});
describe('canManageFolderRules', () => {
let context: AcaRuleContext;
beforeEach(() => {
context = {
appConfig: {
get: () => true
},
selection: {
folder: {} as any
},
navigation: {
url: '/personal-files'
},
permissions: {
check: () => true
}
} as any;
});
it('should allow creating a rule for the selected folder', () => {
const result = canManageFolderRules(context);
expect(result).toEqual(true);
});
it('should not allow creating a rule if no folder selected', () => {
context.selection.folder = null;
const result = canManageFolderRules(context);
expect(result).toEqual(false);
});
it('should not allow creating a rule if the selected node is a smart folder', () => {
context.selection.first = { entry: { aspectNames: ['smf:customConfigSmartFolder'], isFolder: true } } as NodeEntry;
const result = canManageFolderRules(context);
expect(result).toBe(false);
});
});
});

View File

@@ -22,6 +22,10 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
import { AcaRuleContext } from '@alfresco/aca-shared/rules';
import { AcaRuleContext, canEditFolder, hasFolderSelected, isNotFavorites, isSmartFolder } 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) && isNotFavorites(context) && !isSmartFolder(context);
export const canManageFolderRules = (context: AcaRuleContext): boolean => isFolderRulesAllowed(context);