Skip to content

Commit

Permalink
✨ [#4269] Allow static vars to be used as DMN input parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed May 8, 2024
1 parent 6129354 commit 56ee320
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {parseExpression} from 'feelin';
import {useFormikContext} from 'formik';
import React, {useContext} from 'react';
import React from 'react';
import {FormattedMessage} from 'react-intl';
import {useAsync} from 'react-use';

import {FormContext} from 'components/admin/form_design/Context';
import {DMN_DECISION_DEFINITIONS_PARAMS_LIST} from 'components/admin/form_design/constants';
import {get} from 'utils/fetch';

Expand Down Expand Up @@ -104,7 +103,6 @@ const DMNParametersForm = () => {
const {
values: {pluginId, decisionDefinitionId, decisionDefinitionVersion},
} = useFormikContext();
const {formVariables} = useContext(FormContext);

const {loading, value: dmnParams = EMPTY_DMN_PARAMS} = useAsync(async () => {
if (!pluginId || !decisionDefinitionId) {
Expand All @@ -131,8 +129,6 @@ const DMNParametersForm = () => {
};
}, [pluginId, decisionDefinitionId, decisionDefinitionVersion]);

const variablesChoices = formVariables.map(variable => [variable.key, variable.name]);

return (
<div className="mappings">
<InputsOverview inputClauses={dmnParams.inputClauses} />
Expand All @@ -144,8 +140,8 @@ const DMNParametersForm = () => {
<VariableMapping
loading={loading}
mappingName="inputMapping"
formVariables={variablesChoices}
dmnVariables={dmnParams.inputs}
includeStaticVariables
/>
</div>
<div className="mappings__mapping">
Expand All @@ -155,7 +151,6 @@ const DMNParametersForm = () => {
<VariableMapping
loading={loading}
mappingName="outputMapping"
formVariables={variablesChoices}
dmnVariables={dmnParams.outputs}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Field from 'components/admin/forms/Field';
import Select from 'components/admin/forms/Select';
import VariableSelection from 'components/admin/forms/VariableSelection';

const VariableMapping = ({loading, mappingName, formVariables, dmnVariables}) => {
const VariableMapping = ({loading, mappingName, dmnVariables, includeStaticVariables = false}) => {
const intl = useIntl();
const {getFieldProps, values} = useFormikContext();

Expand Down Expand Up @@ -51,6 +51,7 @@ const VariableMapping = ({loading, mappingName, formVariables, dmnVariables}) =>
>
<VariableSelection
id={`${mappingName}.${index}.formVariable`}
includeStaticVariables={includeStaticVariables}
{...getFieldProps(`${mappingName}.${index}.formVariable`)}
aria-label={intl.formatMessage({
description: 'Accessible label for (form) variable dropdown',
Expand Down Expand Up @@ -103,7 +104,7 @@ const VariableMapping = ({loading, mappingName, formVariables, dmnVariables}) =>
VariableMapping.propTypes = {
loading: PropTypes.bool,
mappingName: PropTypes.string,
formVariables: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
includeStaticVariables: PropTypes.bool,
dmnVariables: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)),
};

Expand Down

0 comments on commit 56ee320

Please sign in to comment.