Skip to content

Commit

Permalink
[ML] Adds waiting state for transforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Apr 28, 2021
1 parent 0cf1256 commit a1c14f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/transform/common/api_schemas/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ export const transformIdsSchema = schema.arrayOf(

export type TransformIdsSchema = TypeOf<typeof transformIdsSchema>;

// reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/TransformStats.java#L250
export const transformStateSchema = schema.oneOf([
schema.literal(TRANSFORM_STATE.ABORTING),
schema.literal(TRANSFORM_STATE.FAILED),
schema.literal(TRANSFORM_STATE.INDEXING),
schema.literal(TRANSFORM_STATE.STARTED),
schema.literal(TRANSFORM_STATE.STOPPED),
schema.literal(TRANSFORM_STATE.STOPPING),
schema.literal(TRANSFORM_STATE.WAITING),
]);

export const indexPatternTitleSchema = schema.object({
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/transform/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ export const APP_CREATE_TRANSFORM_CLUSTER_PRIVILEGES = [

export const APP_INDEX_PRIVILEGES = ['monitor'];

// reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/transforms/DataFrameTransformStats.java#L243
// reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/TransformStats.java#L250
export const TRANSFORM_STATE = {
ABORTING: 'aborting',
FAILED: 'failed',
INDEXING: 'indexing',
STARTED: 'started',
STOPPED: 'stopped',
STOPPING: 'stopping',
WAITING: 'waiting',
} as const;

const transformStates = Object.values(TRANSFORM_STATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ import { TRANSFORM_STATE } from '../../../../../../common/constants';
import { getTransformProgress, TransformListRow, TRANSFORM_LIST_COLUMN } from '../../../../common';
import { useActions } from './use_actions';

// reflects https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/TransformStats.java#L250
const STATE_COLOR = {
aborting: 'warning',
failed: 'danger',
indexing: 'primary',
started: 'primary',
stopped: 'hollow',
stopping: 'hollow',
waiting: 'hollow',
} as const;

export const getTaskStateBadge = (
Expand Down Expand Up @@ -202,13 +204,15 @@ export const useColumns = (
{!isBatchTransform && (
<Fragment>
<EuiFlexItem style={{ width: '40px' }} grow={false}>
{/* If not stopped or failed show the animated progress bar */}
{/* If not stopped, failed or waiting show the animated progress bar */}
{item.stats.state !== TRANSFORM_STATE.STOPPED &&
item.stats.state !== TRANSFORM_STATE.WAITING &&
item.stats.state !== TRANSFORM_STATE.FAILED && (
<EuiProgress color="primary" size="m" />
)}
{/* If stopped or failed show an empty (0%) progress bar */}
{/* If stopped, failed or waiting show an empty (0%) progress bar */}
{(item.stats.state === TRANSFORM_STATE.STOPPED ||
item.stats.state === TRANSFORM_STATE.WAITING ||
item.stats.state === TRANSFORM_STATE.FAILED) && (
<EuiProgress value={0} max={100} color="primary" size="m" />
)}
Expand Down

0 comments on commit a1c14f3

Please sign in to comment.