|
3 | 3 | import '@ant-design/v5-patch-for-react-19';
|
4 | 4 |
|
5 | 5 | import { SetStateAction, useEffect, useState } from 'react';
|
6 |
| -import { Tabs } from 'antd'; |
| 6 | +import { Card, Tabs } from 'antd'; |
| 7 | +import { ExclamationCircleOutlined } from '@ant-design/icons'; |
7 | 8 | import { withTheme } from '@rjsf/core';
|
8 | 9 | import { Theme as AntDTheme } from '@rjsf/antd';
|
9 | 10 | import validator from '@rjsf/validator-ajv8';
|
@@ -53,6 +54,9 @@ function IngestForm({
|
53 | 54 | const [activeTab, setActiveTab] = useState<string>('form');
|
54 | 55 | const [forceRenderKey, setForceRenderKey] = useState<number>(0); // Force refresh RJSF to clear validation errors
|
55 | 56 | const [hasJSONChanges, setHasJSONChanges] = useState<boolean>(false);
|
| 57 | + const [additionalProperties, setAdditionalProperties] = useState< |
| 58 | + string[] | null |
| 59 | + >(null); |
56 | 60 |
|
57 | 61 | useEffect(() => {
|
58 | 62 | if (defaultTemporalExtent) {
|
@@ -114,47 +118,94 @@ function IngestForm({
|
114 | 118 | };
|
115 | 119 |
|
116 | 120 | return (
|
117 |
| - <Tabs |
118 |
| - activeKey={activeTab} |
119 |
| - onChange={setActiveTab} |
120 |
| - items={[ |
121 |
| - { |
122 |
| - key: 'form', |
123 |
| - label: 'Form', |
124 |
| - children: ( |
125 |
| - <Form |
126 |
| - key={forceRenderKey} // Forces re-render when data updates |
127 |
| - schema={jsonSchema as JSONSchema7} |
128 |
| - uiSchema={uiSchema} |
129 |
| - validator={validator} |
130 |
| - customValidate={customValidate} |
131 |
| - templates={{ |
132 |
| - ObjectFieldTemplate: ObjectFieldTemplate, |
133 |
| - }} |
134 |
| - formData={formData} |
135 |
| - onChange={onFormDataChanged} |
136 |
| - onSubmit={(data) => handleSubmit(data, onSubmit)} |
137 |
| - formContext={{ updateFormData }} |
138 |
| - > |
139 |
| - {children} |
140 |
| - </Form> |
141 |
| - ), |
142 |
| - }, |
143 |
| - { |
144 |
| - key: 'json', |
145 |
| - label: 'Manual JSON Edit', |
146 |
| - children: ( |
147 |
| - <JSONEditor |
148 |
| - value={formData || {}} |
149 |
| - onChange={handleJsonEditorChange} |
150 |
| - disableCollectionNameChange={disableCollectionNameChange} |
151 |
| - hasJSONChanges={hasJSONChanges} |
152 |
| - setHasJSONChanges={setHasJSONChanges} |
153 |
| - /> |
154 |
| - ), |
155 |
| - }, |
156 |
| - ]} |
157 |
| - /> |
| 121 | + <> |
| 122 | + <Tabs |
| 123 | + activeKey={activeTab} |
| 124 | + onChange={setActiveTab} |
| 125 | + items={[ |
| 126 | + { |
| 127 | + key: 'form', |
| 128 | + label: 'Form', |
| 129 | + children: ( |
| 130 | + <> |
| 131 | + <Form |
| 132 | + key={forceRenderKey} // Forces re-render when data updates |
| 133 | + schema={jsonSchema as JSONSchema7} |
| 134 | + uiSchema={uiSchema} |
| 135 | + validator={validator} |
| 136 | + customValidate={customValidate} |
| 137 | + templates={{ |
| 138 | + ObjectFieldTemplate: ObjectFieldTemplate, |
| 139 | + }} |
| 140 | + formData={formData} |
| 141 | + onChange={onFormDataChanged} |
| 142 | + onSubmit={(data) => handleSubmit(data, onSubmit)} |
| 143 | + formContext={{ updateFormData }} |
| 144 | + > |
| 145 | + {children} |
| 146 | + </Form> |
| 147 | + {additionalProperties && additionalProperties.length > 0 && ( |
| 148 | + <Card |
| 149 | + data-testid="extra-properties-card" |
| 150 | + title={ |
| 151 | + <div |
| 152 | + style={{ |
| 153 | + display: 'flex', |
| 154 | + alignItems: 'center', |
| 155 | + gap: '8px', |
| 156 | + color: '#faad14', |
| 157 | + }} |
| 158 | + > |
| 159 | + <ExclamationCircleOutlined /> |
| 160 | + <span>Extra Properties set via JSON Editor</span> |
| 161 | + </div> |
| 162 | + } |
| 163 | + style={{ |
| 164 | + width: '100%', |
| 165 | + marginTop: '10px', |
| 166 | + maxHeight: '300px', |
| 167 | + overflowY: 'auto', |
| 168 | + }} |
| 169 | + > |
| 170 | + <ul |
| 171 | + style={{ |
| 172 | + display: 'grid', |
| 173 | + gridTemplateRows: 'repeat(3, auto)', // 3 rows before wrapping to new column |
| 174 | + gridAutoFlow: 'column', |
| 175 | + gap: '10px', |
| 176 | + padding: 0, |
| 177 | + listStyleType: 'none', |
| 178 | + }} |
| 179 | + > |
| 180 | + {additionalProperties.map((prop) => ( |
| 181 | + <li key={prop} style={{ paddingLeft: '10px' }}> |
| 182 | + {prop} |
| 183 | + </li> |
| 184 | + ))} |
| 185 | + </ul> |
| 186 | + </Card> |
| 187 | + )} |
| 188 | + </> |
| 189 | + ), |
| 190 | + }, |
| 191 | + { |
| 192 | + key: 'json', |
| 193 | + label: 'Manual JSON Edit', |
| 194 | + children: ( |
| 195 | + <JSONEditor |
| 196 | + value={formData || {}} |
| 197 | + onChange={handleJsonEditorChange} |
| 198 | + disableCollectionNameChange={disableCollectionNameChange} |
| 199 | + hasJSONChanges={hasJSONChanges} |
| 200 | + setHasJSONChanges={setHasJSONChanges} |
| 201 | + additionalProperties={additionalProperties} |
| 202 | + setAdditionalProperties={setAdditionalProperties} |
| 203 | + /> |
| 204 | + ), |
| 205 | + }, |
| 206 | + ]} |
| 207 | + /> |
| 208 | + </> |
158 | 209 | );
|
159 | 210 | }
|
160 | 211 |
|
|
0 commit comments