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

feat(ui) Allow a user to type in a custom value in ingestion Secret Fields #6301

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
@@ -1,5 +1,5 @@
import React, { ReactNode } from 'react';
import { Divider, Form, Select } from 'antd';
import { AutoComplete, Divider, Form } from 'antd';
import styled from 'styled-components/macro';
import { Secret } from '../../../../../../types.generated';
import CreateSecretButton from './CreateSecretButton';
Expand Down Expand Up @@ -80,6 +80,8 @@ function SecretFieldTooltip({ tooltipLabel }: { tooltipLabel?: string | ReactNod
}

function SecretField({ field, secrets, removeMargin, refetchSecrets }: SecretFieldProps) {
const options = secrets.map((secret) => ({ value: `\${${secret.name}}`, label: secret.name }));

return (
<StyledFormItem
name={field.name}
Expand All @@ -89,24 +91,18 @@ function SecretField({ field, secrets, removeMargin, refetchSecrets }: SecretFie
removeMargin={!!removeMargin}
isSecretField
>
<Select
showSearch
<AutoComplete
placeholder={field.placeholder}
filterOption={(input, option) => !!option?.children.toLowerCase().includes(input.toLowerCase())}
filterOption={(input, option) => !!option?.value.toLowerCase().includes(input.toLowerCase())}
options={options}
dropdownRender={(menu) => (
<>
{menu}
<StyledDivider />
<CreateSecretButton refetchSecrets={refetchSecrets} />
</>
)}
>
{secrets.map((secret) => (
<Select.Option key={secret.urn} value={`\${${secret.name}}`}>
{secret.name}
</Select.Option>
))}
</Select>
/>
</StyledFormItem>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function clearFieldAndParents(recipe: any, fieldPath: string | string[]) {
export function setFieldValueOnRecipe(recipe: any, value: any, fieldPath: string | string[]) {
const updatedRecipe = { ...recipe };
if (value !== undefined) {
if (value === null) {
if (value === null || value === '') {
clearFieldAndParents(updatedRecipe, fieldPath);
return updatedRecipe;
}
Expand Down