Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove: APIKey Header customization from publisher portal #608

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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