requestMapper: Fix enabled services with firstboot

Previously used `.push()` method was limited by non-writable length of the enabled services array, ending up in the following error:
```
 Uncaught (in promise) TypeError: can't define array index property past the end of an array with non-writable length
```

This fixes the problem by updating the array via spread operator.

Before: when creating an image with Oscap profile with enabled serviced and adding a firstboot script, the Create blueprint button at the Review step threw an error on click.
After fix: it's possible to create an image with Oscap profile that includes enabled services and a firstboot script.
This commit is contained in:
regexowl 2024-09-24 09:36:36 +02:00 committed by Klara Simickova
parent 484d475bfe
commit e051aa3f7f

View file

@ -472,12 +472,12 @@ const getServices = (state: RootState): Services | undefined => {
return undefined;
}
const enabledSvcs = services.enabled || [];
let enabledSvcs = services.enabled || [];
const includeFBSvc: boolean =
!!selectFirstBootScript(state) &&
!services.enabled?.includes(FIRST_BOOT_SERVICE);
if (includeFBSvc) {
enabledSvcs.push(FIRST_BOOT_SERVICE);
enabledSvcs = [...enabledSvcs, FIRST_BOOT_SERVICE];
}
return {