Merge pull request #5521 from influxdata/5474/dashboard_undefined

fix(dashboard): avoid undefined error when dashboard is not ready yet
pull/5529/head
Pavel Závora 2020-06-22 21:09:26 +02:00 committed by GitHub
commit 25563b07de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -27,6 +27,10 @@ export const updateDashboardLinks = (
) => {
const {active} = dashboardLinks
if (!activeDashboard) {
return {...dashboardLinks, active: null}
}
if (!active || active.key !== String(activeDashboard.id)) {
return updateActiveDashboardLink(dashboardLinks, activeDashboard)
}
@ -38,10 +42,6 @@ const updateActiveDashboardLink = (
dashboardLinks: DashboardSwitcherLinks,
dashboard: Dashboard
) => {
if (!dashboard) {
return {...dashboardLinks, active: null}
}
const active = dashboardLinks.links.find(
link => link.key === String(dashboard.id)
)