From 385bab94b75cf3b0a105f532927267525a9bc370 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Tue, 1 Dec 2020 08:02:30 +0100 Subject: [PATCH] fix bug when redirecting to SO management with a tag having whitespaces in its name --- .../public/management/utils/get_tag_connections_url.test.ts | 4 ++-- .../public/management/utils/get_tag_connections_url.ts | 2 +- .../saved_object_tagging/functional/tests/som_integration.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.test.ts b/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.test.ts index 812106b4e3bbf..1b5aa39b81b39 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.test.ts +++ b/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.test.ts @@ -28,14 +28,14 @@ describe('getTagConnectionsUrl', () => { it('appends the basePath to the generated url', () => { const tag = createTag('myTag'); expect(getTagConnectionsUrl(tag, httpMock.basePath)).toMatchInlineSnapshot( - `"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(myTag)"` + `"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(%22myTag%22)"` ); }); it('escapes the query', () => { const tag = createTag('tag with spaces'); expect(getTagConnectionsUrl(tag, httpMock.basePath)).toMatchInlineSnapshot( - `"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(tag%20with%20spaces)"` + `"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(%22tag%20with%20spaces%22)"` ); }); }); diff --git a/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.ts b/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.ts index 808e0ddcf2d65..f65ee4ddcb425 100644 --- a/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.ts +++ b/x-pack/plugins/saved_objects_tagging/public/management/utils/get_tag_connections_url.ts @@ -12,6 +12,6 @@ import { TagWithRelations } from '../../../common/types'; * already selected in the query/filter bar. */ export const getTagConnectionsUrl = (tag: TagWithRelations, basePath: IBasePath) => { - const query = encodeURIComponent(`tag:(${tag.name})`); + const query = encodeURIComponent(`tag:("${tag.name}")`); return basePath.prepend(`/app/management/kibana/objects?initialQuery=${query}`); }; diff --git a/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts b/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts index 4897264b0d0c1..912ab3945b8e6 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/som_integration.ts @@ -55,7 +55,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await PageObjects.common.waitUntilUrlIncludes('/app/management/kibana/objects'); await PageObjects.savedObjects.waitTableIsLoaded(); - expect(await PageObjects.savedObjects.getCurrentSearchValue()).to.eql('tag:(tag-1)'); + expect(await PageObjects.savedObjects.getCurrentSearchValue()).to.eql('tag:("tag-1")'); expect(await PageObjects.savedObjects.getRowTitles()).to.eql([ 'Visualization 1 (tag-1)', 'Visualization 3 (tag-1 + tag-3)',