@balena/ui-shared-components 12.3.2-build-fix-non-unified-os-release-variant-selection-90cd58ee804ea7899167b6feb1468e8a2e6beb56-1 → 12.3.2-build-fix-non-unified-os-release-variant-selection-c6aa80ca41df6028f60420084ff0be1ab0a19b9b-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ interface ImageFormProps {
14
14
  model: DownloadImageFormModel;
15
15
  hasEsrVersions?: boolean;
16
16
  onSelectedOsTypeChange: (osType: string) => void;
17
- onChange: (key: keyof DownloadImageFormModel, value: DownloadImageFormModel[keyof DownloadImageFormModel]) => void;
17
+ onChange: (obj: Partial<DownloadImageFormModel>) => void;
18
18
  }
19
19
  export declare const ImageForm: import("react").NamedExoticComponent<ImageFormProps>;
20
20
  export {};
@@ -48,30 +48,35 @@ export const ImageForm = memo(function ImageForm({ compatibleDeviceTypes, osVers
48
48
  const showAllVersionsToggle = useMemo(() => preferredSelectionOpts.length < selectionOpts.length, [preferredSelectionOpts.length, selectionOpts.length]);
49
49
  const handleVariantChange = useCallback((newVariant) => {
50
50
  setVariant(newVariant);
51
- onChange('developmentMode', newVariant === 'dev');
51
+ const newState = {
52
+ developmentMode: newVariant === 'dev',
53
+ };
52
54
  if (version === null || version === void 0 ? void 0 : version.hasPrebuiltVariants) {
53
55
  const rawVersionForVariant = version.rawVersions[newVariant];
54
- if (rawVersionForVariant != null &&
55
- rawVersionForVariant !== version.value) {
56
- onChange('version', rawVersionForVariant);
56
+ if (rawVersionForVariant != null) {
57
+ newState.version = rawVersionForVariant;
57
58
  }
58
59
  }
60
+ onChange(newState);
59
61
  }, [onChange, version]);
60
62
  const handleVersionChange = useCallback((ver) => {
61
63
  var _a;
62
64
  ver !== null && ver !== void 0 ? ver : (ver = (_a = versionSelectionOpts.find((v) => v.isRecommended)) !== null && _a !== void 0 ? _a : versionSelectionOpts[0]);
65
+ const newState = {
66
+ developmentMode: variant === 'dev',
67
+ };
63
68
  if (ver === null || ver === void 0 ? void 0 : ver.hasPrebuiltVariants) {
64
69
  const rawVersionForVariant = ver.rawVersions[variant];
65
- if (rawVersionForVariant) {
66
- onChange('version', rawVersionForVariant);
67
- setVersion(ver);
68
- }
69
- else {
70
+ if (!rawVersionForVariant) {
70
71
  handleVariantChange(variant === 'dev' ? 'prod' : 'dev');
72
+ return;
71
73
  }
72
- return;
74
+ newState.version = rawVersionForVariant;
75
+ }
76
+ else {
77
+ newState.version = ver === null || ver === void 0 ? void 0 : ver.rawVersion;
73
78
  }
74
- onChange('version', ver === null || ver === void 0 ? void 0 : ver.rawVersion);
79
+ onChange(newState);
75
80
  setVersion(ver);
76
81
  }, [versionSelectionOpts, variant, onChange, handleVariantChange]);
77
82
  // TODO: Revisit this as it is clearly not using hooks as intended
@@ -103,7 +108,7 @@ export const ImageForm = memo(function ImageForm({ compatibleDeviceTypes, osVers
103
108
  if (!newDeviceType) {
104
109
  return;
105
110
  }
106
- onChange('deviceType', newDeviceType);
111
+ onChange({ deviceType: newDeviceType });
107
112
  }, [compatibleDeviceTypes, model.deviceType.slug, onChange]);
108
113
  const recommendedVersion = useMemo(() => { var _a; return (_a = versionSelectionOpts.find((v) => { var _a; return !((_a = v.knownIssueList) === null || _a === void 0 ? void 0 : _a.length); })) === null || _a === void 0 ? void 0 : _a.value; }, [versionSelectionOpts]);
109
114
  return (_jsxs(Box, { action: downloadUrl, method: "post", component: "form", noValidate: true, autoComplete: "off", p: 2, ref: formElement, children: [_jsx("input", { type: "hidden", name: "deviceType", value: model.deviceType.slug }), _jsx("input", { type: "hidden", name: "_token", value: authToken }), _jsx("input", { type: "hidden", name: "appId", value: applicationId }), _jsx("input", { type: "hidden", name: "fileType", value: ".zip" }), _jsx("input", { type: "hidden", name: "version", value: model.version }), _jsxs(Box, { py: 3, display: "flex", flexWrap: "wrap", gap: 2, children: [compatibleDeviceTypes && compatibleDeviceTypes.length > 1 && (_jsxs(Box, { display: "flex", flexDirection: "column", flex: "1", maxWidth: "100%", children: [_jsxs(InputLabel, { htmlFor: "device-type-select", sx: { display: 'flex', alignItems: 'center', mb: 2 }, children: ["Select device type", ' ', _jsx(Tooltip, { title: "Applications can support any devices that share the same architecture as their default device type.", children: _jsx(HelpIcon, { color: "info", sx: { fontSize: '1rem', marginLeft: 1 } }) })] }), _jsx(Autocomplete, { fullWidth: true, id: "device-type-select", value: model.deviceType, options: compatibleDeviceTypes, getOptionLabel: (option) => option.name, renderOption: (props, option) => {
@@ -134,14 +139,14 @@ export const ImageForm = memo(function ImageForm({ compatibleDeviceTypes, osVers
134
139
  height: 54, children: _jsx(FormControlLabel, { control: _jsx(Checkbox, { id: "e2e-show-all-versions-check", checked: showAllVersions, onChange: handleShowAllVersions }), label: "Show outdated versions" }) }))] })), (!isInitialDefault || !variant) && (_jsx(Box, { sx: { mt: 3 }, children: _jsx(VariantSelector, { version: version, variant: variant, onVariantChange: (v) => {
135
140
  handleVariantChange(v ? 'dev' : 'prod');
136
141
  } }) })), _jsx(Divider, { variant: "fullWidth", sx: { my: 3, borderStyle: 'dashed' } }), _jsxs(Box, { display: "flex", flexDirection: "column", children: [_jsxs(FormControl, { children: [_jsx(FormLabel, { id: "network-radio-buttons-group-label", children: "Network" }), _jsxs(RadioGroup, { "aria-labelledby": "network-radio-buttons-group-label", value: model.network, name: "network", onChange: (event) => {
137
- onChange('network', event.target.value);
142
+ onChange({ network: event.target.value });
138
143
  }, children: [_jsx(FormControlLabel, { value: "ethernet", control: _jsx(Radio, {}), label: "Ethernet only" }), _jsx(FormControlLabel, { value: "wifi", control: _jsx(Radio, {}), label: "Wifi + Ethernet" })] })] }), model.network === 'wifi' && (_jsxs(_Fragment, { children: [_jsx(InputLabel, { htmlFor: "device-wifi-ssid", sx: { mb: 2 }, children: "WiFi SSID" }), _jsx(TextField, { value: model.wifiSsid, id: "device-wifi-ssid", slotProps: {
139
144
  htmlInput: {
140
145
  name: 'wifiSsid',
141
146
  autoComplete: 'wifiSsid-auto-complete',
142
147
  },
143
148
  }, onChange: (event) => {
144
- onChange('wifiSsid', event.target.value);
149
+ onChange({ wifiSsid: event.target.value });
145
150
  } }), _jsx(InputLabel, { htmlFor: "device-wifi-password", sx: { my: 2 }, children: "Wifi Passphrase" }), _jsx(TextField, { type: showPassword ? 'text' : 'password', id: "device-wifi-password", value: model.wifiKey, slotProps: {
146
151
  htmlInput: {
147
152
  name: 'wifiKey',
@@ -155,7 +160,7 @@ export const ImageForm = memo(function ImageForm({ compatibleDeviceTypes, osVers
155
160
  }, edge: "end", children: showPassword ? _jsx(VisibilityOff, {}) : _jsx(Visibility, {}) }) })),
156
161
  },
157
162
  }, onChange: (event) => {
158
- onChange('wifiKey', event.target.value);
163
+ onChange({ wifiKey: event.target.value });
159
164
  } })] }))] }), _jsx(Divider, { variant: "fullWidth", sx: { my: 3, borderStyle: 'dashed' } }), _jsxs(Button, { onClick: () => {
160
165
  setShowAdvancedSettings(!showAdvancedSettings);
161
166
  }, variant: "outlined", sx: { mb: 2 }, children: [showAdvancedSettings ? _jsx(RemoveIcon, {}) : _jsx(AddIcon, {}), " Advanced settings"] }), _jsx(Collapse, { in: showAdvancedSettings, collapsedSize: 0, children: _jsxs(Box, { display: "flex", flexDirection: "column", children: [_jsxs(FormControl, { children: [_jsxs(FormLabel, { htmlFor: "poll-interval-label", sx: { display: 'flex' }, children: ["Check for updates every X minutes", ' ', _jsx(MUILinkWithTracking, { href: POLL_INTERVAL_DOCS, sx: {
@@ -168,21 +173,23 @@ export const ImageForm = memo(function ImageForm({ compatibleDeviceTypes, osVers
168
173
  autoComplete: 'appUpdatePollInterval-auto-complete',
169
174
  },
170
175
  }, onChange: (event) => {
171
- onChange('appUpdatePollInterval', event.target.value);
176
+ onChange({
177
+ appUpdatePollInterval: parseInt(event.target.value, 10),
178
+ });
172
179
  } })] }), _jsx(InputLabel, { htmlFor: "provision-key-name", sx: { my: 2 }, children: "Provisioning Key name" }), _jsx(TextField, { name: "provisioningKeyName", id: "provision-key-name", value: (_a = model.provisioningKeyName) !== null && _a !== void 0 ? _a : '', slotProps: {
173
180
  htmlInput: {
174
181
  name: 'provisioningKeyName',
175
182
  autoComplete: 'provisioningKeyName-auto-complete',
176
183
  },
177
184
  }, onChange: (event) => {
178
- onChange('provisioningKeyName', event.target.value);
185
+ onChange({ provisioningKeyName: event.target.value });
179
186
  } }), _jsx(InputLabel, { htmlFor: "provision-key-expiring", sx: { my: 2 }, children: "Provisioning Key expiring on" }), _jsx(TextField, { type: "date", id: "provision-key-expiring", value: (_b = model.provisioningKeyExpiryDate) !== null && _b !== void 0 ? _b : '', slotProps: {
180
187
  htmlInput: {
181
188
  name: 'provisioningKeyExpiryDate',
182
189
  autoComplete: 'provisioningKeyExpiryDate-auto-complete',
183
190
  },
184
191
  }, onChange: (event) => {
185
- onChange('provisioningKeyExpiryDate', event.target.value);
192
+ onChange({ provisioningKeyExpiryDate: event.target.value });
186
193
  } })] }) })] }));
187
194
  });
188
195
  // TODO: We need a better way than just copying the styling. Consider creating a component to export
@@ -242,13 +242,13 @@ export const DownloadImageDialog = ({ open, applicationId, releaseId, compatible
242
242
  const setOsTypeCallback = useCallback((osT) => {
243
243
  setOsType(osT);
244
244
  }, []);
245
- const handleChange = useCallback((key, value) => {
245
+ const handleChange = useCallback((updatedProps) => {
246
246
  let newFormModelState;
247
- if (key === 'deviceType') {
248
- newFormModelState = getInitialState(value, applicationId, releaseId);
247
+ if (updatedProps.deviceType != null) {
248
+ newFormModelState = getInitialState(updatedProps.deviceType, applicationId, releaseId);
249
249
  }
250
250
  else {
251
- newFormModelState = Object.assign(Object.assign({}, formModel), { [key]: value });
251
+ newFormModelState = Object.assign(Object.assign({}, formModel), updatedProps);
252
252
  onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newFormModelState);
253
253
  }
254
254
  setFormModel(newFormModelState);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/ui-shared-components",
3
- "version": "12.3.2-build-fix-non-unified-os-release-variant-selection-90cd58ee804ea7899167b6feb1468e8a2e6beb56-1",
3
+ "version": "12.3.2-build-fix-non-unified-os-release-variant-selection-c6aa80ca41df6028f60420084ff0be1ab0a19b9b-1",
4
4
  "main": "./dist/index.js",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -138,6 +138,6 @@
138
138
  },
139
139
  "homepage": "https://github.com/balena-io/ui-shared-components#readme",
140
140
  "versionist": {
141
- "publishedAt": "2025-04-23T15:21:12.813Z"
141
+ "publishedAt": "2025-04-23T16:40:18.642Z"
142
142
  }
143
143
  }