Skip to content

Commit 95b5c8a

Browse files
maciaszczykmfloreks
authored andcommitted
Imrove global search (#2431)
1 parent 40ca85e commit 95b5c8a

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

Diff for: src/app/backend/resource/container/logs_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func TestGetLogs(t *testing.T) {
331331
LogLines: logs.LogLines{logs.LogLine{
332332
Timestamp: "0",
333333
Content: "an error message from api server",
334-
},},
334+
}},
335335
Selection: logs.Selection{
336336
ReferencePoint: logs.LogLineId{
337337
LogTimestamp: "0",

Diff for: src/app/frontend/chrome/search/component.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,33 @@ import {stateName} from '../../search/state';
2020
export class SearchController {
2121
/**
2222
* @param {!ui.router.$state} $state
23+
* @param {!kdUiRouter.$transitions} $transitions
2324
* @ngInject
2425
*/
25-
constructor($state) {
26+
constructor($state, $transitions) {
2627
/** @private {!ui.router.$state} */
2728
this.state_ = $state;
2829

30+
/** @private {!kdUiRouter.$transitions} */
31+
this.transitions_ = $transitions;
32+
33+
/** @export {string} */
34+
this.query = '';
35+
}
36+
37+
/**
38+
* Register state change listener to empty search bar with every state change.
39+
*/
40+
$onInit() {
41+
this.transitions_.onStart({}, () => {
42+
this.clear();
43+
});
44+
}
45+
46+
/**
47+
* @export
48+
*/
49+
clear() {
2950
this.query = '';
3051
}
3152

Diff for: src/app/frontend/chrome/search/search.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@
1616

1717
<form class="kd-search"
1818
ng-submit="$ctrl.submit()">
19-
<md-icon class="kd-search-icon">search</md-icon>
19+
<md-icon class="kd-search-icon"
20+
type="submit">search</md-icon>
2021
<input type="search"
2122
placeholder="Search"
2223
ng-model="$ctrl.query"
24+
ui-keydown="{esc: '$ctrl.clear()'}"
2325
required>
26+
<md-icon class="kd-search-icon"
27+
ng-click="$ctrl.clear()"
28+
ng-show="$ctrl.query">
29+
close
30+
</md-icon>
2431
</form>

0 commit comments

Comments
 (0)