mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-06 04:26:57 +00:00
ui feedbacks for 1.5.0 (#17545)
* ui feedbacks for 1.5.0 * fix sonar issue due to cron changes * minor fix
This commit is contained in:
parent
cf347adf72
commit
7f7dbef411
@ -30,7 +30,7 @@ export interface SelectTestSuiteProps {
|
||||
|
||||
export interface TestCaseFormProps {
|
||||
initialValue?: CreateTestCase;
|
||||
onSubmit: (data: CreateTestCase) => void;
|
||||
onSubmit: (data: CreateTestCase) => Promise<void>;
|
||||
onCancel: (data: CreateTestCase) => void;
|
||||
table: Table;
|
||||
}
|
||||
|
||||
@ -72,11 +72,12 @@ const ParameterForm: React.FC<ParameterFormProps> = ({ definition, table }) => {
|
||||
DynamicField?: ReactElement
|
||||
) => {
|
||||
const ruleValidation: RuleRender = ({ getFieldValue }) => ({
|
||||
validator(_, value) {
|
||||
validator(_, formValue) {
|
||||
if (data?.validationRule) {
|
||||
const fieldValue = data.validationRule.parameterField
|
||||
? getFieldValue(['params', data.validationRule.parameterField])
|
||||
? +getFieldValue(['params', data.validationRule.parameterField])
|
||||
: undefined;
|
||||
const value = +formValue;
|
||||
if (fieldValue && value) {
|
||||
switch (data.validationRule.rule) {
|
||||
case Rule.GreaterThanOrEquals:
|
||||
|
||||
@ -46,6 +46,7 @@ import {
|
||||
getListTestDefinitions,
|
||||
} from '../../../../rest/testAPI';
|
||||
import {
|
||||
filterSelectOptions,
|
||||
getNameFromFQN,
|
||||
replaceAllSpacialCharWith_,
|
||||
} from '../../../../utils/CommonUtils';
|
||||
@ -88,6 +89,7 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
|
||||
);
|
||||
const [testCases, setTestCases] = useState<TestCase[]>([]);
|
||||
const [currentColumnType, setCurrentColumnType] = useState<string>();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const columnName = Form.useWatch('column', form);
|
||||
|
||||
@ -196,8 +198,10 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
|
||||
};
|
||||
};
|
||||
|
||||
const handleFormSubmit: FormProps['onFinish'] = (value) => {
|
||||
onSubmit(createTestCaseObj(value));
|
||||
const handleFormSubmit: FormProps['onFinish'] = async (value) => {
|
||||
setLoading(true);
|
||||
await onSubmit(createTestCaseObj(value));
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const onBack = () => {
|
||||
@ -277,6 +281,16 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
|
||||
});
|
||||
}, [activeColumnFqn]);
|
||||
|
||||
const testTypeOptions = useMemo(
|
||||
() =>
|
||||
testDefinitions.map((suite) => ({
|
||||
label: getEntityName(suite),
|
||||
value: suite.fullyQualifiedName ?? '',
|
||||
})),
|
||||
|
||||
[testDefinitions]
|
||||
);
|
||||
|
||||
return (
|
||||
<Form
|
||||
data-testid="test-case-form"
|
||||
@ -359,10 +373,8 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
|
||||
<Select
|
||||
showSearch
|
||||
data-testid="test-type"
|
||||
options={testDefinitions.map((suite) => ({
|
||||
label: getEntityName(suite),
|
||||
value: suite.fullyQualifiedName,
|
||||
}))}
|
||||
filterOption={filterSelectOptions}
|
||||
options={testTypeOptions}
|
||||
placeholder={t('label.select-field', { field: t('label.test-type') })}
|
||||
onChange={handleTestDefinitionChange}
|
||||
/>
|
||||
@ -401,10 +413,14 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
|
||||
|
||||
<Form.Item noStyle>
|
||||
<Space className="w-full justify-end" size={16}>
|
||||
<Button data-testid="cancel-btn" onClick={onBack}>
|
||||
<Button data-testid="cancel-btn" disabled={loading} onClick={onBack}>
|
||||
{t('label.back')}
|
||||
</Button>
|
||||
<Button data-testid="submit-test" htmlType="submit" type="primary">
|
||||
<Button
|
||||
data-testid="submit-test"
|
||||
htmlType="submit"
|
||||
loading={loading}
|
||||
type="primary">
|
||||
{t('label.submit')}
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
@ -142,6 +142,11 @@ const EntityDeleteModal = ({
|
||||
type="text"
|
||||
value={name}
|
||||
onChange={handleOnChange}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && isNameMatching) {
|
||||
handleSave();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@ -22,11 +22,6 @@ export const getPeriodOptions = () => {
|
||||
value: '',
|
||||
prep: '',
|
||||
},
|
||||
{
|
||||
label: i18n.t('label.minute-plural'),
|
||||
value: 'minute',
|
||||
prep: '',
|
||||
},
|
||||
{
|
||||
label: i18n.t('label.hour'),
|
||||
value: 'hour',
|
||||
|
||||
@ -33,9 +33,6 @@ const mockProps: CronEditorProp = {
|
||||
const getHourDescription = (value: string) =>
|
||||
`label.schedule-to-run-every hour ${value} past the hour`;
|
||||
|
||||
const getMinuteDescription = (value: string) =>
|
||||
`label.schedule-to-run-every ${value}`;
|
||||
|
||||
const getDayDescription = () => 'label.schedule-to-run-every day at 00:00';
|
||||
|
||||
const handleScheduleEverySelector = async (text: string) => {
|
||||
@ -104,40 +101,6 @@ describe('Test CronEditor component', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('Minute option should render corresponding component', async () => {
|
||||
render(<CronEditor disabled={false} onChange={jest.fn} />);
|
||||
|
||||
await handleScheduleEverySelector('label.minute-plural');
|
||||
|
||||
expect(screen.getByTestId('schedule-description')).toHaveTextContent(
|
||||
getMinuteDescription('5')
|
||||
);
|
||||
|
||||
expect(
|
||||
await screen.findByTestId('minute-segment-container')
|
||||
).toBeInTheDocument();
|
||||
|
||||
const minutesOptions = await screen.findByTestId('minute-segment-options');
|
||||
|
||||
expect(minutesOptions).toBeInTheDocument();
|
||||
|
||||
const minuteSelect = await findByRole(minutesOptions, 'combobox');
|
||||
|
||||
act(() => {
|
||||
userEvent.click(minuteSelect);
|
||||
});
|
||||
await waitForElement(() => screen.getByText('15'));
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByText('15'));
|
||||
});
|
||||
|
||||
expect(await screen.getAllByText('15')).toHaveLength(2);
|
||||
|
||||
expect(screen.getByTestId('schedule-description')).toHaveTextContent(
|
||||
getMinuteDescription('15')
|
||||
);
|
||||
});
|
||||
|
||||
it('Day option should render corresponding component', async () => {
|
||||
render(<CronEditor disabled={false} onChange={jest.fn} />);
|
||||
|
||||
|
||||
@ -870,3 +870,13 @@ export const getServiceTypeExploreQueryFilter = (serviceType: string) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const filterSelectOptions = (
|
||||
input: string,
|
||||
option?: { label: string; value: string }
|
||||
) => {
|
||||
return (
|
||||
toLower(option?.label).includes(toLower(input)) ||
|
||||
toLower(option?.value).includes(toLower(input))
|
||||
);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user