Skip to content

Commit

Permalink
Merge pull request #634 from BLasan/validate-policy-file-type
Browse files Browse the repository at this point in the history
Add: Validation for Policy Upload
  • Loading branch information
BLasan authored Dec 9, 2024
2 parents 5967bf8 + 60ef32d commit e09cac4
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -102,10 +103,19 @@ const UploadPolicyDropzone: FC<UploadPolicyDropzoneProps> = ({
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 = () => {
Expand Down

0 comments on commit e09cac4

Please sign in to comment.