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

    &:hover {
      path {
        fill: ${({theme:e})=>e.colors.primary.base};
      }
    }
  }
`,o=n.iK.span`
  color: ${({theme:e})=>e.colors.grayscale.base};
`;function d({actions:e}){return(0,l.tZ)(s,{className:"actions",children:e.map(((e,t)=>{const a=r.Z[e.icon];return e.tooltip?(0,l.tZ)(i.u,{id:`${e.label}-tooltip`,title:e.tooltip,placement:e.placement,children:(0,l.tZ)(o,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,l.tZ)(a,{})})},t):(0,l.tZ)(o,{role:"button",tabIndex:0,className:"action-button",onClick:e.onClick,children:(0,l.tZ)(a,{})},t)}))})}},936942:(e,t,a)=>{a.r(t),a.d(t,{default:()=>N});var n=a(667294),i=a(61988),r=a(431069),l=a(115926),s=a.n(l),o=a(34858),d=a(440768),c=a(414114),u=a(586074),g=a(217198),p=a(419259),h=a(129848),m=a(593139),P=a(751995),E=a(313322),b=a(774069),_=a(749140),S=a(135944);const f=P.iK.div`
  margin: ${({theme:e})=>2*e.gridUnit}px auto
    ${({theme:e})=>4*e.gridUnit}px auto;
`,v=(0,P.iK)(_.ry)`
  border-radius: ${({theme:e})=>e.borderRadius}px;
  border: 1px solid ${({theme:e})=>e.colors.secondary.light2};
`,L=P.iK.div`
  margin-bottom: ${({theme:e})=>10*e.gridUnit}px;

  .control-label {
    margin-bottom: ${({theme:e})=>2*e.gridUnit}px;
  }

  .required {
    margin-left: ${({theme:e})=>e.gridUnit/2}px;
    color: ${({theme:e})=>e.colors.error.base};
  }

  input[type='text'] {
    padding: ${({theme:e})=>1.5*e.gridUnit}px
      ${({theme:e})=>2*e.gridUnit}px;
    border: 1px solid ${({theme:e})=>e.colors.grayscale.light2};
    border-radius: ${({theme:e})=>e.gridUnit}px;
    width: 50%;
  }
