mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[ACS-6630] Revert move of ActionRef, RuleRef and RouteRef from extensions library to js-api library
This commit is contained in:
@@ -47,3 +47,9 @@ export interface ContentActionRef extends ExtensionElement {
|
||||
visible?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ActionRef {
|
||||
id: string;
|
||||
type: string;
|
||||
payload?: string;
|
||||
}
|
||||
|
@@ -15,7 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { RouteRef } from './routing.extensions';
|
||||
import { RuleRef } from './rule.extensions';
|
||||
import { ActionRef } from './action.extensions';
|
||||
|
||||
export interface ExtensionRef {
|
||||
$id: string;
|
||||
|
26
lib/extensions/src/lib/config/routing.extensions.ts
Normal file
26
lib/extensions/src/lib/config/routing.extensions.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface RouteRef {
|
||||
id: string;
|
||||
path: string;
|
||||
component: string;
|
||||
parentRoute?: string;
|
||||
layout?: string;
|
||||
auth?: string[];
|
||||
data?: { [key: string]: string };
|
||||
}
|
@@ -33,3 +33,15 @@ export interface RuleContext {
|
||||
|
||||
getEvaluator(key: string): RuleEvaluator;
|
||||
}
|
||||
|
||||
export class RuleRef {
|
||||
type: string;
|
||||
id?: string;
|
||||
parameters?: Array<RuleParameter>;
|
||||
}
|
||||
|
||||
export interface RuleParameter {
|
||||
type: string;
|
||||
value: any;
|
||||
parameters?: Array<RuleParameter>;
|
||||
}
|
||||
|
@@ -16,10 +16,9 @@
|
||||
*/
|
||||
|
||||
import { every, not, some } from './core.evaluators';
|
||||
import { RuleParameter } from '@alfresco/js-api';
|
||||
import { RuleParameter } from '../config/rule.extensions';
|
||||
|
||||
describe('Core Evaluators', () => {
|
||||
|
||||
const context: any = {
|
||||
getEvaluator: (key: string) => {
|
||||
switch (key) {
|
||||
|
@@ -15,23 +15,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { RuleContext } from '../config/rule.extensions';
|
||||
import { RuleParameter } from '@alfresco/js-api';
|
||||
import { RuleContext, RuleParameter } from '../config/rule.extensions';
|
||||
|
||||
export const not = (context: RuleContext, ...args: RuleParameter[]): boolean => {
|
||||
if (!args || args.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return args
|
||||
.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return !evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
return args.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return !evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
};
|
||||
|
||||
export const every = (context: RuleContext, ...args: RuleParameter[]): boolean => {
|
||||
@@ -39,15 +37,14 @@ export const every = (context: RuleContext, ...args: RuleParameter[]): boolean =
|
||||
return false;
|
||||
}
|
||||
|
||||
return args
|
||||
.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
return args.every((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
};
|
||||
|
||||
export const some = (context: RuleContext, ...args: RuleParameter[]): boolean => {
|
||||
@@ -55,13 +52,12 @@ export const some = (context: RuleContext, ...args: RuleParameter[]): boolean =>
|
||||
return false;
|
||||
}
|
||||
|
||||
return args
|
||||
.some((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
return args.some((arg) => {
|
||||
const evaluator = context.getEvaluator(arg.value);
|
||||
if (!evaluator) {
|
||||
console.warn('evaluator not found: ' + arg.value);
|
||||
return false;
|
||||
}
|
||||
return evaluator(context, ...(arg.parameters || []));
|
||||
});
|
||||
};
|
||||
|
@@ -17,11 +17,12 @@
|
||||
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ContentActionRef, ContentActionType } from '../config/action.extensions';
|
||||
import { ActionRef, ContentActionRef, ContentActionType } from '../config/action.extensions';
|
||||
import { ExtensionElement } from '../config/extension-element';
|
||||
import { filterEnabled, getValue, mergeObjects, sortByOrder } from '../config/extension-utils';
|
||||
import { ExtensionConfig, ExtensionRef } from '../config/extension.config';
|
||||
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { RouteRef } from '../config/routing.extensions';
|
||||
import { RuleRef } from '../config/rule.extensions';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@@ -18,9 +18,11 @@
|
||||
import { ExtensionService } from './extension.service';
|
||||
import { ExtensionLoaderService } from './extension-loader.service';
|
||||
import { ExtensionConfig } from '../config/extension.config';
|
||||
import { ActionRef, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { ComponentRegisterService } from './component-register.service';
|
||||
import { RuleService } from './rule.service';
|
||||
import { RuleRef } from '../config/rule.extensions';
|
||||
import { RouteRef } from '../config/routing.extensions';
|
||||
import { ActionRef } from '../config/action.extensions';
|
||||
|
||||
describe('ExtensionService', () => {
|
||||
const blankConfig: ExtensionConfig = {
|
||||
|
@@ -16,16 +16,18 @@
|
||||
*/
|
||||
|
||||
import { Injectable, Type, InjectionToken, Inject } from '@angular/core';
|
||||
import { RuleEvaluator, RuleContext } from '../config/rule.extensions';
|
||||
import { RuleEvaluator, RuleRef, RuleContext } from '../config/rule.extensions';
|
||||
import { ExtensionConfig } from '../config/extension.config';
|
||||
import { ExtensionLoaderService } from './extension-loader.service';
|
||||
import { RouteRef } from '../config/routing.extensions';
|
||||
import { ActionRef } from '../config/action.extensions';
|
||||
import * as core from '../evaluators/core.evaluators';
|
||||
import { ComponentRegisterService } from './component-register.service';
|
||||
import { RuleService } from './rule.service';
|
||||
import { ExtensionElement } from '../config/extension-element';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { mergeArrays, mergeObjects } from '../config/extension-utils';
|
||||
import { ActionRef, ExtensionComposition, RouteRef, RuleRef } from '@alfresco/js-api';
|
||||
import { ExtensionComposition } from '@alfresco/js-api';
|
||||
|
||||
/**
|
||||
* The default extensions factory
|
||||
@@ -110,15 +112,14 @@ export class ExtensionService {
|
||||
}
|
||||
|
||||
appendConfig(partialConfig: ExtensionComposition) {
|
||||
this.config = {
|
||||
this.setup({
|
||||
...this.config,
|
||||
rules: mergeArrays(this.config.rules, partialConfig.rules),
|
||||
features: mergeObjects(this.config.features, partialConfig.features),
|
||||
features: this.config.features ? mergeObjects(this.config.features, partialConfig.features) : partialConfig.features,
|
||||
routes: mergeArrays(this.config.routes, partialConfig.routes),
|
||||
actions: mergeArrays(this.config.actions, partialConfig.actions),
|
||||
appConfig: mergeObjects(this.config.appConfig, partialConfig.appConfig)
|
||||
};
|
||||
this.setup(this.config);
|
||||
appConfig: this.config.appConfig ? mergeObjects(this.config.appConfig, partialConfig.appConfig) : partialConfig.appConfig
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,10 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RuleContext, RuleEvaluator } from '../config/rule.extensions';
|
||||
import { RuleRef, RuleContext, RuleEvaluator, RuleParameter } from '../config/rule.extensions';
|
||||
import { ExtensionConfig } from '../config/extension.config';
|
||||
import { ExtensionLoaderService } from './extension-loader.service';
|
||||
import { RuleParameter, RuleRef } from '@alfresco/js-api';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@@ -23,6 +23,7 @@ export * from './lib/config/extension.config';
|
||||
export * from './lib/config/icon.extensions';
|
||||
export * from './lib/config/navbar.extensions';
|
||||
export * from './lib/config/permission.extensions';
|
||||
export * from './lib/config/routing.extensions';
|
||||
export * from './lib/config/rule.extensions';
|
||||
export * from './lib/config/sidebar.extensions';
|
||||
export * from './lib/config/viewer.extensions';
|
||||
|
Reference in New Issue
Block a user