From 9cc98e499cc4b4b6bd858ada0ed9c3b9872880c8 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 11 Oct 2021 17:06:15 +0100 Subject: [PATCH] changes based on review --- .../components/action_clone/clone_action_name.tsx | 6 +++--- .../components/action_delete/use_delete_action.tsx | 4 ++-- .../jobs_list/components/edit_job_flyout/edit_utils.js | 4 ++-- .../ml/public/application/util/field_types_utils.test.ts | 8 ++++---- .../server/models/data_frame_analytics/index_patterns.ts | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_clone/clone_action_name.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_clone/clone_action_name.tsx index a7f1c6fca75d1..8ef743d2eea9f 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_clone/clone_action_name.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_clone/clone_action_name.tsx @@ -412,9 +412,9 @@ export const useNavigateToWizardWithClonedJob = () => { let sourceIndexId; try { - const ip = (await dataViews.find(sourceIndex)).find(({ title }) => title === sourceIndex); - if (ip !== undefined) { - sourceIndexId = ip.id; + const dv = (await dataViews.find(sourceIndex)).find(({ title }) => title === sourceIndex); + if (dv !== undefined) { + sourceIndexId = dv.id; } else { toasts.addDanger( i18n.translate('xpack.ml.dataframe.analyticsList.noSourceIndexPatternForClone', { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_delete/use_delete_action.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_delete/use_delete_action.tsx index 452b8665b0afe..0d2025c0d049a 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_delete/use_delete_action.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/action_delete/use_delete_action.tsx @@ -55,8 +55,8 @@ export const useDeleteAction = (canDeleteDataFrameAnalytics: boolean) => { const checkIndexPatternExists = async () => { try { - const ip = (await dataViews.find(indexName)).find(({ title }) => title === indexName); - if (ip !== undefined) { + const dv = (await dataViews.find(indexName)).find(({ title }) => title === indexName); + if (dv !== undefined) { setIndexPatternExists(true); } else { setIndexPatternExists(false); diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js index 240ca81f994df..ad192a738174e 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js @@ -111,8 +111,8 @@ export function loadIndexPatterns(maxNumber) { dataViewsContract .find('*', maxNumber) .then((dataViews) => { - const indexPatterns = dataViews.sort((a, b) => a.title.localeCompare(b.title)); - resolve(indexPatterns); + const sortedDataViews = dataViews.sort((a, b) => a.title.localeCompare(b.title)); + resolve(sortedDataViews); }) .catch((resp) => { reject(resp); diff --git a/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts b/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts index 907ec711ede6e..0c50dc9efa343 100644 --- a/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts +++ b/x-pack/plugins/ml/public/application/util/field_types_utils.test.ts @@ -25,19 +25,19 @@ describe('ML - field type utils', () => { }; expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.NUMBER); - // @ts-ignore reassigning ready-only type + // @ts-ignore reassigning read-only type field.type = KBN_FIELD_TYPES.DATE; expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.DATE); - // @ts-ignore reassigning ready-only type + // @ts-ignore reassigning read-only type field.type = KBN_FIELD_TYPES.IP; expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.IP); - // @ts-ignore reassigning ready-only type + // @ts-ignore reassigning read-only type field.type = KBN_FIELD_TYPES.BOOLEAN; expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.BOOLEAN); - // @ts-ignore reassigning ready-only type + // @ts-ignore reassigning read-only type field.type = KBN_FIELD_TYPES.GEO_POINT; expect(kbnTypeToMLJobType(field)).toBe(ML_JOB_FIELD_TYPES.GEO_POINT); }); diff --git a/x-pack/plugins/ml/server/models/data_frame_analytics/index_patterns.ts b/x-pack/plugins/ml/server/models/data_frame_analytics/index_patterns.ts index 44b4b9b3cc7da..568be4197baf8 100644 --- a/x-pack/plugins/ml/server/models/data_frame_analytics/index_patterns.ts +++ b/x-pack/plugins/ml/server/models/data_frame_analytics/index_patterns.ts @@ -11,10 +11,10 @@ export class IndexPatternHandler { constructor(private dataViewService: DataViewsService) {} // returns a id based on an index pattern name async getIndexPatternId(indexName: string) { - const ip = (await this.dataViewService.find(indexName)).find( + const dv = (await this.dataViewService.find(indexName)).find( ({ title }) => title === indexName ); - return ip?.id; + return dv?.id; } async deleteIndexPatternById(indexId: string) {