Skip to content

Commit 46193dd

Browse files
Merge branch 'master' into dev/import-dashboard-url-generator-directly
2 parents 834c38c + faaa127 commit 46193dd

File tree

67 files changed

+861
-220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+861
-220
lines changed

.backportrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
"targetPRLabels": ["backport"],
2727
"branchLabelMapping": {
28-
"^v7.8.0$": "7.x",
28+
"^v7.9.0$": "7.x",
2929
"^v(\\d+).(\\d+).\\d+$": "$1.$2"
3030
}
3131
}

docs/visualize/tsvb.asciidoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,17 @@ Edit the source for the Markdown visualization.
122122
. To insert the mustache template variable into the editor, click the variable name.
123123
+
124124
The http://mustache.github.io/mustache.5.html[mustache syntax] uses the Handlebar.js processor, which is an extended version of the Mustache template language.
125+
126+
[float]
127+
[[tsvb-style-markdown]]
128+
==== Style Markdown text
129+
130+
Style your Markdown visualization using http://lesscss.org/features/[less syntax].
131+
132+
. Select *Markdown*.
133+
134+
. Select *Panel options*.
135+
136+
. Enter styling rules in *Custom CSS* section
137+
+
138+
Less in TSVB does not support custom plugins or inline JavaScript.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
"leaflet-responsive-popup": "0.6.4",
211211
"leaflet-vega": "^0.8.6",
212212
"leaflet.heat": "0.2.0",
213-
"less": "^2.7.3",
213+
"less": "npm:@elastic/less@2.7.3-kibana",
214214
"less-loader": "5.0.0",
215215
"lodash": "npm:@elastic/lodash@3.10.1-kibana4",
216216
"lodash.clonedeep": "^4.5.0",