`,I=(0,c.ZP)((({addDangerToast:e,onCssTemplateAdd:t,onHide:a,show:r,cssTemplate:l=null})=>{const[s,c]=(0,n.useState)(!0),[u,g]=(0,n.useState)(null),[p,h]=(0,n.useState)(!0),m=null!==l,{state:{loading:P,resource:_},fetchResource:I,createResource:y,updateResource:T}=(0,o.LE)("css_template",(0,i.t)("css_template"),e),N=()=>{h(!0),a()};return(0,n.useEffect)((()=>{if(m&&(null==u||!u.id||l&&(null==l?void 0:l.id)!==u.id||p&&r)){if(null!==(null==l?void 0:l.id)&&!P){const e=l.id||0;I(e)}}else!m&&(!u||u.id||p&&r)&&g({template_name:"",css:""})}),[l]),(0,n.useEffect)((()=>{_&&g(_)}),[_]),(0,n.useEffect)((()=>{var e;null!=u&&u.template_name.length&&null!=u&&null!=(e=u.css)&&e.length?c(!1):c(!0)}),[u?u.template_name:"",u?u.css:""]),p&&r&&h(!1),(0,S.BX)(b.default,{disablePrimaryButton:s,onHandledPrimaryAction:()=>{if(m){if(null!=u&&u.id){const e=u.id;delete u.id,delete u.created_by,delete u.changed_by,delete u.changed_on_delta_humanized,T(e,u).then((e=>{e&&(t&&t(),N())}))}}else u&&y(u).then((e=>{e&&(t&&t(),N())}))},onHide:N,primaryButtonName:m?(0,i.t)("Save"):(0,i.t)("Add"),show:r,width:"55%",title:(0,S.BX)("h4",{children:[m?(0,S.tZ)(E.Z.EditAlt,{css:d.xL}):(0,S.tZ)(E.Z.PlusLarge,{css:d.xL}),m?(0,i.t)("Edit CSS template properties"):(0,i.t)("Add CSS template")]}),children:[(0,S.tZ)(f,{children:(0,S.tZ)("h4",{children:(0,i.t)("Basic information")})}),(0,S.BX)(L,{children:[(0,S.BX)("div",{className:"control-label",children:[(0,i.t)("Name"),(0,S.tZ)("span",{className:"required",children:"*"})]}),(0,S.tZ)("input",{name:"template_name",onChange:e=>{const{target:t}=e,a={...u,template_name:u?u.template_name:"",css:u?u.css:""};a[t.name]=t.value,g(a)},type:"text",value:null==u?void 0:u.template_name})]}),(0,S.BX)(L,{children:[(0,S.BX)("div",{className:"control-label",children:[(0,i.t)("css"),(0,S.tZ)("span",{className:"required",children:"*"})]}),(0,S.tZ)(v,{onChange:e=>{const t={...u,template_name:u?u.template_name:"",css:e};g(t)},value:null==u?void 0:u.css,width:"100%"})]})]})}));var y=a(554070),T=a(400012);const N=(0,c.ZP)((function({addDangerToast:e,addSuccessToast:t,user:a}){const{state:{loading:l,resourceCount:c,resourceCollection:P,bulkSelectEnabled:E},hasPerm:b,fetchData:_,refreshData:f,toggleBulkSelect:v}=(0,o.Yi)("css_template",(0,i.t)("CSS templates"),e),[L,N]=(0,n.useState)(!1),[A,k]=(0,n.useState)(null),w=b("can_write"),M=b("can_write"),R=b("can_write"),[Z,C]=(0,n.useState)(null),K=[{id:"template_name",desc:!0}],x=(0,n.useMemo)((()=>[{accessor:"template_name",Header:(0,i.t)("Name")},{Cell:({row:{original:{changed_on_delta_humanized:e,changed_by:t}}})=>(0,S.tZ)(y.w,{date:e,user:t}),Header:(0,i.t)("Last modified"),accessor:"changed_on_delta_humanized",size:"xl",disableSortBy:!0},{Cell:({row:{original:e}})=>{const t=[M?{label:"edit-action",tooltip:(0,i.t)("Edit template"),placement:"bottom",icon:"Edit",onClick:()=>(k(e),void N(!0))}:null,R?{label:"delete-action",tooltip:(0,i.t)("Delete template"),placement:"bottom",icon:"Trash",onClick:()=>C(e)}:null].filter((e=>!!e));return(0,S.tZ)(h.Z,{actions:t})},Header:(0,i.t)("Actions"),id:"actions",disableSortBy:!0,hidden:!M&&!R,size:"xl"},{accessor:T.J.ChangedBy,hidden:!0}]),[R,w]),Y={name:(0,i.t)("CSS templates")},G=[];w&&G.push({name:(0,S.BX)(S.HY,{children:[(0,S.tZ)("i",{className:"fa fa-plus"})," ",(0,i.t)("CSS template")]}),buttonStyle:"primary",onClick:()=>{k(null),N(!0)}}),R&&G.push({name:(0,i.t)("Bulk select"),onClick:v,buttonStyle:"secondary"}),Y.buttons=G;const B=(0,n.useMemo)((()=>[{Header:(0,i.t)("Name"),key:"search",id:"template_name",input:"search",operator:m.p.Contains},{Header:(0,i.t)("Modified by"),key:"changed_by",id:"changed_by",input:"select",operator:m.p.RelationOneMany,unfilteredLabel:(0,i.t)("All"),fetchSelects:(0,d.tm)("css_template","changed_by",(0,d.v$)((e=>(0,i.t)("An error occurred while fetching dataset datasource values: %s",e))),a),paginate:!0}]),[]);return(0,S.BX)(S.HY,{children:[(0,S.tZ)(u.Z,{...Y}),(0,S.tZ)(I,{addDangerToast:e,cssTemplate:A,onCssTemplateAdd:()=>f(),onHide:()=>N(!1),show:L}),Z&&(0,S.tZ)(g.Z,{description:(0,i.t)("This action will permanently delete the template."),onConfirm:()=>{Z&&(({id:a,template_name:n})=>{r.Z.delete({endpoint:`/api/v1/css_template/${a}`}).then((()=>{f(),C(null),t((0,i.t)("Deleted: %s",n))}),(0,d.v$)((t=>e((0,i.t)("There was an issue deleting %s: %s",n,t)))))})(Z)},onHide:()=>C(null),open:!0,title:(0,i.t)("Delete Template?")}),(0,S.tZ)(p.Z,{title:(0,i.t)("Please confirm"),description:(0,i.t)("Are you sure you want to delete the selected templates?"),onConfirm:a=>{r.Z.delete({endpoint:`/api/v1/css_template/?q=${s().encode(a.map((({id:e})=>e)))}`}).then((({json:e={}})=>{f(),t(e.message)}),(0,d.v$)((t=>e((0,i.t)("There was an issue deleting the selected templates: %s",t)))))},children:a=>{const n=R?[{key:"delete",name:(0,i.t)("Delete"),onSelect:a,type:"danger"}]:[];return(0,S.tZ)(m.Z,{className:"css-templates-list-view",columns:x,count:c,data:P,fetchData:_,filters:B,initialSort:K,loading:l,pageSize:25,bulkActions:n,bulkSelectEnabled:E,disableBulkSelect:v,addDangerToast:e,addSuccessToast:t,refreshData:f})}})]})}))},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 n=a(656590);t.createFirstEllipsis=function(e){return{type:n.ITEM_TYPES.ELLIPSIS,key:n.ITEM_KEYS.FIRST_ELLIPSIS,value:e,isActive:!1}},t.createSecondEllipsis=function(e){return{type:n.ITEM_TYPES.ELLIPSIS,key:n.ITEM_KEYS.SECOND_ELLIPSIS,value:e,isActive:!1}},t.createFirstPageLink=function(e){var t=e.currentPage;return{type:n.ITEM_TYPES.FIRST_PAGE_LINK,key:n.ITEM_KEYS.FIRST_PAGE_LINK,value:1,isActive:1===t}},t.createPreviousPageLink=function(e){var t=e.currentPage;return{type:n.ITEM_TYPES.PREVIOUS_PAGE_LINK,key:n.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:n.ITEM_TYPES.NEXT_PAGE_LINK,key:n.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:n.ITEM_TYPES.LAST_PAGE_LINK,key:n.ITEM_KEYS.LAST_PAGE_LINK,value:a,isActive:t===a}},t.createPageFunctionFactory=function(e){var t=e.currentPage;return function(e){return{type:n.ITEM_TYPES.PAGE,key:e,value:e,isActive:e===t}}}},1158:(e,t)=>{t.createRange=function(e,t){for(var a=[],n=e;n<=t;n++)a.push(n);return a}},402371:(e,t,a)=>{var n=a(1158),i=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 r=null==e.boundaryPagesRange?1:Number(e.boundaryPagesRange);if(isNaN(r))throw new Error("getPaginationModel(): boundaryPagesRange should be a number");if(r<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 s=Boolean(e.hidePreviousAndNextPageLinks),o=Boolean(e.hideFirstAndLastPageLinks),d=Boolean(e.hideEllipsis),c=d?0:1,u=[],g=i.createPageFunctionFactory(e);if(o||u.push(i.createFirstPageLink(e)),s||u.push(i.createPreviousPageLink(e)),1+2*c+2*l+2*r>=t){var p=n.createRange(1,t).map(g);u.push.apply(u,p)}else{var h=r,m=n.createRange(1,h).map(g),P=t+1-r,E=t,b=n.createRange(P,E).map(g),_=Math.min(Math.max(a-l,h+c+1),P-c-2*l-1),S=_+2*l,f=n.createRange(_,S).map(g);if(u.push.apply(u,m),!d){var v=_-1,L=(v===h+1?g:i.createFirstEllipsis)(v);u.push(L)}if(u.push.apply(u,f),!d){var I=S+1,y=(I===P-1?g:i.createSecondEllipsis)(I);u.push(y)}u.push.apply(u,b)}return s||u.push(i.createNextPageLink(e)),o||u.push(i.createLastPageLink(e)),u};var r=a(656590);t.ITEM_TYPES=r.ITEM_TYPES,t.ITEM_KEYS=r.ITEM_KEYS}}]);
//# sourceMappingURL=306d0879fedb1e44e9b2.chunk.js.map