Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

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 @@ -33,11 +33,18 @@ const ConnectorCasesWebhookTypeFieldsRt = rt.strict({
* Jira
*/

export const JiraFieldsRt = rt.strict({
issueType: rt.union([rt.string, rt.null]),
priority: rt.union([rt.string, rt.null]),
parent: rt.union([rt.string, rt.null]),
});
export const JiraFieldsRt = rt.intersection([
rt.strict({
issueType: rt.union([rt.string, rt.null]),
priority: rt.union([rt.string, rt.null]),
parent: rt.union([rt.string, rt.null]),
}),
rt.exact(
rt.partial({
otherFields: rt.union([rt.string, rt.null]),
})
),
]);

export type JiraFieldsType = rt.TypeOf<typeof JiraFieldsRt>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ describe('Jira Fields', () => {

expect(await screen.findByTestId('prioritySelect')).toBeInTheDocument();
expect(await screen.findByTestId('issueTypeSelect')).toBeInTheDocument();
expect(await screen.findByTestId('otherFieldsEditor')).toBeInTheDocument();

expect(await screen.findByTestId('search-parent-issues')).toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { ConnectorFieldsProps } from '../types';
import { useGetIssueTypes } from './use_get_issue_types';
import { useGetFieldsByIssueType } from './use_get_fields_by_issue_type';
import { SearchIssues } from './search_issues';
import { JsonEditorField } from '../json_editor_field';

const { emptyField } = fieldValidators;

Expand Down Expand Up @@ -134,6 +135,27 @@ const JiraFieldsComponent: React.FunctionComponent<ConnectorFieldsProps> = ({ co
</EuiFlexItem>
</EuiFlexGroup>
</div>
<EuiSpacer size="m" />
<UseField
path="fields.otherFields"
component={JsonEditorField}
config={{
label: i18n.OTHER_FIELDS,
}}
componentProps={{
euiCodeEditorProps: {
fullWidth: true,
height: '200px',
disabled: isLoadingIssueTypes,
isLoading: isLoadingIssueTypes,
options: {
fontSize: '12px',
renderValidationDecorations: 'off',
},
},
dataTestSubj: 'otherFieldsEditor',
}}
/>
</EuiSkeletonText>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('Jira Fields: Preview', () => {
issueType: '10006',
priority: 'High',
parent: 'Parent Task',
otherFields: '{"testField":"testValue"}',
};

beforeEach(() => {
Expand All @@ -56,5 +57,6 @@ describe('Jira Fields: Preview', () => {
expect(getByTextWithMarkup('Issue type: Task')).toBeInTheDocument();
expect(getByTextWithMarkup('Parent issue: Parent Task')).toBeInTheDocument();
expect(getByTextWithMarkup('Priority: High')).toBeInTheDocument();
expect(getByTextWithMarkup('{"testField":"testValue"}')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const JiraFieldsPreviewComponent: React.FunctionComponent<
});

const issueTypes = issueTypesData?.data;
const otherFields = fields?.otherFields ?? '';

const listItems = useMemo(
() => [
Expand Down Expand Up @@ -58,8 +59,17 @@ const JiraFieldsPreviewComponent: React.FunctionComponent<
},
]
: []),
...(otherFields != null && otherFields.length > 0
? [
{
title: i18n.OTHER_FIELDS,
description: otherFields,
displayAsCodeBlock: true,
},
]
: []),
],
[issueType, issueTypes, parent, priority]
[issueType, issueTypes, parent, priority, otherFields]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ export const PARENT_ISSUE = i18n.translate('xpack.cases.connectors.jira.parentIs
export const ISSUE_TYPE_REQUIRED = i18n.translate('xpack.cases.connectors.jira.issueTypeRequired', {
defaultMessage: 'Issue type is required',
});

export const OTHER_FIELDS = i18n.translate(
'xpack.cases.connectors.jira.otherFieldsSelectFieldLabel',
{
defaultMessage: 'Other fields',
}
);