Skip to content
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

[8.x] Preparation for High Contrast Mode, Core/SharedUX domains (#202606) #203147

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/developer_examples/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
AppMountParameters,
I18nStart,
ThemeServiceStart,
UserProfileService,
} from '@kbn/core/public';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { ExampleDefinition } from './types';
Expand All @@ -36,6 +37,7 @@ interface StartServices {
analytics: Pick<AnalyticsServiceStart, 'reportEvent'>;
i18n: I18nStart;
theme: Pick<ThemeServiceStart, 'theme$'>;
userProfile: UserProfileService;
}

interface Props {
Expand Down
4 changes: 2 additions & 2 deletions examples/developer_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export class DeveloperExamplesPlugin implements Plugin<DeveloperExamplesSetup, v
async mount(params: AppMountParameters) {
const { renderApp } = await import('./app');
const [coreStart] = await core.getStartServices();
const { analytics, i18n, theme } = coreStart;
const { analytics, i18n, theme, userProfile } = coreStart;
return renderApp(
{
startServices: { analytics, i18n, theme },
startServices: { analytics, i18n, theme, userProfile },
examples,
navigateToApp: (appId: string) => coreStart.application.navigateToApp(appId),
getUrlForApp: (appId: string) => coreStart.application.getUrlForApp(appId),
Expand Down
6 changes: 4 additions & 2 deletions examples/routing_example/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
CoreStart,
I18nStart,
ThemeServiceStart,
UserProfileService,
} from '@kbn/core/public';
import type { IHttpFetchError } from '@kbn/core-http-browser';
import {
Expand All @@ -25,6 +26,7 @@ interface StartServices {
analytics: Pick<AnalyticsServiceStart, 'reportEvent'>;
i18n: I18nStart;
theme: Pick<ThemeServiceStart, 'theme$'>;
userProfile: UserProfileService;
}

export interface Services {
Expand All @@ -37,8 +39,8 @@ export interface Services {
}

export function getServices(core: CoreStart): Services {
const { analytics, i18n, theme } = core;
const startServices = { analytics, i18n, theme };
const { analytics, i18n, theme, userProfile } = core;
const startServices = { analytics, i18n, theme, userProfile };

return {
startServices,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { toMountPoint } from '@kbn/react-kibana-mount';

export const ACTION_HELLO_WORLD = 'ACTION_HELLO_WORLD';

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

export const createHelloWorldActionDefinition = (
getStartServices: () => Promise<StartServices>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const DYNAMIC_ACTION_ID = `${ACTION_HELLO_WORLD}-Waldo`;

interface Props {
uiActionsStartService: UiActionsStart;
startServices: Pick<CoreStart, 'overlays' | 'analytics' | 'i18n' | 'theme'>;
startServices: Pick<CoreStart, 'overlays' | 'analytics' | 'i18n' | 'theme' | 'userProfile'>;
}

export const HelloWorldExample = ({ uiActionsStartService, startServices }: Props) => {
Expand Down
1 change: 1 addition & 0 deletions packages/cloud/connection_details/kibana/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ConnectionDetailsGlobalDependencies {
http: CoreStart['http'];
application: CoreStart['application'];
overlays: CoreStart['overlays'];
userProfile: CoreStart['userProfile'];
};
plugins: {
cloud?: CloudStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface OpenConnectionDetailsParams {
i18n: CoreStart['i18n'];
analytics?: CoreStart['analytics'];
theme: CoreStart['theme'];
userProfile: CoreStart['userProfile'];
};
};
}
Expand Down
2 changes: 2 additions & 0 deletions packages/content-management/content_editor/src/services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { I18nStart } from '@kbn/core-i18n-browser';
import type { MountPoint, OverlayRef } from '@kbn/core-mount-utils-browser';
import type { OverlayFlyoutOpenOptions } from '@kbn/core-overlays-browser';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { UserProfileService } from '@kbn/core-user-profile-browser';
import { toMountPoint } from '@kbn/react-kibana-mount';

type NotifyFn = (title: JSX.Element, text?: string) => void;
Expand Down Expand Up @@ -68,6 +69,7 @@ interface ContentEditorStartServices {
analytics: Pick<AnalyticsServiceStart, 'reportEvent'>;
i18n: I18nStart;
theme: Pick<ThemeServiceStart, 'theme$'>;
userProfile: UserProfileService;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/content-management/content_editor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@kbn/test-jest-helpers",
"@kbn/react-kibana-mount",
"@kbn/content-management-user-profiles",
"@kbn/core-user-profile-browser",
],
"exclude": [
"target/**/*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type { I18nStart } from '@kbn/core-i18n-browser';
import type { MountPoint, OverlayRef } from '@kbn/core-mount-utils-browser';
import type { OverlayFlyoutOpenOptions } from '@kbn/core-overlays-browser';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { UserProfileServiceStart } from '@kbn/core-user-profile-browser';
import type { UserProfileService, UserProfileServiceStart } from '@kbn/core-user-profile-browser';
import type { FormattedRelative } from '@kbn/i18n-react';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { RedirectAppLinksKibanaProvider } from '@kbn/shared-ux-link-redirect-app';
Expand Down Expand Up @@ -100,6 +100,7 @@ interface TableListViewStartServices {
analytics: Pick<AnalyticsServiceStart, 'reportEvent'>;
i18n: I18nStart;
theme: Pick<ThemeServiceStart, 'theme$'>;
userProfile: UserProfileService;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
import type { AnalyticsServiceStart } from '@kbn/core-analytics-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { UserProfileService } from '@kbn/core-user-profile-browser';
import { renderApp as renderStatusApp } from './status';
import {
renderApp as renderErrorApp,
Expand All @@ -45,6 +46,7 @@ export interface CoreAppsServiceStartDeps {
analytics: AnalyticsServiceStart;
i18n: I18nStart;
theme: ThemeServiceStart;
userProfile: UserProfileService;
}

export class CoreAppsService {
Expand Down Expand Up @@ -86,9 +88,7 @@ export class CoreAppsService {
http,
notifications,
uiSettings,
analytics,
i18n,
theme,
...startDeps
}: CoreAppsServiceStartDeps) {
if (!application.history) {
return;
Expand All @@ -101,7 +101,7 @@ export class CoreAppsService {
uiSettings,
});

setupPublicBaseUrlConfigWarning({ docLinks, http, notifications, analytics, i18n, theme });
setupPublicBaseUrlConfigWarning({ docLinks, http, notifications, ...startDeps });
}

public stop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { notificationServiceMock } from '@kbn/core-notifications-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { userProfileServiceMock } from '@kbn/core-user-profile-browser-mocks';

import { setupPublicBaseUrlConfigWarning } from './public_base_url';

Expand All @@ -22,12 +23,8 @@ describe('publicBaseUrl warning', () => {
const i18nStart = i18nServiceMock.createStartContract();
const analytics = analyticsServiceMock.createAnalyticsServiceStart();
const theme = themeServiceMock.createStartContract();
const startServices = {
notifications,
analytics,
i18n: i18nStart,
theme,
};
const userProfile = userProfileServiceMock.createStart();
const startServices = { notifications, analytics, i18n: i18nStart, theme, userProfile };
const addWarningToastSpy = jest.spyOn(notifications.toasts, 'addWarning');

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { DocLinksStart } from '@kbn/core-doc-links-browser';
import type { AnalyticsServiceStart } from '@kbn/core-analytics-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { UserProfileService } from '@kbn/core-user-profile-browser';
import type { InternalHttpStart } from '@kbn/core-http-browser-internal';
import type { NotificationsStart } from '@kbn/core-notifications-browser';
import { mountReactNode } from '@kbn/core-mount-utils-browser-internal';
Expand All @@ -35,6 +36,7 @@ interface Deps {
analytics: AnalyticsServiceStart;
i18n: I18nStart;
theme: ThemeServiceStart;
userProfile: UserProfileService;
}

export const setupPublicBaseUrlConfigWarning = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
"@kbn/react-kibana-context-render",
"@kbn/core-analytics-browser-mocks",
"@kbn/core-i18n-browser-mocks",
"@kbn/core-theme-browser-mocks"
"@kbn/core-theme-browser-mocks",
"@kbn/core-user-profile-browser",
"@kbn/core-user-profile-browser-mocks"
],
"exclude": [
"target/**/*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { customBrandingServiceMock } from '@kbn/core-custom-branding-browser-moc
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { userProfileServiceMock } from '@kbn/core-user-profile-browser-mocks';
import { getAppInfo } from '@kbn/core-application-browser-internal';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { findTestSubject } from '@kbn/test-jest-helpers';
Expand Down Expand Up @@ -55,6 +56,7 @@ function defaultStartDeps(availableApps?: App[], currentAppId?: string) {
analytics: analyticsServiceMock.createAnalyticsServiceStart(),
i18n: i18nServiceMock.createStartContract(),
theme: themeServiceMock.createStartContract(),
userProfile: userProfileServiceMock.createStart(),
application: applicationServiceMock.createInternalStartContract(currentAppId),
docLinks: docLinksServiceMock.createStartContract(),
http: httpServiceMock.createStartContract(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@kbn/core-theme-browser-mocks",
"@kbn/react-kibana-context-render",
"@kbn/recently-accessed",
"@kbn/core-user-profile-browser-mocks",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { i18n } from '@kbn/i18n';
import { Subscription } from 'rxjs';
import type { AnalyticsServiceStart, AnalyticsServiceSetup } from '@kbn/core-analytics-browser';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { UserProfileService } from '@kbn/core-user-profile-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
import type { OverlayStart } from '@kbn/core-overlays-browser';
Expand All @@ -29,6 +30,7 @@ export interface StartDeps {
i18n: I18nStart;
overlays: OverlayStart;
theme: ThemeServiceStart;
userProfile: UserProfileService;
analytics: AnalyticsServiceStart;
targetDomElement: HTMLElement;
}
Expand Down Expand Up @@ -62,36 +64,26 @@ export class NotificationsService {
return notificationSetup;
}

public start({
analytics,
i18n: i18nDep,
overlays,
theme,
targetDomElement,
}: StartDeps): NotificationsStart {
public start({ overlays, targetDomElement, ...startDeps }: StartDeps): NotificationsStart {
this.targetDomElement = targetDomElement;
const toastsContainer = document.createElement('div');
targetDomElement.appendChild(toastsContainer);

const eventReporter = new EventReporter({ analytics });
const eventReporter = new EventReporter({ analytics: startDeps.analytics });

return {
toasts: this.toasts.start({
eventReporter,
i18n: i18nDep,
overlays,
analytics,
theme,
targetDomElement: toastsContainer,
...startDeps,
}),
showErrorDialog: ({ title, error }) =>
showErrorDialog({
title,
error,
openModal: overlays.openModal,
analytics,
i18n: i18nDep,
theme,
...startDeps,
}),
};
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { mountWithIntl } from '@kbn/test-jest-helpers';
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { ErrorToast } from './error_toast';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { userProfileServiceMock } from '@kbn/core-user-profile-browser-mocks';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';

interface ErrorToastProps {
Expand All @@ -25,6 +26,7 @@ interface ErrorToastProps {
let openModal: jest.Mock;
const mockAnalytics = analyticsServiceMock.createAnalyticsServiceStart();
const mockTheme = themeServiceMock.createStartContract();
const mockUserProfile = userProfileServiceMock.createStart();
const mockI18n = i18nServiceMock.createStartContract();

beforeEach(() => (openModal = jest.fn()));
Expand All @@ -39,6 +41,7 @@ function render(props: ErrorToastProps = {}) {
analytics={mockAnalytics}
i18n={mockI18n}
theme={mockTheme}
userProfile={mockUserProfile}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import type { AnalyticsServiceStart } from '@kbn/core-analytics-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type { OverlayStart } from '@kbn/core-overlays-browser';
import { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { UserProfileService } from '@kbn/core-user-profile-browser';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';

interface StartServices {
analytics: AnalyticsServiceStart;
i18n: I18nStart;
userProfile: UserProfileService;
theme: ThemeServiceStart;
}

Expand Down Expand Up @@ -62,7 +64,10 @@ export function showErrorDialog({
error,
openModal,
...startServices
}: Pick<ErrorToastProps, 'error' | 'title' | 'openModal' | 'analytics' | 'i18n' | 'theme'>) {
}: Pick<
ErrorToastProps,
'error' | 'title' | 'openModal' | 'analytics' | 'i18n' | 'userProfile' | 'theme'
>) {
let text = '';

if (isRequestError(error)) {
Expand Down
Loading
Loading