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

ENG-2789 Fix for Airflow Integration Dialog Rendering Infinitely #1206

Merged
merged 4 commits into from
Apr 13, 2023
Merged
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
61 changes: 24 additions & 37 deletions src/ui/common/src/components/integrations/dialogs/airflowDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Box from '@mui/material/Box';
import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';

import { AirflowConfig } from '../../../utils/integrations';
import { readOnlyFieldDisableReason, readOnlyFieldWarning } from './constants';
Expand All @@ -24,29 +24,7 @@ export const AirflowDialog: React.FC<Props> = ({
value,
editMode,
}) => {
const [host, setHost] = useState<string>(value?.host ?? null);
const [s3CredsProfile, setS3CredsProfile] = useState<string>(
value?.s3_credentials_profile ?? Placeholders.s3_credentials_profile
);

useEffect(() => {
if (host) {
if (host.startsWith('http://')) {
// Backend requires the protocol to be stripped
onUpdateField('host', host.substring(7));
} else if (host.startsWith('https://')) {
// Backend requires the protocol to be stripped
onUpdateField('host', host.substring(8));
} else {
onUpdateField('host', host);
}
}

if (s3CredsProfile) {
onUpdateField('s3_credentials_profile', s3CredsProfile);
}
}, [host, onUpdateField, s3CredsProfile]);

const [host, setHost] = useState<string>(value?.host ?? '');
return (
<Box sx={{ mt: 2 }}>
<IntegrationTextInputField
Expand All @@ -55,7 +33,18 @@ export const AirflowDialog: React.FC<Props> = ({
label="Host *"
description="The hostname of the Airflow server."
placeholder={Placeholders.host}
onChange={(event) => setHost(event.target.value)}
onChange={(event) => {
setHost(event.target.value);
if (event.target.value.startsWith('http://')) {
// Backend requires the protocol to be stripped
onUpdateField('host', event.target.value.substring(7));
} else if (event.target.value.startsWith('https://')) {
// Backend requires the protocol to be stripped
onUpdateField('host', event.target.value.substring(8));
} else {
onUpdateField('host', event.target.value);
}
}}
value={host}
disabled={editMode}
warning={editMode ? undefined : readOnlyFieldWarning}
Expand All @@ -69,7 +58,7 @@ export const AirflowDialog: React.FC<Props> = ({
description="The username of a user with access to the above server."
placeholder={Placeholders.username}
onChange={(event) => onUpdateField('username', event.target.value)}
value={value?.username ?? null}
value={value?.username ?? ''}
/>

<IntegrationTextInputField
Expand All @@ -80,7 +69,7 @@ export const AirflowDialog: React.FC<Props> = ({
placeholder={Placeholders.password}
type="password"
onChange={(event) => onUpdateField('password', event.target.value)}
value={value?.password ?? null}
value={value?.password ?? ''}
/>

<IntegrationTextInputField
Expand All @@ -89,10 +78,10 @@ export const AirflowDialog: React.FC<Props> = ({
label="S3 Credentials Path *"
description="The path on the Airflow server to the AWS credentials that have access to the same S3 bucket configured for Aqueduct storage."
placeholder={Placeholders.s3_credentials_path}
onChange={(event) =>
onUpdateField('s3_credentials_path', event.target.value)
}
value={value?.s3_credentials_path ?? null}
onChange={(event) => {
onUpdateField('s3_credentials_path', event.target.value);
}}
value={value?.s3_credentials_path ?? ''}
/>

<IntegrationTextInputField
Expand All @@ -101,12 +90,10 @@ export const AirflowDialog: React.FC<Props> = ({
label="S3 Credentials Profile"
description="The profile to use for the AWS credentials above. The default profile will be used if none is provided."
placeholder={Placeholders.s3_credentials_profile}
onChange={(event) => setS3CredsProfile(event.target.value)}
value={
s3CredsProfile !== Placeholders.s3_credentials_profile
? s3CredsProfile
: null
}
onChange={(event) => {
onUpdateField('s3_credentials_profile', event.target.value);
}}
value={value?.s3_credentials_profile ?? ''}
/>
</Box>
);
Expand Down