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

Fix _timestamp in doc tables + arrays in advanced settings #3259

Merged
merged 1 commit into from
Mar 25, 2015
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
2 changes: 1 addition & 1 deletion src/kibana/components/index_patterns/_flatten_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ define(function (require) {
}
});

return hit.$$_flattened = _.merge(source, fields, _.pick(hit, self.metaFields));
return hit.$$_flattened = _.merge(source, fields, _.pick(hit, self.metaFields), _.pick(hit.fields, self.metaFields));
};
});
4 changes: 3 additions & 1 deletion src/kibana/plugins/settings/sections/advanced/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
define(function (require) {
var _ = require('lodash');
var configDefaults = require('components/config/defaults');
var getValType = require('plugins/settings/sections/advanced/lib/get_val_type');


require('plugins/settings/sections/advanced/advanced_row');

Expand Down Expand Up @@ -38,7 +40,7 @@ define(function (require) {
var conf = {
name: name,
defVal: def.value,
type: (def.type || _.isArray(val) || typeof val),
type: getValType(def, val),
description: def.description,
value: val,
};
Expand Down
22 changes: 22 additions & 0 deletions src/kibana/plugins/settings/sections/advanced/lib/get_val_type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
define(function (require) {
var _ = require('lodash');

/**
* @param {object} advanced setting definition object
* @param {?} current value of the setting
* @returns {string} the type to use for determining the display and editor
*/
function getValType(def, value) {
if (def.type) {
return def.type;
}

if (_.isArray(value) || _.isArray(def.value)) {
return 'array';
}

return (typeof def.value);
}

return getValType;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
define(function (require) {
var getValType = require('plugins/settings/sections/advanced/lib/get_val_type');
describe('Settings', function () {
describe('Advanced', function () {
describe('getValType(def, val)', function () {
it('should be a function', function () {
expect(getValType).to.be.a(Function);
});

it('should return the explicitly defined type of a setting', function () {
expect(getValType({type: 'string'})).to.be('string');
expect(getValType({type: 'json'})).to.be('json');
expect(getValType({type: 'string', value: 5})).to.be('string');
});

it('should return array if the value is an Array and there is no defined type', function () {
expect(getValType({type: 'string'}, [1, 2, 3])).to.be('string');
expect(getValType({type: 'json', value: [1, 2, 3]})).to.be('json');

expect(getValType({value: 'someString'}, [1, 2, 3])).to.be('array');
expect(getValType({value: [1, 2, 3]}, 'someString')).to.be('array');

});

it('should return the type of the default value if there is no type and it is not an array', function () {
expect(getValType({value: 'someString'})).to.be('string');
expect(getValType({value: 'someString'}, 42)).to.be('string');
});
});
});
});
});