From 5da14042f70711ea5cf66e034699730335462f66 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 14:08:03 +0200 Subject: Merging upstream version 1.45.3+dfsg. Signed-off-by: Daniel Baumann --- src/web/gui/v2/8011.3f8282bb427ea06e9408.chunk.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/web/gui/v2/8011.3f8282bb427ea06e9408.chunk.js (limited to 'src/web/gui/v2/8011.3f8282bb427ea06e9408.chunk.js') diff --git a/src/web/gui/v2/8011.3f8282bb427ea06e9408.chunk.js b/src/web/gui/v2/8011.3f8282bb427ea06e9408.chunk.js new file mode 100644 index 000000000..3650e6f71 --- /dev/null +++ b/src/web/gui/v2/8011.3f8282bb427ea06e9408.chunk.js @@ -0,0 +1 @@ +!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="63d7e3d3-3447-403b-bc85-d272e4dea26d",e._sentryDebugIdIdentifier="sentry-dbid-63d7e3d3-3447-403b-bc85-d272e4dea26d")}catch(e){}}();var _global="undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:{};_global.SENTRY_RELEASE={id:"08864407160b3973b9b88c5ae92687282b21e2f4"},(self.webpackChunkcloud_frontend=self.webpackChunkcloud_frontend||[]).push([[8011],{88011:(e,t,l)=>{l.r(t),l.d(t,{default:()=>se});l(41393),l(81454);var n=l(96540),a=l(10058),o=l(4659),s=l(63450),r=l(58168),i=(l(62953),l(63950)),c=l.n(i),d=l(29217),u=l(78940);const m=e=>{let{scope:t,setScope:l=c(),isDisabled:o,...s}=e;return n.createElement(a.Flex,(0,r.A)({gap:3},s),Object.entries(u.Wu).map((e=>{let[s,{text:r,tooltip:i}]=e;return n.createElement(a.RadioButton,{key:s,checked:s===t,onChange:()=>l(s),disabled:o},n.createElement(d.A,{content:i,align:"bottom"},n.createElement(a.TextSmall,{color:"textDescription"},r)))})))};var p=l(54518),b=l(87659);const g=e=>{let{selectedKey:t,selectedValue:l,onAddHostLabel:o=c(),onRemoveHostLabel:s=c(),isDefault:r=!1,showPlaceholder:i=c(),isDisabled:u}=e;const[m,b]=(0,n.useState)(t||""),[g,h]=(0,n.useState)(l||""),E=()=>{m&&g&&(o({[m]:g}),i())};return n.createElement(a.Flex,{gap:2},n.createElement(p.A,{component:"input",onChange:b,onBlur:E,placeholder:"Host key",value:m,disabled:u||!r}),n.createElement(p.A,{component:"input",onChange:h,onBlur:E,placeholder:"Host value",value:g,disabled:u||!r||!m}),r?n.createElement(d.A,{content:"Save label pair",align:"bottom"},n.createElement(a.Button,{flavour:"borderless",disabled:!m||!g},n.createElement(a.Icon,{name:"check",color:"primary",size:"small"}))):n.createElement(d.A,{content:"Remove label pair",align:"bottom"},n.createElement(a.Button,{flavour:"borderless",onClick:()=>s(t)},n.createElement(a.Icon,{name:"x",color:"primary",size:"small"}))))},h=e=>{let{hostLabels:t,onAddHostLabel:l,onRemoveHostLabel:a}=e;return Object.entries(t).map((e=>{let[t,o]=e;return n.createElement(g,{key:t,onAddHostLabel:l,selectedKey:t,selectedValue:o,onRemoveHostLabel:a})}))},E=e=>{let{hostLabels:t,onAddHostLabel:l=c(),onRemoveHostLabel:o=c(),isEdit:s,isDisabled:r}=e;const i=!!Object.entries(t||{}).length,[d,,u]=(0,b.A)(!1);return n.createElement(a.Flex,{column:!0,gap:1},n.createElement(a.TextSmall,{color:"textLite"},"Host labels"),i&&n.createElement(h,{hostLabels:t,onAddHostLabel:l,onRemoveHostLabel:o}),(!i||d)&&n.createElement(g,{key:JSON.stringify(t),onAddHostLabel:l,isDefault:!0,showPlaceholder:u,isDisabled:r}),s&&!d&&i&&n.createElement(a.Flex,{justifyContent:"end"},n.createElement(a.Button,{flavour:"borderless",onClick:u},"Add host label")))};var v=l(99851);function f(){const e=new Date,t=e.getFullYear(),l=e.getMonth(),n=e.getDate(),a=new Date(0);return a.setFullYear(t,l,n+1),a.setHours(0,0,0,0),a}var C=l(51730),A=l(82526),x=l(27467);const S=Object.entries(u.SB).map((e=>{let[t,l]=e;return{label:l,value:t}})),D=f(),k=(0,C.o)((0,A.W)(D,{years:1})),y=e=>{let{duration:t,setDuration:l,setDate:o,endDate:s,isDisabled:r}=e;const i=(0,x.rW)("offset");return n.createElement(a.Flex,{gap:2},n.createElement(p.A,{component:"select",title:"Duration",onChange:l,options:S,placeholder:"Select duration",value:t,isDisabled:r}),"custom"===t.value&&n.createElement(a.Flex,{alignSelf:"end"},n.createElement(v.A,{isSinglePicker:!0,values:{singleDate:s},minDate:D,maxDate:k,utc:i,onChange:o,isPlaying:!1,accessorProps:u.Iv,padding:[4,0],width:"auto",accessorTooltipContent:"Select end date"})))};function L(){return(0,C.o)(Date.now())}const R=L(),w=f(),O=e=>{let{start:t,end:l,onChange:o,isDisabled:s,isEdit:r}=e;const[i,c]=(0,n.useState)(r?"schedule":u.SX),[m,p]=(0,n.useState)(u.DK),[b,g]=(0,n.useState)(0),h=(0,x.rW)("offset"),[E,S]=(0,n.useState)(t?new Date(t):r?null:R),[D,k]=(0,n.useState)(l?new Date(l):r?null:w),[O,H]=(0,n.useState)((0,C.o)((0,A.W)(E,{days:1})));(0,n.useEffect)((()=>{const e=(0,A.W)(E,{days:1});H(e),!r&&E>=D&&k(e)}),[E]),(0,n.useEffect)((()=>{o({start:E,end:D,scheduleOption:i,duration:m})}),[E,D,i,m]);const I=f(),N=(0,C.o)((0,A.W)(I,{years:1}));return n.createElement(a.Flex,{column:!0,gap:3},!r&&n.createElement(a.Flex,{gap:3},Object.entries(u.Yo).map((e=>{let[t,{text:l,tooltip:o}]=e;return n.createElement(a.RadioButton,{key:t,checked:t===i,onChange:()=>c(t),disabled:s},n.createElement(d.A,{content:o,align:"bottom"},n.createElement(a.TextSmall,{color:"textDescription"},l)))}))),"now"===i?n.createElement(y,{duration:m,setDuration:p,setDate:e=>{S(Date.now()),k(e)},endDate:D,isDisabled:s}):n.createElement(a.Flex,{gap:2},n.createElement(a.Flex,{column:!0,gap:2,flex:{grow:1,shrink:1},basis:0},n.createElement(a.TextSmall,null,"Start date"),n.createElement(v.A,{isSinglePicker:!0,values:{singleDate:new Date(E)},minDate:L(),maxDate:N,utc:h,onChange:e=>{S(e),g((e=>e+1))},isPlaying:!1,accessorProps:u.Iv,padding:[4,0],width:"auto",accessorTooltipContent:"Select start date"})),n.createElement(a.Flex,{column:!0,gap:2,flex:{grow:1,shrink:1},basis:0},n.createElement(a.TextSmall,null,"End date"),n.createElement(v.A,{key:b,isSinglePicker:!0,values:{singleDate:D?new Date(D):D},minDate:O,maxDate:N,utc:h,onChange:k,isPlaying:!1,accessorProps:u.Iv,padding:[4,0],width:"auto",accessorTooltipContent:"Select end date"}))))},H=e=>{let{content:t="Loading alerts..."}=e;return n.createElement(a.Flex,{height:45,alignItems:"center",justifyContent:"center"},n.createElement(a.Text,null,t))};var I=l(54856);const N=e=>n.createElement(a.Flex,(0,r.A)({gap:2,alignItems:"center"},e),n.createElement(a.Icon,{size:"small",color:"warning",name:"warning_triangle"}),n.createElement(a.Text,null,"This feature is only available to paid plans"),n.createElement(I.A,null));l(9391),l(17333),l(3064),l(98992),l(54520),l(72577);var P=l(47767),F=l(38819),_=l(22292),T=l(46741),B=l(3914),j=l(67990),M=l(71856),U=l(88982),W=l(29848),z=l(36021),K=l(47444),V=l(45860);const J=(0,K.K0)({key:"spaceAlertMetas",get:e=>()=>(0,V.z5)(e)});var Y=l(10368),G=l(79394),Z=l(71835);const q={name:"",rooms:[],nodes:[],hostLabels:null,alertNames:[],alertContexts:[],alertRoles:[],startsAt:null,lastsUntil:null},X=e=>{let{id:t,name:l,...n}=e;return{label:l,value:t,...n}},$=e=>({label:e,value:e}),Q=e=>{var t;let{rooms:l,nodes:n,hostLabels:a,startsAt:o,lastsUntil:s,...r}=e;return{...r,scope:r.accountId?"personal":u._V,canSubmit:!(null===r||void 0===r||null===(t=r.name)||void 0===t||!t.length),rooms:null!==l&&void 0!==l&&l.length?l.map(X):[M.PT],...null!==n&&void 0!==n&&n.length?{nodes:n.map(X).filter((e=>{let{notAvailable:t}=e;return!t}))}:{},...a?{hostLabels:a}:{},...o?{startsAt:o}:{},...s?{lastsUntil:s}:{}}},ee=e=>{let{value:t}=e;return t},te=(e,t)=>{const{scope:l,rooms:n,nodes:a,hostLabels:o,startsAt:s,lastsUntil:r,scheduleOption:i,duration:c,...d}=e,m=n.filter((e=>{let{value:t}=e;return t!==u.jH.value})).map(ee),p=a.map(ee),b=!!Object.keys(o||{}).length,{start:g,end:h}=(e=>{let{startsAt:t,lastsUntil:l,scheduleOption:n,duration:a}=e;if("schedule"==n)return{start:t,end:l};let o,s=Date.now();switch(a){case"oneHour":o=(0,A.W)(s,{hours:1});break;case"sixHours":o=(0,A.W)(s,{hours:6});break;case"twelveHours":o=(0,A.W)(s,{hours:12});break;case"oneDay":o=(0,A.W)(s,{days:1});break;case"custom":o=l}return{start:s,...o?{end:o}:{}}})({startsAt:s,lastsUntil:r,scheduleOption:i,duration:c});return{...d,..."personal"==l?{account_id:t}:{},...m.length?{room_ids:m}:{},...p.length?{node_ids:p}:{},...b?{host_labels:o}:{},...g?{starts_at:new Date(g).toISOString()}:{},...h?{lasts_until:new Date(h).toISOString()}:{}}},le=[{label:"CRITICAL",value:"CRITICAL"},{label:"WARNING",value:"WARNING"},{label:"CLEAR",value:"CLEAR"}],ne=e=>{var t;let{rule:l,onClose:a,isEdit:o}=e;const s=(0,_.NJ)(),r=(0,P.Zp)(),i=(0,B.bq)(),[c,d]=(0,b.A)(),m=(0,U.A)({all:!0}),p=null===(t=m.find((e=>{let{label:t}=e;return"All nodes"==t})))||void 0===t?void 0:t.value,{loaded:g,value:h,hasError:E}=(()=>{var e;const t=(0,B.vt)(),l=(0,K.xf)(J(t));return{loaded:"loading"!==l.state,value:(null===(e=l.contents)||void 0===e?void 0:e.data)||V.rx,hasError:"hasError"===l.state}})(),v=(0,z._B)(),f=(0,z.FU)(),C=o?f:v,A=(0,W.ly)(),x=(0,z.Lz)(),[,,S]=(0,Z.A)(),[D,k]=(0,n.useState)({alertNameOptions:[],alertContextOptions:[],alertRoleOptions:[]}),{alertNameOptions:y,alertContextOptions:L,alertRoleOptions:R}=D,[w,O]=(0,n.useState)((()=>({...q,...Q(l)}))),H=(0,j.vv)(w.roomIds||[p]),I=(0,n.useCallback)((e=>O((t=>({...t,scope:e})))),[]),N=(0,n.useCallback)((e=>O((t=>({...t,name:e,canSubmit:!(null===e||void 0===e||!e.length)})))),[]),M=(0,n.useCallback)((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const l=(e=>e.length<=1?e:e[e.length-1].value==u.jH.value?[u.jH]:e.filter((e=>{let{value:t}=e;return!!t})))(e),n=l.map((e=>{let{value:t}=e;return t||p})),a=t.length{let{value:l}=e;return!t.includes(l)}))[0]:null;O((e=>({...e,rooms:l,roomIds:n,lastRoomAdded:a||null})))}),[p]),X=(0,n.useCallback)((e=>O((t=>({...t,nodeIds:e.map((e=>{let{value:t}=e;return t})),nodes:e})))),[]),ee=(0,n.useCallback)((e=>O((t=>({...t,hostLabels:{...t.hostLabels,...e}})))),[]),ne=(0,n.useCallback)((e=>O((t=>{const l={...t.hostLabels};return delete l[e],{...t,hostLabels:l}}))),[]),ae=(0,n.useCallback)((e=>t=>O((l=>({...l,[e]:t.map((e=>{let{value:t}=e;return t}))})))),[]),oe=(0,n.useCallback)((e=>{let{start:t,end:l,scheduleOption:n,duration:a}=e;return O((e=>({...e,startsAt:t,lastsUntil:l,scheduleOption:n,duration:a.value})))}),[]),se=(0,n.useCallback)((()=>{d(),C(te(w,s)).then((()=>{a(),x(),A()})).catch((e=>S((0,Y.H)(e)))).finally(d)}),[w,s]),re=(0,G.A)();(0,n.useEffect)((()=>{var e;const t=(null===(e=w.lastRoomAdded)||void 0===e?void 0:e.value)||p;let l=null;return t&&(l=re(t)),()=>{var e;return!(null===(e=l)||void 0===e||!e.cancel)&&l.cancel()}}),[w.roomIds,re]),(0,n.useEffect)((()=>{if(g){const{contexts:e,names:t,roles:l}=h||{};k({alertNameOptions:t?t.map($):[],alertContextOptions:e?e.map($):[],alertRoleOptions:l?l.map($):[]})}}),[g]),(0,n.useEffect)((()=>{const e=(0,F.PP)(),t=(()=>{const{silencingRulePrefill:e}=(0,F.PP)();if(!e)return{};let t={};try{t=JSON.parse(e)}catch(l){}return t})(),{alertName:l,nodeId:n,instance:a,roomId:o}=t;if(o){const e=m.filter((e=>{let{value:t}=e;return t==o}));e&&M(e)}if(l&&O((e=>({...e,alertNames:[l]}))),a&&O((e=>({...e,alertContexts:[a]}))),n){const e=H.filter((e=>{let{value:t}=e;return t==n}));e&&X(e)}(0,F.Z8)({...e,silencingRulePrefill:""})}),[O,ae,X,H]);const ie=(0,T.JT)("space:CreatePersonalSilencingRule"),ce=(0,n.useCallback)((()=>r("/spaces/".concat(i,"/settings/billing"))),[i]);return{state:w,onScopeChange:I,onRuleNameChange:N,onRoomsSelectionChange:M,roomOptions:m,onNodesSelectionChange:X,nodesOptions:H,alertMetasLoaded:g,alertMetas:h,alertNameOptions:y,alertContextOptions:L,alertRoleOptions:R,alertStatusOptions:le,alertMetasError:E,onAlertValueChange:ae,onAddHostLabel:ee,onRemoveHostLabel:ne,onDatesChange:oe,loading:c,onSave:se,spaceCreatePersonalSilencingRule:ie,onUpdateButtonClick:ce}},ae=e=>null!==e&&void 0!==e&&e.length?e.map($):[],oe=()=>n.createElement(a.Box,{as:"hr",height:"1px",width:"100%",sx:{borderWidth:"1px 0px 0px 0px",borderColor:"borderSecondary",borderStyle:"solid"}}),se=e=>{let{rule:t={},onClose:l,isEdit:r}=e;const{state:i,onScopeChange:c,onRuleNameChange:u,onRoomsSelectionChange:b,roomOptions:g,onNodesSelectionChange:h,nodesOptions:v,alertMetasLoaded:f,alertNameOptions:C,alertContextOptions:A,alertRoleOptions:x,alertStatusOptions:S,onAlertValueChange:D,onAddHostLabel:k,onRemoveHostLabel:y,onDatesChange:L,loading:R,onSave:w,spaceCreatePersonalSilencingRule:I,onUpdateButtonClick:P}=ne({rule:t,onClose:l,isEdit:r});return n.createElement(a.Modal,{onEsc:l,backdropProps:{backdropBlur:!0}},n.createElement(s.$m,{style:{maxHeight:"800px"}},n.createElement(a.ModalHeader,{padding:[6,4,3]},n.createElement(a.Flex,{column:!0,gap:2},n.createElement(a.Flex,{flex:!0,alignItems:"center",justifyContent:"between"},n.createElement(a.H4,null,"Add silencing rule"),l&&n.createElement(s.Oj,{onClose:l})),n.createElement(a.Text,null,"Define an alert notification silencing rule that will apply to all users or just you."," ",n.createElement(o.A,{"data-ga":"alert-silencing::click-link-docs::rule-modal","data-testid":"silencing-rules-doc",href:"https://learn.netdata.cloud/docs/alerts-and-notifications/notifications/netdata-cloud-notifications/manage-alert-notification-silencing-rules",rel:"noopener noreferrer",target:"_blank"},"Learn how to configure silencing rules.")),!I&&n.createElement(N,null))),n.createElement(a.ModalBody,{padding:[0]},n.createElement(s.fn,null,n.createElement(a.Flex,{column:!0,gap:3},n.createElement(m,{scope:i.scope,setScope:c,padding:[0,0,1,0],isDisabled:!I}),n.createElement(p.A,{component:"input",onChange:u,placeholder:"Add rule name",title:"Rule name*",value:i.name,disabled:!I}),n.createElement(p.A,{component:"select",isMulti:!0,onChange:e=>b(e,i.roomIds),options:g,placeholder:"Select rooms",title:"Rooms*",value:i.rooms,isDisabled:!I}),n.createElement(p.A,{component:"select",isMulti:!0,onChange:h,options:v,placeholder:"Select nodes",title:"Nodes",value:i.nodes,isDisabled:!I||!v.length}),n.createElement(E,{hostLabels:i.hostLabels,onAddHostLabel:k,onRemoveHostLabel:y,isEdit:r,isDisabled:!I}),f?n.createElement(n.Fragment,null,n.createElement(oe,null),n.createElement(p.A,{component:"select",isMulti:!0,onChange:D("alertNames"),options:C,placeholder:"Select alert name",title:"Alert name",value:ae(i.alertNames),isDisabled:!I}),n.createElement(p.A,{component:"select",isMulti:!0,onChange:D("alertContexts"),options:A,placeholder:"Select alert context",title:"Alert context",value:ae(i.alertContexts),isDisabled:!I}),n.createElement(p.A,{component:"select",isMulti:!0,onChange:D("severities"),options:S,placeholder:"Select alert status",title:"Alert status",value:ae(i.severities),isDisabled:!I}),n.createElement(p.A,{component:"select",isMulti:!0,onChange:D("alertRoles"),options:x,placeholder:"Select alert role",title:"Alert role",value:ae(i.alertRoles),isDisabled:!I})):n.createElement(H,null),n.createElement(oe,null),n.createElement(O,{start:i.startsAt,end:i.lastsUntil,onChange:L,isEdit:r,isDisabled:!I}))),n.createElement(s.fn,{alignItems:"end",justifyContent:"center"},n.createElement(a.Flex,{gap:4},n.createElement(a.Button,{flavour:"borderless",label:"Cancel",onClick:l,disabled:R}),I?n.createElement(d.A,{content:r?"Update the rule":"Create the rule",align:"bottom"},n.createElement(a.Button,{label:"OK",onClick:w,"data-ga":"alert-silencing::click-save-".concat(r?"edit":"new","-rule::rule-modal"),"data-testid":"saveRule-button",textTransform:"uppercase",isLoading:R,disabled:R||!i.canSubmit})):n.createElement(d.A,{content:"Update to a paid plan in order to be able to create silencing rules",align:"bottom"},n.createElement(a.Button,{label:"Upgrade!",onClick:P})))))))}}}]); \ No newline at end of file -- cgit v1.2.3