Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Canvas] Adds support for uppercase cluster names in esdocs and other datasource bug fixes #44311

Merged
merged 6 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function esdocs(): ExpressionFunction<'esdocs', Filter, Arguments, any> {
});

if (index) {
query.from(index.toLowerCase());
query.from(index);
}

if (fields) {
Expand All @@ -92,7 +92,7 @@ export function esdocs(): ExpressionFunction<'esdocs', Filter, Arguments, any> {
if (sort) {
const [sortField, sortOrder] = sort.split(',').map(str => str.trim());
if (sortField) {
query.order(`"${sortField}"`, sortOrder.toLowerCase() === 'asc');
query.order(`"${sortField}"`, sortOrder === 'asc');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const ESIndexSelect = ({ value, loading, indices, onChange, onFocus, onBl
return (
<EuiComboBox
selectedOptions={selectedOption}
onChange={([index]) => onChange(get(index, 'label', defaultIndex).toLowerCase())}
onChange={([index]) => onChange(get(index, 'label', defaultIndex))}
onSearchChange={searchValue => {
// resets input when user starts typing
if (searchValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {
};

const getIndex = () => {
return getSimpleArg('index', args)[0] || defaultIndex;
return getSimpleArg('index', args)[0] || '';
};

const getQuery = () => {
Expand All @@ -58,7 +58,11 @@ const EsdocsDatasource = ({ args, updateArgs, defaultIndex }) => {
const fields = getFields();
const [sortField, sortOrder] = getSortBy();

const index = getIndex().toLowerCase();
const index = getIndex();

if (!index && defaultIndex) {
setArg('index', defaultIndex);
}

const sortOptions = [{ value: 'asc', text: 'Ascending' }, { value: 'desc', text: 'Descending' }];

Expand Down
15 changes: 10 additions & 5 deletions x-pack/legacy/plugins/canvas/public/lib/es_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ export const getIndices = () =>
})
.catch(err => notify.error(err, { title: `Couldn't fetch Elasticsearch indices` }));

export const getDefaultIndex = () =>
savedObjectsClient
.get('index-pattern', AdvancedSettings.get('defaultIndex'))
.then(defaultIndex => defaultIndex.attributes.title)
.catch(err => notify.error(err, { title: `Couldn't fetch default index` }));
export const getDefaultIndex = () => {
const defaultIndexId = AdvancedSettings.get('defaultIndex');

return defaultIndexId
? savedObjectsClient
.get('index-pattern', defaultIndexId)
.then(defaultIndex => defaultIndex.attributes.title)
.catch(err => notify.error(err, { title: `Couldn't fetch default index` }))
: Promise.resolve('');
};