-
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.
- Loading branch information
1 parent
df7e130
commit 1fe31fa
Showing
12 changed files
with
114 additions
and
62 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
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/observability_ai_assistant/public/context/license/license_context.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,23 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import useObservable from 'react-use/lib/useObservable'; | ||
import { ILicense } from '@kbn/licensing-plugin/public'; | ||
import { useObservabilityAiAssistantPluginContext } from '../observability_ai_assistant_plugins/use_observability_ai_assistant_plugin_context'; | ||
|
||
export const LicenseContext = React.createContext<ILicense | undefined>(undefined); | ||
|
||
export function LicenseProvider({ children }: { children: React.ReactChild }) { | ||
const { | ||
start: { licensing }, | ||
} = useObservabilityAiAssistantPluginContext(); | ||
const license = useObservable(licensing.license$); | ||
|
||
// render rest of application and pass down license via context | ||
return <LicenseContext.Provider value={license} children={children} />; | ||
} |
13 changes: 13 additions & 0 deletions
13
x-pack/plugins/observability_ai_assistant/public/context/license/use_license_context.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,13 @@ | ||
/* | ||
* 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 { useContext } from 'react'; | ||
import { LicenseContext } from './license_context'; | ||
|
||
export function useLicenseContext() { | ||
return useContext(LicenseContext); | ||
} |
17 changes: 17 additions & 0 deletions
17
.../context/observability_ai_assistant_plugins/observability_ai_assistant_plugin_context.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,17 @@ | ||
/* | ||
* 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 } from 'react'; | ||
import { ObservabilityAIAssistantPluginStartDependencies } from '../../types'; | ||
|
||
export interface ObservabilityAiAssistantPluginContextValue { | ||
start: ObservabilityAIAssistantPluginStartDependencies; | ||
} | ||
|
||
export const ObservabilityAiAssistantContext = createContext( | ||
{} as ObservabilityAiAssistantPluginContextValue | ||
); |
13 changes: 13 additions & 0 deletions
13
...ntext/observability_ai_assistant_plugins/use_observability_ai_assistant_plugin_context.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,13 @@ | ||
/* | ||
* 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 { useContext } from 'react'; | ||
import { ObservabilityAiAssistantContext } from './observability_ai_assistant_plugin_context'; | ||
|
||
export function useObservabilityAiAssistantPluginContext() { | ||
return useContext(ObservabilityAiAssistantContext); | ||
} |
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
35 changes: 0 additions & 35 deletions
35
x-pack/plugins/observability_ai_assistant/public/hooks/use_license.ts
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