Skip to content

Commit

Permalink
[ML] Adding ability to change data view in advanced job wizard (#115191
Browse files Browse the repository at this point in the history
…) (#115585)

* [ML] Adding ability to change data view in advanced job wizard

* updating translation ids

* type and text changes

* code clean up

* route id change

* text changes

* text change

* changing data view to index pattern

* adding api tests

* text updates

* removing first step

* renaming temp variable

* adding permission checks

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: James Gowdy <jgowdy@elastic.co>
  • Loading branch information
kibanamachine and jgowdyelastic authored Oct 19, 2021
1 parent a50fb5a commit 6e64940
Show file tree
Hide file tree
Showing 22 changed files with 711 additions and 19 deletions.
14 changes: 14 additions & 0 deletions x-pack/plugins/ml/common/types/job_validation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { ErrorType } from '../util/errors';

export interface DatafeedValidationResponse {
valid: boolean;
documentsFound: boolean;
error?: ErrorType;
}
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/common/types/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { ErrorType } from '../util/errors';
import type { ErrorType } from '../util/errors';
export type JobType = 'anomaly-detector' | 'data-frame-analytics';
export const ML_SAVED_OBJECT_TYPE = 'ml-job';
export const ML_MODULE_SAVED_OBJECT_TYPE = 'ml-module';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useNavigateToPath = () => {
const location = useLocation();

return useCallback(
async (path: string | undefined, preserveSearch = false) => {
async (path: string | undefined, preserveSearch: boolean = false) => {
if (path === undefined) return;
const modifiedPath = `${path}${preserveSearch === true ? location.search : ''}`;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ export class JobCreator {
return this._datafeed_config.indices;
}

public set indices(indics: string[]) {
this._datafeed_config.indices = indics;
}

public get scriptFields(): Field[] {
return this._scriptFields;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,21 @@ export function convertToMultiMetricJob(
jobCreator.createdBy = CREATED_BY_LABEL.MULTI_METRIC;
jobCreator.modelPlot = false;
stashJobForCloning(jobCreator, true, true);

navigateToPath(`jobs/new_job/${JOB_TYPE.MULTI_METRIC}`, true);
}

export function convertToAdvancedJob(jobCreator: JobCreatorType, navigateToPath: NavigateToPath) {
jobCreator.createdBy = null;
stashJobForCloning(jobCreator, true, true);

navigateToPath(`jobs/new_job/${JOB_TYPE.ADVANCED}`, true);
}

export function resetAdvancedJob(jobCreator: JobCreatorType, navigateToPath: NavigateToPath) {
jobCreator.createdBy = null;
stashJobForCloning(jobCreator, true, false);
navigateToPath('/jobs/new_job');
}

export function resetJob(jobCreator: JobCreatorType, navigateToPath: NavigateToPath) {
jobCreator.jobId = '';
stashJobForCloning(jobCreator, true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const JsonEditorFlyout: FC<Props> = ({ isDisabled, jobEditorMode, datafee
>
<FormattedMessage
id="xpack.ml.newJob.wizard.jsonFlyout.indicesChange.calloutText"
defaultMessage="It is not possible to alter the indices being used by the datafeed here. If you wish to select a different index pattern or saved search, please start the job creation again, selecting a different index pattern."
defaultMessage="You cannot alter the indices being used by the datafeed here. To select a different index pattern or saved search, go to step 1 of the wizard and select the Change index pattern option."
/>
</EuiCallOut>
</>
Expand Down
Loading

0 comments on commit 6e64940

Please sign in to comment.