Skip to content

Commit

Permalink
Don't show telemetry opt-in/out notice when it has been disabled via …
Browse files Browse the repository at this point in the history
…yml config. (elastic#116867)
  • Loading branch information
lukeelmers authored and kibanamachine committed Nov 1, 2021
1 parent 5b44541 commit 9bedf46
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.

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 @@ -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(<Welcome urlBasePath="/" onSkip={() => {}} telemetry={telemetry} />);

expect(component).toMatchSnapshot();
});

test('fires opt-in seen when mounted', () => {
const telemetry = telemetryPluginMock.createStartContract();
const mockSetOptedInNoticeSeen = jest.fn();
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/home/public/application/components/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ export class Welcome extends React.Component<Props> {

private renderTelemetryEnabledOrDisabledText = () => {
const { telemetry } = this.props;
if (!telemetry || !telemetry.telemetryService.userCanChangeSettings) {
if (
!telemetry ||
!telemetry.telemetryService.userCanChangeSettings ||
!telemetry.telemetryService.getCanChangeOptInStatus()
) {
return null;
}

Expand Down

0 comments on commit 9bedf46

Please sign in to comment.