Skip to content

Commit

Permalink
Fix transport level security ui
Browse files Browse the repository at this point in the history
Uncheck and disable http checkbox when mtls is checked
  • Loading branch information
SavinduDimal committed Oct 9, 2023
1 parent f6b1635 commit 2121317
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ function TransportLevel(props) {
});
};

const handleMutualSSLChange = (event) => {
const { checked } = event.target;
if (checked) {
configDispatcher({
action: 'transport',
event: { checked: false, value: 'http' },
});
}
configDispatcher({
action: 'securityScheme',
event: { checked, value: API_SECURITY_MUTUAL_SSL },
});
};

// Get the client certificates from backend.
useEffect(() => {
API.getAllClientCertificates(id).then((resp) => {
Expand Down Expand Up @@ -192,11 +206,7 @@ function TransportLevel(props) {
<Checkbox
disabled={isRestricted(['apim:api_create'], apiFromContext)}
checked={isMutualSSLEnabled}
onChange={({ target: { checked, value } }) => configDispatcher({
action: 'securityScheme',
event: { checked, value },
})}
value={API_SECURITY_MUTUAL_SSL}
onChange={handleMutualSSLChange}
color='primary'
id='mutual-ssl-checkbox'
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export default function Transports(props) {
<FormControlLabel
control={(
<Checkbox
disabled={isRestricted(['apim:api_create'], apiFromContext)}
disabled={isRestricted(['apim:api_create'], apiFromContext) || isMutualSSLEnabled}
checked={api.transport
? api.transport.includes('http') : null}
? api.transport.includes('http') && !isMutualSSLEnabled : null}
onChange={({ target: { checked } }) => configDispatcher({
action: 'transport',
event: { checked, value: 'http' },
Expand Down

0 comments on commit 2121317

Please sign in to comment.