forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] DF Analytics results: ensure
View
link is only enabled when jo…
…b has successfully completed (elastic#73539) * disable view link if job is incomplete or failed * ensure hooks run before return to avoid react error
- Loading branch information
1 parent
5b09dd9
commit f18e84d
Showing
3 changed files
with
97 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...frame_analytics/pages/analytics_management/components/action_view/get_view_link_status.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { | ||
isRegressionAnalysis, | ||
isOutlierAnalysis, | ||
isClassificationAnalysis, | ||
} from '../../../../common/analytics'; | ||
import { | ||
DataFrameAnalyticsListRow, | ||
isDataFrameAnalyticsStopped, | ||
isDataFrameAnalyticsFailed, | ||
getDataFrameAnalyticsProgressPhase, | ||
} from '../analytics_list/common'; | ||
|
||
const unknownJobTypeMessage = i18n.translate( | ||
'xpack.ml.dataframe.analyticsList.viewActionUnknownJobTypeToolTipContent', | ||
{ | ||
defaultMessage: 'There is no results page available for this type of data frame analytics job.', | ||
} | ||
); | ||
const jobNotStartedMessage = i18n.translate( | ||
'xpack.ml.dataframe.analyticsList.viewActionJobNotStartedToolTipContent', | ||
{ | ||
defaultMessage: | ||
'The data frame analytics job did not start. There is no results page available.', | ||
} | ||
); | ||
const jobNotFinishedMessage = i18n.translate( | ||
'xpack.ml.dataframe.analyticsList.viewActionJobNotFinishedToolTipContent', | ||
{ | ||
defaultMessage: | ||
'The data frame analytics job is not finished. There is no results page available.', | ||
} | ||
); | ||
const jobFailedMessage = i18n.translate( | ||
'xpack.ml.dataframe.analyticsList.viewActionJobFailedToolTipContent', | ||
{ | ||
defaultMessage: 'The data frame analytics job failed. There is no results page available.', | ||
} | ||
); | ||
|
||
interface ViewLinkStatusReturn { | ||
disabled: boolean; | ||
tooltipContent?: string; | ||
} | ||
|
||
export function getViewLinkStatus(item: DataFrameAnalyticsListRow): ViewLinkStatusReturn { | ||
const viewLinkStatus: ViewLinkStatusReturn = { disabled: false }; | ||
|
||
const progressStats = getDataFrameAnalyticsProgressPhase(item.stats); | ||
const jobFailed = isDataFrameAnalyticsFailed(item.stats.state); | ||
const jobNotStarted = progressStats.currentPhase === 1 && progressStats.progress === 0; | ||
const jobFinished = | ||
isDataFrameAnalyticsStopped(item.stats.state) && | ||
progressStats.currentPhase === progressStats.totalPhases && | ||
progressStats.progress === 100; | ||
const isUnknownJobType = | ||
!isRegressionAnalysis(item.config.analysis) && | ||
!isOutlierAnalysis(item.config.analysis) && | ||
!isClassificationAnalysis(item.config.analysis); | ||
|
||
const disabled = !jobFinished || jobFailed || isUnknownJobType; | ||
|
||
if (disabled) { | ||
viewLinkStatus.disabled = true; | ||
if (isUnknownJobType) { | ||
viewLinkStatus.tooltipContent = unknownJobTypeMessage; | ||
} else if (jobFailed) { | ||
viewLinkStatus.tooltipContent = jobFailedMessage; | ||
} else if (jobNotStarted) { | ||
viewLinkStatus.tooltipContent = jobNotStartedMessage; | ||
} else if (!jobFinished) { | ||
viewLinkStatus.tooltipContent = jobNotFinishedMessage; | ||
} | ||
} | ||
|
||
return viewLinkStatus; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters