Skip to content

Commit

Permalink
Fix regression where resources were treated as templates
Browse files Browse the repository at this point in the history
  • Loading branch information
AjBreidenbach committed Mar 19, 2024
1 parent 914028d commit ce613cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,16 @@ const getters = {
},
resolveResource(state) {
return name => {
if(!name) return
let rt = state['Resource'][name]
if(!rt && !name?.startsWith('::')) {
rt = state['Resource'][`::${name}`]
if(!name) return null
try {
let rt = state['Resource'][name]
if(!rt && !name?.startsWith('::')) {
rt = state['Resource'][`::${name}`]
}
return rt
} catch(e) {
return null
}
return rt
}
},
resolveDeployment(state) { return name => state['Deployment'][name] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ const actions = {
const deployment = deploymentName?
rootGetters.getDeployments.find(dep => dep.name == deploymentName):
rootGetters.getDeployment
deploymentName = deployment.name
const environmentName = deployment._environment
deploymentName = deployment?.name || deploymentName
const environmentName = deployment?._environment || getters.getCurrentEnvironment?.name

let deploymentDict

Expand Down Expand Up @@ -455,7 +455,6 @@ const actions = {
'pushPreparedMutation',
createResourceTemplate({...matchedNested, dependentName, dependentRequirement, deploymentTemplateName: state.lastFetchedFrom.templateSlug}),
)
console.log(`adding ${match} @initMatched`)
}

resolvedDependencyMatch = matchedNested || resolvedDependencyMatch
Expand Down Expand Up @@ -535,7 +534,6 @@ const actions = {
let promises = []

for(const dependency of getters.getDependencies(resource.name) || resource.dependencies || []) {
console.log(dependency)
promises.push(dispatch(
'initMatched', {
isDeploymentTemplate,
Expand Down Expand Up @@ -1074,12 +1072,21 @@ const getters = {
return getters.getCardsStacked('*').find(card => card.name == cardName)
}
},
getDependencies: (_state, getters) => {
getDependencies: (_state, getters, rootState, rootGetters) => {
return function(resourceTemplateName) {
const rt = getters.dtResolveResourceTemplate(resourceTemplateName)
if(!resourceTemplateName) return null

const rt = (
rootGetters.resolveResource(resourceTemplateName?.name || resourceTemplateName) ||
getters.dtResolveResourceTemplate(resourceTemplateName)
)

if(!rt) return null

if(rt.__typename == 'Resource') {
return rt.connections
}

let dependencies = _.cloneDeep(rt.dependencies || [])

if(dependencies.length == 0) return []
Expand Down Expand Up @@ -1202,7 +1209,7 @@ const getters = {
if(!card) return true
if(card.imported) return true
const dependencies = getters.getDependencies(card)
if(!dependencies.length) return true;
if(!dependencies?.length) return true;
return dependencies.every(dependency => (
(dependency.constraint.min == 0 && !dependency.match) ||
(getters.requirementMatchIsValid(dependency) && getters.cardIsValid(dependency.match))
Expand Down

0 comments on commit ce613cf

Please sign in to comment.