import React from 'react'; import SensitiveFieldWarning from 'components/SensitiveFieldWarning'; import { useDetectSensitiveField } from 'hooks/useDetectSensitiveField'; import get from 'lodash/get'; import { useTheme } from 'providers/Theme'; import { useDispatch } from 'react-redux'; import SingleLineEditor from 'components/SingleLineEditor'; import { updateCollectionAuth } from 'providers/ReduxStore/slices/collections'; import { saveCollectionSettings } from 'providers/ReduxStore/slices/collections/actions'; import StyledWrapper from './StyledWrapper'; const WsseAuth = ({ collection }) => { const dispatch = useDispatch(); const { storedTheme } = useTheme(); const wsseAuth = collection.draft?.root ? get(collection, 'draft.root.request.auth.wsse', {}) : get(collection, 'root.request.auth.wsse', {}); const { isSensitive } = useDetectSensitiveField(collection); const { showWarning, warningMessage } = isSensitive(wsseAuth?.password); const handleSave = () => dispatch(saveCollectionSettings(collection.uid)); const handleUserChange = (username) => { dispatch( updateCollectionAuth({ mode: 'wsse', collectionUid: collection.uid, content: { username: username || '', password: wsseAuth.password || '' } }) ); }; const handlePasswordChange = (password) => { dispatch( updateCollectionAuth({ mode: 'wsse', collectionUid: collection.uid, content: { username: wsseAuth.username || '', password: password || '' } }) ); }; return (
handleUserChange(val)} collection={collection} isCompact />
handlePasswordChange(val)} collection={collection} isSecret={true} isCompact /> {showWarning && }
); }; export default WsseAuth;