mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-04 06:33:10 +00:00
* UI: Fixed issue: UI: Issues around Add Data Quality Test #7498 * remove tailwind class
This commit is contained in:
parent
e9d77a2c01
commit
6fb2b87a29
@ -22,17 +22,20 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Typography,
|
Typography,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
|
import { useForm } from 'antd/lib/form/Form';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
import { EditorContentRef } from 'Models';
|
import { EditorContentRef } from 'Models';
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { useHistory, useParams } from 'react-router-dom';
|
import { useHistory, useParams } from 'react-router-dom';
|
||||||
|
import { useAuthContext } from '../../../authentication/auth-provider/AuthProvider';
|
||||||
import { getListTestSuites } from '../../../axiosAPIs/testAPI';
|
import { getListTestSuites } from '../../../axiosAPIs/testAPI';
|
||||||
import {
|
import {
|
||||||
API_RES_MAX_SIZE,
|
API_RES_MAX_SIZE,
|
||||||
getTableTabPath,
|
getTableTabPath,
|
||||||
} from '../../../constants/constants';
|
} from '../../../constants/constants';
|
||||||
import { TestSuite } from '../../../generated/tests/testSuite';
|
import { TestSuite } from '../../../generated/tests/testSuite';
|
||||||
|
import { useAuth } from '../../../hooks/authHooks';
|
||||||
import SVGIcons, { Icons } from '../../../utils/SvgUtils';
|
import SVGIcons, { Icons } from '../../../utils/SvgUtils';
|
||||||
import { showErrorToast } from '../../../utils/ToastUtils';
|
import { showErrorToast } from '../../../utils/ToastUtils';
|
||||||
import RichTextEditor from '../../common/rich-text-editor/RichTextEditor';
|
import RichTextEditor from '../../common/rich-text-editor/RichTextEditor';
|
||||||
@ -46,7 +49,18 @@ const SelectTestSuite: React.FC<SelectTestSuiteProps> = ({
|
|||||||
initialValue,
|
initialValue,
|
||||||
}) => {
|
}) => {
|
||||||
const { entityTypeFQN } = useParams<Record<string, string>>();
|
const { entityTypeFQN } = useParams<Record<string, string>>();
|
||||||
|
const { isAdminUser } = useAuth();
|
||||||
|
const { isAuthDisabled } = useAuthContext();
|
||||||
|
const [form] = useForm();
|
||||||
|
const hasAccess = isAdminUser || isAuthDisabled;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const [formData, setFormData] = useState<{
|
||||||
|
testSuiteId: string;
|
||||||
|
testSuiteName: string;
|
||||||
|
}>({
|
||||||
|
testSuiteId: initialValue?.data?.id || '',
|
||||||
|
testSuiteName: initialValue?.name || '',
|
||||||
|
});
|
||||||
const [isNewTestSuite, setIsNewTestSuite] = useState(
|
const [isNewTestSuite, setIsNewTestSuite] = useState(
|
||||||
initialValue?.isNewTestSuite ?? false
|
initialValue?.isNewTestSuite ?? false
|
||||||
);
|
);
|
||||||
@ -69,6 +83,10 @@ const SelectTestSuite: React.FC<SelectTestSuiteProps> = ({
|
|||||||
return markdownRef.current?.getEditorContent() || '';
|
return markdownRef.current?.getEditorContent() || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resetSelectedId = () => {
|
||||||
|
form.setFieldsValue({ testSuiteId: undefined });
|
||||||
|
};
|
||||||
|
|
||||||
const handleCancelClick = () => {
|
const handleCancelClick = () => {
|
||||||
history.push(getTableTabPath(entityTypeFQN, 'profiler'));
|
history.push(getTableTabPath(entityTypeFQN, 'profiler'));
|
||||||
};
|
};
|
||||||
@ -78,7 +96,7 @@ const SelectTestSuite: React.FC<SelectTestSuiteProps> = ({
|
|||||||
name: value.testSuiteName,
|
name: value.testSuiteName,
|
||||||
description: getDescription(),
|
description: getDescription(),
|
||||||
data: testSuites.find((suite) => suite.id === value.testSuiteId),
|
data: testSuites.find((suite) => suite.id === value.testSuiteId),
|
||||||
isNewTestSuite,
|
isNewTestSuite: isEmpty(formData.testSuiteId),
|
||||||
};
|
};
|
||||||
|
|
||||||
onSubmit(data);
|
onSubmit(data);
|
||||||
@ -92,21 +110,37 @@ const SelectTestSuite: React.FC<SelectTestSuiteProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
|
form={form}
|
||||||
initialValues={{
|
initialValues={{
|
||||||
testSuiteId: initialValue?.data?.id,
|
testSuiteId: initialValue?.data?.id,
|
||||||
testSuiteName: initialValue?.name,
|
testSuiteName: initialValue?.name,
|
||||||
}}
|
}}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
name="selectTestSuite"
|
name="selectTestSuite"
|
||||||
onFinish={handleFormSubmit}>
|
onFinish={handleFormSubmit}
|
||||||
|
onValuesChange={(value, values) => {
|
||||||
|
setFormData(values);
|
||||||
|
if (value.testSuiteId) {
|
||||||
|
markdownRef?.current?.clearEditorContent();
|
||||||
|
form.setFieldsValue({
|
||||||
|
...values,
|
||||||
|
testSuiteName: '',
|
||||||
|
});
|
||||||
|
} else if (value.testSuiteName) {
|
||||||
|
resetSelectedId();
|
||||||
|
}
|
||||||
|
}}>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="Test Suite:"
|
label="Test Suite:"
|
||||||
name="testSuiteId"
|
name="testSuiteId"
|
||||||
rules={[
|
rules={[
|
||||||
{ required: !isNewTestSuite, message: 'Test suite is required' },
|
{
|
||||||
|
required:
|
||||||
|
!isNewTestSuite || !isEmpty(form.getFieldValue('testSuiteId')),
|
||||||
|
message: 'Test suite is required',
|
||||||
|
},
|
||||||
]}>
|
]}>
|
||||||
<Select
|
<Select
|
||||||
disabled={isNewTestSuite}
|
|
||||||
options={testSuites.map((suite) => ({
|
options={testSuites.map((suite) => ({
|
||||||
label: suite.name,
|
label: suite.name,
|
||||||
value: suite.id,
|
value: suite.id,
|
||||||
@ -114,77 +148,87 @@ const SelectTestSuite: React.FC<SelectTestSuiteProps> = ({
|
|||||||
placeholder="Select test suite"
|
placeholder="Select test suite"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Divider plain>OR</Divider>
|
{hasAccess && (
|
||||||
|
|
||||||
{isNewTestSuite ? (
|
|
||||||
<>
|
<>
|
||||||
<Typography.Paragraph
|
<Divider plain>OR</Divider>
|
||||||
className="tw-text-base tw-mt-5"
|
|
||||||
data-testid="new-test-title">
|
|
||||||
New Test Suite
|
|
||||||
</Typography.Paragraph>
|
|
||||||
<Form.Item
|
|
||||||
label="Name:"
|
|
||||||
name="testSuiteName"
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: isNewTestSuite,
|
|
||||||
message: 'Name is required!',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
validator: (_, value) => {
|
|
||||||
if (testSuites.some((suite) => suite.name === value)) {
|
|
||||||
return Promise.reject('Name already exist!');
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve();
|
{isNewTestSuite ? (
|
||||||
},
|
<>
|
||||||
},
|
<Typography.Paragraph
|
||||||
]}>
|
className="text-base m-t-lg"
|
||||||
<Input
|
data-testid="new-test-title">
|
||||||
data-testid="test-suite-name"
|
New Test Suite
|
||||||
placeholder="Enter test suite name"
|
</Typography.Paragraph>
|
||||||
/>
|
<Form.Item
|
||||||
</Form.Item>
|
label="Name:"
|
||||||
<Form.Item
|
name="testSuiteName"
|
||||||
label="Description:"
|
rules={[
|
||||||
name="description"
|
{
|
||||||
rules={[
|
required: isEmpty(form.getFieldValue('testSuiteId')),
|
||||||
{
|
message: 'Name is required!',
|
||||||
required: true,
|
},
|
||||||
validator: () => {
|
{
|
||||||
if (isEmpty(getDescription())) {
|
validator: (_, value) => {
|
||||||
return Promise.reject('Description is required!');
|
if (testSuites.some((suite) => suite.name === value)) {
|
||||||
}
|
return Promise.reject('Name already exist!');
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
<RichTextEditor
|
<Input
|
||||||
initialValue={initialValue?.description || ''}
|
data-testid="test-suite-name"
|
||||||
ref={markdownRef}
|
placeholder="Enter test suite name"
|
||||||
style={{
|
/>
|
||||||
margin: 0,
|
</Form.Item>
|
||||||
}}
|
<Form.Item
|
||||||
/>
|
label="Description:"
|
||||||
</Form.Item>
|
name="description"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: isEmpty(form.getFieldValue('testSuiteId')),
|
||||||
|
validator: () => {
|
||||||
|
if (
|
||||||
|
isEmpty(getDescription()) &&
|
||||||
|
isEmpty(form.getFieldValue('testSuiteId'))
|
||||||
|
) {
|
||||||
|
return Promise.reject('Description is required!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<RichTextEditor
|
||||||
|
initialValue={initialValue?.description || ''}
|
||||||
|
ref={markdownRef}
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
}}
|
||||||
|
onTextChange={() => {
|
||||||
|
resetSelectedId();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Row className="m-b-xlg" justify="center">
|
||||||
|
<Button
|
||||||
|
data-testid="create-new-test-suite"
|
||||||
|
icon={
|
||||||
|
<SVGIcons
|
||||||
|
alt="plus"
|
||||||
|
className="w-4 m-r-xss"
|
||||||
|
icon={Icons.ICON_PLUS_PRIMERY}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onClick={() => setIsNewTestSuite(true)}>
|
||||||
|
<span className="tw-text-primary">Create new test suite</span>
|
||||||
|
</Button>
|
||||||
|
</Row>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
<Row className="tw-mb-10" justify="center">
|
|
||||||
<Button
|
|
||||||
data-testid="create-new-test-suite"
|
|
||||||
icon={
|
|
||||||
<SVGIcons
|
|
||||||
alt="plus"
|
|
||||||
className="tw-w-4 tw-mr-1"
|
|
||||||
icon={Icons.ICON_PLUS_PRIMERY}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onClick={() => setIsNewTestSuite(true)}>
|
|
||||||
<span className="tw-text-primary">Create new test suite</span>
|
|
||||||
</Button>
|
|
||||||
</Row>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Form.Item noStyle>
|
<Form.Item noStyle>
|
||||||
|
@ -62,6 +62,9 @@ const RichTextEditor = forwardRef<editorRef, RichTextEditorProp>(
|
|||||||
getEditorContent() {
|
getEditorContent() {
|
||||||
return editorValue;
|
return editorValue;
|
||||||
},
|
},
|
||||||
|
clearEditorContent() {
|
||||||
|
richTextEditorRef.current?.getInstance().setMarkdown('');
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -561,6 +561,7 @@ declare module 'Models' {
|
|||||||
|
|
||||||
export interface EditorContentRef {
|
export interface EditorContentRef {
|
||||||
getEditorContent: () => string;
|
getEditorContent: () => string;
|
||||||
|
clearEditorContent: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Feed interfaces and types
|
// Feed interfaces and types
|
||||||
|
@ -84,3 +84,8 @@
|
|||||||
.opacity-60 {
|
.opacity-60 {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-base {
|
||||||
|
font-size: 1rem /* 16px */;
|
||||||
|
line-height: 1.5rem /* 24px */;
|
||||||
|
}
|
||||||
|
@ -14,3 +14,6 @@
|
|||||||
.w-40 {
|
.w-40 {
|
||||||
width: 10rem /* 160px */;
|
width: 10rem /* 160px */;
|
||||||
}
|
}
|
||||||
|
.w-4 {
|
||||||
|
width: 1rem /* 16px */;
|
||||||
|
}
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
@import '~antd/dist/antd.less';
|
@import '~antd/dist/antd.less';
|
||||||
@import url('./variables.less');
|
@import url('./variables.less');
|
||||||
|
|
||||||
|
//lg: 24px;
|
||||||
|
//md: 16px;
|
||||||
|
//sm: 12px;
|
||||||
|
//xs: 8px;
|
||||||
|
//xss: 4px;
|
||||||
|
|
||||||
.m-0 {
|
.m-0 {
|
||||||
margin: 0 !important;
|
margin: 0 !important;
|
||||||
}
|
}
|
||||||
@ -65,6 +71,9 @@
|
|||||||
.m-r-0 {
|
.m-r-0 {
|
||||||
margin-right: 0 !important;
|
margin-right: 0 !important;
|
||||||
}
|
}
|
||||||
|
.m-r-xss {
|
||||||
|
margin-right: @margin-xss;
|
||||||
|
}
|
||||||
.m-r-xs {
|
.m-r-xs {
|
||||||
margin-right: @margin-xs;
|
margin-right: @margin-xs;
|
||||||
}
|
}
|
||||||
@ -122,6 +131,9 @@
|
|||||||
.m-b-lg {
|
.m-b-lg {
|
||||||
margin-bottom: @margin-lg;
|
margin-bottom: @margin-lg;
|
||||||
}
|
}
|
||||||
|
.m-b-xlg {
|
||||||
|
margin-bottom: @margin-xlg;
|
||||||
|
}
|
||||||
.m-auto {
|
.m-auto {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
@ -30,3 +30,5 @@
|
|||||||
@switch-sm-height: 12px;
|
@switch-sm-height: 12px;
|
||||||
@switch-min-width: 30px;
|
@switch-min-width: 30px;
|
||||||
@switch-sm-min-width: 23px;
|
@switch-sm-min-width: 23px;
|
||||||
|
@padding-xlg: 48px;
|
||||||
|
@margin-xlg: 48px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user