From c5bcef45f744f362ac8b6465934fb3d783f361fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yulia=20=C4=8Cech?= <6585477+yuliacech@users.noreply.github.com> Date: Tue, 20 Oct 2020 15:44:28 +0200 Subject: [PATCH] Fix reactRouterNavigate when used with a string (#80520) * Fix reactRouterNavigate when used with a string * Update license management snapshots Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../react_router_navigate.tsx | 4 +- .../upload_license.test.tsx.snap | 102 ++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx b/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx index 7a9fe19273324..e127ac4d98133 100644 --- a/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx +++ b/src/plugins/kibana_react/public/react_router_navigate/react_router_navigate.tsx @@ -18,7 +18,7 @@ */ import { ScopedHistory } from 'kibana/public'; -import { History } from 'history'; +import { History, parsePath } from 'history'; interface LocationObject { pathname?: string; @@ -32,7 +32,7 @@ const isModifiedEvent = (event: any) => const isLeftClickEvent = (event: any) => event.button === 0; export const toLocationObject = (to: string | LocationObject) => - typeof to === 'string' ? { pathname: to } : to; + typeof to === 'string' ? parsePath(to) : to; export const reactRouterNavigate = ( history: ScopedHistory | History, diff --git a/x-pack/plugins/license_management/__jest__/__snapshots__/upload_license.test.tsx.snap b/x-pack/plugins/license_management/__jest__/__snapshots__/upload_license.test.tsx.snap index 429f6c7af6e27..2767642254322 100644 --- a/x-pack/plugins/license_management/__jest__/__snapshots__/upload_license.test.tsx.snap +++ b/x-pack/plugins/license_management/__jest__/__snapshots__/upload_license.test.tsx.snap @@ -120,7 +120,9 @@ exports[`UploadLicense should display a modal when license requires acknowledgem "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -171,7 +173,9 @@ exports[`UploadLicense should display a modal when license requires acknowledgem "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -213,7 +217,9 @@ exports[`UploadLicense should display a modal when license requires acknowledgem "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -1035,22 +1041,30 @@ exports[`UploadLicense should display an error when ES says license is expired 1 "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -1113,22 +1127,30 @@ exports[`UploadLicense should display an error when ES says license is expired 1 "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -1182,22 +1204,30 @@ exports[`UploadLicense should display an error when ES says license is expired 1 "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -1723,22 +1753,30 @@ exports[`UploadLicense should display an error when ES says license is invalid 1 "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -1801,22 +1839,30 @@ exports[`UploadLicense should display an error when ES says license is invalid 1 "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -1870,22 +1916,30 @@ exports[`UploadLicense should display an error when ES says license is invalid 1 "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -2411,22 +2465,30 @@ exports[`UploadLicense should display an error when submitting invalid JSON 1`] "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -2489,22 +2551,30 @@ exports[`UploadLicense should display an error when submitting invalid JSON 1`] "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -2558,22 +2628,30 @@ exports[`UploadLicense should display an error when submitting invalid JSON 1`] "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -3099,22 +3177,30 @@ exports[`UploadLicense should display error when ES returns error 1`] = ` "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -3177,22 +3263,30 @@ exports[`UploadLicense should display error when ES returns error 1`] = ` "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ], @@ -3246,22 +3340,30 @@ exports[`UploadLicense should display error when ES returns error 1`] = ` "calls": Array [ Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], Array [ Object { + "hash": "", "pathname": "/home", + "search": "", }, ], ],