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

Paginated selectable list directive #6550

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9c7c4d9
init commit
stormpython Mar 15, 2016
930a0eb
[startup] Write process pid file earlier as per #4680
bevacqua Mar 15, 2016
1aab5e0
troubleshooting
stormpython Mar 15, 2016
8455d56
almost ready
stormpython Mar 16, 2016
3aa06ab
removing commented code
stormpython Mar 16, 2016
c72c440
add support for a configPrefix setting
spalger Mar 16, 2016
c852844
remove configPrefix from test_bundle
w33ble Mar 16, 2016
5a488f4
restore the key validation
w33ble Mar 16, 2016
8790a79
add test for dot-notated config keys
w33ble Mar 16, 2016
041c2f6
adding back sort functionality to saved object and paginated selectab…
stormpython Mar 17, 2016
6939960
fixing issue with list not sorting
stormpython Mar 17, 2016
27c6f17
refactoring html and css
stormpython Mar 17, 2016
ec68aa0
Merge branch 'feature/design' into selectable_list_directive
stormpython Mar 17, 2016
f7cc5f1
empty schema test is not async
w33ble Mar 17, 2016
765185f
remove unused toPath
w33ble Mar 17, 2016
96e5937
actually check object keys in schema
w33ble Mar 17, 2016
41e3081
add some more tests around invalid config paths
w33ble Mar 17, 2016
1ff22b1
refactoring to allow for array of objects, removing useless css styles
stormpython Mar 17, 2016
242fe85
Merge branch 'feature/design' into selectable_list_directive
stormpython Mar 17, 2016
420c1bc
adding tests
stormpython Mar 18, 2016
2152047
correctly use Joi.object().keys(), finally
w33ble Mar 18, 2016
00f5527
Merge branch 'feature/design' into selectable_list_directive
stormpython Mar 18, 2016
b968b0b
adding more tests, refactoring directive
stormpython Mar 19, 2016
a8c1305
short url: ensure absolute path isn't persisted
jbudz Mar 18, 2016
2a71673
[short url] use url.format when creating /goto link
jbudz Mar 21, 2016
690a140
[short url] Add tests for query strings, no hashes
jbudz Mar 21, 2016
49d297f
[short url] Cleanup
jbudz Mar 21, 2016
a612a0e
[short url] Add server tests
jbudz Mar 21, 2016
1dc9a18
Merge branch 'feature/design' of github.com:elastic/kibana into selec…
stormpython Mar 22, 2016
d66df55
Merge pull request #6581 from jbudz/issues/6127
epixa Mar 22, 2016
149cc2e
fixing issue with background hover on paginated-selectable-list and s…
stormpython Mar 22, 2016
cf78a36
Merge pull request #6239 from elastic/feature/design
Mar 22, 2016
08bae15
Merge branch 'master' into selectable_list_directive
stormpython Mar 22, 2016
b126e35
move unset into its own module, include tests
w33ble Mar 22, 2016
115128b
use external unset module
w33ble Mar 22, 2016
2ebd94d
use unset instead of delete, fixes schema bug
w33ble Mar 22, 2016
08e9202
[npm] update babel
spalger Mar 22, 2016
12fe251
Merge pull request #6604 from spalger/update/babel/master
spalger Mar 22, 2016
7bbfa22
Merge pull request #6539 from bevacqua/feature/pid-file-earlier
spalger Mar 23, 2016
4408069
Merge pull request #6554 from w33ble/implement/pluginConfigPrefix
w33ble Mar 23, 2016
f458af2
Merge branch 'master' into selectable_list_directive
stormpython Mar 23, 2016
62316aa
Remove -reskin from 5.0 snapshot version
epixa Mar 23, 2016
66a8c7f
Merge branch 'master' into selectable_list_directive
stormpython Mar 23, 2016
2992a66
adding label filter for input on saved object filter placeholder
stormpython Mar 23, 2016
d90baae
removing div and adding display block to anchor tag to allow the enti…
stormpython Mar 23, 2016
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": false,
"version": "5.0.0-reskin-snapshot",
"version": "5.0.0-snapshot",
"build": {
"number": 8467,
"sha": "6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9"
Expand Down Expand Up @@ -81,10 +81,10 @@
"ansicolors": "0.3.2",
"autoprefixer": "5.1.1",
"autoprefixer-loader": "2.0.0",
"babel": "5.8.23",
"babel-core": "5.8.23",
"babel": "5.8.38",
"babel-core": "5.8.38",
"babel-loader": "5.3.2",
"babel-runtime": "5.8.20",
"babel-runtime": "5.8.38",
"bluebird": "2.9.34",
"boom": "2.8.0",
"bootstrap": "3.3.6",
Expand Down
13 changes: 8 additions & 5 deletions src/plugins/kibana/public/visualize/styles/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
padding: 0;
display: flex;

div.wizard-small {
flex: 2;
}

div.wizard-large {
flex: 3;
}

.wizard-column {
flex: 1;
display: flex;
Expand Down Expand Up @@ -45,11 +53,6 @@

.list-group {
margin-bottom: 0;

.list-group-item {
border-radius: 0;
border: none;
}
}

.striped {
Expand Down
23 changes: 9 additions & 14 deletions src/plugins/kibana/public/visualize/wizard/step_2.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<bread-crumbs></bread-crumbs>
<div class="wizard">
<div class="wizard-column">
<h3>From a New Search</h3>
<!-- Index patterns -->
<div class="wizard-row">
<div class="panel panel-default">
<div class="panel-heading">Index Patterns</div>
</div>
<ul class="striped list-group">
<li class="list-group-item" ng-repeat="pattern in indexPattern.list | orderBy: 'toString()'">
<a class="index-link" kbn-href="{{ makeUrl(pattern) }}">{{pattern}}</a>
</li>
</ul>
</div>
<div class="wizard-small wizard-column">
<h3>From a New Search, Select Index</h3>
<paginated-selectable-list
per-page="20"
list="indexPattern.list"
user-make-url="makeUrl"
class="wizard-row">
</paginated-selectable-list>
</div>
<div class="wizard-column">
<div class="wizard-large wizard-column">
<h3>Or, From a Saved Search</h3>
<!-- Saved searches -->
<saved-object-finder
Expand Down
1 change: 1 addition & 0 deletions src/plugins/kibana/public/visualize/wizard/wizard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from 'lodash';
import 'plugins/kibana/visualize/saved_visualizations/saved_visualizations';
import 'ui/directives/saved_object_finder';
import 'ui/directives/paginated_selectable_list';
import 'plugins/kibana/discover/saved_searches/saved_searches';
import routes from 'ui/routes';
import RegistryVisTypesProvider from 'ui/registry/vis_types';
Expand Down
35 changes: 33 additions & 2 deletions src/server/config/__tests__/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,36 @@ describe('lib/config/config', function () {

describe('constructor', function () {

it('should not allow any config if the schema is not passed', function (done) {
it('should not allow any config if the schema is not passed', function () {
var config = new Config();
var run = function () {
config.set('something.enable', true);
};
expect(run).to.throwException();
done();
});

it('should allow keys in the schema', function () {
var config = new Config(schema);
var run = function () {
config.set('test.client.host', 'http://0.0.0.0');
};
expect(run).to.not.throwException();
});

it('should not allow keys not in the schema', function () {
var config = new Config(schema);
var run = function () {
config.set('paramNotDefinedInTheSchema', true);
};
expect(run).to.throwException();
});

it('should not allow child keys not in the schema', function () {
var config = new Config(schema);
var run = function () {
config.set('test.client.paramNotDefinedInTheSchema', true);
};
expect(run).to.throwException();
});

it('should set defaults', function () {
Expand Down Expand Up @@ -198,6 +221,14 @@ describe('lib/config/config', function () {
expect(config.get('myTest.test')).to.be(true);
});

it('should allow you to extend the schema with a prefix', function () {
var newSchema = Joi.object({ test: Joi.boolean().default(true) }).default();
config.extendSchema('prefix.myTest', newSchema);
expect(config.get('prefix')).to.eql({ myTest: { test: true }});
expect(config.get('prefix.myTest')).to.eql({ test: true });
expect(config.get('prefix.myTest.test')).to.be(true);
});

it('should NOT allow you to extend the schema if somethign else is there', function () {
var newSchema = Joi.object({ test: Joi.boolean().default(true) }).default();
var run = function () {
Expand Down
83 changes: 83 additions & 0 deletions src/server/config/__tests__/unset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import unset from '../unset';
import expect from 'expect.js';

describe('unset(obj, key)', function () {
describe('invalid input', function () {
it('should do nothing if not given an object', function () {
const obj = 'hello';
unset(obj, 'e');
expect(obj).to.equal('hello');
});

it('should do nothing if not given a key', function () {
const obj = { one: 1 };
unset(obj);
expect(obj).to.eql({ one: 1 });
});

it('should do nothing if given an empty string as a key', function () {
const obj = { one: 1 };
unset(obj, '');
expect(obj).to.eql({ one: 1 });
});
});

describe('shallow removal', function () {
let obj;

beforeEach(function () {
obj = { one: 1, two: 2, deep: { three: 3, four: 4 } };
});

it('should remove the param using a string key', function () {
unset(obj, 'two');
expect(obj).to.eql({ one: 1, deep: { three: 3, four: 4 } });
});

it('should remove the param using an array key', function () {
unset(obj, ['two']);
expect(obj).to.eql({ one: 1, deep: { three: 3, four: 4 } });
});
});

describe('deep removal', function () {
let obj;

beforeEach(function () {
obj = { one: 1, two: 2, deep: { three: 3, four: 4 } };
});

it('should remove the param using a string key', function () {
unset(obj, 'deep.three');
expect(obj).to.eql({ one: 1, two: 2, deep: { four: 4 } });
});

it('should remove the param using an array key', function () {
unset(obj, ['deep', 'three']);
expect(obj).to.eql({ one: 1, two: 2, deep: { four: 4 } });
});
});

describe('recursive removal', function () {
it('should clear object if only value is removed', function () {
const obj = { one: { two: { three: 3 } } };
unset(obj, 'one.two.three');
expect(obj).to.eql({});
});

it('should clear object if no props are left', function () {
const obj = { one: { two: { three: 3 } } };
unset(obj, 'one.two');
expect(obj).to.eql({});
});

it('should remove deep property, then clear the object', function () {
const obj = { one: { two: { three: 3, four: 4 } } };
unset(obj, 'one.two.three');
expect(obj).to.eql({ one: { two: { four: 4 } } });

unset(obj, 'one.two.four');
expect(obj).to.eql({});
});
});
});
45 changes: 29 additions & 16 deletions src/server/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import Promise from 'bluebird';
import Joi from 'joi';
import _ from 'lodash';
import override from './override';
import unset from './unset';
import createDefaultSchema from './schema';
import pkg from '../../utils/package_json';
import clone from './deep_clone_with_buffers';
import { zipObject } from 'lodash';

const schema = Symbol('Joi Schema');
const schemaKeys = Symbol('Schema Extensions');
const schemaExts = Symbol('Schema Extensions');
const vals = Symbol('config values');
const pendingSets = Symbol('Pending Settings');

Expand All @@ -18,16 +18,15 @@ module.exports = class Config {
}

constructor(initialSchema, initialSettings) {
this[schemaKeys] = new Map();

this[schemaExts] = Object.create(null);
this[vals] = Object.create(null);
this[pendingSets] = new Map(_.pairs(clone(initialSettings || {})));
this[pendingSets] = _.merge(Object.create(null), initialSettings || {});

if (initialSchema) this.extendSchema(initialSchema);
}

getPendingSets() {
return this[pendingSets];
return new Map(_.pairs(this[pendingSets]));
}

extendSchema(key, extension) {
Expand All @@ -41,27 +40,27 @@ module.exports = class Config {
throw new Error(`Config schema already has key: ${key}`);
}

this[schemaKeys].set(key, extension);
_.set(this[schemaExts], key, extension);
this[schema] = null;

let initialVals = this[pendingSets].get(key);
let initialVals = _.get(this[pendingSets], key);
if (initialVals) {
this.set(key, initialVals);
this[pendingSets].delete(key);
unset(this[pendingSets], key);
} else {
this._commit(this[vals]);
}
}

removeSchema(key) {
if (!this[schemaKeys].has(key)) {
if (!_.has(this[schemaExts], key)) {
throw new TypeError(`Unknown schema key: ${key}`);
}

this[schema] = null;
this[schemaKeys].delete(key);
this[pendingSets].delete(key);
delete this[vals][key];
unset(this[schemaExts], key);
unset(this[pendingSets], key);
unset(this[vals], key);
}

resetTo(obj) {
Expand Down Expand Up @@ -138,7 +137,7 @@ module.exports = class Config {
// Catch the partial paths
if (path.join('.') === key) return true;
// Only go deep on inner objects with children
if (schema._inner.children.length) {
if (_.size(schema._inner.children)) {
for (let i = 0; i < schema._inner.children.length; i++) {
let child = schema._inner.children[i];
// If the child is an object recurse through it's children and return
Expand All @@ -163,8 +162,22 @@ module.exports = class Config {

getSchema() {
if (!this[schema]) {
let objKeys = zipObject([...this[schemaKeys]]);
this[schema] = Joi.object().keys(objKeys).default();
this[schema] = (function convertToSchema(children) {
let schema = Joi.object().keys({}).default();

for (const key of Object.keys(children)) {
const child = children[key];
const childSchema = _.isPlainObject(child) ? convertToSchema(child) : child;

if (!childSchema || !childSchema.isJoi) {
throw new TypeError('Unable to convert configuration definition value to Joi schema: ' + childSchema);
}

schema = schema.keys({ [key]: childSchema });
}

return schema;
}(this[schemaExts]));
}

return this[schema];
Expand Down
26 changes: 26 additions & 0 deletions src/server/config/unset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import _ from 'lodash';
import toPath from 'lodash/internal/toPath';

module.exports = function unset(object, rawPath) {
if (!object) return;
const path = toPath(rawPath);

switch (path.length) {
case 0:
return;

case 1:
delete object[rawPath];
break;

default:
const leaf = path.pop();
const parentPath = path.slice();
const parent = _.get(object, parentPath);
unset(parent, leaf);
if (!_.size(parent)) {
unset(object, parentPath);
}
break;
}
};
Loading