Add post header inputs
parent
50b7086f6f
commit
23c9f8c22d
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue