Skip to content

Commit

Permalink
Use ui-select for index pattern selector (elastic#10144)
Browse files Browse the repository at this point in the history
* Replace index pattern selector with ui-select

* Show index patterns in alphabetical order

* Add highlighting to select
  • Loading branch information
lukasolson committed Mar 31, 2017
1 parent 5babfee commit 5620116
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
"tinygradient": "0.3.0",
"trunc-html": "1.0.2",
"trunc-text": "1.0.2",
"ui-select": "0.19.6",
"url-loader": "0.5.6",
"validate-npm-package-name": "2.2.2",
"vision": "4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ describe('discover field chooser directives', function () {

describe('Index list', function () {
it('should be in alphabetical order', function (done) {
expect($elem.find('li.sidebar-item-title').text()).to.be('abc');
$elem.find('.ui-select-toggle').click();
expect($elem.find('[role=option]').text().replace(/\W+/g, '')).to.be('abc');
done();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<div class="sidebar-list">
<div ng-show="indexPatternList.length > 1">
<div class="index-pattern" ng-click="showIndexPatternSelection = !showIndexPatternSelection"
ng-class="{active: showIndexPatternSelection === true}">
<div css-truncate title="{{indexPattern.id}}">{{indexPattern.id}}</div>
<i ng-hide="showIndexPatternSelection" class="fa fa-caret-down"></i>
<i ng-show="showIndexPatternSelection" class="fa fa-caret-up"></i>
</div>
<div ng-show="showIndexPatternSelection">
<ul class="list-unstyled sidebar-item index-pattern-selection">
<li css-truncate class="sidebar-item-title" title="{{id}}" ng-repeat="id in indexPatternList | orderBy" ng-show="indexPattern.id != id" ng-click="setIndexPattern(id)">{{id}}</li>
</ul>
</div>
<ui-select
class="index-pattern-selection"
ng-model="selectedIndexPattern"
on-select="setIndexPattern($item)"
ng-init="selectedIndexPattern = indexPattern.id"
>
<ui-select-match>
{{$select.selected}}
</ui-select-match>
<ui-select-choices repeat="id in indexPatternList | filter:$select.search | orderBy">
<div ng-bind-html="id | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
</div>
<div ng-hide="indexPatternList.length > 1">
<div class="index-pattern">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'ui/directives/css_truncate';
import 'ui/directives/field_name';
import 'ui/filters/unique';
import 'plugins/kibana/discover/components/field_chooser/discover_field';
import 'angular-ui-select';
import _ from 'lodash';
import $ from 'jquery';
import rison from 'rison-node';
Expand Down
1 change: 0 additions & 1 deletion src/core_plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<div class="col-md-2 sidebar-container collapsible-sidebar">
<disc-field-chooser
columns="state.columns"
refresh="refreshFieldList"
hits="rows"
field-counts="fieldCounts"
filter="filterQuery"
Expand Down
7 changes: 2 additions & 5 deletions src/ui/public/styles/sidebar.less
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,8 @@
}
}

.index-pattern-selection .sidebar-item-title {
background-color: @sidebar-index-pattern-selection-bg;
&:hover {
background-color: @sidebar-index-pattern-selection-bg-hover;
}
.index-pattern-selection .ui-select-toggle {
border-radius: 0;
}

}
7 changes: 7 additions & 0 deletions webpackShims/angular-ui-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require('jquery');
require('angular');
require('angular-sanitize');
require('ui-select/dist/select');
require('ui-select/dist/select.css');

require('ui/modules').get('kibana', ['ui.select', 'ngSanitize']);

0 comments on commit 5620116

Please sign in to comment.