diff --git a/src/client/components/types/steps-lists.js b/src/client/components/types/steps-lists.js index a85d662..7238bdb 100644 --- a/src/client/components/types/steps-lists.js +++ b/src/client/components/types/steps-lists.js @@ -4,11 +4,8 @@ import {Traversal} from '@avocado/behavior/item/traversal'; import {typeFits} from './typing'; -export const variableStepsList = (context, previousSteps, key, variable, variableType, type, maxDepth) => { +export const variableStepsList = (context, previousSteps, key, variable, variableType, type, isFinal) => { const steps = []; - if (0 === maxDepth) { - return [steps]; - } if (typeFits(type, variableType)) { steps.push({type: 'key', key}); } @@ -23,23 +20,20 @@ export const variableStepsList = (context, previousSteps, key, variable, variabl steps.push({type: 'invoke', args: []}); } } + if (isFinal) { + return [steps]; + } const sublists = Object.entries(description) - .map(([nextKey, description]) => ( - ( - // Cycle killer - variableType === description.type - && variableType !== type + .map(([nextKey, newDescription]) => ( + variableStepsList( + context, + previousSteps.concat(steps), + nextKey, + ('object' === typeof variable && null !== variable) ? variable[nextKey] : undefined, + newDescription.type, + type, + newDescription.cycle, ) - ? [] - : variableStepsList( - context, - previousSteps.concat(steps), - nextKey, - ('object' === typeof variable && null !== variable) ? variable[nextKey] : undefined, - description.type, - type, - maxDepth - 1, - ) )) .map((childLists) => ( childLists.map((stepsList) => ( @@ -51,11 +45,11 @@ export const variableStepsList = (context, previousSteps, key, variable, variabl return sublists.length > 0 ? [steps].concat(flatten(sublists)) : [steps]; }; -export const contextStepsList = (context, type, maxDepth) => ( +export const contextStepsList = (context, type) => ( flatten( Object.entries(context.all()) .map(([key, [variable, variableType]]) => ( - variableStepsList(context, [{type: 'key', key}], key, variable, variableType, type, maxDepth) + variableStepsList(context, [{type: 'key', key}], key, variable, variableType, type, false) )) ) .filter((stepsList) => stepsList.length > 0) diff --git a/src/client/components/types/steps.jsx b/src/client/components/types/steps.jsx index 2500ac4..5f3627e 100644 --- a/src/client/components/types/steps.jsx +++ b/src/client/components/types/steps.jsx @@ -19,7 +19,6 @@ const Steps = (props) => { : value.steps ? typeFromSteps(context, value.steps) : typeFromLiteral(value), - steps.length + 2 ); return (
diff --git a/src/client/components/types/value.type-renderer.jsx b/src/client/components/types/value.type-renderer.jsx index 58cd345..47ff9b6 100644 --- a/src/client/components/types/value.type-renderer.jsx +++ b/src/client/components/types/value.type-renderer.jsx @@ -35,7 +35,7 @@ const renderValue = (context, type, value) => { return ; } case 'literal': { - const stepsList = contextStepsList(context, type, 3); + const stepsList = contextStepsList(context, type); const tierOptions = Object.keys(stepsList.reduce((r, optionSteps) => { if (!optionSteps[0] || !optionSteps[0].key) { return r;