From be0a8dd23d15e280d4b0bf7dbae48afac50491d6 Mon Sep 17 00:00:00 2001 From: ppisljar Date: Wed, 16 Sep 2020 03:04:00 -0700 Subject: [PATCH] review feedback --- .../ui_actions_enhanced/.eslintrc.json | 5 ++++ .../ui_actions_enhanced/common/types.ts | 28 +++++++++++++++++++ .../components/action_wizard/test_data.tsx | 2 -- .../public/dynamic_actions/types.ts | 21 ++------------ .../ui_actions_service_enhancements.ts | 7 ++--- .../test_helpers/time_range_container.ts | 1 - .../ui_actions_enhanced/server/index.ts | 7 +++++ .../ui_actions_enhanced/server/types.ts | 25 ++--------------- 8 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 x-pack/plugins/ui_actions_enhanced/.eslintrc.json create mode 100644 x-pack/plugins/ui_actions_enhanced/common/types.ts diff --git a/x-pack/plugins/ui_actions_enhanced/.eslintrc.json b/x-pack/plugins/ui_actions_enhanced/.eslintrc.json new file mode 100644 index 000000000000000..2aab6c2d9093b66 --- /dev/null +++ b/x-pack/plugins/ui_actions_enhanced/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/consistent-type-definitions": 0 + } +} diff --git a/x-pack/plugins/ui_actions_enhanced/common/types.ts b/x-pack/plugins/ui_actions_enhanced/common/types.ts new file mode 100644 index 000000000000000..1150f4f823e8e46 --- /dev/null +++ b/x-pack/plugins/ui_actions_enhanced/common/types.ts @@ -0,0 +1,28 @@ +/* + * 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 { SerializableState } from '../../../../src/plugins/kibana_utils/common'; + +export type BaseActionConfig = SerializableState; + +export type SerializedAction = { + readonly factoryId: string; + readonly name: string; + readonly config: Config; +}; + +/** + * Serialized representation of a triggers-action pair, used to persist in storage. + */ +export type SerializedEvent = { + eventId: string; + triggers: string[]; + action: SerializedAction; +}; + +export type DynamicActionsState = { + events: SerializedEvent[]; +}; diff --git a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx index 4b8f52b48e2c9d7..af930bfba6b8b6a 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/components/action_wizard/test_data.tsx @@ -24,7 +24,6 @@ export const dashboards = [ { id: 'dashboard2', title: 'Dashboard 2' }, ]; -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions type DashboardDrilldownConfig = { dashboardId?: string; useCurrentFilters: boolean; @@ -120,7 +119,6 @@ export const dashboardFactory = new ActionFactory(dashboardDrilldownActionFactor getFeatureUsageStart: () => licensingMock.createStart().featureUsage, }); -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions type UrlDrilldownConfig = { url: string; openInNewTab: boolean; diff --git a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts index e906540a268d502..28d104093f64f7a 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/dynamic_actions/types.ts @@ -5,26 +5,9 @@ */ import { TriggerId } from '../../../../../src/plugins/ui_actions/public'; -import { SerializableState } from '../../../../../src/plugins/kibana_utils/common'; +import { SerializedAction, SerializedEvent, BaseActionConfig } from '../../common/types'; -export type BaseActionConfig = SerializableState; - -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type SerializedAction = { - readonly factoryId: string; - readonly name: string; - readonly config: Config; -}; - -/** - * Serialized representation of a triggers-action pair, used to persist in storage. - */ -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type SerializedEvent = { - eventId: string; - triggers: string[]; - action: SerializedAction; -}; +export { SerializedAction, SerializedEvent, BaseActionConfig }; /** * Action factory context passed into ActionFactories' CollectConfig, getDisplayName, getIconType diff --git a/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts b/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts index 360e30e11553d82..a999f9ec0098b0f 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/services/ui_actions_service_enhancements.ts @@ -19,10 +19,9 @@ import { LicensingPluginSetup, LicensingPluginStart } from '../../../licensing/p import { SavedObjectReference } from '../../../../../src/core/types'; import { PersistableStateDefinition } from '../../../../../src/plugins/kibana_utils/common'; -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type DynamicActionsState = { - events: SerializedEvent[]; -}; +import { DynamicActionsState } from '../../common/types'; + +export { DynamicActionsState }; export interface UiActionsServiceEnhancementsParams { readonly actionFactories?: ActionFactoryRegistry; diff --git a/x-pack/plugins/ui_actions_enhanced/public/test_helpers/time_range_container.ts b/x-pack/plugins/ui_actions_enhanced/public/test_helpers/time_range_container.ts index 3d143b0cacd0636..9a529f192158d6e 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/test_helpers/time_range_container.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/test_helpers/time_range_container.ts @@ -17,7 +17,6 @@ import { TimeRange } from '../../../../../src/plugins/data/public'; * https://github.com/microsoft/TypeScript/issues/15300 is fixed so we use a type * here instead */ -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions export type InheritedChildrenInput = { timeRange: TimeRange; id?: string; diff --git a/x-pack/plugins/ui_actions_enhanced/server/index.ts b/x-pack/plugins/ui_actions_enhanced/server/index.ts index 97552a6eda60be5..594c15bc270c079 100644 --- a/x-pack/plugins/ui_actions_enhanced/server/index.ts +++ b/x-pack/plugins/ui_actions_enhanced/server/index.ts @@ -22,3 +22,10 @@ export { SerializedAction as UiActionsEnhancedSerializedAction, SerializedEvent as UiActionsEnhancedSerializedEvent, } from './types'; + +export { + DynamicActionsState, + BaseActionConfig as UiActionsEnhancedBaseActionConfig, + SerializedAction as UiActionsEnhancedSerializedAction, + SerializedEvent as UiActionsEnhancedSerializedEvent, +} from '../common/types'; diff --git a/x-pack/plugins/ui_actions_enhanced/server/types.ts b/x-pack/plugins/ui_actions_enhanced/server/types.ts index 5942a03d6fe2b17..4859be67283442c 100644 --- a/x-pack/plugins/ui_actions_enhanced/server/types.ts +++ b/x-pack/plugins/ui_actions_enhanced/server/types.ts @@ -7,30 +7,9 @@ import { PersistableState, PersistableStateDefinition, - SerializableState, } from '../../../../src/plugins/kibana_utils/common'; -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type SerializedAction = { - readonly factoryId: string; - readonly name: string; - readonly config: Config; -}; - -/** - * Serialized representation of a triggers-action pair, used to persist in storage. - */ -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type SerializedEvent = { - eventId: string; - triggers: string[]; - action: SerializedAction; -}; - -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -export type DynamicActionsState = { - events: SerializedEvent[]; -}; +import { SerializedAction, SerializedEvent, DynamicActionsState } from '../common/types'; export type ActionFactoryRegistry = Map; @@ -43,3 +22,5 @@ export interface ActionFactory

extends PersistableState

{ id: string; } + +export { SerializedEvent, SerializedAction, DynamicActionsState };