mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Security Solution] Fix 'disable usage data here.' link (#86452)
* fix 'disable usage data here.' link * update snapshot * update link * update mocks Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
6a517411eb
commit
fc7ae0e1a6
9 changed files with 32 additions and 9 deletions
|
@ -49,7 +49,7 @@ export const LOCALSTORAGE_KEY = 'telemetry.data';
|
|||
/**
|
||||
* Link to Advanced Settings.
|
||||
*/
|
||||
export const PATH_TO_ADVANCED_SETTINGS = 'management/kibana/settings';
|
||||
export const PATH_TO_ADVANCED_SETTINGS = '/app/management/kibana/settings';
|
||||
|
||||
/**
|
||||
* Link to the Elastic Telemetry privacy statement.
|
||||
|
|
|
@ -10,7 +10,7 @@ exports[`OptInDetailsComponent renders as expected 1`] = `
|
|||
values={
|
||||
Object {
|
||||
"disableLink": <EuiLink
|
||||
href="management/kibana/settings"
|
||||
href="/app/management/kibana/settings"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<FormattedMessage
|
||||
|
|
|
@ -20,15 +20,23 @@ import React from 'react';
|
|||
import { EuiButton } from '@elastic/eui';
|
||||
import { shallowWithIntl } from '@kbn/test/jest';
|
||||
import { OptedInNoticeBanner } from './opted_in_notice_banner';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { httpServiceMock } from '../../../../core/public/http/http_service.mock';
|
||||
|
||||
const mockHttp = httpServiceMock.createStartContract();
|
||||
|
||||
describe('OptInDetailsComponent', () => {
|
||||
it('renders as expected', () => {
|
||||
expect(shallowWithIntl(<OptedInNoticeBanner onSeenBanner={() => {}} />)).toMatchSnapshot();
|
||||
expect(
|
||||
shallowWithIntl(<OptedInNoticeBanner onSeenBanner={() => {}} http={mockHttp} />)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('fires the "onSeenBanner" prop when a link is clicked', () => {
|
||||
const onLinkClick = jest.fn();
|
||||
const component = shallowWithIntl(<OptedInNoticeBanner onSeenBanner={onLinkClick} />);
|
||||
const component = shallowWithIntl(
|
||||
<OptedInNoticeBanner onSeenBanner={onLinkClick} http={mockHttp} />
|
||||
);
|
||||
|
||||
const button = component.findWhere((n) => n.type() === EuiButton);
|
||||
|
||||
|
|
|
@ -24,14 +24,18 @@ import { EuiButton, EuiLink, EuiCallOut, EuiSpacer } from '@elastic/eui';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { PATH_TO_ADVANCED_SETTINGS, PRIVACY_STATEMENT_URL } from '../../common/constants';
|
||||
import { HttpSetup } from '../../../../core/public';
|
||||
|
||||
interface Props {
|
||||
http: HttpSetup;
|
||||
onSeenBanner: () => any;
|
||||
}
|
||||
|
||||
export class OptedInNoticeBanner extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { onSeenBanner } = this.props;
|
||||
const { onSeenBanner, http } = this.props;
|
||||
const basePath = http.basePath.get();
|
||||
|
||||
const bannerTitle = i18n.translate('telemetry.telemetryOptedInNoticeTitle', {
|
||||
defaultMessage: 'Help us improve the Elastic Stack',
|
||||
});
|
||||
|
@ -56,7 +60,7 @@ export class OptedInNoticeBanner extends React.PureComponent<Props> {
|
|||
</EuiLink>
|
||||
),
|
||||
disableLink: (
|
||||
<EuiLink href={PATH_TO_ADVANCED_SETTINGS} onClick={onSeenBanner}>
|
||||
<EuiLink href={`${basePath}${PATH_TO_ADVANCED_SETTINGS}`} onClick={onSeenBanner}>
|
||||
<FormattedMessage
|
||||
id="telemetry.telemetryOptedInDisableUsage"
|
||||
defaultMessage="disable usage data here"
|
||||
|
|
|
@ -76,6 +76,7 @@ export function mockTelemetryNotifications({
|
|||
telemetryService: TelemetryService;
|
||||
}) {
|
||||
return new TelemetryNotifications({
|
||||
http: httpServiceMock.createSetupContract(),
|
||||
overlays: overlayServiceMock.createStartContract(),
|
||||
telemetryService,
|
||||
});
|
||||
|
|
|
@ -104,6 +104,7 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
|
|||
this.telemetryService.userCanChangeSettings = this.canUserChangeSettings;
|
||||
|
||||
this.telemetryNotifications = new TelemetryNotifications({
|
||||
http,
|
||||
overlays,
|
||||
telemetryService: this.telemetryService,
|
||||
});
|
||||
|
|
|
@ -20,14 +20,18 @@
|
|||
import { renderOptedInNoticeBanner } from './render_opted_in_notice_banner';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { overlayServiceMock } from '../../../../../core/public/overlays/overlay_service.mock';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { httpServiceMock } from '../../../../../core/public/http/http_service.mock';
|
||||
|
||||
describe('renderOptedInNoticeBanner', () => {
|
||||
it('adds a banner to banners with priority of 10000', () => {
|
||||
const bannerID = 'brucer-wayne';
|
||||
const overlays = overlayServiceMock.createStartContract();
|
||||
const mockHttp = httpServiceMock.createStartContract();
|
||||
overlays.banners.add.mockReturnValue(bannerID);
|
||||
|
||||
const returnedBannerId = renderOptedInNoticeBanner({
|
||||
http: mockHttp,
|
||||
onSeen: jest.fn(),
|
||||
overlays,
|
||||
});
|
||||
|
|
|
@ -23,11 +23,12 @@ import { OptedInNoticeBanner } from '../../components/opted_in_notice_banner';
|
|||
import { toMountPoint } from '../../../../kibana_react/public';
|
||||
|
||||
interface RenderBannerConfig {
|
||||
http: CoreStart['http'];
|
||||
overlays: CoreStart['overlays'];
|
||||
onSeen: () => void;
|
||||
}
|
||||
export function renderOptedInNoticeBanner({ onSeen, overlays }: RenderBannerConfig) {
|
||||
const mount = toMountPoint(<OptedInNoticeBanner onSeenBanner={onSeen} />);
|
||||
export function renderOptedInNoticeBanner({ onSeen, overlays, http }: RenderBannerConfig) {
|
||||
const mount = toMountPoint(<OptedInNoticeBanner onSeenBanner={onSeen} http={http} />);
|
||||
const bannerId = overlays.banners.add(mount, 10000);
|
||||
|
||||
return bannerId;
|
||||
|
|
|
@ -23,18 +23,21 @@ import { renderOptInBanner } from './render_opt_in_banner';
|
|||
import { TelemetryService } from '../telemetry_service';
|
||||
|
||||
interface TelemetryNotificationsConstructor {
|
||||
http: CoreStart['http'];
|
||||
overlays: CoreStart['overlays'];
|
||||
telemetryService: TelemetryService;
|
||||
}
|
||||
|
||||
export class TelemetryNotifications {
|
||||
private readonly http: CoreStart['http'];
|
||||
private readonly overlays: CoreStart['overlays'];
|
||||
private readonly telemetryService: TelemetryService;
|
||||
private optedInNoticeBannerId?: string;
|
||||
private optInBannerId?: string;
|
||||
|
||||
constructor({ overlays, telemetryService }: TelemetryNotificationsConstructor) {
|
||||
constructor({ http, overlays, telemetryService }: TelemetryNotificationsConstructor) {
|
||||
this.telemetryService = telemetryService;
|
||||
this.http = http;
|
||||
this.overlays = overlays;
|
||||
}
|
||||
|
||||
|
@ -46,6 +49,7 @@ export class TelemetryNotifications {
|
|||
|
||||
public renderOptedInNoticeBanner = (): void => {
|
||||
const bannerId = renderOptedInNoticeBanner({
|
||||
http: this.http,
|
||||
onSeen: this.setOptedInNoticeSeen,
|
||||
overlays: this.overlays,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue