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

Add applicable_data_sources field to workflows definition #1888

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -203,6 +203,17 @@ exports[`Integration Setup Inputs Renders the S3 connector form as expected 1`]
</EuiFormRow>
<EuiSpacer />
<IntegrationWorkflowsInputs
config={
Object {
"checkpointLocation": "",
"connectionDataSource": "ss4o_logs-nginx-test",
"connectionLocation": "",
"connectionTableName": "",
"connectionType": "s3",
"displayName": "Test Instance Name",
"enabledWorkflows": Array [],
}
}
integration={
Object {
"assets": Array [
Expand Down Expand Up @@ -443,6 +454,17 @@ exports[`Integration Setup Inputs Renders the S3 connector form without workflow
</EuiFormRow>
<EuiSpacer />
<IntegrationWorkflowsInputs
config={
Object {
"checkpointLocation": "",
"connectionDataSource": "ss4o_logs-nginx-test",
"connectionLocation": "",
"connectionTableName": "",
"connectionType": "s3",
"displayName": "Test Instance Name",
"enabledWorkflows": Array [],
}
}
integration={
Object {
"assets": Array [
Expand Down Expand Up @@ -2165,6 +2187,17 @@ exports[`Integration Setup Inputs Renders the query inputs 1`] = `

exports[`Integration Setup Inputs Renders the workflows inputs 1`] = `
<IntegrationWorkflowsInputs
config={
Object {
"checkpointLocation": "",
"connectionDataSource": "ss4o_logs-nginx-test",
"connectionLocation": "",
"connectionTableName": "",
"connectionType": "index",
"displayName": "Test Instance Name",
"enabledWorkflows": Array [],
}
}
integration={
Object {
"assets": Array [
Expand Down Expand Up @@ -2219,6 +2252,17 @@ exports[`Integration Setup Inputs Renders the workflows inputs 1`] = `
className="euiFormRow__fieldWrapper"
>
<SetupWorkflowSelector
config={
Object {
"checkpointLocation": "",
"connectionDataSource": "ss4o_logs-nginx-test",
"connectionLocation": "",
"connectionTableName": "",
"connectionType": "index",
"displayName": "Test Instance Name",
"enabledWorkflows": Array [],
}
}
id="random_html_id"
integration={
Object {
Expand Down Expand Up @@ -2372,3 +2416,257 @@ exports[`Integration Setup Inputs Renders the workflows inputs 1`] = `
</EuiFormRow>
</IntegrationWorkflowsInputs>
`;

exports[`Integration Setup Inputs Renders the workflows inputs with conditional workflows 1`] = `
<IntegrationWorkflowsInputs
config={
Object {
"checkpointLocation": "",
"connectionDataSource": "ss4o_logs-nginx-test",
"connectionLocation": "",
"connectionTableName": "",
"connectionType": "s3",
"displayName": "Test Instance Name",
"enabledWorkflows": Array [],
}
}
integration={
Object {
"assets": Array [
Object {
"extension": "ndjson",
"name": "sample",
"type": "savedObjectBundle",
"version": "1.0.1",
},
],
"components": Array [
Object {
"name": "logs",
"version": "1.0.0",
},
],
"license": "Apache-2.0",
"name": "sample",
"type": "logs",
"version": "2.0.0",
"workflows": Array [
Object {
"description": "This is a test workflow.",
"enabled_by_default": true,
"label": "Workflow 1",
"name": "workflow1",
},
Object {
"applicable_data_sources": Array [
"index",
],
"description": "This should not render.",
"enabled_by_default": true,
"label": "Workflow 2",
"name": "workflow2",
},
],
}
}
updateConfig={[Function]}
>
<EuiFormRow
describedByIds={Array []}
display="row"
error={
Array [
"Must select at least one workflow.",
]
}
fullWidth={false}
hasChildLabel={true}
hasEmptyLabelSpace={false}
isInvalid={false}
labelType="label"
>
<div
className="euiFormRow"
id="random_html_id-row"
>
<div
className="euiFormRow__fieldWrapper"
>
<SetupWorkflowSelector
config={
Object {
"checkpointLocation": "",
"connectionDataSource": "ss4o_logs-nginx-test",
"connectionLocation": "",
"connectionTableName": "",
"connectionType": "s3",
"displayName": "Test Instance Name",
"enabledWorkflows": Array [],
}
}
id="random_html_id"
integration={
Object {
"assets": Array [
Object {
"extension": "ndjson",
"name": "sample",
"type": "savedObjectBundle",
"version": "1.0.1",
},
],
"components": Array [
Object {
"name": "logs",
"version": "1.0.0",
},
],
"license": "Apache-2.0",
"name": "sample",
"type": "logs",
"version": "2.0.0",
"workflows": Array [
Object {
"description": "This is a test workflow.",
"enabled_by_default": true,
"label": "Workflow 1",
"name": "workflow1",
},
Object {
"applicable_data_sources": Array [
"index",
],
"description": "This should not render.",
"enabled_by_default": true,
"label": "Workflow 2",
"name": "workflow2",
},
],
}
}
onBlur={[Function]}
onFocus={[Function]}
toggleWorkflow={[Function]}
useWorkflows={
Array [
Array [
"workflow1",
true,
],
Array [
"workflow2",
true,
],
]
}
>
<EuiCheckableCard
checkableType="checkbox"
checked={true}
id="workflow-checkbox-workflow1"
key="workflow1"
label="Workflow 1"
onChange={[Function]}
value="workflow1"
>
<_EuiSplitPanelOuter
className="euiCheckableCard euiCheckableCard-isChecked"
direction="row"
hasBorder={true}
responsive={false}
>
<EuiPanel
className="euiSplitPanel euiSplitPanel--row euiCheckableCard euiCheckableCard-isChecked"
grow={false}
hasBorder={true}
paddingSize="none"
>
<div
className="euiPanel euiPanel--borderRadiusMedium euiPanel--plain euiPanel--hasShadow euiPanel--hasBorder euiPanel--flexGrowZero euiSplitPanel euiSplitPanel--row euiCheckableCard euiCheckableCard-isChecked"
>
<_EuiSplitPanelInner
color="primary"
grow={false}
onClick={[Function]}
>
<EuiPanel
borderRadius="none"
className="euiSplitPanel__inner"
color="primary"
element="div"
grow={false}
hasBorder={false}
hasShadow={false}
onClick={[Function]}
>
<div
className="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusNone euiPanel--primary euiPanel--noShadow euiPanel--noBorder euiPanel--flexGrowZero euiPanel--isClickable euiSplitPanel__inner"
onClick={[Function]}
>
<EuiCheckbox
checked={true}
compressed={false}
disabled={false}
id="workflow-checkbox-workflow1"
indeterminate={false}
onChange={[Function]}
value="workflow1"
>
<div
className="euiCheckbox euiCheckbox--noLabel"
>
<input
checked={true}
className="euiCheckbox__input"
disabled={false}
id="workflow-checkbox-workflow1"
onChange={[Function]}
type="checkbox"
value="workflow1"
/>
<div
className="euiCheckbox__square"
/>
</div>
</EuiCheckbox>
</div>
</EuiPanel>
</_EuiSplitPanelInner>
<_EuiSplitPanelInner>
<EuiPanel
borderRadius="none"
className="euiSplitPanel__inner"
color="transparent"
element="div"
hasBorder={false}
hasShadow={false}
>
<div
className="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusNone euiPanel--transparent euiPanel--noShadow euiPanel--noBorder euiSplitPanel__inner"
>
<label
aria-describedby="workflow-checkbox-workflow1-details"
className="euiCheckableCard__label"
htmlFor="workflow-checkbox-workflow1"
>
Workflow 1
</label>
<div
className="euiCheckableCard__children"
id="workflow-checkbox-workflow1-details"
>
This is a test workflow.
</div>
</div>
</EuiPanel>
</_EuiSplitPanelInner>
</div>
</EuiPanel>
</_EuiSplitPanelOuter>
</EuiCheckableCard>
</SetupWorkflowSelector>
</div>
</div>
</EuiFormRow>
</IntegrationWorkflowsInputs>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,42 @@ describe('Integration Setup Inputs', () => {

it('Renders the workflows inputs', async () => {
const wrapper = mount(
<IntegrationWorkflowsInputs updateConfig={() => {}} integration={TEST_INTEGRATION_CONFIG} />
<IntegrationWorkflowsInputs
config={TEST_INTEGRATION_SETUP_INPUTS}
updateConfig={() => {}}
integration={TEST_INTEGRATION_CONFIG}
/>
);

await waitFor(() => {
expect(wrapper).toMatchSnapshot();
});
});

it('Renders the workflows inputs with conditional workflows', async () => {
const wrapper = mount(
<IntegrationWorkflowsInputs
config={{ ...TEST_INTEGRATION_SETUP_INPUTS, connectionType: 's3' }}
updateConfig={() => {}}
integration={{
...TEST_INTEGRATION_CONFIG,
workflows: [
{
name: 'workflow1',
label: 'Workflow 1',
description: 'This is a test workflow.',
enabled_by_default: true,
},
{
name: 'workflow2',
label: 'Workflow 2',
description: 'This should not render.',
enabled_by_default: true,
applicable_data_sources: ['index'],
},
],
}}
/>
);

await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ const addIntegration = async ({
let sessionId: string | null = null;

if (config.connectionType === 'index') {
let enabledWorkflows: string[] | undefined;
if (integration.workflows) {
enabledWorkflows = integration.workflows
.filter((w) =>
w.applicable_data_sources ? w.applicable_data_sources.includes('index') : true
)
.map((w) => w.name);
}
const res = await addIntegrationRequest({
addSample: false,
templateName: integration.name,
Expand All @@ -147,6 +155,7 @@ const addIntegration = async ({
name: config.displayName,
indexPattern: config.connectionDataSource,
skipRedirect: setIsInstalling ? true : false,
workflows: enabledWorkflows,
});
if (setIsInstalling) {
setIsInstalling(false, res);
Expand Down
Loading
Loading