diff --git a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Policies/PolicyForm/UploadPolicyDropzone.tsx b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Policies/PolicyForm/UploadPolicyDropzone.tsx index 57d63bd57ee..35ddf32d200 100644 --- a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Policies/PolicyForm/UploadPolicyDropzone.tsx +++ b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Policies/PolicyForm/UploadPolicyDropzone.tsx @@ -35,10 +35,11 @@ import clsx from 'clsx'; import Icon from '@mui/material/Icon'; import { HelpOutline } from '@mui/icons-material'; import { green, red } from '@mui/material/colors'; - +import APIMAlert from 'AppComponents/Shared/Alert'; const PREFIX = 'UploadPolicyDropzone'; + const classes = { dropZoneWrapper: `${PREFIX}-dropZoneWrapper`, acceptDrop: `${PREFIX}-acceptDrop`, @@ -102,10 +103,19 @@ const UploadPolicyDropzone: FC = ({ policyDefinitionFile, setPolicyDefinitionFile, }) => { - + const intl = useIntl(); const handleDrop = (policyDefinition: any) => { - setPolicyDefinitionFile(policyDefinition); + if (policyDefinition && policyDefinition[0] && + (policyDefinition[0].name.endsWith('.j2') || + policyDefinition[0].name.endsWith('.xml'))) { + setPolicyDefinitionFile(policyDefinition); + return; + } + APIMAlert.error(intl.formatMessage({ + id: 'Uploading.Policies.Error', + defaultMessage: 'Incompatible file type', + })); }; const intl = useIntl(); const renderPolicyFileDropzone = () => {