From 3606c59673f1bfc80e79c56d64ab98636ecf7f4f Mon Sep 17 00:00:00 2001 From: Pascal Delange Date: Fri, 3 Jan 2025 10:21:23 +0100 Subject: [PATCH] remove unused function (duplicated elsewhere) --- .../src/components/Decisions/RulesDetail.tsx | 2 +- .../RulesExecutions/RuleExecutionDetail.tsx | 149 ------------------ .../src/models/operator-functions.ts | 1 + 3 files changed, 2 insertions(+), 150 deletions(-) delete mode 100644 packages/app-builder/src/components/Decisions/RulesExecutions/RuleExecutionDetail.tsx diff --git a/packages/app-builder/src/components/Decisions/RulesDetail.tsx b/packages/app-builder/src/components/Decisions/RulesDetail.tsx index af329938..8e14b102 100644 --- a/packages/app-builder/src/components/Decisions/RulesDetail.tsx +++ b/packages/app-builder/src/components/Decisions/RulesDetail.tsx @@ -6,8 +6,8 @@ import { } from '@app-builder/models/astNode/data-accessor'; import { type CustomList } from '@app-builder/models/custom-list'; import { type RuleExecution } from '@app-builder/models/decision'; -import { type OperatorFunction } from '@app-builder/models/operator-functions'; import { type NodeEvaluation } from '@app-builder/models/node-evaluation'; +import { type OperatorFunction } from '@app-builder/models/operator-functions'; import { type ScenarioIterationRule } from '@app-builder/models/scenario-iteration-rule'; import { useAstNodeEditor } from '@app-builder/services/editor/ast-editor'; import { diff --git a/packages/app-builder/src/components/Decisions/RulesExecutions/RuleExecutionDetail.tsx b/packages/app-builder/src/components/Decisions/RulesExecutions/RuleExecutionDetail.tsx deleted file mode 100644 index a27b9a69..00000000 --- a/packages/app-builder/src/components/Decisions/RulesExecutions/RuleExecutionDetail.tsx +++ /dev/null @@ -1,149 +0,0 @@ -import { decisionsI18n, Paper } from '@app-builder/components'; -import { AstBuilder } from '@app-builder/components/Scenario/AstBuilder/AstBuilder'; -import { type AstNode, type DataModel } from '@app-builder/models'; -import { - type DatabaseAccessAstNode, - type PayloadAstNode, -} from '@app-builder/models/astNode/data-accessor'; -import { type CustomList } from '@app-builder/models/custom-list'; -import { type RuleExecution } from '@app-builder/models/decision'; -import { type OperatorFunction } from '@app-builder/models/operator-functions'; -import { type NodeEvaluation } from '@app-builder/models/node-evaluation'; -import { type ScenarioIterationRule } from '@app-builder/models/scenario-iteration-rule'; -import { useAstNodeEditor } from '@app-builder/services/editor/ast-editor'; -import { - DisplayReturnValuesProvider, - useDisplayReturnValues, -} from '@app-builder/services/editor/return-value'; -import { formatNumber, useFormatLanguage } from '@app-builder/utils/format'; -import * as React from 'react'; -import { Trans, useTranslation } from 'react-i18next'; -import { Switch } from 'ui-design-system'; - -export function RuleExecutionDetail({ - ruleExecution, - triggerObjectType, - astRuleData, -}: { - ruleExecution: RuleExecution; - triggerObjectType: string; - astRuleData: { - rules: ScenarioIterationRule[]; - databaseAccessors: DatabaseAccessAstNode[]; - payloadAccessors: PayloadAstNode[]; - operators: OperatorFunction[]; - dataModel: DataModel; - customLists: CustomList[]; - }; -}) { - const { t } = useTranslation(decisionsI18n); - const language = useFormatLanguage(); - const currentRule = React.useMemo( - () => astRuleData.rules.find((rule) => rule.id === ruleExecution.ruleId), - [astRuleData.rules, ruleExecution.ruleId], - ); - - if (!currentRule || !currentRule.formula) { - return ( -

- {t('decisions:rules.error.not_found')} -

- ); - } - - return ( - -
-
- , - }} - values={{ - score: formatNumber(currentRule.scoreModifier, { - language, - signDisplay: 'always', - }), - }} - /> -
- {ruleExecution.evaluation ? : null} -
- - -
- ); -} - -function DisplayReturnValuesSwitch() { - const { t } = useTranslation(decisionsI18n); - const [displayReturnValues, setDisplayReturnValues] = - useDisplayReturnValues(); - - const id = React.useId(); - - return ( -
- - -
- ); -} - -function RuleFormula({ - formula, - databaseAccessors, - evaluation, - payloadAccessors, - operators, - dataModel, - customLists, - triggerObjectType, -}: { - formula: AstNode; - evaluation?: NodeEvaluation; - databaseAccessors: DatabaseAccessAstNode[]; - payloadAccessors: PayloadAstNode[]; - operators: OperatorFunction[]; - dataModel: DataModel; - customLists: CustomList[]; - triggerObjectType: string; -}) { - const astEditorStore = useAstNodeEditor({ - initialAstNode: formula, - initialEvaluation: evaluation, - }); - return ( - - - - ); -} diff --git a/packages/app-builder/src/models/operator-functions.ts b/packages/app-builder/src/models/operator-functions.ts index 1a04d495..07e4ae9d 100644 --- a/packages/app-builder/src/models/operator-functions.ts +++ b/packages/app-builder/src/models/operator-functions.ts @@ -19,6 +19,7 @@ export type OperatorFunction = | TimeAddOperator | ValidTimestampExtractParts | AggregatorOperator; + export function isOperatorFunction(value: string): value is OperatorFunction { return ( isMainAstOperatorFunction(value) ||