World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#14061] sub-task(web-v2): Support UI for tag assignment values (#14071)
Qian Xia3f3aa5ece7e0
diff --git a/web-v2/web/src/app/compliance/tags/CreateTagDialog.js b/web-v2/web/src/app/compliance/tags/CreateTagDialog.jsindex 5cd1003016..c4bf8bb8aa 100644--- a/web-v2/web/src/app/compliance/tags/CreateTagDialog.js+++ b/web-v2/web/src/app/compliance/tags/CreateTagDialog.js@@ -18,7 +18,7 @@*/import React, { useEffect, useState, useRef } from 'react'-import { ColorPicker, Form, Input, Modal, Space, Typography } from 'antd'+import { ColorPicker, Form, Input, Modal, Radio, Select, Space, Tag, Typography } from 'antd'import Icons from '@/components/Icons'import RenderPropertiesFormItem from '@/components/EntityPropertiesFormItem'import { validateMessages, mismatchName } from '@/config'@@ -35,6 +35,8 @@ const defaultValues = {name: '',comment: '',color: '#0369a1',+ valueMode: 'any',+ allowedValues: [],properties: []}@@ -99,6 +101,12 @@ export default function CreateTagDialog({ ...props }) {const submitData = {name: values.name.trim(),comment: values.comment,+ allowedValues:+ values.valueMode === 'any'+ ? null+ : values.valueMode === 'none'+ ? []+ : values.allowedValues.map(value => value.trim()),properties: values.properties.reduce((acc, item) => {acc[item.key] = values[item.key] || item.value@@ -160,6 +168,65 @@ export default function CreateTagDialog({ ...props }) {<Form.Item name='comment' label='Comment'><TextArea /></Form.Item>+ {editTag ? (+ <Form.Item label='Values' extra='Set when the tag was created.'>+ {cacheData?.allowedValues == null ? (+ 'Any value'+ ) : cacheData.allowedValues.length === 0 ? (+ 'No value'+ ) : (+ <Space wrap>+ {cacheData.allowedValues.map((value, index) => (+ <Tag className='mr-0' key={index}>+ {value}+ </Tag>+ ))}+ </Space>+ )}+ </Form.Item>+ ) : (+ <>+ <Form.Item label='Values' className={values?.valueMode === 'allowed' ? 'mb-2' : undefined}>+ <Form.Item name='valueMode' noStyle>+ <Radio.Group+ options={[+ { label: 'Any value', value: 'any' },+ { label: 'No value', value: 'none' },+ { label: 'Only these values', value: 'allowed' }+ ]}+ />+ </Form.Item>+ </Form.Item>+ {values?.valueMode === 'allowed' && (+ <Form.Item+ name='allowedValues'+ extra='Press Enter to add each value. Case-sensitive, 256 characters maximum.'+ rules={[+ {+ validator: (_, allowedValues) => {+ if (!allowedValues?.length) {+ return Promise.reject(new Error('Add at least one allowed value'))+ }+ const values = allowedValues.map(value => value.trim())+ if (values.some(value => !value)) {+ return Promise.reject(new Error('Allowed values cannot be empty'))+ }+ if (new Set(values).size !== values.length) {+ return Promise.reject(new Error('Allowed values must be unique'))+ }++ return values.every(value => value.length <= 256)+ ? Promise.resolve()+ : Promise.reject(new Error('Each value must be at most 256 characters'))+ }+ }+ ]}+ >+ <Select mode='tags' placeholder='Type a value and press Enter' />+ </Form.Item>+ )}+ </>+ )}<Form.Item name='color' label='Color'><Space><ColorPicker value={values?.color} onChange={handlePickerChange} />