This is an automated email from the ASF dual-hosted git repository.

LauraXia123 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new 3f3aa5ece7 [#14061] sub-task(web-v2):  Support UI for tag assignment 
values (#14071)
3f3aa5ece7 is described below

commit 3f3aa5ece7e0a1d1d9554eb620e036483565710a
Author: Qian Xia <[email protected]>
AuthorDate: Wed Nov 11 10:21:34 2026 +0800

    [#14061] sub-task(web-v2):  Support UI for tag assignment values (#14071)
    
    ### What changes were proposed in this pull request?
    <img width="1756" height="1442" alt="Image"
    
src="https://github.com/user-attachments/assets/946b250f-c633-4d32-ba1c-1055d7c7c599";
    />
    
    <img width="1728" height="1354" alt="Image"
    
src="https://github.com/user-attachments/assets/701fa852-9ad5-456f-b4e3-1b61b3c91c9a";
    />
    
    <img width="1912" height="1352" alt="Image"
    
src="https://github.com/user-attachments/assets/88659592-3f46-4b9a-be12-4286a18d65ed";
    />
    
    ### Why are the changes needed?
    
    
    Fix: #14061
    
    ### Does this PR introduce _any_ user-facing change?
    N/A
    
    ### How was this patch tested?
    manually
---
 .../web/src/app/compliance/tags/CreateTagDialog.js | 69 +++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/web-v2/web/src/app/compliance/tags/CreateTagDialog.js 
b/web-v2/web/src/app/compliance/tags/CreateTagDialog.js
index 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} 
/>

Reply via email to