@fgv/ts-res-ui-components 5.0.0-21 → 5.0.0-23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +401 -155
- package/config/jest.setup.js +10 -0
- package/dist/ts-res-ui-components.d.ts +1657 -76
- package/lib/components/common/QualifierContextControl.js +4 -1
- package/lib/components/common/ResourceTreeView.js +4 -1
- package/lib/components/forms/GenericQualifierTypeEditForm.d.ts +26 -0
- package/lib/components/forms/GenericQualifierTypeEditForm.js +166 -0
- package/lib/components/forms/QualifierEditForm.d.ts +1 -1
- package/lib/components/forms/index.d.ts +2 -0
- package/lib/components/forms/index.js +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts +3 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js +118 -51
- package/lib/components/pickers/ResourcePicker/ResourcePickerTree.js +32 -10
- package/lib/components/pickers/ResourcePicker/index.js +4 -2
- package/lib/components/views/CompiledView/index.js +75 -16
- package/lib/components/views/ConfigurationView/index.js +94 -35
- package/lib/components/views/FilterView/index.js +7 -4
- package/lib/components/views/GridView/EditableGridCell.d.ts +76 -0
- package/lib/components/views/GridView/EditableGridCell.js +224 -0
- package/lib/components/views/GridView/GridSelector.d.ts +43 -0
- package/lib/components/views/GridView/GridSelector.js +89 -0
- package/lib/components/views/GridView/MultiGridView.d.ts +85 -0
- package/lib/components/views/GridView/MultiGridView.js +196 -0
- package/lib/components/views/GridView/ResourceGrid.d.ts +38 -0
- package/lib/components/views/GridView/ResourceGrid.js +232 -0
- package/lib/components/views/GridView/SharedContextControls.d.ts +47 -0
- package/lib/components/views/GridView/SharedContextControls.js +95 -0
- package/lib/components/views/GridView/cells/BooleanCell.d.ts +44 -0
- package/lib/components/views/GridView/cells/BooleanCell.js +49 -0
- package/lib/components/views/GridView/cells/DropdownCell.d.ts +58 -0
- package/lib/components/views/GridView/cells/DropdownCell.js +182 -0
- package/lib/components/views/GridView/cells/StringCell.d.ts +57 -0
- package/lib/components/views/GridView/cells/StringCell.js +106 -0
- package/lib/components/views/GridView/cells/TriStateCell.d.ts +54 -0
- package/lib/components/views/GridView/cells/TriStateCell.js +112 -0
- package/lib/components/views/GridView/cells/index.d.ts +15 -0
- package/lib/components/views/GridView/cells/index.js +11 -0
- package/lib/components/views/GridView/index.d.ts +53 -0
- package/lib/components/views/GridView/index.js +212 -0
- package/lib/components/views/ImportView/index.js +22 -19
- package/lib/components/views/MessagesWindow/index.js +4 -1
- package/lib/components/views/ResolutionView/index.js +8 -5
- package/lib/contexts/ObservabilityContext.d.ts +85 -0
- package/lib/contexts/ObservabilityContext.js +98 -0
- package/lib/contexts/index.d.ts +2 -0
- package/lib/contexts/index.js +24 -0
- package/lib/hooks/useConfigurationState.d.ts +3 -3
- package/lib/hooks/useResolutionState.js +850 -246
- package/lib/hooks/useResourceData.d.ts +7 -4
- package/lib/hooks/useResourceData.js +185 -184
- package/lib/index.d.ts +5 -1
- package/lib/index.js +8 -1
- package/lib/namespaces/GridTools.d.ts +136 -0
- package/lib/namespaces/GridTools.js +138 -0
- package/lib/namespaces/ObservabilityTools.d.ts +3 -0
- package/lib/namespaces/ObservabilityTools.js +23 -0
- package/lib/namespaces/ResolutionTools.d.ts +2 -1
- package/lib/namespaces/ResolutionTools.js +2 -0
- package/lib/namespaces/index.d.ts +2 -0
- package/lib/namespaces/index.js +2 -0
- package/lib/test/integration/observability.integration.test.d.ts +2 -0
- package/lib/test/unit/hooks/useResourceData.test.d.ts +2 -0
- package/lib/test/unit/utils/downloadHelper.test.d.ts +2 -0
- package/lib/test/unit/workflows/resolutionWorkflows.test.d.ts +2 -0
- package/lib/test/unit/workflows/resourceCreation.test.d.ts +2 -0
- package/lib/test/unit/workflows/resultPatternExtensions.test.d.ts +2 -0
- package/lib/test/unit/workflows/validation.test.d.ts +2 -0
- package/lib/types/index.d.ts +387 -20
- package/lib/types/index.js +2 -1
- package/lib/utils/cellValidation.d.ts +113 -0
- package/lib/utils/cellValidation.js +248 -0
- package/lib/utils/downloadHelper.d.ts +66 -0
- package/lib/utils/downloadHelper.js +195 -0
- package/lib/utils/observability/factories.d.ts +29 -0
- package/lib/utils/observability/factories.js +58 -0
- package/lib/utils/observability/implementations.d.ts +61 -0
- package/lib/utils/observability/implementations.js +103 -0
- package/lib/utils/observability/index.d.ts +4 -0
- package/lib/utils/observability/index.js +26 -0
- package/lib/utils/observability/interfaces.d.ts +30 -0
- package/lib/utils/observability/interfaces.js +23 -0
- package/lib/utils/resolutionEditing.js +2 -1
- package/lib/utils/resourceSelector.d.ts +97 -0
- package/lib/utils/resourceSelector.js +195 -0
- package/lib/utils/resourceSelectors.d.ts +146 -0
- package/lib/utils/resourceSelectors.js +233 -0
- package/lib/utils/tsResIntegration.d.ts +6 -41
- package/lib/utils/tsResIntegration.js +20 -16
- package/lib/utils/zipLoader/zipProcessingHelpers.d.ts +3 -2
- package/lib/utils/zipLoader/zipProcessingHelpers.js +6 -5
- package/lib-commonjs/components/common/QualifierContextControl.js +4 -1
- package/lib-commonjs/components/common/ResourceTreeView.js +4 -1
- package/lib-commonjs/components/forms/GenericQualifierTypeEditForm.js +171 -0
- package/lib-commonjs/components/forms/index.js +3 -1
- package/lib-commonjs/components/orchestrator/ResourceOrchestrator.js +118 -51
- package/lib-commonjs/components/pickers/ResourcePicker/ResourcePickerTree.js +32 -10
- package/lib-commonjs/components/pickers/ResourcePicker/index.js +4 -2
- package/lib-commonjs/components/views/CompiledView/index.js +75 -16
- package/lib-commonjs/components/views/ConfigurationView/index.js +93 -34
- package/lib-commonjs/components/views/FilterView/index.js +7 -4
- package/lib-commonjs/components/views/GridView/EditableGridCell.js +232 -0
- package/lib-commonjs/components/views/GridView/GridSelector.js +94 -0
- package/lib-commonjs/components/views/GridView/MultiGridView.js +201 -0
- package/lib-commonjs/components/views/GridView/ResourceGrid.js +237 -0
- package/lib-commonjs/components/views/GridView/SharedContextControls.js +100 -0
- package/lib-commonjs/components/views/GridView/cells/BooleanCell.js +54 -0
- package/lib-commonjs/components/views/GridView/cells/DropdownCell.js +187 -0
- package/lib-commonjs/components/views/GridView/cells/StringCell.js +111 -0
- package/lib-commonjs/components/views/GridView/cells/TriStateCell.js +117 -0
- package/lib-commonjs/components/views/GridView/cells/index.js +18 -0
- package/lib-commonjs/components/views/GridView/index.js +217 -0
- package/lib-commonjs/components/views/ImportView/index.js +22 -19
- package/lib-commonjs/components/views/MessagesWindow/index.js +4 -1
- package/lib-commonjs/components/views/ResolutionView/index.js +8 -5
- package/lib-commonjs/contexts/ObservabilityContext.js +104 -0
- package/lib-commonjs/contexts/index.js +30 -0
- package/lib-commonjs/hooks/useResolutionState.js +849 -245
- package/lib-commonjs/hooks/useResourceData.js +184 -215
- package/lib-commonjs/index.js +15 -1
- package/lib-commonjs/namespaces/GridTools.js +161 -0
- package/lib-commonjs/namespaces/ObservabilityTools.js +33 -0
- package/lib-commonjs/namespaces/ResolutionTools.js +10 -1
- package/lib-commonjs/namespaces/index.js +3 -1
- package/lib-commonjs/types/index.js +10 -0
- package/lib-commonjs/utils/cellValidation.js +253 -0
- package/lib-commonjs/utils/downloadHelper.js +198 -0
- package/lib-commonjs/utils/observability/factories.js +63 -0
- package/lib-commonjs/utils/observability/implementations.js +109 -0
- package/lib-commonjs/utils/observability/index.js +36 -0
- package/lib-commonjs/utils/observability/interfaces.js +24 -0
- package/lib-commonjs/utils/resolutionEditing.js +2 -1
- package/lib-commonjs/utils/resourceSelector.js +200 -0
- package/lib-commonjs/utils/resourceSelectors.js +242 -0
- package/lib-commonjs/utils/tsResIntegration.js +21 -16
- package/lib-commonjs/utils/zipLoader/zipProcessingHelpers.js +7 -5
- package/package.json +7 -7
- package/src/components/common/QualifierContextControl.tsx +0 -338
- package/src/components/common/ResolutionContextOptionsControl.tsx +0 -450
- package/src/components/common/ResolutionResults/index.tsx +0 -481
- package/src/components/common/ResourceListView.tsx +0 -167
- package/src/components/common/ResourcePickerOptionsControl.tsx +0 -351
- package/src/components/common/ResourceTreeView.tsx +0 -417
- package/src/components/common/SourceResourceDetail/index.tsx +0 -493
- package/src/components/forms/HierarchyEditor.tsx +0 -285
- package/src/components/forms/QualifierEditForm.tsx +0 -487
- package/src/components/forms/QualifierTypeEditForm.tsx +0 -458
- package/src/components/forms/ResourceTypeEditForm.tsx +0 -437
- package/src/components/forms/index.ts +0 -11
- package/src/components/orchestrator/ResourceOrchestrator.tsx +0 -444
- package/src/components/pickers/ResourcePicker/README.md +0 -570
- package/src/components/pickers/ResourcePicker/ResourceItem.tsx +0 -127
- package/src/components/pickers/ResourcePicker/ResourcePickerList.tsx +0 -114
- package/src/components/pickers/ResourcePicker/ResourcePickerTree.tsx +0 -461
- package/src/components/pickers/ResourcePicker/index.tsx +0 -234
- package/src/components/pickers/ResourcePicker/types.ts +0 -301
- package/src/components/pickers/ResourcePicker/utils/treeNavigation.ts +0 -210
- package/src/components/views/CompiledView/index.tsx +0 -1342
- package/src/components/views/ConfigurationView/index.tsx +0 -848
- package/src/components/views/FilterView/index.tsx +0 -681
- package/src/components/views/ImportView/index.tsx +0 -789
- package/src/components/views/MessagesWindow/index.tsx +0 -325
- package/src/components/views/ResolutionView/EditableJsonView.tsx +0 -386
- package/src/components/views/ResolutionView/NewResourceModal.tsx +0 -158
- package/src/components/views/ResolutionView/UnifiedChangeControls.tsx +0 -163
- package/src/components/views/ResolutionView/index.tsx +0 -751
- package/src/components/views/SourceView/index.tsx +0 -291
- package/src/hooks/useConfigurationState.ts +0 -436
- package/src/hooks/useFilterState.ts +0 -150
- package/src/hooks/useResolutionState.ts +0 -893
- package/src/hooks/useResourceData.ts +0 -596
- package/src/hooks/useViewState.ts +0 -97
- package/src/index.ts +0 -68
- package/src/namespaces/ConfigurationTools.ts +0 -59
- package/src/namespaces/FilterTools.ts +0 -47
- package/src/namespaces/ImportTools.ts +0 -42
- package/src/namespaces/PickerTools.ts +0 -104
- package/src/namespaces/ResolutionTools.ts +0 -68
- package/src/namespaces/ResourceTools.ts +0 -106
- package/src/namespaces/TsResTools.ts +0 -49
- package/src/namespaces/ViewStateTools.ts +0 -91
- package/src/namespaces/ZipTools.ts +0 -49
- package/src/namespaces/index.ts +0 -49
- package/src/types/index.ts +0 -1273
- package/src/utils/configurationUtils.ts +0 -339
- package/src/utils/fileProcessing.ts +0 -164
- package/src/utils/filterResources.ts +0 -356
- package/src/utils/resolutionEditing.ts +0 -346
- package/src/utils/resolutionUtils.ts +0 -740
- package/src/utils/tsResIntegration.ts +0 -475
- package/src/utils/zipLoader/index.ts +0 -5
- package/src/utils/zipLoader/zipProcessingHelpers.ts +0 -46
- package/src/utils/zipLoader/zipUtils.ts +0 -7
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import React, { useState, useCallback } from 'react';
|
|
2
|
-
import { XMarkIcon, InformationCircleIcon } from '@heroicons/react/24/outline';
|
|
3
|
-
import { ResourceTypes } from '@fgv/ts-res';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Props for the ResourceTypeEditForm component.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export interface ResourceTypeEditFormProps {
|
|
11
|
-
/** Existing resource type to edit (undefined for creating new type) */
|
|
12
|
-
resourceType?: ResourceTypes.Config.IResourceTypeConfig;
|
|
13
|
-
/** Callback fired when resource type is saved */
|
|
14
|
-
onSave: (resourceType: ResourceTypes.Config.IResourceTypeConfig) => void;
|
|
15
|
-
/** Callback fired when editing is cancelled */
|
|
16
|
-
onCancel: () => void;
|
|
17
|
-
/** Names of existing resource types to prevent duplicates */
|
|
18
|
-
existingNames?: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface FormData {
|
|
22
|
-
name: string;
|
|
23
|
-
typeName: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const COMMON_TYPE_NAMES = [
|
|
27
|
-
'string',
|
|
28
|
-
'object',
|
|
29
|
-
'array',
|
|
30
|
-
'number',
|
|
31
|
-
'boolean',
|
|
32
|
-
'localizedString',
|
|
33
|
-
'config',
|
|
34
|
-
'settings',
|
|
35
|
-
'permissions',
|
|
36
|
-
'template',
|
|
37
|
-
'content',
|
|
38
|
-
'metadata'
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Modal form component for creating and editing resource types in a ts-res system configuration.
|
|
43
|
-
*
|
|
44
|
-
* The ResourceTypeEditForm provides an interface for defining resource types that categorize
|
|
45
|
-
* resources and determine their data handling behavior. It supports both common predefined
|
|
46
|
-
* types and custom types for specialized use cases, with automatic type suggestion based
|
|
47
|
-
* on resource type names.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```tsx
|
|
51
|
-
* import { ConfigurationTools } from '@fgv/ts-res-ui-components';
|
|
52
|
-
*
|
|
53
|
-
* // Creating a new resource type with common type
|
|
54
|
-
* const [showForm, setShowForm] = useState(false);
|
|
55
|
-
* const [resourceTypes, setResourceTypes] = useState([]);
|
|
56
|
-
*
|
|
57
|
-
* const handleSave = (resourceType) => {
|
|
58
|
-
* setResourceTypes(prev => [...prev, resourceType]);
|
|
59
|
-
* setShowForm(false);
|
|
60
|
-
* };
|
|
61
|
-
*
|
|
62
|
-
* {showForm && (
|
|
63
|
-
* <ConfigurationTools.ResourceTypeEditForm
|
|
64
|
-
* onSave={handleSave}
|
|
65
|
-
* onCancel={() => setShowForm(false)}
|
|
66
|
-
* existingNames={resourceTypes.map(rt => rt.name)}
|
|
67
|
-
* />
|
|
68
|
-
* )}
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```tsx
|
|
73
|
-
* // Editing an existing resource type
|
|
74
|
-
* const userSettingsType = {
|
|
75
|
-
* name: 'userSettings',
|
|
76
|
-
* typeName: 'object' // Built-in object type for structured data
|
|
77
|
-
* };
|
|
78
|
-
*
|
|
79
|
-
* <ConfigurationTools.ResourceTypeEditForm
|
|
80
|
-
* resourceType={userSettingsType}
|
|
81
|
-
* onSave={updateResourceType}
|
|
82
|
-
* onCancel={closeEditor}
|
|
83
|
-
* existingNames={otherTypeNames}
|
|
84
|
-
* />
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```tsx
|
|
89
|
-
* // Creating resource types for different content categories
|
|
90
|
-
* const contentTypes = [
|
|
91
|
-
* { name: 'errorMessages', typeName: 'string' },
|
|
92
|
-
* { name: 'uiLabels', typeName: 'localizedString' },
|
|
93
|
-
* { name: 'navigationMenus', typeName: 'object' },
|
|
94
|
-
* { name: 'permissionLists', typeName: 'array' },
|
|
95
|
-
* { name: 'appConfig', typeName: 'config' },
|
|
96
|
-
* { name: 'customValidator', typeName: 'customValidation' } // Custom type
|
|
97
|
-
* ];
|
|
98
|
-
*
|
|
99
|
-
* const CreateResourceTypesForm = () => {
|
|
100
|
-
* const [currentType, setCurrentType] = useState(null);
|
|
101
|
-
*
|
|
102
|
-
* return (
|
|
103
|
-
* <div>
|
|
104
|
-
* {currentType && (
|
|
105
|
-
* <ConfigurationTools.ResourceTypeEditForm
|
|
106
|
-
* resourceType={currentType}
|
|
107
|
-
* onSave={handleSaveType}
|
|
108
|
-
* onCancel={() => setCurrentType(null)}
|
|
109
|
-
* existingNames={existingNames}
|
|
110
|
-
* />
|
|
111
|
-
* )}
|
|
112
|
-
* </div>
|
|
113
|
-
* );
|
|
114
|
-
* };
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```tsx
|
|
119
|
-
* // Custom resource type for specialized processing
|
|
120
|
-
* const templateType = {
|
|
121
|
-
* name: 'emailTemplates',
|
|
122
|
-
* typeName: 'htmlTemplate' // Custom type name for specialized handling
|
|
123
|
-
* };
|
|
124
|
-
*
|
|
125
|
-
* <ConfigurationTools.ResourceTypeEditForm
|
|
126
|
-
* resourceType={templateType}
|
|
127
|
-
* onSave={(updatedType) => {
|
|
128
|
-
* // Handle custom type processing
|
|
129
|
-
* console.log('Custom type saved:', updatedType.typeName);
|
|
130
|
-
* saveToConfiguration(updatedType);
|
|
131
|
-
* }}
|
|
132
|
-
* onCancel={cancelEdit}
|
|
133
|
-
* />
|
|
134
|
-
* ```
|
|
135
|
-
*
|
|
136
|
-
* @public
|
|
137
|
-
*/
|
|
138
|
-
export const ResourceTypeEditForm: React.FC<ResourceTypeEditFormProps> = ({
|
|
139
|
-
resourceType,
|
|
140
|
-
onSave,
|
|
141
|
-
onCancel,
|
|
142
|
-
existingNames = []
|
|
143
|
-
}) => {
|
|
144
|
-
const [formData, setFormData] = useState<FormData>(() => {
|
|
145
|
-
if (resourceType) {
|
|
146
|
-
return {
|
|
147
|
-
name: resourceType.name,
|
|
148
|
-
typeName: resourceType.typeName
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
name: '',
|
|
153
|
-
typeName: 'string'
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
const [errors, setErrors] = useState<Record<string, string>>({});
|
|
158
|
-
const [useCustomTypeName, setUseCustomTypeName] = useState(() => {
|
|
159
|
-
if (resourceType) {
|
|
160
|
-
return !COMMON_TYPE_NAMES.includes(resourceType.typeName);
|
|
161
|
-
}
|
|
162
|
-
return false;
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Validation
|
|
166
|
-
const validateForm = useCallback((): boolean => {
|
|
167
|
-
const newErrors: Record<string, string> = {};
|
|
168
|
-
|
|
169
|
-
if (!formData.name.trim()) {
|
|
170
|
-
newErrors.name = 'Name is required';
|
|
171
|
-
} else if (existingNames.includes(formData.name) && formData.name !== resourceType?.name) {
|
|
172
|
-
newErrors.name = 'Name must be unique';
|
|
173
|
-
} else if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(formData.name)) {
|
|
174
|
-
newErrors.name = 'Name must start with a letter and contain only letters, numbers, and underscores';
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (!formData.typeName.trim()) {
|
|
178
|
-
newErrors.typeName = 'Type name is required';
|
|
179
|
-
} else if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(formData.typeName)) {
|
|
180
|
-
newErrors.typeName =
|
|
181
|
-
'Type name must start with a letter and contain only letters, numbers, and underscores';
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
setErrors(newErrors);
|
|
185
|
-
return Object.keys(newErrors).length === 0;
|
|
186
|
-
}, [formData, existingNames, resourceType?.name]);
|
|
187
|
-
|
|
188
|
-
const handleSave = useCallback(() => {
|
|
189
|
-
if (!validateForm()) return;
|
|
190
|
-
|
|
191
|
-
const result: ResourceTypes.Config.IResourceTypeConfig = {
|
|
192
|
-
name: formData.name,
|
|
193
|
-
typeName: formData.typeName
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
onSave(result);
|
|
197
|
-
}, [formData, validateForm, onSave]);
|
|
198
|
-
|
|
199
|
-
const updateField = useCallback(
|
|
200
|
-
(field: keyof FormData, value: any) => {
|
|
201
|
-
setFormData((prev) => {
|
|
202
|
-
const updated = { ...prev, [field]: value };
|
|
203
|
-
|
|
204
|
-
// Auto-generate typeName from name for new resource types if using common types
|
|
205
|
-
if (field === 'name' && !resourceType && !useCustomTypeName) {
|
|
206
|
-
const cleanName = value.toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
|
|
207
|
-
const commonType = COMMON_TYPE_NAMES.find(
|
|
208
|
-
(type) => cleanName.includes(type) || type.includes(cleanName)
|
|
209
|
-
);
|
|
210
|
-
if (commonType) {
|
|
211
|
-
updated.typeName = commonType;
|
|
212
|
-
} else {
|
|
213
|
-
updated.typeName = cleanName || 'string';
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return updated;
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
if (errors[field]) {
|
|
221
|
-
setErrors((prev) => ({ ...prev, [field]: '' }));
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
[errors, resourceType, useCustomTypeName]
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
const handleTypeNameModeChange = useCallback(
|
|
228
|
-
(useCustom: boolean) => {
|
|
229
|
-
setUseCustomTypeName(useCustom);
|
|
230
|
-
if (!useCustom && !resourceType) {
|
|
231
|
-
// Reset to a common type
|
|
232
|
-
updateField('typeName', 'string');
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
[resourceType, updateField]
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
const getTypeNameDescription = (typeName: string): string => {
|
|
239
|
-
switch (typeName) {
|
|
240
|
-
case 'string':
|
|
241
|
-
return 'Simple text content (default)';
|
|
242
|
-
case 'object':
|
|
243
|
-
return 'Complex structured data (JSON objects)';
|
|
244
|
-
case 'array':
|
|
245
|
-
return 'List of values or objects';
|
|
246
|
-
case 'number':
|
|
247
|
-
return 'Numeric values';
|
|
248
|
-
case 'boolean':
|
|
249
|
-
return 'True/false values';
|
|
250
|
-
case 'localizedString':
|
|
251
|
-
return 'Text content with localization support';
|
|
252
|
-
case 'config':
|
|
253
|
-
return 'Configuration settings and parameters';
|
|
254
|
-
case 'settings':
|
|
255
|
-
return 'User or application settings';
|
|
256
|
-
case 'permissions':
|
|
257
|
-
return 'Access control and permission data';
|
|
258
|
-
case 'template':
|
|
259
|
-
return 'Template content for rendering';
|
|
260
|
-
case 'content':
|
|
261
|
-
return 'Rich content (HTML, Markdown, etc.)';
|
|
262
|
-
case 'metadata':
|
|
263
|
-
return 'Descriptive information about resources';
|
|
264
|
-
default:
|
|
265
|
-
return 'Custom resource type';
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
return (
|
|
270
|
-
<div className="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 p-4">
|
|
271
|
-
<div className="bg-white rounded-lg shadow-xl max-w-2xl w-full h-full max-h-[calc(100vh-2rem)] flex flex-col">
|
|
272
|
-
{/* Fixed Header */}
|
|
273
|
-
<div className="flex items-center justify-between p-6 border-b flex-shrink-0">
|
|
274
|
-
<h3 className="text-lg font-medium text-gray-900">
|
|
275
|
-
{resourceType ? 'Edit Resource Type' : 'Add Resource Type'}
|
|
276
|
-
</h3>
|
|
277
|
-
<button onClick={onCancel} className="text-gray-400 hover:text-gray-600">
|
|
278
|
-
<XMarkIcon className="w-6 h-6" />
|
|
279
|
-
</button>
|
|
280
|
-
</div>
|
|
281
|
-
|
|
282
|
-
{/* Scrollable Content */}
|
|
283
|
-
<div className="p-6 space-y-6 overflow-y-auto flex-1 min-h-0">
|
|
284
|
-
{/* Basic Properties */}
|
|
285
|
-
<div>
|
|
286
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">Name *</label>
|
|
287
|
-
<input
|
|
288
|
-
type="text"
|
|
289
|
-
value={formData.name}
|
|
290
|
-
onChange={(e) => updateField('name', e.target.value)}
|
|
291
|
-
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
292
|
-
errors.name ? 'border-red-300' : 'border-gray-300'
|
|
293
|
-
}`}
|
|
294
|
-
placeholder="Enter resource type name (e.g., 'userSettings', 'errorMessages')"
|
|
295
|
-
/>
|
|
296
|
-
{errors.name && <p className="mt-1 text-sm text-red-600">{errors.name}</p>}
|
|
297
|
-
<p className="mt-1 text-xs text-gray-500">
|
|
298
|
-
A descriptive name for this type of resource. This will be used to categorize and identify
|
|
299
|
-
resources.
|
|
300
|
-
</p>
|
|
301
|
-
</div>
|
|
302
|
-
|
|
303
|
-
{/* Type Name Configuration */}
|
|
304
|
-
<div>
|
|
305
|
-
<label className="block text-sm font-medium text-gray-700 mb-3">Type Name Configuration *</label>
|
|
306
|
-
|
|
307
|
-
<div className="space-y-3">
|
|
308
|
-
<div className="flex items-center">
|
|
309
|
-
<input
|
|
310
|
-
type="radio"
|
|
311
|
-
id="useCommonType"
|
|
312
|
-
name="typeNameMode"
|
|
313
|
-
checked={!useCustomTypeName}
|
|
314
|
-
onChange={() => handleTypeNameModeChange(false)}
|
|
315
|
-
className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300"
|
|
316
|
-
/>
|
|
317
|
-
<label htmlFor="useCommonType" className="ml-2 text-sm text-gray-700">
|
|
318
|
-
Use common type name
|
|
319
|
-
</label>
|
|
320
|
-
</div>
|
|
321
|
-
|
|
322
|
-
{!useCustomTypeName && (
|
|
323
|
-
<div className="ml-6">
|
|
324
|
-
<select
|
|
325
|
-
value={formData.typeName}
|
|
326
|
-
onChange={(e) => updateField('typeName', e.target.value)}
|
|
327
|
-
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
328
|
-
errors.typeName ? 'border-red-300' : 'border-gray-300'
|
|
329
|
-
}`}
|
|
330
|
-
>
|
|
331
|
-
{COMMON_TYPE_NAMES.map((type) => (
|
|
332
|
-
<option key={type} value={type}>
|
|
333
|
-
{type}
|
|
334
|
-
</option>
|
|
335
|
-
))}
|
|
336
|
-
</select>
|
|
337
|
-
<p className="mt-1 text-xs text-gray-600">{getTypeNameDescription(formData.typeName)}</p>
|
|
338
|
-
</div>
|
|
339
|
-
)}
|
|
340
|
-
|
|
341
|
-
<div className="flex items-center">
|
|
342
|
-
<input
|
|
343
|
-
type="radio"
|
|
344
|
-
id="useCustomType"
|
|
345
|
-
name="typeNameMode"
|
|
346
|
-
checked={useCustomTypeName}
|
|
347
|
-
onChange={() => handleTypeNameModeChange(true)}
|
|
348
|
-
className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300"
|
|
349
|
-
/>
|
|
350
|
-
<label htmlFor="useCustomType" className="ml-2 text-sm text-gray-700">
|
|
351
|
-
Define custom type name
|
|
352
|
-
</label>
|
|
353
|
-
</div>
|
|
354
|
-
|
|
355
|
-
{useCustomTypeName && (
|
|
356
|
-
<div className="ml-6">
|
|
357
|
-
<input
|
|
358
|
-
type="text"
|
|
359
|
-
value={formData.typeName}
|
|
360
|
-
onChange={(e) => updateField('typeName', e.target.value)}
|
|
361
|
-
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
362
|
-
errors.typeName ? 'border-red-300' : 'border-gray-300'
|
|
363
|
-
}`}
|
|
364
|
-
placeholder="Enter custom type name"
|
|
365
|
-
/>
|
|
366
|
-
<p className="mt-1 text-xs text-gray-500">
|
|
367
|
-
Define a custom type name for specialized resource handling
|
|
368
|
-
</p>
|
|
369
|
-
</div>
|
|
370
|
-
)}
|
|
371
|
-
</div>
|
|
372
|
-
|
|
373
|
-
{errors.typeName && <p className="mt-1 text-sm text-red-600">{errors.typeName}</p>}
|
|
374
|
-
</div>
|
|
375
|
-
|
|
376
|
-
{/* Information Panel */}
|
|
377
|
-
<div className="p-4 bg-blue-50 rounded-lg">
|
|
378
|
-
<div className="flex items-start">
|
|
379
|
-
<InformationCircleIcon className="w-5 h-5 text-blue-400 mt-0.5 mr-3 flex-shrink-0" />
|
|
380
|
-
<div className="text-sm text-blue-800">
|
|
381
|
-
<h4 className="font-medium mb-2">About Resource Types</h4>
|
|
382
|
-
<div className="space-y-2">
|
|
383
|
-
<p>
|
|
384
|
-
Resource types define how resources are categorized and processed in your application.
|
|
385
|
-
</p>
|
|
386
|
-
<ul className="list-disc list-inside space-y-1 ml-2">
|
|
387
|
-
<li>
|
|
388
|
-
<strong>Name:</strong> A human-readable identifier for grouping resources
|
|
389
|
-
</li>
|
|
390
|
-
<li>
|
|
391
|
-
<strong>Type Name:</strong> Determines how the resource data is interpreted and
|
|
392
|
-
validated
|
|
393
|
-
</li>
|
|
394
|
-
<li>Common types (string, object, array) provide built-in processing</li>
|
|
395
|
-
<li>Custom types allow specialized handling for domain-specific data</li>
|
|
396
|
-
</ul>
|
|
397
|
-
</div>
|
|
398
|
-
</div>
|
|
399
|
-
</div>
|
|
400
|
-
</div>
|
|
401
|
-
|
|
402
|
-
{/* Preview */}
|
|
403
|
-
<div className="p-4 bg-gray-50 rounded-lg">
|
|
404
|
-
<h4 className="font-medium text-gray-900 mb-2">Preview</h4>
|
|
405
|
-
<div className="text-sm text-gray-600">
|
|
406
|
-
<p>
|
|
407
|
-
<span className="font-medium">Resource Type:</span> {formData.name || '(name not set)'}
|
|
408
|
-
</p>
|
|
409
|
-
<p>
|
|
410
|
-
<span className="font-medium">Type Name:</span> {formData.typeName}
|
|
411
|
-
</p>
|
|
412
|
-
<p>
|
|
413
|
-
<span className="font-medium">Description:</span> {getTypeNameDescription(formData.typeName)}
|
|
414
|
-
</p>
|
|
415
|
-
</div>
|
|
416
|
-
</div>
|
|
417
|
-
</div>
|
|
418
|
-
|
|
419
|
-
{/* Fixed Footer */}
|
|
420
|
-
<div className="flex justify-end space-x-3 px-6 py-4 border-t bg-gray-50 flex-shrink-0">
|
|
421
|
-
<button
|
|
422
|
-
onClick={onCancel}
|
|
423
|
-
className="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
424
|
-
>
|
|
425
|
-
Cancel
|
|
426
|
-
</button>
|
|
427
|
-
<button
|
|
428
|
-
onClick={handleSave}
|
|
429
|
-
className="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
430
|
-
>
|
|
431
|
-
{resourceType ? 'Save Changes' : 'Add Resource Type'}
|
|
432
|
-
</button>
|
|
433
|
-
</div>
|
|
434
|
-
</div>
|
|
435
|
-
</div>
|
|
436
|
-
);
|
|
437
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { QualifierTypeEditForm } from './QualifierTypeEditForm';
|
|
2
|
-
export type { QualifierTypeEditFormProps } from './QualifierTypeEditForm';
|
|
3
|
-
|
|
4
|
-
export { QualifierEditForm } from './QualifierEditForm';
|
|
5
|
-
export type { QualifierEditFormProps } from './QualifierEditForm';
|
|
6
|
-
|
|
7
|
-
export { ResourceTypeEditForm } from './ResourceTypeEditForm';
|
|
8
|
-
export type { ResourceTypeEditFormProps } from './ResourceTypeEditForm';
|
|
9
|
-
|
|
10
|
-
export { HierarchyEditor } from './HierarchyEditor';
|
|
11
|
-
export type { HierarchyEditorProps } from './HierarchyEditor';
|