Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uptime] Remove custom handling of license enabling #82019

Merged
merged 2 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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