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 pull request #1 from davismcphee/discover-timeline-davis
Switch from `useDiscoverMainRoute` to `DiscoverContainer` component
- Loading branch information
Showing
13 changed files
with
130 additions
and
123 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
17 changes: 0 additions & 17 deletions
17
src/plugins/discover/public/application/services_provider.tsx
This file was deleted.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
src/plugins/discover/public/components/discover_container/discover_container.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,55 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { ScopedHistory } from '@kbn/core/public'; | ||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
import { DiscoverMainRoute } from '../../application/main'; | ||
import type { DiscoverServices } from '../../build_services'; | ||
import type { CustomizationCallback } from '../../customizations'; | ||
import { setHeaderActionMenuMounter, setScopedHistory } from '../../kibana_services'; | ||
|
||
export interface DiscoverContainerInternalProps { | ||
services: DiscoverServices; | ||
scopedHistory: ScopedHistory; | ||
customize: CustomizationCallback; | ||
isDev: boolean; | ||
} | ||
|
||
export const DiscoverContainerInternal = ({ | ||
services, | ||
scopedHistory, | ||
customize, | ||
isDev, | ||
}: DiscoverContainerInternalProps) => { | ||
const customizationCallbacks = useMemo(() => [customize], [customize]); | ||
const [initialized, setInitialized] = useState(false); | ||
|
||
useEffect(() => { | ||
setScopedHistory(scopedHistory); | ||
setHeaderActionMenuMounter(() => {}); | ||
setInitialized(true); | ||
}, [scopedHistory]); | ||
|
||
if (!initialized) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<KibanaContextProvider services={services}> | ||
<DiscoverMainRoute | ||
customizationCallbacks={customizationCallbacks} | ||
mode="embedded" | ||
isDev={isDev} | ||
/> | ||
</KibanaContextProvider> | ||
); | ||
}; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default DiscoverContainerInternal; |
24 changes: 24 additions & 0 deletions
24
src/plugins/discover/public/components/discover_container/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,24 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { withSuspense } from '@kbn/shared-ux-utility'; | ||
import { lazy } from 'react'; | ||
import type { DiscoverServices } from '../../build_services'; | ||
import type { DiscoverContainerInternalProps } from './discover_container'; | ||
|
||
export type DiscoverContainerProps = Omit<DiscoverContainerInternalProps, 'services' | 'isDev'> & { | ||
/* | ||
* Any override that user of this hook | ||
* wants discover to use. Need to keep in mind that this | ||
* param is only for overrides for the services that Discover | ||
* already consumes. | ||
*/ | ||
services: Partial<DiscoverServices>; | ||
}; | ||
|
||
export const DiscoverContainerInternal = withSuspense(lazy(() => import('./discover_container'))); |
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 was deleted.
Oops, something went wrong.
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