Skip to content

Commit

Permalink
Refactor getStaticPageProps to use project.defaultWorkflow, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbouslog committed Mar 2, 2022
1 parent 061982b commit 215e840
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,23 @@ export default async function getStaticPageProps({ params, query }) {
}
}

let { workflowID } = params
/*
workflowID is defined:
1. per URL param, or if no URL param...
2. as a project's single active workflow,
or if multiple active workflows,
or if no active workflows...
3. as undefined
*/
const workflowID = params?.workflowID || store?.project?.defaultWorkflow
/*
snapshots don't include computed values, like defaultWorkflow,
which is why when determining workflowID, defaultWorkflow is not determined from the following project snapshot
*/
const { project } = getSnapshot(store)
const language = project.primary_language
const { active_workflows } = project.links

/*
if workflowID is not defined in the URL params, but there is only one active workflow, then set the single active workflow as the workflowID
*/
if (!workflowID && active_workflows?.length === 1) {
workflowID = active_workflows[0]
}

const workflowOrder = project.configuration?.workflow_order || []
/*
Validate any workflow URLs
Expand Down

0 comments on commit 215e840

Please sign in to comment.