Skip to content

Commit

Permalink
Rename subactions
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Aug 30, 2020
1 parent 90bc2fc commit 4f1f865
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ describe('api', () => {
});
});

describe('getIssueTypes', () => {
describe('issueTypes', () => {
test('it returns the issue types correctly', async () => {
const res = await api.getIssueTypes({
const res = await api.issueTypes({
externalService,
params: {},
});
Expand All @@ -359,9 +359,9 @@ describe('api', () => {
});
});

describe('getFieldsByIssueType', () => {
describe('fieldsByIssueType', () => {
test('it returns the issue types correctly', async () => {
const res = await api.getFieldsByIssueType({
const res = await api.fieldsByIssueType({
externalService,
params: { id: '10006' },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,6 @@ export const api: ExternalServiceApi = {
handshake: handshakeHandler,
pushToService: pushToServiceHandler,
getIncident: getIncidentHandler,
getIssueTypes: getIssueTypesHandler,
getFieldsByIssueType: getFieldsByIssueTypeHandler,
issueTypes: getIssueTypesHandler,
fieldsByIssueType: getFieldsByIssueTypeHandler,
};
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ async function executor(
logger.debug(`response push to service for incident id: ${data.id}`);
}

if (subAction === 'getIssueTypes') {
if (subAction === 'issueTypes') {
const getIssueTypesParams = subActionParams as ExecutorSubActionGetIssueTypesParams;
data = await api.getIssueTypes({
data = await api.issueTypes({
externalService,
params: getIssueTypesParams,
});
}

if (subAction === 'getFieldsByIssueType') {
if (subAction === 'fieldsByIssueType') {
const getFieldsByIssueTypeParams = subActionParams as ExecutorSubActionGetFieldsByIssueTypeParams;
data = await api.getFieldsByIssueType({
data = await api.fieldsByIssueType({
externalService,
params: getFieldsByIssueTypeParams,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ export const ExecutorParamsSchema = schema.oneOf([
subActionParams: ExecutorSubActionPushParamsSchema,
}),
schema.object({
subAction: schema.literal('getIssueTypes'),
subAction: schema.literal('issueTypes'),
subActionParams: ExecutorSubActionGetIssueTypesParamsSchema,
}),
schema.object({
subAction: schema.literal('getFieldsByIssueType'),
subAction: schema.literal('fieldsByIssueType'),
subActionParams: ExecutorSubActionGetFieldsByIssueTypeParamsSchema,
}),
]);
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ export interface ExternalServiceApi {
handshake: (args: HandshakeApiHandlerArgs) => Promise<void>;
pushToService: (args: PushToServiceApiHandlerArgs) => Promise<PushToServiceResponse>;
getIncident: (args: GetIncidentApiHandlerArgs) => Promise<void>;
getIssueTypes: (args: GetIssueTypesHandlerArgs) => Promise<GetIssueTypesResponse>;
getFieldsByIssueType: (
issueTypes: (args: GetIssueTypesHandlerArgs) => Promise<GetIssueTypesResponse>;
fieldsByIssueType: (
args: GetFieldsByIssueTypeHandlerArgs
) => Promise<GetFieldsByIssueTypeResponse>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const validateCommonConfig = (
}

try {
configurationUtilities.ensureWhitelistedUri(configObject.apiUrl);
configurationUtilities.ensureUriAllowed(configObject.apiUrl);
} catch (whitelistError) {
return i18n.WHITE_LISTED_ERROR(whitelistError.message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@
import { HttpSetup } from 'kibana/public';
import { BASE_ACTION_API_PATH } from '../../../constants';

export async function getCreateIssueMetadata({
http,
signal,
connectorId,
}: {
http: HttpSetup;
signal: AbortSignal;
connectorId: string;
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'getCreateIssueMetadata', subActionParams: {} },
}),
signal,
});
}

export async function getIssueTypes({
http,
signal,
Expand All @@ -35,7 +18,7 @@ export async function getIssueTypes({
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'getIssueTypes', subActionParams: {} },
params: { subAction: 'issueTypes', subActionParams: {} },
}),
signal,
});
Expand All @@ -54,7 +37,7 @@ export async function getFieldsByIssueType({
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'getFieldsByIssueType', subActionParams: { id } },
params: { subAction: 'fieldsByIssueType', subActionParams: { id } },
}),
signal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { DocLinksStart } from 'kibana/public';
import JiraConnectorFields from './Jira_connectors';
import JiraConnectorFields from './jira_connectors';
import { JiraActionConnector } from './types';

describe('JiraActionConnectorFields renders', () => {
Expand Down

0 comments on commit 4f1f865

Please sign in to comment.