-
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
chore(slo): Migrate to server-route-repository #198726
Changes from 41 commits
090c53d
d0a9883
88fd533
861d205
e05e672
7ea5f27
6e3bbb2
2540e6f
f580480
377fc19
44273f6
6e96060
232486d
1b93e2b
073560c
708e1c2
7caf413
db15edf
8a94f42
a204ad0
7bea57b
b2f09e6
6cd5ceb
f5fe891
f3d5672
46db725
7694fe2
3b7a5b8
8a3d28f
7e25fd8
885ee36
d81a3f2
478bae0
02e5e1c
69b2183
bb3e780
2de2399
4f70c8a
cc67e0f
4cdca40
65d06fc
4e3270c
688c62a
1d6dbfd
803c813
ec0d9b6
b8d0087
a4ffd0b
acf22fd
9945ab4
f81ed59
ef1715c
ab5510c
5a421e5
fca3bbb
11b8a0f
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 |
---|---|---|
|
@@ -5,27 +5,28 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import React, { useEffect } from 'react'; | ||
import { Router } from '@kbn/shared-ux-router'; | ||
import { BehaviorSubject, Subject } from 'rxjs'; | ||
import type { CoreStart } from '@kbn/core-lifecycle-browser'; | ||
import { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; | ||
import { Storage } from '@kbn/kibana-utils-plugin/public'; | ||
import { | ||
FetchContext, | ||
fetch$, | ||
initializeTitles, | ||
useBatchedPublishingSubjects, | ||
fetch$, | ||
FetchContext, | ||
useFetchContext, | ||
} from '@kbn/presentation-publishing'; | ||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; | ||
import { Router } from '@kbn/shared-ux-router'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { createBrowserHistory } from 'history'; | ||
import { Storage } from '@kbn/kibana-utils-plugin/public'; | ||
import type { StartServicesAccessor } from '@kbn/core-lifecycle-browser'; | ||
import React, { useEffect } from 'react'; | ||
import { BehaviorSubject, Subject } from 'rxjs'; | ||
import { PluginContext } from '../../../context/plugin_context'; | ||
import { SLOPublicPluginsStart, SLORepositoryClient } from '../../../types'; | ||
import { SLO_ALERTS_EMBEDDABLE_ID } from './constants'; | ||
import { SloAlertsEmbeddableState, SloAlertsApi } from './types'; | ||
import { SloPublicPluginsStart, SloPublicStart } from '../../../types'; | ||
import { SloAlertsWrapper } from './slo_alerts_wrapper'; | ||
import { SloAlertsApi, SloAlertsEmbeddableState } from './types'; | ||
const history = createBrowserHistory(); | ||
const queryClient = new QueryClient(); | ||
|
||
|
@@ -34,10 +35,17 @@ export const getAlertsPanelTitle = () => | |
defaultMessage: 'SLO Alerts', | ||
}); | ||
|
||
export function getAlertsEmbeddableFactory( | ||
getStartServices: StartServicesAccessor<SloPublicPluginsStart, SloPublicStart>, | ||
kibanaVersion: string | ||
) { | ||
export function getAlertsEmbeddableFactory({ | ||
coreStart, | ||
pluginsStart, | ||
sloClient, | ||
kibanaVersion, | ||
}: { | ||
coreStart: CoreStart; | ||
pluginsStart: SLOPublicPluginsStart; | ||
sloClient: SLORepositoryClient; | ||
kibanaVersion: string; | ||
}) { | ||
const factory: ReactEmbeddableFactory< | ||
SloAlertsEmbeddableState, | ||
SloAlertsEmbeddableState, | ||
|
@@ -48,15 +56,15 @@ export function getAlertsEmbeddableFactory( | |
return state.rawState as SloAlertsEmbeddableState; | ||
}, | ||
buildEmbeddable: async (state, buildApi, uuid, parentApi) => { | ||
const [coreStart, pluginStart] = await getStartServices(); | ||
const deps = { ...coreStart, ...pluginStart }; | ||
const deps = { ...coreStart, ...pluginsStart }; | ||
async function onEdit() { | ||
try { | ||
const { openSloConfiguration } = await import('./slo_alerts_open_configuration'); | ||
|
||
const result = await openSloConfiguration( | ||
coreStart, | ||
pluginStart, | ||
pluginsStart, | ||
sloClient, | ||
api.getSloAlertsConfig() | ||
); | ||
api.updateSloAlertsConfig(result); | ||
|
@@ -143,18 +151,28 @@ export function getAlertsEmbeddableFactory( | |
kibanaVersion, | ||
}} | ||
> | ||
<Router history={history}> | ||
<QueryClientProvider client={queryClient}> | ||
<SloAlertsWrapper | ||
onEdit={onEdit} | ||
deps={deps} | ||
slos={slos} | ||
timeRange={fetchContext.timeRange ?? { from: 'now-15m/m', to: 'now' }} | ||
reloadSubject={reload$} | ||
showAllGroupByInstances={showAllGroupByInstances} | ||
/> | ||
</QueryClientProvider> | ||
</Router> | ||
<PluginContext.Provider | ||
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. All the embeddables registration would need to be refactored to use a common context providers instead of creating from scratch for the 5 different embeddable we have. Very error prone. 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. Linking with this comment here. There is indeed an |
||
value={{ | ||
observabilityRuleTypeRegistry: | ||
pluginsStart.observability.observabilityRuleTypeRegistry, | ||
ObservabilityPageTemplate: | ||
pluginsStart.observabilityShared.navigation.PageTemplate, | ||
sloClient, | ||
}} | ||
> | ||
<Router history={history}> | ||
<QueryClientProvider client={queryClient}> | ||
<SloAlertsWrapper | ||
onEdit={onEdit} | ||
deps={deps} | ||
slos={slos} | ||
timeRange={fetchContext.timeRange ?? { from: 'now-15m/m', to: 'now' }} | ||
reloadSubject={reload$} | ||
showAllGroupByInstances={showAllGroupByInstances} | ||
/> | ||
</QueryClientProvider> | ||
</Router> | ||
</PluginContext.Provider> | ||
</KibanaContextProvider> | ||
</I18nContext> | ||
); | ||
|
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.
Should
spaces
not be an optional dependency?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.
Maybe you're right. Moving it back to optional