"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[9563],{452630:(e,t,a)=>{t.iB=t.YM=void 0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},n=l(a(667294)),i=l(a(45697)),o=a(402371);function l(e){return e&&e.__esModule?e:{default:e}}t.YM=function(e){var t=e.itemTypeToComponent,a=e.WrapperComponent,l=void 0===a?"div":a,s=function(e){var a=e.currentPage,i=e.totalPages,s=e.boundaryPagesRange,c=e.siblingPagesRange,u=e.hideEllipsis,d=e.hidePreviousAndNextPageLinks,g=e.hideFirstAndLastPageLinks,p=e.onChange,h=e.disabled,b=function(e,t){var a={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(a[r]=e[r]);return a}(e,["currentPage","totalPages","boundaryPagesRange","siblingPagesRange","hideEllipsis","hidePreviousAndNextPageLinks","hideFirstAndLastPageLinks","onChange","disabled"]),P=(0,o.getPaginationModel)({currentPage:a,totalPages:i,boundaryPagesRange:s,siblingPagesRange:c,hideEllipsis:u,hidePreviousAndNextPageLinks:d,hideFirstAndLastPageLinks:g}),E=function(e,t,a){return function(i){var o,l,s,c=e[i.type],u=(l=(o=i).value,s=o.isDisabled,function(){!s&&a&&t!==l&&a(l)});return n.default.createElement(c,r({onClick:u},i))}}(t,a,p);return n.default.createElement(l,b,P.map((function(e){return E(r({},e,{isDisabled:!!h}))})))};return s.propTypes={currentPage:i.default.number.isRequired,totalPages:i.default.number.isRequired,boundaryPagesRange:i.default.number,siblingPagesRange:i.default.number,hideEllipsis:i.default.bool,hidePreviousAndNextPageLinks:i.default.bool,hideFirstAndLastPageLinks:i.default.bool,onChange:i.default.func,disabled:i.default.bool},s},t.iB=o.ITEM_TYPES},554070:(e,t,a)=>{a.d(t,{w:()=>l});var r=a(358593),n=a(83379),i=a(61988),o=a(135944);const l=({user:e,date:t})=>{const a=(0,o.tZ)("span",{className:"no-wrap",children:t});if(e){const t=(0,n.Z)(e),l=(0,i.t)("Modified by: %s",t);return(0,o.tZ)(r.u,{title:l,placement:"bottom",children:a})}return a}},129848:(e,t,a)=>{a.d(t,{Z:()=>c});var r=a(751995),n=a(358593),i=a(313322),o=a(135944);const l=r.iK.span`
  white-space: nowrap;
  min-width: 100px;
  svg,
  i {
    margin-right: 8px;

    &:hover {
      path {
        fill: ${({theme:e})=>e.colors.primary.base};
      }
    }
  }
`,s=r.iK.span`
  color: ${({theme:e})=>e.colors.grayscale.base};
`;function c({actions:e}){return(0,o.tZ)(l,{className:"actions",children:e.map(((e,t)=>{const a=i.Z[e.icon];return e.tooltip?(0,o.tZ)(n.u,{id:`${e.label}-tooltip`,title:e.tooltip,placement:e.placement,children:(0,o.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,o.tZ)(a,{})})},t):(0,o.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,o.tZ)(a,{})},t)}))})}},194222:(e,t,a)=>{a.d(t,{Z:()=>u});var r=a(751995),n=a(61988),i=a(358593),o=a(313322),l=a(690335),s=a(135944);function c(e,t,a){switch(e){case l.Z9.Working:return a.colors.primary.base;case l.Z9.Error:return a.colors.error.base;case l.Z9.Success:return t?a.colors.success.base:a.colors.alert.base;case l.Z9.Noop:return a.colors.success.base;case l.Z9.Grace:return a.colors.alert.base;default:return a.colors.grayscale.base}}function u({state:e,isReportEnabled:t=!1}){const a=(0,r.Fg)(),u={icon:o.Z.Check,label:"",status:""};switch(e){case l.Z9.Success:u.icon=t?o.Z.Check:o.Z.AlertSolidSmall,u.label=t?(0,n.t)("Report sent"):(0,n.t)("Alert triggered, notification sent"),u.status=l.Z9.Success;break;case l.Z9.Working:u.icon=o.Z.Running,u.label=t?(0,n.t)("Report sending"):(0,n.t)("Alert running"),u.status=l.Z9.Working;break;case l.Z9.Error:u.icon=o.Z.XSmall,u.label=t?(0,n.t)("Report failed"):(0,n.t)("Alert failed"),u.status=l.Z9.Error;break;case l.Z9.Noop:u.icon=o.Z.Check,u.label=(0,n.t)("Nothing triggered"),u.status=l.Z9.Noop;break;case l.Z9.Grace:u.icon=o.Z.AlertSolidSmall,u.label=(0,n.t)("Alert Triggered, In Grace Period"),u.status=l.Z9.Grace;break;default:u.icon=o.Z.Check,u.label=(0,n.t)("Nothing triggered"),u.status=l.Z9.Noop}const d=u.icon;return(0,s.tZ)(i.u,{title:u.label,placement:"bottomLeft",children:(0,s.tZ)(d,{iconColor:c(u.status,t,a)})})}},232635:(e,t,a)=>{a.r(t),a.d(t,{default:()=>O});var r=a(667294),n=a(616550),i=a(175049),o=a(61988),l=a(522102),s=a(751995),c=a(431069),u=a(730381),d=a.n(u),g=a(129848),p=a(222545),h=a(358593),b=a(593139),P=a(586074),E=a(112441),m=a(427600),v=a(414114),f=a(194222),S=a(211965),Z=a(313322),y=a(690335),_=a(135944);const L=e=>S.iv`
  color: ${e.colors.grayscale.light1};
  margin-right: ${2*e.gridUnit}px;
