Thodoris Greasidis 2023-07-07 19:51:43 +03:00
parent f07f6b84d4
commit d78b76aceb

View File

@ -115,22 +115,22 @@ export function askLoginType() {
}); });
} }
export function selectDeviceType() { export async function selectDeviceType() {
return getBalenaSdk() const sdk = getBalenaSdk();
.models.config.getDeviceTypes() let deviceTypes = await sdk.models.deviceType.getAllSupported();
.then((deviceTypes) => { if (deviceTypes.length === 0) {
deviceTypes = _.sortBy(deviceTypes, 'name').filter( // Without this open-balena users would get an empty list
(dt) => dt.state !== 'DISCONTINUED', // until we add a hostApps import in open-balena.
); deviceTypes = await sdk.models.deviceType.getAll();
return getCliForm().ask({ }
message: 'Device Type', return getCliForm().ask({
type: 'list', message: 'Device Type',
choices: _.map(deviceTypes, ({ slug: value, name }) => ({ type: 'list',
name, choices: _.map(deviceTypes, ({ slug: value, name }) => ({
value, name,
})), value,
}); })),
}); });
} }
/** /**