web-interface.assets.bb8c8232-64.8324d02abbc7ed0c3d2d.js Maven / Gradle / Ivy
(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-64"],{"ZuR+biJv":(k,Q,n)=>{"use strict";n.d(Q,{A:()=>V});var e=n("pmX897Fv"),z=n.n(e),s=n("DjJvgDaP"),O=n.n(s),B=O()(z());B.push([k.id,`.bK_1OgMCpxX5cNvo_KNH {
margin-top: 35px;
}
.r3CTNJIqazOh7HmXypag {
margin-left: 15px;
margin-right: 15px;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-form/EventConditionForm.css"],names:[],mappings:"AAAA;IACI,gBAAgB;AACpB;;AAEA;IACI,iBAAiB;IACjB,kBAAkB;AACtB",sourcesContent:[`:local(.conditionTypesInfo) {
margin-top: 35px;
}
:local(.hr) {
margin-left: 15px;
margin-right: 15px;
}
`],sourceRoot:""}]),B.locals={conditionTypesInfo:"bK_1OgMCpxX5cNvo_KNH",hr:"r3CTNJIqazOh7HmXypag"};const V=B},yUieYTlS:(k,Q,n)=>{"use strict";n.d(Q,{A:()=>V});var e=n("pmX897Fv"),z=n.n(e),s=n("DjJvgDaP"),O=n.n(s),B=O()(z());B.push([k.id,`.ZziANjUKFVuuqMSwLmtB {
width: 150px;
}
.Xylx_0ZpoJHGYL_KE6gZ:not(:last-child)::after {
content: ', ';
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-form/FieldsList.css"],names:[],mappings:"AAAA;IACI,YAAY;AAChB;;AAEA;IACI,aAAa;AACjB",sourcesContent:[`:local(.actions) {
width: 150px;
}
:local(.providerOptions):not(:last-child)::after {
content: ', ';
}
`],sourceRoot:""}]),B.locals={actions:"ZziANjUKFVuuqMSwLmtB",providerOptions:"Xylx_0ZpoJHGYL_KE6gZ"};const V=B},nQKpNrvS:(k,Q,n)=>{"use strict";n.d(Q,{A:()=>V});var e=n("pmX897Fv"),z=n.n(e),s=n("DjJvgDaP"),O=n.n(s),B=O()(z());B.push([k.id,`.NLt8T3UO0KICJTv1bzhC {
float: right;
margin-top: 10px;
}
.cWTw12YX10UuN5KAKoIX {
margin-top: 35px;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-form/NotificationsForm.css"],names:[],mappings:"AAAA;IACI,YAAY;IACZ,gBAAgB;AACpB;;AAEA;IACI,gBAAgB;AACpB",sourcesContent:[`:local(.manageNotifications) {
float: right;
margin-top: 10px;
}
:local(.notificationSettings) {
margin-top: 35px;
}
`],sourceRoot:""}]),B.locals={manageNotifications:"NLt8T3UO0KICJTv1bzhC",notificationSettings:"cWTw12YX10UuN5KAKoIX"};const V=B},"xtK/Ddao":(k,Q,n)=>{"use strict";n.d(Q,{A:()=>bn});var e=n("Z7aTuO5B"),z=n("ii0bleBb"),s=n.n(z),O=n("QL8i6bcz"),B=n("IW7priiX"),V=n.n(B),ge=n("8fnsnG21"),oe=n("UMMlOSMl"),R=n("IOI9nV80"),pe=n("JnTtTRmZ"),ve=n.n(pe),T=n("MdYBRjRJ"),Ce=n("eFxcQyPT"),Ee=n("IA3Ku5lS");const _=(0,Ee.rN)("core.AvailableEventDefinitionTypes",()=>ve().createActions({get:{asyncResult:!0}})),Pe=(0,Ee.Bv)("core.AvailableEventDefinitionTypes",()=>ve().createStore({listenables:[_],sourceUrl:"/events/entity_types",entityTypes:void 0,init(){this.get()},getInitialState(){return this.entityTypes},get(){(0,Ce.Ay)("GET",T.H3(this.sourceUrl)).then(t=>{this.entityTypes=t,this.trigger(this.entityTypes)})}}));var De=n("ibdPvtmL"),le=n("cd5HAK44"),se=n("J7MaobQD"),Re=n("q2j1bVbz"),ye=n("7GNmVOX8"),Le=n("brbjQOmY");const Ne=()=>{const{"session-id":o}=(0,Le.A)();return(0,e.useMemo)(()=>{const t=ye.A.get(o);if(!t)return{hasLocalStorageConfig:!1,configFromLocalStorage:void 0};ye.A.delete(o);const{type:i,query:r,streams:l,search_within_ms:d,group_by:c,agg_function:u,agg_field:f,agg_value:E,loc_query_parameters:p}=t,L=u&&E?{conditions:{expression:{expr:void 0,left:{expr:"number-ref",ref:`${u}-${f}`},right:{expr:"number",value:E}}},series:[{id:`${u}-${f}`,function:u,field:f}],group_by:c||[]}:{};return{hasLocalStorageConfig:!0,configFromLocalStorage:{type:i,query:r!=null?r:"",streams:l!=null?l:[],search_within_ms:d,group_by:c!=null?c:[],query_parameters:p!=null?p:[],...L}}},[o])};var ce=n("8OvTct/Z"),te=n("0t7Ye+61"),y=n("v4GbOr/o"),Be=n("leXY1Rul"),_e=n("WgCNywL/"),W=n.n(_e),de=n("J6y4/h8P"),a=n("rIl5IEuP");const Ke=({action:o,activeStepIndex:t,onCancel:i,onOpenNextPage:r,onOpenPrevPage:l,onSubmit:d,steps:c})=>t===c.length-1?e.createElement(R.E6,{onCancel:i,onSubmit:d,submitButtonText:`${o==="edit"?"Update":"Create"} event definition`}):e.createElement("div",null,e.createElement(a.Button,{bsStyle:"info",onClick:l,disabled:t===0},"Previous"),e.createElement("div",{className:"pull-right"},e.createElement(a.Button,{bsStyle:"info",onClick:r},"Next")));var xe=n("/yh+QgO6"),N=n.n(xe),g=n("Pd5CUaTj"),m=n.n(g),v=n("Dg7SLLbb"),C=n.n(v),S=n("ueJll2OF"),A=n.n(S),P=n("GCWFEkMy"),w=n.n(P),M=n("wrndsiBg"),ne=n("S6FuRS7B"),q=n("9O66OgQd");const nt=m()(oe.A.properties,(o,t)=>({value:t,label:C()(o.name)})),it=({eventDefinition:o,validation:t,onChange:i,canEdit:r})=>{const{pathname:l}=(0,te.A)(),d=(0,ce.A)(),c=E=>{const{name:p}=E.target;i(p,ne.yG(E.target))},u=E=>{var p;d(y.g.EVENTDEFINITION_DETAILS.PRIORITY_CHANGED,{app_pathname:(0,T.i)(l),app_section:"event-definition-details",app_action_value:"priority-select",priority:(p=nt[A()(E)-1])==null?void 0:p.label}),i("priority",A()(E))},f=!r||o.config.type==="system-notifications-v1"||o.config.type==="sigma-v1";return e.createElement(a.Row,null,e.createElement(a.Col,{md:7,lg:6},e.createElement("h2",{className:q.A.title},"Event Details"),e.createElement("fieldset",null,e.createElement(a.Input,{id:"event-definition-title",name:"title",label:"Title",type:"text",bsStyle:t.errors.title?"error":null,help:N()(t,"errors.title[0]","Title for this Event Definition, Events and Alerts created from it."),value:o.title,onChange:c,readOnly:f,required:!0}),e.createElement(a.Input,{id:"event-definition-description",name:"description",label:e.createElement("span",null,"Description ",e.createElement("small",{className:"text-muted"},"(Optional)")),type:"textarea",help:"Longer description for this Event Definition.",value:o.description,onChange:c,readOnly:f,rows:2}),e.createElement("div",{style:{width:"100%"}},e.createElement(a.ControlLabel,null,"Remediation Steps ",e.createElement("small",{className:"text-muted"},"(Optional)")),f?e.createElement(M.G8,{show:!0,withFullView:!0,height:150,value:o.remediation_steps||"No remediation steps given"}):e.createElement(M.nt,{id:"event-definition-remediation-steps",readOnly:f,height:150,value:o.remediation_steps,onChange:E=>c({target:{name:"remediation_steps",value:E}})})),e.createElement(a.FormGroup,{controlId:"event-definition-priority"},e.createElement(a.ControlLabel,null,"Priority"),e.createElement(R.l6,{options:nt,value:w()(o.priority),onChange:u,clearable:!1,disabled:f,required:!0}),e.createElement(a.HelpBlock,null,"Choose the priority for Events created from this Definition.")))))};it.propTypes={eventDefinition:s().object.isRequired,validation:s().object.isRequired,onChange:s().func.isRequired};const Nt=it;var ot=n("4E3oowBb"),Tt=n("xnXzNzZh"),St=n("dFpwyWHg"),Me=n.n(St),It=n("C2ikvoS0"),je=n.n(It),Ft=n("1IntWRSu"),Ue=n.n(Ft),At=n("8nGWeFnd"),Ve=n.n(At),bt=n("TeAcaicX"),Ge=n.n(bt),Ot=n("eE3+5goe"),ze=n.n(Ot),Se=n("ZuR+biJv"),me={};me.styleTagTransform=ze(),me.setAttributes=Ve(),me.insert=Ue().bind(null,"head"),me.domAPI=je(),me.insertStyleElement=Ge();var _n=Me()(Se.A,me);const st=Se.A&&Se.A.locals?Se.A.locals:void 0;var Pt=n("IFFKjdia");const We=({action:o,entityTypes:t,eventDefinition:i,validation:r,currentUser:l,onChange:d,canEdit:c})=>{const{pathname:u}=(0,te.A)(),f=(0,ce.A)(),E=h=>h===void 0?{}:O.d.exports("eventDefinitionTypes").find(F=>F.type===h)||{},p=()=>O.d.exports("eventDefinitionTypes").sort((h,F)=>{const Y=h.sortOrder,J=F.sortOrder;if(Y!==void 0||J!==void 0){const b=W()(Y,Number.MAX_SAFE_INTEGER)-W()(J,Number.MAX_SAFE_INTEGER);if(b!==0)return b}return(0,ot.j)(h.displayName,F.displayName)}),L=()=>p().map(h=>({label:h.displayName,value:h.type})),re=h=>{f(y.g.EVENTDEFINITION_CONDITION.TYPE_SELECTED,{app_pathname:(0,T.i)(u),app_section:"event-definition-condition",app_action_value:"type-select",condition_type:h});const F=E(h),Y=(F==null?void 0:F.defaultConfig)||{};d("config",{...Y,type:h})},ie=()=>{const h=p().map(F=>e.createElement(e.Fragment,{key:F.type},e.createElement("dt",null,F.displayName),e.createElement("dd",null,F.description||"No description available.")));return e.createElement("dl",null,h)},G=()=>!L().some(h=>i.config.type===h.value)&&o==="edit",ee=()=>i._scope==="ILLUMINATE"&&o==="edit",U=()=>i.config.type==="sigma-v1"&&o==="edit",I=E(i.config.type),D=i.config.type===Pt.eD,X=c&&!D,Z=I!=null&&I.formComponent?e.createElement(I.formComponent,{action:o,entityTypes:t,currentUser:l,validation:r,eventDefinition:i,onChange:d,key:i.id}):null;return e.createElement(a.Row,null,e.createElement(a.Col,{md:7,lg:6},e.createElement("h2",{className:q.A.title},"Event Condition"),X?e.createElement(e.Fragment,null,e.createElement("p",null,"Configure how Graylog should create Events of this kind. You can later use those Events as input on other Conditions, making it possible to build powerful Conditions based on others."),e.createElement(a.FormGroup,{validationState:r.errors.config?"error":null},e.createElement(a.ControlLabel,{htmlFor:"event-condition-type-select"},"Condition Type"),e.createElement(R.l6,{placeholder:"Select a Condition Type",inputId:"event-condition-type-select",options:L(),value:i.config.type,onChange:re,clearable:!1,disabled:G()||ee()||U(),required:!0}),e.createElement(a.HelpBlock,null,N()(r,"errors.config[0]","Choose the type of Condition for this Event.")))):e.createElement("p",null,"The conditions of this event definition type cannot be edited.")),X&&!G()&&e.createElement(e.Fragment,null,e.createElement(a.Col,{md:5,lg:5,lgOffset:1},e.createElement(Tt.g,{className:st.conditionTypesInfo,title:"Available Conditions"},ie())),e.createElement(a.Clearfix,null),Z&&e.createElement(e.Fragment,null,e.createElement("hr",{className:st.hr}),e.createElement(a.Col,{md:12},Z))))};We.defaultProps={action:"create",entityTypes:void 0},We.propTypes={action:s().oneOf(["create","edit"]),entityTypes:s().object,eventDefinition:s().object.isRequired,currentUser:s().object.isRequired,validation:s().object.isRequired,onChange:s().func.isRequired};const Dt=We;var Rt=n("RjO1iR6D"),at=n.n(Rt);const rt=()=>e.createElement(e.Fragment,null,"Event Keys are Fields used to arrange Events into groups. A group is created for each unique Key, so Graylog will generate as many Events as unique Keys are found. Example:",e.createElement("p",null),e.createElement("b",null,"No Event Keys:")," One Event for each ",e.createElement("em",null,"Login failure")," message.",e.createElement("br",null),e.createElement("b",null,"Event Key ",e.createElement("code",null,"username"),":")," One Event for each username with a ",e.createElement("em",null,"Login failure")," message.");var Lt=n("6tmAsyUP"),Bt=n("P5NcJT2c"),_t=n.n(Bt),Ie=n("BqxuktKK"),Fe=n("HCsT5Gmk"),Kt=Object.defineProperty,xt=(o,t,i)=>t in o?Kt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,H=(o,t,i)=>(xt(o,typeof t!="symbol"?t+"":t,i),i);const Mt=["fieldName","config.providers[0].type"],He=o=>o===void 0?{}:O.d.exports("fieldValueProviders").find(t=>t.type===o)||{},Xe=(o,t)=>N()(o,"providers[0].type",t),jt=()=>O.d.exports("fieldValueProviders").map(o=>({label:o.displayName,value:o.type}));class Ye extends e.Component{constructor(t){super(t),H(this,"validate",()=>{const{isKey:r,keyPosition:l,config:d}=this.state,c={},u=Xe(d);let f=[];u&&(f=He(u).requiredFields),Mt.forEach(p=>{N()(this.state,p)||(c[p]="Field cannot be empty.")}),r&&(!_t()(l)||Number(l)<1)&&(c.key_position="Field must be a positive number."),f.forEach(p=>{N()(d,`providers[0].${p}`)||(c[p]="Field cannot be empty.")});const E=Object.keys(c).length;return E>0&&this.setState({validation:{errors:c}}),E===0}),H(this,"handleSubmit",()=>{if(this.props.sendTelemetry(y.g.EVENTDEFINITION_FIELDS.DONE_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"done-button"}),this.validate()){const{fieldName:r,onChange:l}=this.props,{fieldName:d,config:c,isKey:u,keyPosition:f}=this.state;l(r,d,c,u,f-1)}}),H(this,"handleCancel",()=>{this.props.sendTelemetry(y.g.EVENTDEFINITION_FIELDS.CANCEL_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"cancel-button"}),this.props.onCancel()}),H(this,"handleFieldNameChange",r=>{const l=ne.yG(r.target);this.setState({fieldName:l})}),H(this,"handleConfigChange",r=>{this.setState({config:r})}),H(this,"handleProviderTypeChange",r=>{this.props.sendTelemetry(r==="lookup-v1"?y.g.EVENTDEFINITION_FIELDS.SET_VALUE_FROM_LOOKUP_TABLE_SELECTED:y.g.EVENTDEFINITION_FIELDS.SET_VALUE_FROM_TEMPLATE_SELECTED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"set-value-from-select",value_source:r});const{config:l}=this.state,c=He(r).defaultConfig||{},u={...l,providers:[{...c,type:r}]};this.handleConfigChange(u)}),H(this,"handleKeySortChange",r=>{const l=r.target.value===""?"":ne.yG(r.target);this.setState({keyPosition:l})}),H(this,"toggleKey",r=>{const l=ne.yG(r.target);this.props.sendTelemetry(y.g.EVENTDEFINITION_FIELDS.AS_EVENT_KEY_TOGGLED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"event-key-checkbox",event_key_checked:l}),this.setState({isKey:l})}),H(this,"renderFieldValueProviderForm",()=>{const{fieldName:r,config:l,validation:d}=this.state,{currentUser:c}=this.props,u=Xe(l);if(!u)return null;const f=He(u);return f.formComponent?e.createElement(f.formComponent,{fieldName:r,config:l,onChange:this.handleConfigChange,validation:d,currentUser:c}):e.createElement("div",null,"Selected provider is not available.")});const i=t.keys.indexOf(t.fieldName);this.state={fieldName:t.fieldName,config:{data_type:"string",providers:[],...t.config},isKey:i>=0,keyPosition:i>=0?i+1:t.keys.length+1,validation:{errors:{}}}}render(){const{fieldName:t}=this.props,{fieldName:i,isKey:r,keyPosition:l,config:d,validation:c}=this.state;return e.createElement(a.Row,null,e.createElement(a.Col,{md:7,lg:6},e.createElement("h2",{className:q.A.title},t?`Custom Field "${i}"`:"New Custom Field"),e.createElement(a.Input,{id:"field-name",name:"name",label:"Name",type:"text",value:i,onChange:this.handleFieldNameChange,bsStyle:c.errors.fieldName?"error":null,help:c.errors.fieldName||"Name for this Field.",required:!0}),e.createElement(a.FormGroup,{validationState:c.errors.key_position?"error":null},e.createElement(a.ControlLabel,null,"Use Field as Event Key\u2003",e.createElement(R.Zf,{title:"More about Event Keys",trigger:["click","hover"],placement:"right"},e.createElement(rt,null))),e.createElement(a.InputGroup,null,e.createElement(a.InputGroup.Addon,null,e.createElement("input",{id:"is-key",name:"is-key",type:"checkbox",onChange:this.toggleKey,checked:r})),e.createElement(a.FormControl,{id:"field-key",name:"key",type:"number",value:l,onChange:this.handleKeySortChange,disabled:!r})),e.createElement(a.HelpBlock,null,c.errors.key_position||"Indicates if this Field should be a Key and its order.")),e.createElement(a.FormGroup,null,e.createElement(a.ControlLabel,null,"Field Data Type"),e.createElement(a.FormControl.Static,null,"String")),e.createElement(a.FormGroup,{controlId:"event-field-provider",validationState:c.errors["config.providers[0].type"]?"error":null},e.createElement(a.ControlLabel,null,"Set Value From"),e.createElement(R.l6,{name:"event-field-provider",ignoreAccents:!1,placeholder:"Select Value Source",onChange:this.handleProviderTypeChange,options:jt(),value:Xe(d,""),matchProp:"label",required:!0}),e.createElement(a.HelpBlock,null,c.errors["config.providers[0].type"]||"Select a source for the value of this Field."))),e.createElement(a.Col,{md:12},this.renderFieldValueProviderForm()),e.createElement(a.Col,{md:12},e.createElement(a.ButtonToolbar,null,e.createElement(a.Button,{bsStyle:"success",onClick:this.handleSubmit},"Add custom field"),e.createElement(a.Button,{onClick:this.handleCancel},"Cancel"))))}}H(Ye,"propTypes",{fieldName:s().string,config:s().object,currentUser:s().object.isRequired,keys:s().array.isRequired,onChange:s().func.isRequired,onCancel:s().func.isRequired,sendTelemetry:s().func.isRequired,location:s().object.isRequired}),H(Ye,"defaultProps",{fieldName:"",config:{}});const Ut=(0,Fe.A)((0,Ie.A)(Ye));var Ae=n("yUieYTlS"),ue={};ue.styleTagTransform=ze(),ue.setAttributes=Ve(),ue.insert=Ue().bind(null,"head"),ue.domAPI=je(),ue.insertStyleElement=Ge();var xn=Me()(Ae.A,ue);const lt=Ae.A&&Ae.A.locals?Ae.A.locals:void 0;var Vt=Object.defineProperty,Gt=(o,t,i)=>t in o?Vt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,he=(o,t,i)=>(Gt(o,typeof t!="symbol"?t+"":t,i),i);const zt=["Field Name","Is Key?","Value Source","Data Type","Configuration","Actions"],Wt=o=>o===void 0?{}:O.d.exports("fieldValueProviders").find(t=>t.type===o)||{},Ht=o=>{const t=Object.keys(o).filter(i=>i!=="type");return e.createElement("p",null,t.map(i=>e.createElement("span",{key:i,className:lt.providerOptions},i,": ",e.createElement("em",null,JSON.stringify(o[i])))))};class ct extends e.Component{constructor(){super(...arguments),he(this,"handleAddFieldClick",()=>{this.props.sendTelemetry(y.g.EVENTDEFINITION_FIELDS.ADD_CUSTOM_FIELD_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"add-custom-field-button"});const{onAddFieldClick:t}=this.props;t()}),he(this,"handleEditClick",t=>()=>{const{onEditFieldClick:i}=this.props;i(t)}),he(this,"handleRemoveClick",t=>()=>{const{onRemoveFieldClick:i}=this.props;i(t)}),he(this,"fieldFormatter",t=>{const{fields:i,keys:r}=this.props,l=i[t],d=r.indexOf(t),c=Wt(l.providers[0].type);return e.createElement("tr",{key:t},e.createElement("td",null,t),e.createElement("td",null,d<0?"No":"Yes"),e.createElement("td",null,c.displayName||l.providers[0].type),e.createElement("td",null,l.data_type),e.createElement("td",null,Ht(l.providers[0])),e.createElement("td",{className:lt.actions},e.createElement(a.ButtonToolbar,null,e.createElement(a.Button,{bsStyle:"primary",bsSize:"xsmall",onClick:this.handleRemoveClick(t)},"Remove Field"),e.createElement(a.Button,{bsStyle:"info",bsSize:"xsmall",onClick:this.handleEditClick(t)},"Edit"))))})}render(){const{fields:t}=this.props,i=Object.keys(t).sort(ot.j),r=e.createElement(a.Button,{bsStyle:"success",onClick:this.handleAddFieldClick},"Add custom field");return i.length===0?e.createElement(e.Fragment,null,e.createElement("p",null,"This Event does not have any custom Fields yet."),r):e.createElement(e.Fragment,null,e.createElement(R.bQ,{id:"event-definition-fields",className:"table-striped table-hover",headers:zt,rows:i,dataRowFormatter:this.fieldFormatter,filterKeys:[]}),r)}}he(ct,"propTypes",{fields:s().object.isRequired,keys:s().array.isRequired,onAddFieldClick:s().func.isRequired,onEditFieldClick:s().func.isRequired,onRemoveFieldClick:s().func.isRequired,sendTelemetry:s().func.isRequired,location:s().object.isRequired});const Xt=(0,Fe.A)((0,Ie.A)(ct)),dt=({currentUser:o,eventDefinition:t,validation:i,onChange:r,canEdit:l})=>{const[d,c]=(0,e.useState)(void 0),[u,f]=(0,e.useState)(!1),E=I=>{const D=at()(t.field_spec,I);r("field_spec",D);const X=Object.keys(D),Z=t.key_spec.filter(h=>X.includes(h));r("key_spec",Z)},p=I=>{c(u?void 0:I),f(!u)},L=(I,D,X,Z,h)=>{const F=I===D?V()(t.field_spec):at()(t.field_spec,I);F[D]=X,r("field_spec",F);const Y=Object.keys(F);let J=t.key_spec.filter(b=>Y.includes(b)&&b!==D);Z&&(J=[...J.slice(0,h),D,...J.slice(h)]),r("key_spec",J),p()},re=t.config.type==="system-notifications-v1",ie=l&&!re;if(u)return e.createElement(Ut,{keys:t.key_spec,fieldName:d,config:d?t.field_spec[d]:void 0,onChange:L,onCancel:p,currentUser:o});const G=N()(i,"errors.field_spec",[]),ee=N()(i,"errors.key_spec",[]),U=[...G,...ee];return e.createElement(a.Row,null,e.createElement(a.Col,{md:12},e.createElement("h2",{className:q.A.title},"Event Fields ",e.createElement("small",null,"(optional)")),ie?e.createElement(e.Fragment,null,e.createElement("p",null,"Include additional information in Events generated from this Event Definition by adding custom Fields. That can help you search Events or having more context when receiving Notifications."),U.length>0&&e.createElement(a.Alert,{bsStyle:"danger",className:q.A.validationSummary,title:"Fields with errors"},e.createElement("p",null,"Please correct the following errors before saving this Event Definition:"),e.createElement("ul",null,U.map(I=>e.createElement("li",{key:I},I)))),Object.keys(t.field_spec).length>0&&e.createElement("dl",null,e.createElement("dt",null,"Keys",e.createElement(Lt.A,{title:"More about Event Keys",trigger:["click","hover"],placement:"right"},e.createElement(rt,null))),e.createElement("dd",null,t.key_spec.length>0?t.key_spec.join(", "):"No Keys configured yet.")),e.createElement(Xt,{fields:t.field_spec,validation:i,keys:t.key_spec,onAddFieldClick:p,onEditFieldClick:p,onRemoveFieldClick:E})):e.createElement("p",null,"The event fields of this event definition type cannot be edited.")))};dt.propTypes={currentUser:s().object.isRequired,eventDefinition:s().object.isRequired,validation:s().object.isRequired,onChange:s().func.isRequired};const Yt=dt;var Jt=n("LLTH+mT+"),Qt=n.n(Jt),Zt=n("ty2gyrHp"),kt=n("d4kzUuQm"),mt=n("yGRmSjYM"),$t=n("42lc8BRs"),wt=Object.defineProperty,qt=(o,t,i)=>t in o?wt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,ae=(o,t,i)=>(qt(o,typeof t!="symbol"?t+"":t,i),i);class Je extends e.Component{constructor(t){super(t),ae(this,"handleNewNotificationSubmit",i=>{this.props.sendTelemetry(y.g.EVENTDEFINITION_NOTIFICATIONS.DONE_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"done-button"});const{onChange:r}=this.props;i.then(l=>r(l.id))}),ae(this,"handleSubmit",()=>{this.props.sendTelemetry(y.g.EVENTDEFINITION_NOTIFICATIONS.DONE_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"done-button"});const{onChange:i}=this.props,{selectedNotification:r}=this.state;i(r)}),ae(this,"handleCancel",()=>{this.props.sendTelemetry(y.g.EVENTDEFINITION_NOTIFICATIONS.CANCEL_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"cancel-button"}),this.props.onCancel()}),ae(this,"handleSelectNotificationChange",i=>{if(i==="create"){this.props.sendTelemetry(y.g.EVENTDEFINITION_NOTIFICATIONS.CREATE_NEW_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"create-new-option"}),this.setState({displayNewNotificationForm:!0});return}this.props.sendTelemetry(y.g.EVENTDEFINITION_NOTIFICATIONS.NOTIFICATION_SELECTED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"existing-notification-option"}),this.setState({selectedNotification:i,displayNewNotificationForm:!1})}),ae(this,"formatNotifications",i=>{const{hasCreationPermissions:r}=this.props,l=i.map(d=>({label:d.title,value:d.id}));return r&&l.unshift({label:"Create New Notification...",value:"create"}),l}),this.state={selectedNotification:void 0,displayNewNotificationForm:!1}}render(){const{notifications:t}=this.props,{displayNewNotificationForm:i,selectedNotification:r}=this.state,l=i?e.createElement(a.Button,{bsStyle:"success",type:"submit",form:"new-notification-form"},"Add notification"):e.createElement(a.Button,{bsStyle:"success",onClick:this.handleSubmit},"Add notification");return e.createElement(a.Row,null,e.createElement(a.Col,{md:7,lg:6},e.createElement("h2",{className:q.A.title},"Add Notification"),e.createElement("fieldset",null,e.createElement(a.FormGroup,{controlId:"notification-select"},e.createElement(a.ControlLabel,null,"Choose Notification"),e.createElement(R.l6,{id:"notification-select",matchProp:"label",placeholder:"Select Notification",onChange:this.handleSelectNotificationChange,options:this.formatNotifications(t),value:r}),e.createElement(a.HelpBlock,null,"Select a Notification to use on Alerts of this kind or create a new Notification that you can later use in other Alerts.")),i&&e.createElement($t.A,{action:"create",formId:"new-notification-form",onSubmit:this.handleNewNotificationSubmit,embedded:!0})),e.createElement(a.ButtonToolbar,null,l,e.createElement(a.Button,{onClick:this.handleCancel},"Cancel"))))}}ae(Je,"propTypes",{notifications:s().array.isRequired,onChange:s().func.isRequired,onCancel:s().func.isRequired,hasCreationPermissions:s().bool,sendTelemetry:s().func.isRequired,location:s().object.isRequired}),ae(Je,"defaultProps",{hasCreationPermissions:!1});const en=(0,Fe.A)((0,Ie.A)(Je));var tn=n("WoBpjwwo"),nn=n.n(tn),on=n("ZoCQyFC1"),ut=n.n(on),sn=n("9oVghaOd"),an=n.n(sn),rn=n("ATOIS62c"),ln=Object.defineProperty,cn=(o,t,i)=>t in o?ln(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,be=(o,t,i)=>(cn(o,typeof t!="symbol"?t+"":t,i),i);const ft=["HOURS","MINUTES","SECONDS"],dn=de.default.div(({theme:o})=>(0,de.css)`
padding-top: ${o.spacings.lg};
`);class pt extends e.Component{constructor(t){super(t),be(this,"propagateChanges",(u,f)=>{const{eventDefinition:E,onSettingsChange:p}=this.props,L=V()(E.notification_settings);L[u]=f,p("notification_settings",L)}),be(this,"handleGracePeriodChange",(u,f,E)=>{const p=E?an().duration(ut()([u,0]),f).asMilliseconds():0;this.propagateChanges("grace_period_ms",p),this.setState({gracePeriodDuration:u,gracePeriodUnit:f})}),be(this,"handleBacklogSizeChange",u=>{const{name:f}=u.target,E=u.target.value===""?"":ne.yG(u.target);this.setState({[nn()(f)]:E}),this.propagateChanges(f,ut()([Number(E),0]))}),be(this,"toggleBacklogSize",()=>{const{isBacklogSizeEnabled:u,backlogSize:f}=this.state;this.setState({isBacklogSizeEnabled:!u}),this.propagateChanges("backlog_size",u?0:f)});const{backlog_size:i,grace_period_ms:r}=t.eventDefinition.notification_settings,l=(0,rn.z)(r,ft),d=t.defaults.default_backlog_size,c=W()(i,d);this.state={gracePeriodDuration:l.duration,gracePeriodUnit:l.unit,isBacklogSizeEnabled:i===null?!1:c>0,backlogSize:c}}render(){const{eventDefinition:t}=this.props,{gracePeriodDuration:i,gracePeriodUnit:r,isBacklogSizeEnabled:l,backlogSize:d}=this.state;return t.notifications.length===0?null:e.createElement(dn,null,e.createElement(a.FormGroup,{controlId:"grace-period"},e.createElement(R.gM,{label:"Grace Period",update:this.handleGracePeriodChange,defaultEnabled:i!==0,value:i,unit:r,units:ft,clearable:!0}),e.createElement("p",null,"Graylog sends Notifications for Alerts every time they occur. Set a Grace Period to control how long Graylog should wait before sending Notifications again. Note that Events with keys will have a Grace Period for each different key value.")),e.createElement(a.FormGroup,null,e.createElement(a.ControlLabel,null,"Message Backlog"),e.createElement(a.InputGroup,null,e.createElement(a.InputGroup.Addon,null,e.createElement("input",{id:"toggle_backlog_size",type:"checkbox",checked:l,onChange:this.toggleBacklogSize})),e.createElement(a.FormControl,{type:"number",id:"backlog_size",name:"backlog_size",onChange:this.handleBacklogSizeChange,value:d,disabled:!l})),e.createElement("p",null,"Number of messages to be included in Notifications.")))}}pt.propTypes={eventDefinition:s().object.isRequired,defaults:s().object.isRequired,onSettingsChange:s().func.isRequired};const mn=pt;var un=Object.defineProperty,fn=(o,t,i)=>t in o?un(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,Qe=(o,t,i)=>(fn(o,typeof t!="symbol"?t+"":t,i),i);const pn=o=>o===void 0?{}:O.d.exports("eventNotificationTypes").find(t=>t.type===o)||{};class Et extends e.Component{constructor(){super(...arguments),Qe(this,"handleRemoveClick",t=>()=>{const{onRemoveNotificationClick:i}=this.props;i(t)}),Qe(this,"notificationFormatter",t=>{if(t.missing)return e.createElement("tr",null,e.createElement("td",{colSpan:2},"Could not find information for Notification ",e.createElement("em",null,t.title)),e.createElement("td",{className:"actions"},e.createElement(a.Button,{bsStyle:"danger",bsSize:"xsmall",onClick:this.handleRemoveClick(t.title)},"Delete")));const i=pn(t.config.type);return e.createElement("tr",{key:t.id},e.createElement("td",null,t.title),e.createElement("td",null,i.displayName||t.config.type),e.createElement("td",{className:"actions"},e.createElement(a.Button,{bsStyle:"danger",bsSize:"xsmall",onClick:this.handleRemoveClick(t.id)},"Delete")))})}render(){const{eventDefinition:t,notifications:i,onAddNotificationClick:r}=this.props,l=t.notifications.map(c=>i.find(u=>u.id===c.notification_id)||{title:c.notification_id,missing:!0}),d=e.createElement(a.Button,{bsStyle:"success",onClick:r},"Add notification");return l.length===0?e.createElement(e.Fragment,null,e.createElement("p",null,"This Event is not configured to trigger any Notifications yet."),d):e.createElement(e.Fragment,null,e.createElement(R.bQ,{id:"event-definition-notifications",className:"table-striped table-hover",headers:["Notification","Type","Actions"],sortByKey:"title",rows:l,dataRowFormatter:this.notificationFormatter,filterKeys:[]}),d)}}Qe(Et,"propTypes",{eventDefinition:s().object.isRequired,notifications:s().array.isRequired,onAddNotificationClick:s().func.isRequired,onRemoveNotificationClick:s().func.isRequired});const En=Et;var Oe=n("nQKpNrvS"),fe={};fe.styleTagTransform=ze(),fe.setAttributes=Ve(),fe.insert=Ue().bind(null,"head"),fe.domAPI=je(),fe.insertStyleElement=Ge();var Mn=Me()(Oe.A,fe);const hn=Oe.A&&Oe.A.locals?Oe.A.locals:void 0;var gn=Object.defineProperty,vn=(o,t,i)=>t in o?gn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,Ze=(o,t,i)=>(vn(o,typeof t!="symbol"?t+"":t,i),i);class ht extends e.Component{constructor(){super(),Ze(this,"toggleAddNotificationForm",()=>{this.props.sendTelemetry(y.g.EVENTDEFINITION_NOTIFICATIONS.ADD_CLICKED,{app_pathname:(0,T.i)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"add-notification-button"});const{showAddNotificationForm:t}=this.state;this.setState({showAddNotificationForm:!t})}),Ze(this,"handleAssignNotification",t=>{const{onChange:i,eventDefinition:r}=this.props,l=V()(r.notifications);l.push({notification_id:t}),i("notifications",l),this.toggleAddNotificationForm()}),Ze(this,"handleRemoveNotification",t=>{const{onChange:i,eventDefinition:r}=this.props,l=r.notifications.find(c=>c.notification_id===t),d=Qt()(r.notifications,l);i("notifications",d)}),this.state={showAddNotificationForm:!1}}render(){const{eventDefinition:t,notifications:i,defaults:r,currentUser:l,onChange:d}=this.props,{showAddNotificationForm:c}=this.state,f=t.notifications.map(E=>E.notification_id).filter(E=>!(0,mt.Nn)(l.permissions,`eventnotifications:read:${E}`));return f.length>0?e.createElement(a.Row,null,e.createElement(a.Col,{md:6,lg:5},e.createElement(a.Alert,{bsStyle:"warning"},"Missing Notifications Permissions for: ",e.createElement("br",null)," ",f.join(", ")))):c?e.createElement(en,{notifications:i,onChange:this.handleAssignNotification,onCancel:this.toggleAddNotificationForm,hasCreationPermissions:(0,mt.Nn)(l.permissions,"eventnotifications:create")}):e.createElement(a.Row,null,e.createElement(a.Col,{md:6,lg:5},e.createElement("span",{className:hn.manageNotifications},e.createElement(Zt.m,{to:kt.Ay.ALERTS.NOTIFICATIONS.LIST,target:"_blank"},e.createElement(a.Button,{bsStyle:"link",bsSize:"small"},"Manage Notifications ",e.createElement(R.In,{name:"open_in_new"})))),e.createElement("h2",{className:q.A.title},"Notifications ",e.createElement("small",null,"(optional)")),e.createElement("p",null,"Is this Event important enough that requires your attention? Make it an Alert by adding Notifications to it."),e.createElement(En,{eventDefinition:t,notifications:i,onAddNotificationClick:this.toggleAddNotificationForm,onRemoveNotificationClick:this.handleRemoveNotification}),e.createElement(mn,{eventDefinition:t,defaults:r,onSettingsChange:d})))}}ht.propTypes={eventDefinition:s().object.isRequired,notifications:s().array.isRequired,defaults:s().object.isRequired,currentUser:s().object.isRequired,onChange:s().func.isRequired,sendTelemetry:s().func.isRequired,location:s().object.isRequired};const Cn=(0,Fe.A)((0,Ie.A)(ht));var yn=n("XirFL5dA");const Nn=de.default.div`
margin-bottom: 10px;
`,j=["event-details","condition","fields","notifications","summary"],Tn=[y.g.EVENTDEFINITION_DETAILS.STEP_CLICKED,y.g.EVENTDEFINITION_CONDITION.STEP_CLICKED,y.g.EVENTDEFINITION_FIELDS.STEP_CLICKED,y.g.EVENTDEFINITION_NOTIFICATIONS.STEP_CLICKED,y.g.EVENTDEFINITION_SUMMARY.STEP_CLICKED],Sn=o=>o===void 0?{displayName:null}:O.d.exports("eventDefinitionTypes").find(t=>t.type===o)||{},ke=({action:o,activeStep:t,canEdit:i,currentUser:r,defaults:l,entityTypes:d,eventDefinition:c,formControls:u,notifications:f,onCancel:E,onChange:p,onChangeStep:L,onSubmit:re,validation:ie})=>{const{pathname:G}=(0,te.A)(),ee=(0,ce.A)(),U=j.indexOf(t),I=b=>{b&&b.preventDefault(),re()},D={key:c.id,action:o,entityTypes:d,eventDefinition:c,onChange:p,validation:ie,currentUser:r},X=e.useMemo(()=>i||c._scope.toUpperCase()==="ILLUMINATE",[i,c._scope]),Z=Sn(c.config.type),h=[{key:j[0],title:"Event Details",component:e.createElement(Nt,{...D,canEdit:i})},{key:j[1],title:W()(Z.displayName,"Condition"),component:e.createElement(Dt,{...D,canEdit:X})},{key:j[2],title:"Fields",component:e.createElement(Yt,{...D,canEdit:i})},{key:j[3],title:"Notifications",component:e.createElement(Cn,{...D,notifications:f,defaults:l})},{key:j[4],title:"Summary",component:e.createElement(yn.A,{eventDefinition:c,currentUser:r,notifications:f,validation:ie})}],F=b=>{ee(Tn[j.indexOf(b)],{app_pathname:(0,T.i)(G),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"event-definition-step",current_step:h[j.indexOf(t)].title}),L(b)},Y=()=>{ee(y.g.EVENTDEFINITION_PREVIOUS_CLICKED,{app_pathname:(0,T.i)(G),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"previous-button",current_step:h[U].title});const b=U>0?j[U-1]:void 0;L(b)},J=()=>{ee(y.g.EVENTDEFINITION_NEXT_CLICKED,{app_pathname:(0,T.i)(G),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"next-button",current_step:h[U].title});const b=j[U+1];L(b)};return e.createElement(a.Row,null,e.createElement(a.Col,{md:12},e.createElement(Nn,null,e.createElement(R.sQ,{steps:h,activeStep:t,onStepChange:F,horizontal:!0,justified:!0,containerClassName:"",hidePreviousNextButtons:!0})),e.createElement(u,{activeStepIndex:U,action:o,onOpenPrevPage:Y,onOpenNextPage:J,steps:h,onSubmit:I,onCancel:E})))};ke.propTypes={action:s().oneOf(["create","edit"]),eventDefinition:s().object.isRequired,currentUser:s().object.isRequired,validation:s().object.isRequired,entityTypes:s().object.isRequired,notifications:s().array.isRequired,defaults:s().object.isRequired,onChange:s().func.isRequired,onCancel:s().func.isRequired,onSubmit:s().func.isRequired},ke.defaultProps={action:"edit",formControls:Ke};const In=ke,Fn=()=>{se.M.listAll()},An=o=>o===void 0?{}:O.d.exports("eventDefinitionTypes").find(t=>t.type===o)||{},$e=({action:o,eventDefinition:t,formControls:i,initialStep:r,onCancel:l,onChangeStep:d,onEventDefinitionChange:c,onSubmit:u})=>{const[f,E]=(0,e.useState)(r),[p,L]=(0,e.useState)(t),[re,ie]=(0,e.useState)({errors:{}}),[G,ee]=(0,e.useState)(void 0),[U,I]=(0,e.useState)(!1),{configFromLocalStorage:D,hasLocalStorageConfig:X}=Ne(),{loadingScopePermissions:Z,scopePermissions:h}=(0,Be.A)(p),F=(0,ge.P)(Pe),Y=(0,ge.P)(se.c),J=(0,Re.A)(),{pathname:b}=(0,te.A)(),we=(0,ce.A)(),On=!F||!Y.all||!G,Pn={default_backlog_size:G==null?void 0:G.events_notification_default_backlog},gt=(0,e.useCallback)(()=>{De.t.listEventsClusterConfig().then(K=>ee(K))},[]),Dn=(0,e.useCallback)((K,x)=>{L(et=>({...et,[K]:x})),c({...p,[K]:x}),I(!0)},[p,c,L,I]);(0,e.useEffect)(()=>{if(gt(),Fn(),X){const K=An(D.type),x=(K==null?void 0:K.defaultConfig)||{};L(et=>{const yt=V()(et);return{...yt,config:{...x,...yt.config,...D}}})}},[D,gt,X]);const vt=()=>{I(!1),u()},qe=K=>{ie(K),E(j[j.length-1])},Ct=K=>{const{body:x}=K.additional;if(K.status===400){if(x&&x.failed){qe(x);return}if(x.type&&x.type==="ApiError"){if(x.message.includes("org.graylog.events.conditions.Expression")||x.message.includes("org.graylog.events.conditions.Expr")||x.message.includes("org.graylog.events.processor.aggregation.AggregationSeries")){qe({errors:{conditions:["Aggregation condition is not valid"]}});return}x.message.includes("embryonic")&&qe({errors:{query_parameters:["Query parameters must be declared"]}})}}},Rn=()=>{I(!1),o==="create"?(we(y.g.EVENTDEFINITION_SUMMARY.CREATE_CLICKED,{app_pathname:(0,T.i)(b),app_section:"new-event-definition",app_action_value:"create-event-definition-button"}),le.a.create(p).then(vt,Ct)):(we(y.g.EVENTDEFINITION_SUMMARY.UPDATE_CLICKED,{app_pathname:(0,T.i)(b),app_section:"edit-event-definition",app_action_value:"update-event-definition-button"}),le.a.update(p.id,p).then(vt,Ct))},Ln=()=>{we(y.g.EVENTDEFINITION_SUMMARY.CANCEL_CLICKED,{app_pathname:(0,T.i)(b),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"cancel-button"}),l()},Bn=K=>{d==null||d(K),E(K)};return On||Z?e.createElement(R.y$,{text:"Loading Event information..."}):e.createElement(e.Fragment,null,U&&e.createElement(R.Oj,{question:"Do you really want to abandon this page and lose your changes? This action cannot be undone."}),e.createElement(In,{action:o,canEdit:h.is_mutable,currentUser:J,defaults:Pn,activeStep:f,entityTypes:F,eventDefinition:p,formControls:i,notifications:Y.all,onCancel:Ln,onChange:Dn,onChangeStep:Bn,onSubmit:Rn,validation:re}))};$e.propTypes={action:s().oneOf(["create","edit"]),eventDefinition:s().object,onEventDefinitionChange:s().func},$e.defaultProps={action:"edit",eventDefinition:{title:"",description:"",priority:oe.A.NORMAL,config:{},field_spec:{},key_spec:[],notification_settings:{grace_period_ms:3e5,backlog_size:null},notifications:[],alert:!1},formControls:void 0,initialStep:j[0],onCancel:void 0,onSubmit:void 0,onChangeStep:void 0,onEventDefinitionChange:()=>{}};const bn=$e},"42lc8BRs":(k,Q,n)=>{"use strict";n.d(Q,{A:()=>xe});var e=n("Z7aTuO5B"),z=n("ii0bleBb"),s=n.n(z),O=n("VZ0CjfW1"),B=n.n(O),V=n("IW7priiX"),ge=n.n(V),oe=n("IOI9nV80"),R=n("d4kzUuQm"),pe=n("J7MaobQD"),ve=n("N6x7vnl1"),T=n("/yh+QgO6"),Ce=n.n(T),Ee=n("QL8i6bcz"),_=n("rIl5IEuP"),Pe=n("S6FuRS7B"),De=n("BqxuktKK"),le=n("MdYBRjRJ"),se=n("v4GbOr/o"),Re=n("HCsT5Gmk"),ye=Object.defineProperty,Le=(N,g,m)=>g in N?ye(N,g,{enumerable:!0,configurable:!0,writable:!0,value:m}):N[g]=m,$=(N,g,m)=>(Le(N,typeof g!="symbol"?g+"":g,m),m);const Ne=N=>N===void 0?{}:Ee.d.exports("eventNotificationTypes").find(g=>g.type===N)||{},ce=()=>Ee.d.exports("eventNotificationTypes").map(N=>({label:N.displayName,value:N.type}));class te extends e.Component{constructor(g){super(g),$(this,"setIsSubmitEnabled",m=>{this.setState({isSubmitEnabled:m})}),$(this,"handleSubmit",m=>{const{notification:v,onSubmit:C,sendTelemetry:S,action:A,location:P}=this.props;S(A==="create"?se.g.NOTIFICATIONS.CREATE_CLICKED:se.g.NOTIFICATIONS.EDIT_CLICKED,{app_pathname:(0,le.i)(P.pathname),app_section:"event-notification",app_action_value:`${A}-button`}),m.preventDefault(),C(v)}),$(this,"handleChange",m=>{const{name:v}=m.target,{onChange:C}=this.props;C(v,(0,Pe.yG)(m.target))}),$(this,"handleConfigChange",m=>{const{onChange:v}=this.props;v("config",m)}),$(this,"handleTypeChange",m=>{const{sendTelemetry:v,location:C}=this.props;v(se.g.EVENTDEFINITION_NOTIFICATIONS.NOTIFICATION_TYPE_SELECTED,{app_pathname:(0,le.i)(C.pathname),app_section:"event-definition-notifications",app_action_value:"notification-type-select",notification_type:m});const A=Ne(m).defaultConfig||{};this.handleConfigChange({...A,type:m})}),$(this,"handleTestTrigger",()=>{const{notification:m,onTest:v,sendTelemetry:C,location:S}=this.props;C(se.g.NOTIFICATIONS.EXECUTE_TEST_CLICKED,{app_pathname:(0,le.i)(S.pathname),app_section:"event-notification",app_action_value:"execute-test-button"}),v(m)}),this.state={isSubmitEnabled:!0}}render(){const{action:g,embedded:m,formId:v,notification:C,onCancel:S,validation:A,testResult:P}=this.props,{isSubmitEnabled:w}=this.state,M=Ne(C.config.type),ne=M.formComponent?e.createElement(M.formComponent,{config:C.config,onChange:this.handleConfigChange,validation:A,setIsSubmitEnabled:this.setIsSubmitEnabled}):null,q=P.isLoading?e.createElement(oe.y$,{text:"Testing..."}):"Execute Test Notification";return e.createElement(_.Row,null,e.createElement(_.Col,{lg:8},e.createElement("form",{onSubmit:this.handleSubmit,id:v},e.createElement(_.Input,{id:"notification-title",name:"title",label:"Title",type:"text",bsStyle:A.errors.title?"error":null,help:Ce()(A,"errors.title[0]","Title to identify this Notification."),value:C.title,onChange:this.handleChange,required:!0,autoFocus:!0}),e.createElement(_.Input,{id:"notification-description",name:"description",label:e.createElement("span",null,"Description ",e.createElement("small",{className:"text-muted"},"(Optional)")),type:"textarea",help:"Longer description for this Notification.",value:C.description,onChange:this.handleChange,rows:2}),e.createElement(_.FormGroup,{controlId:"notification-type",validationState:A.errors.config?"error":null},e.createElement(_.ControlLabel,null,"Notification Type"),e.createElement(oe.l6,{id:"notification-type",options:ce(),value:C.config.type,onChange:this.handleTypeChange,clearable:!1,required:!0}),e.createElement(_.HelpBlock,null,Ce()(A,"errors.config[0]","Choose the type of Notification to create."))),ne,ne&&e.createElement(_.FormGroup,null,e.createElement(_.ControlLabel,null,"Test Notification ",e.createElement("small",{className:"text-muted"},"(Optional)")),e.createElement(_.FormControl.Static,null,e.createElement(_.Button,{bsStyle:"info",bsSize:"small",disabled:P.isLoading,onClick:this.handleTestTrigger},q)),P.message&&e.createElement(_.Alert,{bsStyle:P.error?"danger":"success",title:P.error?"Error: ":"Success: "},P.message),e.createElement(_.HelpBlock,null,"Execute this Notification with a test Alert.")),!m&&e.createElement(oe.hP,{disabledSubmit:!w,submitButtonText:`${g==="create"?"Create":"Update"} notification`,onCancel:S}))))}}$(te,"propTypes",{action:s().oneOf(["create","edit"]),notification:s().object.isRequired,validation:s().object.isRequired,testResult:s().shape({isLoading:s().bool,error:s().bool,message:s().string}).isRequired,formId:s().string,embedded:s().bool.isRequired,onChange:s().func.isRequired,onCancel:s().func.isRequired,onSubmit:s().func.isRequired,onTest:s().func.isRequired,sendTelemetry:s().func.isRequired,location:s().object.isRequired}),$(te,"defaultProps",{action:"edit",formId:void 0});const y=(0,Re.A)((0,De.A)(te));var Be=Object.defineProperty,_e=(N,g,m)=>g in N?Be(N,g,{enumerable:!0,configurable:!0,writable:!0,value:m}):N[g]=m,W=(N,g,m)=>(_e(N,typeof g!="symbol"?g+"":g,m),m);const de={errors:{}},a={isLoading:!1},Te=class tt extends e.Component{constructor(g){super(g),W(this,"handleChange",(m,v)=>{const{notification:C}=this.state,S=ge()(C);S[m]=v,this.setState({notification:S,isDirty:!0,testResult:a})}),W(this,"handleCancel",()=>{const{history:m}=this.props;m.push(R.Ay.ALERTS.NOTIFICATIONS.LIST)}),W(this,"handleSubmit",()=>{const{action:m,embedded:v,onSubmit:C,history:S}=this.props,{notification:A}=this.state;this.setState({isDirty:!1});let P;m==="create"?(P=pe.M.create(A),P.then(()=>{v||S.push(R.Ay.ALERTS.NOTIFICATIONS.LIST)},w=>{const{body:M}=w.additional;w.status===400&&M&&M.failed&&(this.setState({validation:M}),tt.scrollToFirstError())})):(P=pe.M.update(A.id,A),P.then(()=>{v||S.push(R.Ay.ALERTS.NOTIFICATIONS.LIST)},w=>{const{body:M}=w.additional;w.status===400&&M&&M.failed&&(this.setState({validation:M}),tt.scrollToFirstError())})),C(P)}),W(this,"handleTest",()=>{const{notification:m}=this.state;this.setState({testResult:{isLoading:!0},validation:de});const v=B()(a);this.testPromise=pe.M.test(m),this.testPromise.then(C=>(v.error=!1,v.message="Notification was executed successfully.",C),C=>{v.error=!0;const{body:S}=C.additional;C.status===400&&S&&S.failed?(v.message="Validation failed, please correct any errors in the form before continuing.",this.setState({validation:S})):v.message=C.responseMessage||"Unknown error, please check your Graylog server logs."}).finally(()=>{this.setState({testResult:v}),this.testPromise=void 0})}),this.state={notification:g.notification,validation:de,testResult:a,isDirty:!1}}static scrollToFirstError(){document.getElementsByClassName("has-error")[0]!==void 0&&document.getElementsByClassName("has-error")[0].scrollIntoView(!0)}componentWillUnmount(){this.testPromise&&this.testPromise.cancel()}render(){const{action:g,embedded:m,formId:v}=this.props,{notification:C,validation:S,testResult:A,isDirty:P}=this.state;return e.createElement(e.Fragment,null,!m&&P&&e.createElement(oe.Oj,{question:"Do you really want to abandon this page and lose your changes? This action cannot be undone."}),e.createElement(y,{action:g,notification:C,validation:S,testResult:A,formId:v,embedded:m,onChange:this.handleChange,onCancel:this.handleCancel,onSubmit:this.handleSubmit,onTest:this.handleTest}))}};W(Te,"propTypes",{action:s().oneOf(["create","edit"]),notification:s().object,embedded:s().bool,formId:s().string,onSubmit:s().func,history:s().object.isRequired}),W(Te,"defaultProps",{action:"edit",notification:{title:"",description:"",config:{}},embedded:!1,formId:void 0,onSubmit:()=>{}});let Ke=Te;const xe=(0,ve.A)(Ke)},VZ0CjfW1:(k,Q,n)=>{var e=n("8U3oBBH1"),z=4;function s(O){return e(O,z)}k.exports=s}}]);})();
//# sourceMappingURL=bb8c8232-64.8324d02abbc7ed0c3d2d.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy