-
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.
[Logs UI] ML log integration splash screen (#69288)
Co-authored-by: Brandon Morelli <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
2b72de5
commit f6c9ca2
Showing
7 changed files
with
232 additions
and
13 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
174 changes: 174 additions & 0 deletions
174
...lugins/infra/public/components/logging/log_analysis_setup/subscription_splash_content.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,174 @@ | ||
/* | ||
* 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 React, { useEffect } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
EuiPage, | ||
EuiPageBody, | ||
EuiPageContent, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiSpacer, | ||
EuiTitle, | ||
EuiText, | ||
EuiButton, | ||
EuiButtonEmpty, | ||
EuiImage, | ||
} from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { LoadingPage } from '../../loading_page'; | ||
|
||
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; | ||
import { euiStyled } from '../../../../../observability/public'; | ||
import { useTrialStatus } from '../../../hooks/use_trial_status'; | ||
|
||
export const SubscriptionSplashContent: React.FC = () => { | ||
const { services } = useKibana(); | ||
const { loadState, isTrialAvailable, checkTrialAvailability } = useTrialStatus(); | ||
|
||
useEffect(() => { | ||
checkTrialAvailability(); | ||
}, [checkTrialAvailability]); | ||
|
||
if (loadState === 'pending') { | ||
return ( | ||
<LoadingPage | ||
message={i18n.translate('xpack.infra.logs.logAnalysis.splash.loadingMessage', { | ||
defaultMessage: 'Checking license...', | ||
})} | ||
/> | ||
); | ||
} | ||
|
||
const canStartTrial = isTrialAvailable && loadState === 'resolved'; | ||
|
||
let title; | ||
let description; | ||
let cta; | ||
|
||
if (canStartTrial) { | ||
title = ( | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.startTrialTitle" | ||
defaultMessage="To access anomaly detection, start a free trial" | ||
/> | ||
); | ||
|
||
description = ( | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.startTrialDescription" | ||
defaultMessage="Our free, 14-day trial includes machine learning features, which enable you to detect anomalies in your logs." | ||
/> | ||
); | ||
|
||
cta = ( | ||
<EuiButton | ||
fullWidth={false} | ||
fill | ||
href={services.http.basePath.prepend('/app/management/stack/license_management')} | ||
> | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.startTrialCta" | ||
defaultMessage="Start trial" | ||
/> | ||
</EuiButton> | ||
); | ||
} else { | ||
title = ( | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.updateSubscriptionTitle" | ||
defaultMessage="To access anomaly detection, upgrade to a Platinum Subscription" | ||
/> | ||
); | ||
|
||
description = ( | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.updateSubscriptionDescription" | ||
defaultMessage="You must have a Platinum Subscription to use machine learning features." | ||
/> | ||
); | ||
|
||
cta = ( | ||
<EuiButton fullWidth={false} fill href="https://www.elastic.co/subscriptions"> | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.updateSubscriptionCta" | ||
defaultMessage="Upgrade subscription" | ||
/> | ||
</EuiButton> | ||
); | ||
} | ||
|
||
return ( | ||
<SubscriptionPage> | ||
<EuiPageBody> | ||
<SubscriptionPageContent verticalPosition="center" horizontalPosition="center"> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiTitle size="m"> | ||
<h2>{title}</h2> | ||
</EuiTitle> | ||
<EuiSpacer size="xl" /> | ||
<EuiText> | ||
<p>{description}</p> | ||
</EuiText> | ||
<EuiSpacer /> | ||
<div>{cta}</div> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiImage | ||
alt={i18n.translate('xpack.infra.logs.logAnalysis.splash.splashImageAlt', { | ||
defaultMessage: 'Placeholder image', | ||
})} | ||
url={services.http.basePath.prepend( | ||
'/plugins/infra/assets/anomaly_chart_minified.svg' | ||
)} | ||
size="fullWidth" | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<SubscriptionPageFooter> | ||
<EuiTitle size="xs"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.learnMoreTitle" | ||
defaultMessage="Want to learn more?" | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
<EuiButtonEmpty | ||
flush="left" | ||
iconType="training" | ||
target="_blank" | ||
color="text" | ||
href="https://www.elastic.co/guide/en/kibana/master/xpack-logs-analysis.html" | ||
> | ||
<FormattedMessage | ||
id="xpack.infra.logs.logAnalysis.splash.learnMoreLink" | ||
defaultMessage="Read documentation" | ||
/> | ||
</EuiButtonEmpty> | ||
</SubscriptionPageFooter> | ||
</SubscriptionPageContent> | ||
</EuiPageBody> | ||
</SubscriptionPage> | ||
); | ||
}; | ||
|
||
const SubscriptionPage = euiStyled(EuiPage)` | ||
height: 100% | ||
`; | ||
|
||
const SubscriptionPageContent = euiStyled(EuiPageContent)` | ||
max-width: 768px !important; | ||
`; | ||
|
||
const SubscriptionPageFooter = euiStyled.div` | ||
background: ${(props) => props.theme.eui.euiColorLightestShade}; | ||
margin: 0 -${(props) => props.theme.eui.paddingSizes.l} -${(props) => | ||
props.theme.eui.paddingSizes.l}; | ||
padding: ${(props) => props.theme.eui.paddingSizes.l}; | ||
`; |
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,51 @@ | ||
/* | ||
* 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 { boolean } from 'io-ts'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { useState } from 'react'; | ||
import { useKibana } from '../../../../../src/plugins/kibana_react/public'; | ||
import { API_BASE_PATH as LICENSE_MANAGEMENT_API_BASE_PATH } from '../../../license_management/common/constants'; | ||
import { useTrackedPromise } from '../utils/use_tracked_promise'; | ||
import { decodeOrThrow } from '../../common/runtime_types'; | ||
|
||
interface UseTrialStatusState { | ||
loadState: 'uninitialized' | 'pending' | 'resolved' | 'rejected'; | ||
isTrialAvailable: boolean; | ||
checkTrialAvailability: () => void; | ||
} | ||
|
||
export function useTrialStatus(): UseTrialStatusState { | ||
const { services } = useKibana(); | ||
const [isTrialAvailable, setIsTrialAvailable] = useState<boolean>(false); | ||
|
||
const [loadState, checkTrialAvailability] = useTrackedPromise( | ||
{ | ||
createPromise: async () => { | ||
const response = await services.http.get(`${LICENSE_MANAGEMENT_API_BASE_PATH}/start_trial`); | ||
return decodeOrThrow(boolean)(response); | ||
}, | ||
onResolve: (response) => { | ||
setIsTrialAvailable(response); | ||
}, | ||
onReject: (error) => { | ||
services.notifications.toasts.addDanger( | ||
i18n.translate('xpack.infra.trialStatus.trialStatusNetworkErrorMessage', { | ||
defaultMessage: 'We could not determine if the trial license is available', | ||
}) | ||
); | ||
}, | ||
}, | ||
[services] | ||
); | ||
|
||
return { | ||
loadState: loadState.state, | ||
isTrialAvailable, | ||
checkTrialAvailability, | ||
}; | ||
} |
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