mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[AAE-11496] - Make aca-shared and aca-folder-rules buidlable (#2851)
* [AAE-11496] Fix aca-shared build * Add build option to aca-folder-rules * Add small test for aos
This commit is contained in:
6
projects/aca-shared/ng-package.json
Normal file
6
projects/aca-shared/ng-package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dest": "../../dist/aca-shared",
|
||||
"lib": {
|
||||
"entryFile": "src/public-api.ts"
|
||||
}
|
||||
}
|
28
projects/aca-shared/package.json
Normal file
28
projects/aca-shared/package.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@alfresco/aca-shared",
|
||||
"version": "0.0.1",
|
||||
"commit": "",
|
||||
"license": "LGPL-3.0",
|
||||
"scripts": {},
|
||||
"peerDependencies": {
|
||||
"@alfresco/adf-content-services": "6.0.0-A.1-37376",
|
||||
"@alfresco/adf-core": "6.0.0-A.1-37376",
|
||||
"@alfresco/adf-extensions": "6.0.0-A.1-37376",
|
||||
"@alfresco/js-api": "5.2.0",
|
||||
"@angular/animations": "14.1.2",
|
||||
"@angular/cdk": "14.1.2",
|
||||
"@angular/common": "14.1.2",
|
||||
"@angular/compiler": "14.1.2",
|
||||
"@angular/core": "14.1.2",
|
||||
"@angular/flex-layout": "^14.0.0-beta.40",
|
||||
"@angular/forms": "14.1.2",
|
||||
"@angular/material": "14.1.2",
|
||||
"@ngrx/effects": "^14.2.0",
|
||||
"@ngrx/router-store": "^14.2.0",
|
||||
"@ngrx/store": "^14.2.0",
|
||||
"@ngx-translate/core": "^14.0.0",
|
||||
"rxjs": "6.6.6",
|
||||
"tslib": "^2.0.0",
|
||||
"zone.js": "0.11.8"
|
||||
}
|
||||
}
|
@@ -26,8 +26,23 @@
|
||||
import * as app from './app.rules';
|
||||
import { TestRuleContext } from './test-rule-context';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { getFileExtension } from './app.rules';
|
||||
|
||||
describe('app.evaluators', () => {
|
||||
describe('getFileExtension', () => {
|
||||
it('should return no extension when input is null', () => {
|
||||
expect(getFileExtension(null)).toBe(null);
|
||||
});
|
||||
|
||||
it('should extract file extension', () => {
|
||||
expect(getFileExtension('test.docx')).toBe('docx');
|
||||
});
|
||||
|
||||
it('should not extract file extension', () => {
|
||||
expect(getFileExtension('unknown')).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canDownloadSelection', () => {
|
||||
it('should return [false] if selection is empty', () => {
|
||||
const context = new TestRuleContext();
|
||||
|
@@ -25,11 +25,61 @@
|
||||
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
import { getFileExtension, supportedExtensions } from '@alfresco/adf-office-services-ext';
|
||||
import * as navigation from './navigation.rules';
|
||||
import * as repository from './repository.rules';
|
||||
import { isAdmin } from './user.rules';
|
||||
|
||||
/* cspell:disable */
|
||||
export const supportedExtensions = {
|
||||
doc: 'ms-word',
|
||||
docx: 'ms-word',
|
||||
docm: 'ms-word',
|
||||
dot: 'ms-word',
|
||||
dotx: 'ms-word',
|
||||
dotm: 'ms-word',
|
||||
rtf: 'ms-word',
|
||||
xls: 'ms-excel',
|
||||
xlsx: 'ms-excel',
|
||||
xlsb: 'ms-excel',
|
||||
xlsm: 'ms-excel',
|
||||
xlt: 'ms-excel',
|
||||
xltx: 'ms-excel',
|
||||
xltm: 'ms-excel',
|
||||
xlam: 'ms-excel',
|
||||
ppt: 'ms-powerpoint',
|
||||
pptx: 'ms-powerpoint',
|
||||
pot: 'ms-powerpoint',
|
||||
potx: 'ms-powerpoint',
|
||||
potm: 'ms-powerpoint',
|
||||
pptm: 'ms-powerpoint',
|
||||
pps: 'ms-powerpoint',
|
||||
ppsx: 'ms-powerpoint',
|
||||
ppam: 'ms-powerpoint',
|
||||
ppsm: 'ms-powerpoint',
|
||||
sldx: 'ms-powerpoint',
|
||||
sldm: 'ms-powerpoint',
|
||||
vsd: 'ms-visio',
|
||||
vss: 'ms-visio',
|
||||
vst: 'ms-visio',
|
||||
vsdx: 'ms-visio',
|
||||
vsdm: 'ms-visio',
|
||||
vssx: 'ms-visio',
|
||||
vssm: 'ms-visio',
|
||||
vstx: 'ms-visio',
|
||||
vstm: 'ms-visio'
|
||||
};
|
||||
/* cspell:enable */
|
||||
|
||||
export function getFileExtension(fileName: string): string | null {
|
||||
if (fileName) {
|
||||
const match = fileName.match(/\.([^\./\?\#]+)($|\?|\#)/);
|
||||
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export interface AcaRuleContext extends RuleContext {
|
||||
withCredentials: boolean;
|
||||
appConfig: AppConfigService;
|
||||
@@ -257,7 +307,7 @@ export function canUpdateSelectedNode(context: RuleContext): boolean {
|
||||
if (context.selection && !context.selection.isEmpty) {
|
||||
const node = context.selection.first;
|
||||
|
||||
if (node.entry.isFile && hasLockedFiles(context)) {
|
||||
if (node?.entry.isFile && hasLockedFiles(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -329,8 +379,8 @@ export const isWriteLocked = (context: RuleContext): boolean =>
|
||||
*/
|
||||
export const isUserWriteLockOwner = (context: RuleContext): boolean =>
|
||||
isWriteLocked(context) &&
|
||||
context.selection.file.entry.properties['cm:lockOwner'] &&
|
||||
context.selection.file.entry.properties['cm:lockOwner'].id === context.profile.id;
|
||||
context.selection.file?.entry.properties['cm:lockOwner'] &&
|
||||
context.selection.file?.entry.properties['cm:lockOwner'].id === context.profile.id;
|
||||
|
||||
/**
|
||||
* Checks if user can lock selected file.
|
||||
@@ -344,7 +394,7 @@ export const canLockFile = (context: RuleContext): boolean => !isWriteLocked(con
|
||||
*/
|
||||
export function canUnlockFile(context: RuleContext): boolean {
|
||||
const { file } = context.selection;
|
||||
return isWriteLocked(context) && (context.permissions.check(file.entry, ['delete']) || isUserWriteLockOwner(context));
|
||||
return isWriteLocked(context) && (context.permissions.check(file?.entry, ['delete']) || isUserWriteLockOwner(context));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,7 +525,7 @@ export const canShowLogout = (context: AcaRuleContext): boolean => !context.with
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export const isLibraryManager = (context: RuleContext): boolean =>
|
||||
hasLibrarySelected(context) && context.selection.library.entry && context.selection.library.entry.role === 'SiteManager';
|
||||
hasLibrarySelected(context) && context.selection.library?.entry.role === 'SiteManager';
|
||||
|
||||
/**
|
||||
* Checks if the preview button for search results can be showed
|
||||
|
@@ -52,7 +52,7 @@ import {
|
||||
SetUserProfileAction,
|
||||
SnackbarErrorAction,
|
||||
ResetSelectionAction
|
||||
} from '../../../store/src/public-api';
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { ContentApiService } from './content-api.service';
|
||||
import { RouterExtensionService } from './router.extension.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
import { Action } from '@ngrx/store';
|
||||
import { SiteBody } from '@alfresco/js-api';
|
||||
import { ModalConfiguration } from '@alfresco/aca-shared';
|
||||
import { ModalConfiguration } from '../models/modal-configuration';
|
||||
|
||||
export enum LibraryActionTypes {
|
||||
Delete = 'DELETE_LIBRARY',
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
import { Action } from '@ngrx/store';
|
||||
import { MinimalNodeEntity } from '@alfresco/js-api';
|
||||
import { ModalConfiguration } from '@alfresco/aca-shared';
|
||||
import { ModalConfiguration } from '../models/modal-configuration';
|
||||
|
||||
export enum NodeActionTypes {
|
||||
SetSelection = 'SET_SELECTED_NODES',
|
||||
|
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
import { Action } from '@ngrx/store';
|
||||
import { ModalConfiguration } from '@alfresco/aca-shared';
|
||||
import { ModalConfiguration } from '../models/modal-configuration';
|
||||
|
||||
export enum UploadActionTypes {
|
||||
UploadFiles = 'UPLOAD_FILES',
|
||||
|
@@ -0,0 +1,3 @@
|
||||
export interface ModalConfiguration {
|
||||
focusedElementOnCloseSelector?: string;
|
||||
}
|
@@ -14,9 +14,7 @@
|
||||
"importHelpers": true,
|
||||
"types": [],
|
||||
"lib": ["dom", "es2018"],
|
||||
"paths": {
|
||||
"@alfresco/aca-shared/*": ["./*"]
|
||||
}
|
||||
"paths": {}
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"skipTemplateCodegen": true,
|
||||
|
Reference in New Issue
Block a user