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.4] Use theme for the telemetry opt-in banner (#139911) #140001

Merged
merged 1 commit into from
Sep 5, 2022
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 src/plugins/telemetry/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
overlayServiceMock,
httpServiceMock,
notificationServiceMock,
themeServiceMock,
} from '@kbn/core/public/mocks';
import { TelemetryService } from './services/telemetry_service';
import { TelemetryNotifications } from './services/telemetry_notifications/telemetry_notifications';
Expand Down Expand Up @@ -75,6 +76,7 @@ export function mockTelemetryNotifications({
return new TelemetryNotifications({
http: httpServiceMock.createSetupContract(),
overlays: overlayServiceMock.createStartContract(),
theme: themeServiceMock.createStartContract(),
telemetryService,
telemetryConstants: mockTelemetryConstants(),
});
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/telemetry/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
analytics,
http,
overlays,
theme,
application,
savedObjects,
docLinks,
Expand All @@ -213,6 +214,7 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
const telemetryNotifications = new TelemetryNotifications({
http,
overlays,
theme,
telemetryService: this.telemetryService,
telemetryConstants,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
*/

import { renderOptedInNoticeBanner } from './render_opted_in_notice_banner';
import { overlayServiceMock, httpServiceMock } from '@kbn/core/public/mocks';
import { overlayServiceMock, httpServiceMock, themeServiceMock } from '@kbn/core/public/mocks';
import { mockTelemetryConstants } from '../../mocks';

describe('renderOptedInNoticeBanner', () => {
it('adds a banner to banners with priority of 10000', () => {
const bannerID = 'brucer-wayne';
const overlays = overlayServiceMock.createStartContract();
const mockHttp = httpServiceMock.createStartContract();
const theme = themeServiceMock.createStartContract();
const telemetryConstants = mockTelemetryConstants();
overlays.banners.add.mockReturnValue(bannerID);

const returnedBannerId = renderOptedInNoticeBanner({
http: mockHttp,
onSeen: jest.fn(),
overlays,
theme,
telemetryConstants,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@
*/

import React from 'react';
import type { HttpStart, OverlayStart } from '@kbn/core/public';
import type { HttpStart, OverlayStart, ThemeServiceStart } from '@kbn/core/public';
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
import { withSuspense } from '@kbn/shared-ux-utility';
import type { TelemetryConstants } from '../..';

interface RenderBannerConfig {
http: HttpStart;
overlays: OverlayStart;
theme: ThemeServiceStart;
onSeen: () => void;
telemetryConstants: TelemetryConstants;
}

export function renderOptedInNoticeBanner({
onSeen,
overlays,
http,
theme,
telemetryConstants,
}: RenderBannerConfig) {
const OptedInNoticeBannerLazy = withSuspense(
Expand All @@ -36,7 +39,8 @@ export function renderOptedInNoticeBanner({
onSeenBanner={onSeen}
http={http}
telemetryConstants={telemetryConstants}
/>
/>,
{ theme$: theme.theme$ }
);
const bannerId = overlays.banners.add(mount, 10000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { HttpStart, OverlayStart } from '@kbn/core/public';
import { HttpStart, OverlayStart, ThemeServiceStart } from '@kbn/core/public';
import { renderOptedInNoticeBanner } from './render_opted_in_notice_banner';
import { renderOptInBanner } from './render_opt_in_banner';
import { TelemetryService } from '../telemetry_service';
Expand All @@ -15,6 +15,7 @@ import { TelemetryConstants } from '../..';
interface TelemetryNotificationsConstructor {
http: HttpStart;
overlays: OverlayStart;
theme: ThemeServiceStart;
telemetryService: TelemetryService;
telemetryConstants: TelemetryConstants;
}
Expand All @@ -25,6 +26,7 @@ interface TelemetryNotificationsConstructor {
export class TelemetryNotifications {
private readonly http: HttpStart;
private readonly overlays: OverlayStart;
private readonly theme: ThemeServiceStart;
private readonly telemetryConstants: TelemetryConstants;
private readonly telemetryService: TelemetryService;
private optedInNoticeBannerId?: string;
Expand All @@ -33,12 +35,14 @@ export class TelemetryNotifications {
constructor({
http,
overlays,
theme,
telemetryService,
telemetryConstants,
}: TelemetryNotificationsConstructor) {
this.telemetryService = telemetryService;
this.http = http;
this.overlays = overlays;
this.theme = theme;
this.telemetryConstants = telemetryConstants;
}

Expand All @@ -59,6 +63,7 @@ export class TelemetryNotifications {
http: this.http,
onSeen: this.setOptedInNoticeSeen,
overlays: this.overlays,
theme: this.theme,
telemetryConstants: this.telemetryConstants,
});

Expand Down