mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-16 02:42:00 +00:00
Minor: Add support for beta tag for form field (#16921)
This commit is contained in:
parent
bfa9e237de
commit
5a7b0b48c2
@ -21,4 +21,5 @@ export interface FormItemLabelProps {
|
|||||||
overlayClassName?: string;
|
overlayClassName?: string;
|
||||||
overlayInnerStyle?: React.CSSProperties;
|
overlayInnerStyle?: React.CSSProperties;
|
||||||
align?: TooltipProps['align'];
|
align?: TooltipProps['align'];
|
||||||
|
isBeta?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,4 +50,26 @@ describe('Test FormItemLabel Component', () => {
|
|||||||
expect(label).toContainHTML(mockProps.label as string);
|
expect(label).toContainHTML(mockProps.label as string);
|
||||||
expect(helpIcon).toBeInTheDocument();
|
expect(helpIcon).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should render beta badge if isBeta is true', async () => {
|
||||||
|
render(<FormItemLabel {...mockProps} isBeta />);
|
||||||
|
|
||||||
|
const label = screen.getByTestId('form-item-label');
|
||||||
|
|
||||||
|
const betaBadge = screen.getByText('label.beta');
|
||||||
|
|
||||||
|
expect(label).toContainHTML(mockProps.label as string);
|
||||||
|
expect(betaBadge).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not render beta badge if isBeta is false', async () => {
|
||||||
|
render(<FormItemLabel {...mockProps} />);
|
||||||
|
|
||||||
|
const label = screen.getByTestId('form-item-label');
|
||||||
|
|
||||||
|
const betaBadge = screen.queryByText('label.beta');
|
||||||
|
|
||||||
|
expect(label).toContainHTML(mockProps.label as string);
|
||||||
|
expect(betaBadge).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,9 +12,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { InfoCircleOutlined } from '@ant-design/icons';
|
import { InfoCircleOutlined } from '@ant-design/icons';
|
||||||
import { Tooltip } from 'antd';
|
import { Badge, Tooltip } from 'antd';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { GRAYED_OUT_COLOR } from '../../../constants/constants';
|
import { GRAYED_OUT_COLOR } from '../../../constants/constants';
|
||||||
|
import { useApplicationStore } from '../../../hooks/useApplicationStore';
|
||||||
import { FormItemLabelProps } from './Form.interface';
|
import { FormItemLabelProps } from './Form.interface';
|
||||||
|
|
||||||
const FormItemLabel = ({
|
const FormItemLabel = ({
|
||||||
@ -24,7 +26,11 @@ const FormItemLabel = ({
|
|||||||
overlayInnerStyle,
|
overlayInnerStyle,
|
||||||
overlayClassName,
|
overlayClassName,
|
||||||
placement = 'top',
|
placement = 'top',
|
||||||
|
isBeta = false,
|
||||||
}: FormItemLabelProps) => {
|
}: FormItemLabelProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { theme } = useApplicationStore();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span data-testid="form-item-label">{label}</span>
|
<span data-testid="form-item-label">{label}</span>
|
||||||
@ -43,6 +49,14 @@ const FormItemLabel = ({
|
|||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
{isBeta && (
|
||||||
|
<Badge
|
||||||
|
className="m-l-xs"
|
||||||
|
color={theme.primaryColor}
|
||||||
|
count={t('label.beta')}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -54,4 +54,5 @@ export interface FieldProp {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
hasSeparator?: boolean;
|
hasSeparator?: boolean;
|
||||||
formItemLayout?: FormItemLayout;
|
formItemLayout?: FormItemLayout;
|
||||||
|
isBeta?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,15 +27,15 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
.ant-form-item-label {
|
.ant-form-item-label {
|
||||||
display: block;
|
display: block;
|
||||||
flex: 0 0 33.33333333%;
|
flex: 0 0 40%;
|
||||||
max-width: 33.33333333%;
|
max-width: 40%;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
}
|
}
|
||||||
.ant-form-item-control {
|
.ant-form-item-control {
|
||||||
display: block;
|
display: block;
|
||||||
flex: 0 0 66.66666667%;
|
flex: 0 0 60%;
|
||||||
max-width: 66.66666667%;
|
max-width: 60%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,7 @@ export const getField = (field: FieldProp) => {
|
|||||||
id,
|
id,
|
||||||
formItemProps,
|
formItemProps,
|
||||||
hasSeparator = false,
|
hasSeparator = false,
|
||||||
|
isBeta = false,
|
||||||
formItemLayout = 'vertical',
|
formItemLayout = 'vertical',
|
||||||
} = field;
|
} = field;
|
||||||
|
|
||||||
@ -209,6 +210,7 @@ export const getField = (field: FieldProp) => {
|
|||||||
<FormItemLabel
|
<FormItemLabel
|
||||||
align={props.tooltipAlign as TooltipProps['align']}
|
align={props.tooltipAlign as TooltipProps['align']}
|
||||||
helperText={helperText}
|
helperText={helperText}
|
||||||
|
isBeta={isBeta}
|
||||||
label={label}
|
label={label}
|
||||||
overlayClassName={props.overlayClassName as string}
|
overlayClassName={props.overlayClassName as string}
|
||||||
overlayInnerStyle={props.overlayInnerStyle as React.CSSProperties}
|
overlayInnerStyle={props.overlayInnerStyle as React.CSSProperties}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user