Skip to content

Commit

Permalink
[ML] Fixes display of matching modules in index data visualizer (elas…
Browse files Browse the repository at this point in the history
…tic#45261) (elastic#45369)

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

* [ML] Update following review on adding recognizer check
  • Loading branch information
peteharverson authored Sep 11, 2019
1 parent 56d0452 commit fd1b0fc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
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' } : {}}>
<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

0 comments on commit fd1b0fc

Please sign in to comment.