Skip to content

Commit

Permalink
Warn users when project linked packages cannot satisfy the .zap file …
Browse files Browse the repository at this point in the history
…import/open

- Throw an error in importEndpointType when device types cannot be found for an endpoint type
- JIRA: ZAPP-1363
  • Loading branch information
brdandu committed May 9, 2024
1 parent 0cc6562 commit 88ee61b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src-electron/db/query-impexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const dbApi = require('./db-api')
const dbEnums = require('../../src-shared/db-enum')
const dbMapping = require('./db-mapping.js')
const queryUpgrade = require('../sdk/matter.js')
const sessionNotification = require('./query-session-notification')

/**
* Imports a single endpoint
* @param {} db
Expand Down Expand Up @@ -234,13 +236,15 @@ ORDER BY
* @param {*} sessionPartitionId
* @param {*} packageId
* @param {*} endpointType
* @param {*} sessionId
* @returns Promise of endpoint insertion.
*/
async function importEndpointType(
db,
sessionPartitionId,
packageIds,
endpointType
endpointType,
sessionId
) {
// Insert endpoint type
let endpointTypeId = await dbApi.dbInsert(
Expand Down Expand Up @@ -306,6 +310,18 @@ async function importEndpointType(
]
)

// Log an error message into the session notice table when device types being imported are not found
if (!rows || rows.length == 0) {
sessionNotification.setNotification(
db,
'ERROR',
'Device Types could not be found in the ZCL extensions linked to this project. Please make sure the zcl and template json files listed in your zap file exist.',
sessionId,
1,
1
)
}

// Associate deviceTypes with the endpointType
for (let row of rows) {
promises.push(
Expand Down
3 changes: 2 additions & 1 deletion src-electron/importexport/import-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,8 @@ async function importEndpointTypes(
db,
sessionPartitionInfo[0].sessionPartitionId,
allZclPackageIds,
endpointTypes[i]
endpointTypes[i],
sessionId
)
let endpointId = ''
if (sortedEndpoints[i]) {
Expand Down

0 comments on commit 88ee61b

Please sign in to comment.