[v11.0.x] Dashboard: DashboardPageProxy - Use chaining operators to prevent runtime error (#86536)

Dashboard: DashboardPageProxy - Use chaining operators to prevent runtime error (#86507)

* Use chaining operators to prevent runtime error

* Fix tests

---------

Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
(cherry picked from commit 7a147f2ce8)

Co-authored-by: Alexa V <239999+axelavargas@users.noreply.github.com>
pull/86542/head
grafana-delivery-bot[bot] 1 year ago committed by GitHub
parent 2c4277f5f8
commit d05587b2fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      public/app/features/dashboard/containers/DashboardPageProxy.test.tsx
  2. 2
      public/app/features/dashboard/containers/DashboardPageProxy.tsx

@ -147,7 +147,7 @@ describe('DashboardPageProxy', () => {
act(() => {
setup({
route: { routeName: DashboardRoutes.Home, component: () => null, path: '/' },
match: { params: {}, isExact: true, path: '/', url: '/' },
match: { params: { uid: '' }, isExact: true, path: '/', url: '/' },
});
});
@ -176,7 +176,14 @@ describe('DashboardPageProxy', () => {
act(() => {
setup({
route: { routeName: DashboardRoutes.Home, component: () => null, path: '/' },
match: { params: {}, isExact: true, path: '/', url: '/' },
match: {
params: {
uid: '',
},
isExact: true,
path: '/',
url: '/',
},
});
});

@ -54,7 +54,7 @@ function DashboardPageProxy(props: DashboardPageProxyProps) {
return null;
}
if (dashboard.value && dashboard.value.dashboard.uid && dashboard.value.dashboard.uid !== props.match.params.uid) {
if (dashboard?.value?.dashboard?.uid !== props.match.params.uid) {
return null;
}

Loading…
Cancel
Save