Skip to content

Commit

Permalink
[Backport 2.x] Finish frontend S3 framework for integrations (#1086)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent b1331ed commit 48bd609
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
config={
Object {
"connectionDataSource": "",
"connectionLocation": "",
"connectionType": "index",
"displayName": "sample Integration",
}
Expand Down Expand Up @@ -109,6 +110,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="sample Integration"
value="sample Integration"
>
<EuiFormControlLayout
Expand All @@ -128,6 +130,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="sample Integration"
type="text"
value="sample Integration"
/>
Expand Down Expand Up @@ -690,6 +693,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
config={
Object {
"connectionDataSource": "",
"connectionLocation": "",
"connectionType": "index",
"displayName": "sample Integration",
}
Expand Down Expand Up @@ -1115,6 +1119,7 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="sample Integration"
value="Test Instance Name"
>
<EuiFormControlLayout
Expand All @@ -1134,6 +1139,7 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="sample Integration"
type="text"
value="Test Instance Name"
/>
Expand Down
21 changes: 19 additions & 2 deletions public/components/integrations/components/setup_integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface IntegrationSetupInputs {
displayName: string;
connectionType: string;
connectionDataSource: string;
connectionLocation: string;
}

interface IntegrationConfigProps {
Expand Down Expand Up @@ -201,6 +202,7 @@ export function SetupIntegrationForm({
<EuiFieldText
value={config.displayName}
onChange={(event) => updateConfig({ displayName: event.target.value })}
placeholder={`${integration.name} Integration`}
/>
</EuiFormRow>
<EuiSpacer />
Expand Down Expand Up @@ -244,6 +246,15 @@ export function SetupIntegrationForm({
singleSelection={{ asPlainText: true }}
/>
</EuiFormRow>
{config.connectionType === 's3' ? (
<EuiFormRow label="S3 Bucket Location">
<EuiFieldText
value={config.connectionLocation}
onChange={(event) => updateConfig({ connectionLocation: event.target.value })}
placeholder="s3://"
/>
</EuiFormRow>
) : null}
</EuiForm>
);
}
Expand All @@ -261,7 +272,7 @@ export function SetupBottomBar({
loading: boolean;
setLoading: (loading: boolean) => void;
loadingProgress: number;
setProgress: (updater: number | ((progress: number) => void)) => void;
setProgress: (updater: number | ((progress: number) => number)) => void;
}) {
const { setToast } = useToast();

Expand Down Expand Up @@ -313,7 +324,12 @@ export function SetupBottomBar({

// Queries must exist because we disable s3 if they're not present
for (const query of assets.data.queries!) {
const queryStr = query.query.replace('${TABLE}', config.connectionDataSource);
let queryStr = (query.query as string).replaceAll(
'{table_name}',
`${config.connectionDataSource}.default.${integration.name}`
);
queryStr = queryStr.replaceAll('{s3_bucket_location}', config.connectionLocation);
queryStr = queryStr.replaceAll('{object_name}', integration.name);
const currProgress = loadingProgress; // Need a frozen copy for getting accurate query steps
const result = await runQuery(queryStr, (step) =>
setProgress(currProgress + step)
Expand Down Expand Up @@ -381,6 +397,7 @@ export function SetupIntegrationPage({ integration }: { integration: string }) {
displayName: `${integration} Integration`,
connectionType: 'index',
connectionDataSource: '',
connectionLocation: '',
} as IntegrationSetupInputs);

const [template, setTemplate] = useState({
Expand Down

0 comments on commit 48bd609

Please sign in to comment.