Skip to content

Commit

Permalink
Merge branch '8.x' into backport/8.x/pr-197453
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula authored Nov 6, 2024
2 parents 701b348 + 7c70868 commit 0fb0557
Show file tree
Hide file tree
Showing 158 changed files with 2,041 additions and 1,670 deletions.
7 changes: 5 additions & 2 deletions dev_docs/tutorials/saved_objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { SavedObjectsType } from 'src/core/server';

export const dashboardVisualization: SavedObjectsType = {
name: 'dashboard_visualization', [1]
hidden: true,
hidden: true, [3]
switchToModelVersionAt: '8.10.0', // this is the default, feel free to omit it unless you intend to switch to using model versions before 8.10.0
namespaceType: 'multiple-isolated', [2]
mappings: {
Expand Down Expand Up @@ -46,6 +46,9 @@ these should follow our API URL path convention and always be written in snake c
that objects of this type can only exist in a single space. See
<DocLink id="kibDevDocsSavedObjectsIntro" section="sharing-saved-objects" text="Sharing Saved Objects"/> for more information.

[3] This field determines whether repositories have access to the type by default. Hidden types will not be automatically exposed via the Saved Objects Client APIs.
Hidden types must be listed in `SavedObjectsClientProviderOptions[includedHiddenTypes]` to be accessible by the client.

**src/plugins/my_plugin/server/saved_objects/index.ts**

```ts
Expand Down Expand Up @@ -301,4 +304,4 @@ export const foo: SavedObjectsType = {

[1] Needs to be `false` to use the `hiddenFromHttpApis` option

[2] Set this to `true` to build your own HTTP API and have complete control over the route handler.
[2] Set this to `true` to build your own HTTP API and have complete control over the route handler.
16 changes: 10 additions & 6 deletions examples/guided_onboarding_example/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters, CoreStart } from '@kbn/core/public';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { AppPluginStartDependencies } from './types';
import { GuidedOnboardingExampleApp } from './components/app';

export const renderApp = (
{ notifications }: CoreStart,
coreStart: CoreStart,
{ guidedOnboarding }: AppPluginStartDependencies,
{ element, history }: AppMountParameters
) => {
const { notifications } = coreStart;
ReactDOM.render(
<GuidedOnboardingExampleApp
notifications={notifications}
guidedOnboarding={guidedOnboarding}
history={history}
/>,
<KibanaRenderContextProvider {...coreStart}>
<GuidedOnboardingExampleApp
notifications={notifications}
guidedOnboarding={guidedOnboarding}
history={history}
/>
</KibanaRenderContextProvider>,
element
);

Expand Down
111 changes: 54 additions & 57 deletions examples/guided_onboarding_example/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
*/

import React from 'react';
import { FormattedMessage, I18nProvider } from '@kbn/i18n-react';
import { FormattedMessage } from '@kbn/i18n-react';
import { Routes, Router, Route } from '@kbn/shared-ux-router';
import { EuiPageTemplate } from '@elastic/eui';
import { CoreStart, ScopedHistory } from '@kbn/core/public';

import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public/types';
import { StepTwo } from './step_two';
import { StepOne } from './step_one';
Expand All @@ -30,62 +29,60 @@ export const GuidedOnboardingExampleApp = (props: GuidedOnboardingExampleAppDeps
const { notifications, guidedOnboarding, history } = props;

return (
<I18nProvider>
<EuiPageTemplate restrictWidth={true} panelled={true}>
<EuiPageTemplate.Header
pageTitle={
<FormattedMessage
id="guidedOnboardingExample.title"
defaultMessage="Guided onboarding examples"
/>
<EuiPageTemplate restrictWidth={true} panelled={true}>
<EuiPageTemplate.Header
pageTitle={
<FormattedMessage
id="guidedOnboardingExample.title"
defaultMessage="Guided onboarding examples"
/>
}
/>
{guidedOnboarding?.guidedOnboardingApi?.isEnabled ? (
<EuiPageTemplate.Section>
<Router history={history}>
<Routes>
<Route exact path="/">
<Main notifications={notifications} guidedOnboarding={guidedOnboarding} />
</Route>
<Route exact path="/stepOne">
<StepOne guidedOnboarding={guidedOnboarding} />
</Route>
<Route exact path="/stepTwo">
<StepTwo />
</Route>
<Route exact path="/stepThree">
<StepThree guidedOnboarding={guidedOnboarding} />
</Route>
<Route path="/stepFour/:indexName?">
<StepFour guidedOnboarding={guidedOnboarding} />
</Route>
</Routes>
</Router>
</EuiPageTemplate.Section>
) : (
<EuiPageTemplate.EmptyPrompt
iconType="error"
color="danger"
title={
<h2>
<FormattedMessage
id="guidedOnboardingExample.errorTitle"
defaultMessage="Guided onboarding is disabled"
/>
</h2>
}
body={
<p>
<FormattedMessage
id="guidedOnboardingExample.errorDescription"
defaultMessage="Make sure your Kibana instance runs on Cloud and/or
your user has access to Setup guides feature."
/>
</p>
}
/>
{guidedOnboarding?.guidedOnboardingApi?.isEnabled ? (
<EuiPageTemplate.Section>
<Router history={history}>
<Routes>
<Route exact path="/">
<Main notifications={notifications} guidedOnboarding={guidedOnboarding} />
</Route>
<Route exact path="/stepOne">
<StepOne guidedOnboarding={guidedOnboarding} />
</Route>
<Route exact path="/stepTwo">
<StepTwo />
</Route>
<Route exact path="/stepThree">
<StepThree guidedOnboarding={guidedOnboarding} />
</Route>
<Route path="/stepFour/:indexName?">
<StepFour guidedOnboarding={guidedOnboarding} />
</Route>
</Routes>
</Router>
</EuiPageTemplate.Section>
) : (
<EuiPageTemplate.EmptyPrompt
iconType="error"
color="danger"
title={
<h2>
<FormattedMessage
id="guidedOnboardingExample.errorTitle"
defaultMessage="Guided onboarding is disabled"
/>
</h2>
}
body={
<p>
<FormattedMessage
id="guidedOnboardingExample.errorDescription"
defaultMessage="Make sure your Kibana instance runs on Cloud and/or
your user has access to Setup guides feature."
/>
</p>
}
/>
)}
</EuiPageTemplate>
</I18nProvider>
)}
</EuiPageTemplate>
);
};
1 change: 1 addition & 0 deletions examples/guided_onboarding_example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@kbn/i18n",
"@kbn/guided-onboarding",
"@kbn/shared-ux-router",
"@kbn/react-kibana-context-render",
],
"exclude": [
"target/**/*",
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@
"@kbn/index-management-plugin": "link:x-pack/plugins/index_management",
"@kbn/index-management-shared-types": "link:x-pack/packages/index-management/index_management_shared_types",
"@kbn/index-patterns-test-plugin": "link:test/plugin_functional/plugins/index_patterns",
"@kbn/inference-common": "link:x-pack/packages/ai-infra/inference-common",
"@kbn/inference-plugin": "link:x-pack/plugins/inference",
"@kbn/inference_integration_flyout": "link:x-pack/packages/ml/inference_integration_flyout",
"@kbn/infra-forge": "link:x-pack/packages/kbn-infra-forge",
Expand Down Expand Up @@ -1025,10 +1026,10 @@
"@mapbox/mapbox-gl-rtl-text": "0.2.3",
"@mapbox/mapbox-gl-supported": "2.0.1",
"@mapbox/vector-tile": "1.3.1",
"@openfeature/core": "^1.4.0",
"@openfeature/core": "^1.5.0",
"@openfeature/launchdarkly-client-provider": "^0.3.0",
"@openfeature/server-sdk": "^1.15.1",
"@openfeature/web-sdk": "^1.2.4",
"@openfeature/server-sdk": "^1.16.1",
"@openfeature/web-sdk": "^1.3.1",
"@opentelemetry/api": "^1.1.0",
"@opentelemetry/api-metrics": "^0.31.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.34.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export interface SavedObjectsType<Attributes = any> {
* The hidden types will not be automatically exposed via the HTTP API.
* Therefore, that should prevent unexpected behavior in the client code, as all the interactions will be done via the plugin API.
*
* Hidden types must be listed to be accessible by the client.
*
* (await context.core).savedObjects.getClient({ includeHiddenTypes: [MY_PLUGIN_HIDDEN_SAVED_OBJECT_TYPE] })
*
* See {@link SavedObjectsServiceStart.createInternalRepository | createInternalRepository}.
*
*/
hidden: boolean;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { LoadingIndicator } from '../../components/common/loading_indicator';
import { useDataView } from '../../hooks/use_data_view';
import type { ContextHistoryLocationState } from './services/locator';
import { useDiscoverServices } from '../../hooks/use_discover_services';
import { useRootProfile } from '../../context_awareness';

export interface ContextUrlParams {
dataViewId: string;
Expand Down Expand Up @@ -47,8 +48,8 @@ export function ContextAppRoute() {
const { dataViewId: encodedDataViewId, id } = useParams<ContextUrlParams>();
const dataViewId = decodeURIComponent(encodedDataViewId);
const anchorId = decodeURIComponent(id);

const { dataView, error } = useDataView({ index: locationState?.dataViewSpec || dataViewId });
const rootProfileState = useRootProfile();

if (error) {
return (
Expand All @@ -72,9 +73,13 @@ export function ContextAppRoute() {
);
}

if (!dataView) {
if (!dataView || rootProfileState.rootProfileLoading) {
return <LoadingIndicator />;
}

return <ContextApp anchorId={anchorId} dataView={dataView} referrer={locationState?.referrer} />;
return (
<rootProfileState.AppWrapper>
<ContextApp anchorId={anchorId} dataView={dataView} referrer={locationState?.referrer} />
</rootProfileState.AppWrapper>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { firstValueFrom, lastValueFrom } from 'rxjs';
import { lastValueFrom } from 'rxjs';
import { i18n } from '@kbn/i18n';
import { ISearchSource, EsQuerySortValue } from '@kbn/data-plugin/public';
import type { DataView } from '@kbn/data-views-plugin/public';
Expand All @@ -29,11 +29,7 @@ export async function fetchAnchor(
anchorRow: DataTableRecord;
interceptedWarnings: SearchResponseWarning[];
}> {
const { core, profilesManager } = services;

const solutionNavId = await firstValueFrom(core.chrome.getActiveSolutionNavId$());
await profilesManager.resolveRootProfile({ solutionNavId });
await profilesManager.resolveDataSourceProfile({
await services.profilesManager.resolveDataSourceProfile({
dataSource: createDataSource({ dataView, query: undefined }),
dataView,
query: { query: '', language: 'kuery' },
Expand Down Expand Up @@ -68,7 +64,7 @@ export async function fetchAnchor(
});

return {
anchorRow: profilesManager.resolveDocumentProfile({
anchorRow: services.profilesManager.resolveDocumentProfile({
record: buildDataTableRecord(doc, dataView, true),
}),
interceptedWarnings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import React, { useCallback, useEffect } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { firstValueFrom } from 'rxjs';
import { EuiCallOut, EuiLink, EuiLoadingSpinner, EuiPage, EuiPageBody } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { ElasticRequestState } from '@kbn/unified-doc-viewer';
Expand All @@ -31,18 +30,16 @@ export interface DocProps extends EsDocSearchProps {
export function Doc(props: DocProps) {
const { dataView } = props;
const services = useDiscoverServices();
const { locator, chrome, docLinks, core, profilesManager } = services;
const { locator, chrome, docLinks, profilesManager } = services;
const indexExistsLink = docLinks.links.apis.indexExists;

const onBeforeFetch = useCallback(async () => {
const solutionNavId = await firstValueFrom(core.chrome.getActiveSolutionNavId$());
await profilesManager.resolveRootProfile({ solutionNavId });
await profilesManager.resolveDataSourceProfile({
dataSource: dataView?.id ? createDataViewDataSource({ dataViewId: dataView.id }) : undefined,
dataView,
query: { query: '', language: 'kuery' },
});
}, [profilesManager, core, dataView]);
}, [profilesManager, dataView]);

const onProcessRecord = useCallback(
(record: DataTableRecord) => {
Expand Down
11 changes: 9 additions & 2 deletions src/plugins/discover/public/application/doc/single_doc_route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useDiscoverServices } from '../../hooks/use_discover_services';
import { DiscoverError } from '../../components/common/error_alert';
import { useDataView } from '../../hooks/use_data_view';
import { DocHistoryLocationState } from './locator';
import { useRootProfile } from '../../context_awareness';

export interface DocUrlParams {
dataViewId: string;
Expand Down Expand Up @@ -53,6 +54,8 @@ export const SingleDocRoute = () => {
index: locationState?.dataViewSpec || decodeURIComponent(dataViewId),
});

const rootProfileState = useRootProfile();

if (error) {
return (
<EuiEmptyPrompt
Expand All @@ -75,7 +78,7 @@ export const SingleDocRoute = () => {
);
}

if (!dataView) {
if (!dataView || rootProfileState.rootProfileLoading) {
return <LoadingIndicator />;
}

Expand All @@ -94,5 +97,9 @@ export const SingleDocRoute = () => {
);
}

return <Doc id={id} index={index} dataView={dataView} referrer={locationState?.referrer} />;
return (
<rootProfileState.AppWrapper>
<Doc id={id} index={index} dataView={dataView} referrer={locationState?.referrer} />
</rootProfileState.AppWrapper>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React from 'react';
import React, { ReactNode } from 'react';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import { waitFor } from '@testing-library/react';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
Expand Down Expand Up @@ -50,6 +50,7 @@ jest.mock('../../context_awareness', () => {
...originalModule,
useRootProfile: () => ({
rootProfileLoading: mockRootProfileLoading,
AppWrapper: ({ children }: { children: ReactNode }) => <>{children}</>,
}),
};
});
Expand Down
Loading

0 comments on commit 0fb0557

Please sign in to comment.