-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
184 additions
and
10 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/StyledWrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import styled from 'styled-components'; | ||
|
||
const StyledWrapper = styled.div` | ||
.settings-label { | ||
width: 80px; | ||
} | ||
.textbox { | ||
border: 1px solid #ccc; | ||
padding: 0.15rem 0.45rem; | ||
box-shadow: none; | ||
border-radius: 0px; | ||
outline: none; | ||
box-shadow: none; | ||
transition: border-color ease-in-out 0.1s; | ||
border-radius: 3px; | ||
background-color: ${(props) => props.theme.modal.input.bg}; | ||
border: 1px solid ${(props) => props.theme.modal.input.border}; | ||
&:focus { | ||
border: solid 1px ${(props) => props.theme.modal.input.focusBorder} !important; | ||
outline: none !important; | ||
} | ||
} | ||
`; | ||
|
||
export default StyledWrapper; |
100 changes: 100 additions & 0 deletions
100
packages/bruno-app/src/components/CollectionSettings/ClientCertSettings/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React, { useEffect } from 'react'; | ||
import { useFormik } from 'formik'; | ||
import * as Yup from 'yup'; | ||
|
||
import StyledWrapper from './StyledWrapper'; | ||
|
||
const ClientCertSettings = ({ clientCertConfig, onUpdate }) => { | ||
const formik = useFormik({ | ||
initialValues: { | ||
enabled: clientCertConfig.enabled || false, | ||
domain: clientCertConfig.domain || '', | ||
cert: clientCertConfig.cert || '', | ||
key: clientCertConfig.key || '', | ||
passphrase: clientCertConfig.port || '' | ||
}, | ||
validationSchema: Yup.object({ | ||
enabled: Yup.boolean(), | ||
domain: Yup.string(), | ||
cert: Yup.string(), | ||
key: Yup.string(), | ||
passphrase: Yup.string() | ||
}), | ||
onSubmit: (values) => { | ||
onUpdate(values); | ||
} | ||
}); | ||
|
||
useEffect(() => { | ||
formik.setValues({ | ||
enabled: clientCertConfig.enabled || false, | ||
domain: clientCertConfig.domain || '', | ||
cert: clientCertConfig.cert || '', | ||
key: clientCertConfig.key || '', | ||
passphrase: clientCertConfig.port || '' | ||
}); | ||
}, [clientCertConfig]); | ||
|
||
const getFile = (e) => { | ||
formik.values[e.name] = e.files[0].path; | ||
}; | ||
|
||
return ( | ||
<StyledWrapper> | ||
<form className="bruno-form" onSubmit={formik.handleSubmit}> | ||
<div className="mb-3 flex items-center"> | ||
<label className="settings-label" htmlFor="enabled"> | ||
Enabled | ||
</label> | ||
<input type="checkbox" name="enabled" checked={formik.values.enabled} onChange={formik.handleChange} /> | ||
</div> | ||
<div className="mb-3 flex items-center"> | ||
<label className="settings-label" htmlFor="domain"> | ||
Domain | ||
</label> | ||
<input | ||
id="domain" | ||
type="text" | ||
name="domain" | ||
placeholder="*.example.org" | ||
className="block textbox" | ||
onChange={formik.handleChange} | ||
value={formik.values.domain || ''} | ||
/> | ||
</div> | ||
<div className="mb-3 flex items-center"> | ||
<label className="settings-label" htmlFor="cert"> | ||
Cert file | ||
</label> | ||
<input id="cert" type="file" name="cert" className="block" onChange={(e) => getFile(e.target)} /> | ||
</div> | ||
<div className="mb-3 flex items-center"> | ||
<label className="settings-label" htmlFor="key"> | ||
Key file | ||
</label> | ||
<input id="key" type="file" name="key" className="block" onChange={(e) => getFile(e.target)} /> | ||
</div> | ||
<div className="mb-3 flex items-center"> | ||
<label className="settings-label" htmlFor="passphrase"> | ||
Passphrase | ||
</label> | ||
<input | ||
id="passphrase" | ||
type="text" | ||
name="passphrase" | ||
className="block textbox" | ||
onChange={formik.handleChange} | ||
value={formik.values.passphrase || ''} | ||
/> | ||
</div> | ||
<div className="mt-6"> | ||
<button type="submit" className="submit btn btn-sm btn-secondary"> | ||
Save | ||
</button> | ||
</div> | ||
</form> | ||
</StyledWrapper> | ||
); | ||
}; | ||
|
||
export default ClientCertSettings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters