Local modifications to ClusterLabs/Anvil by Alteeve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1 lines
25 KiB

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[249],{88668:function(e,r,n){var t=n(83369),i=n(90619),a=n(72385);function SetCache(e){var r=-1,n=null==e?0:e.length;for(this.__data__=new t;++r<n;)this.add(e[r])}SetCache.prototype.add=SetCache.prototype.push=i,SetCache.prototype.has=a,e.exports=SetCache},82908:function(e){e.exports=function(e,r){for(var n=-1,t=null==e?0:e.length;++n<t;)if(r(e[n],n,e))return!0;return!1}},90939:function(e,r,n){var t=n(21299),i=n(37005);e.exports=function baseIsEqual(e,r,n,a,l){return e===r||(null!=e&&null!=r&&(i(e)||i(r))?t(e,r,n,a,baseIsEqual,l):e!=e&&r!=r)}},21299:function(e,r,n){var t=n(46384),i=n(67114),a=n(18351),l=n(16096),s=n(64160),o=n(1469),u=n(44144),d=n(36719),c="[object Arguments]",m="[object Array]",h="[object Object]",p=Object.prototype.hasOwnProperty;e.exports=function(e,r,n,v,g,f){var x=o(e),j=o(r),Z=x?m:s(e),b=j?m:s(r);Z=Z==c?h:Z,b=b==c?h:b;var M=Z==h,y=b==h,_=Z==b;if(_&&u(e)){if(!u(r))return!1;x=!0,M=!1}if(_&&!M)return f||(f=new t),x||d(e)?i(e,r,n,v,g,f):a(e,r,Z,n,v,g,f);if(!(1&n)){var C=M&&p.call(e,"__wrapped__"),A=y&&p.call(r,"__wrapped__");if(C||A){var w=C?e.value():e,O=A?r.value():r;return f||(f=new t),g(w,O,n,v,f)}}return!!_&&(f||(f=new t),l(e,r,n,v,g,f))}},74757:function(e){e.exports=function(e,r){return e.has(r)}},67114:function(e,r,n){var t=n(88668),i=n(82908),a=n(74757);e.exports=function(e,r,n,l,s,o){var u=1&n,d=e.length,c=r.length;if(d!=c&&!(u&&c>d))return!1;var m=o.get(e),h=o.get(r);if(m&&h)return m==r&&h==e;var p=-1,v=!0,g=2&n?new t:void 0;for(o.set(e,r),o.set(r,e);++p<d;){var f=e[p],x=r[p];if(l)var j=u?l(x,f,p,r,e,o):l(f,x,p,e,r,o);if(void 0!==j){if(j)continue;v=!1;break}if(g){if(!i(r,function(e,r){if(!a(g,r)&&(f===e||s(f,e,n,l,o)))return g.push(r)})){v=!1;break}}else if(!(f===x||s(f,x,n,l,o))){v=!1;break}}return o.delete(e),o.delete(r),v}},18351:function(e,r,n){var t=n(62705),i=n(11149),a=n(77813),l=n(67114),s=n(68776),o=n(21814),u=t?t.prototype:void 0,d=u?u.valueOf:void 0;e.exports=function(e,r,n,t,u,c,m){switch(n){case"[object DataView]":if(e.byteLength!=r.byteLength||e.byteOffset!=r.byteOffset)break;e=e.buffer,r=r.buffer;case"[object ArrayBuffer]":if(e.byteLength!=r.byteLength||!c(new i(e),new i(r)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return a(+e,+r);case"[object Error]":return e.name==r.name&&e.message==r.message;case"[object RegExp]":case"[object String]":return e==r+"";case"[object Map]":var h=s;case"[object Set]":var p=1&t;if(h||(h=o),e.size!=r.size&&!p)break;var v=m.get(e);if(v)return v==r;t|=2,m.set(e,r);var g=l(h(e),h(r),t,u,c,m);return m.delete(e),g;case"[object Symbol]":if(d)return d.call(e)==d.call(r)}return!1}},16096:function(e,r,n){var t=n(58234),i=Object.prototype.hasOwnProperty;e.exports=function(e,r,n,a,l,s){var o=1&n,u=t(e),d=u.length;if(d!=t(r).length&&!o)return!1;for(var c=d;c--;){var m=u[c];if(!(o?m in r:i.call(r,m)))return!1}var h=s.get(e),p=s.get(r);if(h&&p)return h==r&&p==e;var v=!0;s.set(e,r),s.set(r,e);for(var g=o;++c<d;){var f=e[m=u[c]],x=r[m];if(a)var j=o?a(x,f,m,r,e,s):a(f,x,m,e,r,s);if(!(void 0===j?f===x||l(f,x,n,a,s):j)){v=!1;break}g||(g="constructor"==m)}if(v&&!g){var Z=e.constructor,b=r.constructor;Z!=b&&"constructor"in e&&"constructor"in r&&!("function"==typeof Z&&Z instanceof Z&&"function"==typeof b&&b instanceof b)&&(v=!1)}return s.delete(e),s.delete(r),v}},68776:function(e){e.exports=function(e){var r=-1,n=Array(e.size);return e.forEach(function(e,t){n[++r]=[t,e]}),n}},90619:function(e){e.exports=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}},72385:function(e){e.exports=function(e){return this.__data__.has(e)}},21814:function(e){e.exports=function(e){var r=-1,n=Array(e.size);return e.forEach(function(e){n[++r]=e}),n}},18446:function(e,r,n){var t=n(90939);e.exports=function(e,r){return t(e,r)}},24084:function(e,r,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/mail-config",function(){return n(94116)}])},7576:function(e,r,n){"use strict";var t=n(85893),i=n(67294),a=n(56597),l=n(68917);r.Z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{initial:{actionProceedText:r="",content:n="",titleText:s="",...o}={}}=e,u=(0,i.useRef)(null),[d,c]=(0,i.useState)({actionProceedText:r,content:n,titleText:s}),m=(0,i.useCallback)(e=>c(r=>{let{loading:n,...t}=r;return{...t,loading:e}}),[]),h=(0,i.useCallback)(e=>{var r,n;return null==u?void 0:null===(n=u.current)||void 0===n?void 0:null===(r=n.setOpen)||void 0===r?void 0:r.call(null,e)},[]),p=(0,i.useCallback)((e,r)=>c({actionProceedText:"",content:(0,t.jsx)(l.Z,{...r}),showActionArea:!1,showClose:!0,titleText:e}),[]),v=(0,i.useMemo)(()=>(0,t.jsx)(a.Z,{...o,...d,ref:u}),[d,o]);return{confirmDialog:v,confirmDialogRef:u,setConfirmDialogLoading:m,setConfirmDialogOpen:h,setConfirmDialogProps:c,finishConfirm:p}}},94116:function(e,r,n){"use strict";n.r(r),n.d(r,{default:function(){return mail_config}});var t=n(85893),i=n(48263),a=n(9008),l=n.n(a),s=n(21405),o=n(272),u=n(67294),d=n(25934),c=n(73393),m=n(67645),h=n(55238),p=n(15079),v=n(41247),g=n(16310),f=n(78438);let x=g.Rx().oneOf([0,1,2,3,4]),j=g.Ry({delete:g.O7().optional(),level:x.required(),target:g.Ry({type:g.Z_().oneOf(["node","subnode"]).required(),uuid:g.Z_().uuid().required()}),uuid:g.Z_().uuid().optional()}),Z=g.Vo(e=>g.Ry((0,f.Z)(e,j))),b=g.Ry({alertOverrides:Z,email:g.Z_().email().required(),language:g.Z_().oneOf(["en_CA"]).optional(),level:x.required(),name:g.Z_().required(),uuid:g.Z_().uuid().optional()}),M=g.Vo(e=>g.Ry((0,f.Z)(e,b)));var y=n(89712),_=n(83221),C=n(52886),A=n(84154),w=n(88468);let O=[{displayValue:"Ignore",value:0},{displayValue:"Critical",value:1},{displayValue:"Warning",value:2},{displayValue:"Notice",value:3},{displayValue:"Info",value:4}];var ManageMailRecipient_AlertOverrideInputGroup=e=>{let{alertOverrideTargetOptions:r,alertOverrideValueId:n,mailRecipientUuid:a,formikUtils:l}=e,s=(0,u.useMemo)(()=>null!=n?n:(0,d.Z)(),[n]),{formik:o}=l,{values:{[a]:c}}=o,{alertOverrides:{[s]:m}}=c,p=(0,u.useMemo)(()=>"".concat(a,".alertOverrides.").concat(s),[s,a]),v=(0,u.useMemo)(()=>"".concat(p,".remove"),[p]),g=(0,u.useMemo)(()=>"".concat(p,".target"),[p]),f=(0,u.useMemo)(()=>"".concat(p,".level"),[p]);return(0,t.jsxs)(i.ZP,{alignItems:"center",columns:{xs:1,sm:10},container:!0,justifyContent:"stretch",spacing:"1em",children:[(0,t.jsx)(i.ZP,{item:!0,xs:6,children:(0,t.jsx)(y.Z,{getOptionLabel:e=>e.name,id:g,isOptionEqualToValue:(e,r)=>e.uuid===r.uuid,label:"Target",noOptionsText:"No node or subnode found.",onChange:(e,r)=>o.setFieldValue(g,r,!0),openOnFocus:!0,options:r,renderOption:(e,r)=>(0,u.createElement)("li",{...e,key:"".concat(r.node,"-").concat(r.uuid)},"node"===r.type?(0,t.jsxs)(h.Z,{spacing:0,children:[(0,t.jsx)(A.Ac,{inheritColour:!0,children:r.name}),(0,t.jsx)(A.KI,{inheritColour:!0,children:r.description})]}):(0,t.jsx)(A.Ac,{inheritColour:!0,paddingLeft:".6em",children:r.name})),value:m.target})}),(0,t.jsx)(i.ZP,{item:!0,flexGrow:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(C.Z,{id:f,label:"Alert level",name:f,onChange:o.handleChange,selectItems:O,value:m.level})})}),(0,t.jsx)(i.ZP,{item:!0,width:"min-content",children:(0,t.jsx)(_.Z,{mapPreset:"delete",onClick:()=>{m.uuids?o.setFieldValue(v,!0,!0):o.setValues(e=>{let r={...e},{[a]:n}=r,{[s]:t,...i}=n.alertOverrides;return n.alertOverrides={...i},r})},size:"small"})})]})},S=n(63071),ManageMailRecipient_ManageAlertOverride=e=>{let{alertOverrideTargetOptions:r,formikUtils:n,mailRecipientUuid:i}=e,{formik:a}=n,{values:{[i]:l}}=a,{alertOverrides:s}=l;return(0,t.jsx)(S.Z,{allowAddItem:!0,edit:!0,header:"Alert override rules",listEmpty:"No alert overrides(s)",listItems:s,onAdd:()=>{let e=(0,d.Z)();a.setValues(r=>{let n={...r},{[i]:t}=n;return t.alertOverrides={...t.alertOverrides,[e]:{level:2,target:null}},n})},renderListItem:(e,a)=>!a.remove&&(0,t.jsx)(ManageMailRecipient_AlertOverrideInputGroup,{alertOverrideTargetOptions:r,alertOverrideValueId:e,formikUtils:n,mailRecipientUuid:i})})},F=n(21642),P=n(55675),E=n(82175),R=n(18446),k=n.n(R),I=n(13218),V=n.n(I),q=n(23279),D=n.n(q),lib_debounce=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{wait:n=500,...t}=r;return D()(e,n,t)},L=n(43799);let isChainEqual=(e,r,n)=>{let[t,...i]=e;if(!(t in r))return!1;let a=r[t],l=n[t];return V()(a)&&V()(l)&&i.length?isChainEqual(i,a,l):!k()(a,l)};var hooks_useFormikUtils=e=>{let r=(0,E.TA)({...e}),n=(0,u.useCallback)(e=>{let n=e.split(".");return isChainEqual(n,r.values,r.initialValues)},[r.initialValues,r.values]),t=(0,u.useCallback)(e=>({readOnly:!0,onFocus:e=>{e.target.readOnly=!1},...e}),[]),i=(0,u.useMemo)(()=>lib_debounce(r.handleChange),[r.handleChange]),a=(0,u.useMemo)(()=>!r.dirty||!r.isValid||r.isValidating||r.isSubmitting,[r.dirty,r.isSubmitting,r.isValid,r.isValidating]),l=(0,u.useMemo)(()=>(0,L.Z)(r.errors,{skip:e=>!n(e)}),[r.errors,n]);return{disableAutocomplete:t,disabledSubmit:a,formik:r,formikErrors:l,handleChange:i}};let U=[{displayValue:(0,t.jsxs)(h.Z,{spacing:0,children:[(0,t.jsx)(A.Ac,{inheritColour:!0,fontWeight:"inherit",children:"Critical"}),(0,t.jsx)(A.KI,{inheritColour:!0,whiteSpace:"normal",children:"Alerts that could lead to imminent service interruption or unexpected loss of redundancy."})]}),value:1},{displayValue:(0,t.jsxs)(h.Z,{spacing:0,children:[(0,t.jsx)(A.Ac,{inheritColour:!0,fontWeight:"inherit",children:"Warning"}),(0,t.jsx)(A.KI,{inheritColour:!0,whiteSpace:"normal",children:"Alerts that require attention from administrators, such as redundancy loss due to load shedding, hardware in pre-failure, input power loss, temperature anomalies, etc."})]}),value:2},{displayValue:(0,t.jsxs)(h.Z,{spacing:0,children:[(0,t.jsx)(A.Ac,{inheritColour:!0,fontWeight:"inherit",children:"Notice"}),(0,t.jsx)(A.KI,{inheritColour:!0,whiteSpace:"normal",children:"Alerts that are generally safe to ignore, but might provide early warnings of developing issues or insight into system behaviour."})]}),value:3},{displayValue:(0,t.jsxs)(h.Z,{spacing:0,children:[(0,t.jsx)(A.Ac,{inheritColour:!0,fontWeight:"inherit",children:"Info"}),(0,t.jsx)(A.KI,{inheritColour:!0,whiteSpace:"normal",children:"Alerts that are almost always safe to ignore, but may be useful in testing and debugging."})]}),value:4}],B={1:"Critical",2:"Warning",3:"Notice",4:"Info"},getAlertOverrideRequestList=function(e,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"/alert-override",{uuid:t}=e;return t?Object.values(e.alertOverrides).reduce((e,r)=>{let{remove:i,level:a,target:l,uuids:s}=r;if(s&&e.push(...Object.keys(s).map(e=>({method:"delete",url:"".concat(n,"/").concat(e)}))),l&&!i){var o;let r=null!==(o=l.subnodes)&&void 0!==o?o:[l.uuid];e.push(...r.map(e=>({body:{hostUuid:e,level:a,mailRecipientUuid:t},method:"post",url:n})))}return e},[]):[]};var ManageMailRecipient_AddMailRecipientForm=e=>{let{alertOverrideTargetOptions:r,mailRecipientUuid:n,previousFormikValues:a,tools:l}=e,s=(0,u.useMemo)(()=>null!=n?n:(0,d.Z)(),[n]),h=hooks_useFormikUtils({initialValues:null!=a?a:{[s]:{alertOverrides:{},email:"",language:"en_CA",level:2,name:""}},onSubmit:(e,r)=>{let{setSubmitting:n}=r,{[s]:i}=e,o="Add",u=(0,t.jsx)(t.Fragment,{children:"Failed to add mail recipient."}),d="post",c=(0,t.jsx)(t.Fragment,{children:"Mail recipient added."}),h="Add mail recipient with the following?",g="/mail-recipient";a&&(o="Update",u=(0,t.jsx)(t.Fragment,{children:"Failed to update mail server."}),d="put",c=(0,t.jsx)(t.Fragment,{children:"Mail recipient updated."}),h="Update ".concat(i.name," with the following?"),g+="/".concat(s));let{alertOverrides:f,uuid:x,...j}=i;l.confirm.prepare({actionProceedText:o,content:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(p.Z,{entries:j}),(0,t.jsx)(p.Z,{entries:{alertOverrides:Object.entries(f).reduce((e,r)=>{let[n,t]=r;return t.remove||!t.target||(e[n]={level:t.level,name:t.target.name}),e},{})}})]}),onCancelAppend:()=>n(!1),onProceedAppend:async()=>{l.confirm.loading(!0);let handleError=e=>{let r=(0,v.Z)(e);r.children=(0,t.jsxs)(t.Fragment,{children:[u," ",r.children]}),l.confirm.finish("Error",r),n(!1)};m.Z[d](g,j).then(e=>{let{data:r}=e,n={...i};r&&(n.uuid=r.uuid);let t=a&&a[s],o=getAlertOverrideRequestList(n,t).map(e=>m.Z[e.method](e.url,e.body));Promise.all(o).then(()=>{l.confirm.finish("Success",{children:c}),l["post"===d?"add":"edit"].open(!1)}).catch(handleError)}).catch(handleError)},titleText:h}),l.confirm.open(!0)},validationSchema:M}),{disabledSubmit:g,formik:f,formikErrors:x,handleChange:j}=h,Z=(0,u.useMemo)(()=>"".concat(s,".email"),[s]),b=(0,u.useMemo)(()=>"".concat(s,".level"),[s]),y=(0,u.useMemo)(()=>"".concat(s,".name"),[s]);return(0,t.jsxs)(i.ZP,{columns:{xs:1,sm:2},component:"form",container:!0,onSubmit:e=>{e.preventDefault(),f.submitForm()},spacing:"1em",children:[(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:y,label:"Recipient name",name:y,onChange:j,required:!0,value:f.values[s].name})})}),(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:Z,label:"Recipient email",name:Z,onChange:j,required:!0,value:f.values[s].email})})}),(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(C.Z,{id:b,label:"Alert level",name:b,onChange:f.handleChange,required:!0,selectItems:U,selectProps:{MenuProps:{sx:{["& .".concat(o.Z.paper)]:{maxWidth:{md:"60%",lg:"40%"}}}},renderValue:e=>B[e]},value:f.values[s].level})})}),(0,t.jsx)(i.ZP,{item:!0,width:"100%",children:(0,t.jsx)(ManageMailRecipient_ManageAlertOverride,{alertOverrideTargetOptions:r,formikUtils:h,mailRecipientUuid:s})}),(0,t.jsx)(i.ZP,{item:!0,width:"100%",children:(0,t.jsx)(F.Z,{count:1,messages:x})}),(0,t.jsx)(i.ZP,{item:!0,width:"100%",children:(0,t.jsx)(c.Z,{actions:[{background:"blue",children:a?"Update":"Add",disabled:g,type:"submit"}]})})]})},T=n(48882),H=n(56211),N=n(6903),W=n(32576),z=n(7576),K=n(67978);let reduceHeader=function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return"function"==typeof e?e(...n):e};var components_CrudList=function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];let[i]=r,{addHeader:a,editHeader:l,entriesUrl:s,getAddLoading:o,getDeleteErrorMessage:d,getDeleteHeader:c,getDeletePromiseChain:h=function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return e(...n)},getDeleteSuccessMessage:p,getEditLoading:g=e=>e,listEmpty:f,listProps:x,onItemClick:j=function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return e(...n)},refreshInterval:Z=5e3,renderAddForm:b,renderDeleteItem:M,renderEditForm:y,renderListItem:_}=i,C=(0,u.useRef)(null),A=(0,u.useRef)(null),{confirmDialog:w,finishConfirm:O,setConfirmDialogLoading:F,setConfirmDialogOpen:P,setConfirmDialogProps:E}=(0,z.Z)({initial:{scrollContent:!0}}),[R,k]=(0,u.useState)(!1),[I,V]=(0,u.useState)(),[q,D]=(0,u.useState)(),{loading:L}=(0,K.Z)(s,{onSuccess:e=>D(e),refreshInterval:Z}),{fetch:U,loading:B}=(0,N.Z)({onData:e=>D(e),url:s}),{fetch:T,loading:G}=(0,N.Z)({onData:e=>V(e),url:s}),J=(0,u.useMemo)(()=>reduceHeader(a),[a]),X=(0,u.useMemo)(()=>reduceHeader(l,I),[I,l]),Q=(0,u.useMemo)(()=>({add:{open:function(){var e;let r=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return null==C?void 0:null===(e=C.current)||void 0===e?void 0:e.setOpen(r)}},confirm:{finish:O,loading:F,open:function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return P(e)},prepare:E},edit:{open:function(){var e;let r=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return null==A?void 0:null===(e=A.current)||void 0===e?void 0:e.setOpen(r)}}}),[O,F,P,E]),Y=(0,u.useMemo)(()=>L||B,[B,L]),{buildDeleteDialogProps:$,checks:ee,getCheck:er,hasAllChecks:en,hasChecks:et,multipleItems:ei,resetChecks:ea,setAllChecks:el,setCheck:es}=(0,W.Z)({list:q});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(S.Z,{allowCheckAll:ei,allowEdit:!0,allowItemButton:R,disableDelete:!et,edit:R,getListCheckboxProps:()=>({checked:en,onChange:(e,r)=>el(r)}),getListItemCheckboxProps:e=>({checked:er(e),onChange:(r,n)=>es(e,n)}),header:!0,listEmpty:f,listItems:q,loading:Y,onAdd:()=>{var e;return null==C?void 0:null===(e=C.current)||void 0===e?void 0:e.setOpen(!0)},onDelete:()=>{E($({onProceedAppend:()=>{F(!0),Promise.all(h((e,r)=>e.map(e=>m.Z.delete("".concat(r,"/").concat(e))),ee,s)).then(()=>{O("Success",p()),U()}).catch(e=>{let r=(0,v.Z)(e);O("Error",d(r))}),ea()},getConfirmDialogTitle:c,renderEntry:function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return M(q,...r)}})),P(!0)},onEdit:()=>k(e=>!e),onItemClick:function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];return j((e,r)=>{var n;null==A||null===(n=A.current)||void 0===n||n.setOpen(!0),T("/".concat(r))},...r)},renderListItem:_,...x}),(0,t.jsx)(H.Js,{header:J,loading:null==o?void 0:o.call(null),ref:C,showClose:!0,children:b(Q)}),(0,t.jsx)(H.Js,{header:X,loading:g(G),ref:A,showClose:!0,children:y(Q,I)}),w]})},ManageMailRecipient_EditMailRecipientForm=e=>(0,t.jsx)(ManageMailRecipient_AddMailRecipientForm,{...e}),ManageMailRecipient_ManageMailRecipient=()=>{let[e,r]=(0,u.useState)(),{altData:n,loading:i}=(0,K.Z)("/anvil",{mod:T.Z}),a=(0,u.useMemo)(()=>n&&Object.values(n).sort((e,r)=>e.name.localeCompare(r.name)).reduce((e,r)=>{let n={description:r.description,name:r.name,node:r.uuid,subnodes:[],type:"node",uuid:r.uuid},t=Object.values(r.hosts).sort((e,r)=>e.name.localeCompare(r.name)).reduce((e,t)=>{var i;return"dr"===t.type||(e.push({name:t.name,node:r.uuid,type:"subnode",uuid:t.uuid}),null===(i=n.subnodes)||void 0===i||i.push(t.uuid)),e},[]);return e.push(n,...t),e},[]),[n]),{fetch:l,loading:s}=(0,N.Z)({onData:e=>r(e),url:"/alert-override"}),o=(0,u.useMemo)(()=>{if(!n||!e)return;let r=Object.values(e).reduce((e,r)=>{let{node:{uuid:n}}=r;return e[n]?e[n].push(r):e[n]=[r],e},{});return Object.entries(r).reduce((e,r)=>{let[t,i]=r,[a,...l]=i,s=i.length>1&&l.every(e=>{let{level:r}=e;return r===a.level});if(s){let{0:{level:r}}=i,{[t]:a}=n;e[t]={level:r,target:{description:a.description,name:a.name,node:a.uuid,subnodes:i.map(e=>{let{subnode:{uuid:r}}=e;return r}),type:"node",uuid:a.uuid},uuids:i.reduce((e,r)=>{let{subnode:n,uuid:t}=r;return e[t]=n.uuid,e},{})}}else i.forEach(r=>{let{level:n,node:t,subnode:i,uuid:a}=r;e[i.uuid]={level:n,target:{name:i.name,node:t.uuid,type:"subnode",uuid:i.uuid},uuids:{[a]:i.uuid}}});return e},{})},[e,n]);return(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(components_CrudList,{addHeader:"Add mail recipient",editHeader:e=>"Update ".concat(null==e?void 0:e.name),entriesUrl:"/mail-recipient",getAddLoading:e=>e||i,getDeleteErrorMessage:e=>{let{children:r,...n}=e;return{...n,children:(0,t.jsxs)(t.Fragment,{children:["Failed to delete mail recipient(s). ",r]})}},getDeleteHeader:e=>"Delete the following ".concat(e," mail recipient(s)?"),getDeleteSuccessMessage:()=>({children:(0,t.jsx)(t.Fragment,{children:"Successfully deleted mail recipient(s)."})}),getEditLoading:e=>e||s,listEmpty:"No mail recipient(s) found.",onItemClick:function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];let[,i]=n;e(...n),l(void 0,{params:{"mail-recipient":i}})},renderAddForm:e=>a&&(0,t.jsx)(ManageMailRecipient_AddMailRecipientForm,{alertOverrideTargetOptions:a,tools:e}),renderDeleteItem:(e,r)=>{let{key:n}=r,i=null==e?void 0:e[n];return(0,t.jsx)(A.Ac,{children:null==i?void 0:i.name})},renderEditForm:(e,r)=>a&&r&&o&&(0,t.jsx)(ManageMailRecipient_EditMailRecipientForm,{alertOverrideTargetOptions:a,mailRecipientUuid:r.uuid,previousFormikValues:{[r.uuid]:{alertOverrides:o,...r}},tools:e}),renderListItem:(e,r)=>{let{name:n}=r;return(0,t.jsx)(A.Ac,{children:n})}})})};let G=g.Ry({address:g.Z_().required(),authentication:g.Z_().oneOf(["none","plain-text","encrypted"]),confirmPassword:g.Z_().when("password",(e,r)=>String(e).length>0?r.required().oneOf([g.iH("password")]):r.optional()),heloDomain:g.Z_().required(),password:g.Z_().optional(),port:g.Rx().required(),security:g.Z_().oneOf(["none","starttls","tls-ssl"]),username:g.Z_().optional(),uuid:g.Z_().uuid().required()}),J=g.Vo(e=>g.Ry((0,f.Z)(e,G)));var ManageMailServer_AddMailServerForm=e=>{let{localhostDomain:r="",mailServerUuid:n,previousFormikValues:a,tools:l}=e,s=(0,u.useMemo)(()=>null!=n?n:(0,d.Z)(),[n]),{disableAutocomplete:o,disabledSubmit:h,formik:g,formikErrors:f,handleChange:x}=hooks_useFormikUtils({initialValues:null!=a?a:{[s]:{address:"",authentication:"none",heloDomain:r,port:587,security:"none",uuid:s}},onSubmit:(e,r)=>{let{setSubmitting:n}=r,{[s]:i}=e,o="Add",u=(0,t.jsx)(t.Fragment,{children:"Failed to add mail server."}),d="post",c=(0,t.jsx)(t.Fragment,{children:"Mail server added."}),h="Add mail server with the following?",g="/mail-server";a&&(o="Update",u=(0,t.jsx)(t.Fragment,{children:"Failed to update mail server."}),d="put",c=(0,t.jsx)(t.Fragment,{children:"Mail server updated."}),h="Update ".concat(i.address,":").concat(i.port," with the following?"),g+="/".concat(s));let{confirmPassword:f,uuid:x,...j}=i;l.confirm.prepare({actionProceedText:o,content:(0,t.jsx)(p.Z,{entries:j}),onCancelAppend:()=>n(!1),onProceedAppend:()=>{l.confirm.loading(!0),m.Z[d](g,i).then(()=>{l.confirm.finish("Success",{children:c}),l["post"===d?"add":"edit"].open(!1)}).catch(e=>{let r=(0,v.Z)(e);r.children=(0,t.jsxs)(t.Fragment,{children:[u," ",r.children]}),l.confirm.finish("Error",r),n(!1)})},titleText:h}),l.confirm.open(!0)},validationSchema:J}),j=(0,u.useMemo)(()=>"".concat(s,".address"),[s]),Z=(0,u.useMemo)(()=>"".concat(s,".authentication"),[s]),b=(0,u.useMemo)(()=>"".concat(s,".confirmPassword"),[s]),M=(0,u.useMemo)(()=>"".concat(s,".heloDomain"),[s]),y=(0,u.useMemo)(()=>"".concat(s,".password"),[s]),_=(0,u.useMemo)(()=>"".concat(s,".port"),[s]),A=(0,u.useMemo)(()=>"".concat(s,".security"),[s]),O=(0,u.useMemo)(()=>"".concat(s,".username"),[s]);return(0,t.jsxs)(i.ZP,{component:"form",onSubmit:e=>{e.preventDefault(),g.submitForm()},container:!0,columns:{xs:1,sm:2},spacing:"1em",children:[(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:j,label:"Server address",name:j,onBlur:g.handleBlur,onChange:x,required:!0,value:g.values[s].address})})}),(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:_,label:"Server port",name:_,onBlur:g.handleBlur,onChange:x,required:!0,type:"number",value:g.values[s].port})})}),(0,t.jsx)(i.ZP,{item:!0,sm:2,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(C.Z,{id:A,label:"Server security type",name:A,onBlur:g.handleBlur,onChange:x,required:!0,selectItems:["none","starttls","tls-ssl"],value:g.values[s].security})})}),(0,t.jsx)(i.ZP,{item:!0,sm:2,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(C.Z,{id:Z,label:"Server authentication method",name:Z,onBlur:g.handleBlur,onChange:x,required:!0,selectItems:["none","plain-text","encrypted"],value:g.values[s].authentication})})}),(0,t.jsx)(i.ZP,{item:!0,sm:2,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:M,label:"HELO domain",name:M,onBlur:g.handleBlur,onChange:x,required:!0,value:g.values[s].heloDomain})})}),(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:O,inputProps:o(),label:"Server username",name:O,onBlur:g.handleBlur,onChange:x,value:g.values[s].username})})}),(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:y,inputProps:o(),label:"Server password",name:y,onBlur:g.handleBlur,onChange:x,type:"password",value:g.values[s].password})})}),(0,t.jsx)(i.ZP,{item:!0,xs:1}),(0,t.jsx)(i.ZP,{item:!0,xs:1,children:(0,t.jsx)(w.Z,{input:(0,t.jsx)(P.Z,{id:b,inputProps:o(),label:"Confirm password",name:b,onBlur:g.handleBlur,onChange:x,type:"password",value:g.values[s].confirmPassword})})}),(0,t.jsx)(i.ZP,{item:!0,width:"100%",children:(0,t.jsx)(F.Z,{count:1,messages:f})}),(0,t.jsx)(i.ZP,{item:!0,width:"100%",children:(0,t.jsx)(c.Z,{actions:[{background:"blue",children:a?"Update":"Add",disabled:h,type:"submit"}]})})]})},ManageMailServer_EditMailServerForm=e=>(0,t.jsx)(ManageMailServer_AddMailServerForm,{...e}),ManageMailServer_ManageMailServer=()=>{let{data:e,loading:r}=(0,K.Z)("/host/local");return(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(components_CrudList,{addHeader:"Add mail server",editHeader:e=>"Update ".concat(null==e?void 0:e.address,":").concat(null==e?void 0:e.port),entriesUrl:"/mail-server",getAddLoading:e=>e||r,getDeleteErrorMessage:e=>{let{children:r,...n}=e;return{...n,children:(0,t.jsxs)(t.Fragment,{children:["Failed to delete mail server(s). ",r]})}},getDeleteHeader:e=>"Delete the following ".concat(e," mail server(s)?"),getDeleteSuccessMessage:()=>({children:(0,t.jsx)(t.Fragment,{children:"Successfully deleted mail server(s)."})}),listEmpty:"No mail server(s) found",renderAddForm:r=>e&&(0,t.jsx)(ManageMailServer_AddMailServerForm,{localhostDomain:e.domain,tools:r}),renderDeleteItem:(e,r)=>{let{key:n}=r,i=null==e?void 0:e[n];return(0,t.jsxs)(A.Ac,{children:[null==i?void 0:i.address,":",null==i?void 0:i.port]})},renderEditForm:(e,r)=>r&&(0,t.jsx)(ManageMailServer_EditMailServerForm,{mailServerUuid:r.uuid,previousFormikValues:{[r.uuid]:r},tools:e}),renderListItem:(e,r)=>{let{address:n,port:i}=r;return(0,t.jsxs)(A.Ac,{children:[n,":",i]})}})})},X=n(37260),mail_config=()=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l(),{children:(0,t.jsx)("title",{children:"Mail Config"})}),(0,t.jsx)(s.Z,{}),(0,t.jsxs)(i.ZP,{container:!0,columns:{xs:1,md:6,lg:4},children:[(0,t.jsx)(i.ZP,{item:!0,xs:1}),(0,t.jsx)(i.ZP,{item:!0,xs:1,md:4,lg:2,children:(0,t.jsxs)(X.s_,{children:[(0,t.jsx)(X.V9,{children:(0,t.jsx)(A.z,{children:"Mail config"})}),(0,t.jsx)(X.TZ,{expandInitially:!0,header:"Manage mail servers",children:(0,t.jsx)(ManageMailServer_ManageMailServer,{})}),(0,t.jsx)(X.TZ,{expandInitially:!0,header:"Manage mail recipients",children:(0,t.jsx)(ManageMailRecipient_ManageMailRecipient,{})})]})})]})]})}},function(e){e.O(0,[494,804,416,50,263,213,310,461,264,775,675,633,733,380,774,888,179],function(){return e(e.s=24084)}),_N_E=e.O()}]);