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 dc1b861a17 [#11922] improvement(web-v2): Show AWS Glue properties on 
the catalog edit page (#13706)
dc1b861a17 is described below

commit dc1b861a17bf560f963d0a186a8bee95ee74876c
Author: dennismdejong <[email protected]>
AuthorDate: Wed Nov 11 04:46:43 2026 +0100

    [#11922] improvement(web-v2): Show AWS Glue properties on the catalog edit 
page (#13706)
    
    ### What changes were proposed in this pull request?
    
    The catalog edit dialog only rendered the properties the catalog
    response
    reports, plus the required ones and `region`/`location`. The optional
    AWS Glue
    properties `aws-glue-catalog-id`, `aws-glue-endpoint`,
    `default-table-format`
    and `table-format-filter` were therefore invisible when a Glue catalog
    did not
    report them (e.g. a catalog created from the CLI without them).
    
    - `providerBase.glue.defaultProps` flags those four properties with
    `alwaysVisible: true`, so they are rendered on the edit page even when
    the
      catalog does not report them yet, and `aws-glue-catalog-id` with
    `immutable: true`, so it is read-only while editing (the connector marks
    it
      immutable, a `setProperty` on it is rejected with HTTP 400).
    - The dialog visibility, required-field and property-assembly logic
    moved into
      `src/lib/utils/catalogProperties.js` (`isCatalogPropertyHidden`,
    `isCatalogRequiredField`, `buildCatalogProperties`), keeping the
    existing
      behavior and adding the `alwaysVisible` bypass.
    - `buildCatalogProperties` leaves an `alwaysVisible` property out of the
    request while the catalog does not report it and it still holds its
    declared
    default (or is empty), so saving an unrelated change no longer writes
    empty
      or default-valued properties.
    
    ### Why are the changes needed?
    
    Users could not see or change these four Glue catalog properties on the
    Web v2
    catalog edit page, even though they can be set at creation time.
    
    Fix: #11922
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes, in the Web v2 catalog edit page for `glue` catalogs:
    
    - `aws-glue-catalog-id`, `aws-glue-endpoint`, `default-table-format` and
    `table-format-filter` are now displayed even when the catalog does not
    report
      them.
    - `aws-glue-catalog-id` is read-only while editing, because the
    connector
      treats it as immutable.
    
    No API or property-key changes.
    
    ### How was this patch tested?
    
    - Added `src/lib/utils/catalogProperties.test.js` (14 unit tests)
    covering the
    create/edit visibility rules, the required-field rule, the
    `alwaysVisible`
    interaction with `parentField` visibility and the submitted property
    map.
    - Verified the rendered dialog against a Glue catalog that reports only
    `aws-region` and `warehouse` in a throwaway jsdom harness: before this
    change
    the four fields are absent, after it they are present,
    `aws-glue-catalog-id`
    is disabled, submitting without edits dispatches no update, and editing
    only
      `aws-glue-endpoint` produces exactly
    
    
`[{"@type":"setProperty","property":"aws-glue-endpoint","value":"http://localhost:4566"}]`.
    - `pnpm vitest run`, `pnpm lint`, `pnpm prettier:check` and `next build`
    pass.
    
    ---------
    
    Co-authored-by: Qian Xia <[email protected]>
---
 .../catalogs/rightContent/CreateCatalogDialog.js   |  53 ++---
 web-v2/web/src/config/catalog.js                   |   5 +
 web-v2/web/src/lib/utils/catalogProperties.js      | 143 ++++++++++++
 web-v2/web/src/lib/utils/catalogProperties.test.js | 253 +++++++++++++++++++++
 4 files changed, 419 insertions(+), 35 deletions(-)

diff --git a/web-v2/web/src/app/catalogs/rightContent/CreateCatalogDialog.js 
b/web-v2/web/src/app/catalogs/rightContent/CreateCatalogDialog.js
index 92dfeb5dfe..3ab2eab3d1 100644
--- a/web-v2/web/src/app/catalogs/rightContent/CreateCatalogDialog.js
+++ b/web-v2/web/src/app/catalogs/rightContent/CreateCatalogDialog.js
@@ -44,6 +44,7 @@ import {
   sensitiveCatalogPropertyKeys
 } from '@/config/catalog'
 import { nameRegex } from '@/lib/utils/regex'
+import { buildCatalogProperties, isCatalogPropertyHidden, 
isCatalogRequiredField } from '@/lib/utils/catalogProperties'
 import { useResetFormOnCloseModal } from '@/lib/hooks/use-reset'
 import { genUpdates } from '@/lib/utils'
 import { cn } from '@/lib/utils/tailwind'
@@ -78,12 +79,7 @@ export default function CreateCatalogDialog({ ...props }) {
   const dispatch = useAppDispatch()
   const isShowTestConnect = ['fileset', 'model'].includes(catalogType) || 
currentProvider === 'lakehouse-generic'
 
-  const isRequiredField = prop => {
-    return (
-      prop.required ||
-      (prop.key === 'warehouse' && currentProvider === 'lakehouse-iceberg' && 
['hive', 'jdbc'].includes(catalogBackend))
-    )
-  }
+  const isRequiredField = prop => isCatalogRequiredField(prop, { 
currentProvider, catalogBackend })
 
   const defaultValues = {
     name: '',
@@ -113,22 +109,14 @@ export default function CreateCatalogDialog({ ...props }) 
{
     setCurrentStep
   )
 
-  const isHidden = prop => {
-    const { parentField, hide, key } = prop
-
-    // In edit mode, hide props not present in the loaded catalog response
-    if (editCatalog && cacheData?.properties && !(key in 
cacheData.properties)) {
-      return true
-    }
-    switch (parentField) {
-      case 'catalog-backend':
-        return catalogBackend && hide && hide.includes(catalogBackend)
-      case 'authentication.type':
-        return !authType || (hide && hide.includes(authType))
-      default:
-        return !(!editCatalog || ['region', 'location'].includes(key) || 
isRequiredField(prop))
-    }
-  }
+  const isHidden = prop =>
+    isCatalogPropertyHidden(prop, {
+      editCatalog,
+      catalogProperties: cacheData?.properties,
+      catalogBackend,
+      authType,
+      currentProvider
+    })
 
   const handScroll = () => {
     if (scrollRef.current) {
@@ -252,17 +240,12 @@ export default function CreateCatalogDialog({ ...props }) 
{
       type: catalogType,
       provider: values.provider,
       comment: values.comment,
-      properties: [...values.properties, ...defaultProps].reduce((acc, item) 
=> {
-        if (item.key === 'location' || item.key.startsWith('location-')) {
-          if (item.value) {
-            acc[item.key] = item.prefix ? item.prefix + item.value : item.value
-          }
-        } else {
-          acc[item.key] = values[item.key] || (item.value instanceof Array ? 
item.value.join(',') : item.value)
-        }
-
-        return acc
-      }, {})
+      properties: buildCatalogProperties({
+        values,
+        defaultProps,
+        editCatalog: Boolean(editCatalog),
+        catalogProperties: cacheData?.properties || {}
+      })
     }
   }
 
@@ -543,7 +526,7 @@ export default function CreateCatalogDialog({ ...props }) {
                             {prop.select ? (
                               <Select
                                 data-refer={`catalog-props-${prop.key}`}
-                                disabled={editCatalog && prop.required}
+                                disabled={editCatalog && (prop.required || 
prop.immutable)}
                                 placeholder={prop.description ? 
prop.description : ''}
                               >
                                 {prop.select?.map(item => (
@@ -556,7 +539,7 @@ export default function CreateCatalogDialog({ ...props }) {
                               <Input
                                 data-refer={`catalog-props-${prop.key}`}
                                 placeholder={prop.description ? 
prop.description : ''}
-                                disabled={prop.disabled}
+                                disabled={prop.disabled || (editCatalog && 
prop.immutable)}
                                 
type={sensitiveCatalogPropertyKeys.includes(prop.key) ? 'password' : 'text'}
                               />
                             )}
diff --git a/web-v2/web/src/config/catalog.js b/web-v2/web/src/config/catalog.js
index 41c8881a43..0b934a9e7d 100644
--- a/web-v2/web/src/config/catalog.js
+++ b/web-v2/web/src/config/catalog.js
@@ -380,6 +380,8 @@ export const providerBase = {
         label: 'AWS Glue Catalog ID',
         key: 'aws-glue-catalog-id',
         value: '',
+        alwaysVisible: true,
+        immutable: true,
         description: "12-digit AWS account ID; defaults to caller's account"
       },
       {
@@ -398,6 +400,7 @@ export const providerBase = {
         label: 'AWS Glue Endpoint',
         key: 'aws-glue-endpoint',
         value: '',
+        alwaysVisible: true,
         description: 'Custom endpoint URL, e.g. http://localhost:4566 for 
LocalStack'
       },
       {
@@ -405,12 +408,14 @@ export const providerBase = {
         key: 'default-table-format',
         value: 'hive',
         select: ['hive', 'iceberg'],
+        alwaysVisible: true,
         description: 'Default format for createTable()'
       },
       {
         label: 'Table Format Filter',
         key: 'table-format-filter',
         value: 'all',
+        alwaysVisible: true,
         description: 'Comma-separated formats exposed by listTables()'
       }
     ]
diff --git a/web-v2/web/src/lib/utils/catalogProperties.js 
b/web-v2/web/src/lib/utils/catalogProperties.js
new file mode 100644
index 0000000000..97823187ca
--- /dev/null
+++ b/web-v2/web/src/lib/utils/catalogProperties.js
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * A property is required when it is flagged as such, or when it is the 
warehouse of a Hive/JDBC
+ * backed Iceberg catalog.
+ *
+ * @param {object} prop property definition from 
`providerBase[provider].defaultProps`
+ * @param {object} context current dialog state
+ * @param {string} context.currentProvider selected catalog provider
+ * @param {string} context.catalogBackend selected `catalog-backend` value
+ * @returns {boolean} whether the property must be filled in
+ */
+export const isCatalogRequiredField = (prop, { currentProvider, catalogBackend 
} = {}) => {
+  return Boolean(
+    prop.required ||
+    (prop.key === 'warehouse' && currentProvider === 'lakehouse-iceberg' && 
['hive', 'jdbc'].includes(catalogBackend))
+  )
+}
+
+/**
+ * Decides whether a catalog property field is hidden in the create/edit 
dialog.
+ *
+ * In edit mode only the fields the catalog reports are rendered, plus the 
required ones and the
+ * `region`/`location` fields, so the dialog does not lose properties it 
cannot round-trip. Fields
+ * declared with `alwaysVisible` (e.g. optional connector properties that were 
never set) stay
+ * visible even when the catalog response omits them.
+ *
+ * @param {object} prop property definition from 
`providerBase[provider].defaultProps`
+ * @param {object} context current dialog state
+ * @param {boolean} context.editCatalog whether the dialog edits an existing 
catalog
+ * @param {object} context.catalogProperties properties loaded from the edited 
catalog
+ * @param {string} context.catalogBackend selected `catalog-backend` value
+ * @param {string} context.authType selected `authentication.type` value
+ * @param {string} context.currentProvider selected catalog provider
+ * @returns {boolean} whether the property field is hidden
+ */
+export const isCatalogPropertyHidden = (prop, context = {}) => {
+  const { editCatalog, catalogProperties, catalogBackend, authType, 
currentProvider } = context
+  const { parentField, hide, key } = prop
+
+  // In edit mode, hide props not present in the loaded catalog response. 
Fields flagged
+  // `alwaysVisible` opt out so the dialog can still render optional 
properties the catalog omits,
+  // but they keep honoring parent-dependent hiding below.
+  if (editCatalog && catalogProperties && !(key in catalogProperties) && 
!prop.alwaysVisible) {
+    return true
+  }
+
+  // Visibility driven by another field always wins.
+  if (parentField === 'catalog-backend') {
+    return Boolean(catalogBackend && hide && hide.includes(catalogBackend))
+  }
+
+  if (parentField === 'authentication.type') {
+    return Boolean(!authType || (hide && hide.includes(authType)))
+  }
+
+  if (editCatalog && prop.alwaysVisible) {
+    return false
+  }
+
+  // Outside edit mode every field is rendered; in edit mode only 
required/region/location survive.
+  return Boolean(
+    editCatalog &&
+    !['region', 'location'].includes(key) &&
+    !isCatalogRequiredField(prop, { currentProvider, catalogBackend })
+  )
+}
+
+/**
+ * Merges the dialog's free-form property rows with the declared default 
properties into the
+ * `properties` map sent to the server. Default properties are applied last so 
they win on conflicts.
+ *
+ * @param {object} args
+ * @param {object} args.values current form values, including the free-form 
`properties` rows
+ * @param {Array<object>} args.defaultProps default properties rendered as 
dedicated form fields
+ * @param {boolean} args.editCatalog whether the dialog edits an existing 
catalog
+ * @param {object} args.catalogProperties properties loaded from the edited 
catalog
+ * @returns {object} the `properties` map to submit
+ */
+export const buildCatalogProperties = ({
+  values = {},
+  defaultProps = [],
+  editCatalog = false,
+  catalogProperties = {}
+}) => {
+  const properties = {}
+
+  const appendProperty = (item, isDefaultProp) => {
+    const { key } = item
+
+    if (key === 'location' || key.startsWith('location-')) {
+      if (item.value) {
+        properties[key] = item.prefix ? item.prefix + item.value : item.value
+      }
+
+      return
+    }
+
+    const defaultValue = item.value instanceof Array ? item.value.join(',') : 
item.value
+    const value = values[key] || defaultValue
+
+    if (isDefaultProp && editCatalog) {
+      // Optional, editable alwaysVisible fields are rendered even when the 
catalog omits them.
+      // Leave them out when the user clears them so an existing property is 
removed instead of
+      // being written back as an empty string.
+      if (item.alwaysVisible && !item.required && !item.immutable && 
!item.disabled) {
+        if (values[key] === '' || values[key] == null) {
+          return
+        }
+      }
+
+      // Keep fields the catalog does not report absent until the user gives 
them a value, otherwise
+      // saving an unrelated change would write empty or default-valued 
properties.
+      if (!(key in catalogProperties) && (value === '' || value == null || 
value === defaultValue)) {
+        return
+      }
+    }
+
+    properties[key] = value
+  }
+
+  ;(values.properties || []).forEach(item => appendProperty(item, false))
+  defaultProps.forEach(item => appendProperty(item, true))
+
+  return properties
+}
diff --git a/web-v2/web/src/lib/utils/catalogProperties.test.js 
b/web-v2/web/src/lib/utils/catalogProperties.test.js
new file mode 100644
index 0000000000..10fbed3026
--- /dev/null
+++ b/web-v2/web/src/lib/utils/catalogProperties.test.js
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { describe, expect, it } from 'vitest'
+import { buildCatalogProperties, isCatalogPropertyHidden, 
isCatalogRequiredField } from '@/lib/utils/catalogProperties'
+import { providerBase } from '@/config/catalog'
+
+const glueProps = providerBase.glue.defaultProps
+const prop = key => glueProps.find(item => item.key === key)
+
+describe('isCatalogRequiredField', () => {
+  it('treats props flagged as required as required', () => {
+    expect(isCatalogRequiredField(prop('aws-region'), { currentProvider: 
'glue' })).toBe(true)
+  })
+
+  it('requires the warehouse of hive and jdbc backed Iceberg catalogs', () => {
+    const warehouse = { key: 'warehouse', required: false }
+
+    expect(isCatalogRequiredField(warehouse, { currentProvider: 
'lakehouse-iceberg', catalogBackend: 'jdbc' })).toBe(
+      true
+    )
+    expect(isCatalogRequiredField(warehouse, { currentProvider: 
'lakehouse-iceberg', catalogBackend: 'hive' })).toBe(
+      true
+    )
+    expect(isCatalogRequiredField(warehouse, { currentProvider: 
'lakehouse-iceberg', catalogBackend: 'rest' })).toBe(
+      false
+    )
+    expect(isCatalogRequiredField(warehouse, { currentProvider: 'glue' 
})).toBe(false)
+  })
+})
+
+describe('isCatalogPropertyHidden', () => {
+  it('renders every field while creating a catalog', () => {
+    const context = { editCatalog: false, catalogProperties: {} }
+
+    glueProps.forEach(item => {
+      expect(isCatalogPropertyHidden(item, context)).toBe(false)
+    })
+  })
+
+  it('keeps optional Glue properties visible on the edit dialog when the 
catalog omits them', () => {
+    const context = { editCatalog: true, catalogProperties: { 'aws-region': 
'us-east-1', warehouse: 's3://b/w' } }
+
+    expect(isCatalogPropertyHidden(prop('aws-glue-catalog-id'), 
context)).toBe(false)
+    expect(isCatalogPropertyHidden(prop('aws-glue-endpoint'), 
context)).toBe(false)
+    expect(isCatalogPropertyHidden(prop('default-table-format'), 
context)).toBe(false)
+    expect(isCatalogPropertyHidden(prop('table-format-filter'), 
context)).toBe(false)
+  })
+
+  it('hides optional properties the catalog does not report and that are not 
flagged alwaysVisible', () => {
+    const context = { editCatalog: true, catalogProperties: { 'aws-region': 
'us-east-1' } }
+
+    expect(isCatalogPropertyHidden(prop('aws-access-key-id'), 
context)).toBe(true)
+    expect(isCatalogPropertyHidden(prop('aws-secret-access-key'), 
context)).toBe(true)
+  })
+
+  it('keeps required, region and location properties visible on the edit 
dialog', () => {
+    const context = {
+      editCatalog: true,
+      catalogProperties: { 'aws-region': 'us-east-1', 'jdbc-url': 
'jdbc:mysql://h:3306', location: 's3://b/w' }
+    }
+
+    expect(isCatalogPropertyHidden(prop('aws-region'), context)).toBe(false)
+    expect(isCatalogPropertyHidden({ key: 'location' }, context)).toBe(false)
+    expect(isCatalogPropertyHidden({ key: 'jdbc-url', required: true }, 
context)).toBe(false)
+    expect(isCatalogPropertyHidden({ key: 'jdbc-database' }, 
context)).toBe(true)
+
+    // A location the catalog does not report stays hidden, required or not.
+    expect(isCatalogPropertyHidden({ key: 'location' }, { editCatalog: true, 
catalogProperties: {} })).toBe(true)
+  })
+
+  it('hides alwaysVisible properties whose visibility depends on another 
field', () => {
+    const jdbcDriver = {
+      key: 'jdbc-driver',
+      required: true,
+      alwaysVisible: true,
+      parentField: 'catalog-backend',
+      hide: ['hive', 'rest']
+    }
+
+    expect(
+      isCatalogPropertyHidden(jdbcDriver, { editCatalog: true, 
catalogProperties: {}, catalogBackend: 'hive' })
+    ).toBe(true)
+    expect(
+      isCatalogPropertyHidden(jdbcDriver, { editCatalog: true, 
catalogProperties: {}, catalogBackend: 'jdbc' })
+    ).toBe(false)
+  })
+
+  it('hides required parent-dependent properties the catalog does not report', 
() => {
+    const jdbcUser = {
+      key: 'jdbc-user',
+      required: true,
+      parentField: 'catalog-backend',
+      hide: ['hive', 'rest']
+    }
+
+    const context = {
+      editCatalog: true,
+      catalogProperties: { 'catalog-backend': 'jdbc', 'jdbc-url': 
'jdbc:mysql://h:3306' },
+      catalogBackend: 'jdbc'
+    }
+
+    // A JDBC-backed catalog may omit the credentials from the response. The 
empty required field
+    // must stay hidden so it cannot block saving an unrelated change.
+    expect(isCatalogPropertyHidden(jdbcUser, context)).toBe(true)
+  })
+
+  it('hides fields depending on the selected catalog backend', () => {
+    const jdbcDriver = {
+      key: 'jdbc-driver',
+      required: true,
+      parentField: 'catalog-backend',
+      hide: ['hive', 'rest']
+    }
+
+    expect(
+      isCatalogPropertyHidden(jdbcDriver, { editCatalog: false, 
catalogProperties: {}, catalogBackend: 'jdbc' })
+    ).toBe(false)
+    expect(
+      isCatalogPropertyHidden(jdbcDriver, { editCatalog: false, 
catalogProperties: {}, catalogBackend: 'hive' })
+    ).toBe(true)
+  })
+
+  it('hides Kerberos fields when the authentication type is simple', () => {
+    const kerberosKeytab = {
+      key: 'authentication.kerberos.keytab-uri',
+      parentField: 'authentication.type',
+      hide: ['simple']
+    }
+
+    expect(isCatalogPropertyHidden(kerberosKeytab, { editCatalog: false, 
authType: 'simple' })).toBe(true)
+    expect(isCatalogPropertyHidden(kerberosKeytab, { editCatalog: false, 
authType: 'Kerberos' })).toBe(false)
+    expect(isCatalogPropertyHidden(kerberosKeytab, { editCatalog: false, 
authType: undefined })).toBe(true)
+  })
+})
+
+describe('buildCatalogProperties', () => {
+  const visibleGlueProps = glueProps.filter(
+    item => !isCatalogPropertyHidden(item, { editCatalog: true, 
catalogProperties: {} })
+  )
+
+  it('submits the declared default properties while creating a catalog', () => 
{
+    const properties = buildCatalogProperties({
+      values: { provider: 'glue' },
+      defaultProps: visibleGlueProps,
+      editCatalog: false
+    })
+
+    expect(properties).toMatchObject({ 'default-table-format': 'hive', 
'table-format-filter': 'all' })
+  })
+
+  it('keeps alwaysVisible properties out of the request when the catalog omits 
them and they are untouched', () => {
+    const properties = buildCatalogProperties({
+      values: { 'aws-region': 'us-east-1', warehouse: 's3://b/w' },
+      defaultProps: visibleGlueProps,
+      editCatalog: true,
+      catalogProperties: { 'aws-region': 'us-east-1', warehouse: 's3://b/w' }
+    })
+
+    expect(properties).not.toHaveProperty('aws-glue-catalog-id')
+    expect(properties).not.toHaveProperty('aws-glue-endpoint')
+    expect(properties).not.toHaveProperty('default-table-format')
+    expect(properties).not.toHaveProperty('table-format-filter')
+  })
+
+  it('submits alwaysVisible properties the user sets on the edit dialog', () 
=> {
+    const properties = buildCatalogProperties({
+      values: {
+        'aws-region': 'us-east-1',
+        warehouse: 's3://b/w',
+        'aws-glue-endpoint': 'http://localhost:4566',
+        'default-table-format': 'iceberg'
+      },
+      defaultProps: visibleGlueProps,
+      editCatalog: true,
+      catalogProperties: { 'aws-region': 'us-east-1', warehouse: 's3://b/w' }
+    })
+
+    expect(properties).toMatchObject({
+      'aws-glue-endpoint': 'http://localhost:4566',
+      'default-table-format': 'iceberg'
+    })
+
+    // Untouched fields still holding their declared default are left out of 
the request.
+    expect(properties).not.toHaveProperty('table-format-filter')
+  })
+
+  it('omits cleared optional alwaysVisible properties so the update removes 
them', () => {
+    const catalogProperties = {
+      'aws-region': 'us-east-1',
+      warehouse: 's3://b/w',
+      'aws-glue-endpoint': 'http://localhost:4566'
+    }
+
+    const properties = buildCatalogProperties({
+      values: { 'aws-region': 'us-east-1', warehouse: 's3://b/w', 
'aws-glue-endpoint': '' },
+      defaultProps: visibleGlueProps,
+      editCatalog: true,
+      catalogProperties
+    })
+
+    // Leaving the endpoint empty must produce a removeProperty update, not 
setProperty with ''.
+    expect(properties).not.toHaveProperty('aws-glue-endpoint')
+  })
+
+  it('round-trips properties the catalog already reports', () => {
+    const catalogProperties = { 'aws-glue-endpoint': 'http://localhost:4566', 
'default-table-format': 'iceberg' }
+
+    const values = providerBase.glue.defaultProps.reduce((acc, item) => {
+      if (!isCatalogPropertyHidden(item, { editCatalog: true, 
catalogProperties })) {
+        acc[item.key] = catalogProperties[item.key] ?? item.value
+      }
+
+      return acc
+    }, {})
+
+    const properties = buildCatalogProperties({
+      values,
+      defaultProps: visibleGlueProps,
+      editCatalog: true,
+      catalogProperties
+    })
+
+    expect(properties).toMatchObject(catalogProperties)
+  })
+
+  it('keeps the free-form property rows and the location handling', () => {
+    const properties = buildCatalogProperties({
+      values: { properties: [{ key: 'custom-key', value: 'custom-value' }] },
+      defaultProps: [{ key: 'location', value: 'warehouse/schema', prefix: 
's3://bucket/' }],
+      editCatalog: true,
+      catalogProperties: {}
+    })
+
+    expect(properties).toEqual({ 'custom-key': 'custom-value', location: 
's3://bucket/warehouse/schema' })
+  })
+})

Reply via email to