From 2c9eed360d7c0d848f08ea91169bdf7382065be4 Mon Sep 17 00:00:00 2001 From: Lukas Siatka Date: Thu, 7 May 2020 13:53:05 +0200 Subject: [PATCH] Chore: fixes few strict-null errors (#23775) * Chore: fixes strict-null-error in Login > ChangePassword component * Chore: fixes strict-null-error in Login > LoginForm component * Chore: fixes strict-null-errors in OrgActionBar component and components that render it * Chore: fixes strict-null-errors in PageHeader component * Chore: fixes strict-null-errors in PermissionList components * Chore: fixes strict-null-errors in loki language provider * Chore: fixes strict-null-errors in loki datasource * Chore: fixes strict-null-errors in panel_editor > EditorTabBody component * Chore: fixes strict-null-errors in flatten utility * Chore: fixes strict-null-errors in search component * Chore: fixes strict-null-errors in SharedPreferences component * Chore: fixes strict-null-errors in MetricSelect component * Chore: updates type on a param to type on argument * Chore: updates strict-null errors count from 791 to 757 * Chore: updates PageHeader - adds null checks * Chore: updates PageHeader - updates null checks * Chore: updates PageHeader null checks to longer format * Chore: updates strict-null fixes * Chore: updates error count limit in ci-frontend-metrics --- .../core/components/PageHeader/PageHeader.tsx | 34 +++++++++++++------ .../PermissionList/AddPermission.tsx | 2 +- .../PermissionList/PermissionListItem.tsx | 4 +-- .../core/components/Select/MetricSelect.tsx | 6 ++-- public/app/core/utils/flatten.ts | 6 ++-- .../app/plugins/datasource/loki/datasource.ts | 2 +- .../datasource/loki/language_provider.ts | 9 +++-- scripts/ci-frontend-metrics.sh | 2 +- 8 files changed, 40 insertions(+), 25 deletions(-) diff --git a/public/app/core/components/PageHeader/PageHeader.tsx b/public/app/core/components/PageHeader/PageHeader.tsx index da8dfb2b95c..8253d5c671f 100644 --- a/public/app/core/components/PageHeader/PageHeader.tsx +++ b/public/app/core/components/PageHeader/PageHeader.tsx @@ -9,8 +9,12 @@ export interface Props { model: NavModel; } -const SelectNav = ({ main, customCss }: { main: NavModelItem; customCss: string }) => { - const defaultSelectedItem = main.children.find(navItem => { +const SelectNav = ({ children, customCss }: { children: NavModelItem[]; customCss: string }) => { + if (!children || children.length === 0) { + return null; + } + + const defaultSelectedItem = children.find(navItem => { return navItem.active === true; }); @@ -22,15 +26,18 @@ const SelectNav = ({ main, customCss }: { main: NavModelItem; customCss: string return (
-