`;function k({type:e}){const t={icon:null,label:""};switch(e){case y.cv.Email:t.icon=(0,_.tZ)(Z.Z.Email,{css:L}),t.label=y.cv.Email;break;case y.cv.Slack:case y.cv.SlackV2:t.icon=(0,_.tZ)(Z.Z.Slack,{css:L}),t.label=y.cv.Slack;break;default:t.icon=null,t.label=""}return t.icon?(0,_.tZ)(h.u,{title:t.label,placement:"bottom",children:t.icon}):null}var I=a(419259),T=a(217198);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 w=s.iK.span`
  color: ${({theme:e})=>e.colors.grayscale.base};
`,A=(0,s.iK)(Z.Z.Refresh)`
  color: ${({theme:e})=>e.colors.primary.base};
  width: auto;
  height: ${({theme:e})=>5*e.gridUnit}px;
  position: relative;
  top: ${({theme:e})=>e.gridUnit}px;
  left: ${({theme:e})=>e.gridUnit}px;
  cursor: pointer;
`,N=({updatedAt:e,update:t})=>{const[a,n]=(0,r.useState)(d()(e));return(0,r.useEffect)((()=>{n((()=>d()(e)));const t=setInterval((()=>{n((()=>d()(e)))}),6e4);return()=>clearInterval(t)}),[e]),(0,_.BX)(w,{children:[(0,o.t)("Last Updated %s",a.isValid()?a.calendar():"--"),t&&(0,_.tZ)(A,{onClick:t})]})};var R=a(34858),M=a(440768),C=a(922318),x=a(567317),K=a(554070),G=a(400012);const Y=(0,i.I)(),$={[y.Z9.Success]:(0,o.t)("Success"),[y.Z9.Working]:(0,o.t)("Working"),[y.Z9.Error]:(0,o.t)("Error"),[y.Z9.Noop]:(0,o.t)("Not triggered"),[y.Z9.Grace]:(0,o.t)("On Grace")},F=(0,l.Z)({requestType:"rison",method:"DELETE",endpoint:"/api/v1/report/"}),D=s.iK.div`
  width: 100%;
  padding: 0 ${({theme:e})=>4*e.gridUnit}px
    ${({theme:e})=>3*e.gridUnit}px;
  background-color: ${({theme:e})=>e.colors.grayscale.light5};
`,B=s.iK.div`
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  > *:first-child {
    margin-right: ${({theme:e})=>e.gridUnit}px;
  }
