Skip to content

Commit a0be3c4

Browse files
committed
Fix ESLint prettier/prettier and prop-types issues
- Fix indentation in ConfigurationLayout.jsx onSchemaChange callback - Add PropTypes validation to GlobalServiceTierSection component - Add PropTypes validation to OperationServiceTierField component - Fix formatting in configTypes.js SERVICE_TIER_HELP_TEXT
1 parent edb73c3 commit a0be3c4

File tree

4 files changed

+48
-32
lines changed

4 files changed

+48
-32
lines changed

src/ui/src/components/configuration-layout/ConfigurationLayout.jsx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,34 +1245,34 @@ const ConfigurationLayout = () => {
12451245
onChange={handleFormChange}
12461246
extractionSchema={extractionSchema}
12471247
onSchemaChange={(schemaData, isDirty) => {
1248-
setExtractionSchema(schemaData);
1249-
if (isDirty) {
1250-
const updatedConfig = { ...formValues };
1251-
// CRITICAL: Always set classes, even if empty array (to support wipe all functionality)
1252-
// Handle null (no classes) by setting empty array
1253-
if (schemaData === null) {
1254-
updatedConfig.classes = [];
1255-
} else if (Array.isArray(schemaData)) {
1256-
// Store as 'classes' field with JSON Schema content
1257-
updatedConfig.classes = schemaData;
1248+
setExtractionSchema(schemaData);
1249+
if (isDirty) {
1250+
const updatedConfig = { ...formValues };
1251+
// CRITICAL: Always set classes, even if empty array (to support wipe all functionality)
1252+
// Handle null (no classes) by setting empty array
1253+
if (schemaData === null) {
1254+
updatedConfig.classes = [];
1255+
} else if (Array.isArray(schemaData)) {
1256+
// Store as 'classes' field with JSON Schema content
1257+
updatedConfig.classes = schemaData;
1258+
}
1259+
setFormValues(updatedConfig);
1260+
setJsonContent(JSON.stringify(updatedConfig, null, 2));
1261+
try {
1262+
setYamlContent(yaml.dump(updatedConfig));
1263+
} catch (e) {
1264+
console.error('Error converting to YAML:', e);
1265+
}
12581266
}
1259-
setFormValues(updatedConfig);
1260-
setJsonContent(JSON.stringify(updatedConfig, null, 2));
1261-
try {
1262-
setYamlContent(yaml.dump(updatedConfig));
1263-
} catch (e) {
1264-
console.error('Error converting to YAML:', e);
1267+
}}
1268+
onSchemaValidate={(valid, errors) => {
1269+
if (!valid) {
1270+
setValidationErrors(errors.map((e) => ({ message: `Schema: ${e.path} - ${e.message}` })));
1271+
} else {
1272+
setValidationErrors([]);
12651273
}
1266-
}
1267-
}}
1268-
onSchemaValidate={(valid, errors) => {
1269-
if (!valid) {
1270-
setValidationErrors(errors.map((e) => ({ message: `Schema: ${e.path} - ${e.message}` })));
1271-
} else {
1272-
setValidationErrors([]);
1273-
}
1274-
}}
1275-
/>
1274+
}}
1275+
/>
12761276
</SpaceBetween>
12771277
)}
12781278

src/ui/src/components/configuration-layout/GlobalServiceTierSection.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import React from 'react';
5+
import PropTypes from 'prop-types';
56
import { FormField, Select } from '@cloudscape-design/components';
67
import { SERVICE_TIER_OPTIONS, SERVICE_TIER_HELP_TEXT } from '../../constants/configTypes';
78

@@ -45,4 +46,11 @@ const GlobalServiceTierSection = ({ configuration, onConfigChange }) => {
4546
);
4647
};
4748

49+
GlobalServiceTierSection.propTypes = {
50+
configuration: PropTypes.shape({
51+
service_tier: PropTypes.string,
52+
}).isRequired,
53+
onConfigChange: PropTypes.func.isRequired,
54+
};
55+
4856
export default GlobalServiceTierSection;

src/ui/src/components/configuration-layout/OperationServiceTierField.jsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import React from 'react';
5+
import PropTypes from 'prop-types';
56
import { FormField, Select } from '@cloudscape-design/components';
67
import { SERVICE_TIER_OPERATION_OPTIONS, SERVICE_TIER_HELP_TEXT } from '../../constants/configTypes';
78

@@ -19,10 +20,7 @@ const OperationServiceTierField = ({ value, onChange, globalTier = 'standard' })
1920
};
2021

2122
return (
22-
<FormField
23-
label="Service Tier Override"
24-
description={`${SERVICE_TIER_HELP_TEXT.operation} Current effective tier: ${effectiveTier}`}
25-
>
23+
<FormField label="Service Tier Override" description={`${SERVICE_TIER_HELP_TEXT.operation} Current effective tier: ${effectiveTier}`}>
2624
<Select
2725
selectedOption={SERVICE_TIER_OPERATION_OPTIONS.find((opt) => opt.value === value)}
2826
onChange={handleChange}
@@ -33,4 +31,15 @@ const OperationServiceTierField = ({ value, onChange, globalTier = 'standard' })
3331
);
3432
};
3533

34+
OperationServiceTierField.propTypes = {
35+
value: PropTypes.string,
36+
onChange: PropTypes.func.isRequired,
37+
globalTier: PropTypes.string,
38+
};
39+
40+
OperationServiceTierField.defaultProps = {
41+
value: null,
42+
globalTier: 'standard',
43+
};
44+
3645
export default OperationServiceTierField;

src/ui/src/constants/configTypes.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,5 @@ export const SERVICE_TIER_OPERATION_OPTIONS = [
4040
export const SERVICE_TIER_HELP_TEXT = {
4141
global:
4242
'Choose the default service tier for all Bedrock API calls. Priority offers fastest response times at premium pricing, Standard provides consistent performance, and Flex offers cost savings with longer latency.',
43-
operation:
44-
'Override the global service tier for this specific operation. Select "Use Global Default" to inherit the global setting.',
43+
operation: 'Override the global service tier for this specific operation. Select "Use Global Default" to inherit the global setting.',
4544
};

0 commit comments

Comments
 (0)