Skip to content

Commit 5105e31

Browse files
Resolve review comments
1 parent 7cf8aa8 commit 5105e31

File tree

7 files changed

+47
-23
lines changed

7 files changed

+47
-23
lines changed

portals/publisher/src/main/webapp/site/public/locales/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,6 @@
16361636
"Apis.Details.Resources.components.AsyncOperation.no.security": "No security",
16371637
"Apis.Details.Resources.components.AsyncOperation.operations.count.label": "Operations ({count})",
16381638
"Apis.Details.Resources.components.AsyncOperation.security.enabled": "Security enabled",
1639-
"Apis.Details.Resources.components.AsyncOperation.security.operation": "Security",
16401639
"Apis.Details.Resources.components.Operation.Delete": "Delete",
16411640
"Apis.Details.Resources.components.Operation.Name": "Name",
16421641
"Apis.Details.Resources.components.Operation.Schema": "Schema",

portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Configuration/Topics.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export default function Topics(props) {
155155
...propVal,
156156
'x-operation': opName,
157157
'x-message': msgKey,
158+
'x-prop-name': propName,
158159
};
159160
});
160161
});
@@ -240,11 +241,12 @@ export default function Topics(props) {
240241
// Wire payload properties AFTER operations exist
241242
if (verbInfo.message && verbInfo.message.payload && verbInfo.message.payload.properties) {
242243
const byMessage = {};
243-
Object.entries(verbInfo.message.payload.properties).forEach(([propName, propVal]) => {
244+
Object.entries(verbInfo.message.payload.properties).forEach(([compositeKey, propVal]) => {
244245
const msgName = propVal['x-message'] || propVal['x-operation'] || '__default__';
245246
byMessage[msgName] = byMessage[msgName] || { opName: propVal['x-operation'], props: {} };
246-
const { 'x-operation': _op, 'x-message': _msg, ...cleanProp } = propVal;
247-
byMessage[msgName].props[propName] = cleanProp;
247+
const originalPropName = propVal['x-prop-name'] || compositeKey;
248+
const { 'x-operation': _op, 'x-message': _msg, 'x-prop-name': _pname, ...cleanProp } = propVal;
249+
byMessage[msgName].props[originalPropName] = cleanProp;
248250
});
249251

250252
Object.entries(byMessage).forEach(([msgName, { opName, props: msgProps }]) => {
@@ -480,21 +482,26 @@ export default function Topics(props) {
480482
}
481483
return { ...currentOperations, [target]: channelCopy };
482484
}
483-
case 'addPayloadProperty':
485+
case 'addPayloadProperty': {
484486
updatedOperation[verb].message = updatedOperation[verb].message || { };
485487
updatedOperation[verb].message.payload = updatedOperation[verb].message.payload || { };
486488
updatedOperation[verb].message.payload.type = 'object';
487489
updatedOperation[verb].message.payload.properties = updatedOperation[verb].message.payload.properties
488490
|| { };
489-
updatedOperation[verb].message.payload.properties[value.name] = {
491+
const propKey = isAsyncV3
492+
? `${value.message}__${value.name}`
493+
: value.name;
494+
updatedOperation[verb].message.payload.properties[propKey] = {
490495
description: value.description,
491496
type: value.type,
492497
...(isAsyncV3 && {
493498
'x-operation': value.operation,
494499
'x-message': value.message,
500+
'x-prop-name': value.name,
495501
}),
496502
};
497503
break;
504+
}
498505
case 'deletePayloadProperty': {
499506
const existingProps = updatedOperation[verb]?.message?.payload?.properties || {};
500507
const { [value]: _removed, ...remainingProps } = existingProps;

portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Policies/PoliciesSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const PoliciesSection: FC<PolicySectionProps> = ({
7979

8080
// Derive async api version from spec directly
8181
const isAsyncV3 = openAPISpec?.asyncapi
82-
? parseInt(openAPISpec.asyncapi.split('.')[0], 10) >= 3
82+
? Number.parseInt(openAPISpec.asyncapi.split('.')[0], 10) >= 3
8383
: false;
8484

8585
return (

portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Resources/components/AsyncOperation.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function AsyncOperation(props) {
106106
: verb;
107107

108108
const theme = useTheme();
109-
const backgroundColor = theme.custom.resourceChipColors[verb] || theme.palette.primary.main;
109+
const backgroundColor = theme.custom.resourceChipColors[trimmedVerb] || theme.palette.primary.main;
110110

111111
const [isExpanded, setIsExpanded] = useState(false);
112112
const isUsedInAPIProduct = false;
@@ -183,7 +183,7 @@ function AsyncOperation(props) {
183183
width='100%'
184184
>
185185
<Box display='flex' alignItems='center' gap={2} sx={{ flex: 4 }}>
186-
<Badge invisible={false} color='error' variant='dot'>
186+
<Badge invisible='false' color='error' variant='dot'>
187187
<Button
188188
disableFocusRipple
189189
variant='outlined'
@@ -271,7 +271,7 @@ function AsyncOperation(props) {
271271
) : (
272272
<Grid container direction='row' justifyContent='space-between' alignItems='center' spacing={0}>
273273
<Grid item md={11}>
274-
<Badge invisible={false} color='error' variant='dot'>
274+
<Badge invisible='false' color='error' variant='dot'>
275275
<Button
276276
disableFocusRipple
277277
variant='outlined'

portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Resources/components/operationComponents/asyncapi/AddPayloadProperty.jsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,31 @@ function AddPayloadProperty(props) {
126126
* Add new property
127127
*/
128128
function addNewProperty() {
129-
if (isAsyncV3 && property.operation && !namedOperations.includes(property.operation)) {
130-
Alert.error(intl.formatMessage(
131-
{
132-
id: 'Apis.Details.Resources.components.operationComponents.AddParameter.operation.not.found',
133-
defaultMessage: 'Operation "{operation}" does not exist',
134-
},
135-
{ operation: property.operation },
136-
));
137-
return;
129+
if (isAsyncV3) {
130+
if (!property.operation) {
131+
Alert.error(intl.formatMessage({
132+
id: 'Apis.Details.Resources.components.operationComponents.AddParameter.operation.required',
133+
defaultMessage: 'Operation name is required',
134+
}));
135+
return;
136+
}
137+
if (!property.message) {
138+
Alert.error(intl.formatMessage({
139+
id: 'Apis.Details.Resources.components.operationComponents.AddParameter.message.required',
140+
defaultMessage: 'Message name is required',
141+
}));
142+
return;
143+
}
144+
if (!namedOperations.includes(property.operation)) {
145+
Alert.error(intl.formatMessage(
146+
{
147+
id: 'Apis.Details.Resources.components.operationComponents.AddParameter.operation.not.found',
148+
defaultMessage: 'Operation "{operation}" does not exist',
149+
},
150+
{ operation: property.operation },
151+
));
152+
return;
153+
}
138154
}
139155
operationsDispatcher({
140156
action: 'addPayloadProperty',
@@ -221,7 +237,7 @@ function AddPayloadProperty(props) {
221237
}
222238
}}
223239
/>
224-
</Grid>
240+
</Grid>
225241
<Grid item xs={2} md={2}>
226242
<FormControl margin='dense' variant='outlined' className={classes.formControl}>
227243
{/* <InputLabel ref={inputLabel} htmlFor='data-type' error={isParameterExist}> */}
@@ -365,7 +381,9 @@ AddPayloadProperty.propTypes = {
365381
operationsDispatcher: PropTypes.func.isRequired,
366382
target: PropTypes.string.isRequired,
367383
verb: PropTypes.string.isRequired,
368-
intl: PropTypes.shape({}).isRequired,
384+
intl: PropTypes.shape({
385+
formatMessage: PropTypes.func.isRequired,
386+
}).isRequired,
369387
isAsyncV3: PropTypes.bool,
370388
namedOperations: PropTypes.arrayOf(PropTypes.string),
371389
};

portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Resources/components/operationComponents/asyncapi/Asyncv3OperationsList.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ Asyncv3OperationsList.defaultProps = {
138138
disableDelete: false,
139139
};
140140

141-
export default Asyncv3OperationsList;
141+
export default Asyncv3OperationsList;

portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Resources/components/operationComponents/asyncapi/ListPayloadProperties.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ export default function ListPayloadProperties(props) {
133133
properties && Object.entries(properties).map(([k, v]) => {
134134
return (
135135
<TableRow key={k}>
136-
<TableCell align='left'>{k}</TableCell>
137136
{isAsyncV3 && (
138137
<>
139138
<TableCell align='left'>{v['x-operation'] || '—'}</TableCell>
140139
<TableCell align='left'>{v['x-message'] || '—'}</TableCell>
141140
</>
142141
)}
142+
<TableCell align='left'>{k}</TableCell>
143143
<TableCell align='left'>{v.type}</TableCell>
144144
<TableCell align='left'>{v.description}</TableCell>
145145
<TableCell align='left'>

0 commit comments

Comments
 (0)