-
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.
Shim input_control_vis for KP (#52243)
* Shim input_control_vis * Convert input_control_vis src files to typescript * Add Required, Optional, Required and Class types to kbn-utility-types * Collect all ui/* imports into legacy imports file * Pass down plugin deps from top level * Add timeout and terminate_after options to SearchSourceFields
- Loading branch information
1 parent
87a9b6b
commit 72c5c5c
Showing
79 changed files
with
2,067 additions
and
1,305 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 { resolve } from 'path'; | ||
import { Legacy } from 'kibana'; | ||
|
||
import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; | ||
|
||
const inputControlVisPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => | ||
new Plugin({ | ||
id: 'input_control_vis', | ||
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter', 'data'], | ||
publicDir: resolve(__dirname, 'public'), | ||
uiExports: { | ||
styleSheetPaths: resolve(__dirname, 'public/index.scss'), | ||
hacks: [resolve(__dirname, 'public/legacy')], | ||
injectDefaultVars: server => ({}), | ||
}, | ||
init: (server: Legacy.Server) => ({}), | ||
config(Joi: any) { | ||
return Joi.object({ | ||
enabled: Joi.boolean().default(true), | ||
}).default(); | ||
}, | ||
} as Legacy.PluginSpecOptions); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default inputControlVisPluginInitializer; |
File renamed without changes.
48 changes: 48 additions & 0 deletions
48
...r/__snapshots__/controls_tab.test.js.snap → .../__snapshots__/controls_tab.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...pshots__/list_control_editor.test.js.snap → ...shots__/list_control_editor.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...or/__snapshots__/options_tab.test.js.snap → ...r/__snapshots__/options_tab.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...shots__/range_control_editor.test.js.snap → ...hots__/range_control_editor.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
...egacy/core_plugins/input_control_vis/public/components/editor/__tests__/get_deps_mock.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,76 @@ | ||
/* | ||
* 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 { FieldList } from 'src/plugins/data/public'; | ||
import { InputControlVisDependencies } from '../../../plugin'; | ||
|
||
const fields: FieldList = [] as any; | ||
fields.push({ name: 'myField' } as any); | ||
fields.getByName = (name: any) => { | ||
return fields.find(({ name: n }) => n === name); | ||
}; | ||
|
||
export const getDepsMock = (): InputControlVisDependencies => | ||
({ | ||
core: { | ||
getStartServices: jest.fn().mockReturnValue([ | ||
null, | ||
{ | ||
data: { | ||
ui: { | ||
IndexPatternSelect: () => (<div />) as any, | ||
}, | ||
indexPatterns: { | ||
get: () => ({ | ||
fields, | ||
}), | ||
}, | ||
}, | ||
}, | ||
]), | ||
injectedMetadata: { | ||
getInjectedVar: jest.fn().mockImplementation(key => { | ||
switch (key) { | ||
case 'autocompleteTimeout': | ||
return 1000; | ||
case 'autocompleteTerminateAfter': | ||
return 100000; | ||
default: | ||
return ''; | ||
} | ||
}), | ||
}, | ||
}, | ||
data: { | ||
query: { | ||
filterManager: { | ||
fieldName: 'myField', | ||
getIndexPattern: () => ({ | ||
fields, | ||
}), | ||
getAppFilters: jest.fn().mockImplementation(() => []), | ||
getGlobalFilters: jest.fn().mockImplementation(() => []), | ||
}, | ||
timefilter: { | ||
timefilter: {}, | ||
}, | ||
}, | ||
}, | ||
} as any); |
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
File renamed without changes.
46 changes: 46 additions & 0 deletions
46
...e_plugins/input_control_vis/public/components/editor/__tests__/get_search_service_mock.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,46 @@ | ||
/* | ||
* 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 { SearchSource } from '../../../legacy_imports'; | ||
|
||
export const getSearchSourceMock = (esSearchResponse?: any): SearchSource => | ||
jest.fn().mockImplementation(() => ({ | ||
setParent: jest.fn(), | ||
setField: jest.fn(), | ||
fetch: jest.fn().mockResolvedValue( | ||
esSearchResponse | ||
? esSearchResponse | ||
: { | ||
aggregations: { | ||
termsAgg: { | ||
buckets: [ | ||
{ | ||
key: 'Zurich Airport', | ||
doc_count: 691, | ||
}, | ||
{ | ||
key: 'Xi an Xianyang International Airport', | ||
doc_count: 526, | ||
}, | ||
], | ||
}, | ||
}, | ||
} | ||
), | ||
})); |
31 changes: 31 additions & 0 deletions
31
...acy/core_plugins/input_control_vis/public/components/editor/__tests__/update_component.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,31 @@ | ||
/* | ||
* 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 { ShallowWrapper, ReactWrapper } from 'enzyme'; | ||
|
||
export const updateComponent = async ( | ||
component: | ||
| ShallowWrapper<any, Readonly<{}>, React.Component<{}, {}, any>> | ||
| ReactWrapper<any, Readonly<{}>, React.Component<{}, {}, any>> | ||
) => { | ||
// Ensure all promises resolve | ||
await new Promise(resolve => process.nextTick(resolve)); | ||
// Ensure the state changes are reflected | ||
component.update(); | ||
}; |
Oops, something went wrong.