[data view mgmt] fix privileges problem for field preview (#127523) (#127541)

* fix privledges problem for field preview

* fix test

(cherry picked from commit fb11d2d8fe)

# Conflicts:
#	src/plugins/data_view_field_editor/__jest__/client_integration/field_editor_flyout_preview.test.ts
#	src/plugins/data_view_field_editor/public/components/preview/field_preview_context.tsx
This commit is contained in:
Matthew Kime 2022-03-11 10:28:33 -06:00 committed by GitHub
parent 0135f75aaf
commit 485e9689b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -367,7 +367,7 @@ describe('Field editor Preview panel', () => {
title: 'First doc - title',
},
documentId: '001',
index: 'testIndex',
index: 'testIndexPattern',
script: {
source: 'echo("hello")',
},

View file

@ -167,7 +167,6 @@ export const FieldPreviewProvider: FunctionComponent = ({ children }) => {
[documents, currentIdx]
);
const currentDocIndex = currentDocument?._index;
const currentDocId: string = currentDocument?._id ?? '';
const totalDocs = documents.length;
const { name, document, script, format, type } = params;
@ -334,7 +333,7 @@ export const FieldPreviewProvider: FunctionComponent = ({ children }) => {
const currentApiCall = ++previewCount.current;
const response = await getFieldPreview({
index: currentDocIndex,
index: indexPattern.title,
document: params.document!,
context: `${params.type!}_field` as FieldPreviewContext,
script: params.script!,
@ -386,11 +385,11 @@ export const FieldPreviewProvider: FunctionComponent = ({ children }) => {
}, [
needToUpdatePreview,
params,
currentDocIndex,
currentDocId,
getFieldPreview,
notifications.toasts,
valueFormatter,
indexPattern.title,
]);
const goToNextDoc = useCallback(() => {