import { saveCollectionSecurityConfig } from 'providers/ReduxStore/slices/collections/actions'; import { useDispatch } from 'react-redux'; import toast from 'react-hot-toast'; import { useState } from 'react'; import Portal from 'components/Portal'; import Modal from 'components/Modal'; import StyledWrapper from './StyledWrapper'; const JsSandboxModeModal = ({ collection, onClose }) => { const dispatch = useDispatch(); const [jsSandboxMode, setJsSandboxMode] = useState(collection?.securityConfig?.jsSandboxMode || 'safe'); const handleChange = (e) => { setJsSandboxMode(e.target.value); }; const handleSave = () => { dispatch( saveCollectionSecurityConfig(collection?.uid, { jsSandboxMode: jsSandboxMode }) ) .then(() => { toast.success('Sandbox mode updated successfully'); onClose(); }) .catch((err) => console.log(err) && toast.error('Failed to update sandbox mode')); }; return (
The collection might include JavaScript code in Variables, Scripts, Tests, and Assertions.
Please choose the security level for the JavaScript code execution.

JavaScript code is executed in a secure sandbox and cannot excess your filesystem or execute system commands.

JavaScript code has access to the filesystem, can execute system commands and access sensitive information.

* SAFE mode has been introduced v1.25 onwards and is in beta. Please report any issues on github.
); }; export default JsSandboxModeModal;