Skip to content

Commit

Permalink
[Uptime] Remove custom handling of license enabling (elastic#82019)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
shahzad31 and kibanamachine committed Nov 2, 2020
1 parent 9d3583e commit 896c919
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 78 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 @@ -3,48 +3,22 @@
* 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, { useContext, useState, useEffect } from 'react';
import React, { useContext, useEffect } from 'react';
import { EuiCallOut, EuiButton, EuiSpacer } from '@elastic/eui';
import { useDispatch, useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import { UptimeSettingsContext } from '../../../contexts';
import * as labels from './translations';
import { getMLCapabilitiesAction } from '../../../state/actions';
import { hasMLFeatureSelector } from '../../../state/selectors';

export const ShowLicenseInfo = () => {
const { basePath } = useContext(UptimeSettingsContext);
const [loading, setLoading] = useState<boolean>(false);
const hasMlFeature = useSelector(hasMLFeatureSelector);

const dispatch = useDispatch();

useEffect(() => {
dispatch(getMLCapabilitiesAction.get());
}, [dispatch]);

useEffect(() => {
let retryInterval: any;
if (loading) {
retryInterval = setInterval(() => {
dispatch(getMLCapabilitiesAction.get());
}, 5000);
} else {
clearInterval(retryInterval);
}

return () => {
clearInterval(retryInterval);
};
}, [dispatch, loading]);

useEffect(() => {
setLoading(false);
}, [hasMlFeature]);

const startLicenseTrial = () => {
setLoading(true);
};

return (
<>
<EuiCallOut
Expand All @@ -55,16 +29,12 @@ export const ShowLicenseInfo = () => {
iconType="help"
>
<p>{labels.START_TRAIL_DESC}</p>
<span onClick={startLicenseTrial} onKeyDown={() => {}}>
<EuiButton
color="primary"
isLoading={loading}
target="_blank"
href={basePath + `/app/management/stack/license_management/home`}
>
{labels.START_TRAIL}
</EuiButton>
</span>
<EuiButton
color="primary"
href={basePath + `/app/management/stack/license_management/home`}
>
{labels.START_TRAIL}
</EuiButton>
</EuiCallOut>
<EuiSpacer />
</>
Expand Down

0 comments on commit 896c919

Please sign in to comment.