-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SIEM] Migrating frontend services to NP #52783
Changes from 38 commits
021c4e1
bc62682
f23a295
3d8ac01
1cabdd9
62906ad
566d373
e61b37d
d08b492
86d047b
c412394
2b3e663
21a20b5
51f5619
5a127e1
b7ff02f
ea1a780
633bc16
2d4c1a2
9be9f4f
c0d2a4a
7fcc147
b78bf54
f982691
5843449
d62d583
9f4f0dd
8c1282e
0fab29b
62a40d6
8ff4f77
deb1ea1
ad83050
c5e9fbb
aa8fe1b
c517c89
83f4eb4
26a6d0e
cd3bd29
512a949
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,16 @@ import { Chrome } from 'ui/chrome'; | |
|
||
import { SiemApp } from './start_app'; | ||
import template from './template.html'; | ||
import { DEFAULT_KBN_VERSION, DEFAULT_TIMEZONE_BROWSER } from '../../common/constants'; | ||
|
||
export const ROOT_ELEMENT_ID = 'react-siem-root'; | ||
|
||
export type StartCore = LegacyCoreStart; | ||
export type StartPlugins = Required< | ||
Pick<PluginsStart, 'data' | 'embeddable' | 'inspector' | 'uiActions'> | ||
>; | ||
export type StartServices = StartCore & StartPlugins; | ||
|
||
export class Plugin { | ||
constructor( | ||
// @ts-ignore this is added to satisfy the New Platform typing constraint, | ||
|
@@ -25,7 +32,11 @@ export class Plugin { | |
this.chrome = chrome; | ||
} | ||
|
||
public start(core: LegacyCoreStart, plugins: PluginsStart) { | ||
public start(core: StartCore, plugins: StartPlugins) { | ||
// TODO(rylnd): once we're on NP, we can populate version from env.packageInfo | ||
core.uiSettings.set(DEFAULT_KBN_VERSION, '8.0.0'); | ||
core.uiSettings.set(DEFAULT_TIMEZONE_BROWSER, 'UTC'); | ||
|
||
// @ts-ignore improper type description | ||
this.chrome.setRootTemplate(template); | ||
const checkForRoot = () => { | ||
Comment on lines
36
to
37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe you can replace all this code with the NP mounting mechanism in |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ import React, { memo, FC } from 'react'; | |
import { ApolloProvider } from 'react-apollo'; | ||
import { Provider as ReduxStoreProvider } from 'react-redux'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import { LegacyCoreStart } from 'kibana/public'; | ||
import { PluginsStart } from 'ui/new_platform/new_platform'; | ||
|
||
import { EuiErrorBoundary } from '@elastic/eui'; | ||
import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; | ||
|
@@ -19,16 +17,14 @@ import { BehaviorSubject } from 'rxjs'; | |
import { pluck } from 'rxjs/operators'; | ||
import { I18nContext } from 'ui/i18n'; | ||
|
||
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; | ||
import { KibanaContextProvider, useUiSetting$ } from '../lib/kibana'; | ||
import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; | ||
|
||
import { DEFAULT_DARK_MODE } from '../../common/constants'; | ||
import { ErrorToastDispatcher } from '../components/error_toast_dispatcher'; | ||
import { compose } from '../lib/compose/kibana_compose'; | ||
import { AppFrontendLibs } from '../lib/lib'; | ||
import { KibanaCoreContextProvider } from '../lib/compose/kibana_core'; | ||
import { KibanaPluginsContextProvider } from '../lib/compose/kibana_plugins'; | ||
import { useKibanaUiSetting } from '../lib/settings/use_kibana_ui_setting'; | ||
import { StartCore, StartPlugins } from './plugin'; | ||
import { PageRouter } from '../routes'; | ||
import { createStore } from '../store'; | ||
import { GlobalToaster, ManageGlobalToaster } from '../components/toasters'; | ||
|
@@ -44,7 +40,7 @@ const StartApp: FC<AppFrontendLibs> = memo(libs => { | |
const store = createStore(undefined, libs$.pipe(pluck('apolloClient'))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rudolf we have a few uses of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Step 1 & 2 sound fine, however step 3 is a bit off. Registering applications is done during |
||
|
||
const AppPluginRoot = memo(() => { | ||
const [darkMode] = useKibanaUiSetting(DEFAULT_DARK_MODE); | ||
const [darkMode] = useUiSetting$<boolean>(DEFAULT_DARK_MODE); | ||
return ( | ||
<EuiErrorBoundary> | ||
<I18nContext> | ||
|
@@ -77,21 +73,15 @@ const StartApp: FC<AppFrontendLibs> = memo(libs => { | |
|
||
export const ROOT_ELEMENT_ID = 'react-siem-root'; | ||
|
||
export const SiemApp = memo<{ core: LegacyCoreStart; plugins: PluginsStart }>( | ||
({ core, plugins }) => ( | ||
<KibanaContextProvider | ||
services={{ | ||
appName: 'siem', | ||
data: plugins.data, | ||
storage: new Storage(localStorage), | ||
...core, | ||
}} | ||
> | ||
<KibanaCoreContextProvider core={core}> | ||
<KibanaPluginsContextProvider plugins={plugins}> | ||
<StartApp {...compose()} /> | ||
</KibanaPluginsContextProvider> | ||
</KibanaCoreContextProvider> | ||
</KibanaContextProvider> | ||
) | ||
); | ||
export const SiemApp = memo<{ core: StartCore; plugins: StartPlugins }>(({ core, plugins }) => ( | ||
<KibanaContextProvider | ||
services={{ | ||
appName: 'siem', | ||
data: plugins.data, | ||
storage: new Storage(localStorage), | ||
...core, | ||
}} | ||
> | ||
<StartApp {...compose()} /> | ||
</KibanaContextProvider> | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get an error from the service when I try to retrieve this value. I know I can get the version from the plugin's init context, but I'm unsure if/where there's an equivalent for this setting, or if the warning is just a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error are you getting? Why do you set these settings here? Did you mean to use
core.uiSettings.get
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was receiving warnings when trying to
get
these two keys. The UI Settings service did not seem to know about them and advised I set defaults. I don't see that now, though, so I'll remove these 🤷♂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshdover Ok, the rest of my team hit this when it hit master. For a fresh app, the service doesn't know about these keys, and throws errors. On my instance, these defaults were persisted to my kibana index, which is why I didn't see the error after removing these lines.
The unknown keys here are
kbnVersion
andtimezoneBrowser
. I know that the version is available on the initializer context, so I could understand it being removed from UI settings, but I'm not sure abouttimezoneBrowser
.