diff --git a/src/plugins/vis_augmenter/public/utils/utils.test.ts b/src/plugins/vis_augmenter/public/utils/utils.test.ts index d8ebe41b087f..f831deef3955 100644 --- a/src/plugins/vis_augmenter/public/utils/utils.test.ts +++ b/src/plugins/vis_augmenter/public/utils/utils.test.ts @@ -372,12 +372,12 @@ describe('utils', () => { expect(loader.findAll).toHaveBeenCalledWith( '', 100, - [], + undefined, { type: 'visualization', id: visId1 as string, }, - [] + undefined ); }); it('single plugin resource is propagated to findAll()', async () => { @@ -391,7 +391,7 @@ describe('utils', () => { expect(loader.findAll).toHaveBeenCalledWith( 'resource-1', 100, - [], + undefined, { type: 'visualization', id: visId1 as string, @@ -411,7 +411,7 @@ describe('utils', () => { expect(loader.findAll).toHaveBeenCalledWith( 'resource-1|resource-2', 100, - [], + undefined, { type: 'visualization', id: visId1 as string, diff --git a/src/plugins/vis_augmenter/public/utils/utils.ts b/src/plugins/vis_augmenter/public/utils/utils.ts index f1c18ce15b79..c8ebde337757 100644 --- a/src/plugins/vis_augmenter/public/utils/utils.ts +++ b/src/plugins/vis_augmenter/public/utils/utils.ts @@ -72,19 +72,19 @@ export const getAugmentVisSavedObjs = async ( ); } try { - // If there is specified plugin resource IDs, add a search string and search field - // into findAll() fn call + // If there are any plugin resource IDs specified, add a search string and search field + // into findAll() call const pluginResourceIdsSpecified = - pluginResourceIds !== undefined && pluginResourceIds.length > 0; + Array.isArray(pluginResourceIds) && pluginResourceIds.length > 0; const resp = await loader?.findAll( - pluginResourceIdsSpecified ? pluginResourceIds.join('|') : '', + pluginResourceIdsSpecified ? pluginResourceIds!.join('|') : '', 100, - [], + undefined, { type: 'visualization', id: visId as string, }, - pluginResourceIdsSpecified ? ['pluginResource.id'] : [] + pluginResourceIdsSpecified ? ['pluginResource.id'] : undefined ); return (get(resp, 'hits', []) as any[]) as ISavedAugmentVis[]; } catch (e) {