mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* handle case where control index pattern no longer exists * fix errors when vis is edited with missing index pattern
This commit is contained in:
parent
519991342c
commit
781ac42577
6 changed files with 50 additions and 11 deletions
|
@ -48,7 +48,13 @@ export class FieldSelect extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
const indexPattern = await this.props.getIndexPattern(indexPatternId);
|
||||
let indexPattern;
|
||||
try {
|
||||
indexPattern = await this.props.getIndexPattern(indexPatternId);
|
||||
} catch (err) {
|
||||
// index pattern no longer exists
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._hasUnmounted) {
|
||||
return;
|
||||
|
|
|
@ -46,13 +46,15 @@ export class IndexPatternSelect extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
const indexPattern = await this.props.getIndexPattern(indexPatternId);
|
||||
|
||||
if (!this._isMounted) {
|
||||
let indexPattern;
|
||||
try {
|
||||
indexPattern = await this.props.getIndexPattern(indexPatternId);
|
||||
} catch (err) {
|
||||
// index pattern no longer exists
|
||||
return;
|
||||
}
|
||||
|
||||
if (!indexPattern) {
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,9 +66,13 @@ ListControl.propTypes = {
|
|||
id: PropTypes.string.isRequired,
|
||||
label: PropTypes.string.isRequired,
|
||||
selectedOptions: PropTypes.arrayOf(comboBoxOptionShape).isRequired,
|
||||
options: PropTypes.arrayOf(comboBoxOptionShape).isRequired,
|
||||
options: PropTypes.arrayOf(comboBoxOptionShape),
|
||||
disableMsg: PropTypes.string,
|
||||
multiselect: PropTypes.bool.isRequired,
|
||||
controlIndex: PropTypes.number.isRequired,
|
||||
stageFilter: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
ListControl.defaultProps = {
|
||||
options: [],
|
||||
};
|
||||
|
|
|
@ -6,9 +6,14 @@ which doesn't exist on any documents in the "${indexPatternName}" index pattern.
|
|||
Choose a different field or index documents that contain values for this field.`;
|
||||
}
|
||||
|
||||
export function noIndexPatternMsg(indexPatternId) {
|
||||
return `Could not locate index-pattern id: ${indexPatternId}.`;
|
||||
}
|
||||
|
||||
export class Control {
|
||||
constructor(controlParams, filterManager, kbnApi, useTimeFilter) {
|
||||
this.id = controlParams.id;
|
||||
this.controlParams = controlParams;
|
||||
this.options = controlParams.options;
|
||||
this.type = controlParams.type;
|
||||
this.label = controlParams.label ? controlParams.label : controlParams.fieldName;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import _ from 'lodash';
|
||||
import {
|
||||
Control,
|
||||
noValuesDisableMsg
|
||||
noValuesDisableMsg,
|
||||
noIndexPatternMsg,
|
||||
} from './control';
|
||||
import { PhraseFilterManager } from './filter_manager/phrase_filter_manager';
|
||||
import { createSearchSource } from './create_search_source';
|
||||
|
@ -35,6 +36,12 @@ const termsAgg = (field, size, direction) => {
|
|||
class ListControl extends Control {
|
||||
|
||||
async fetch() {
|
||||
const indexPattern = this.filterManager.getIndexPattern();
|
||||
if (!indexPattern) {
|
||||
this.disable(noIndexPatternMsg(this.controlParams.indexPattern));
|
||||
return;
|
||||
}
|
||||
|
||||
let ancestorFilters;
|
||||
if (this.hasAncestors()) {
|
||||
if (this.hasUnsetAncestor()) {
|
||||
|
@ -52,7 +59,6 @@ class ListControl extends Control {
|
|||
ancestorFilters = this.getAncestorFilters();
|
||||
}
|
||||
|
||||
const indexPattern = this.filterManager.getIndexPattern();
|
||||
const fieldName = this.filterManager.fieldName;
|
||||
const initialSearchSourceState = {
|
||||
timeout: '1s',
|
||||
|
@ -89,7 +95,12 @@ class ListControl extends Control {
|
|||
}
|
||||
|
||||
export async function listControlFactory(controlParams, kbnApi, useTimeFilter) {
|
||||
const indexPattern = await kbnApi.indexPatterns.get(controlParams.indexPattern);
|
||||
let indexPattern;
|
||||
try {
|
||||
indexPattern = await kbnApi.indexPatterns.get(controlParams.indexPattern);
|
||||
} catch (err) {
|
||||
// ignore not found error and return control so it can be displayed in disabled state.
|
||||
}
|
||||
|
||||
return new ListControl(
|
||||
controlParams,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import _ from 'lodash';
|
||||
import {
|
||||
Control,
|
||||
noValuesDisableMsg
|
||||
noValuesDisableMsg,
|
||||
noIndexPatternMsg,
|
||||
} from './control';
|
||||
import { RangeFilterManager } from './filter_manager/range_filter_manager';
|
||||
import { createSearchSource } from './create_search_source';
|
||||
|
@ -30,6 +31,11 @@ class RangeControl extends Control {
|
|||
|
||||
async fetch() {
|
||||
const indexPattern = this.filterManager.getIndexPattern();
|
||||
if (!indexPattern) {
|
||||
this.disable(noIndexPatternMsg(this.controlParams.indexPattern));
|
||||
return;
|
||||
}
|
||||
|
||||
const fieldName = this.filterManager.fieldName;
|
||||
|
||||
const aggs = minMaxAgg(indexPattern.fields.byName[fieldName]);
|
||||
|
@ -60,7 +66,12 @@ class RangeControl extends Control {
|
|||
}
|
||||
|
||||
export async function rangeControlFactory(controlParams, kbnApi, useTimeFilter) {
|
||||
const indexPattern = await kbnApi.indexPatterns.get(controlParams.indexPattern);
|
||||
let indexPattern;
|
||||
try {
|
||||
indexPattern = await kbnApi.indexPatterns.get(controlParams.indexPattern);
|
||||
} catch (err) {
|
||||
// ignore not found error and return control so it can be displayed in disabled state.
|
||||
}
|
||||
const unsetValue = { min: 0, max: 1 };
|
||||
return new RangeControl(
|
||||
controlParams,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue