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

[ML] Fixes display of matching modules in index data visualizer #45261

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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 { FC } from 'react';

import { IndexPattern } from 'ui/index_patterns';

declare const DataRecognizer: FC<{
indexPattern: IndexPattern;
results: any;
className: string;
}>;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/



import './data_recognizer_directive';
import './data_recognizer';

export { DataRecognizer } from './data_recognizer';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { FC } from 'react';
import React, { FC, useState } from 'react';

import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
Expand All @@ -15,12 +15,22 @@ import { EuiPanel, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui';

import { useUiChromeContext } from '../../../../contexts/ui/use_ui_chrome_context';
import { CreateJobLinkCard } from '../../../../components/create_job_link_card';
import { DataRecognizer } from '../../../../components/data_recognizer';

interface Props {
indexPattern: IndexPattern;
}

export const ActionsPanel: FC<Props> = ({ indexPattern }) => {
const [recognizerResultsCount, setRecognizerResultsCount] = useState(0);

const recognizerResults = {
count: 0,
onChange() {
setRecognizerResultsCount(recognizerResults.count);
},
};

const basePath = useUiChromeContext().getBasePath();

function openAdvancedJobWizard() {
Expand All @@ -29,6 +39,9 @@ export const ActionsPanel: FC<Props> = ({ indexPattern }) => {
window.open(`${basePath}/app/ml#/jobs/new_job/advanced?index=${indexPattern}`, '_self');
}

// Note we use display:none for the DataRecognizer section as it needs to be
// passed the recognizerResults object, and then run the recognizer check which
// controls whether the recognizer section is ultimately displayed.
return (
<EuiPanel data-test-subj="mlDataVisualizerActionsPanel">
<EuiTitle>
Expand All @@ -40,6 +53,23 @@ export const ActionsPanel: FC<Props> = ({ indexPattern }) => {
</h2>
</EuiTitle>
<EuiSpacer size="s" />
<div style={recognizerResultsCount === 0 ? { display: 'none' } : {}}>
peteharverson marked this conversation as resolved.
Show resolved Hide resolved
<EuiText>
<p>
<FormattedMessage
id="xpack.ml.datavisualizer.actionsPanel.selectKnownConfigurationDescription"
defaultMessage="Select known configurations for recognized data:"
/>
</p>
</EuiText>
<EuiSpacer size="m" />
<DataRecognizer
indexPattern={indexPattern}
results={recognizerResults}
className="euiFlexGroup euiFlexGrid--gutterLarge euiFlexGroup--responsive euiFlexGroup--wrap"
></DataRecognizer>
<EuiSpacer size="l" />
</div>
<EuiText>
<p>
<FormattedMessage
Expand Down