"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[9563],{52630:(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=o(a(67294)),i=o(a(45697)),l=a(2371);function o(e){return e&&e.__esModule?e:{default:e}}t.YM=function(e){var t=e.itemTypeToComponent,a=e.WrapperComponent,o=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,b=e.disabled,h=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"]),m=(0,l.getPaginationModel)({currentPage:a,totalPages:i,boundaryPagesRange:s,siblingPagesRange:c,hideEllipsis:u,hidePreviousAndNextPageLinks:d,hideFirstAndLastPageLinks:g}),P=function(e,t,a){return function(i){var l,o,s,c=e[i.type],u=(o=(l=i).value,s=l.isDisabled,function(){!s&&a&&t!==o&&a(o)});return n.default.createElement(c,r({onClick:u},i))}}(t,a,p);return n.default.createElement(o,h,m.map((function(e){return P(r({},e,{isDisabled:!!b}))})))};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=l.ITEM_TYPES},54070:(e,t,a)=>{a.d(t,{w:()=>o}),a(67294);var r=a(58593),n=a(83379),i=a(61988),l=a(11965);const o=({user:e,date:t})=>{const a=(0,l.tZ)("span",{className:"no-wrap"},t);if(e){const t=(0,n.Z)(e),o=(0,i.t)("Modified by: %s",t);return(0,l.tZ)(r.u,{title:o,placement:"bottom"},a)}return a}},29848:(e,t,a)=>{a.d(t,{Z:()=>c}),a(67294);var r=a(51995),n=a(58593),i=a(70707),l=a(11965);const o=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,l.tZ)(o,{className:"actions"},e.map(((e,t)=>{const a=i.Z[e.icon];return e.tooltip?(0,l.tZ)(n.u,{id:`${e.label}-tooltip`,title:e.tooltip,placement:e.placement,key:t},(0,l.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick},(0,l.tZ)(a,null))):(0,l.tZ)(s,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,key:t},(0,l.tZ)(a,null))})))}},94222:(e,t,a)=>{a.d(t,{Z:()=>u});var r=a(51995),n=a(61988),i=(a(67294),a(58593)),l=a(70707),o=a(90335),s=a(11965);function c(e,t,a){switch(e){case o.Z9.Working:return a.colors.primary.base;case o.Z9.Error:return a.colors.error.base;case o.Z9.Success:return t?a.colors.success.base:a.colors.alert.base;case o.Z9.Noop:return a.colors.success.base;case o.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:l.Z.Check,label:"",status:""};switch(e){case o.Z9.Success:u.icon=t?l.Z.Check:l.Z.AlertSolidSmall,u.label=t?(0,n.t)("Report sent"):(0,n.t)("Alert triggered, notification sent"),u.status=o.Z9.Success;break;case o.Z9.Working:u.icon=l.Z.Running,u.label=t?(0,n.t)("Report sending"):(0,n.t)("Alert running"),u.status=o.Z9.Working;break;case o.Z9.Error:u.icon=l.Z.XSmall,u.label=t?(0,n.t)("Report failed"):(0,n.t)("Alert failed"),u.status=o.Z9.Error;break;case o.Z9.Noop:u.icon=l.Z.Check,u.label=(0,n.t)("Nothing triggered"),u.status=o.Z9.Noop;break;case o.Z9.Grace:u.icon=l.Z.AlertSolidSmall,u.label=(0,n.t)("Alert Triggered, In Grace Period"),u.status=o.Z9.Grace;break;default:u.icon=l.Z.Check,u.label=(0,n.t)("Nothing triggered"),u.status=o.Z9.Noop}const d=u.icon;return(0,s.tZ)(i.u,{title:u.label,placement:"bottomLeft"},(0,s.tZ)(d,{iconColor:c(u.status,t,a)}))}},32635:(e,t,a)=>{a.r(t),a.d(t,{default:()=>z});var r=a(67294),n=a(16550),i=a(75049),l=a(61988),o=a(22102),s=a(51995),c=a(31069),u=a(30381),d=a.n(u),g=a(29848),p=a(34581),b=a(58593),h=a(93139),m=a(86074),P=a(12441),E=a(27600),f=a(14114),v=a(94222),S=a(11965),Z=a(70707),y=a(90335);const _=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.ud.Email:t.icon=(0,S.tZ)(Z.Z.Email,{css:_}),t.label=y.ud.Email;break;case y.ud.Slack:t.icon=(0,S.tZ)(Z.Z.Slack,{css:_}),t.label=y.ud.Slack;break;default:t.icon=null,t.label=""}return t.icon?(0,S.tZ)(b.u,{title:t.label,placement:"bottom"},t.icon):null}var L=a(19259),I=a(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 T=s.iK.span`
  color: ${({theme:e})=>e.colors.grayscale.base};
`,w=(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;
`,A=({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,S.tZ)(T,null,(0,l.t)("Last Updated %s",a.isValid()?a.calendar():"--"),t&&(0,S.tZ)(w,{onClick:t}))};var N=a(34858),R=a(40768),M=a(22318),C=a(67317),x=a(54070),K=a(12);const G=(0,i.I)(),$={[y.Z9.Success]:(0,l.t)("Success"),[y.Z9.Working]:(0,l.t)("Working"),[y.Z9.Error]:(0,l.t)("Error"),[y.Z9.Noop]:(0,l.t)("Not triggered"),[y.Z9.Grace]:(0,l.t)("On Grace")},F=(0,o.Z)({requestType:"rison",method:"DELETE",endpoint:"/api/v1/report/"}),Y=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};
`,D=s.iK.div`
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  > *:first-child {
    margin-right: ${({theme:e})=>e.gridUnit}px;
  }
`,O=G.get("alertsreports.header.icon"),z=(0,f.ZP)((function({addDangerToast:e,isReportEnabled:t=!1,user:a,addSuccessToast:i}){const o=t?(0,l.t)("report"):(0,l.t)("alert"),s=t?(0,l.t)("reports"):(0,l.t)("alerts"),u=t?"Reports":"Alerts",f=(0,r.useMemo)((()=>[{id:"type",operator:h.p.Equals,value:t?"Report":"Alert"}]),[t]),{state:{loading:Z,resourceCount:_,resourceCollection:T,bulkSelectEnabled:w,lastFetched:G},hasPerm:z,fetchData:B,setResourceCollection:H,refreshData:U,toggleBulkSelect:W}=(0,N.Yi)("report",(0,l.t)("reports"),e,!0,void 0,f),{updateResource:V}=(0,N.LE)("report",(0,l.t)("reports"),e),[X,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=z("can_write"),re=z("can_write"),ne=z("can_write");(0,r.useEffect)((()=>{w&&re&&W()}),[t]);const ie=[{id:"name",desc:!0}],le=(0,r.useCallback)(((e,t)=>{if(null!=e&&e.id){const a=e.id,r=[...T];H(r.map((a=>(null==a?void 0:a.id)===e.id?{...a,active:t}:a))),V(a,{active:t},!1,!1).then().catch((()=>H(r)))}}),[T,H,V]),oe=(0,r.useMemo)((()=>[{Cell:({row:{original:{last_state:e}}})=>(0,S.tZ)(v.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(E.v2):"",accessor:"last_eval_dttm",Header:(0,l.t)("Last run"),size:"lg"},{accessor:"name",Header:(0,l.t)("Name"),size:"xl"},{Header:(0,l.t)("Schedule"),accessor:"crontab_humanized",size:"xl",Cell:({row:{original:{crontab_humanized:e="",timezone:t}}})=>(0,S.tZ)(b.u,{title:`${e} (${t})`,placement:"topLeft"},(0,S.tZ)("span",null,`${e} (${t})`))},{Cell:({row:{original:{recipients:e}}})=>e.map((e=>(0,S.tZ)(k,{key:e.id,type:e.type}))),accessor:"recipients",Header:(0,l.t)("Notification method"),disableSortBy:!0,size:"xl"},{Cell:({row:{original:{owners:e=[]}}})=>(0,S.tZ)(p.Z,{users:e}),Header:(0,l.t)("Owners"),id:"owners",disableSortBy:!0,size:"xl"},{Cell:({row:{original:{changed_on_delta_humanized:e,changed_by:t}}})=>(0,S.tZ)(x.w,{date:e,user:t}),Header:(0,l.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,M.i5)(a);return(0,S.tZ)(P.r,{disabled:!t,checked:e.active,onClick:t=>le(e,t),size:"small"})},Header:(0,l.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,M.i5)(a),i=[ae?{label:"execution-log-action",tooltip:(0,l.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,l.t)("Edit"):(0,l.t)("View"),placement:"bottom",icon:r?"Edit":"Binoculars",onClick:()=>te(e)}:null,r&&re?{label:"delete-action",tooltip:(0,l.t)("Delete"),placement:"bottom",icon:"Trash",onClick:()=>ee(e)}:null].filter((e=>null!==e));return(0,S.tZ)(g.Z,{actions:i})},Header:(0,l.t)("Actions"),id:"actions",hidden:!ae&&!re,disableSortBy:!0,size:"xl"},{accessor:K.J.ChangedBy,hidden:!0}]),[re,ae,t,le]),se=[];ne&&se.push({name:(0,S.tZ)(r.Fragment,null,(0,S.tZ)("i",{className:"fa fa-plus"})," ",o),buttonStyle:"primary",onClick:()=>{te(null)}}),re&&se.push({name:(0,l.t)("Bulk select"),onClick:W,buttonStyle:"secondary","data-test":"bulk-select-toggle"});const ce={title:(0,l.t)("No %s yet",s),image:"filter-results.svg",buttonAction:()=>te(null),buttonText:ne?(0,S.tZ)(r.Fragment,null,(0,S.tZ)("i",{className:"fa fa-plus"})," ",o," "):null},ue=(0,r.useMemo)((()=>[{Header:(0,l.t)("Name"),key:"search",id:"name",input:"search",operator:h.p.Contains},{Header:(0,l.t)("Owner"),key:"owner",id:"owners",input:"select",operator:h.p.RelationManyMany,unfilteredLabel:(0,l.t)("All"),fetchSelects:(0,R.tm)("report","owners",(0,R.v$)((e=>(0,l.t)("An error occurred while fetching owners values: %s",e))),a),paginate:!0},{Header:(0,l.t)("Status"),key:"status",id:"last_state",input:"select",operator:h.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,l.t)("Modified by"),key:"changed_by",id:"changed_by",input:"select",operator:h.p.RelationOneMany,unfilteredLabel:(0,l.t)("All"),fetchSelects:(0,R.tm)("report","changed_by",(0,R.v$)((e=>(0,l.t)("An error occurred while fetching dataset datasource values: %s",e))),a),paginate:!0}]),[]),de=O?(0,S.tZ)(D,null,(0,S.tZ)("div",null,(0,l.t)("Alerts & reports")),(0,S.tZ)(O,null)):(0,l.t)("Alerts & reports");return(0,S.tZ)(r.Fragment,null,(0,S.tZ)(m.Z,{activeChild:u,name:de,tabs:[{name:"Alerts",label:(0,l.t)("Alerts"),url:"/alert/list/",usesRouter:!0,"data-test":"alert-list"},{name:"Reports",label:(0,l.t)("Reports"),url:"/report/list/",usesRouter:!0,"data-test":"report-list"}],buttons:se},(0,S.tZ)(Y,null,(0,S.tZ)(A,{updatedAt:G,update:()=>U()}))),(0,S.tZ)(C.ZP,{alert:q,addDangerToast:e,layer:q,onHide:()=>{j(!1),J(null),U()},show:X,isReport:t,key:(null==q?void 0:q.id)||`${(new Date).getTime()}`}),Q&&(0,S.tZ)(I.Z,{description:(0,l.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,l.t)("Deleted: %s",a))}),(0,R.v$)((t=>e((0,l.t)("There was an issue deleting %s: %s",a,t)))))})(Q)},onHide:()=>ee(null),open:!0,title:(0,l.t)("Delete %s?",o)}),(0,S.tZ)(L.Z,{title:(0,l.t)("Please confirm"),description:(0,l.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,R.v$)((t=>e((0,l.t)("There was an issue deleting the selected %s: %s",s,t))))(t)}}},(t=>{const a=re?[{key:"delete",name:(0,l.t)("Delete"),onSelect:t,type:"danger"}]:[];return(0,S.tZ)(h.Z,{className:"alerts-list-view",columns:oe,count:_,data:T,emptyState:ce,fetchData:B,filters:ue,initialSort:ie,loading:Z,bulkActions:a,bulkSelectEnabled:w,disableBulkSelect:W,refreshData:U,addDangerToast:e,addSuccessToast:i,pageSize:25})})))}))},83379:(e,t,a)=>{function r(e){return e?`${e.first_name} ${e.last_name}`:""}a.d(t,{Z:()=>r})},56590:(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}},53804:(e,t,a)=>{var r=a(56590);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}},2371:(e,t,a)=>{var r=a(1158),n=a(53804);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 l=null==e.siblingPagesRange?1:Number(e.siblingPagesRange);if(isNaN(l))throw new Error("getPaginationModel(): siblingPagesRange should be a number");if(l<0)throw new Error("getPaginationModel(): siblingPagesRange shouldn't be a negative number");var o=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)),o||d.push(n.createPreviousPageLink(e)),1+2*u+2*l+2*i>=t){var p=r.createRange(1,t).map(g);d.push.apply(d,p)}else{var b=i,h=r.createRange(1,b).map(g),m=t+1-i,P=t,E=r.createRange(m,P).map(g),f=Math.min(Math.max(a-l,b+u+1),m-u-2*l-1),v=f+2*l,S=r.createRange(f,v).map(g);if(d.push.apply(d,h),!c){var Z=f-1,y=(Z===b+1?g:n.createFirstEllipsis)(Z);d.push(y)}if(d.push.apply(d,S),!c){var _=v+1,k=(_===m-1?g:n.createSecondEllipsis)(_);d.push(k)}d.push.apply(d,E)}return o||d.push(n.createNextPageLink(e)),s||d.push(n.createLastPageLink(e)),d};var i=a(56590);t.ITEM_TYPES=i.ITEM_TYPES,t.ITEM_KEYS=i.ITEM_KEYS}}]);
//# sourceMappingURL=43011e1d5c0b01f0efc6.chunk.js.map