Skip to content

Commit

Permalink
Get information from action type
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Jan 25, 2021
1 parent 14c2c02 commit 277b184
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 96 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/case/common/api/cases/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

import * as rt from 'io-ts';

import { ActionResult } from '../../../../actions/common';
import { ActionResult, ActionType } from '../../../../actions/common';
import { UserRT } from '../user';
import { CaseConnectorRt, ConnectorMappingsRt, ESCaseConnector } from '../connectors';

export type ActionConnector = ActionResult;
export { ActionType };

// TODO: we will need to add this type rt.literal('close-by-third-party')
const ClosureTypeRT = rt.union([rt.literal('close-by-user'), rt.literal('close-by-pushing')]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,35 @@
* you may not use this file except in compliance with the Elastic License.
*/

/* eslint-disable @kbn/eslint/no-restricted-paths */

import {
ServiceNowIMConnectorConfiguration,
ServiceNowSIRConnectorConfiguration,
JiraConnectorConfiguration,
ResilientConnectorConfiguration,
getResilientActionType,
getServiceNowIMActionType,
getServiceNowSIRActionType,
getJiraActionType,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../triggers_actions_ui/public/common';
import { ConnectorConfiguration } from './types';

const resilient = getResilientActionType();
const serviceNowIM = getServiceNowIMActionType();
const serviceNowSIR = getServiceNowSIRActionType();
const jira = getJiraActionType();

export const connectorsConfiguration: Record<string, ConnectorConfiguration> = {
'.servicenow': ServiceNowIMConnectorConfiguration as ConnectorConfiguration,
'.servicenow-sir': ServiceNowSIRConnectorConfiguration as ConnectorConfiguration,
'.jira': JiraConnectorConfiguration as ConnectorConfiguration,
'.resilient': ResilientConnectorConfiguration as ConnectorConfiguration,
'.servicenow': {
name: serviceNowIM.actionTypeTitle ?? '',
logo: serviceNowIM.iconClass,
},
'.servicenow-sir': {
name: serviceNowSIR.actionTypeTitle ?? '',
logo: serviceNowSIR.iconClass,
},
'.jira': {
name: jira.actionTypeTitle ?? '',
logo: jira.iconClass,
},
'.resilient': {
name: resilient.actionTypeTitle ?? '',
logo: resilient.iconClass,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import React from 'react';
import { ActionType } from '../../../../../triggers_actions_ui/public';

import {
ActionType as ThirdPartySupportedActions,
Expand All @@ -24,7 +23,8 @@ export interface ThirdPartyField {
defaultActionType: ThirdPartySupportedActions;
}

export interface ConnectorConfiguration extends ActionType {
export interface ConnectorConfiguration {
name: string;
logo: string;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ActionTypeModel,
ConnectorValidationResult,
} from '../../../../types';
import { connectorConfiguration } from './config';
import logo from './logo.svg';
import { JiraActionConnector, JiraConfig, JiraSecrets, JiraActionParams } from './types';
import * as i18n from './translations';
Expand Down Expand Up @@ -62,10 +61,10 @@ const validateConnector = (

export function getActionType(): ActionTypeModel<JiraConfig, JiraSecrets, JiraActionParams> {
return {
id: connectorConfiguration.id,
id: '.jira',
iconClass: logo,
selectMessage: i18n.JIRA_DESC,
actionTypeTitle: connectorConfiguration.name,
actionTypeTitle: i18n.JIRA_TITLE,
validateConnector,
actionConnectorFields: lazy(() => import('./jira_connectors')),
validateParams: (actionParams: JiraActionParams): GenericValidationResult<unknown> => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ActionTypeModel,
ConnectorValidationResult,
} from '../../../../types';
import { connectorConfiguration } from './config';
import logo from './logo.svg';
import {
ResilientActionConnector,
Expand Down Expand Up @@ -71,10 +70,10 @@ export function getActionType(): ActionTypeModel<
ResilientActionParams
> {
return {
id: connectorConfiguration.id,
id: '.resilient',
iconClass: logo,
selectMessage: i18n.DESC,
actionTypeTitle: connectorConfiguration.name,
actionTypeTitle: i18n.TITLE,
validateConnector,
actionConnectorFields: lazy(() => import('./resilient_connectors')),
validateParams: (actionParams: ResilientActionParams): GenericValidationResult<unknown> => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ActionTypeModel,
ConnectorValidationResult,
} from '../../../../types';
import { serviceNowIMConfiguration, serviceNowSIRConfiguration } from './config';
import logo from './logo.svg';
import {
ServiceNowActionConnector,
Expand Down Expand Up @@ -67,10 +66,10 @@ export function getServiceNowIMActionType(): ActionTypeModel<
ServiceNowIMActionParams
> {
return {
id: serviceNowIMConfiguration.id,
id: '.servicenow',
iconClass: logo,
selectMessage: serviceNowIMConfiguration.desc,
actionTypeTitle: serviceNowIMConfiguration.name,
selectMessage: i18n.SERVICENOW_DESC,
actionTypeTitle: i18n.SERVICENOW_TITLE,
validateConnector,
actionConnectorFields: lazy(() => import('./servicenow_connectors')),
validateParams: (actionParams: ServiceNowIMActionParams): GenericValidationResult<unknown> => {
Expand Down Expand Up @@ -100,10 +99,10 @@ export function getServiceNowSIRActionType(): ActionTypeModel<
ServiceNowSIRActionParams
> {
return {
id: serviceNowSIRConfiguration.id,
id: '.servicenow-sir',
iconClass: logo,
selectMessage: serviceNowSIRConfiguration.desc,
actionTypeTitle: serviceNowSIRConfiguration.name,
selectMessage: i18n.SERVICENOW_SIR_TITLE,
actionTypeTitle: i18n.SERVICENOW_SIR_TITLE,
validateConnector,
actionConnectorFields: lazy(() => import('./servicenow_connectors')),
validateParams: (actionParams: ServiceNowSIRActionParams): GenericValidationResult<unknown> => {
Expand Down
10 changes: 6 additions & 4 deletions x-pack/plugins/triggers_actions_ui/public/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export * from './index_controls';
export * from './lib';
export * from './types';

export { serviceNowIMConfiguration as ServiceNowIMConnectorConfiguration } from '../application/components/builtin_action_types/servicenow/config';
export { serviceNowSIRConfiguration as ServiceNowSIRConnectorConfiguration } from '../application/components/builtin_action_types/servicenow/config';
export { connectorConfiguration as JiraConnectorConfiguration } from '../application/components/builtin_action_types/jira/config';
export { connectorConfiguration as ResilientConnectorConfiguration } from '../application/components/builtin_action_types/resilient/config';
export {
getServiceNowIMActionType,
getServiceNowSIRActionType,
} from '../application/components/builtin_action_types/servicenow';
export { getJiraActionType } from '../application/components/builtin_action_types/jira';
export { getResilientActionType } from '../application/components/builtin_action_types/resilient';

0 comments on commit 277b184

Please sign in to comment.