Skip to content

Commit

Permalink
Add "view in machine learning" buttons to setup flyout
Browse files Browse the repository at this point in the history
  • Loading branch information
afgomez authored and Alejandro Fernández Gómez committed Aug 6, 2020
1 parent b26bd61 commit 80859ff
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const AnalyzeInMlButton: React.FunctionComponent<{
);
};

const getOverallAnomalyExplorerLinkDescriptor = (
export const getOverallAnomalyExplorerLinkDescriptor = (
jobId: string,
timeRange: TimeRange
): LinkDescriptor => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ export const LogAnalysisModuleList: React.FC<{
onViewModuleSetup: (module: ModuleId) => void;
}> = ({ onViewModuleSetup }) => {
const { hasLogAnalysisSetupCapabilities } = useLogAnalysisCapabilitiesContext();
const { setupStatus: logEntryRateSetupStatus } = useLogEntryRateModuleContext();
const { setupStatus: logEntryCategoriesSetupStatus } = useLogEntryCategoriesModuleContext();
const {
setupStatus: logEntryRateSetupStatus,
jobIds: logEntryRateJobIds,
} = useLogEntryRateModuleContext();
const {
setupStatus: logEntryCategoriesSetupStatus,
jobIds: logEntryCategoriesJobIds,
} = useLogEntryCategoriesModuleContext();

const viewLogEntryRateSetupFlyout = useCallback(() => {
onViewModuleSetup('logs_ui_analysis');
Expand All @@ -37,6 +43,7 @@ export const LogAnalysisModuleList: React.FC<{
<EuiFlexGroup>
<EuiFlexItem>
<LogAnalysisModuleListCard
jobId={logEntryRateJobIds['log-entry-rate']}
hasSetupCapabilities={hasLogAnalysisSetupCapabilities}
moduleDescription={logEntryRateModule.moduleDescription}
moduleName={logEntryRateModule.moduleName}
Expand All @@ -46,6 +53,7 @@ export const LogAnalysisModuleList: React.FC<{
</EuiFlexItem>
<EuiFlexItem>
<LogAnalysisModuleListCard
jobId={logEntryCategoriesJobIds['log-entry-categories-count']}
hasSetupCapabilities={hasLogAnalysisSetupCapabilities}
moduleDescription={logEntryCategoriesModule.moduleDescription}
moduleName={logEntryCategoriesModule.moduleName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,43 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiCard, EuiIcon } from '@elastic/eui';
import { EuiCard, EuiIcon, EuiButtonEmpty } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { SetupStatus } from '../../../../../common/log_analysis';
import { CreateJobButton, RecreateJobButton } from '../../log_analysis_setup/create_job_button';
import { useLinkProps } from '../../../../hooks/use_link_props';
import { getOverallAnomalyExplorerLinkDescriptor } from '../../log_analysis_results/analyze_in_ml_button';

export const LogAnalysisModuleListCard: React.FC<{
jobId: string;
hasSetupCapabilities: boolean;
moduleDescription: string;
moduleName: string;
moduleStatus: SetupStatus;
onViewSetup: () => void;
}> = ({ hasSetupCapabilities, moduleDescription, moduleName, moduleStatus, onViewSetup }) => {
}> = ({
jobId,
hasSetupCapabilities,
moduleDescription,
moduleName,
moduleStatus,
onViewSetup,
}) => {
const moduleIcon =
moduleStatus.type === 'required' ? (
<EuiIcon size="xxl" type="machineLearningApp" />
) : (
<EuiIcon color="secondary" size="xxl" type="check" />
);

const viewInMlLinkProps = useLinkProps(
getOverallAnomalyExplorerLinkDescriptor(jobId, {
endTime: Date.now(),
startTime: Date.now() - 86400000 * 14,
})
);

const moduleSetupButton =
moduleStatus.type === 'required' ? (
<CreateJobButton hasSetupCapabilities={hasSetupCapabilities} onClick={onViewSetup}>
Expand All @@ -33,7 +50,15 @@ export const LogAnalysisModuleListCard: React.FC<{
/>
</CreateJobButton>
) : (
<RecreateJobButton hasSetupCapabilities={hasSetupCapabilities} onClick={onViewSetup} />
<>
<RecreateJobButton hasSetupCapabilities={hasSetupCapabilities} onClick={onViewSetup} />
<EuiButtonEmpty {...viewInMlLinkProps}>
<FormattedMessage
id="xpack.infra.logs.analysy.viewInMlButtonLabel"
defaultMessage="View in Machine Learning"
/>
</EuiButtonEmpty>
</>
);

return (
Expand Down

0 comments on commit 80859ff

Please sign in to comment.