From 0203bb4fd4b53a889b283e4af53a83822674b82e Mon Sep 17 00:00:00 2001 From: Dmitrii Arnautov Date: Wed, 9 Oct 2019 16:22:13 +0200 Subject: [PATCH] [ML] PR remarks --- x-pack/legacy/plugins/ml/common/types/modules.ts | 14 ++++++++------ .../recognize/components/kibana_objects.tsx | 2 +- .../ml/public/jobs/new_job_new/recognize/page.tsx | 12 ++++++------ .../recognize/{resolvers.tsx => resolvers.ts} | 6 ++---- .../plugins/ml/public/services/job_service.d.ts | 2 +- .../ml/public/services/ml_api_service/index.d.ts | 1 + 6 files changed, 19 insertions(+), 18 deletions(-) rename x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/{resolvers.tsx => resolvers.ts} (94%) diff --git a/x-pack/legacy/plugins/ml/common/types/modules.ts b/x-pack/legacy/plugins/ml/common/types/modules.ts index 58e53499181273..978b799c737d29 100644 --- a/x-pack/legacy/plugins/ml/common/types/modules.ts +++ b/x-pack/legacy/plugins/ml/common/types/modules.ts @@ -5,21 +5,23 @@ */ import { Datafeed, Job } from '../../public/jobs/new_job_new/common/job_creator/configs'; +import { SavedObjectAttributes } from '../../../../../../target/types/core/server'; export interface ModuleJob { id: string; config: Partial; } +export interface KibanaObjectConfig extends SavedObjectAttributes { + description: string; + title: string; + version: number; +} + export interface KibanaObject { id: string; title: string; - config: { - kibanaSavedObjectMeta: { searchSourceJSON: string }; - description: string; - title: string; - version: number; - }; + config: KibanaObjectConfig; } export interface KibanaObjects { diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/components/kibana_objects.tsx b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/components/kibana_objects.tsx index 8f2e082b86afd6..808a50f9056926 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/components/kibana_objects.tsx +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/components/kibana_objects.tsx @@ -27,7 +27,7 @@ export interface KibanaObjectItemProps { export const KibanaObjects: FC = memo( ({ objectType, kibanaObjects, isSaving }) => { - const kibanaObjectLabels: { [key: string]: string } = { + const kibanaObjectLabels: Record = { dashboard: i18n.translate('xpack.ml.newJob.simple.recognize.dashboardsLabel', { defaultMessage: 'Dashboards', }), diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/page.tsx b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/page.tsx index 4862b35cff7a61..5d9e19482bc936 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/page.tsx +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/page.tsx @@ -74,11 +74,11 @@ interface PageProps { } export enum SAVE_STATE { - NOT_SAVED = 'NOT_SAVED', - SAVING = 'SAVING', - SAVED = 'SAVED', - FAILED = 'FAILED', - PARTIAL_FAILURE = 'PARTIAL_FAILURE', + NOT_SAVED, + SAVING, + SAVED, + FAILED, + PARTIAL_FAILURE, } export const Page: FC = ({ moduleId, existingGroupIds }) => { @@ -98,7 +98,7 @@ export const Page: FC = ({ moduleId, existingGroupIds }) => { jobGroups: [] as string[], }); const [jobs, setJobs] = useState([]); - const [kibanaObjects, setKibanaObjects] = useState({} as KibanaObjects); + const [kibanaObjects, setKibanaObjects] = useState({}); const [saveState, setSaveState] = useState(SAVE_STATE.NOT_SAVED); const [resultsUrl, setResultsUrl] = useState(''); const [validationResult, setValidationResult] = useState({}); diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/resolvers.tsx b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/resolvers.ts similarity index 94% rename from x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/resolvers.tsx rename to x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/resolvers.ts index 5cd9bd226e7926..cd6b0769cb45cf 100644 --- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/resolvers.tsx +++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/resolvers.ts @@ -8,10 +8,8 @@ import chrome from 'ui/chrome'; import { i18n } from '@kbn/i18n'; import { toastNotifications } from 'ui/notify'; import { IPrivate } from 'ui/private'; -// @ts-ignore -import { mlJobService } from 'plugins/ml/services/job_service'; -// @ts-ignore -import { ml } from 'plugins/ml/services/ml_api_service'; +import { mlJobService } from '../../../services/job_service'; +import { ml } from '../../../services/ml_api_service'; /** * Checks whether the jobs in a data recognizer module have been created. diff --git a/x-pack/legacy/plugins/ml/public/services/job_service.d.ts b/x-pack/legacy/plugins/ml/public/services/job_service.d.ts index 3b60a7af505d7d..c2d3882580be1b 100644 --- a/x-pack/legacy/plugins/ml/public/services/job_service.d.ts +++ b/x-pack/legacy/plugins/ml/public/services/job_service.d.ts @@ -11,7 +11,7 @@ export interface ExistingJobsAndGroups { declare interface JobService { currentJob: any; - createResultsUrlForJobs: () => string; + createResultsUrlForJobs: (jobs: any[], target: string) => string; tempJobCloningObjects: { job: any; skipTimeRangeStep: boolean; diff --git a/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts b/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts index 24b6e4babb00dc..6f0194664db7c8 100644 --- a/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts +++ b/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts @@ -73,6 +73,7 @@ declare interface Ml { getDatafeedStats(obj: object): Promise; esSearch(obj: object): any; getIndices(): Promise; + dataRecognizerModuleJobsExist(obj: { moduleId: string }): Promise; getDataRecognizerModule(obj: { moduleId: string }): Promise; setupDataRecognizerConfig(obj: object): Promise; getTimeFieldRange(obj: object): Promise;