`,H=Y.get("alertsreports.header.icon"),O=(0,v.ZP)((function({addDangerToast:e,isReportEnabled:t=!1,user:a,addSuccessToast:i}){const l=t?(0,o.t)("Report"):(0,o.t)("Alert"),s=t?(0,o.t)("reports"):(0,o.t)("alerts"),u=t?"Reports":"Alerts",v=(0,r.useMemo)((()=>[{id:"type",operator:b.p.Equals,value:t?"Report":"Alert"}]),[t]),{state:{loading:S,resourceCount:Z,resourceCollection:L,bulkSelectEnabled:w,lastFetched:A},hasPerm:Y,fetchData:O,setResourceCollection:z,refreshData:U,toggleBulkSelect:X}=(0,R.Yi)("report",(0,o.t)("reports"),e,!0,void 0,v),{updateResource:W}=(0,R.LE)("report",(0,o.t)("reports"),e),[V,j]=(0,r.useState)(!1),[q,J]=(0,r.useState)(null),[Q,ee]=(0,r.useState)(null);function te(e){J(e),j(!0)}const ae=Y("can_write"),re=Y("can_write"),ne=Y("can_write");(0,r.useEffect)((()=>{w&&re&&X()}),[t]);const ie=[{id:"name",desc:!0}],oe=(0,r.useCallback)(((e,t)=>{if(null!=e&&e.id){const a=e.id,r=[...L];z(r.map((a=>(null==a?void 0:a.id)===e.id?{...a,active:t}:a))),W(a,{active:t},!1,!1).then().catch((()=>z(r)))}}),[L,z,W]),le=(0,r.useMemo)((()=>[{Cell:({row:{original:{last_state:e}}})=>(0,_.tZ)(f.Z,{state:e,isReportEnabled:t}),accessor:"last_state",size:"xs",disableSortBy:!0},{Cell:({row:{original:{last_eval_dttm:e}}})=>e?d().utc(e).local().format(m.v2):"",accessor:"last_eval_dttm",Header:(0,o.t)("Last run"),size:"lg"},{accessor:"name",Header:(0,o.t)("Name"),size:"xl"},{Header:(0,o.t)("Schedule"),accessor:"crontab_humanized",size:"xl",Cell:({row:{original:{crontab_humanized:e="",timezone:t}}})=>(0,_.tZ)(h.u,{title:`${e} (${t})`,placement:"topLeft",children:(0,_.tZ)("span",{children:`${e} (${t})`})})},{Cell:({row:{original:{recipients:e}}})=>e.map((e=>(0,_.tZ)(k,{type:e.type},e.id))),accessor:"recipients",Header:(0,o.t)("Notification method"),disableSortBy:!0,size:"xl"},{Cell:({row:{original:{owners:e=[]}}})=>(0,_.tZ)(p.Z,{users:e}),Header:(0,o.t)("Owners"),id:"owners",disableSortBy:!0,size:"xl"},{Cell:({row:{original:{changed_on_delta_humanized:e,changed_by:t}}})=>(0,_.tZ)(K.w,{date:e,user:t}),Header:(0,o.t)("Last modified"),accessor:"changed_on_delta_humanized",size:"xl"},{Cell:({row:{original:e}})=>{const t=e.owners.map((e=>e.id)).includes(a.userId)||(0,C.i5)(a);return(0,_.tZ)(E.r,{disabled:!t,checked:e.active,onClick:t=>oe(e,t),size:"small"})},Header:(0,o.t)("Active"),accessor:"active",id:"active",size:"xl"},{Cell:({row:{original:e}})=>{const t=(0,n.k6)(),r=e.owners.map((e=>e.id)).includes(a.userId)||(0,C.i5)(a),i=[ae?{label:"execution-log-action",tooltip:(0,o.t)("Execution log"),placement:"bottom",icon:"Note",onClick:()=>t.push(`/${e.type.toLowerCase()}/${e.id}/log`)}:null,ae?{label:r?"edit-action":"preview-action",tooltip:r?(0,o.t)("Edit"):(0,o.t)("View"),placement:"bottom",icon:r?"Edit":"Binoculars",onClick:()=>te(e)}:null,r&&re?{label:"delete-action",tooltip:(0,o.t)("Delete"),placement:"bottom",icon:"Trash",onClick:()=>ee(e)}:null].filter((e=>null!==e));return(0,_.tZ)(g.Z,{actions:i})},Header:(0,o.t)("Actions"),id:"actions",hidden:!ae&&!re,disableSortBy:!0,size:"xl"},{accessor:G.J.ChangedBy,hidden:!0}]),[re,ae,t,oe]),se=[];ne&&se.push({name:(0,_.BX)(_.HY,{children:[(0,_.tZ)("i",{className:"fa fa-plus"})," ",l]}),buttonStyle:"primary",onClick:()=>{te(null)}}),re&&se.push({name:(0,o.t)("Bulk select"),onClick:X,buttonStyle:"secondary"});const ce={title:(0,o.t)("No %s yet",s),image:"filter-results.svg",buttonAction:()=>te(null),buttonText:ne?(0,_.BX)(_.HY,{children:[(0,_.tZ)("i",{className:"fa fa-plus"})," ",l," "]}):null},ue=(0,r.useMemo)((()=>[{Header:(0,o.t)("Name"),key:"search",id:"name",input:"search",operator:b.p.Contains},{Header:(0,o.t)("Owner"),key:"owner",id:"owners",input:"select",operator:b.p.RelationManyMany,unfilteredLabel:(0,o.t)("All"),fetchSelects:(0,M.tm)("report","owners",(0,M.v$)((e=>(0,o.t)("An error occurred while fetching owners values: %s",e))),a),paginate:!0},{Header:(0,o.t)("Status"),key:"status",id:"last_state",input:"select",operator:b.p.Equals,unfilteredLabel:"Any",selects:[{label:$[y.Z9.Success],value:y.Z9.Success},{label:$[y.Z9.Working],value:y.Z9.Working},{label:$[y.Z9.Error],value:y.Z9.Error},{label:$[y.Z9.Noop],value:y.Z9.Noop},{label:$[y.Z9.Grace],value:y.Z9.Grace}]},{Header:(0,o.t)("Modified by"),key:"changed_by",id:"changed_by",input:"select",operator:b.p.RelationOneMany,unfilteredLabel:(0,o.t)("All"),fetchSelects:(0,M.tm)("report","changed_by",(0,M.v$)((e=>(0,o.t)("An error occurred while fetching dataset datasource values: %s",e))),a),paginate:!0}]),[]),de=H?(0,_.BX)(B,{children:[(0,_.tZ)("div",{children:(0,o.t)("Alerts & reports")}),(0,_.tZ)(H,{})]}):(0,o.t)("Alerts & reports");return(0,_.BX)(_.HY,{children:[(0,_.tZ)(P.Z,{activeChild:u,name:de,tabs:[{name:"Alerts",label:(0,o.t)("Alerts"),url:"/alert/list/",usesRouter:!0},{name:"Reports",label:(0,o.t)("Reports"),url:"/report/list/",usesRouter:!0}],buttons:se,children:(0,_.tZ)(D,{children:(0,_.tZ)(N,{updatedAt:A,update:()=>U()})})}),(0,_.tZ)(x.ZP,{alert:q,addDangerToast:e,layer:q,onHide:()=>{j(!1),J(null),U()},show:V,isReport:t},(null==q?void 0:q.id)||`${(new Date).getTime()}`),Q&&(0,_.tZ)(T.Z,{description:(0,o.t)("This action will permanently delete %s.",Q.name),onConfirm:()=>{Q&&(({id:t,name:a})=>{c.Z.delete({endpoint:`/api/v1/report/${t}`}).then((()=>{U(),ee(null),i((0,o.t)("Deleted: %s",a))}),(0,M.v$)((t=>e((0,o.t)("There was an issue deleting %s: %s",a,t)))))})(Q)},onHide:()=>ee(null),open:!0,title:(0,o.t)("Delete %s?",l)}),(0,_.tZ)(I.Z,{title:(0,o.t)("Please confirm"),description:(0,o.t)("Are you sure you want to delete the selected %s?",s),onConfirm:async t=>{try{const{message:e}=await F(t.map((({id:e})=>e)));U(),i(e)}catch(t){(0,M.v$)((t=>e((0,o.t)("There was an issue deleting the selected %s: %s",s,t))))(t)}},children:t=>{const a=re?[{key:"delete",name:(0,o.t)("Delete"),onSelect:t,type:"danger"}]:[];return(0,_.tZ)(b.Z,{className:"alerts-list-view",columns:le,count:Z,data:L,emptyState:ce,fetchData:O,filters:ue,initialSort:ie,loading:S,bulkActions:a,bulkSelectEnabled:w,disableBulkSelect:X,refreshData:U,addDangerToast:e,addSuccessToast:i,pageSize:25})}})]})}))},656590:(e,t)=>{t.ITEM_TYPES={PAGE:"PAGE",ELLIPSIS:"ELLIPSIS",FIRST_PAGE_LINK:"FIRST_PAGE_LINK",PREVIOUS_PAGE_LINK:"PREVIOUS_PAGE_LINK",NEXT_PAGE_LINK:"NEXT_PAGE_LINK",LAST_PAGE_LINK:"LAST_PAGE_LINK"},t.ITEM_KEYS={FIRST_ELLIPSIS:-1,SECOND_ELLIPSIS:-2,FIRST_PAGE_LINK:-3,PREVIOUS_PAGE_LINK:-4,NEXT_PAGE_LINK:-5,LAST_PAGE_LINK:-6}},653804:(e,t,a)=>{var r=a(656590);t.createFirstEllipsis=function(e){return{type:r.ITEM_TYPES.ELLIPSIS,key:r.ITEM_KEYS.FIRST_ELLIPSIS,value:e,isActive:!1}},t.createSecondEllipsis=function(e){return{type:r.ITEM_TYPES.ELLIPSIS,key:r.ITEM_KEYS.SECOND_ELLIPSIS,value:e,isActive:!1}},t.createFirstPageLink=function(e){var t=e.currentPage;return{type:r.ITEM_TYPES.FIRST_PAGE_LINK,key:r.ITEM_KEYS.FIRST_PAGE_LINK,value:1,isActive:1===t}},t.createPreviousPageLink=function(e){var t=e.currentPage;return{type:r.ITEM_TYPES.PREVIOUS_PAGE_LINK,key:r.ITEM_KEYS.PREVIOUS_PAGE_LINK,value:Math.max(1,t-1),isActive:1===t}},t.createNextPageLink=function(e){var t=e.currentPage,a=e.totalPages;return{type:r.ITEM_TYPES.NEXT_PAGE_LINK,key:r.ITEM_KEYS.NEXT_PAGE_LINK,value:Math.min(a,t+1),isActive:t===a}},t.createLastPageLink=function(e){var t=e.currentPage,a=e.totalPages;return{type:r.ITEM_TYPES.LAST_PAGE_LINK,key:r.ITEM_KEYS.LAST_PAGE_LINK,value:a,isActive:t===a}},t.createPageFunctionFactory=function(e){var t=e.currentPage;return function(e){return{type:r.ITEM_TYPES.PAGE,key:e,value:e,isActive:e===t}}}},1158:(e,t)=>{t.createRange=function(e,t){for(var a=[],r=e;r<=t;r++)a.push(r);return a}},402371:(e,t,a)=>{var r=a(1158),n=a(653804);t.getPaginationModel=function(e){if(null==e)throw new Error("getPaginationModel(): options object should be a passed");var t=Number(e.totalPages);if(isNaN(t))throw new Error("getPaginationModel(): totalPages should be a number");if(t<0)throw new Error("getPaginationModel(): totalPages shouldn't be a negative number");var a=Number(e.currentPage);if(isNaN(a))throw new Error("getPaginationModel(): currentPage should be a number");if(a<0)throw new Error("getPaginationModel(): currentPage shouldn't be a negative number");if(a>t)throw new Error("getPaginationModel(): currentPage shouldn't be greater than totalPages");var i=null==e.boundaryPagesRange?1:Number(e.boundaryPagesRange);if(isNaN(i))throw new Error("getPaginationModel(): boundaryPagesRange should be a number");if(i<0)throw new Error("getPaginationModel(): boundaryPagesRange shouldn't be a negative number");var o=null==e.siblingPagesRange?1:Number(e.siblingPagesRange);if(isNaN(o))throw new Error("getPaginationModel(): siblingPagesRange should be a number");if(o<0)throw new Error("getPaginationModel(): siblingPagesRange shouldn't be a negative number");var l=Boolean(e.hidePreviousAndNextPageLinks),s=Boolean(e.hideFirstAndLastPageLinks),c=Boolean(e.hideEllipsis),u=c?0:1,d=[],g=n.createPageFunctionFactory(e);if(s||d.push(n.createFirstPageLink(e)),l||d.push(n.createPreviousPageLink(e)),1+2*u+2*o+2*i>=t){var p=r.createRange(1,t).map(g);d.push.apply(d,p)}else{var h=i,b=r.createRange(1,h).map(g),P=t+1-i,E=t,m=r.createRange(P,E).map(g),v=Math.min(Math.max(a-o,h+u+1),P-u-2*o-1),f=v+2*o,S=r.createRange(v,f).map(g);if(d.push.apply(d,b),!c){var Z=v-1,y=(Z===h+1?g:n.createFirstEllipsis)(Z);d.push(y)}if(d.push.apply(d,S),!c){var _=f+1,L=(_===P-1?g:n.createSecondEllipsis)(_);d.push(L)}d.push.apply(d,m)}return l||d.push(n.createNextPageLink(e)),s||d.push(n.createLastPageLink(e)),d};var i=a(656590);t.ITEM_TYPES=i.ITEM_TYPES,t.ITEM_KEYS=i.ITEM_KEYS}}]);
//# sourceMappingURL=60369560067ac0f8e859.chunk.js.map