Skip to content

Commit

Permalink
Merge pull request #608 from BLasan/remove-api-key-header-customization
Browse files Browse the repository at this point in the history
Remove: APIKey Header customization from publisher portal #608
  • Loading branch information
BLasan authored Mar 21, 2024
2 parents 18239a7 + 3da2d04 commit ab01bc3
Showing 1 changed file with 57 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import APIValidation from 'AppData/APIValidation';
export default function ApiKeyHeader(props) {
const { api, configDispatcher } = props;
const [apiFromContext] = useAPI();
const isRestAPI = apiFromContext.type==="HTTP";
const [isHeaderNameValid, setIsHeaderNameValid] = useState(true);
let hasResourceWithSecurity;
const apiKeyHeaderValue = api.apiKeyHeader;
Expand Down Expand Up @@ -73,63 +74,65 @@ export default function ApiKeyHeader(props) {
}
}

return (
<Grid container spacing={1} alignItems='center'>
<Grid item xs={11}>
<TextField
disabled={isRestricted(['apim:api_create'], apiFromContext) || !hasResourceWithSecurity}
id='outlined-name'
label={(
<FormattedMessage
id='Apis.Details.Configuration.Configuration.apiKey.header.label'
defaultMessage='ApiKey Header'
/>
)}
value={hasResourceWithSecurity ? apiKeyHeaderValue : ' '}
error={!isHeaderNameValid}
helperText={
(!isHeaderNameValid)
&& (
if(isRestAPI){
return (
<Grid container spacing={1} alignItems='center'>
<Grid item xs={11}>
<TextField
disabled={isRestricted(['apim:api_create'], apiFromContext) || !hasResourceWithSecurity}
id='outlined-name'
label={(
<FormattedMessage
id='Apis.Details.Configuration.ApiKeyHeader.helper.text'
defaultMessage='ApiKey header name cannot contain spaces or special characters'
id='Apis.Details.Configuration.Configuration.apiKey.header.label'
defaultMessage='ApiKey Header'
/>
)
}
InputProps={{
id: 'itest-id-apiKeyHeaderName-input',
onBlur: ({ target: { value } }) => {
validateHeader(value);
},
}}
margin='normal'
variant='outlined'
onChange={({ target: { value } }) => configDispatcher({
action: 'apiKeyHeader',
value: value === '' ? 'ApiKey' : value })}
style={{ display: 'flex' }}
/>
</Grid>
<Grid item xs={1}>
<Tooltip
title={(
<FormattedMessage
id='Apis.Details.Configuration.Configuration.ApiKeyHeader.tooltip'
defaultMessage={
' The header name that is used to send the api key '
+ 'information. "ApiKey" is the default header.'
}
/>
)}
aria-label='ApiKey Header'
placement='right-end'
interactive
>
<HelpOutline />
</Tooltip>
)}
value={hasResourceWithSecurity ? apiKeyHeaderValue : ' '}
error={!isHeaderNameValid}
helperText={
(!isHeaderNameValid)
&& (
<FormattedMessage
id='Apis.Details.Configuration.ApiKeyHeader.helper.text'
defaultMessage='ApiKey header name cannot contain spaces or special characters'
/>
)
}
InputProps={{
id: 'itest-id-apiKeyHeaderName-input',
onBlur: ({ target: { value } }) => {
validateHeader(value);
},
}}
margin='normal'
variant='outlined'
onChange={({ target: { value } }) => configDispatcher({
action: 'apiKeyHeader',
value: value === '' ? 'ApiKey' : value })}
style={{ display: 'flex' }}
/>
</Grid>
<Grid item xs={1}>
<Tooltip
title={(
<FormattedMessage
id='Apis.Details.Configuration.Configuration.ApiKeyHeader.tooltip'
defaultMessage={
' The header name that is used to send the api key '
+ 'information. "ApiKey" is the default header.'
}
/>
)}
aria-label='ApiKey Header'
placement='right-end'
interactive
>
<HelpOutline />
</Tooltip>
</Grid>
</Grid>
</Grid>
);
);
}
}

ApiKeyHeader.propTypes = {
Expand Down

0 comments on commit ab01bc3

Please sign in to comment.