From 31ac5123159931cd4fbcf54cc129b57047e80567 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Wed, 8 Jul 2020 15:47:30 -0400 Subject: [PATCH 1/3] clear interval if job stopped --- .../components/create_step/progress_stats.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx index a50254334526c..0d104fbec8cd2 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx @@ -22,6 +22,7 @@ import { DataFrameAnalyticsId } from '../../../../common/analytics'; export const PROGRESS_REFRESH_INTERVAL_MS = 1000; const FAILED = 'failed'; +const STOPPED = 'stopped'; export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) => { const [initialized, setInitialized] = useState(false); @@ -70,8 +71,9 @@ export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) => setCurrentProgress(progressStats); if ( - progressStats.currentPhase === progressStats.totalPhases && - progressStats.progress === 100 + (progressStats.currentPhase === progressStats.totalPhases && + progressStats.progress === 100) || + jobStats.state === STOPPED ) { clearInterval(interval); } From c37ceb46815f0efcd8958ed644ee0638ccf306ca Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Wed, 8 Jul 2020 17:22:39 -0400 Subject: [PATCH 2/3] ensure analysisFieldsTable error messages up to date --- .../analysis_fields_table.tsx | 39 +++++++++++++++---- .../configuration_step_form.tsx | 32 +++++++-------- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx index def6acdae14e3..ff8797bc523c1 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/analysis_fields_table.tsx @@ -85,16 +85,27 @@ export const AnalysisFieldsTable: FC<{ includes: string[]; loadingItems: boolean; setFormState: React.Dispatch>; + minimumFieldsRequiredMessage?: string; + setMinimumFieldsRequiredMessage: React.Dispatch>; tableItems: FieldSelectionItem[]; -}> = ({ dependentVariable, includes, loadingItems, setFormState, tableItems }) => { + unsupportedFieldsError?: string; + setUnsupportedFieldsError: React.Dispatch>; +}> = ({ + dependentVariable, + includes, + loadingItems, + setFormState, + minimumFieldsRequiredMessage, + setMinimumFieldsRequiredMessage, + tableItems, + unsupportedFieldsError, + setUnsupportedFieldsError, +}) => { const [sortableProperties, setSortableProperties] = useState(); const [currentPaginationData, setCurrentPaginationData] = useState<{ pageIndex: number; itemsPerPage: number; }>({ pageIndex: 0, itemsPerPage: 5 }); - const [minimumFieldsRequiredMessage, setMinimumFieldsRequiredMessage] = useState< - undefined | string - >(undefined); useEffect(() => { if (includes.length === 0 && tableItems.length > 0) { @@ -164,8 +175,21 @@ export const AnalysisFieldsTable: FC<{ label={i18n.translate('xpack.ml.dataframe.analytics.create.includedFieldsLabel', { defaultMessage: 'Included fields', })} - isInvalid={minimumFieldsRequiredMessage !== undefined} - error={minimumFieldsRequiredMessage} + fullWidth + isInvalid={ + minimumFieldsRequiredMessage !== undefined || unsupportedFieldsError !== undefined + } + error={[ + ...(minimumFieldsRequiredMessage !== undefined ? [minimumFieldsRequiredMessage] : []), + ...(unsupportedFieldsError !== undefined + ? [ + i18n.translate('xpack.ml.dataframe.analytics.create.unsupportedFieldsError', { + defaultMessage: 'Invalid. {message}', + values: { message: unsupportedFieldsError }, + }), + ] + : []), + ]} > @@ -209,9 +233,10 @@ export const AnalysisFieldsTable: FC<{ ) { selection = [dependentVariable]; } - // If nothing selected show minimum fields required message and don't update form yet + // If includes is empty show minimum fields required message and don't update form yet if (selection.length === 0) { setMinimumFieldsRequiredMessage(minimumFieldsMessage); + setUnsupportedFieldsError(undefined); } else { setMinimumFieldsRequiredMessage(undefined); setFormState({ includes: selection }); diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx index 9dae54b6537b3..571c7731822c0 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/configuration_step/configuration_step_form.tsx @@ -73,6 +73,9 @@ export const ConfigurationStepForm: FC = ({ const [includesTableItems, setIncludesTableItems] = useState([]); const [maxDistinctValuesError, setMaxDistinctValuesError] = useState(); const [unsupportedFieldsError, setUnsupportedFieldsError] = useState(); + const [minimumFieldsRequiredMessage, setMinimumFieldsRequiredMessage] = useState< + undefined | string + >(); const { setEstimatedModelMemoryLimit, setFormState } = actions; const { estimatedModelMemoryLimit, form, isJobCreated, requestMessages } = state; @@ -117,6 +120,7 @@ export const ConfigurationStepForm: FC = ({ dependentVariableEmpty || jobType === undefined || maxDistinctValuesError !== undefined || + minimumFieldsRequiredMessage !== undefined || requiredFieldsError !== undefined || unsupportedFieldsError !== undefined; @@ -400,32 +404,22 @@ export const ConfigurationStepForm: FC = ({ )} From 469e59fe90c881a970df8ce782f9d436d7405dfe Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Thu, 9 Jul 2020 13:42:26 -0400 Subject: [PATCH 3/3] use shared constant for job state --- .../components/create_step/progress_stats.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx index 0d104fbec8cd2..c87f0f4206feb 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/components/create_step/progress_stats.tsx @@ -15,14 +15,15 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { useMlKibana } from '../../../../../contexts/kibana'; -import { getDataFrameAnalyticsProgressPhase } from '../../../analytics_management/components/analytics_list/common'; +import { + getDataFrameAnalyticsProgressPhase, + DATA_FRAME_TASK_STATE, +} from '../../../analytics_management/components/analytics_list/common'; import { isGetDataFrameAnalyticsStatsResponseOk } from '../../../analytics_management/services/analytics_service/get_analytics'; import { ml } from '../../../../../services/ml_api_service'; import { DataFrameAnalyticsId } from '../../../../common/analytics'; export const PROGRESS_REFRESH_INTERVAL_MS = 1000; -const FAILED = 'failed'; -const STOPPED = 'stopped'; export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) => { const [initialized, setInitialized] = useState(false); @@ -55,7 +56,7 @@ export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) => if (jobStats !== undefined) { const progressStats = getDataFrameAnalyticsProgressPhase(jobStats); - if (jobStats.state === FAILED) { + if (jobStats.state === DATA_FRAME_TASK_STATE.FAILED) { clearInterval(interval); setFailedJobMessage( jobStats.failure_reason || @@ -73,7 +74,7 @@ export const ProgressStats: FC<{ jobId: DataFrameAnalyticsId }> = ({ jobId }) => if ( (progressStats.currentPhase === progressStats.totalPhases && progressStats.progress === 100) || - jobStats.state === STOPPED + jobStats.state === DATA_FRAME_TASK_STATE.STOPPED ) { clearInterval(interval); }