"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[9563],{29848:(e,t,r)=>{r.d(t,{Z:()=>c}),r(67294);var l=r(51995),a=r(58593),o=r(70707),s=r(11965);const n=l.iK.span`
  white-space: nowrap;
  min-width: 100px;
  svg,
  i {
    margin-right: 8px;

    &:hover {
      path {
        fill: ${e=>{let{theme:t}=e;return t.colors.primary.base}};
      }
    }
  }
`,i=l.iK.span`
  color: ${e=>{let{theme:t}=e;return t.colors.grayscale.base}};
`;function c(e){let{actions:t}=e;return(0,s.tZ)(n,{className:"actions"},t.map(((e,t)=>{const r=o.Z[e.icon];return e.tooltip?(0,s.tZ)(a.u,{id:`${e.label}-tooltip`,title:e.tooltip,placement:e.placement,key:t},(0,s.tZ)(i,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick},(0,s.tZ)(r,null))):(0,s.tZ)(i,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,key:t},(0,s.tZ)(r,null))})))}},94222:(e,t,r)=>{r.d(t,{Z:()=>u});var l=r(51995),a=r(61988),o=(r(67294),r(58593)),s=r(70707),n=r(90335),i=r(11965);function c(e,t,r){switch(e){case n.Z.Working:return r.colors.primary.base;case n.Z.Error:return r.colors.error.base;case n.Z.Success:return t?r.colors.success.base:r.colors.alert.base;case n.Z.Noop:return r.colors.success.base;case n.Z.Grace:return r.colors.alert.base;default:return r.colors.grayscale.base}}function u(e){let{state:t,isReportEnabled:r=!1}=e;const u=(0,l.Fg)(),d={icon:s.Z.Check,label:"",status:""};switch(t){case n.Z.Success:d.icon=r?s.Z.Check:s.Z.AlertSolidSmall,d.label=r?(0,a.t)("Report sent"):(0,a.t)("Alert triggered, notification sent"),d.status=n.Z.Success;break;case n.Z.Working:d.icon=s.Z.Running,d.label=r?(0,a.t)("Report sending"):(0,a.t)("Alert running"),d.status=n.Z.Working;break;case n.Z.Error:d.icon=s.Z.XSmall,d.label=r?(0,a.t)("Report failed"):(0,a.t)("Alert failed"),d.status=n.Z.Error;break;case n.Z.Noop:d.icon=s.Z.Check,d.label=(0,a.t)("Nothing triggered"),d.status=n.Z.Noop;break;case n.Z.Grace:d.icon=s.Z.AlertSolidSmall,d.label=(0,a.t)("Alert Triggered, In Grace Period"),d.status=n.Z.Grace;break;default:d.icon=s.Z.Check,d.label=(0,a.t)("Nothing triggered"),d.status=n.Z.Noop}const p=d.icon;return(0,i.tZ)(o.u,{title:d.label,placement:"bottomLeft"},(0,i.tZ)(p,{iconColor:c(d.status,r,u)}))}},90335:(e,t,r)=>{var l,a;r.d(t,{Z:()=>l,u:()=>a}),function(e){e.Success="Success",e.Working="Working",e.Error="Error",e.Noop="Not triggered",e.Grace="On Grace"}(l||(l={})),function(e){e.Email="Email",e.Slack="Slack"}(a||(a={}))},32635:(e,t,r)=>{r.r(t),r.d(t,{default:()=>U});var l=r(67294),a=r(16550),o=r(75049),s=r(61988),n=r(22102),i=r(51995),c=r(31069),u=r(30381),d=r.n(u),p=r(29848),m=r(34581),b=r(58593),g=r(93139),Z=r(86074),h=r(12441),k=r(27600),y=r(14114),f=r(94222),S=r(11965),w=r(70707),v=r(90335);const C=e=>S.iv`
  color: ${e.colors.grayscale.light1};
  margin-right: ${2*e.gridUnit}px;
