Skip to content

Commit

Permalink
fix(#198): exclude stylesheet parameters that conflict with existing …
Browse files Browse the repository at this point in the history
…script options

This was decided on a slack meeting as the approach to take.
  • Loading branch information
marisademeglio committed Apr 22, 2024
1 parent 46a3310 commit 0e9539c
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/main/data/middlewares/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,26 +785,27 @@ export function pipelineMiddleware({ getState, dispatch }) {
})
)
} else {
// don't add stylesheet parameters if they have
// the same name as existing script options
let uniqueParameters = parameters.filter(
(p) =>
!job.script.options.find(
(o) => o.name == p.name
)
)
// update job options with new parameters
const stylesheetParameterOptions = [
...job.jobRequest.stylesheetParameterOptions,
]
for (let item of parameters) {
const existingOption = stylesheetParameterOptions.find(
(o) => o.name === item.name
)
if (existingOption !== undefined) {
existingOption.value = item.default
} else {
// For now, only consider non-uri parameters
stylesheetParameterOptions.push({
name: item.name,
value: item.default,
isFile: false,
isStylesheetParameter: true,
})
}
}

uniqueParameters.map((item) => {
stylesheetParameterOptions.push({
name: item.name,
value: item.default,
isFile: false,
isStylesheetParameter: true,
})
})
// Also send back the parameters to the UI
// for composition of the script options
dispatch(
Expand All @@ -816,7 +817,7 @@ export function pipelineMiddleware({ getState, dispatch }) {
...stylesheetParameterOptions,
],
},
stylesheetParameters: parameters,
stylesheetParameters: [...uniqueParameters],
})
)
}
Expand Down

0 comments on commit 0e9539c

Please sign in to comment.