web-interface.assets.07ba022f-539.8a4e25b6f1de6dd54742.js Maven / Gradle / Ivy
(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["07ba022f-539"],{"ZuR+biJv":(M,A,n)=>{"use strict";n.d(A,{Z:()=>V});var e=n("pmX897Fv"),b=n.n(e),a=n("DjJvgDaP"),D=n.n(a),v=D()(b());v.push([M.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:""}]),v.locals={conditionTypesInfo:"bK_1OgMCpxX5cNvo_KNH",hr:"r3CTNJIqazOh7HmXypag"};const V=v},uCppV7l0:(M,A,n)=>{"use strict";n.d(A,{Z:()=>V});var e=n("pmX897Fv"),b=n.n(e),a=n("DjJvgDaP"),D=n.n(a),v=D()(b());v.push([M.id,`.xZzz7avfOImN5wyTQXue dl dl {
padding-left: 10px;
margin-bottom: 5px;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-form/EventDefinitionSummary.css"],names:[],mappings:"AAAA;IACI,kBAAkB;IAClB,kBAAkB;AACtB",sourcesContent:[`:local(.eventSummary) dl dl {
padding-left: 10px;
margin-bottom: 5px;
}
`],sourceRoot:""}]),v.locals={eventSummary:"xZzz7avfOImN5wyTQXue"};const V=v},yUieYTlS:(M,A,n)=>{"use strict";n.d(A,{Z:()=>V});var e=n("pmX897Fv"),b=n.n(e),a=n("DjJvgDaP"),D=n.n(a),v=D()(b());v.push([M.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:""}]),v.locals={actions:"ZziANjUKFVuuqMSwLmtB",providerOptions:"Xylx_0ZpoJHGYL_KE6gZ"};const V=v},nQKpNrvS:(M,A,n)=>{"use strict";n.d(A,{Z:()=>V});var e=n("pmX897Fv"),b=n.n(e),a=n("DjJvgDaP"),D=n.n(a),v=D()(b());v.push([M.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:""}]),v.locals={manageNotifications:"NLt8T3UO0KICJTv1bzhC",notificationSettings:"cWTw12YX10UuN5KAKoIX"};const V=v},njMnXJuB:(M,A,n)=>{"use strict";n.d(A,{Z:()=>V});var e=n("pmX897Fv"),b=n.n(e),a=n("DjJvgDaP"),D=n.n(a),v=D()(b());v.push([M.id,`.m1bai3Kt45u9j3MtW7hT {
margin-bottom: 20px;
}
.EJT6DlEKjyYuxyouwsaR {
table-layout: fixed;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-form/field-value-providers/CommonFieldValueProviderSummary.css"],names:[],mappings:"AAAA;IACI,mBAAmB;AACvB;;AAEA;IACI,mBAAmB;AACvB",sourcesContent:[`:local(.field) {
margin-bottom: 20px;
}
:local(.fixedTable) {
table-layout: fixed;
}
`],sourceRoot:""}]),v.locals={field:"m1bai3Kt45u9j3MtW7hT",fixedTable:"EJT6DlEKjyYuxyouwsaR"};const V=v},yqbobKTV:(M,A,n)=>{"use strict";n.d(A,{Z:()=>V});var e=n("pmX897Fv"),b=n.n(e),a=n("DjJvgDaP"),D=n.n(a),v=D()(b());v.push([M.id,`.DqBObyDjYFhBwILgUW_Q .panel-body {
padding: 20px 10px;
}
.DqBObyDjYFhBwILgUW_Q ul {
padding-left: 1em;
}
`,"",{version:3,sources:["webpack://./src/components/event-definitions/event-definition-form/field-value-providers/TemplateFieldValueProviderPreview.css"],names:[],mappings:"AAAA;IACI,kBAAkB;AACtB;;AAEA;IACI,iBAAiB;AACrB",sourcesContent:[`:local(.templatePreview) .panel-body {
padding: 20px 10px;
}
:local(.templatePreview) ul {
padding-left: 1em;
}
`],sourceRoot:""}]),v.locals={templatePreview:"DqBObyDjYFhBwILgUW_Q"};const V=v},IFFKjdia:(M,A,n)=>{"use strict";n.d(A,{$Z:()=>D,JG:()=>b,Qk:()=>e,oT:()=>a});const e="system-notifications-v1",b="event_definitions",a={pageSize:20,sort:{attributeId:"title",direction:"asc"},displayedColumns:["title","description","priority","scheduling","status","matched_at"],columnsOrder:["title","description","priority","matched_at","status","scheduling"]},D=[{id:"scheduling",title:"Scheduling",sortable:!1},{id:"matched_at",title:"Last Matched",sortable:!0}]},"4FHtc+Yb":(M,A,n)=>{"use strict";n.d(A,{Z:()=>yi});var e=n("Z7aTuO5B"),b=n("ii0bleBb"),a=n.n(b),D=n("yAXMqwrl"),v=n("QL8i6bcz"),V=n("IW7priiX"),J=n.n(V),q=n("d4kzUuQm"),de=n("8fnsnG21"),ce=n("Dh8G0fI8"),E=n("/GOzvPf6"),Me=n("JnTtTRmZ"),pe=n.n(Me),T=n("MdYBRjRJ"),j=n("eFxcQyPT"),Fe=n("IA3Ku5lS");const Ve=(0,Fe.ei)("core.AvailableEventDefinitionTypes",()=>pe().createActions({get:{asyncResult:!0}})),fe=(0,Fe.dS)("core.AvailableEventDefinitionTypes",()=>pe().createStore({listenables:[Ve],sourceUrl:"/events/entity_types",entityTypes:void 0,init(){this.get()},getInitialState(){return this.entityTypes},get(){(0,j.ZP)("GET",T.DC(this.sourceUrl)).then(t=>{this.entityTypes=t,this.trigger(this.entityTypes)})}}));var me=n("ibdPvtmL"),Se=n("cd5HAK44"),Pe=n("J7MaobQD"),$e=n("ava0cCRK"),Q=n("q2j1bVbz"),ve=n("7GNmVOX8"),be=n("brbjQOmY");const je=()=>{const{"session-id":o}=(0,be.Z)();return(0,e.useMemo)(()=>{const t=ve.Z.get(o);if(!t)return{hasLocalStorageConfig:!1,configFromLocalStorage:void 0};ve.Z.delete(o);const{type:i,query:r,streams:s,search_within_ms:c,group_by:d,agg_function:m,agg_field:f,agg_value:C,loc_query_parameters:I}=t,L=m&&C?{conditions:{expression:{expr:void 0,left:{expr:"number-ref",ref:`${m}-${f}`},right:{expr:"number",value:C}}},series:[{id:`${m}-${f}`,function:m,field:f}],group_by:d||[]}:{};return{hasLocalStorageConfig:!0,configFromLocalStorage:{type:i,query:r!=null?r:"",streams:s!=null?s:[],search_within_ms:c,group_by:d!=null?d:[],query_parameters:I!=null?I:[],...L}}},[o])};var Ee=n("8OvTct/Z"),k=n("0t7Ye+61"),y=n("v4GbOr/o"),oe=n("w7+AQV2V"),he=n.n(oe),ge=n("WgCNywL/"),ae=n.n(ge),Ie=n("J6y4/h8P"),ye=n("oCSEoDew"),R=n.n(ye),p=n("pjsNBHWI"),u=n.n(p),l=n("uZqmR+ju"),h=n("/7OuCFNo"),F=n("/yh+QgO6"),S=n.n(F),x=n("Pd5CUaTj"),X=n.n(x),W=n("Dg7SLLbb"),De=n.n(W),Ze=n("ueJll2OF"),we=n.n(Ze),mt=n("GCWFEkMy"),ut=n.n(mt),le=n("S6FuRS7B"),$=n("9O66OgQd");const g=X()(ce.Z.properties,(o,t)=>({value:t,label:De()(o.name)})),P=({eventDefinition:o,validation:t,onChange:i})=>{const{pathname:r}=(0,k.Z)(),s=(0,Ee.Z)(),c=f=>{const{name:C}=f.target;i(C,le.n6(f.target))},d=f=>{var C;s(y.A.EVENTDEFINITION_DETAILS.PRIORITY_CHANGED,{app_pathname:(0,T.av)(r),app_section:"event-definition-details",app_action_value:"priority-select",priority:(C=g[we()(f)-1])==null?void 0:C.label}),i("priority",we()(f))},m=o.config.type==="system-notifications-v1";return e.createElement(l.Row,null,e.createElement(l.Col,{md:7,lg:6},e.createElement("h2",{className:$.Z.title},"Event Details"),e.createElement("fieldset",null,e.createElement(l.Input,{id:"event-definition-title",name:"title",label:"Title",type:"text",bsStyle:t.errors.title?"error":null,help:S()(t,"errors.title[0]","Title for this Event Definition, Events and Alerts created from it."),value:o.title,onChange:c,readOnly:m,required:!0}),e.createElement(l.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:m,rows:2}),e.createElement(l.FormGroup,{controlId:"event-definition-priority"},e.createElement(l.ControlLabel,null,"Priority"),e.createElement(E.Ph,{options:g,value:ut()(o.priority),onChange:d,clearable:!1,disabled:m,required:!0}),e.createElement(l.HelpBlock,null,"Choose the priority for Events created from this Definition.")))))};P.propTypes={eventDefinition:a().object.isRequired,validation:a().object.isRequired,onChange:a().func.isRequired};const O=P;var K=n("4E3oowBb"),Oe=n("xnXzNzZh"),Ce=n("dFpwyWHg"),Te=n.n(Ce),Qt=n("C2ikvoS0"),Ue=n.n(Qt),kt=n("1IntWRSu"),Ge=n.n(kt),$t=n("8nGWeFnd"),We=n.n($t),wt=n("TeAcaicX"),ze=n.n(wt),qt=n("eE3+5goe"),Xe=n.n(qt),qe=n("ZuR+biJv"),Re={};Re.styleTagTransform=Xe(),Re.setAttributes=We(),Re.insert=Ge().bind(null,"head"),Re.domAPI=Ue(),Re.insertStyleElement=ze();var Ti=Te()(qe.Z,Re);const bt=qe.Z&&qe.Z.locals?qe.Z.locals:void 0;var en=n("IFFKjdia");const pt=({action:o,entityTypes:t,eventDefinition:i,validation:r,currentUser:s,onChange:c})=>{const{pathname:d}=(0,k.Z)(),m=(0,Ee.Z)(),f=N=>N===void 0?{}:v.G.exports("eventDefinitionTypes").find(B=>B.type===N)||{},C=()=>v.G.exports("eventDefinitionTypes").sort((N,B)=>{const U=N.sortOrder,ne=B.sortOrder;if(U!==void 0||ne!==void 0){const se=ae()(U,Number.MAX_SAFE_INTEGER)-ae()(ne,Number.MAX_SAFE_INTEGER);if(se!==0)return se}return(0,K.S)(N.displayName,B.displayName)}),I=()=>C().map(N=>({label:N.displayName,value:N.type})),L=N=>{m(y.A.EVENTDEFINITION_CONDITION.TYPE_SELECTED,{app_pathname:(0,T.av)(d),app_section:"event-definition-condition",app_action_value:"type-select",condition_type:N});const B=f(N),U=(B==null?void 0:B.defaultConfig)||{};c("config",{...U,type:N})},ee=()=>{const N=C().map(B=>e.createElement(e.Fragment,{key:B.type},e.createElement("dt",null,B.displayName),e.createElement("dd",null,B.description||"No description available.")));return e.createElement("dl",null,N)},te=()=>!I().some(N=>i.config.type===N.value)&&o==="edit",H=f(i.config.type),Z=i.config.type===en.Qk,G=H!=null&&H.formComponent?e.createElement(H.formComponent,{action:o,entityTypes:t,currentUser:s,validation:r,eventDefinition:i,onChange:c,key:i.id}):null;return e.createElement(l.Row,null,e.createElement(l.Col,{md:7,lg:6},e.createElement("h2",{className:$.Z.title},"Event Condition"),Z?e.createElement("p",null,"The conditions of system notification event definitions cannot be edited."):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(l.FormGroup,{controlId:"event-definition-priority",validationState:r.errors.config?"error":null},e.createElement(l.ControlLabel,null,"Condition Type"),e.createElement(E.Ph,{placeholder:"Select a Condition Type",options:I(),value:i.config.type,onChange:L,clearable:!1,disabled:te(),required:!0}),e.createElement(l.HelpBlock,null,S()(r,"errors.config[0]","Choose the type of Condition for this Event."))))),!Z&&!te()&&e.createElement(e.Fragment,null,e.createElement(l.Col,{md:5,lg:5,lgOffset:1},e.createElement(Oe.e,{className:bt.conditionTypesInfo,title:"Available Conditions"},ee())),e.createElement(l.Clearfix,null),G&&e.createElement(e.Fragment,null,e.createElement("hr",{className:bt.hr}),e.createElement(l.Col,{md:12},G))))};pt.defaultProps={action:"create",entityTypes:void 0},pt.propTypes={action:a().oneOf(["create","edit"]),entityTypes:a().object,eventDefinition:a().object.isRequired,currentUser:a().object.isRequired,validation:a().object.isRequired,onChange:a().func.isRequired};const tn=pt;var nn=n("RjO1iR6D"),At=n.n(nn);const It=o=>{const{id:t,...i}=o,r="More about Event Keys";return e.createElement(l.Popover,{id:t,title:r,...i},e.createElement("p",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."))};It.propTypes={id:a().string.isRequired};const Dt=It;var on=n("P5NcJT2c"),an=n.n(on),et=n("BqxuktKK"),tt=n("HCsT5Gmk"),ln=Object.defineProperty,rn=(o,t,i)=>t in o?ln(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,w=(o,t,i)=>(rn(o,typeof t!="symbol"?t+"":t,i),i);const sn=["fieldName","config.providers[0].type"],ft=o=>o===void 0?{}:v.G.exports("fieldValueProviders").find(t=>t.type===o)||{},vt=(o,t)=>S()(o,"providers[0].type",t),dn=()=>v.G.exports("fieldValueProviders").map(o=>({label:o.displayName,value:o.type}));class Et extends e.Component{constructor(t){super(t),w(this,"validate",()=>{const{isKey:r,keyPosition:s,config:c}=this.state,d={},m=vt(c);let f=[];m&&(f=ft(m).requiredFields),sn.forEach(I=>{S()(this.state,I)||(d[I]="Field cannot be empty.")}),r&&(!an()(s)||Number(s)<1)&&(d.key_position="Field must be a positive number."),f.forEach(I=>{S()(c,`providers[0].${I}`)||(d[I]="Field cannot be empty.")});const C=Object.keys(d).length;return C>0&&this.setState({validation:{errors:d}}),C===0}),w(this,"handleSubmit",()=>{if(this.props.sendTelemetry(y.A.EVENTDEFINITION_FIELDS.DONE_CLICKED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"done-button"}),this.validate()){const{fieldName:r,onChange:s}=this.props,{fieldName:c,config:d,isKey:m,keyPosition:f}=this.state;s(r,c,d,m,f-1)}}),w(this,"handleCancel",()=>{this.props.sendTelemetry(y.A.EVENTDEFINITION_FIELDS.CANCEL_CLICKED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"cancel-button"}),this.props.onCancel()}),w(this,"handleFieldNameChange",r=>{const s=le.n6(r.target);this.setState({fieldName:s})}),w(this,"handleConfigChange",r=>{this.setState({config:r})}),w(this,"handleProviderTypeChange",r=>{this.props.sendTelemetry(r==="lookup-v1"?y.A.EVENTDEFINITION_FIELDS.SET_VALUE_FROM_LOOKUP_TABLE_SELECTED:y.A.EVENTDEFINITION_FIELDS.SET_VALUE_FROM_TEMPLATE_SELECTED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"set-value-from-select",value_source:r});const{config:s}=this.state,d=ft(r).defaultConfig||{},m={...s,providers:[{...d,type:r}]};this.handleConfigChange(m)}),w(this,"handleKeySortChange",r=>{const s=r.target.value===""?"":le.n6(r.target);this.setState({keyPosition:s})}),w(this,"toggleKey",r=>{const s=le.n6(r.target);this.props.sendTelemetry(y.A.EVENTDEFINITION_FIELDS.AS_EVENT_KEY_TOGGLED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"event-key-checkbox",event_key_checked:s}),this.setState({isKey:s})}),w(this,"renderFieldValueProviderForm",()=>{const{fieldName:r,config:s,validation:c}=this.state,{currentUser:d}=this.props,m=vt(s);if(!m)return null;const f=ft(m);return f.formComponent?e.createElement(f.formComponent,{fieldName:r,config:s,onChange:this.handleConfigChange,validation:c,currentUser:d}):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:s,config:c,validation:d}=this.state;return e.createElement(l.Row,null,e.createElement(l.Col,{md:7,lg:6},e.createElement("h2",{className:$.Z.title},t?`Custom Field "${i}"`:"New Custom Field"),e.createElement(l.Input,{id:"field-name",name:"name",label:"Name",type:"text",value:i,onChange:this.handleFieldNameChange,bsStyle:d.errors.fieldName?"error":null,help:d.errors.fieldName||"Name for this Field.",required:!0}),e.createElement(l.FormGroup,{validationState:d.errors.key_position?"error":null},e.createElement(l.ControlLabel,null,"Use Field as Event Key\u2003",e.createElement(E.Ox,{placement:"right",trigger:["click","focus"],overlay:e.createElement(Dt,{id:"key-popover"})},e.createElement(l.Button,{bsStyle:"link",bsSize:"xsmall"},e.createElement(E.JO,{name:"question-circle"})))),e.createElement(l.InputGroup,null,e.createElement(l.InputGroup.Addon,null,e.createElement("input",{id:"is-key",name:"is-key",type:"checkbox",onChange:this.toggleKey,checked:r})),e.createElement(l.FormControl,{id:"field-key",name:"key",type:"number",value:s,onChange:this.handleKeySortChange,disabled:!r})),e.createElement(l.HelpBlock,null,d.errors.key_position||"Indicates if this Field should be a Key and its order.")),e.createElement(l.FormGroup,null,e.createElement(l.ControlLabel,null,"Field Data Type"),e.createElement(l.FormControl.Static,null,"String")),e.createElement(l.FormGroup,{controlId:"event-field-provider",validationState:d.errors["config.providers[0].type"]?"error":null},e.createElement(l.ControlLabel,null,"Set Value From"),e.createElement(E.Ph,{name:"event-field-provider",ignoreAccents:!1,placeholder:"Select Value Source",onChange:this.handleProviderTypeChange,options:dn(),value:vt(c,""),matchProp:"label",required:!0}),e.createElement(l.HelpBlock,null,d.errors["config.providers[0].type"]||"Select a source for the value of this Field."))),e.createElement(l.Col,{md:12},this.renderFieldValueProviderForm()),e.createElement(l.Col,{md:12},e.createElement(l.ButtonToolbar,null,e.createElement(l.Button,{bsStyle:"primary",onClick:this.handleSubmit},"Done"),e.createElement(l.Button,{onClick:this.handleCancel},"Cancel"))))}}w(Et,"propTypes",{fieldName:a().string,config:a().object,currentUser:a().object.isRequired,keys:a().array.isRequired,onChange:a().func.isRequired,onCancel:a().func.isRequired,sendTelemetry:a().func.isRequired,location:a().object.isRequired}),w(Et,"defaultProps",{fieldName:"",config:{}});const cn=(0,tt.Z)((0,et.Z)(Et));var nt=n("yUieYTlS"),_e={};_e.styleTagTransform=Xe(),_e.setAttributes=We(),_e.insert=Ge().bind(null,"head"),_e.domAPI=Ue(),_e.insertStyleElement=ze();var Ni=Te()(nt.Z,_e);const Ot=nt.Z&&nt.Z.locals?nt.Z.locals:void 0;var mn=Object.defineProperty,un=(o,t,i)=>t in o?mn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,Ye=(o,t,i)=>(un(o,typeof t!="symbol"?t+"":t,i),i);const pn=["Field Name","Is Key?","Value Source","Data Type","Configuration","Actions"],fn=o=>o===void 0?{}:v.G.exports("fieldValueProviders").find(t=>t.type===o)||{},vn=o=>{const t=Object.keys(o).filter(i=>i!=="type");return e.createElement("p",null,t.map(i=>e.createElement("span",{key:i,className:Ot.providerOptions},i,": ",e.createElement("em",null,JSON.stringify(o[i])))))};class Rt extends e.Component{constructor(){super(...arguments),Ye(this,"handleAddFieldClick",()=>{this.props.sendTelemetry(y.A.EVENTDEFINITION_FIELDS.ADD_CUSTOM_FIELD_CLICKED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-fields",app_action_value:"add-custom-field-button"});const{onAddFieldClick:t}=this.props;t()}),Ye(this,"handleEditClick",t=>()=>{const{onEditFieldClick:i}=this.props;i(t)}),Ye(this,"handleRemoveClick",t=>()=>{const{onRemoveFieldClick:i}=this.props;i(t)}),Ye(this,"fieldFormatter",t=>{const{fields:i,keys:r}=this.props,s=i[t],c=r.indexOf(t),d=fn(s.providers[0].type);return e.createElement("tr",{key:t},e.createElement("td",null,t),e.createElement("td",null,c<0?"No":"Yes"),e.createElement("td",null,d.displayName||s.providers[0].type),e.createElement("td",null,s.data_type),e.createElement("td",null,vn(s.providers[0])),e.createElement("td",{className:Ot.actions},e.createElement(l.ButtonToolbar,null,e.createElement(l.Button,{bsStyle:"primary",bsSize:"xsmall",onClick:this.handleRemoveClick(t)},"Remove Field"),e.createElement(l.Button,{bsStyle:"info",bsSize:"xsmall",onClick:this.handleEditClick(t)},"Edit"))))})}render(){const{fields:t}=this.props,i=Object.keys(t).sort(K.S),r=e.createElement(l.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(E.wQ,{id:"event-definition-fields",className:"table-striped table-hover",headers:pn,rows:i,dataRowFormatter:this.fieldFormatter,filterKeys:[]}),r)}}Ye(Rt,"propTypes",{fields:a().object.isRequired,keys:a().array.isRequired,onAddFieldClick:a().func.isRequired,onEditFieldClick:a().func.isRequired,onRemoveFieldClick:a().func.isRequired,sendTelemetry:a().func.isRequired,location:a().object.isRequired});const En=(0,tt.Z)((0,et.Z)(Rt));var it=n("yqbobKTV"),Le={};Le.styleTagTransform=Xe(),Le.setAttributes=We(),Le.insert=Ge().bind(null,"head"),Le.domAPI=Ue(),Le.insertStyleElement=ze();var Fi=Te()(it.Z,Le);const hn=it.Z&&it.Z.locals?it.Z.locals:void 0;var gn=Object.defineProperty,yn=(o,t,i)=>t in o?gn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,Cn=(o,t,i)=>(yn(o,typeof t!="symbol"?t+"":t,i),i);class _t extends e.Component{render(){return e.createElement(l.Panel,{className:hn.templatePreview,header:e.createElement("h3",null,"Available Fields in Template")},e.createElement("p",null,"Graylog lets you enrich generated Events with dynamic values. You can access Fields from the Event context"," ","with ",e.createElement("code",null,"${source.}"),".",e.createElement("br",null),"Available Fields in the Template depend on the condition that created the Event:"),e.createElement("ul",null,e.createElement("li",null,e.createElement("b",null,"Filter:")," All Fields in the original log message"),e.createElement("li",null,e.createElement("b",null,"Aggregation:")," Fields set in Group By with their original names"),e.createElement("li",null,e.createElement("b",null,"Correlation:")," All Fields in the last matched and non-negated Event")))}}Cn(_t,"propTypes",{});const Tn=_t;var Nn=Object.defineProperty,Fn=(o,t,i)=>t in o?Nn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,He=(o,t,i)=>(Fn(o,typeof t!="symbol"?t+"":t,i),i);const Je=class Ft extends e.Component{constructor(){super(...arguments),He(this,"handleChange",t=>{const{config:i,onChange:r}=this.props,{name:s}=t.target,c=le.n6(t.target),d=J()(i.providers),m=d.find(f=>f.type===Ft.type);m[s]=c,r({...i,providers:d})})}render(){const{config:t,validation:i}=this.props,r=t.providers.find(c=>c.type===Ft.type),s=e.createElement("span",null,"Type a literal text to set to this Field or use"," ",e.createElement(E.dL,{href:"https://cdn.rawgit.com/DJCordhose/jmte/master/doc/index.html"},"JMTE syntax")," ","to add a dynamic Value.");return e.createElement(l.Row,{className:"row-sm"},e.createElement(l.Col,{md:7,lg:6},e.createElement(l.Input,{id:"template-provider-template",name:"template",type:"text",label:"Template",onChange:this.handleChange,value:r.template||"",bsStyle:i.errors.template?"error":null,help:i.errors.template||s}),e.createElement(l.FormGroup,null,e.createElement(l.Checkbox,{id:"lookup-message-require-values",name:"require_values",checked:r.require_values,onChange:this.handleChange},"Require all template values to be set"),e.createElement(l.HelpBlock,null,"Check this option to validate that all variables used in the Template have values."))),e.createElement(l.Col,{md:5,lgOffset:1},e.createElement(Tn,null)))}};He(Je,"propTypes",{config:a().object.isRequired,validation:a().object.isRequired,onChange:a().func.isRequired}),He(Je,"type","template-v1"),He(Je,"defaultConfig",{template:""}),He(Je,"requiredFields",["template"]);const ot=Je;var at=n("njMnXJuB"),Be={};Be.styleTagTransform=Xe(),Be.setAttributes=We(),Be.insert=Ge().bind(null,"head"),Be.domAPI=Ue(),Be.insertStyleElement=ze();var Pi=Te()(at.Z,Be);const Lt=at.Z&&at.Z.locals?at.Z.locals:void 0;var Sn=Object.defineProperty,Pn=(o,t,i)=>t in o?Sn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,ht=(o,t,i)=>(Pn(o,typeof t!="symbol"?t+"":t,i),i);class Bt extends e.Component{constructor(){super(...arguments),ht(this,"state",{displayDetails:!1}),ht(this,"toggleDisplayDetails",()=>{const{displayDetails:t}=this.state;this.setState({displayDetails:!t})})}render(){const{fieldName:t,config:i,keys:r,children:s}=this.props,{displayDetails:c}=this.state;return e.createElement("dl",{className:Lt.field},e.createElement("dt",null,t),e.createElement("dd",null,e.createElement(l.Button,{bsStyle:"link",className:"btn-text",bsSize:"xsmall",onClick:this.toggleDisplayDetails},e.createElement(E.JO,{name:`caret-${c?"down":"right"}`}),"\xA0",c?"Less details":"More details"),c&&e.createElement(l.Table,{condensed:!0,hover:!0,className:Lt.fixedTable},e.createElement("tbody",null,e.createElement("tr",null,e.createElement("td",null,"Is Key?"),e.createElement("td",null,r.includes(t)?"Yes":"No")),e.createElement("tr",null,e.createElement("td",null,"Data Type"),e.createElement("td",null,i.data_type)),s))))}}ht(Bt,"propTypes",{fieldName:a().string.isRequired,config:a().object.isRequired,keys:a().array.isRequired,children:a().element.isRequired});const xt=Bt;var bn=Object.defineProperty,An=(o,t,i)=>t in o?bn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,In=(o,t,i)=>(An(o,typeof t!="symbol"?t+"":t,i),i);class Kt extends e.Component{render(){const{config:t}=this.props;return e.createElement(xt,{...this.props},e.createElement(e.Fragment,null,e.createElement("tr",null,e.createElement("td",null,"Value source"),e.createElement("td",null,"Template")),e.createElement("tr",null,e.createElement("td",null,"Template"),e.createElement("td",null,t.providers[0].template)),e.createElement("tr",null,e.createElement("td",null,"Validate that all Template values are set"),e.createElement("td",null,t.providers[0].require_values?"Yes":"No"))))}}In(Kt,"propTypes",{fieldName:a().string.isRequired,config:a().object.isRequired,keys:a().array.isRequired});const Dn=Kt;var On=n("euujeYld"),Rn=n.n(On),Mt=n("1/PeS1Oa"),_n=Object.defineProperty,Ln=(o,t,i)=>t in o?_n(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,re=(o,t,i)=>(Ln(o,typeof t!="symbol"?t+"":t,i),i);const Qe=class St extends e.Component{constructor(){super(...arguments),re(this,"formatMessageFields",Rn()(t=>t.sort((i,r)=>(0,Mt.Q)(i.name,r.name)).map(i=>({label:`${i.name} \u2013 ${i.value.type.type}`,value:i.name})),t=>t.map(i=>i.name).join("-"))),re(this,"propagateChanges",(t,i)=>{const{config:r,onChange:s}=this.props,c=J()(r.providers),d=c.find(m=>m.type===St.type);d[t]=i,s({...r,providers:c})}),re(this,"handleChange",t=>{const{name:i}=t.target,r=le.n6(t.target);this.propagateChanges(i,r)}),re(this,"handleSelectChange",t=>i=>{this.propagateChanges(t,i)}),re(this,"formatLookupTables",t=>t.sort((i,r)=>(0,Mt.Q)(i.title,r.title)).map(i=>({label:i.title,value:i.name})))}render(){const{allFieldTypes:t,config:i,lookupTables:r,validation:s}=this.props,c=i.providers.find(d=>d.type===St.type);return e.createElement(l.Row,{className:"row-sm"},e.createElement(l.Col,{md:7,lg:6},e.createElement(l.FormGroup,{controlId:"lookup-provider-table",validationState:s.errors.table_name?"error":null},e.createElement(l.ControlLabel,null,"Select Lookup Table"),e.createElement(E.Ph,{name:"event-field-table-name",placeholder:"Select Lookup Table",onChange:this.handleSelectChange("table_name"),options:this.formatLookupTables(r),value:c.table_name,matchProp:"label",required:!0}),e.createElement(l.HelpBlock,null,s.errors.table_name||"Select the Lookup Table Graylog should use to get the value.")),e.createElement(l.FormGroup,{controlId:"lookup-provider-table",validationState:s.errors.key_field?"error":null},e.createElement(l.ControlLabel,null,"Lookup Table Key Field"),e.createElement(E.Ph,{name:"lookup-provider-key",placeholder:"Select Field",onChange:this.handleSelectChange("key_field"),options:this.formatMessageFields(t),value:c.key_field,matchProp:"label",allowCreate:!0,required:!0}),e.createElement(l.HelpBlock,null,s.errors.key_field||"Message Field name whose value will be used as Lookup Table Key."))))}};re(Qe,"propTypes",{allFieldTypes:a().array.isRequired,config:a().object.isRequired,validation:a().object.isRequired,lookupTables:a().array.isRequired,onChange:a().func.isRequired}),re(Qe,"type","lookup-v1"),re(Qe,"defaultConfig",{table_name:"",key_field:""}),re(Qe,"requiredFields",["table_name","key_field"]);const lt=Qe;var rt=n("0TVxnHwi"),Vt=n("xPjmrmtt"),Bn=n("9kZNWwre"),xn=n("nxMFMmDQ");const jt=["lookuptables:read"],Zt=({currentUser:o,...t})=>{const{data:i}=(0,Bn.Z)([],xn.w_),r=(0,de.o)(Vt.m);return(0,e.useEffect)(()=>{(0,rt.rq)(o.permissions,jt)&&Vt.H.searchPaginated(1,0,void 0,!1)},[o.permissions]),(0,rt.rq)(o.permissions,jt)?!i||!r.tables?e.createElement(E.$j,{text:"Loading Field Provider information..."}):e.createElement(lt,{allFieldTypes:i,lookupTables:r.tables,...t}):e.createElement(l.Row,null,e.createElement(l.Col,{md:6,lg:5},e.createElement("p",null,"No Lookup Tables found.")))};Zt.propTypes={config:a().object.isRequired,validation:a().object.isRequired,currentUser:a().object.isRequired,onChange:a().func.isRequired};const Kn=Zt;var Mn=Object.defineProperty,Vn=(o,t,i)=>t in o?Mn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,jn=(o,t,i)=>(Vn(o,typeof t!="symbol"?t+"":t,i),i);class Ut extends e.Component{render(){const{config:t}=this.props,i=t.providers[0];return e.createElement(xt,{...this.props},e.createElement(E.AE,{permissions:"lookuptables:read"},e.createElement(e.Fragment,null,e.createElement("tr",null,e.createElement("td",null,"Value source"),e.createElement("td",null,"Lookup Table")),e.createElement("tr",null,e.createElement("td",null,"Lookup Table"),e.createElement("td",null,i.table_name)),e.createElement("tr",null,e.createElement("td",null,"Lookup Table Key Field"),e.createElement("td",null,i.key_field)))))}}jn(Ut,"propTypes",{fieldName:a().string.isRequired,config:a().object.isRequired,keys:a().array.isRequired});const Zn=Ut;v.G.register(new v.h({},{fieldValueProviders:[{type:ot.type,displayName:"Template",formComponent:ot,summaryComponent:Dn,defaultConfig:ot.defaultConfig,requiredFields:ot.requiredFields},{type:lt.type,displayName:"Lookup Table",formComponent:Kn,summaryComponent:Zn,defaultConfig:lt.defaultConfig,requiredFields:lt.requiredFields}]}));const Gt=({currentUser:o,eventDefinition:t,validation:i,onChange:r})=>{const[s,c]=(0,e.useState)(void 0),[d,m]=(0,e.useState)(!1),f=Z=>{const G=At()(t.field_spec,Z);r("field_spec",G);const N=Object.keys(G),B=t.key_spec.filter(U=>N.includes(U));r("key_spec",B)},C=Z=>{c(d?void 0:Z),m(!d)},I=(Z,G,N,B,U)=>{const ne=Z===G?J()(t.field_spec):At()(t.field_spec,Z);ne[G]=N,r("field_spec",ne);const se=Object.keys(ne);let _=t.key_spec.filter(ue=>se.includes(ue)&&ue!==G);B&&(_=[..._.slice(0,U),G,..._.slice(U)]),r("key_spec",_),C()},L=t.config.type==="system-notifications-v1";if(d)return e.createElement(cn,{keys:t.key_spec,fieldName:s,config:s?t.field_spec[s]:void 0,onChange:I,onCancel:C,currentUser:o});const ee=S()(i,"errors.field_spec",[]),te=S()(i,"errors.key_spec",[]),H=[...ee,...te];return e.createElement(l.Row,null,e.createElement(l.Col,{md:12},e.createElement("h2",{className:$.Z.title},"Event Fields ",e.createElement("small",null,"(optional)")),L?e.createElement("p",null,"The event fields of system notification event definitions cannot be edited."):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."),H.length>0&&e.createElement(l.Alert,{bsStyle:"danger",className:$.Z.validationSummary,title:"Fields with errors"},e.createElement("p",null,"Please correct the following errors before saving this Event Definition:"),e.createElement("ul",null,H.map(Z=>e.createElement("li",{key:Z},Z)))),Object.keys(t.field_spec).length>0&&e.createElement("dl",null,e.createElement("dt",null,"Keys",e.createElement(E.Ox,{placement:"right",trigger:["click","hover"],overlay:e.createElement(Dt,{id:"key-header-popover"})},e.createElement(l.Button,{bsStyle:"link",bsSize:"xsmall"},e.createElement(E.JO,{name:"question-circle"})))),e.createElement("dd",null,t.key_spec.length>0?t.key_spec.join(", "):"No Keys configured yet.")),e.createElement(En,{fields:t.field_spec,validation:i,keys:t.key_spec,onAddFieldClick:C,onEditFieldClick:C,onRemoveFieldClick:f}))))};Gt.propTypes={currentUser:a().object.isRequired,eventDefinition:a().object.isRequired,validation:a().object.isRequired,onChange:a().func.isRequired};const Un=Gt;var Gn=n("LLTH+mT+"),Wn=n.n(Gn),zn=n("ty2gyrHp"),Xn=n("42lc8BRs"),Yn=Object.defineProperty,Hn=(o,t,i)=>t in o?Yn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,Ne=(o,t,i)=>(Hn(o,typeof t!="symbol"?t+"":t,i),i);class gt extends e.Component{constructor(t){super(t),Ne(this,"handleNewNotificationSubmit",i=>{this.props.sendTelemetry(y.A.EVENTDEFINITION_NOTIFICATIONS.DONE_CLICKED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"done-button"});const{onChange:r}=this.props;i.then(s=>r(s.id))}),Ne(this,"handleSubmit",()=>{this.props.sendTelemetry(y.A.EVENTDEFINITION_NOTIFICATIONS.DONE_CLICKED,{app_pathname:(0,T.av)(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)}),Ne(this,"handleCancel",()=>{this.props.sendTelemetry(y.A.EVENTDEFINITION_NOTIFICATIONS.CANCEL_CLICKED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"cancel-button"}),this.props.onCancel()}),Ne(this,"handleSelectNotificationChange",i=>{if(i==="create"){this.props.sendTelemetry(y.A.EVENTDEFINITION_NOTIFICATIONS.CREATE_NEW_CLICKED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"create-new-option"}),this.setState({displayNewNotificationForm:!0});return}this.props.sendTelemetry(y.A.EVENTDEFINITION_NOTIFICATIONS.NOTIFICATION_SELECTED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"existing-notification-option"}),this.setState({selectedNotification:i,displayNewNotificationForm:!1})}),Ne(this,"formatNotifications",i=>{const{hasCreationPermissions:r}=this.props,s=i.map(c=>({label:c.title,value:c.id}));return r&&s.unshift({label:"Create New Notification...",value:"create"}),s}),this.state={selectedNotification:void 0,displayNewNotificationForm:!1}}render(){const{notifications:t}=this.props,{displayNewNotificationForm:i,selectedNotification:r}=this.state,s=i?e.createElement(l.Button,{bsStyle:"primary",type:"submit",form:"new-notification-form"},"Done"):e.createElement(l.Button,{bsStyle:"primary",onClick:this.handleSubmit},"Done");return e.createElement(l.Row,null,e.createElement(l.Col,{md:7,lg:6},e.createElement("h2",{className:$.Z.title},"Add Notification"),e.createElement("fieldset",null,e.createElement(l.FormGroup,{controlId:"notification-select"},e.createElement(l.ControlLabel,null,"Choose Notification"),e.createElement(E.Ph,{id:"notification-select",matchProp:"label",placeholder:"Select Notification",onChange:this.handleSelectNotificationChange,options:this.formatNotifications(t),value:r}),e.createElement(l.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(Xn.Z,{action:"create",formId:"new-notification-form",onSubmit:this.handleNewNotificationSubmit,embedded:!0})),e.createElement(l.ButtonToolbar,null,s,e.createElement(l.Button,{onClick:this.handleCancel},"Cancel"))))}}Ne(gt,"propTypes",{notifications:a().array.isRequired,onChange:a().func.isRequired,onCancel:a().func.isRequired,hasCreationPermissions:a().bool,sendTelemetry:a().func.isRequired,location:a().object.isRequired}),Ne(gt,"defaultProps",{hasCreationPermissions:!1});const Jn=(0,tt.Z)((0,et.Z)(gt));var Qn=n("WoBpjwwo"),kn=n.n(Qn),$n=n("ZoCQyFC1"),Wt=n.n($n),wn=n("9oVghaOd"),qn=n.n(wn),ei=n("ATOIS62c"),ti=Object.defineProperty,ni=(o,t,i)=>t in o?ti(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,st=(o,t,i)=>(ni(o,typeof t!="symbol"?t+"":t,i),i);const zt=["HOURS","MINUTES","SECONDS"],ii=Ie.default.div(({theme:o})=>(0,Ie.css)`
padding-top: ${o.spacings.lg};
`);class Xt extends e.Component{constructor(t){super(t),st(this,"propagateChanges",(m,f)=>{const{eventDefinition:C,onSettingsChange:I}=this.props,L=J()(C.notification_settings);L[m]=f,I("notification_settings",L)}),st(this,"handleGracePeriodChange",(m,f,C)=>{const I=C?qn().duration(Wt()([m,0]),f).asMilliseconds():0;this.propagateChanges("grace_period_ms",I),this.setState({gracePeriodDuration:m,gracePeriodUnit:f})}),st(this,"handleBacklogSizeChange",m=>{const{name:f}=m.target,C=m.target.value===""?"":le.n6(m.target);this.setState({[kn()(f)]:C}),this.propagateChanges(f,Wt()([Number(C),0]))}),st(this,"toggleBacklogSize",()=>{const{isBacklogSizeEnabled:m,backlogSize:f}=this.state;this.setState({isBacklogSizeEnabled:!m}),this.propagateChanges("backlog_size",m?0:f)});const{backlog_size:i,grace_period_ms:r}=t.eventDefinition.notification_settings,s=(0,ei.l)(r,zt),c=t.defaults.default_backlog_size,d=ae()(i,c);this.state={gracePeriodDuration:s.duration,gracePeriodUnit:s.unit,isBacklogSizeEnabled:i===null?!1:d>0,backlogSize:d}}render(){const{eventDefinition:t}=this.props,{gracePeriodDuration:i,gracePeriodUnit:r,isBacklogSizeEnabled:s,backlogSize:c}=this.state;return t.notifications.length===0?null:e.createElement(ii,null,e.createElement(l.FormGroup,{controlId:"grace-period"},e.createElement(E.AX,{label:"Grace Period",update:this.handleGracePeriodChange,defaultEnabled:i!==0,value:i,unit:r,units:zt,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(l.FormGroup,null,e.createElement(l.ControlLabel,null,"Message Backlog"),e.createElement(l.InputGroup,null,e.createElement(l.InputGroup.Addon,null,e.createElement("input",{id:"toggle_backlog_size",type:"checkbox",checked:s,onChange:this.toggleBacklogSize})),e.createElement(l.FormControl,{type:"number",id:"backlog_size",name:"backlog_size",onChange:this.handleBacklogSizeChange,value:c,disabled:!s})),e.createElement("p",null,"Number of messages to be included in Notifications.")))}}Xt.propTypes={eventDefinition:a().object.isRequired,defaults:a().object.isRequired,onSettingsChange:a().func.isRequired};const oi=Xt;var ai=Object.defineProperty,li=(o,t,i)=>t in o?ai(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,dt=(o,t,i)=>(li(o,typeof t!="symbol"?t+"":t,i),i);class Yt extends e.Component{constructor(){super(...arguments),dt(this,"getNotificationPlugin",t=>t===void 0?{}:v.G.exports("eventNotificationTypes").find(i=>i.type===t)||{}),dt(this,"handleRemoveClick",t=>()=>{const{onRemoveNotificationClick:i}=this.props;i(t)}),dt(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(l.Button,{bsStyle:"info",bsSize:"xsmall",onClick:this.handleRemoveClick(t.title)},"Remove from Event")));const i=this.getNotificationPlugin(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(l.Button,{bsStyle:"info",bsSize:"xsmall",onClick:this.handleRemoveClick(t.id)},"Remove from Event")))})}render(){const{eventDefinition:t,notifications:i,onAddNotificationClick:r}=this.props,s=t.notifications.map(d=>i.find(m=>m.id===d.notification_id)||{title:d.notification_id,missing:!0}),c=e.createElement(l.Button,{bsStyle:"success",onClick:r},"Add Notification");return s.length===0?e.createElement(e.Fragment,null,e.createElement("p",null,"This Event is not configured to trigger any Notifications yet."),c):e.createElement(e.Fragment,null,e.createElement(E.wQ,{id:"event-definition-notifications",className:"table-striped table-hover",headers:["Notification","Type","Actions"],sortByKey:"title",rows:s,dataRowFormatter:this.notificationFormatter,filterKeys:[]}),c)}}dt(Yt,"propTypes",{eventDefinition:a().object.isRequired,notifications:a().array.isRequired,onAddNotificationClick:a().func.isRequired,onRemoveNotificationClick:a().func.isRequired});const ri=Yt;var ct=n("nQKpNrvS"),xe={};xe.styleTagTransform=Xe(),xe.setAttributes=We(),xe.insert=Ge().bind(null,"head"),xe.domAPI=Ue(),xe.insertStyleElement=ze();var Ai=Te()(ct.Z,xe);const si=ct.Z&&ct.Z.locals?ct.Z.locals:void 0;var di=Object.defineProperty,ci=(o,t,i)=>t in o?di(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,yt=(o,t,i)=>(ci(o,typeof t!="symbol"?t+"":t,i),i);class Ht extends e.Component{constructor(){super(),yt(this,"toggleAddNotificationForm",()=>{this.props.sendTelemetry(y.A.EVENTDEFINITION_NOTIFICATIONS.ADD_CLICKED,{app_pathname:(0,T.av)(this.props.location.pathname),app_section:"event-definition-notifications",app_action_value:"add-notification-button"});const{showAddNotificationForm:t}=this.state;this.setState({showAddNotificationForm:!t})}),yt(this,"handleAssignNotification",t=>{const{onChange:i,eventDefinition:r}=this.props,s=J()(r.notifications);s.push({notification_id:t}),i("notifications",s),this.toggleAddNotificationForm()}),yt(this,"handleRemoveNotification",t=>{const{onChange:i,eventDefinition:r}=this.props,s=r.notifications.find(d=>d.notification_id===t),c=Wn()(r.notifications,s);i("notifications",c)}),this.state={showAddNotificationForm:!1}}render(){const{eventDefinition:t,notifications:i,defaults:r,currentUser:s,onChange:c}=this.props,{showAddNotificationForm:d}=this.state,f=t.notifications.map(C=>C.notification_id).filter(C=>!(0,rt.rq)(s.permissions,`eventnotifications:read:${C}`));return f.length>0?e.createElement(l.Row,null,e.createElement(l.Col,{md:6,lg:5},e.createElement(l.Alert,{bsStyle:"warning"},"Missing Notifications Permissions for: ",e.createElement("br",null)," ",f.join(", ")))):d?e.createElement(Jn,{notifications:i,onChange:this.handleAssignNotification,onCancel:this.toggleAddNotificationForm,hasCreationPermissions:(0,rt.rq)(s.permissions,"eventnotifications:create")}):e.createElement(l.Row,null,e.createElement(l.Col,{md:6,lg:5},e.createElement("span",{className:si.manageNotifications},e.createElement(zn.J,{to:q.ZP.ALERTS.NOTIFICATIONS.LIST,target:"_blank"},e.createElement(l.Button,{bsStyle:"link",bsSize:"small"},"Manage Notifications ",e.createElement(E.JO,{name:"external-link-alt"})))),e.createElement("h2",{className:$.Z.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(ri,{eventDefinition:t,notifications:i,onAddNotificationClick:this.toggleAddNotificationForm,onRemoveNotificationClick:this.handleRemoveNotification}),e.createElement(oi,{eventDefinition:t,defaults:r,onSettingsChange:c})))}}Ht.propTypes={eventDefinition:a().object.isRequired,notifications:a().array.isRequired,defaults:a().object.isRequired,currentUser:a().object.isRequired,onChange:a().func.isRequired,sendTelemetry:a().func.isRequired,location:a().object.isRequired};const mi=(0,tt.Z)((0,et.Z)(Ht));var ui=n("XirFL5dA");const Y=["event-details","condition","fields","notifications","summary"],pi=[y.A.EVENTDEFINITION_DETAILS.STEP_CLICKED,y.A.EVENTDEFINITION_CONDITION.STEP_CLICKED,y.A.EVENTDEFINITION_FIELDS.STEP_CLICKED,y.A.EVENTDEFINITION_NOTIFICATIONS.STEP_CLICKED,y.A.EVENTDEFINITION_SUMMARY.STEP_CLICKED],fi=o=>o===void 0?{displayName:null}:v.G.exports("eventDefinitionTypes").find(t=>t.type===o)||{},vi=Ie.default.div`
margin-bottom: 10px;
`,Ct=({action:o,eventDefinition:t,currentUser:i,validation:r,entityTypes:s,notifications:c,defaults:d,onChange:m,onCancel:f,onSubmit:C})=>{const{step:I}=(0,be.Z)(),[L,ee]=(0,e.useState)(I||Y[0]),te=(0,h.Z)(),{pathname:H}=(0,k.Z)(),Z=(0,Ee.Z)();(0,e.useEffect)(()=>{const _=new(R())(window.location.href);if(u().parse(_.query()).step!==L){const Ke=_.removeSearch("step").addQuery("step",L);te.replace(Ke.resource())}},[L,te]);const G=_=>{_&&_.preventDefault(),L===he()(Y)&&C()},N={key:t.id,action:o,entityTypes:s,eventDefinition:t,onChange:m,validation:r,currentUser:i},B=fi(t.config.type),U=[{key:Y[0],title:"Event Details",component:e.createElement(O,{...N})},{key:Y[1],title:ae()(B.displayName,"Condition"),component:e.createElement(tn,{...N})},{key:Y[2],title:"Fields",component:e.createElement(Un,{...N})},{key:Y[3],title:"Notifications",component:e.createElement(mi,{...N,notifications:c,defaults:d})},{key:Y[4],title:"Summary",component:e.createElement(ui.Z,{eventDefinition:t,currentUser:i,notifications:c,validation:r})}],ne=_=>{Z(pi[Y.indexOf(_)],{app_pathname:(0,T.av)(H),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"event-definition-step",current_step:U[Y.indexOf(L)].title}),ee(_)},se=()=>{if(L===he()(Y))return e.createElement(E.os,{onCancel:f,onSubmit:G,submitButtonText:`${t.id?"Update":"Create"} event definition`});const _=Y.indexOf(L),ue=()=>{Z(y.A.EVENTDEFINITION_PREVIOUS_CLICKED,{app_pathname:(0,T.av)(H),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"previous-button",current_step:U[_].title});const ke=_>0?Y[_-1]:void 0;ee(ke)},Ke=()=>{Z(y.A.EVENTDEFINITION_NEXT_CLICKED,{app_pathname:(0,T.av)(H),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"next-button",current_step:U[_].title});const ke=Y[_+1];ee(ke)};return e.createElement("div",null,e.createElement(l.Button,{bsStyle:"info",onClick:ue,disabled:_===0},"Previous"),e.createElement("div",{className:"pull-right"},e.createElement(l.Button,{bsStyle:"info",onClick:Ke},"Next")))};return e.createElement(l.Row,null,e.createElement(l.Col,{md:12},e.createElement(vi,null,e.createElement(E.en,{steps:U,activeStep:L,onStepChange:ne,horizontal:!0,justified:!0,containerClassName:"",hidePreviousNextButtons:!0})),se()))};Ct.propTypes={action:a().oneOf(["create","edit"]),eventDefinition:a().object.isRequired,currentUser:a().object.isRequired,validation:a().object.isRequired,entityTypes:a().object.isRequired,notifications:a().array.isRequired,defaults:a().object.isRequired,onChange:a().func.isRequired,onCancel:a().func.isRequired,onSubmit:a().func.isRequired},Ct.defaultProps={action:"edit"};const Ei=Ct,hi=()=>{Pe.e.listAll()},gi=o=>o===void 0?{}:v.G.exports("eventDefinitionTypes").find(t=>t.type===o)||{},Tt=({action:o,eventDefinition:t,onEventDefinitionChange:i})=>{const[r,s]=(0,e.useState)(t),[c,d]=(0,e.useState)({errors:{}}),[m,f]=(0,e.useState)(void 0),[C,I]=(0,e.useState)(!1),{configFromLocalStorage:L,hasLocalStorageConfig:ee}=je(),te=(0,de.o)(fe),H=(0,de.o)(Pe.O),Z=(0,Q.Z)(),G=(0,D.useNavigate)(),{pathname:N}=(0,k.Z)(),B=(0,Ee.Z)(),U=!te||!H.all||!m,ne={default_backlog_size:m==null?void 0:m.events_notification_default_backlog},se=(0,e.useCallback)(()=>{me.h.listEventsClusterConfig().then(ie=>f(ie))},[]),_=(0,e.useCallback)((ie,z)=>{s(Nt=>({...Nt,[ie]:z})),i({...r,[ie]:z}),I(!0)},[r,i,s,I]);(0,e.useEffect)(()=>{if(se(),hi(),ee){const ie=gi(L.type),z=(ie==null?void 0:ie.defaultConfig)||{};s(Nt=>{const Jt=J()(Nt);return{...Jt,config:{...z,...Jt.config,...L}}})}},[L,se,ee]);const ue=()=>{I(!1),G(q.ZP.ALERTS.DEFINITIONS.LIST)},Ke=ie=>{const{body:z}=ie.additional;if(ie.status===400){if(z&&z.failed){d(z);return}if(z.type&&z.type==="ApiError"){if(z.message.includes("org.graylog.events.conditions.Expression")||z.message.includes("org.graylog.events.conditions.Expr")||z.message.includes("org.graylog.events.processor.aggregation.AggregationSeries")){d({errors:{conditions:["Aggregation condition is not valid"]}});return}z.message.includes("embryonic")&&d({errors:{query_parameters:["Query parameters must be declared"]}})}}},ke=()=>{o==="create"?(B(y.A.EVENTDEFINITION_SUMMARY.CREATE_CLICKED,{app_pathname:(0,T.av)(N),app_section:"new-event-definition",app_action_value:"create-event-definition-button"}),Se.y.create(r).then(ue,Ke)):(B(y.A.EVENTDEFINITION_SUMMARY.UPDATE_CLICKED,{app_pathname:(0,T.av)(N),app_section:"edit-event-definition",app_action_value:"update-event-definition-button"}),Se.y.update(r.id,r).then(ue,Ke))},Ci=()=>{B(y.A.EVENTDEFINITION_SUMMARY.CANCEL_CLICKED,{app_pathname:(0,T.av)(N),app_section:o==="create"?"new-event-definition":"edit-event-definition",app_action_value:"cancel-button"}),G(q.ZP.ALERTS.DEFINITIONS.LIST)};return U?e.createElement(E.$j,{text:"Loading Event information..."}):e.createElement(e.Fragment,null,C&&e.createElement(E.oU,{question:"Do you really want to abandon this page and lose your changes? This action cannot be undone."}),e.createElement(Ei,{action:o,eventDefinition:r,currentUser:Z,validation:c,entityTypes:te,notifications:H.all,defaults:ne,onChange:_,onCancel:Ci,onSubmit:ke}))};Tt.propTypes={action:a().oneOf(["create","edit"]),eventDefinition:a().object,onEventDefinitionChange:a().func},Tt.defaultProps={action:"edit",eventDefinition:{title:"",description:"",priority:ce.Z.NORMAL,config:{},field_spec:{},key_spec:[],notification_settings:{grace_period_ms:3e5,backlog_size:null},notifications:[],alert:!1},onEventDefinitionChange:()=>{}};const yi=Tt},XirFL5dA:(M,A,n)=>{"use strict";n.d(A,{Z:()=>R});var e=n("Z7aTuO5B"),b=n("ii0bleBb"),a=n.n(b),D=n("Dg7SLLbb"),v=n.n(D),V=n("QL8i6bcz"),J=n("9oVghaOd"),q=n.n(J),de=n("gtXNkEXl"),ce=n("4E3oowBb"),E=n("uZqmR+ju"),Me=n("0TVxnHwi"),pe=n("Dh8G0fI8"),T=n("9O66OgQd");const j=({validation:p})=>{const u=Object.keys(p.errors);return u.length===0?null:e.createElement(E.Row,null,e.createElement(E.Col,{md:12},e.createElement(E.Alert,{bsStyle:"danger",className:T.Z.validationSummary,title:"We found some errors!"},e.createElement("p",null,"Please correct the following errors before saving this Event Definition:"),e.createElement("ul",null,u.map(l=>p.errors[l].map(h=>{const F=l==="config"?h.replace("config","condition"):h;return e.createElement("li",{key:`${l}-${F}`},F)}))))))};j.propTypes={validation:a().object},j.defaultProps={validation:{errors:[]}};const Fe=j;var Ve=n("dFpwyWHg"),fe=n.n(Ve),me=n("C2ikvoS0"),Se=n.n(me),Pe=n("1IntWRSu"),$e=n.n(Pe),Q=n("8nGWeFnd"),ve=n.n(Q),be=n("TeAcaicX"),Ae=n.n(be),je=n("eE3+5goe"),Ee=n.n(je),k=n("uCppV7l0"),y={};y.styleTagTransform=Ee(),y.setAttributes=ve(),y.insert=$e().bind(null,"head"),y.domAPI=Se(),y.insertStyleElement=Ae();var oe=fe()(k.Z,y);const he=k.Z&&k.Z.locals?k.Z.locals:void 0;var ge=n("IFFKjdia"),ae=n("+BJjAwAf"),Ie=n("ava0cCRK");const ye=({eventDefinition:p,notifications:u,validation:l,currentUser:h})=>{const[F,S]=(0,e.useState)(!1);(0,e.useEffect)(()=>{(()=>{F||S(!0)})()},[F,S]);const x=()=>e.createElement(e.Fragment,null,e.createElement("h3",{className:T.Z.title},"Details"),e.createElement("dl",null,e.createElement("dt",null,"Title"),e.createElement("dd",null,p.title||"No title given"),e.createElement("dt",null,"Description"),e.createElement("dd",null,p.description||"No description given"),e.createElement("dt",null,"Priority"),e.createElement("dd",null,v()(pe.Z.properties[p.priority].name)))),X=(g,P)=>P===void 0?{}:V.G.exports(g).find(O=>O.type===P)||{},W=g=>{const P=X("eventDefinitionTypes",g.type),O=P.summaryComponent?e.createElement(P.summaryComponent,{config:g,currentUser:h}):e.createElement("p",null,"Condition plugin ",e.createElement("em",null,g.type)," does not provide a summary.");return e.createElement(e.Fragment,null,e.createElement("h3",{className:T.Z.title},P.displayName||g.type),O)},De=(g,P,O)=>{if(!P.providers||P.providers.length===0)return e.createElement("span",{key:g},"No field value provider configured.");const K=P.providers[0]||{},Oe=X("fieldValueProviders",K.type);return Oe.summaryComponent?e.createElement(Oe.summaryComponent,{fieldName:g,config:P,keys:O,key:g,currentUser:h}):e.createElement("p",{key:g},"Provider plugin ",e.createElement("em",null,K.type)," does not provide a summary.")},Ze=(g,P,O)=>e.createElement(e.Fragment,null,e.createElement("dl",null,e.createElement("dt",null,"Keys"),e.createElement("dd",null,O.length>0?O.join(", "):"No Keys configured for Events based on this Definition.")),g.sort(ce.S).map(K=>De(K,P[K],O))),we=(g,P)=>{const O=Object.keys(g);return e.createElement(e.Fragment,null,e.createElement("h3",{className:T.Z.title},"Fields"),O.length===0?e.createElement("p",null,"No Fields configured for Events based on this Definition."):Ze(O,g,P))},mt=g=>{const P=u.find(K=>K.id===g.notification_id);let O;if(P){const K=X("eventNotificationTypes",P.config.type);O=K.summaryComponent?e.createElement(K.summaryComponent,{type:K.displayName,notification:P,definitionNotification:g}):e.createElement("p",null,"Notification plugin ",e.createElement("em",null,P.config.type)," does not provide a summary.")}else O=e.createElement("p",null,"Could not find information for Notification ",e.createElement("em",null,g.notification_id),".");return e.createElement(e.Fragment,{key:g.notification_id},O)},ut=g=>{const P=q().duration(g.grace_period_ms).format("d [days] h [hours] m [minutes] s [seconds]",{trim:"all"}),O=g.grace_period_ms?`Grace Period is set to ${P}`:"Grace Period is disabled",K=g.backlog_size?`Notifications will include ${g.backlog_size} messages`:"Notifications will not include any messages.";return e.createElement(e.Fragment,null,e.createElement("h4",null,"Settings"),e.createElement("dl",null,e.createElement("dd",null,O),e.createElement("dd",null,K)))},le=(g,P)=>{const O=g.filter(Ce=>(0,Me.rq)(h.permissions,`eventnotifications:read:${Ce.notification_id}`)),K=g.filter(Ce=>!O.map(Te=>Te.notification_id).includes(Ce.notification_id)),Oe=K.length>0?e.createElement(E.Alert,{bsStyle:"warning"},"Missing Notifications Permissions for:",e.createElement("br",null),K.map(Ce=>Ce.notification_id).join(", ")):null;return e.createElement(e.Fragment,null,e.createElement("h3",{className:T.Z.title},"Notifications"),e.createElement("p",null,Oe),O.length===0&&K.length<=0?e.createElement("p",null,"This Event is not configured to trigger any Notifications."):e.createElement(e.Fragment,null,ut(P),g.map(mt)))},$=p.config.type===ge.Qk;return e.createElement(E.Row,{className:he.eventSummary},e.createElement(E.Col,{md:12},e.createElement("h2",{className:T.Z.title},"Event Summary"),F&&e.createElement(Fe,{validation:l}),e.createElement(E.Row,null,e.createElement(E.Col,{md:5},x()),!$&&e.createElement(E.Col,{md:5,mdOffset:1},W(p.config))),e.createElement(E.Row,null,!$&&e.createElement(E.Col,{md:5},we(p.field_spec,p.key_spec)),e.createElement(E.Col,{md:5,mdOffset:$?0:1},le(p.notifications,p.notification_settings)))))};ye.propTypes={eventDefinition:a().object.isRequired,notifications:a().array.isRequired,validation:a().object,currentUser:a().object.isRequired},ye.defaultProps={validation:void 0};const R=ye},"42lc8BRs":(M,A,n)=>{"use strict";n.d(A,{Z:()=>ye});var e=n("Z7aTuO5B"),b=n("ii0bleBb"),a=n.n(b),D=n("VZ0CjfW1"),v=n.n(D),V=n("IW7priiX"),J=n.n(V),q=n("/GOzvPf6"),de=n("d4kzUuQm"),ce=n("J7MaobQD"),E=n("N6x7vnl1"),Me=n("/yh+QgO6"),pe=n.n(Me),T=n("QL8i6bcz"),j=n("uZqmR+ju"),Fe=n("S6FuRS7B"),Ve=n("BqxuktKK"),fe=n("MdYBRjRJ"),me=n("v4GbOr/o"),Se=n("HCsT5Gmk"),Pe=Object.defineProperty,$e=(R,p,u)=>p in R?Pe(R,p,{enumerable:!0,configurable:!0,writable:!0,value:u}):R[p]=u,Q=(R,p,u)=>($e(R,typeof p!="symbol"?p+"":p,u),u);const ve=R=>R===void 0?{}:T.G.exports("eventNotificationTypes").find(p=>p.type===R)||{},be=()=>T.G.exports("eventNotificationTypes").map(R=>({label:R.displayName,value:R.type}));class Ae extends e.Component{constructor(p){super(p),Q(this,"setIsSubmitEnabled",u=>{this.setState({isSubmitEnabled:u})}),Q(this,"handleSubmit",u=>{const{notification:l,onSubmit:h,sendTelemetry:F,action:S,location:x}=this.props;F(S==="create"?me.A.NOTIFICATIONS.CREATE_CLICKED:me.A.NOTIFICATIONS.EDIT_CLICKED,{app_pathname:(0,fe.av)(x.pathname),app_section:"event-notification",app_action_value:`${S}-button`}),u.preventDefault(),h(l)}),Q(this,"handleChange",u=>{const{name:l}=u.target,{onChange:h}=this.props;h(l,(0,Fe.n6)(u.target))}),Q(this,"handleConfigChange",u=>{const{onChange:l}=this.props;l("config",u)}),Q(this,"handleTypeChange",u=>{const{sendTelemetry:l,location:h}=this.props;l(me.A.EVENTDEFINITION_NOTIFICATIONS.NOTIFICATION_TYPE_SELECTED,{app_pathname:(0,fe.av)(h.pathname),app_section:"event-definition-notifications",app_action_value:"notification-type-select",notification_type:u});const S=ve(u).defaultConfig||{};this.handleConfigChange({...S,type:u})}),Q(this,"handleTestTrigger",()=>{const{notification:u,onTest:l,sendTelemetry:h,location:F}=this.props;h(me.A.NOTIFICATIONS.EXECUTE_TEST_CLICKED,{app_pathname:(0,fe.av)(F.pathname),app_section:"event-notification",app_action_value:"execute-test-button"}),l(u)}),this.state={isSubmitEnabled:!0}}render(){const{action:p,embedded:u,formId:l,notification:h,onCancel:F,validation:S,testResult:x}=this.props,{isSubmitEnabled:X}=this.state,W=ve(h.config.type),De=W.formComponent?e.createElement(W.formComponent,{config:h.config,onChange:this.handleConfigChange,validation:S,setIsSubmitEnabled:this.setIsSubmitEnabled}):null,Ze=x.isLoading?e.createElement(q.$j,{text:"Testing..."}):"Execute Test Notification";return e.createElement(j.Row,null,e.createElement(j.Col,{lg:8},e.createElement("form",{onSubmit:this.handleSubmit,id:l},e.createElement(j.Input,{id:"notification-title",name:"title",label:"Title",type:"text",bsStyle:S.errors.title?"error":null,help:pe()(S,"errors.title[0]","Title to identify this Notification."),value:h.title,onChange:this.handleChange,required:!0,autoFocus:!0}),e.createElement(j.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:h.description,onChange:this.handleChange,rows:2}),e.createElement(j.FormGroup,{controlId:"notification-type",validationState:S.errors.config?"error":null},e.createElement(j.ControlLabel,null,"Notification Type"),e.createElement(q.Ph,{id:"notification-type",options:be(),value:h.config.type,onChange:this.handleTypeChange,clearable:!1,required:!0}),e.createElement(j.HelpBlock,null,pe()(S,"errors.config[0]","Choose the type of Notification to create."))),De,De&&e.createElement(j.FormGroup,null,e.createElement(j.ControlLabel,null,"Test Notification ",e.createElement("small",{className:"text-muted"},"(Optional)")),e.createElement(j.FormControl.Static,null,e.createElement(j.Button,{bsStyle:"info",bsSize:"small",disabled:x.isLoading,onClick:this.handleTestTrigger},Ze)),x.message&&e.createElement(j.Alert,{bsStyle:x.error?"danger":"success",title:x.error?"Error: ":"Success: "},x.message),e.createElement(j.HelpBlock,null,"Execute this Notification with a test Alert.")),!u&&e.createElement(q.Ow,{disabledSubmit:!X,submitButtonText:`${p==="create"?"Create":"Update"} notification`,onCancel:F}))))}}Q(Ae,"propTypes",{action:a().oneOf(["create","edit"]),notification:a().object.isRequired,validation:a().object.isRequired,testResult:a().shape({isLoading:a().bool,error:a().bool,message:a().string}).isRequired,formId:a().string,embedded:a().bool.isRequired,onChange:a().func.isRequired,onCancel:a().func.isRequired,onSubmit:a().func.isRequired,onTest:a().func.isRequired,sendTelemetry:a().func.isRequired,location:a().object.isRequired}),Q(Ae,"defaultProps",{action:"edit",formId:void 0});const je=(0,Se.Z)((0,Ve.Z)(Ae));var Ee=n("ava0cCRK"),k=Object.defineProperty,y=(R,p,u)=>p in R?k(R,p,{enumerable:!0,configurable:!0,writable:!0,value:u}):R[p]=u,oe=(R,p,u)=>(y(R,typeof p!="symbol"?p+"":p,u),u);const he={errors:{}},ge={isLoading:!1},ae=class Pt extends e.Component{constructor(p){super(p),oe(this,"handleChange",(u,l)=>{const{notification:h}=this.state,F=J()(h);F[u]=l,this.setState({notification:F,isDirty:!0,testResult:ge})}),oe(this,"handleCancel",()=>{const{history:u}=this.props;u.push(de.ZP.ALERTS.NOTIFICATIONS.LIST)}),oe(this,"handleSubmit",()=>{const{action:u,embedded:l,onSubmit:h,history:F}=this.props,{notification:S}=this.state;let x;u==="create"?(x=ce.e.create(S),x.then(()=>{this.setState({isDirty:!1},()=>{l||F.push(de.ZP.ALERTS.NOTIFICATIONS.LIST)})},X=>{const{body:W}=X.additional;X.status===400&&W&&W.failed&&(this.setState({validation:W}),Pt.scrollToFirstError())})):(x=ce.e.update(S.id,S),x.then(()=>{this.setState({isDirty:!1},()=>{l||F.push(de.ZP.ALERTS.NOTIFICATIONS.LIST)})},X=>{const{body:W}=X.additional;X.status===400&&W&&W.failed&&(this.setState({validation:W}),Pt.scrollToFirstError())})),h(x)}),oe(this,"handleTest",()=>{const{notification:u}=this.state;this.setState({testResult:{isLoading:!0},validation:he});const l=v()(ge);this.testPromise=ce.e.test(u),this.testPromise.then(h=>(l.error=!1,l.message="Notification was executed successfully.",h),h=>{l.error=!0;const{body:F}=h.additional;h.status===400&&F&&F.failed?(l.message="Validation failed, please correct any errors in the form before continuing.",this.setState({validation:F})):l.message=h.responseMessage||"Unknown error, please check your Graylog server logs."}).finally(()=>{this.setState({testResult:l}),this.testPromise=void 0})}),this.state={notification:p.notification,validation:he,testResult:ge,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:p,embedded:u,formId:l}=this.props,{notification:h,validation:F,testResult:S,isDirty:x}=this.state;return e.createElement(e.Fragment,null,!u&&x&&e.createElement(q.oU,{question:"Do you really want to abandon this page and lose your changes? This action cannot be undone."}),e.createElement(je,{action:p,notification:h,validation:F,testResult:S,formId:l,embedded:u,onChange:this.handleChange,onCancel:this.handleCancel,onSubmit:this.handleSubmit,onTest:this.handleTest}))}};oe(ae,"propTypes",{action:a().oneOf(["create","edit"]),notification:a().object,embedded:a().bool,formId:a().string,onSubmit:a().func,history:a().object.isRequired}),oe(ae,"defaultProps",{action:"edit",notification:{title:"",description:"",config:{}},embedded:!1,formId:void 0,onSubmit:()=>{}});let Ie=ae;const ye=(0,E.Z)(Ie)},Dh8G0fI8:(M,A,n)=>{"use strict";n.d(A,{Z:()=>b});const b={LOW:1,NORMAL:2,HIGH:3,properties:{1:{name:"low"},2:{name:"normal"},3:{name:"high"}}}},N6x7vnl1:(M,A,n)=>{"use strict";n.d(A,{Z:()=>D});var e=n("Z7aTuO5B"),b=n("/7OuCFNo");const D=v=>V=>{const J=(0,b.Z)();return e.createElement(v,{...V,history:J})}},VZ0CjfW1:(M,A,n)=>{var e=n("8U3oBBH1"),b=4;function a(D){return e(D,b)}M.exports=a}}]);})();
//# sourceMappingURL=07ba022f-539.8a4e25b6f1de6dd54742.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy