-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev/import-dashboard-url-generator-directly
- Loading branch information
Showing
67 changed files
with
861 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ | |
"leaflet-responsive-popup": "0.6.4", | ||
"leaflet-vega": "^0.8.6", | ||
"leaflet.heat": "0.2.0", | ||
"less": "^2.7.3", | ||
"less": "npm:@elastic/less@2.7.3-kibana", | ||
"less-loader": "5.0.0", | ||
"lodash": "npm:@elastic/[email protected]", | ||
"lodash.clonedeep": "^4.5.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/plugins/discover/public/application/angular/doc_table/components/_table_header.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.kbnDocTableHeader { | ||
white-space: nowrap; | ||
} | ||
.kbnDocTableHeader button { | ||
margin-left: $euiSizeXS; | ||
} | ||
|
69 changes: 69 additions & 0 deletions
69
src/plugins/discover/public/application/components/hits_counter/hits_counter.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { mountWithIntl } from 'test_utils/enzyme_helpers'; | ||
import { ReactWrapper } from 'enzyme'; | ||
import { HitsCounter, HitsCounterProps } from './hits_counter'; | ||
// @ts-ignore | ||
import { findTestSubject } from '@elastic/eui/lib/test'; | ||
|
||
describe('hits counter', function() { | ||
let props: HitsCounterProps; | ||
let component: ReactWrapper<HitsCounterProps>; | ||
|
||
beforeAll(() => { | ||
props = { | ||
onResetQuery: jest.fn(), | ||
showResetButton: true, | ||
hits: 2, | ||
}; | ||
}); | ||
|
||
it('HitsCounter renders a button by providing the showResetButton property', () => { | ||
component = mountWithIntl(<HitsCounter {...props} />); | ||
expect(findTestSubject(component, 'resetSavedSearch').length).toBe(1); | ||
}); | ||
|
||
it('HitsCounter not renders a button when the showResetButton property is false', () => { | ||
component = mountWithIntl( | ||
<HitsCounter hits={2} showResetButton={false} onResetQuery={jest.fn()} /> | ||
); | ||
expect(findTestSubject(component, 'resetSavedSearch').length).toBe(0); | ||
}); | ||
|
||
it('expect to render the number of hits', function() { | ||
component = mountWithIntl(<HitsCounter {...props} />); | ||
const hits = findTestSubject(component, 'discoverQueryHits'); | ||
expect(hits.text()).toBe('2'); | ||
}); | ||
|
||
it('expect to render 1,899 hits if 1899 hits given', function() { | ||
component = mountWithIntl( | ||
<HitsCounter hits={1899} showResetButton={false} onResetQuery={jest.fn()} /> | ||
); | ||
const hits = findTestSubject(component, 'discoverQueryHits'); | ||
expect(hits.text()).toBe('1,899'); | ||
}); | ||
|
||
it('should reset query', function() { | ||
component = mountWithIntl(<HitsCounter {...props} />); | ||
findTestSubject(component, 'resetSavedSearch').simulate('click'); | ||
expect(props.onResetQuery).toHaveBeenCalled(); | ||
}); | ||
}); |
83 changes: 83 additions & 0 deletions
83
src/plugins/discover/public/application/components/hits_counter/hits_counter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'; | ||
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { formatNumWithCommas } from '../../helpers'; | ||
|
||
export interface HitsCounterProps { | ||
/** | ||
* the number of query hits | ||
*/ | ||
hits: number; | ||
/** | ||
* displays the reset button | ||
*/ | ||
showResetButton: boolean; | ||
/** | ||
* resets the query | ||
*/ | ||
onResetQuery: () => void; | ||
} | ||
|
||
export function HitsCounter({ hits, showResetButton, onResetQuery }: HitsCounterProps) { | ||
return ( | ||
<I18nProvider> | ||
<EuiFlexGroup | ||
gutterSize="s" | ||
className="dscResultCount" | ||
responsive={false} | ||
justifyContent="center" | ||
alignItems="center" | ||
> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
<strong data-test-subj="discoverQueryHits">{formatNumWithCommas(hits)}</strong>{' '} | ||
<FormattedMessage | ||
id="discover.hitsPluralTitle" | ||
defaultMessage="{hits, plural, one {hit} other {hits}}" | ||
values={{ | ||
hits, | ||
}} | ||
/> | ||
</EuiText> | ||
</EuiFlexItem> | ||
{showResetButton && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonEmpty | ||
iconType="refresh" | ||
data-test-subj="resetSavedSearch" | ||
onClick={onResetQuery} | ||
size="s" | ||
aria-label={i18n.translate('discover.reloadSavedSearchButton', { | ||
defaultMessage: 'Reset search', | ||
})} | ||
> | ||
<FormattedMessage | ||
id="discover.reloadSavedSearchButton" | ||
defaultMessage="Reset search" | ||
/> | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
</I18nProvider> | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/plugins/discover/public/application/components/hits_counter/hits_counter_directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { HitsCounter } from './hits_counter'; | ||
|
||
export function createHitsCounterDirective(reactDirective: any) { | ||
return reactDirective(HitsCounter, [ | ||
['hits', { watchDepth: 'reference' }], | ||
['showResetButton', { watchDepth: 'reference' }], | ||
['onResetQuery', { watchDepth: 'reference' }], | ||
]); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/plugins/discover/public/application/components/hits_counter/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { HitsCounter } from './hits_counter'; | ||
export { createHitsCounterDirective } from './hits_counter_directive'; |
Oops, something went wrong.