Skip to content

Commit 0e9539c

Browse files
fix(#198): exclude stylesheet parameters that conflict with existing script options
This was decided on a slack meeting as the approach to take.
1 parent 46a3310 commit 0e9539c

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/main/data/middlewares/pipeline.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -785,26 +785,27 @@ export function pipelineMiddleware({ getState, dispatch }) {
785785
})
786786
)
787787
} else {
788+
// don't add stylesheet parameters if they have
789+
// the same name as existing script options
790+
let uniqueParameters = parameters.filter(
791+
(p) =>
792+
!job.script.options.find(
793+
(o) => o.name == p.name
794+
)
795+
)
788796
// update job options with new parameters
789797
const stylesheetParameterOptions = [
790798
...job.jobRequest.stylesheetParameterOptions,
791799
]
792-
for (let item of parameters) {
793-
const existingOption = stylesheetParameterOptions.find(
794-
(o) => o.name === item.name
795-
)
796-
if (existingOption !== undefined) {
797-
existingOption.value = item.default
798-
} else {
799-
// For now, only consider non-uri parameters
800-
stylesheetParameterOptions.push({
801-
name: item.name,
802-
value: item.default,
803-
isFile: false,
804-
isStylesheetParameter: true,
805-
})
806-
}
807-
}
800+
801+
uniqueParameters.map((item) => {
802+
stylesheetParameterOptions.push({
803+
name: item.name,
804+
value: item.default,
805+
isFile: false,
806+
isStylesheetParameter: true,
807+
})
808+
})
808809
// Also send back the parameters to the UI
809810
// for composition of the script options
810811
dispatch(
@@ -816,7 +817,7 @@ export function pipelineMiddleware({ getState, dispatch }) {
816817
...stylesheetParameterOptions,
817818
],
818819
},
819-
stylesheetParameters: parameters,
820+
stylesheetParameters: [...uniqueParameters],
820821
})
821822
)
822823
}

0 commit comments

Comments
 (0)