[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>
This commit is contained in:
grafana-delivery-bot[bot]
2024-04-18 17:32:41 +02:00
committed by GitHub
co-authored by Alexa V
parent 2c4277f5f8
commit d05587b2fd
2 changed files with 10 additions and 3 deletions
@@ -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;
}