Skip to content

Commit

Permalink
renaming tempJobCloningObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Sep 10, 2024
1 parent ae77a8c commit 4a13c21
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export const LinksMenuUI = (props: LinksMenuProps) => {
if (dataView === null) {
return;
}

dataView.getIndexPattern();
const field = findMessageField(dataView);
if (field !== null) {
setMessageField(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export async function cloneJob(toastNotifications, application, mlApi, jobId) {
loadFullJob(mlApi, jobId),
]);

const tempJobCloningObjects = {
const tempJobCloningData = {
skipTimeRangeStep: false,
};

Expand All @@ -232,9 +232,9 @@ export async function cloneJob(toastNotifications, application, mlApi, jobId) {
createdBy !== CREATED_BY_LABEL.ADVANCED
) {
// if the job is from a wizards, i.e. contains a created_by property
// use tempJobCloningObjects to temporarily store the job
tempJobCloningObjects.createdBy = originalJob?.custom_settings?.created_by;
tempJobCloningObjects.job = cloneableJob;
// use tempJobCloningData to temporarily store the job
tempJobCloningData.createdBy = originalJob?.custom_settings?.created_by;
tempJobCloningData.job = cloneableJob;

if (
originalJob.data_counts.earliest_record_timestamp !== undefined &&
Expand All @@ -260,27 +260,27 @@ export async function cloneJob(toastNotifications, application, mlApi, jobId) {
end = originalJob.data_counts.latest_bucket_timestamp + bucketSpanMs * 2 - 1;
}

tempJobCloningObjects.start = start;
tempJobCloningObjects.end = end;
tempJobCloningData.start = start;
tempJobCloningData.end = end;
}
} else {
// otherwise tempJobCloningObjects
tempJobCloningObjects.job = cloneableJob;
// otherwise tempJobCloningData
tempJobCloningData.job = cloneableJob;
// resets the createdBy field in case it still retains previous settings
tempJobCloningObjects.createdBy = undefined;
tempJobCloningData.createdBy = undefined;
}
if (datafeed !== undefined) {
tempJobCloningObjects.datafeed = datafeed;
tempJobCloningData.datafeed = datafeed;
}

if (originalJob.calendars) {
tempJobCloningObjects.calendars = await mlCalendarService.fetchCalendarsByIds(
tempJobCloningData.calendars = await mlCalendarService.fetchCalendarsByIds(
mlApi,
originalJob.calendars
);
}

jobCloningService.stashJobCloningObjects(tempJobCloningObjects);
jobCloningService.stashJobCloningData(tempJobCloningData);

application.navigateToApp(PLUGIN_ID, { path: ML_PAGES.ANOMALY_DETECTION_CREATE_JOB });
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const Page: FC<PageProps> = ({ existingJobsAndGroups, jobType }) => {
if (jobCloningService.calendars) {
jobCreator.calendars = jobCloningService.calendars;
}
jobCloningService.clearJobCloningObjects();
jobCloningService.clearJobCloningData();
} else {
// creating a new job
jobCreator.bucketSpan = DEFAULT_BUCKET_SPAN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
import type { JobCreator } from '../jobs/new_job/common/job_creator/job_creator';

interface TempJobCloningObjects {
interface TempJobCloningData {
createdBy: any;
datafeed: any;
job: any;
Expand All @@ -20,12 +20,12 @@ interface TempJobCloningObjects {
}

export class JobCloningService {
// tempJobCloningObjects -> used to pass a job object between the job management page and
// tempJobCloningData -> used to pass a job object between the job management page and
// and the advanced wizard.
// if populated when loading the advanced wizard, the job is used for cloning.
// if populated when loading the job management page, the start datafeed modal
// is automatically opened.
private tempJobCloningObjects: TempJobCloningObjects = {
private tempJobCloningData: TempJobCloningData = {
createdBy: undefined,
datafeed: undefined,
job: undefined,
Expand All @@ -36,12 +36,12 @@ export class JobCloningService {
autoSetTimeRange: false,
};

public getJobCloningObjects(): Readonly<TempJobCloningObjects> {
return this.tempJobCloningObjects;
public getJobCloningData(): Readonly<TempJobCloningData> {
return this.tempJobCloningData;
}

clearJobCloningObjects() {
this.tempJobCloningObjects = {
clearJobCloningData() {
this.tempJobCloningData = {
createdBy: undefined,
datafeed: undefined,
job: undefined,
Expand All @@ -59,7 +59,7 @@ export class JobCloningService {
includeTimeRange: boolean,
autoSetTimeRange: boolean = false
) {
const tempJobCloningObjects: TempJobCloningObjects = {
const tempJobCloningData: TempJobCloningData = {
job: jobCreator.jobConfig,
datafeed: jobCreator.datafeedConfig,
createdBy: jobCreator.createdBy ?? undefined,
Expand All @@ -75,16 +75,16 @@ export class JobCloningService {
: { autoSetTimeRange: true }),
};

this.tempJobCloningObjects = tempJobCloningObjects;
this.tempJobCloningData = tempJobCloningData;
}

public checkForAutoStartDatafeed() {
const job = this.tempJobCloningObjects.job;
const datafeed = this.tempJobCloningObjects.datafeed;
const job = this.tempJobCloningData.job;
const datafeed = this.tempJobCloningData.datafeed;
if (job !== undefined) {
this.tempJobCloningObjects.job = undefined;
this.tempJobCloningObjects.datafeed = undefined;
this.tempJobCloningObjects.createdBy = undefined;
this.tempJobCloningData.job = undefined;
this.tempJobCloningData.datafeed = undefined;
this.tempJobCloningData.createdBy = undefined;

const hasDatafeed = isPopulatedObject(datafeed);
const datafeedId = hasDatafeed ? datafeed.datafeed_id : '';
Expand All @@ -97,33 +97,33 @@ export class JobCloningService {
}
}

public stashJobCloningObjects(config: TempJobCloningObjects) {
this.tempJobCloningObjects = config;
public stashJobCloningData(config: TempJobCloningData) {
this.tempJobCloningData = config;
}

public get createdBy() {
return this.tempJobCloningObjects.createdBy;
return this.tempJobCloningData.createdBy;
}
public get datafeed() {
return this.tempJobCloningObjects.datafeed;
return this.tempJobCloningData.datafeed;
}
public get job() {
return this.tempJobCloningObjects.job;
return this.tempJobCloningData.job;
}
public get skipTimeRangeStep() {
return this.tempJobCloningObjects.skipTimeRangeStep;
return this.tempJobCloningData.skipTimeRangeStep;
}
public get start() {
return this.tempJobCloningObjects.start;
return this.tempJobCloningData.start;
}
public get end() {
return this.tempJobCloningObjects.end;
return this.tempJobCloningData.end;
}
public get calendars() {
return this.tempJobCloningObjects.calendars;
return this.tempJobCloningData.calendars;
}
public get autoSetTimeRange() {
return this.tempJobCloningObjects.autoSetTimeRange;
return this.tempJobCloningData.autoSetTimeRange;
}
}

Expand Down

0 comments on commit 4a13c21

Please sign in to comment.