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

[Backport 2.11] Add integrations queries for Flint #1195

Merged
merged 1 commit into from
Oct 27, 2023
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 @@ -31,6 +31,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
Object {
"connectionDataSource": "",
"connectionLocation": "",
"connectionTableName": "sample",
"connectionType": "index",
"displayName": "sample Integration",
}
Expand Down Expand Up @@ -87,9 +88,15 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
<EuiFormRow
describedByIds={Array []}
display="row"
error={
Array [
"Must be at least 1 character.",
]
}
fullWidth={false}
hasChildLabel={true}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Display Name"
labelType="label"
>
Expand All @@ -101,12 +108,15 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
className="euiFormRow__labelWrapper"
>
<EuiFormLabel
aria-invalid={false}
className="euiFormRow__label"
htmlFor="random_html_id"
isFocused={false}
isInvalid={false}
type="label"
>
<label
aria-invalid={false}
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Expand All @@ -119,6 +129,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
>
<EuiFieldText
id="random_html_id"
isInvalid={false}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
Expand All @@ -135,7 +146,9 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
<div
className="euiFormControlLayout__childrenWrapper"
>
<EuiValidatableControl>
<EuiValidatableControl
isInvalid={false}
>
<input
className="euiFieldText"
id="random_html_id"
Expand Down Expand Up @@ -354,12 +367,14 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
aria-describedby="random_html_id-help-0"
async={false}
compressed={false}
customOptionText="Select {searchValue} as your index"
fullWidth={false}
id="random_html_id"
isClearable={true}
isLoading={true}
onBlur={[Function]}
onChange={[Function]}
onCreateOption={[Function]}
onFocus={[Function]}
options={Array []}
selectedOptions={
Expand Down Expand Up @@ -680,6 +695,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
Object {
"connectionDataSource": "",
"connectionLocation": "",
"connectionTableName": "sample",
"connectionType": "index",
"displayName": "sample Integration",
}
Expand Down Expand Up @@ -817,6 +833,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
>
<EuiButtonEmpty
color="text"
disabled={false}
iconType="cross"
onClick={[Function]}
>
Expand Down Expand Up @@ -1068,9 +1085,15 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
<EuiFormRow
describedByIds={Array []}
display="row"
error={
Array [
"Must be at least 1 character.",
]
}
fullWidth={false}
hasChildLabel={true}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Display Name"
labelType="label"
>
Expand All @@ -1082,12 +1105,15 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
className="euiFormRow__labelWrapper"
>
<EuiFormLabel
aria-invalid={false}
className="euiFormRow__label"
htmlFor="random_html_id"
isFocused={false}
isInvalid={false}
type="label"
>
<label
aria-invalid={false}
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Expand All @@ -1100,6 +1126,7 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
>
<EuiFieldText
id="random_html_id"
isInvalid={false}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
Expand All @@ -1116,7 +1143,9 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
<div
className="euiFormControlLayout__childrenWrapper"
>
<EuiValidatableControl>
<EuiValidatableControl
isInvalid={false}
>
<input
className="euiFieldText"
id="random_html_id"
Expand Down Expand Up @@ -1354,12 +1383,14 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
aria-describedby="random_html_id-help-0"
async={false}
compressed={false}
customOptionText="Select {searchValue} as your index"
fullWidth={false}
id="random_html_id"
isClearable={true}
isLoading={true}
onBlur={[Function]}
onChange={[Function]}
onCreateOption={[Function]}
onFocus={[Function]}
options={Array []}
selectedOptions={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export async function addIntegrationRequest(
setToast: (title: string, color?: Color, text?: string | undefined) => void,
name?: string,
dataSource?: string
) {
): Promise<boolean> {
const http = coreRefs.http!;
if (addSample) {
createDataSourceMappings(
Expand All @@ -309,7 +309,7 @@ export async function addIntegrationRequest(
dataSource = `ss4o_${integration.type}-${integrationTemplateId}-sample-sample`;
}

const response: boolean = await http
let response: boolean = await http
.post(`${INTEGRATIONS_BASE}/store/${templateName}`, {
body: JSON.stringify({ name, dataSource }),
})
Expand All @@ -323,7 +323,7 @@ export async function addIntegrationRequest(
return false;
});
if (!addSample || !response) {
return;
return response;
}
const data: { sampleData: unknown[] } = await http
.get(`${INTEGRATIONS_BASE}/repository/${templateName}/data`)
Expand All @@ -337,16 +337,21 @@ export async function addIntegrationRequest(
data.sampleData
.map((record) => `{"create": { "_index": "${dataSource}" } }\n${JSON.stringify(record)}`)
.join('\n') + '\n';
http
response = await http
.post(CONSOLE_PROXY, {
body: requestBody,
query: {
path: `${dataSource}/_bulk?refresh=wait_for`,
method: 'POST',
},
})
.then((_) => {
return true;
})
.catch((err) => {
console.error(err);
setToast('Failed to load sample data', 'danger');
return false;
});
return response;
}
Loading
Loading