Change var alertType to alertNodeName for accuracy
parent
200b24788b
commit
fcd88a297d
|
@ -114,11 +114,11 @@ export function updateDetails(ruleID, details) {
|
|||
}
|
||||
}
|
||||
|
||||
export const updateAlertProperty = (ruleID, alertType, alertProperty) => ({
|
||||
export const updateAlertProperty = (ruleID, alertNodeName, alertProperty) => ({
|
||||
type: 'UPDATE_RULE_ALERT_PROPERTY',
|
||||
payload: {
|
||||
ruleID,
|
||||
alertType,
|
||||
alertNodeName,
|
||||
alertProperty,
|
||||
},
|
||||
})
|
||||
|
@ -133,12 +133,12 @@ export function updateAlerts(ruleID, alerts) {
|
|||
}
|
||||
}
|
||||
|
||||
export function updateAlertNodes(ruleID, alertType, alertNodesText) {
|
||||
export function updateAlertNodes(ruleID, alertNodeName, alertNodesText) {
|
||||
return {
|
||||
type: 'UPDATE_RULE_ALERT_NODES',
|
||||
payload: {
|
||||
ruleID,
|
||||
alertType,
|
||||
alertNodeName,
|
||||
alertNodesText,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class RuleMessage extends Component {
|
|||
super(props)
|
||||
|
||||
this.state = {
|
||||
selectedAlertType: null,
|
||||
selectedAlertNodeName: null,
|
||||
}
|
||||
|
||||
this.handleChangeMessage = ::this.handleChangeMessage
|
||||
|
@ -28,7 +28,7 @@ class RuleMessage extends Component {
|
|||
const {actions} = this.props
|
||||
actions.updateAlerts(item.ruleID, [item.text])
|
||||
actions.updateAlertNodes(item.ruleID, item.text, '')
|
||||
this.setState({selectedAlertType: item.text})
|
||||
this.setState({selectedAlertNodeName: item.text})
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -44,7 +44,7 @@ class RuleMessage extends Component {
|
|||
}),
|
||||
]
|
||||
|
||||
const selectedAlertType = rule.alerts[0] || alerts[0].text
|
||||
const selectedAlertNodeName = rule.alerts[0] || alerts[0].text
|
||||
|
||||
return (
|
||||
<div className="rule-section">
|
||||
|
@ -62,7 +62,7 @@ class RuleMessage extends Component {
|
|||
<li
|
||||
key={alert.text}
|
||||
className={classnames({
|
||||
active: alert.text === selectedAlertType,
|
||||
active: alert.text === selectedAlertNodeName,
|
||||
})}
|
||||
onClick={() => this.handleChooseAlert(alert)}
|
||||
>
|
||||
|
@ -73,7 +73,7 @@ class RuleMessage extends Component {
|
|||
</div>
|
||||
<RuleMessageOptions
|
||||
rule={rule}
|
||||
alertType={selectedAlertType}
|
||||
alertNodeName={selectedAlertNodeName}
|
||||
updateAlertNodes={actions.updateAlertNodes}
|
||||
updateDetails={actions.updateDetails}
|
||||
updateAlertProperty={actions.updateAlertProperty}
|
||||
|
|
|
@ -27,12 +27,12 @@ class RuleMessageOptions extends Component {
|
|||
render() {
|
||||
const {
|
||||
rule,
|
||||
alertType,
|
||||
alertNodeName,
|
||||
updateAlertNodes,
|
||||
updateDetails,
|
||||
updateAlertProperty,
|
||||
} = this.props
|
||||
const {args, details, properties} = RULE_ALERT_OPTIONS[alertType]
|
||||
const {args, details, properties} = RULE_ALERT_OPTIONS[alertNodeName]
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -48,8 +48,8 @@ class RuleMessageOptions extends Component {
|
|||
type="text"
|
||||
placeholder={args.placeholder}
|
||||
onChange={e =>
|
||||
updateAlertNodes(rule.id, alertType, e.target.value)}
|
||||
value={ALERT_NODES_ACCESSORS[alertType](rule)}
|
||||
updateAlertNodes(rule.id, alertNodeName, e.target.value)}
|
||||
value={ALERT_NODES_ACCESSORS[alertNodeName](rule)}
|
||||
autoComplete="off"
|
||||
spellCheck="false"
|
||||
/>
|
||||
|
@ -69,7 +69,7 @@ class RuleMessageOptions extends Component {
|
|||
type="text"
|
||||
placeholder={placeholder}
|
||||
onChange={e =>
|
||||
updateAlertProperty(rule.id, alertType, {
|
||||
updateAlertProperty(rule.id, alertNodeName, {
|
||||
name: propertyName,
|
||||
args: [e.target.value],
|
||||
})}
|
||||
|
@ -105,7 +105,7 @@ const {func, shape, string} = PropTypes
|
|||
|
||||
RuleMessageOptions.propTypes = {
|
||||
rule: shape({}).isRequired,
|
||||
alertType: string,
|
||||
alertNodeName: string,
|
||||
updateAlertNodes: func.isRequired,
|
||||
updateDetails: func.isRequired,
|
||||
updateAlertProperty: func.isRequired,
|
||||
|
|
|
@ -88,17 +88,17 @@ export default function rules(state = {}, action) {
|
|||
// type, adding other alert nodes to a single rule, and updating an alert node's
|
||||
// properties vs args vs details vs message.
|
||||
case 'UPDATE_RULE_ALERT_NODES': {
|
||||
const {ruleID, alertType, alertNodesText} = action.payload
|
||||
const {ruleID, alertNodeName, alertNodesText} = action.payload
|
||||
|
||||
let alertNodesByType
|
||||
|
||||
switch (alertType) {
|
||||
switch (alertNodeName) {
|
||||
case 'http':
|
||||
case 'tcp':
|
||||
case 'log':
|
||||
alertNodesByType = [
|
||||
{
|
||||
name: alertType,
|
||||
name: alertNodeName,
|
||||
args: [alertNodesText],
|
||||
properties: [],
|
||||
},
|
||||
|
@ -108,7 +108,7 @@ export default function rules(state = {}, action) {
|
|||
case 'smtp':
|
||||
alertNodesByType = [
|
||||
{
|
||||
name: alertType,
|
||||
name: alertNodeName,
|
||||
args: alertNodesText.split(' '),
|
||||
properties: [],
|
||||
},
|
||||
|
@ -117,7 +117,7 @@ export default function rules(state = {}, action) {
|
|||
case 'slack':
|
||||
alertNodesByType = [
|
||||
{
|
||||
name: alertType,
|
||||
name: alertNodeName,
|
||||
properties: [
|
||||
{
|
||||
name: 'channel',
|
||||
|
@ -130,7 +130,7 @@ export default function rules(state = {}, action) {
|
|||
case 'alerta':
|
||||
alertNodesByType = [
|
||||
{
|
||||
name: alertType,
|
||||
name: alertNodeName,
|
||||
args: [],
|
||||
properties: parseAlerta(alertNodesText),
|
||||
},
|
||||
|
@ -140,7 +140,7 @@ export default function rules(state = {}, action) {
|
|||
default:
|
||||
alertNodesByType = [
|
||||
{
|
||||
name: alertType,
|
||||
name: alertNodeName,
|
||||
args: [],
|
||||
properties: [],
|
||||
},
|
||||
|
@ -155,10 +155,10 @@ export default function rules(state = {}, action) {
|
|||
}
|
||||
|
||||
case 'UPDATE_RULE_ALERT_PROPERTY': {
|
||||
const {ruleID, alertType, alertProperty} = action.payload
|
||||
const {ruleID, alertNodeName, alertProperty} = action.payload
|
||||
|
||||
const newAlertNodes = state[ruleID].alertNodes.map(alertNode => {
|
||||
if (alertNode.name !== alertType) {
|
||||
if (alertNode.name !== alertNodeName) {
|
||||
return alertNode
|
||||
}
|
||||
let matched = false
|
||||
|
|
Loading…
Reference in New Issue