From 6725bd1bf7e9cf9e93af81c1b775ec78b314eeef Mon Sep 17 00:00:00 2001 From: Luke Elmers Date: Mon, 1 Nov 2021 15:36:13 -0600 Subject: [PATCH] Don't show telemetry opt-in/out notice when it has been disabled via yml config. (#116867) --- .../__snapshots__/welcome.test.tsx.snap | 85 +++++++++++++++++++ .../application/components/welcome.test.tsx | 8 ++ .../public/application/components/welcome.tsx | 6 +- 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap b/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap index 348f618805858..17f7d2520e862 100644 --- a/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap +++ b/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap @@ -358,3 +358,88 @@ exports[`should render a Welcome screen with the telemetry disclaimer when optIn `; + +exports[`should render a Welcome screen without the opt in/out link when user cannot change optIn status 1`] = ` + +
+
+
+ + + + + +

+ +

+
+ +
+
+
+ + + + + + + + + + + + + +
+
+
+`; diff --git a/src/plugins/home/public/application/components/welcome.test.tsx b/src/plugins/home/public/application/components/welcome.test.tsx index 440af1e0093b5..b042a91e58c9d 100644 --- a/src/plugins/home/public/application/components/welcome.test.tsx +++ b/src/plugins/home/public/application/components/welcome.test.tsx @@ -47,6 +47,14 @@ test('should render a Welcome screen with no telemetry disclaimer', () => { expect(component).toMatchSnapshot(); }); +test('should render a Welcome screen without the opt in/out link when user cannot change optIn status', () => { + const telemetry = telemetryPluginMock.createStartContract(); + telemetry.telemetryService.getCanChangeOptInStatus = jest.fn().mockReturnValue(false); + const component = shallow( {}} telemetry={telemetry} />); + + expect(component).toMatchSnapshot(); +}); + test('fires opt-in seen when mounted', () => { const telemetry = telemetryPluginMock.createStartContract(); const mockSetOptedInNoticeSeen = jest.fn(); diff --git a/src/plugins/home/public/application/components/welcome.tsx b/src/plugins/home/public/application/components/welcome.tsx index 03dff22c7b33f..21e0e03bb2bf7 100644 --- a/src/plugins/home/public/application/components/welcome.tsx +++ b/src/plugins/home/public/application/components/welcome.tsx @@ -76,7 +76,11 @@ export class Welcome extends React.Component { private renderTelemetryEnabledOrDisabledText = () => { const { telemetry } = this.props; - if (!telemetry || !telemetry.telemetryService.userCanChangeSettings) { + if ( + !telemetry || + !telemetry.telemetryService.userCanChangeSettings || + !telemetry.telemetryService.getCanChangeOptInStatus() + ) { return null; }