Skip to content

Commit

Permalink
console: Fix undefined and delete all policies on default
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaplots committed Oct 23, 2023
1 parent cf1af36 commit ceded37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pkg/webui/console/store/middleware/logics/packet-broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ const setPacketBrokerHomeNetworkPolicyLogic = createRequestLogic({
const ids = extractPacketBrokerIdsFromCombinedId(id)
await tts.PacketBrokerAgent.setHomeNetworkRoutingPolicy(ids.net_id, ids.tenant_id, policy)

return policy
const newPolicy = { home_network_id: { net_id: ids.net_id }, ...policy }
if ('tenant_id' in ids) {
newPolicy.home_network_id.tenant_id = ids.tenant_id
}

return newPolicy
},
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,16 @@ const PacketBroker = () => {
async values => {
const vals = validationSchema.cast(values)
const { _routing_configuration, policy } = vals
const ids = Object.keys(routingPolicies)

try {
if (_routing_configuration === 'ttn') {
const ids = Object.keys(routingPolicies)

await dispatch(attachPromise(deleteHomeNetworkDefaultRoutingPolicy()))
await dispatch(attachPromise(deleteAllHomeNetworkRoutingPolicies(ids)))
await dispatch(attachPromise(setHomeNetworkRoutingPolicy(TTN_NET_ID, policy)))
} else if (_routing_configuration === 'all_networks') {
await dispatch(attachPromise(deleteAllHomeNetworkRoutingPolicies(ids)))
await dispatch(attachPromise(setHomeNetworkDefaultRoutingPolicy(policy)))
} else {
await dispatch(attachPromise(setHomeNetworkDefaultRoutingPolicy(policy)))
}
Expand Down

0 comments on commit ceded37

Please sign in to comment.