-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* WIP: Notice banner for OSS folks * Add telemetryNotifyUserAboutOptInDefault to injected vars * add userHasSeenNotice check * More WIP on banner notice component * Text changes on screens * make userHasSeenNotice flag work * Finalzed splash text + checking new flag * Consolidating banner calls and saving status of opt-in notice * Conditionally remove the banner and add some code docs * Fixing prior welcome tests * api integration test for user has seen opt in * change post method to put in ui * unit test for get_telemetry_notify_user_about_optin_default * Ignore TS woes * Adding new tests and snapshots for opt-in banner component * Notice banner test * Translation miss * More opt-in tests * increase types usage * roll back core server api change * update snapshot * Prop name change + snapshot updates
- Loading branch information
Joel Griffith
authored
Nov 18, 2019
1 parent
2caa5bd
commit e312175
Showing
25 changed files
with
682 additions
and
16 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...re_plugins/telemetry/public/components/__snapshots__/opted_in_notice_banner.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
src/legacy/core_plugins/telemetry/public/components/opted_in_notice_banner.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { EuiButton } from '@elastic/eui'; | ||
import { shallowWithIntl } from 'test_utils/enzyme_helpers'; | ||
import { OptedInBanner } from './opted_in_notice_banner'; | ||
|
||
describe('OptInDetailsComponent', () => { | ||
it('renders as expected', () => { | ||
expect(shallowWithIntl(<OptedInBanner onSeenBanner={() => {}} />)).toMatchSnapshot(); | ||
}); | ||
|
||
it('fires the "onSeenBanner" prop when a link is clicked', () => { | ||
const onLinkClick = jest.fn(); | ||
const component = shallowWithIntl(<OptedInBanner onSeenBanner={onLinkClick} />); | ||
|
||
const button = component.findWhere(n => n.type() === EuiButton); | ||
|
||
if (!button) { | ||
throw new Error(`Couldn't find any buttons in opt-in notice`); | ||
} | ||
|
||
button.simulate('click'); | ||
|
||
expect(onLinkClick).toHaveBeenCalled(); | ||
}); | ||
}); |
79 changes: 79 additions & 0 deletions
79
src/legacy/core_plugins/telemetry/public/components/opted_in_notice_banner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/* eslint @elastic/eui/href-or-on-click:0 */ | ||
|
||
import * as React from 'react'; | ||
import { EuiButton, EuiLink, EuiCallOut, EuiSpacer } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
interface Props { | ||
onSeenBanner: () => any; | ||
} | ||
|
||
/** | ||
* React component for displaying the Telemetry opt-in notice. | ||
*/ | ||
export class OptedInBanner extends React.PureComponent<Props> { | ||
onLinkClick = () => { | ||
this.props.onSeenBanner(); | ||
return; | ||
}; | ||
|
||
render() { | ||
return ( | ||
<EuiCallOut title="Help us improve the Elastic Stack"> | ||
<FormattedMessage | ||
id="telemetry.telemetryOptedInNoticeDescription" | ||
defaultMessage="To learn about how usage data helps us manage and improve our products and services, see our {privacyStatementLink}. To stop collection, {disableLink}." | ||
values={{ | ||
privacyStatementLink: ( | ||
<EuiLink | ||
onClick={this.onLinkClick} | ||
href="https://www.elastic.co/legal/privacy-statement" | ||
target="_blank" | ||
rel="noopener" | ||
> | ||
<FormattedMessage | ||
id="telemetry.telemetryOptedInPrivacyStatement" | ||
defaultMessage="Privacy Statement" | ||
/> | ||
</EuiLink> | ||
), | ||
disableLink: ( | ||
<EuiLink href="#/management/kibana/settings" onClick={this.onLinkClick}> | ||
<FormattedMessage | ||
id="telemetry.telemetryOptedInDisableUsage" | ||
defaultMessage="disable usage data here" | ||
/> | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
<EuiSpacer size="s" /> | ||
<EuiButton size="s" onClick={this.props.onSeenBanner}> | ||
<FormattedMessage | ||
id="telemetry.telemetryOptedInDismissMessage" | ||
defaultMessage="Dismiss" | ||
/> | ||
</EuiButton> | ||
</EuiCallOut> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/legacy/core_plugins/telemetry/public/hacks/welcome_banner/render_notice_banner.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { banners } from 'ui/notify'; | ||
import { OptedInBanner } from '../../components/opted_in_notice_banner'; | ||
|
||
/** | ||
* Render the Telemetry Opt-in notice banner. | ||
* | ||
* @param {Object} telemetryOptInProvider The telemetry opt-in provider. | ||
* @param {Object} _banners Banners singleton, which can be overridden for tests. | ||
*/ | ||
export function renderOptedInBanner(telemetryOptInProvider, { _banners = banners } = {}) { | ||
const bannerId = _banners.add({ | ||
component: ( | ||
<OptedInBanner | ||
onSeenBanner={telemetryOptInProvider.setOptInNoticeSeen} | ||
/> | ||
), | ||
priority: 10000 | ||
}); | ||
|
||
telemetryOptInProvider.setOptInBannerNoticeId(bannerId); | ||
} |
Oops, something went wrong.