Skip to content

Commit 83d3541

Browse files
committed
Merge remote-tracking branch 'upstream/master' into pr/smith/65882
2 parents 6b8ed1a + 1c6e6cb commit 83d3541

File tree

35 files changed

+462
-75
lines changed

35 files changed

+462
-75
lines changed

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/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+
});
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
21+
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
22+
import { i18n } from '@kbn/i18n';
23+
import { formatNumWithCommas } from '../../helpers';
24+
25+
export interface HitsCounterProps {
26+
/**
27+
* the number of query hits
28+
*/
29+
hits: number;
30+
/**
31+
* displays the reset button
32+
*/
33+
showResetButton: boolean;
34+
/**
35+
* resets the query
36+
*/
37+
onResetQuery: () => void;
38+
}
39+
40+
export function HitsCounter({ hits, showResetButton, onResetQuery }: HitsCounterProps) {
41+
return (
42+
<I18nProvider>
43+
<EuiFlexGroup
44+
gutterSize="s"
45+
className="dscResultCount"
46+
responsive={false}
47+
justifyContent="center"
48+
alignItems="center"
49+
>
50+
<EuiFlexItem grow={false}>
51+
<EuiText>
52+
<strong data-test-subj="discoverQueryHits">{formatNumWithCommas(hits)}</strong>{' '}
53+
<FormattedMessage
54+
id="discover.hitsPluralTitle"
55+
defaultMessage="{hits, plural, one {hit} other {hits}}"
56+
values={{
57+
hits,
58+
}}
59+
/>
60+
</EuiText>
61+
</EuiFlexItem>
62+
{showResetButton && (
63+
<EuiFlexItem grow={false}>
64+
<EuiButtonEmpty
65+
iconType="refresh"
66+
data-test-subj="resetSavedSearch"
67+
onClick={onResetQuery}
68+
size="s"
69+
aria-label={i18n.translate('discover.reloadSavedSearchButton', {
70+
defaultMessage: 'Reset search',
71+
})}
72+
>
73+
<FormattedMessage
74+
id="discover.reloadSavedSearchButton"
75+
defaultMessage="Reset search"
76+
/>
77+
</EuiButtonEmpty>
78+
</EuiFlexItem>
79+
)}
80+
</EuiFlexGroup>
81+
</I18nProvider>
82+
);
83+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 { HitsCounter } from './hits_counter';
20+
21+
export function createHitsCounterDirective(reactDirective: any) {
22+
return reactDirective(HitsCounter, [
23+
['hits', { watchDepth: 'reference' }],
24+
['showResetButton', { watchDepth: 'reference' }],
25+
['onResetQuery', { watchDepth: 'reference' }],
26+
]);
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
20+
export { HitsCounter } from './hits_counter';
21+
export { createHitsCounterDirective } from './hits_counter_directive';

0 commit comments

Comments
 (0)