kibana/x-pack/plugins/aiops/public/hooks/use_data_source.ts
Walter Rafelsberger ae5594849c
[ML] Move DatePickerWrapper and related code to package (#148063)
- Moves duplicates of `DatePickerWrapper` and related code to package
`@kbn/ml-date-picker`. The duplicated components across the code base
have been consolidated and diverging features combined. Each duplicate
has been checked with a diff against the package before deletion.
- Moves duplicates of `query_utils.ts` to a package
`@kbn/ml-query_utils`.
- Some jest test were migrated from enzyme to react-testing-lib.
- `i18n` strings and data-test-subjects have been updated to be prefixes
in line with package names.
- Replaces custom code related to the `compact` flag with EUI's
breakpoints.
2023-01-12 11:04:49 +01:00

25 lines
841 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { createContext, useContext } from 'react';
import { DataView } from '@kbn/data-views-plugin/common';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import { SavedSearchSavedObject } from '../application/utils/search_utils';
export const DataSourceContext = createContext<{
dataView: DataView | never;
savedSearch: SavedSearch | SavedSearchSavedObject | null;
}>({
get dataView(): never {
throw new Error('DataSourceContext is not implemented');
},
savedSearch: null,
});
export function useDataSource() {
return useContext(DataSourceContext);
}