Skip to content

Commit

Permalink
Fix ancestor tracking regression
Browse files Browse the repository at this point in the history
  • Loading branch information
AjBreidenbach committed Jan 4, 2024
1 parent c1ac17a commit 3aa54b1
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const actions = {
let _ancestors = null

if(ancestors) {
let _ancestors = child._ancestors
_ancestors = child._ancestors
if(
(!child._ancestors && ancestors && !child.readonly) ||
(Array.isArray(child._ancestors) && child._ancestors.length == 0)
Expand Down Expand Up @@ -485,6 +485,14 @@ const actions = {

const directAncestor = state.resourceTemplates[dependentName]

dispatch(
'normalizeUnfurlData', {
key: 'ResourceTemplate',
entry: target,
root: rootGetters.getApplicationRoot
})


if(directAncestor) {
const ancestorDependencies = getters.getDependencies(directAncestor)
const inputsSchemaFromDirectAncestor = ancestorDependencies.find(dep => dep.name == dependentRequirement)?.constraint?.inputsSchema
Expand All @@ -496,17 +504,10 @@ const actions = {
target._ancestors = (directAncestor._ancestors || []).concat([[directAncestor, dependentRequirement]])
}

// TODO determine if this is still necessary with normalization
try { target.properties = Object.entries(targetType.inputsSchema.properties || {}).map(([key, inProp]) => ({name: key, value: inProp.default ?? null}));}
catch { target.properties = []; }

dispatch(
'normalizeUnfurlData', {
key: 'ResourceTemplate',
entry: target,
root: rootGetters.getApplicationRoot
})


if(targetType.requirements?.length > 0) {
target.dependencies = targetType.requirements.map(req => {
return {
Expand Down Expand Up @@ -1151,7 +1152,8 @@ const getters = {

if(!rt._ancestors) return null

const ancestorConstraints = _.cloneDeep(rt._ancestors).map(([rt, req]) => rt.dependencies.find(dep => dep.name == req)?.constraint)
// TODO rt.dependencies should have been normalized to an empty array
const ancestorConstraints = _.cloneDeep(rt._ancestors || []).map(([rt, req]) => rt.dependencies?.find(dep => dep.name == req)?.constraint)

const parentConstraint = ancestorConstraints.reduce((prev, cur) => _.merge(cur, ...(prev?.requirementsFilter || [])), null)

Expand Down

0 comments on commit 3aa54b1

Please sign in to comment.