forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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 upgrade-lodash-4-final
- Loading branch information
Showing
99 changed files
with
2,067 additions
and
413 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
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
20 changes: 20 additions & 0 deletions
20
src/plugins/data/public/index_patterns/expressions/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,20 @@ | ||
/* | ||
* 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 * from './load_index_pattern'; |
39 changes: 39 additions & 0 deletions
39
src/plugins/data/public/index_patterns/expressions/load_index_pattern.test.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,39 @@ | ||
/* | ||
* 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 { indexPatternLoad } from './load_index_pattern'; | ||
|
||
jest.mock('../../services', () => ({ | ||
getIndexPatterns: () => ({ | ||
get: (id: string) => ({ | ||
toSpec: () => ({ | ||
title: 'value', | ||
}), | ||
}), | ||
}), | ||
})); | ||
|
||
describe('indexPattern expression function', () => { | ||
test('returns serialized index pattern', async () => { | ||
const indexPatternDefinition = indexPatternLoad(); | ||
const result = await indexPatternDefinition.fn(null, { id: '1' }, {} as any); | ||
expect(result.type).toEqual('index_pattern'); | ||
expect(result.value.title).toEqual('value'); | ||
}); | ||
}); |
62 changes: 62 additions & 0 deletions
62
src/plugins/data/public/index_patterns/expressions/load_index_pattern.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,62 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { ExpressionFunctionDefinition } from '../../../../../plugins/expressions/public'; | ||
import { getIndexPatterns } from '../../services'; | ||
import { IndexPatternSpec } from '../../../common/index_patterns'; | ||
|
||
const name = 'indexPatternLoad'; | ||
|
||
type Input = null; | ||
type Output = Promise<{ type: 'index_pattern'; value: IndexPatternSpec }>; | ||
|
||
interface Arguments { | ||
id: string; | ||
} | ||
|
||
export const indexPatternLoad = (): ExpressionFunctionDefinition< | ||
typeof name, | ||
Input, | ||
Arguments, | ||
Output | ||
> => ({ | ||
name, | ||
type: 'index_pattern', | ||
inputTypes: ['null'], | ||
help: i18n.translate('data.functions.indexPatternLoad.help', { | ||
defaultMessage: 'Loads an index pattern', | ||
}), | ||
args: { | ||
id: { | ||
types: ['string'], | ||
required: true, | ||
help: i18n.translate('data.functions.indexPatternLoad.id.help', { | ||
defaultMessage: 'index pattern id to load', | ||
}), | ||
}, | ||
}, | ||
async fn(input, args) { | ||
const indexPatterns = getIndexPatterns(); | ||
|
||
const indexPattern = await indexPatterns.get(args.id); | ||
|
||
return { type: 'index_pattern', value: indexPattern.toSpec() }; | ||
}, | ||
}); |
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
95 changes: 95 additions & 0 deletions
95
src/plugins/data/public/ui/query_string_input/no_data_popover.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,95 @@ | ||
/* | ||
* 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 as mount } from 'test_utils/enzyme_helpers'; | ||
import { NoDataPopover } from './no_data_popover'; | ||
import { EuiTourStep } from '@elastic/eui'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
describe('NoDataPopover', () => { | ||
const createMockStorage = () => ({ | ||
get: jest.fn(), | ||
set: jest.fn(), | ||
remove: jest.fn(), | ||
clear: jest.fn(), | ||
}); | ||
|
||
it('should hide popover if showNoDataPopover is set to false', () => { | ||
const Child = () => <span />; | ||
const instance = mount( | ||
<NoDataPopover storage={createMockStorage()} showNoDataPopover={false}> | ||
<Child /> | ||
</NoDataPopover> | ||
); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(false); | ||
expect(instance.find(EuiTourStep).find(Child)).toHaveLength(1); | ||
}); | ||
|
||
it('should hide popover if showNoDataPopover is set to true, but local storage flag is set', () => { | ||
const child = <span />; | ||
const storage = createMockStorage(); | ||
storage.get.mockReturnValue(true); | ||
const instance = mount( | ||
<NoDataPopover storage={storage} showNoDataPopover={false}> | ||
{child} | ||
</NoDataPopover> | ||
); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(false); | ||
}); | ||
|
||
it('should render popover if showNoDataPopover is set to true and local storage flag is not set', () => { | ||
const child = <span />; | ||
const instance = mount( | ||
<NoDataPopover storage={createMockStorage()} showNoDataPopover={true}> | ||
{child} | ||
</NoDataPopover> | ||
); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(true); | ||
}); | ||
|
||
it('should hide popover if it is closed', async () => { | ||
const props = { | ||
children: <span />, | ||
showNoDataPopover: true, | ||
storage: createMockStorage(), | ||
}; | ||
const instance = mount(<NoDataPopover {...props} />); | ||
act(() => { | ||
instance.find(EuiTourStep).prop('closePopover')!(); | ||
}); | ||
instance.setProps({ ...props }); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(false); | ||
}); | ||
|
||
it('should set local storage flag and hide on closing with button', () => { | ||
const props = { | ||
children: <span />, | ||
showNoDataPopover: true, | ||
storage: createMockStorage(), | ||
}; | ||
const instance = mount(<NoDataPopover {...props} />); | ||
act(() => { | ||
instance.find(EuiTourStep).prop('footerAction')!.props.onClick(); | ||
}); | ||
instance.setProps({ ...props }); | ||
expect(props.storage.set).toHaveBeenCalledWith(expect.any(String), true); | ||
expect(instance.find(EuiTourStep).prop('isStepOpen')).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.