`;function E(e){let{type:t}=e;const r={icon:null,label:""};switch(t){case v.u.Email:r.icon=(0,S.tZ)(w.Z.Email,{css:C}),r.label=v.u.Email;break;case v.u.Slack:r.icon=(0,S.tZ)(w.Z.Slack,{css:C}),r.label=v.u.Slack;break;default:r.icon=null,r.label=""}return r.icon?(0,S.tZ)(b.u,{title:r.label,placement:"bottom"},r.icon):null}var $=r(19259),x=r(17198);d().updateLocale("en",{calendar:{lastDay:"[Yesterday at] LTS",sameDay:"[Today at] LTS",nextDay:"[Tomorrow at] LTS",lastWeek:"[last] dddd [at] LTS",nextWeek:"dddd [at] LTS",sameElse:"L"}});const _=i.iK.span`
  color: ${e=>{let{theme:t}=e;return t.colors.grayscale.base}};
`,A=(0,i.iK)(w.Z.Refresh)`
  color: ${e=>{let{theme:t}=e;return t.colors.primary.base}};
  width: auto;
  height: ${e=>{let{theme:t}=e;return 5*t.gridUnit}}px;
  position: relative;
  top: ${e=>{let{theme:t}=e;return t.gridUnit}}px;
  left: ${e=>{let{theme:t}=e;return t.gridUnit}}px;
  cursor: pointer;
`,N=e=>{let{updatedAt:t,update:r}=e;const[a,o]=(0,l.useState)(d()(t));return(0,l.useEffect)((()=>{o((()=>d()(t)));const e=setInterval((()=>{o((()=>d()(t)))}),6e4);return()=>clearInterval(e)}),[t]),(0,S.tZ)(_,null,(0,s.t)("Last Updated %s",a.isValid()?a.calendar():"--"),r&&(0,S.tZ)(A,{onClick:r}))};var T=r(34858),z=r(40768),L=r(22318),R=r(20095);const D=(0,o.I)(),H={[v.Z.Success]:(0,s.t)("Success"),[v.Z.Working]:(0,s.t)("Working"),[v.Z.Error]:(0,s.t)("Error"),[v.Z.Noop]:(0,s.t)("Not triggered"),[v.Z.Grace]:(0,s.t)("On Grace")},W=(0,n.Z)({requestType:"rison",method:"DELETE",endpoint:"/api/v1/report/"}),G=i.iK.div`
  width: 100%;
  padding: 0 ${e=>{let{theme:t}=e;return 4*t.gridUnit}}px
    ${e=>{let{theme:t}=e;return 3*t.gridUnit}}px;
  background-color: ${e=>{let{theme:t}=e;return t.colors.grayscale.light5}};
`,B=i.iK.div`
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  > *:first-child {
    margin-right: ${e=>{let{theme:t}=e;return t.gridUnit}}px;
  }
