From 76f833fc9ab0bc2e98cfe8777c3f467a0068f77f Mon Sep 17 00:00:00 2001 From: Spencer Date: Thu, 25 May 2017 17:20:55 -0700 Subject: [PATCH] [indexPatterns/create] refactor time field options (#11996) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [indexPatterns/create] timeFields -> timeFieldOptions In #11409 we added two new possible options to the "Time Filter field name" drop down. These options display a message that "there are no time fields" or "I don't want to use the time filter". These new options were added to the `controller.timeFields` array, which is where the other options were, but they don't actually represent time fields. This change updates `controller.timeFields` to instead be a list of options, specifically created to populate the select box in the view. They are now stored at `controller.timeFieldOptions` and each option has a `display` property (which will be rendered in the view) and optionally a `fieldName` property. The selected option, `controller.formValues.timeFieldOption` is checked for a `fieldName` property when the Index Pattern is created. * [indexPatterns/create] populate `this.timeFieldOptions` * [indexPatterns/create] unify fetching and errors for timeFieldOptions * [indexPatterns/create] refreshFieldList() -> refreshTimeFieldOptions() * [indexPatterns/create] unify "No time fields available" messages * [indexPatterns/create] disable the timeField select when loading * [indexPatterns/create] only require a time field is there are options Doing this prevents the time field from rendering as invalid when there is no matching index pattern (which has it's own error display) and when the fields are loading * [indexPatterns/create] isolate side-effects * [indexPatterns/create] let refreshTimeFieldOptions() control model * [indexPatterns/create] attempt to make default field selection clearer * [indexPatterns/create] explain why we set timeFieldOption * [indexPatterns/create] make timeFieldName `undefined` when not set * [indexPatterns/create] Don't pass two args to .then() unless needed * 💅 --- .../create_index_pattern.html | 22 +- .../create_index_pattern.js | 207 +++++++++--------- .../pick_create_button_text.js | 4 +- src/core_plugins/kibana/translations/en.json | 1 - 4 files changed, 114 insertions(+), 120 deletions(-) diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern/create_index_pattern.html b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern/create_index_pattern.html index 53c9c61d4f1b2..d153d4a17803f 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern/create_index_pattern.html +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern/create_index_pattern.html @@ -47,12 +47,12 @@

- {{controller.fetchFieldsError}} + {{controller.timeFieldOptionsError}}

@@ -105,7 +105,7 @@ @@ -115,17 +115,11 @@ - -

@@ -347,7 +341,7 @@