Skip to content

Commit

Permalink
Preparation for High Contrast Mode, Analytics Experience domains
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Dec 2, 2024
1 parent 6c0cf0e commit 72c81af
Show file tree
Hide file tree
Showing 100 changed files with 281 additions and 210 deletions.
2 changes: 1 addition & 1 deletion examples/controls_example/public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const App = ({
}

return (
<KibanaRenderContextProvider i18n={core.i18n} theme={core.theme}>
<KibanaRenderContextProvider {...core}>
<EuiPage>
<EuiPageBody>
<EuiPageSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,7 @@ export const ReactControlExample = ({
<EuiCodeBlock language="json">
{JSON.stringify(controlGroupApi?.serializeState(), null, 2)}
</EuiCodeBlock>,
{
theme: core.theme,
i18n: core.i18n,
}
core
)
);
}}
Expand Down
4 changes: 2 additions & 2 deletions examples/discover_customization_examples/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export class DiscoverCustomizationExamplesPlugin implements Plugin {
title: PLUGIN_NAME,
visibleIn: [],
mount: async (appMountParams) => {
const [_, { discover, data }] = await core.getStartServices();
const [{ userProfile }, { discover, data }] = await core.getStartServices();

ReactDOM.render(
<I18nProvider>
<KibanaThemeProvider theme={core.theme}>
<KibanaThemeProvider theme={core.theme} userProfile={userProfile}>
<Router history={appMountParams.history}>
<Routes>
<Route>
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddable_examples/public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const App = ({
}, [pages]);

return (
<KibanaRenderContextProvider i18n={core.i18n} theme={core.theme}>
<KibanaRenderContextProvider {...core}>
<Router basename={mountParams.appBasePath}>
<EuiPageTemplate restrictWidth={true} offset={0}>
<EuiPageTemplate.Sidebar sticky={true}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const getDataTableFactory = (
width: 100%;
`}
>
<KibanaRenderContextProvider theme={core.theme} i18n={core.i18n}>
<KibanaRenderContextProvider {...core}>
<KibanaContextProvider services={allServices}>
<CellActionsProvider
getTriggerCompatibleActions={services.uiActions.getTriggerCompatibleActions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ export const openSavedBookEditor = (
resolve({ addToLibrary });
}}
/>,
{
theme: core.theme,
i18n: core.i18n,
}
core
),
{
type: isCreate ? 'overlay' : 'push',
Expand Down
5 changes: 4 additions & 1 deletion examples/expressions_explorer/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
I18nStart,
IUiSettingsClient,
ThemeServiceStart,
UserProfileService,
} from '@kbn/core/public';
import { ExpressionsStart } from '@kbn/expressions-plugin/public';
import { Start as InspectorStart } from '@kbn/inspector-plugin/public';
Expand All @@ -41,6 +42,7 @@ interface Props {
inspector: InspectorStart;
actions: UiActionsStart;
uiSettings: IUiSettingsClient;
userProfile: UserProfileService;
settings: SettingsStart;
theme: ThemeServiceStart;
i18n: I18nStart;
Expand All @@ -54,13 +56,14 @@ const ExpressionsExplorer = ({
settings,
i18n,
theme,
userProfile,
}: Props) => {
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings,
settings,
theme,
});
const startServices = { i18n, theme };
const startServices = { i18n, theme, userProfile };
return (
<KibanaRenderContextProvider {...startServices}>
<KibanaReactContextProvider>
Expand Down
1 change: 1 addition & 0 deletions examples/expressions_explorer/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class ExpressionsExplorerPlugin implements Plugin<void, void, SetupDeps,
inspector: depsStart.inspector,
actions: depsStart.uiActions,
uiSettings: core.uiSettings,
userProfile: coreStart.userProfile,
settings: core.settings,
theme: coreStart.theme,
i18n: coreStart.i18n,
Expand Down
5 changes: 1 addition & 4 deletions examples/grid_example/public/get_panel_id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ export const getPanelId = async ({
session.close();
}}
/>,
{
theme: coreStart.theme,
i18n: coreStart.i18n,
}
coreStart
)
);
});
Expand Down
2 changes: 1 addition & 1 deletion examples/portable_dashboards_example/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const PortableDashboardsDemos = ({
history: AppMountParameters['history'];
}) => {
return (
<KibanaRenderContextProvider i18n={coreStart.i18n} theme={coreStart.theme}>
<KibanaRenderContextProvider {...coreStart}>
<Router history={history}>
<Routes>
<Route exact path="/">
Expand Down
6 changes: 3 additions & 3 deletions examples/resizable_layout_examples/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
import type { AppMountParameters } from '@kbn/core/public';
import type { AppMountParameters, CoreStart } from '@kbn/core/public';
import { I18nProvider } from '@kbn/i18n-react';
import React, { ReactNode, useState } from 'react';
import ReactDOM from 'react-dom';
Expand Down Expand Up @@ -98,10 +98,10 @@ const ResizableSection = ({
);
};

export const renderApp = ({ element, theme$ }: AppMountParameters) => {
export const renderApp = (coreStart: CoreStart, { element }: AppMountParameters) => {
ReactDOM.render(
<I18nProvider>
<KibanaThemeProvider theme={{ theme$ }}>
<KibanaThemeProvider {...coreStart}>
<div
css={css`
height: calc(100vh - var(--euiFixedHeadersOffset, 0));
Expand Down
3 changes: 2 additions & 1 deletion examples/resizable_layout_examples/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ export class ResizableLayoutExamplesPlugin implements Plugin {
title: PLUGIN_NAME,
visibleIn: [],
mount: async (params: AppMountParameters) => {
const [coreStart] = await core.getStartServices();
// Load application bundle
const { renderApp } = await import('./application');
// Render the application
return renderApp(params);
return renderApp(coreStart, params);
},
});

Expand Down
14 changes: 6 additions & 8 deletions examples/search_examples/public/search/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ import { PLUGIN_ID, PLUGIN_NAME, SERVER_SEARCH_ROUTE_PATH } from '../../common';
import { IMyStrategyResponse } from '../../common/types';

interface SearchExamplesAppDeps
extends Pick<CoreStart, 'notifications' | 'http' | 'analytics' | 'i18n' | 'theme'> {
extends Pick<
CoreStart,
'notifications' | 'http' | 'analytics' | 'i18n' | 'theme' | 'userProfile'
> {
navigation: NavigationPublicPluginStart;
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
Expand Down Expand Up @@ -230,13 +233,8 @@ export const SearchExamplesApp = ({
</EuiText>
);
notifications.toasts.addSuccess(
{
title: 'Query result',
text: toMountPoint(message, startServices),
},
{
toastLifeTimeMs: 300000,
}
{ title: 'Query result', text: toMountPoint(message, startServices) },
{ toastLifeTimeMs: 300000 }
);
if (res.warning) {
notifications.toasts.addWarning({
Expand Down
2 changes: 2 additions & 0 deletions examples/search_examples/public/search_sessions/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface SearchSessionsExampleAppDeps {
analytics: CoreStart['analytics'];
i18n: CoreStart['i18n'];
theme: CoreStart['theme'];
userProfile: CoreStart['userProfile'];
navigation: NavigationPublicPluginStart;
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
Expand Down Expand Up @@ -674,6 +675,7 @@ function doSearch(
analytics: CoreStart['analytics'];
i18n: CoreStart['i18n'];
theme: CoreStart['theme'];
userProfile: CoreStart['userProfile'];
}
): Promise<{ request: IEsSearchRequest; response: IEsSearchResponse; tookMs?: number }> {
if (!dataView) return Promise.reject('Select a data view');
Expand Down
4 changes: 2 additions & 2 deletions examples/unified_field_list_examples/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import { UnifiedFieldListExampleApp } from './example_app';
export const renderApp = (
core: CoreStart,
deps: AppPluginStartDependencies,
{ element, theme$ }: AppMountParameters
{ element }: AppMountParameters
) => {
ReactDOM.render(
<I18nProvider>
<KibanaThemeProvider theme={{ theme$ }}>
<KibanaThemeProvider {...core}>
<UnifiedFieldListExampleApp
services={{
core,
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-search-response-warnings/src/handle_warnings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
AnalyticsServiceStart,
NotificationsStart,
ThemeServiceStart,
UserProfileService,
} from '@kbn/core/public';
import { toMountPoint } from '@kbn/react-kibana-mount';
import type { I18nStart } from '@kbn/core-i18n-browser';
Expand All @@ -36,6 +37,7 @@ interface Services {
inspector: InspectorStart;
notifications: NotificationsStart;
theme: ThemeServiceStart;
userProfile: UserProfileService;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface StartDeps {
expression: ExpressionsServiceStart;
}

export type StartServices = Pick<CoreStart, 'analytics' | 'i18n' | 'theme'>;
export type StartServices = Pick<CoreStart, 'analytics' | 'i18n' | 'theme' | 'userProfile'>;

export type ExpressionXyPluginSetup = void;
export type ExpressionXyPluginStart = void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ export const openEditControlGroupFlyout = (
onDeleteAll={() => onDeleteAll(overlay)}
onCancel={() => closeOverlay(overlay)}
/>,
{
theme: coreServices.theme,
i18n: coreServices.i18n,
}
coreServices
),
{
'aria-label': i18n.translate('controls.controlGroup.manageControl', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ export const openDataControlEditor = <
onSave({ type: selectedControlType, state });
}}
/>,
{
theme: coreServices.theme,
i18n: coreServices.i18n,
}
coreServices
),
{
size: 'm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ export class CopyToDashboardAction implements Action<EmbeddableApiContext> {
public async execute({ embeddable }: EmbeddableApiContext) {
if (!apiIsCompatible(embeddable)) throw new IncompatibleActionError();

const { theme, i18n } = coreServices;
const session = coreServices.overlays.openModal(
toMountPoint(<CopyToDashboardModal closeModal={() => session.close()} api={embeddable} />, {
theme,
i18n,
}),
toMountPoint(
<CopyToDashboardModal closeModal={() => session.close()} api={embeddable} />,
coreServices
),
{
maxWidth: 400,
'data-test-subj': 'copyToDashboardPanel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const DashboardNoMatch = ({ history }: { history: RouteComponentProps['hi
/>
</p>
</EuiCallOut>,
{ analytics: coreServices.analytics, i18n: coreServices.i18n, theme: coreServices.theme }
coreServices
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const EditorMenu = ({ createNewVisType, isDisabled }: EditorMenuProps) =>
/>
);
}),
{ analytics: coreServices.analytics, theme: coreServices.theme, i18n: coreServices.i18n }
coreServices
);

dashboardApi.openOverlay(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function openSettingsFlyout(dashboardApi: DashboardApi) {
}}
/>
</DashboardContext.Provider>,
{ analytics: coreServices.analytics, i18n: coreServices.i18n, theme: coreServices.theme }
coreServices
),
{
size: 's',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,7 @@ export class DashboardContainer
this.domNode.className = 'dashboardContainer';

ReactDOM.render(
<KibanaRenderContextProvider
analytics={coreServices.analytics}
i18n={coreServices.i18n}
theme={coreServices.theme}
>
<KibanaRenderContextProvider {...coreServices}>
<ExitFullScreenButtonKibanaProvider
coreStart={{ chrome: coreServices.chrome, customBranding: coreServices.customBranding }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const confirmCreateWithUnsaved = (
</div>
</EuiOutsideClickDetector>
</EuiFocusTrap>,
{ analytics: coreServices.analytics, i18n: coreServices.i18n, theme: coreServices.theme }
coreServices
),
{
'data-test-subj': 'dashboardCreateConfirmModal',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import type {
IUiSettingsClient,
ThemeServiceStart,
ToastsSetup,
UserProfileService,
} from '@kbn/core/public';

import { BatchedFunc, BfetchPublicSetup, DISABLE_BFETCH } from '@kbn/bfetch-plugin/public';
Expand Down Expand Up @@ -135,6 +136,7 @@ export class SearchInterceptor {
analytics: Pick<AnalyticsServiceStart, 'reportEvent'>;
i18n: I18nStart;
theme: Pick<ThemeServiceStart, 'theme$'>;
userProfile: UserProfileService;
};

/*
Expand All @@ -144,10 +146,10 @@ export class SearchInterceptor {
this.deps.http.addLoadingCountSource(this.pendingCount$);

this.deps.startServices.then(([coreStart, depsStart]) => {
const { application, docLinks, analytics, i18n: i18nStart, theme } = coreStart;
const { application, docLinks, analytics, i18n: i18nStart, theme, userProfile } = coreStart;
this.application = application;
this.docLinks = docLinks;
this.startRenderServices = { analytics, i18n: i18nStart, theme };
this.startRenderServices = { analytics, i18n: i18nStart, theme, userProfile };
this.inspector = (depsStart as SearchServiceStartDependencies).inspector;
});

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/data/public/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
http,
theme,
uiSettings,
userProfile,
chrome,
application,
notifications,
Expand Down Expand Up @@ -259,6 +260,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
inspector,
notifications,
theme,
userProfile,
};

const searchSourceDependencies: SearchSourceDependencies = {
Expand Down Expand Up @@ -314,7 +316,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
tourDisabled: screenshotMode.isScreenshotMode(),
})
),
{ analytics, i18n: i18nStart, theme }
{ analytics, i18n: i18nStart, theme, userProfile }
),
});
}
Expand Down
Loading

0 comments on commit 72c81af

Please sign in to comment.