Skip to content

Commit f6793a7

Browse files
committed
Fix tenantsert store issue
1 parent 1febb6f commit f6793a7

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

portals/admin/src/main/webapp/source/src/app/components/KeyManagers/KeyManagerConfiguration.jsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ const StyledSpan = styled('span')(({ theme }) => ({ color: theme.palette.error.d
1515
* @param {JSON} state The second number.
1616
* @returns {Promise}
1717
*/
18-
function certificateReducer(state, newValue) {
19-
const { field, value } = newValue;
18+
function certificateReducer(state, action) {
19+
// If we receive a direct certificate update
20+
if (action.type === undefined && action.value !== undefined) {
21+
return {
22+
type: action.value.type || 'PEM',
23+
value: action.value.value || '',
24+
};
25+
}
26+
// If we receive a field update
27+
const { field, value } = action;
2028
if (field === 'tenantWideCertificates') {
21-
return { ...state, [field]: value };
22-
} else {
23-
return newValue;
29+
return {
30+
type: value.type || state.type,
31+
value: value.value || '',
32+
};
2433
}
34+
return state;
2535
}
2636

2737
export default function KeyManagerConfiguration(props) {
@@ -39,10 +49,15 @@ export default function KeyManagerConfiguration(props) {
3949
type: 'PEM',
4050
value: '',
4151
});
42-
// Add effect to watch for changes
52+
// Add effect to watch for changes and sync with additionalProperties
4353
useEffect(() => {
4454
if (tenantWideCertificates) {
45-
setAdditionalProperties('certificates', tenantWideCertificates);
55+
// Ensure we only pass the correct structure
56+
const certificateData = {
57+
type: tenantWideCertificates.type || 'PEM',
58+
value: tenantWideCertificates.value || '',
59+
};
60+
setAdditionalProperties('certificates', certificateData);
4661
}
4762
}, [tenantWideCertificates, setAdditionalProperties]);
4863

0 commit comments

Comments
 (0)