mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
## Summary Removes RuleTypeSchema in favor of Type for TypeScript. Does break out one function called `parseScheduleDates` into its own file to remove a circular ref issue.
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
import { Type } from '../detection_engine/schemas/common/schemas';
|
|
|
|
// Based on ML Job/Datafeed States from x-pack/legacy/plugins/ml/common/constants/states.js
|
|
const enabledStates = ['started', 'opened'];
|
|
const loadingStates = ['starting', 'stopping', 'opening', 'closing'];
|
|
const failureStates = ['deleted', 'failed'];
|
|
|
|
export const isJobStarted = (jobState: string, datafeedState: string): boolean => {
|
|
return enabledStates.includes(jobState) && enabledStates.includes(datafeedState);
|
|
};
|
|
|
|
export const isJobLoading = (jobState: string, datafeedState: string): boolean => {
|
|
return loadingStates.includes(jobState) || loadingStates.includes(datafeedState);
|
|
};
|
|
|
|
export const isJobFailed = (jobState: string, datafeedState: string): boolean => {
|
|
return failureStates.includes(jobState) || failureStates.includes(datafeedState);
|
|
};
|
|
|
|
export const isMlRule = (ruleType: Type) => ruleType === 'machine_learning';
|