File size: 1,260 Bytes
246d201 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import React from "react";
import { useTranslation } from "react-i18next";
import SecurityInvariant from "./invariant/invariant";
import { I18nKey } from "#/i18n/declaration";
import { BaseModal } from "../base-modal/base-modal";
interface SecurityProps {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
securityAnalyzer: string;
}
enum SecurityAnalyzerOption {
INVARIANT = "invariant",
}
const SecurityAnalyzers: Record<SecurityAnalyzerOption, React.ElementType> = {
[SecurityAnalyzerOption.INVARIANT]: SecurityInvariant,
};
function Security({ isOpen, onOpenChange, securityAnalyzer }: SecurityProps) {
const { t } = useTranslation();
const AnalyzerComponent =
securityAnalyzer &&
SecurityAnalyzers[securityAnalyzer as SecurityAnalyzerOption]
? SecurityAnalyzers[securityAnalyzer as SecurityAnalyzerOption]
: () => <div>{t(I18nKey.SECURITY$UNKNOWN_ANALYZER_LABEL)}</div>;
return (
<BaseModal
isOpen={isOpen && !!securityAnalyzer}
contentClassName="max-w-[80%] h-[80%]"
bodyClassName="px-0 py-0 max-h-[100%]"
onOpenChange={onOpenChange}
title=""
>
<AnalyzerComponent />
</BaseModal>
);
}
export default Security;
|