-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move KibanaEnvironmentContext to apm and infra
- Loading branch information
1 parent
b3e0d7d
commit 894d688
Showing
12 changed files
with
174 additions
and
109 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
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/apm/public/context/kibana_environment_context/kibana_environment_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,16 @@ | ||
/* | ||
* 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'; | ||
|
||
export interface KibanaEnvContext { | ||
kibanaVersion?: string; | ||
isCloudEnv?: boolean; | ||
isServerlessEnv?: boolean; | ||
} | ||
|
||
export const KibanaEnvironmentContext = createContext<KibanaEnvContext>({}); |
40 changes: 40 additions & 0 deletions
40
.../plugins/apm/public/context/kibana_environment_context/use_kibana_environment_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,40 @@ | ||
/* | ||
* 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, { useMemo, createElement } from 'react'; | ||
import { ApmPluginStartDeps } from '../../plugin'; | ||
import { | ||
KibanaEnvironmentContext, | ||
type KibanaEnvContext, | ||
} from './kibana_environment_context'; | ||
|
||
export const useKibanaEnvironmentContextProvider = ( | ||
plugins: ApmPluginStartDeps | ||
) => { | ||
const value = useMemo( | ||
() => ({ | ||
kibanaVersion: plugins.kibanaVersion, | ||
isCloudEnv: plugins.isCloudEnv, | ||
isServerlessEnv: plugins.isServerlessEnv, | ||
}), | ||
[plugins] | ||
); | ||
|
||
const Provider: React.FC<{ kibanaEnvironment?: KibanaEnvContext }> = ({ | ||
kibanaEnvironment = {}, | ||
children, | ||
}) => { | ||
const newProvider = createElement(KibanaEnvironmentContext.Provider, { | ||
value: { ...kibanaEnvironment, ...value }, | ||
children, | ||
}); | ||
|
||
return newProvider; | ||
}; | ||
|
||
return Provider; | ||
}; |
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
Oops, something went wrong.