-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Display link to create data view from error cases in data frame analytics results pages #143596
[ML] Display link to create data view from error cases in data frame analytics results pages #143596
Changes from 1 commit
098aa10
7e8031b
c849b80
e5f0676
a891812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import { getFeatureCount } from './common'; | |
import { useOutlierData } from './use_outlier_data'; | ||
import { useExplorationUrlState } from '../../hooks/use_exploration_url_state'; | ||
import { ExplorationQueryBarProps } from '../exploration_query_bar/exploration_query_bar'; | ||
import { IndexPatternPrompt } from '../index_pattern_prompt'; | ||
|
||
export type TableItem = Record<string, any>; | ||
|
||
|
@@ -90,6 +91,8 @@ export const OutlierExploration: FC<ExplorationProps> = React.memo(({ jobId }) = | |
jobConfig?.analyzed_fields?.excludes, | ||
resultsField | ||
); | ||
const destIndex = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic is used in several places in DFA like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added util function in c849b80 |
||
(Array.isArray(jobConfig?.dest.index) ? jobConfig?.dest.index[0] : jobConfig?.dest.index) ?? ''; | ||
|
||
if (indexPatternErrorMessage !== undefined) { | ||
return ( | ||
|
@@ -101,7 +104,12 @@ export const OutlierExploration: FC<ExplorationProps> = React.memo(({ jobId }) = | |
color="danger" | ||
iconType="cross" | ||
> | ||
<p>{indexPatternErrorMessage}</p> | ||
<p> | ||
{indexPatternErrorMessage} | ||
{needsDestIndexPattern ? ( | ||
<IndexPatternPrompt destIndex={destIndex} color="text" /> | ||
) : null} | ||
</p> | ||
</EuiCallOut> | ||
</EuiPanel> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,12 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { EuiToolTip } from '@elastic/eui'; | ||
import { EuiToolTip, EuiLink, EuiText } from '@elastic/eui'; | ||
import React, { FC } from 'react'; | ||
import { cloneDeep, isEqual } from 'lodash'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { toMountPoint, wrapWithTheme } from '@kbn/kibana-react-plugin/public'; | ||
import { DeepReadonly } from '../../../../../../../common/types/common'; | ||
import { DataFrameAnalyticsConfig, isOutlierAnalysis } from '../../../../common'; | ||
import { isClassificationAnalysis, isRegressionAnalysis } from '../../../../common/analytics'; | ||
|
@@ -401,9 +403,15 @@ export const useNavigateToWizardWithClonedJob = () => { | |
services: { | ||
notifications: { toasts }, | ||
data: { dataViews }, | ||
http: { basePath }, | ||
application: { capabilities }, | ||
theme, | ||
}, | ||
} = useMlKibana(); | ||
const theme$ = theme.theme$; | ||
const navigateToPath = useNavigateToPath(); | ||
const canCreateDataView = | ||
capabilities.savedObjectsManagement.edit === true || capabilities.indexPatterns.save === true; | ||
|
||
return async (item: Pick<DataFrameAnalyticsListRow, 'config' | 'stats'>) => { | ||
const sourceIndex = Array.isArray(item.config.source.index) | ||
|
@@ -416,13 +424,42 @@ export const useNavigateToWizardWithClonedJob = () => { | |
if (dv !== undefined) { | ||
sourceIndexId = dv.id; | ||
} else { | ||
toasts.addDanger( | ||
i18n.translate('xpack.ml.dataframe.analyticsList.noSourceDataViewForClone', { | ||
defaultMessage: | ||
'Unable to clone the analytics job. No data view exists for index {dataView}.', | ||
values: { dataView: sourceIndex }, | ||
}) | ||
); | ||
toasts.addDanger({ | ||
title: toMountPoint( | ||
wrapWithTheme( | ||
<> | ||
<FormattedMessage | ||
id="xpack.ml.dataframe.analyticsList.noSourceDataViewForClone" | ||
defaultMessage="Unable to clone the analytics job. No data view exists for index {dataView}." | ||
values={{ dataView: sourceIndex }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Super duper nit: The variable name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in 7e8031b |
||
/> | ||
{canCreateDataView ? ( | ||
<EuiText size="xs" color="text"> | ||
<FormattedMessage | ||
id="xpack.ml.dataframe.analytics.cloneAction.dataViewPromptLink" | ||
defaultMessage="{linkToDataViewManagement}" | ||
values={{ | ||
linkToDataViewManagement: ( | ||
<EuiLink | ||
href={`${basePath.get()}/app/management/kibana/dataViews/create`} | ||
target="_blank" | ||
> | ||
<FormattedMessage | ||
id="xpack.ml.dataframe.analytics.cloneAction.dataViewPromptLinkText" | ||
defaultMessage="Create a data view for {dataView}" | ||
values={{ dataView: sourceIndex }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Super duper nit: Similarly, the variable name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated in 7e8031b |
||
/> | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
</EuiText> | ||
) : null} | ||
</>, | ||
theme$ | ||
) | ||
), | ||
}); | ||
} | ||
} catch (e) { | ||
const error = extractErrorMessage(e); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there supposed to be a space in between for
index{destIndex}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming it's like this for when destIndex is undefined. What about when destIndex is defined? It would read "No data view exists for indexmy-index-name. "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Updated in 7e8031b