Skip to content

Commit

Permalink
console: Fix filter of end devices with startsWith
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaplots committed Jan 16, 2025
1 parent 35720e1 commit f05d107
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ const AppSideNavigation = () => {
const rights = useSelector(selectApplicationRights)
const natsDisabled = useSelector(selectNatsProviderDisabled)
const mqttDisabled = useSelector(selectMqttProviderDisabled)
const topEntityFilter = useCallback(e => e.id.startsWith(appId), [appId])
const topEntityFilter = useCallback(
e => {
const separatedAppId = e.id.split('/')[0]
return separatedAppId === appId
},
[appId],
)
const topEntities = useSelector(state => selectEndDeviceTopEntities(state, topEntityFilter))

if (!app) {
Expand Down
21 changes: 12 additions & 9 deletions pkg/webui/console/store/selectors/top-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,20 @@ export const selectTopEntities = createSelector(
)

const createTopEntityByTypeSelector = entityType =>
createSelector([selectTopEntities, (_, filter) => filter], (topEntities, filter) => {
if (!topEntities[entityType]) {
return []
}
createSelector(
[selectTopEntities, (_, topEntityFilter) => topEntityFilter],
(topEntities, topEntityFilter) => {
if (!topEntities[entityType]) {
return []
}

const filteredEntities = filter
? topEntities[entityType].filter(filter)
: topEntities[entityType]
const filteredEntities = topEntityFilter
? topEntities[entityType].filter(topEntityFilter)
: topEntities[entityType]

return filteredEntities
})
return filteredEntities
},
)

export const selectTopEntitiesAll = state => selectTopEntities(state)[ALL]

Expand Down

0 comments on commit f05d107

Please sign in to comment.