Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacing Angular watch list UI with React one #32401

Merged
merged 19 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const ACTION_MODES = {

export const ACTION_MODES: { [key: string]: string } = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript string-based enums (https://www.typescriptlang.org/docs/handbook/enums.html) are normally used for these list of constant values.

// The action execution will be simulated. For example, The email action will create the email that would have been sent but will not actually send it. In this mode, the action may be throttled if the current state of the watch indicates it should be.
SIMULATE: 'simulate',

Expand All @@ -19,6 +18,5 @@ export const ACTION_MODES = {
FORCE_EXECUTE: 'force_execute',

// The action will be skipped and won’t be executed nor simulated. Effectively forcing the action to be throttled.
SKIP: 'skip'

SKIP: 'skip',
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,34 @@

import { i18n } from '@kbn/i18n';

export const ACTION_STATES = {

export const ACTION_STATES: { [key: string]: string } = {
// Action is not being executed because conditions haven't been met
OK: i18n.translate('xpack.watcher.constants.actionStates.okStateText', {
defaultMessage: 'OK'
defaultMessage: 'OK',
}),

// Action has been acknowledged by user
ACKNOWLEDGED: i18n.translate('xpack.watcher.constants.actionStates.acknowledgedStateText', {
defaultMessage: 'Acked'
defaultMessage: 'Acked',
}),

// Action has been throttled (time-based) by the system
THROTTLED: i18n.translate('xpack.watcher.constants.actionStates.throttledStateText', {
defaultMessage: 'Throttled'
defaultMessage: 'Throttled',
}),

// Action has been completed
FIRING: i18n.translate('xpack.watcher.constants.actionStates.firingStateText', {
defaultMessage: 'Firing'
defaultMessage: 'Firing',
}),

// Action has failed
ERROR: i18n.translate('xpack.watcher.constants.actionStates.errorStateText', {
defaultMessage: 'Error'
defaultMessage: 'Error',
}),

// Action has a configuration error
CONFIG_ERROR: i18n.translate('xpack.watcher.constants.actionStates.configErrorStateText', {
defaultMessage: 'Config error'
defaultMessage: 'Config error',
}),

};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const ACTION_TYPES = {

export const ACTION_TYPES: { [key: string]: string } = {
EMAIL: 'email',

WEBHOOK: 'webhook',
Expand All @@ -22,6 +21,5 @@ export const ACTION_TYPES = {

PAGERDUTY: 'pagerduty',

UNKNOWN: 'unknown/invalid'

UNKNOWN: 'unknown/invalid',
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const AGG_TYPES = {

export const AGG_TYPES: { [key: string]: string } = {
COUNT: 'count',

AVERAGE: 'avg',
Expand All @@ -14,6 +13,5 @@ export const AGG_TYPES = {

MIN: 'min',

MAX: 'max'

MAX: 'max',
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const COMPARATORS = {

export const COMPARATORS: { [key: string]: string } = {
GREATER_THAN: '>',

LESS_THAN: '<'

LESS_THAN: '<',
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const ERROR_CODES = {

export const ERROR_CODES: { [key: string]: string } = {
// Property missing on object
ERR_PROP_MISSING: 'ERR_PROP_MISSING',
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const ES_SCROLL_SETTINGS = {

export const ES_SCROLL_SETTINGS: {
KEEPALIVE: string;
PAGE_SIZE: number;
} = {
// How long to keep a scroll alive
KEEPALIVE: '30s',

// How many results to return per scroll response
PAGE_SIZE: 100
PAGE_SIZE: 100,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const INDEX_NAMES = {
export const INDEX_NAMES: { [key: string]: string } = {
WATCHES: '.watches',
WATCHER_HISTORY: '.watcher-history-*',
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/

// Durations are in ms
export const LISTS = {
NEW_ITEMS_HIGHLIGHT_DURATION: 1 * 1000
export const LISTS: { [key: string]: number } = {
NEW_ITEMS_HIGHLIGHT_DURATION: 1 * 1000,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const PAGINATION = {
PAGE_SIZE: 20
export const PAGINATION: { [key: string]: number } = {
PAGE_SIZE: 20,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const WATCH_HISTORY = {
INITIAL_RANGE: 'now-1h'
export const PLUGIN: { [key: string]: string } = {
ID: 'watcher',
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// In milliseconds
const SIXTY_SECONDS = 60 * 1000;

export const REFRESH_INTERVALS = {
export const REFRESH_INTERVALS: { [key: string]: number } = {
WATCH_LIST: SIXTY_SECONDS,
WATCH_HISTORY: SIXTY_SECONDS,
WATCH_VISUALIZATION: SIXTY_SECONDS
WATCH_VISUALIZATION: SIXTY_SECONDS,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const ROUTES = {
export const ROUTES: { [key: string]: string } = {
API_ROOT: '/api/watcher',
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const SORT_ORDERS = {
export const SORT_ORDERS: { [key: string]: string } = {
ASCENDING: 'asc',
DESCENDING: 'desc'
DESCENDING: 'desc',
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const TIME_UNITS = {
export const TIME_UNITS: { [key: string]: string } = {
SECOND: 's',
MINUTE: 'm',
HOUR: 'h',
DAY: 'd'
DAY: 'd',
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const PLUGIN = {
ID: 'watcher'
export const WATCH_HISTORY: { [key: string]: string } = {
INITIAL_RANGE: 'now-1h',
};
33 changes: 0 additions & 33 deletions x-pack/plugins/watcher/common/constants/watch_state_comments.js

This file was deleted.

46 changes: 46 additions & 0 deletions x-pack/plugins/watcher/common/constants/watch_state_comments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 { i18n } from '@kbn/i18n';

export const WATCH_STATE_COMMENTS: { [key: string]: string } = {
OK: '',

PARTIALLY_THROTTLED: i18n.translate(
'xpack.watcher.constants.watchStateComments.partiallyThrottledStateCommentText',
{
defaultMessage: 'Partially throttled',
}
),

THROTTLED: i18n.translate(
'xpack.watcher.constants.watchStateComments.throttledStateCommentText',
{
defaultMessage: 'Throttled',
}
),

PARTIALLY_ACKNOWLEDGED: i18n.translate(
'xpack.watcher.constants.watchStateComments.partiallyAcknowledgedStateCommentText',
{
defaultMessage: 'Partially acked',
}
),

ACKNOWLEDGED: i18n.translate(
'xpack.watcher.constants.watchStateComments.acknowledgedStateCommentText',
{
defaultMessage: 'Acked',
}
),

FAILING: i18n.translate(
'xpack.watcher.constants.watchStateComments.executionFailingStateCommentText',
{
defaultMessage: 'Execution failing',
}
),
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@

import { i18n } from '@kbn/i18n';

export const WATCH_STATES = {

export const WATCH_STATES: { [key: string]: string } = {
DISABLED: i18n.translate('xpack.watcher.constants.watchStates.disabledStateText', {
defaultMessage: 'Disabled'
defaultMessage: 'Disabled',
}),

OK: i18n.translate('xpack.watcher.constants.watchStates.okStateText', {
defaultMessage: 'OK'
defaultMessage: 'OK',
}),

FIRING: i18n.translate('xpack.watcher.constants.watchStates.firingStateText', {
defaultMessage: 'Firing'
defaultMessage: 'Firing',
}),

ERROR: i18n.translate('xpack.watcher.constants.watchStates.errorStateText', {
defaultMessage: 'Error!'
defaultMessage: 'Error!',
bmcconaghy marked this conversation as resolved.
Show resolved Hide resolved
}),

CONFIG_ERROR: i18n.translate('xpack.watcher.constants.watchStates.configErrorStateText', {
defaultMessage: 'Config error'
defaultMessage: 'Config error',
}),

};
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const WATCH_TYPES = {

export const WATCH_TYPES: { [key: string]: string } = {
JSON: 'json',

THRESHOLD: 'threshold',

MONITORING: 'monitoring'

MONITORING: 'monitoring',
};
Loading