From 6a47ddd9c17cf58676c185cac3d62fad37020039 Mon Sep 17 00:00:00 2001 From: Jason Rhodes Date: Sat, 27 Oct 2018 13:33:38 -0400 Subject: [PATCH 1/3] Fixes rare cases where KibanaLink will be loaded outside of React context and requires no redux connect dependency --- .../ErrorGroupOverview/Watcher/WatcherFlyOut.js | 8 +++++--- .../components/app/ErrorGroupOverview/view.js | 1 + x-pack/plugins/apm/public/utils/url.tsx | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/Watcher/WatcherFlyOut.js b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/Watcher/WatcherFlyOut.js index 75110c5931a0f..d7fb8636baa3c 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/Watcher/WatcherFlyOut.js +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/Watcher/WatcherFlyOut.js @@ -33,7 +33,7 @@ import { import { XPACK_DOCS } from '../../../../utils/documentation/xpack'; -import { KibanaLink } from '../../../../utils/url'; +import { UnconnectedKibanaLink } from '../../../../utils/url'; import { createErrorGroupWatch } from './createErrorGroupWatch'; import chrome from 'ui/chrome'; @@ -187,12 +187,13 @@ export default class WatcherFlyout extends Component {

The watch is now ready and will send error reports for{' '} {this.props.serviceName}.{' '} - View watch. - +

) }); @@ -419,6 +420,7 @@ export default class WatcherFlyout extends Component { } WatcherFlyout.propTypes = { + location: PropTypes.object.isRequired, isOpen: PropTypes.bool.isRequired, serviceName: PropTypes.string, onClose: PropTypes.func.isRequired diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/view.js b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/view.js index 9287028347b1d..0348ee5f711f0 100644 --- a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/view.js +++ b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/view.js @@ -53,6 +53,7 @@ class ErrorGroupOverview extends Component { /> = ({ location, pathname, hash, query = {}, ...props -}: KibanaLinkArgs) { +}) => { // Preserve current _g and _a const currentQuery = toQuery(location.search); const nextQuery = { @@ -186,14 +193,14 @@ export function KibanaLinkComponent({ }); return ; -} +}; const withLocation = connect( ({ location }: { location: any }) => ({ location }), {} ); export const RelativeLink = withLocation(RelativeLinkComponent); -export const KibanaLink = withLocation(KibanaLinkComponent); +export const KibanaLink = withLocation(UnconnectedKibanaLink); // This is downright horrible 😭 💔 // Angular decodes encoded url tokens like "%2F" to "/" which causes the route to change. From 03065f5da93ba8d6c4447e41086437217564fc83 Mon Sep 17 00:00:00 2001 From: Jason Rhodes Date: Sat, 27 Oct 2018 21:58:02 -0400 Subject: [PATCH 2/3] Fixes tests for updated Kibana link component --- .../__test__/__snapshots__/url.test.js.snap | 25 ++++++++++++------- .../apm/public/utils/__test__/url.test.js | 8 +++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap b/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap index c2f0bcbe6ff86..5d456b140d077 100644 --- a/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap +++ b/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap @@ -1,27 +1,34 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`KibanaLinkComponent should render correct markup 1`] = ` +exports[`RelativeLinkComponent should render correct markup 1`] = ` Go to Discover `; -exports[`RelativeLinkComponent should render correct markup 1`] = ` +exports[`UnconnectedKibanaComponent should render correct markup 1`] = `undefined`; + +exports[`UnconnectedKibanaLink should render correct markup 1`] = ` Go to Discover `; exports[`ViewMLJob should render component 1`] = ` - View Job - + `; diff --git a/x-pack/plugins/apm/public/utils/__test__/url.test.js b/x-pack/plugins/apm/public/utils/__test__/url.test.js index b3617da276379..93daa86281b22 100644 --- a/x-pack/plugins/apm/public/utils/__test__/url.test.js +++ b/x-pack/plugins/apm/public/utils/__test__/url.test.js @@ -11,7 +11,7 @@ import createHistory from 'history/createMemoryHistory'; import { toQuery, fromQuery, - KibanaLinkComponent, + UnconnectedKibanaLink, RelativeLinkComponent, encodeKibanaSearchParams, decodeKibanaSearchParams, @@ -182,7 +182,7 @@ describe('RelativeLinkComponent', () => { }); }); -describe('KibanaLinkComponent', () => { +describe('UnconnectedKibanaLink', () => { let wrapper; beforeEach(() => { @@ -198,14 +198,14 @@ describe('KibanaLinkComponent', () => { }; wrapper = mount( - Go to Discover - + ); }); From 491fec65fcb6fe7c3d4b302444ff19b896326c26 Mon Sep 17 00:00:00 2001 From: Jason Rhodes Date: Sun, 28 Oct 2018 19:36:31 -0400 Subject: [PATCH 3/3] Removes obsolete snapshot --- .../apm/public/utils/__test__/__snapshots__/url.test.js.snap | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap b/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap index 5d456b140d077..5edeb67d36828 100644 --- a/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap +++ b/x-pack/plugins/apm/public/utils/__test__/__snapshots__/url.test.js.snap @@ -10,8 +10,6 @@ exports[`RelativeLinkComponent should render correct markup 1`] = ` `; -exports[`UnconnectedKibanaComponent should render correct markup 1`] = `undefined`; - exports[`UnconnectedKibanaLink should render correct markup 1`] = `