Add post header inputs

pull/10616/head
deniz kusefoglu 2017-12-05 15:23:32 -08:00
parent 50b7086f6f
commit 23c9f8c22d
3 changed files with 38 additions and 4 deletions

View File

@ -11,6 +11,7 @@ const HandlerInput = ({
disabled = false,
fieldColumns = 'col-md-6',
parseToArray = false,
headerIndex = 0,
}) => {
const formGroupClass = `form-group ${fieldColumns}`
return (
@ -28,7 +29,8 @@ const HandlerInput = ({
onChange={handleModifyHandler(
selectedHandler,
fieldName,
parseToArray
parseToArray,
headerIndex
)}
value={
parseToArray

View File

@ -86,11 +86,29 @@ class RuleHandlers extends Component {
ruleActions.updateAlertNodes(rule.id, handlersOnThisAlert)
}
handleModifyHandler = (selectedHandler, fieldName, parseToArray) => e => {
handleModifyHandler = (
selectedHandler,
fieldName,
parseToArray,
headerIndex
) => e => {
const {handlersOnThisAlert} = this.state
let modifiedEP
if (e.target.type === 'checkbox') {
if (fieldName === 'headerKey') {
const currentHeader = selectedHandler.headers || [[]]
currentHeader[headerIndex][0] = e.target.value // only works for headerIndex= 0 atm. would need to initialize if headerindex is larger.
modifiedEP = {
...selectedHandler,
headers: [...currentHeader],
}
} else if (fieldName === 'headerValue') {
const currentHeader = selectedHandler.headers || [[]]
currentHeader[headerIndex][1] = e.target.value
modifiedEP = {
...selectedHandler,
headers: [...currentHeader],
}
} else if (e.target.type === 'checkbox') {
modifiedEP = {
...selectedHandler,
[fieldName]: !selectedHandler[fieldName],

View File

@ -15,6 +15,20 @@ const HttpHandler = ({selectedHandler, handleModifyHandler}) => {
placeholder="ex: http://example.com/api/alert"
fieldColumns="col-md-12"
/>
<HandlerInput
selectedHandler={selectedHandler}
handleModifyHandler={handleModifyHandler}
fieldName="headerKey"
fieldDisplay="Header Key"
placeholder=""
/>
<HandlerInput
selectedHandler={selectedHandler}
handleModifyHandler={handleModifyHandler}
fieldName="headerValue"
fieldDisplay="Header Value"
placeholder=""
/>
</div>
</div>
</div>