Browse Source

MSPB-65: Stop overriding provision key for all devices (#319)

* Stop overriding provison key for all devices

During formatting from device document to UI template, the `provision`
key was overriden regardless of the device's provisionability.

This triggered a UX bug when adding SUP devices with unknown
brand/model, as it prompted end-users to specify a MAC address
eventhough the device couldn't be provisioned.

Upon creating the device, kazoo would make a request to the provisioning
service, which would subsequently fail because of the missing
provisioning information.

* Remove mergedDevice step
4.3
Joris Tirado 5 years ago
committed by GitHub
parent
commit
8a41770929
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 33 deletions
  1. +18
    -33
      submodules/devices/devices.js

+ 18
- 33
submodules/devices/devices.js View File

@ -936,6 +936,19 @@ define(function(require) {
devicesFormatData: function(data, dataList) {
var self = this,
isNewDevice = !_.has(data.device, 'id'),
getNormalizedProvisionEntriesForKeyType = _.partial(function(device, template, keyType) {
var iterate = _.get(template, [keyType, 'iterate'], 0),
entries = _.get(device, ['provision', keyType], {}),
getEntryValueOrDefault = _.partial(_.get, entries, _, {
type: 'none'
});
return _
.chain(iterate)
.range()
.map(getEntryValueOrDefault)
.value();
}, data.device, data.template),
keyActionsMod = _.get(
self.appFlags.devices.provisionerConfigFlags,
['brands', _.get(data.device, 'provision.endpoint_brand'), 'keyFunctions'],
@ -1019,29 +1032,6 @@ define(function(require) {
isNewDevice && deviceBaseDefaults,
deviceDefaultsForType
),
deviceOverrides = {
provision: _
.chain(data.template)
.thru(self.getKeyTypes)
.map(function(type) {
return {
type: type,
data: _
.chain(data.template)
.get([type, 'iterate'], 0)
.range()
.map(function(index) {
return _.get(data.device, ['provision', type, index], {
type: 'none'
});
})
.value()
};
})
.keyBy('type')
.mapValues('data')
.value()
},
deviceData = _.mergeWith(
{},
templateDefaults,
@ -1050,16 +1040,11 @@ define(function(require) {
function(dest, src) {
return _.every([dest, src], _.isArray) ? src : undefined;
}
),
mergedDevice = _.merge(
{},
deviceData,
deviceOverrides
);
return _.merge({
extra: {
allowVMCellphone: !_.get(mergedDevice, 'call_forward.require_keypress', true),
allowVMCellphone: !_.get(deviceData, 'call_forward.require_keypress', true),
availableCodecs: {
audio: [],
video: []
@ -1083,7 +1068,7 @@ define(function(require) {
.map(function(type) {
var camelCasedType = _.camelCase(type),
i18n = _.get(self.i18n.active().devices.popupSettings.keys, camelCasedType),
entries = _.get(mergedDevice, ['provision', type], []),
entries = getNormalizedProvisionEntriesForKeyType(type),
entriesCount = _.size(entries);
return _.merge({
@ -1171,8 +1156,8 @@ define(function(require) {
help: _.get(i18n, 'help')
};
}),
rtpMethod: _.get(mergedDevice, 'media.encryption.enforce_security', false)
? _.head(mergedDevice.media.encryption.methods)
rtpMethod: _.get(deviceData, 'media.encryption.enforce_security', false)
? _.head(deviceData.media.encryption.methods)
: '',
selectedCodecs: {
audio: [],
@ -1186,7 +1171,7 @@ define(function(require) {
.value();
})
}
}, mergedDevice);
}, deviceData);
},
/**


Loading…
Cancel
Save