`,I=D.get("alertsreports.header.icon"),U=(0,y.ZP)((function(e){let{addDangerToast:t,isReportEnabled:r=!1,user:o,addSuccessToast:n}=e;const i=r?(0,s.t)("report"):(0,s.t)("alert"),u=r?(0,s.t)("reports"):(0,s.t)("alerts"),y=r?"Reports":"Alerts",w=(0,l.useMemo)((()=>[{id:"type",operator:g.p.equals,value:r?"Report":"Alert"}]),[r]),{state:{loading:C,resourceCount:_,resourceCollection:A,bulkSelectEnabled:D,lastFetched:U},hasPerm:M,fetchData:K,setResourceCollection:F,refreshData:O,toggleBulkSelect:P}=(0,T.Yi)("report",(0,s.t)("reports"),t,!0,void 0,w),{updateResource:q}=(0,T.LE)("report",(0,s.t)("reports"),t),[V,Y]=(0,l.useState)(!1),[j,X]=(0,l.useState)(null),[J,Q]=(0,l.useState)(null);function ee(e){X(e),Y(!0)}const te=M("can_write"),re=M("can_write"),le=M("can_write");(0,l.useEffect)((()=>{D&&re&&P()}),[r]);const ae=[{id:"name",desc:!0}],oe=(0,l.useCallback)(((e,t)=>{if(null!=e&&e.id){const r=e.id,l=[...A];F(l.map((r=>(null==r?void 0:r.id)===e.id?{...r,active:t}:r))),q(r,{active:t},!1,!1).then().catch((()=>F(l)))}}),[A,F,q]),se=(0,l.useMemo)((()=>[{Cell:e=>{let{row:{original:{last_state:t}}}=e;return(0,S.tZ)(f.Z,{state:t,isReportEnabled:r})},accessor:"last_state",size:"xs",disableSortBy:!0},{Cell:e=>{let{row:{original:{last_eval_dttm:t}}}=e;return t?d().utc(t).local().format(k.v2):""},accessor:"last_eval_dttm",Header:(0,s.t)("Last run"),size:"lg"},{accessor:"name",Header:(0,s.t)("Name"),size:"xl"},{Header:(0,s.t)("Schedule"),accessor:"crontab_humanized",size:"xl",Cell:e=>{let{row:{original:{crontab_humanized:t="",timezone:r}}}=e;return(0,S.tZ)(b.u,{title:`${t} (${r})`,placement:"topLeft"},(0,S.tZ)("span",null,`${t} (${r})`))}},{Cell:e=>{let{row:{original:{recipients:t}}}=e;return t.map((e=>(0,S.tZ)(E,{key:e.id,type:e.type})))},accessor:"recipients",Header:(0,s.t)("Notification method"),disableSortBy:!0,size:"xl"},{Cell:e=>{let{row:{original:{created_by:t}}}=e;return t?`${t.first_name} ${t.last_name}`:""},Header:(0,s.t)("Created by"),id:"created_by",disableSortBy:!0,size:"xl"},{Cell:e=>{let{row:{original:{owners:t=[]}}}=e;return(0,S.tZ)(m.Z,{users:t})},Header:(0,s.t)("Owners"),id:"owners",disableSortBy:!0,size:"xl"},{Cell:e=>{let{row:{original:{changed_on_delta_humanized:t}}}=e;return(0,S.tZ)("span",{className:"no-wrap"},t)},Header:(0,s.t)("Modified"),accessor:"changed_on_delta_humanized",size:"xl"},{Cell:e=>{let{row:{original:t}}=e;const r=t.owners.map((e=>e.id)).includes(o.userId)||(0,L.i5)(o);return(0,S.tZ)(h.r,{disabled:!r,checked:t.active,onClick:e=>oe(t,e),size:"small"})},Header:(0,s.t)("Active"),accessor:"active",id:"active",size:"xl"},{Cell:e=>{let{row:{original:t}}=e;const r=(0,a.k6)(),l=t.owners.map((e=>e.id)).includes(o.userId)||(0,L.i5)(o),n=[te?{label:"execution-log-action",tooltip:(0,s.t)("Execution log"),placement:"bottom",icon:"Note",onClick:()=>r.push(`/${t.type.toLowerCase()}/${t.id}/log`)}:null,te?{label:l?"edit-action":"preview-action",tooltip:l?(0,s.t)("Edit"):(0,s.t)("View"),placement:"bottom",icon:l?"Edit":"Binoculars",onClick:()=>ee(t)}:null,l&&re?{label:"delete-action",tooltip:(0,s.t)("Delete"),placement:"bottom",icon:"Trash",onClick:()=>Q(t)}:null].filter((e=>null!==e));return(0,S.tZ)(p.Z,{actions:n})},Header:(0,s.t)("Actions"),id:"actions",hidden:!te&&!re,disableSortBy:!0,size:"xl"}]),[re,te,r,oe]),ne=[];le&&ne.push({name:(0,S.tZ)(l.Fragment,null,(0,S.tZ)("i",{className:"fa fa-plus"})," ",i),buttonStyle:"primary",onClick:()=>{ee(null)}}),re&&ne.push({name:(0,s.t)("Bulk select"),onClick:P,buttonStyle:"secondary","data-test":"bulk-select-toggle"});const ie={title:(0,s.t)("No %s yet",u),image:"filter-results.svg",buttonAction:()=>ee(null),buttonText:le?(0,S.tZ)(l.Fragment,null,(0,S.tZ)("i",{className:"fa fa-plus"})," ",i," "):null},ce=(0,l.useMemo)((()=>[{Header:(0,s.t)("Owner"),key:"owner",id:"owners",input:"select",operator:g.p.relationManyMany,unfilteredLabel:(0,s.t)("All"),fetchSelects:(0,z.tm)("report","owners",(0,z.v$)((e=>(0,s.t)("An error occurred while fetching owners values: %s",e))),o),paginate:!0},{Header:(0,s.t)("Created by"),key:"created_by",id:"created_by",input:"select",operator:g.p.relationOneMany,unfilteredLabel:"All",fetchSelects:(0,z.tm)("report","created_by",(0,z.v$)((e=>(0,s.t)("An error occurred while fetching created by values: %s",e))),o),paginate:!0},{Header:(0,s.t)("Status"),key:"status",id:"last_state",input:"select",operator:g.p.equals,unfilteredLabel:"Any",selects:[{label:H[v.Z.Success],value:v.Z.Success},{label:H[v.Z.Working],value:v.Z.Working},{label:H[v.Z.Error],value:v.Z.Error},{label:H[v.Z.Noop],value:v.Z.Noop},{label:H[v.Z.Grace],value:v.Z.Grace}]},{Header:(0,s.t)("Search"),key:"search",id:"name",input:"search",operator:g.p.contains}]),[]),ue=I?(0,S.tZ)(B,null,(0,S.tZ)("div",null,(0,s.t)("Alerts & reports")),(0,S.tZ)(I,null)):(0,s.t)("Alerts & reports");return(0,S.tZ)(l.Fragment,null,(0,S.tZ)(Z.Z,{activeChild:y,name:ue,tabs:[{name:"Alerts",label:(0,s.t)("Alerts"),url:"/alert/list/",usesRouter:!0,"data-test":"alert-list"},{name:"Reports",label:(0,s.t)("Reports"),url:"/report/list/",usesRouter:!0,"data-test":"report-list"}],buttons:ne},(0,S.tZ)(G,null,(0,S.tZ)(N,{updatedAt:U,update:()=>O()}))),(0,S.tZ)(R.ZP,{alert:j,addDangerToast:t,layer:j,onHide:()=>{Y(!1),X(null),O()},show:V,isReport:r,key:(null==j?void 0:j.id)||`${(new Date).getTime()}`}),J&&(0,S.tZ)(x.Z,{description:(0,s.t)("This action will permanently delete %s.",J.name),onConfirm:()=>{J&&(e=>{let{id:r,name:l}=e;c.Z.delete({endpoint:`/api/v1/report/${r}`}).then((()=>{O(),Q(null),n((0,s.t)("Deleted: %s",l))}),(0,z.v$)((e=>t((0,s.t)("There was an issue deleting %s: %s",l,e)))))})(J)},onHide:()=>Q(null),open:!0,title:(0,s.t)("Delete %s?",i)}),(0,S.tZ)($.Z,{title:(0,s.t)("Please confirm"),description:(0,s.t)("Are you sure you want to delete the selected %s?",u),onConfirm:async e=>{try{const{message:t}=await W(e.map((e=>{let{id:t}=e;return t})));O(),n(t)}catch(e){(0,z.v$)((e=>t((0,s.t)("There was an issue deleting the selected %s: %s",u,e))))(e)}}},(e=>{const r=re?[{key:"delete",name:(0,s.t)("Delete"),onSelect:e,type:"danger"}]:[];return(0,S.tZ)(g.Z,{className:"alerts-list-view",columns:se,count:_,data:A,emptyState:ie,fetchData:K,filters:ce,initialSort:ae,loading:C,bulkActions:r,bulkSelectEnabled:D,disableBulkSelect:P,refreshData:O,addDangerToast:t,addSuccessToast:n,pageSize:25})})))}))}}]);
//# sourceMappingURL=8ce82afcfd2a46987ac3.chunk.js.map