Skip to content

Commit

Permalink
Merge pull request #6311 from TheThingsNetwork/fix/payload-formatter-…
Browse files Browse the repository at this point in the history
…request

Prevent the Console from launching requests with unresolved paths in the device payload formatters view
  • Loading branch information
ryaplots committed Jun 12, 2023
2 parents cabd02b + a9a2a38 commit 4174f06
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ For details about compatibility between different releases, see the **Commitment

### Fixed

- Fix payload formatter page launching malformed requests in the Console.

### Security

## [3.26.1] - unreleased
Expand Down
12 changes: 12 additions & 0 deletions cypress/integration/console/shared/payload-formatters/edit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ describe('Payload formatters', () => {
multicast: false,
supports_join: true,
lorawan_version: 'MAC_V1_0_2',
version_ids: {
brand_id: 'the-things-products',
model_id: 'the-things-uno',
hw_version: '1.0',
fw_version: 'quickstart',
band_id: 'EU_863_870',
},
ids: {
device_id: 'device-all-components',
dev_eui: '70B3D57ED8000013',
Expand All @@ -47,6 +54,11 @@ describe('Payload formatters', () => {
},
field_mask: {
paths: [
'version_ids.brand_id',
'version_ids.model_id',
'version_ids.hardware_version',
'version_ids.firmware_version',
'version_ids.band_id',
'frequency_plan_id',
'lorawan_phy_version',
'multicast',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import React from 'react'
import bind from 'autobind-decorator'
import { connect } from 'react-redux'
import { isEmpty } from 'lodash'

import PAYLOAD_FORMATTER_TYPES from '@console/constants/formatter-types'
import tts from '@console/api/tts'
Expand Down Expand Up @@ -74,9 +75,11 @@ import m from './messages'
getRepositoryPayloadFormatters,
},
)
@withRequest(({ appId, device, getRepositoryPayloadFormatters }) =>
getRepositoryPayloadFormatters(appId, device.version_ids),
)
@withRequest(({ appId, device, getRepositoryPayloadFormatters }) => {
if (!isEmpty(device.version_ids)) {
return getRepositoryPayloadFormatters(appId, device.version_ids)
}
})
@withBreadcrumb('device.single.payload-formatters.downlink', props => {
const { appId, devId } = props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import React from 'react'
import bind from 'autobind-decorator'
import { connect } from 'react-redux'
import { isEmpty } from 'lodash'

import PAYLOAD_FORMATTER_TYPES from '@console/constants/formatter-types'
import tts from '@console/api/tts'
Expand Down Expand Up @@ -75,9 +76,11 @@ import m from './messages'
getRepositoryPayloadFormatters,
},
)
@withRequest(({ appId, device, getRepositoryPayloadFormatters }) =>
getRepositoryPayloadFormatters(appId, device.version_ids),
)
@withRequest(({ appId, device, getRepositoryPayloadFormatters }) => {
if (!isEmpty(device.version_ids)) {
return getRepositoryPayloadFormatters(appId, device.version_ids)
}
})
@withBreadcrumb('device.single.payload-formatters.uplink', props => {
const { appId, devId } = props

Expand Down

0 comments on commit 4174f06

Please sign in to comment.