mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Canvas] [8.0] Fixes ESDocs Index argument not being initially applied. (#123026)
This commit is contained in:
parent
ab38a7073c
commit
98e8d874f8
1 changed files with 17 additions and 8 deletions
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, { useEffect, useCallback } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
EuiFormRow,
|
||||
|
@ -27,13 +27,16 @@ import { DataSourceStrings, LUCENE_QUERY_URL } from '../../../i18n';
|
|||
const { ESDocs: strings } = DataSourceStrings;
|
||||
|
||||
const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {
|
||||
const setArg = (name, value) => {
|
||||
updateArgs &&
|
||||
updateArgs({
|
||||
...args,
|
||||
...setSimpleArg(name, value),
|
||||
});
|
||||
};
|
||||
const setArg = useCallback(
|
||||
(name, value) => {
|
||||
updateArgs &&
|
||||
updateArgs({
|
||||
...args,
|
||||
...setSimpleArg(name, value),
|
||||
});
|
||||
},
|
||||
[args, updateArgs]
|
||||
);
|
||||
|
||||
// TODO: This is a terrible way of doing defaults. We need to find a way to read the defaults for the function
|
||||
// and set them for the data source UI.
|
||||
|
@ -73,6 +76,12 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {
|
|||
|
||||
const index = getIndex();
|
||||
|
||||
useEffect(() => {
|
||||
if (getSimpleArg('index', args)[0] !== index) {
|
||||
setArg('index', index);
|
||||
}
|
||||
}, [args, index, setArg]);
|
||||
|
||||
const sortOptions = [
|
||||
{ value: 'asc', text: strings.getAscendingOption() },
|
||||
{ value: 'desc', text: strings.getDescendingOption() },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue