Skip to content

Commit

Permalink
Removes the "Index contains time-based events" checkbox (#11409)
Browse files Browse the repository at this point in the history
* Removing "Index contains time-based events" checkbox

* Rename label

* Adding "No Time Filter field" to time field select list

* Using translation for i18n and consistency with label on create form

* More useful verbiage

* Updating copy

* Adding help block below select for added clarity

* Removing functional tests that used time-based events checkbox

* s/INDEX/INDICES/ to be reflect reality

* Fixing logic error

* Updating functional test to match new behavior

* Use controller property instead of inline expression

* More readable variable name
  • Loading branch information
ycombinator committed Apr 26, 2017
1 parent 70feaa1 commit 7aae24b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="form-group">
<label translate="KIBANA-INDEX_NAME_OR_PATTERN"></label>
<p class="help-block" ng-if="!controller.newIndexPattern.nameIsPattern" translate="KIBANA-WILDCARD_DYNAMIC_INDEX_PATTERNS"></p>
<p class="help-block" ng-if="controller.newIndexPattern.isTimeBased && controller.newIndexPattern.nameIsPattern"><span translate="KIBANA-STATIC_TEXT_IN_DYNAMIC_INDEX_PATTERNS"></span> &mdash;
<p class="help-block" ng-if="controller.newIndexPattern.nameIsPattern"><span translate="KIBANA-STATIC_TEXT_IN_DYNAMIC_INDEX_PATTERNS"></span> &mdash;
<small><a target="_blank" href="http://momentjs.com/docs/#/displaying/format/" translate="KIBANA-DATE_FORMAT_DOCS"></a></small></p>
<input
data-test-subj="createIndexPatternNameInput"
Expand All @@ -41,19 +41,9 @@
</small>
</div>

<div class="form-group time-and-pattern">
<label>
<input
data-test-subj="createIndexPatternIsTimeBasedCheckBox"
ng-model="controller.newIndexPattern.isTimeBased"
type="checkbox">
<span translate="KIBANA-CONTAINS_TIME_BASED_EVENTS"></span>
</label>
</div>

<div class="form-group" ng-if="controller.newIndexPattern.isTimeBased">
<div class="form-group">
<label>
<span translate="KIBANA-TIME_FIELD_NAME"></span>
<span translate="KIBANA-TIME_FILTER_FIELD_NAME"></span>
&nbsp;
<kbn-info info="{{ 'KIBANA-FIELD_FILTER_EVENTS_GLOBAL_TIME' | translate }}"></kbn-info>
&nbsp;
Expand All @@ -63,13 +53,16 @@
</label>
<select
data-test-subj="createIndexPatternTimeFieldSelect"
ng-disabled="controller.fetchFieldsError"
ng-disabled="controller.fetchFieldsError || !controller.indexHasDateFields"
ng-required="!controller.fetchFieldsError"
ng-options="field.name for field in controller.dateFields"
ng-model="controller.newIndexPattern.timeField"
auto-select-if-only-one="controller.dateFields"
class="form-control"
></select>
<p class="help-block" ng-if="!controller.fetchFieldsError && !controller.indexHasDateFields">
The indices which match this index pattern don&rsquo;t contain any time fields.
</p>
</div>

<div class="form-group" ng-if="controller.canExpandIndices()">
Expand All @@ -92,7 +85,7 @@
</div>

<div class="form-group time-and-pattern">
<label ng-if="controller.newIndexPattern.isTimeBased">
<label>
<input
data-test-subj="createIndexPatternNameIsPatternCheckBox"
ng-model="controller.newIndexPattern.nameIsPattern"
Expand All @@ -103,7 +96,7 @@
</label>
</div>

<div class="form-group" ng-if="controller.newIndexPattern.isTimeBased && controller.newIndexPattern.nameIsPattern">
<div class="form-group" ng-if="controller.newIndexPattern.nameIsPattern">
<div class="alert alert-warning">
</p>
<h4 translate="KIBANA-ALERT_INDEX_PATTERN_DEPRECATED"></h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ uiModules.get('apps/management')
// Configure the new index pattern we're going to create.
this.newIndexPattern = {
name: config.get('indexPattern:placeholder'),
isTimeBased: true,
nameIsPattern: false,
expandable: false,
nameInterval: _.find(intervals, { name: 'daily' }),
Expand All @@ -40,9 +39,18 @@ uiModules.get('apps/management')
this.patternErrors = [];
this.fetchFieldsError = $translate.instant('KIBANA-LOADING');

const TIME_FILTER_FIELD_OPTIONS = {
NO_DATE_FIELD_SELECTED: {
name: $translate.instant('KIBANA-NO_DATE_FIELD_SELECTED')
},
NO_DATE_FIELDS_IN_INDICES: {
name: $translate.instant('KIBANA-NO_DATE_FIELDS_IN_INDICES')
}
};

const fetchFieldList = () => {
this.dateFields = this.newIndexPattern.timeField = null;
const useIndexList = this.newIndexPattern.isTimeBased && this.newIndexPattern.nameIsPattern;
const useIndexList = this.newIndexPattern.nameIsPattern;
let fetchFieldsError;
let dateFields;

Expand Down Expand Up @@ -89,7 +97,18 @@ uiModules.get('apps/management')

const updateFieldList = results => {
this.fetchFieldsError = results.fetchFieldsError;
this.dateFields = results.dateFields;
if (this.fetchFieldsError) {
return;
}

this.dateFields = results.dateFields || [];
this.indexHasDateFields = this.dateFields.length > 0;
if (this.indexHasDateFields) {
this.dateFields.unshift(TIME_FILTER_FIELD_OPTIONS.NO_DATE_FIELD_SELECTED);
} else {
this.dateFields.unshift(TIME_FILTER_FIELD_OPTIONS.NO_DATE_FIELDS_IN_INDICES);
}
this.newIndexPattern.timeField = this.dateFields[0];
};

const updateFieldListAndSetTimeField = (results, timeFieldName) => {
Expand All @@ -100,12 +119,13 @@ uiModules.get('apps/management')
}

const matchingTimeField = results.dateFields.find(field => field.name === timeFieldName);
const defaultTimeField = results.dateFields[0];

//assign the field from the results-list
//angular recreates a new timefield instance, each time the list is refreshed.
//This ensures the selected field matches one of the instances in the list.
this.newIndexPattern.timeField = matchingTimeField ? matchingTimeField : defaultTimeField;
if (matchingTimeField) {
this.newIndexPattern.timeField = matchingTimeField;
}
};

const resetIndex = () => {
Expand Down Expand Up @@ -168,7 +188,7 @@ uiModules.get('apps/management')
this.canExpandIndices = () => {
// to maximize performance in the digest cycle, move from the least
// expensive operation to most
return this.newIndexPattern.isTimeBased && !this.newIndexPattern.nameIsPattern && _.includes(this.newIndexPattern.name, '*');
return !this.newIndexPattern.nameIsPattern && _.includes(this.newIndexPattern.name, '*');
};

this.refreshFieldList = () => {
Expand All @@ -184,14 +204,15 @@ uiModules.get('apps/management')

this.createIndexPattern = () => {
const id = this.newIndexPattern.name;
const timeFieldName =
this.newIndexPattern.isTimeBased
? this.newIndexPattern.timeField.name
: undefined;
let timeFieldName;
if ((this.newIndexPattern.timeField !== TIME_FILTER_FIELD_OPTIONS.NO_DATE_FIELD_SELECTED)
&& (this.newIndexPattern.timeField !== TIME_FILTER_FIELD_OPTIONS.NO_DATE_FIELDS_IN_INDICES)) {
timeFieldName = this.newIndexPattern.timeField.name;
}

// Only event-time-based index patterns set an intervalName.
const intervalName =
this.newIndexPattern.isTimeBased && this.newIndexPattern.nameIsPattern
this.newIndexPattern.nameIsPattern
? this.newIndexPattern.nameInterval.name
: undefined;

Expand Down Expand Up @@ -228,11 +249,9 @@ uiModules.get('apps/management')
};

$scope.$watchMulti([
'controller.newIndexPattern.isTimeBased',
'controller.newIndexPattern.nameIsPattern',
'controller.newIndexPattern.nameInterval.name'
], (newVal, oldVal) => {
const isTimeBased = newVal[0];
const nameIsPattern = newVal[1];
const newDefault = getDefaultPatternForInterval(newVal[2]);
const oldDefault = getDefaultPatternForInterval(oldVal[2]);
Expand All @@ -241,10 +260,6 @@ uiModules.get('apps/management')
this.newIndexPattern.name = newDefault;
}

if (!isTimeBased) {
this.newIndexPattern.nameIsPattern = false;
}

if (!nameIsPattern) {
delete this.newIndexPattern.nameInterval;
delete this.newIndexPattern.timeField;
Expand Down Expand Up @@ -301,7 +316,6 @@ uiModules.get('apps/management')
});

$scope.$watchMulti([
'controller.newIndexPattern.isTimeBased',
'controller.sampleCount'
], () => {
this.refreshFieldList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<p ng-if="indexPattern.timeFieldName" class="kuiText kuiVerticalRhythm">
<span class="label label-success">
<i class="fa fa-clock-o"></i> Configured time field: {{indexPattern.timeFieldName}}
<i class="fa fa-clock-o"></i><span translate="KIBANA-TIME_FILTER_FIELD_NAME"></span>: {{indexPattern.timeFieldName}}
</span>
</p>

Expand Down
5 changes: 3 additions & 2 deletions src/core_plugins/kibana/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"UI-WELCOME_ERROR": "Kibana did not load properly. Check the server output for more information.",
"KIBANA-CONFIGURE_INDEX_PATTERN": "Configure an index pattern",
"KIBANA-MUST_CONFIGURE_INDEX_PATTERN": "In order to use Kibana you must configure at least one index pattern. Index patterns are used to identify the Elasticsearch index to run search and analytics against. They are also used to configure fields.",
"KIBANA-CONTAINS_TIME_BASED_EVENTS": "Index contains time-based events",
"KIBANA-INDEX_NAME_CREATED_BY_EVENT_TIMES": "Use event times to create index names ",
"KIBANA-DEPRECATED": "[DEPRECATED]",
"KIBANA-ALERT_INDEX_PATTERN_DEPRECATED": "Time-interval based index patterns are deprecated!",
Expand All @@ -30,7 +29,9 @@
"KIBANA-EXISTING_MATCH_PERCENT": "Pattern matches {{indexExistingMatchPercent}} of existing indices and aliases",
"KIBANA-NON_MATCHING_INDICES_AND_ALIASES": "Indices and aliases that were found, but did not match the pattern:",
"KIBANA-MORE": "more",
"KIBANA-TIME_FIELD_NAME": "Time-field name",
"KIBANA-TIME_FILTER_FIELD_NAME": "Time Filter field name",
"KIBANA-NO_DATE_FIELD_SELECTED": "None selected",
"KIBANA-NO_DATE_FIELDS_IN_INDICES": "None available",
"KIBANA-REFRESH_FIELDS": "refresh fields",
"KIBANA-INVALID_INDEX_PATTERN": "Invalid index name pattern.",
"KIBANA-DATE_FORMAT_DOCS": "Date Format Documentation",
Expand Down
24 changes: 0 additions & 24 deletions test/functional/apps/management/_creation_form_changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,6 @@ export default function ({ getService, getPageObjects }) {
});
});

it('should hide time-based index pattern when time-based option is unchecked', function () {
const self = this;
return PageObjects.settings.getTimeBasedEventsCheckbox()
.then(function (selected) {
// uncheck the 'time-based events' checkbox
return selected.click();
})
// try to find the checkbox (this shouldn fail)
.then(function () {
return PageObjects.settings.getTimeBasedIndexPatternCheckbox();
})
.then(function () {
PageObjects.common.saveScreenshot('Settings-indices-hide-time-based-index-pattern');
// we expect the promise above to fail
const handler = PageObjects.common.createErrorHandler(self);
const msg = 'Found time based index pattern checkbox';
handler(msg);
})
.catch(function () {
// we expect this failure since checkbox should be hidden
return;
});
});

it('should enable creation after selecting time field', function () {
// select a time field and check that Create button is enabled
return PageObjects.settings.selectTimeFieldOption('@timestamp')
Expand Down
12 changes: 2 additions & 10 deletions test/functional/apps/management/_initial_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ export default function ({ getService, getPageObjects }) {
});
});

it('should load with time pattern checked', function () {
return PageObjects.settings.getTimeBasedEventsCheckbox().isSelected()
.then(function (selected) {
PageObjects.common.saveScreenshot('Settings-initial-state');
expect(selected).to.be.ok();
});
});

it('should load with name pattern unchecked', function () {
return PageObjects.settings.getTimeBasedIndexPatternCheckbox().isSelected()
.then(function (selected) {
Expand All @@ -49,10 +41,10 @@ export default function ({ getService, getPageObjects }) {
});
});

it('should not be enable creation', function () {
it('should enable creation', function () {
return PageObjects.settings.getCreateIndexPatternButton().isEnabled()
.then(function (enabled) {
expect(enabled).to.not.be.ok();
expect(enabled).to.be.ok();
});
});
});
Expand Down
4 changes: 0 additions & 4 deletions test/functional/page_objects/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export function SettingsPageProvider({ getService, getPageObjects }) {
await PageObjects.common.navigateToApp('settings');
}

getTimeBasedEventsCheckbox() {
return testSubjects.find('createIndexPatternIsTimeBasedCheckBox');
}

getTimeBasedIndexPatternCheckbox() {
// fail faster since we're sometimes checking that it doesn't exist
return testSubjects.find('createIndexPatternNameIsPatternCheckBox');
Expand Down

0 comments on commit 7aae24b

Please sign in to comment.