mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-13 09:52:46 +00:00
feat(ui) Allow a user to type in a custom value in ingestion Secret Fields (#6301)
This commit is contained in:
parent
ef824bd082
commit
6aedf67b02
@ -1,5 +1,5 @@
|
|||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
import { Divider, Form, Select } from 'antd';
|
import { AutoComplete, Divider, Form } from 'antd';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import { Secret } from '../../../../../../types.generated';
|
import { Secret } from '../../../../../../types.generated';
|
||||||
import CreateSecretButton from './CreateSecretButton';
|
import CreateSecretButton from './CreateSecretButton';
|
||||||
@ -80,6 +80,8 @@ function SecretFieldTooltip({ tooltipLabel }: { tooltipLabel?: string | ReactNod
|
|||||||
}
|
}
|
||||||
|
|
||||||
function SecretField({ field, secrets, removeMargin, refetchSecrets }: SecretFieldProps) {
|
function SecretField({ field, secrets, removeMargin, refetchSecrets }: SecretFieldProps) {
|
||||||
|
const options = secrets.map((secret) => ({ value: `\${${secret.name}}`, label: secret.name }));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledFormItem
|
<StyledFormItem
|
||||||
name={field.name}
|
name={field.name}
|
||||||
@ -89,10 +91,10 @@ function SecretField({ field, secrets, removeMargin, refetchSecrets }: SecretFie
|
|||||||
removeMargin={!!removeMargin}
|
removeMargin={!!removeMargin}
|
||||||
isSecretField
|
isSecretField
|
||||||
>
|
>
|
||||||
<Select
|
<AutoComplete
|
||||||
showSearch
|
|
||||||
placeholder={field.placeholder}
|
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) => (
|
dropdownRender={(menu) => (
|
||||||
<>
|
<>
|
||||||
{menu}
|
{menu}
|
||||||
@ -100,13 +102,7 @@ function SecretField({ field, secrets, removeMargin, refetchSecrets }: SecretFie
|
|||||||
<CreateSecretButton refetchSecrets={refetchSecrets} />
|
<CreateSecretButton refetchSecrets={refetchSecrets} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
>
|
/>
|
||||||
{secrets.map((secret) => (
|
|
||||||
<Select.Option key={secret.urn} value={`\${${secret.name}}`}>
|
|
||||||
{secret.name}
|
|
||||||
</Select.Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</StyledFormItem>
|
</StyledFormItem>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ function clearFieldAndParents(recipe: any, fieldPath: string | string[]) {
|
|||||||
export function setFieldValueOnRecipe(recipe: any, value: any, fieldPath: string | string[]) {
|
export function setFieldValueOnRecipe(recipe: any, value: any, fieldPath: string | string[]) {
|
||||||
const updatedRecipe = { ...recipe };
|
const updatedRecipe = { ...recipe };
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if (value === null) {
|
if (value === null || value === '') {
|
||||||
clearFieldAndParents(updatedRecipe, fieldPath);
|
clearFieldAndParents(updatedRecipe, fieldPath);
|
||||||
return updatedRecipe;
|
return updatedRecipe;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user