src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/tabs/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,21 @@ export function getTabs(
9696
tabs.push({
9797
name: getTitle('indexed', filteredCount, totalCount),
9898
id: TAB_INDEXED_FIELDS,
99+
'data-test-subj': 'tab-indexedFields',
99100
});
100101

101102
if (indexPatternListProvider.areScriptedFieldsEnabled(indexPattern)) {
102103
tabs.push({
103104
name: getTitle('scripted', filteredCount, totalCount),
104105
id: TAB_SCRIPTED_FIELDS,
106+
'data-test-subj': 'tab-scriptedFields',
105107
});
106108
}
107109

108110
tabs.push({
109111
name: getTitle('sourceFilters', filteredCount, totalCount),
110112
id: TAB_SOURCE_FILTERS,
113+
'data-test-subj': 'tab-sourceFilters',
111114
});
112115

113116
return tabs;

src/legacy/ui/public/new_platform/new_platform.test.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jest.mock('history');
2222
import { setRootControllerMock, historyMock } from './new_platform.test.mocks';
2323
import { legacyAppRegister, __reset__, __setup__, __start__ } from './new_platform';
2424
import { coreMock } from '../../../../core/public/mocks';
25+
import { AppMount } from '../../../../core/public';
2526

2627
describe('ui/new_platform', () => {
2728
describe('legacyAppRegister', () => {
@@ -33,7 +34,7 @@ describe('ui/new_platform', () => {
3334

3435
const registerApp = () => {
3536
const unmountMock = jest.fn();
36-
const mountMock = jest.fn(() => unmountMock);
37+
const mountMock = jest.fn<ReturnType<AppMount>, Parameters<AppMount>>(() => unmountMock);
3738
legacyAppRegister({
3839
id: 'test',
3940
title: 'Test',
@@ -62,13 +63,25 @@ describe('ui/new_platform', () => {
6263

6364
controller(scopeMock, elementMock);
6465
expect(mountMock).toHaveBeenCalledWith({
65-
element: elementMock[0],
66+
element: expect.any(HTMLElement),
6667
appBasePath: '/test/base/path/app/test',
6768
onAppLeave: expect.any(Function),
6869
history: historyMock,
6970
});
7071
});
7172

73+
test('app is mounted in new div inside containing element', () => {
74+
const { mountMock } = registerApp();
75+
const controller = setRootControllerMock.mock.calls[0][1];
76+
const scopeMock = { $on: jest.fn() };
77+
const elementMock = [document.createElement('div')];
78+
79+
controller(scopeMock, elementMock);
80+
81+
const { element } = mountMock.mock.calls[0][0];
82+
expect(element.parentElement).toEqual(elementMock[0]);
83+
});
84+
7285
test('controller calls deprecated context app.mount when invoked', () => {
7386
const unmountMock = jest.fn();
7487
// Two arguments changes how this is called.
@@ -84,7 +97,7 @@ describe('ui/new_platform', () => {
8497

8598
controller(scopeMock, elementMock);
8699
expect(mountMock).toHaveBeenCalledWith(expect.any(Object), {
87-
element: elementMock[0],
100+
element: expect.any(HTMLElement),
88101
appBasePath: '/test/base/path/app/test',
89102
onAppLeave: expect.any(Function),
90103
history: historyMock,

src/legacy/ui/public/new_platform/new_platform.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ export const legacyAppRegister = (app: App<any>) => {
176176
legacyAppRegistered = true;
177177

178178
require('ui/chrome').setRootController(app.id, ($scope: IScope, $element: JQLite) => {
179-
const element = $element[0];
179+
const element = document.createElement('div');
180+
$element[0].appendChild(element);
180181

181182
// Root controller cannot return a Promise so use an internal async function and call it immediately
182183
(async () => {

src/plugins/discover/public/application/_discover.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,7 @@ discover-app {
3838
}
3939

4040
.dscResultCount {
41-
text-align: center;
4241
padding-top: $euiSizeXS;
43-
padding-left: $euiSizeM;
44-
45-
.dscResultHits {
46-
padding-left: $euiSizeXS;
47-
}
48-
49-
> .kuiLink {
50-
padding-left: $euiSizeM;
51-
}
5242
}
5343

5444
.dscTimechart__header {

src/plugins/discover/public/application/angular/discover.html

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,12 @@ <h1 class="euiScreenReaderOnly">{{screenTitle}}</h1>
8989
</span>
9090
</button>
9191

92-
<div class="dscResultCount">
93-
<strong data-test-subj="discoverQueryHits">{{(hits || 0) | number:0}}</strong>
94-
<span
95-
class="dscResultHits"
96-
i18n-id="discover.hitsPluralTitle"
97-
i18n-default-message="{hits, plural, one {hit} other {hits}}"
98-
i18n-values="{ hits }"
99-
></span>
100-
<button
101-
ng-if="opts.savedSearch.id"
102-
class="kuiLink"
103-
type="button"
104-
id="reload_saved_search"
105-
ng-click="resetQuery()"
106-
>
107-
{{::'discover.reloadSavedSearchButton' | i18n: {defaultMessage: 'Reset search'} }}
108-
</button>
109-
</div>
92+
<hits-counter
93+
hits="hits || 0"
94+
show-reset-button="opts.savedSearch.id"
95+
on-reset-query="resetQuery"
96+
>
97+
</hits-counter>
11098

11199
<section
112100
aria-label="{{::'discover.histogramOfFoundDocumentsAriaLabel' | i18n: {defaultMessage: 'Histogram of found documents'} }}"

src/plugins/discover/public/application/angular/doc_table/components/_table_header.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.kbnDocTableHeader {
2+
white-space: nowrap;
3+
}
14
.kbnDocTableHeader button {
25
margin-left: $euiSizeXS;
36
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
import React from 'react';
20+
import { mountWithIntl } from 'test_utils/enzyme_helpers';
21+
import { ReactWrapper } from 'enzyme';
22+
import { HitsCounter, HitsCounterProps } from './hits_counter';
23+
// @ts-ignore
24+
import { findTestSubject } from '@elastic/eui/lib/test';
25+
26+
describe('hits counter', function() {
27+
let props: HitsCounterProps;
28+
let component: ReactWrapper<HitsCounterProps>;
29+
30+
beforeAll(() => {
31+
props = {
32+
onResetQuery: jest.fn(),
33+
showResetButton: true,
34+
hits: 2,
35+
};
36+
});
37+
38+
it('HitsCounter renders a button by providing the showResetButton property', () => {
39+
component = mountWithIntl(<HitsCounter {...props} />);
40+
expect(findTestSubject(component, 'resetSavedSearch').length).toBe(1);
41+
});
42+
43+
it('HitsCounter not renders a button when the showResetButton property is false', () => {
44+
component = mountWithIntl(
45+
<HitsCounter hits={2} showResetButton={false} onResetQuery={jest.fn()} />
46+
);
47+
expect(findTestSubject(component, 'resetSavedSearch').length).toBe(0);
48+
});
49+
50+
it('expect to render the number of hits', function() {
51+
component = mountWithIntl(<HitsCounter {...props} />);
52+
const hits = findTestSubject(component, 'discoverQueryHits');
53+
expect(hits.text()).toBe('2');
54+
});
55+
56+
it('expect to render 1,899 hits if 1899 hits given', function() {
57+
component = mountWithIntl(
58+
<HitsCounter hits={1899} showResetButton={false} onResetQuery={jest.fn()} />
59+
);
60+
const hits = findTestSubject(component, 'discoverQueryHits');
61+
expect(hits.text()).toBe('1,899');
62+
});
63+
64+
it('should reset query', function() {
65+
component = mountWithIntl(<HitsCounter {...props} />);
66+
findTestSubject(component, 'resetSavedSearch').simulate('click');
67+
expect(props.onResetQuery).toHaveBeenCalled();
68+
});
69+
});

0 commit comments

Comments
 (0)