Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EPM]: Assign data source to policy in UI #53597

Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use [].flat instead .reduce + .concat to avoid error on empty arrays.
When piplelinesToSave is an empty array [] line 231 will throw `TypeError: Reduce of empty array with no initial value`. We could add a second argument to .reduce, but .flat does what we're doing with .reduce + .concat and avoid the error on empty arrays
  • Loading branch information
John Schulz committed Dec 20, 2019
commit db8d6c6b29debea62db14feccb5a4b1367cc0950
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/epm/server/datasources/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async function installAssets({
// the promises from template installation resolve to template references
const templatesToSave = await Promise.all(templateRefs);
// the promises from pipeline installation resolve to arrays of pipeline references
const pipelinesToSave = (await Promise.all(pipelineRefs)).reduce((a, b) => a.concat(b));
const pipelinesToSave = (await Promise.all(pipelineRefs)).flat();

return templatesToSave.concat(pipelinesToSave);
}
Expand Down