diff --git a/src/plugins/saved_objects_finder/common/types.ts b/src/plugins/saved_objects_finder/common/types.ts index c451be83fd0eb..a37a3abec1ffc 100644 --- a/src/plugins/saved_objects_finder/common/types.ts +++ b/src/plugins/saved_objects_finder/common/types.ts @@ -14,4 +14,5 @@ export type SavedObjectCommon = S export interface FinderAttributes { title?: string; name?: string; + description?: string; } diff --git a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx index ace6f6a9d3661..87482f4151fa8 100644 --- a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx +++ b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.test.tsx @@ -41,17 +41,19 @@ describe('SavedObjectsFinder', () => { const doc = { id: '1', type: 'search', - attributes: { title: 'Example title' }, + attributes: { title: 'Example title', description: 'example description' }, }; const doc2 = { id: '2', type: 'search', - attributes: { title: 'Another title' }, + attributes: { title: 'Another title', description: 'another description' }, }; const doc3 = { type: 'vis', id: '3', attributes: { title: 'Vis' } }; + const doc4 = { type: 'search', id: '4', attributes: { title: 'Search' } }; + const searchMetaData = [ { type: 'search', @@ -234,6 +236,30 @@ describe('SavedObjectsFinder', () => { `); }); + + it('render description if provided', async () => { + (contentClient.mSearch as any as jest.SpyInstance).mockImplementation(() => + Promise.resolve({ hits: [doc, doc2, doc4] }) + ); + + const wrapper = shallow( + + ); + + wrapper.instance().componentDidMount!(); + await nextTick(); + expect( + wrapper + .find(EuiInMemoryTable) + .prop('items') + .filter((item: any) => item.attributes.description) + .map((item: any) => item.attributes.description) + ).toEqual([doc.attributes.description, doc2.attributes.description]); + }); }); describe('sorting', () => { diff --git a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx index 9ea3472e59d3c..f9e74ca829fa7 100644 --- a/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx +++ b/src/plugins/saved_objects_finder/public/finder/saved_object_finder.tsx @@ -146,7 +146,7 @@ class SavedObjectFinderUiClass extends React.Component< const savedObjects = response.hits .map((savedObject) => { const { - attributes: { name, title }, + attributes: { name, title, description }, } = savedObject; const titleToUse = typeof title === 'string' ? title : ''; const nameToUse = name ? name : titleToUse; @@ -156,6 +156,7 @@ class SavedObjectFinderUiClass extends React.Component< title: titleToUse, name: nameToUse, simple: savedObject, + description, }; }) .filter((savedObject) => { @@ -317,13 +318,23 @@ class SavedObjectFinderUiClass extends React.Component< ); const tooltipText = this.props.getTooltipText?.(item); - + const description = !!item.simple.attributes.description && ( + + {item.simple.attributes.description} + + ); return tooltipText ? ( - - {link} - + + + {link} + + {description} + ) : ( - link + + {link} + {description} + ); }, }, diff --git a/x-pack/test/saved_object_tagging/functional/tests/discover_integration.ts b/x-pack/test/saved_object_tagging/functional/tests/discover_integration.ts index 365ce9a715816..f4b917abf5d7f 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/discover_integration.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/discover_integration.ts @@ -82,22 +82,25 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('allows to manually type tag filter query', async () => { await PageObjects.discover.openLoadSavedSearchPanel(); await testSubjects.setValue('savedObjectFinderSearchInput', 'tag:(tag-1)'); - await expectSavedSearches('A Saved Search'); + await expectSavedSearches('A Saved Search\nA Saved Search Description'); }); it('allows to filter by selecting a tag in the filter menu', async () => { await PageObjects.discover.openLoadSavedSearchPanel(); await selectFilterTags('tag-2'); - await expectSavedSearches('A Saved Search', 'A Different Saved Search'); + await expectSavedSearches( + 'A Saved Search\nA Saved Search Description', + 'A Different Saved Search\nA Different Saved Search Description' + ); }); it('allows to filter by multiple tags', async () => { await PageObjects.discover.openLoadSavedSearchPanel(); await selectFilterTags('tag-2', 'tag-3'); await expectSavedSearches( - 'A Saved Search', - 'A Different Saved Search', - 'A Third Saved Search' + 'A Different Saved Search\nA Different Saved Search Description', + 'A Saved Search\nA Saved Search Description', + 'A Third Saved Search\nAn Untagged Saved Search Description' ); }); }); @@ -116,7 +119,11 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); await PageObjects.discover.openLoadSavedSearchPanel(); await selectFilterTags('tag-1', 'tag-2'); - await expectSavedSearches('A Saved Search', 'A Different Saved Search', 'My New Search'); + await expectSavedSearches( + 'A Different Saved Search\nA Different Saved Search Description', + 'A Saved Search\nA Saved Search Description', + 'My New Search' + ); }); it('allows to create a tag from the tag selector', async () => { @@ -172,9 +179,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await PageObjects.discover.openLoadSavedSearchPanel(); await selectFilterTags('tag-3'); await expectSavedSearches( - 'A Different Saved Search', - 'A Third Saved Search', - 'A Saved Search' + 'A Different Saved Search\nA Different Saved Search Description', + 'A Saved Search\nA Saved Search Description', + 'A Third Saved Search\nAn Untagged Saved Search Description' ); }); });