Merge pull request #3468 from influxdata/bugfix/handle-no-selected-rule
Fix NewRuleHandler Bugpull/10616/head
commit
4a31eac5e5
|
@ -117,9 +117,9 @@ class RuleHandlers extends PureComponent<Props, State> {
|
||||||
? 'rule-section--row rule-section--row-first rule-section--border-bottom'
|
? 'rule-section--row rule-section--row-first rule-section--border-bottom'
|
||||||
: 'rule-section--row rule-section--row-first rule-section--row-last'
|
: 'rule-section--row rule-section--row-first rule-section--row-last'
|
||||||
|
|
||||||
const selectedHandlerWithText: HandlerWithText = this.mapWithNicknames([
|
const selectedHandlerWithText: HandlerWithText = this.addNicknameText(
|
||||||
selectedHandler,
|
selectedHandler
|
||||||
])[0]
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rule-section">
|
<div className="rule-section">
|
||||||
|
@ -261,7 +261,7 @@ class RuleHandlers extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getNickname = (handler: Handler): string => {
|
private getNickname = (handler: Handler): string => {
|
||||||
const configType: AlertTypes = handler.type
|
const configType: AlertTypes = _.get(handler, 'type')
|
||||||
if (configType === 'slack') {
|
if (configType === 'slack') {
|
||||||
const workspace: string = _.get<Handler, string>(handler, 'workspace')
|
const workspace: string = _.get<Handler, string>(handler, 'workspace')
|
||||||
|
|
||||||
|
@ -275,14 +275,22 @@ class RuleHandlers extends PureComponent<Props, State> {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
private mapWithNicknames = (handlers: Handler[]): HandlerWithText[] => {
|
private addNicknameText = (handler: Handler): HandlerWithText => {
|
||||||
return _.map(handlers, h => {
|
if (handler) {
|
||||||
const nickname: string = this.getNickname(h)
|
const nickname: string = this.getNickname(handler)
|
||||||
if (nickname) {
|
if (nickname) {
|
||||||
return {...h, text: `${h.type} (${nickname})`}
|
return {...handler, text: `${handler.type} (${nickname})`}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {...h, text: h.type}
|
return {...handler, text: handler.type}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private mapWithNicknames = (handlers: Handler[]): HandlerWithText[] => {
|
||||||
|
return _.map(handlers, h => {
|
||||||
|
return this.addNicknameText(h)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue