-
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.
- Loading branch information
1 parent
cd38380
commit bc78f67
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
x-pack/plugins/uptime/public/components/overview/synthetics_callout.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,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiButton, EuiCallOut, EuiSpacer } from '@elastic/eui'; | ||
import React, { useState } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
|
||
const SYNTHETICS_CALLOUT_LS_KEY = 'xpack.uptime.syntheticsCallout.display'; | ||
const shouldShowSyntheticsCallout = () => { | ||
let value = localStorage.getItem(SYNTHETICS_CALLOUT_LS_KEY); | ||
if (value === null) { | ||
localStorage.setItem(SYNTHETICS_CALLOUT_LS_KEY, 'true'); | ||
value = 'true'; | ||
} | ||
return value === 'true'; | ||
}; | ||
const hideSyntheticsCallout = () => localStorage.setItem(SYNTHETICS_CALLOUT_LS_KEY, 'false'); | ||
|
||
export const SyntheticsCallout = () => { | ||
const [shouldShow, setShouldShow] = useState<boolean>(shouldShowSyntheticsCallout()); | ||
if (!shouldShow) { | ||
return null; | ||
} | ||
return ( | ||
<> | ||
<EuiCallOut | ||
title={i18n.translate('xpack.uptime.overview.pageHeader.syntheticsCallout.title', { | ||
defaultMessage: 'Elastic Synthetics', | ||
})} | ||
iconType="beaker" | ||
> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.uptime.overview.pageHeader.syntheticsCallout.content" | ||
defaultMessage="Elastic Uptime now supports synthetic browser monitors! Learn how to use them {here}." | ||
values={{ here: <a href="https://elastic.co/synthetics">here</a> }} | ||
/> | ||
</p> | ||
<EuiButton | ||
onClick={() => { | ||
if (shouldShow) { | ||
hideSyntheticsCallout(); | ||
setShouldShow(false); | ||
} | ||
}} | ||
> | ||
<FormattedMessage | ||
id="xpack.uptime.overview.pageHeader.syntheticsCallout.dismissButtonText" | ||
defaultMessage="Dismiss" | ||
/> | ||
</EuiButton> | ||
</EuiCallOut> | ||
<EuiSpacer size="s" /> | ||
</> | ||
); | ||
}; |
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