"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[4502],{52630:(e,a,t)=>{a.iB=a.YM=void 0;var n=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},l=s(t(67294)),o=s(t(45697)),r=t(2371);function s(e){return e&&e.__esModule?e:{default:e}}a.YM=function(e){var a=e.itemTypeToComponent,t=e.WrapperComponent,s=void 0===t?"div":t,i=function(e){var t=e.currentPage,o=e.totalPages,i=e.boundaryPagesRange,d=e.siblingPagesRange,u=e.hideEllipsis,c=e.hidePreviousAndNextPageLinks,g=e.hideFirstAndLastPageLinks,b=e.onChange,p=e.disabled,_=function(e,a){var t={};for(var n in e)a.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}(e,["currentPage","totalPages","boundaryPagesRange","siblingPagesRange","hideEllipsis","hidePreviousAndNextPageLinks","hideFirstAndLastPageLinks","onChange","disabled"]),h=(0,r.getPaginationModel)({currentPage:t,totalPages:o,boundaryPagesRange:i,siblingPagesRange:d,hideEllipsis:u,hidePreviousAndNextPageLinks:c,hideFirstAndLastPageLinks:g}),P=function(e,a,t){return function(o){var r,s,i,d=e[o.type],u=(s=(r=o).value,i=r.isDisabled,function(){!i&&t&&a!==s&&t(s)});return l.default.createElement(d,n({onClick:u},o))}}(a,t,b);return l.default.createElement(s,_,h.map((function(e){return P(n({},e,{isDisabled:!!p}))})))};return i.propTypes={currentPage:o.default.number.isRequired,totalPages:o.default.number.isRequired,boundaryPagesRange:o.default.number,siblingPagesRange:o.default.number,hideEllipsis:o.default.bool,hidePreviousAndNextPageLinks:o.default.bool,hideFirstAndLastPageLinks:o.default.bool,onChange:o.default.func,disabled:o.default.bool},i},a.iB=r.ITEM_TYPES},54070:(e,a,t)=>{t.d(a,{w:()=>s}),t(67294);var n=t(58593),l=t(83379),o=t(61988),r=t(11965);const s=({user:e,date:a})=>{const t=(0,r.tZ)("span",{className:"no-wrap"},a);if(e){const a=(0,l.Z)(e),s=(0,o.t)("Modified by: %s",a);return(0,r.tZ)(n.u,{title:s,placement:"bottom"},t)}return t}},95731:(e,a,t)=>{t.r(a),t.d(a,{default:()=>D});var n=t(75049),l=t(51995),o=t(61988),r=t(31069),s=t(67294),i=t(15926),d=t.n(i),u=t(28216),c=t(35755),g=t(61337),b=t(38703),p=t(34858),_=t(40768),h=t(14114),P=t(86074),E=t(17198),m=t(23525),f=t(27600),v=t(58593),S=t(70707),L=t(22318),I=t(93139),y=t(32228),N=t(1315),A=t(54070),T=t(12),w=t(11965);const Z=(0,n.I)(),M=Z.get("database.delete.related"),k=Z.get("databaseconnection.extraOption"),R=(0,l.iK)(S.Z.Check)`
  color: ${({theme:e})=>e.colors.grayscale.dark1};
`,C=(0,l.iK)(S.Z.CancelX)`
  color: ${({theme:e})=>e.colors.grayscale.light1};
`,K=l.iK.div`
  color: ${({theme:e})=>e.colors.grayscale.base};

  .action-button {
    display: inline-block;
    height: 100%;
  }
`;function x({value:e}){return e?(0,w.tZ)(R,null):(0,w.tZ)(C,null)}const D=(0,h.ZP)((function({addDangerToast:e,addSuccessToast:a,user:t}){const{state:{loading:n,resourceCount:l,resourceCollection:i},hasPerm:h,fetchData:Z,refreshData:R}=(0,p.Yi)("database",(0,o.t)("database"),e),C=(0,u.v9)((e=>e.user)),D=(0,m.eY)(f.KD.showDatabaseModal),[Y,O]=(0,c.Kx)({databaseAdded:c.dJ}),[F,G]=(0,s.useState)(D||!1),[U,q]=(0,s.useState)(null),[H,X]=(0,s.useState)(null),[$,z]=(0,s.useState)(!1),V=(0,L.i5)(C),B=$||V,[j,Q]=(0,s.useState)(!1),{roles:J}=C,{CSV_EXTENSIONS:W,COLUMNAR_EXTENSIONS:ee,EXCEL_EXTENSIONS:ae,ALLOWED_EXTENSIONS:te}=(0,u.v9)((e=>e.common.conf));function ne({database:e=null,modalOpen:a=!1}={}){X(e),G(a)}(0,s.useEffect)((()=>{null!=Y&&Y.databaseAdded&&(O({databaseAdded:void 0}),R())}),[Y,O,R]);const le=h("can_write"),oe=h("can_write"),re=h("can_write"),se=h("can_export"),{canUploadCSV:ie,canUploadColumnar:de,canUploadExcel:ue}=(0,_.Mc)(J,W,ee,ae,te),ce=V&&!$,ge=[{label:(0,o.t)("Upload file to database"),childs:[{label:(0,o.t)("Upload CSV"),name:"Upload CSV file",url:"/csvtodatabaseview/form",perm:ie&&B,disable:ce},{label:(0,o.t)("Upload columnar file"),name:"Upload columnar file",url:"/columnartodatabaseview/form",perm:de&&B,disable:ce},{label:(0,o.t)("Upload Excel file"),name:"Upload Excel file",url:"/exceltodatabaseview/form",perm:ue&&B,disable:ce}]}];(0,s.useEffect)((()=>{r.Z.get({endpoint:`/api/v1/database/?q=${d().encode({filters:[{col:"allow_file_upload",opr:"upload_is_enabled",value:!0}]})}`}).then((({json:e})=>{var a;const t=(null==e||null==(a=e.result)?void 0:a.filter((e=>{var a;return null==e||null==(a=e.engine_information)?void 0:a.supports_file_upload})))||[];z((null==t?void 0:t.length)>=1)}))}),[F]);const be={activeChild:"Databases",dropDownLinks:ge.reduce(((e,a)=>(a.childs=a.childs.filter((e=>e.perm)),a.childs.length?(e.push(a),e):e)),[]),name:(0,o.t)("Databases")};le&&(be.buttons=[{"data-test":"btn-create-database",name:(0,w.tZ)(s.Fragment,null,(0,w.tZ)("i",{className:"fa fa-plus"})," ",(0,o.t)("Database")," "),buttonStyle:"primary",onClick:()=>{ne({modalOpen:!0})}}]);const pe=(0,s.useMemo)((()=>[{accessor:"database_name",Header:(0,o.t)("Name")},{accessor:"backend",Header:(0,o.t)("Backend"),size:"lg",disableSortBy:!0},{accessor:"allow_run_async",Header:(0,w.tZ)(v.u,{id:"allow-run-async-header-tooltip",title:(0,o.t)("Asynchronous query execution"),placement:"top"},(0,w.tZ)("span",null,(0,o.t)("AQE"))),Cell:({row:{original:{allow_run_async:e}}})=>(0,w.tZ)(x,{value:e}),size:"sm"},{accessor:"allow_dml",Header:(0,w.tZ)(v.u,{id:"allow-dml-header-tooltip",title:(0,o.t)("Allow data manipulation language"),placement:"top"},(0,w.tZ)("span",null,(0,o.t)("DML"))),Cell:({row:{original:{allow_dml:e}}})=>(0,w.tZ)(x,{value:e}),size:"sm"},{accessor:"allow_file_upload",Header:(0,o.t)("CSV upload"),Cell:({row:{original:{allow_file_upload:e}}})=>(0,w.tZ)(x,{value:e}),size:"md"},{accessor:"expose_in_sqllab",Header:(0,o.t)("Expose in SQL Lab"),Cell:({row:{original:{expose_in_sqllab:e}}})=>(0,w.tZ)(x,{value:e}),size:"md"},{Cell:({row:{original:{changed_by:e,changed_on_delta_humanized:a}}})=>(0,w.tZ)(A.w,{date:a,user:e}),Header:(0,o.t)("Last modified"),accessor:"changed_on_delta_humanized",size:"xl"},{Cell:({row:{original:e}})=>oe||re||se?(0,w.tZ)(K,{className:"actions"},re&&(0,w.tZ)("span",{role:"button",tabIndex:0,className:"action-button",onClick:()=>{return a=e,r.Z.get({endpoint:`/api/v1/database/${a.id}/related_objects/`}).then((({json:e={}})=>{q({...a,chart_count:e.charts.count,dashboard_count:e.dashboards.count,sqllab_tab_count:e.sqllab_tab_states.count})})).catch((0,_.v$)((e=>(0,o.t)("An error occurred while fetching database related data: %s",e))));var a}},(0,w.tZ)(v.u,{id:"delete-action-tooltip",title:(0,o.t)("Delete database"),placement:"bottom"},(0,w.tZ)(S.Z.Trash,null))),se&&(0,w.tZ)(v.u,{id:"export-action-tooltip",title:(0,o.t)("Export"),placement:"bottom"},(0,w.tZ)("span",{role:"button",tabIndex:0,className:"action-button",onClick:()=>{var a;void 0!==(a=e).id&&((0,y.Z)("database",[a.id],(()=>{Q(!1)})),Q(!0))}},(0,w.tZ)(S.Z.Share,null))),oe&&(0,w.tZ)(v.u,{id:"edit-action-tooltip",title:(0,o.t)("Edit"),placement:"bottom"},(0,w.tZ)("span",{role:"button",tabIndex:0,className:"action-button",onClick:()=>ne({database:e,modalOpen:!0})},(0,w.tZ)(S.Z.EditAlt,null)))):null,Header:(0,o.t)("Actions"),id:"actions",hidden:!oe&&!re,disableSortBy:!0},{accessor:T.J.ChangedBy,hidden:!0}]),[re,oe,se]),_e=(0,s.useMemo)((()=>[{Header:(0,o.t)("Name"),key:"search",id:"database_name",input:"search",operator:I.p.Contains},{Header:(0,o.t)("Expose in SQL Lab"),key:"expose_in_sql_lab",id:"expose_in_sqllab",input:"select",operator:I.p.Equals,unfilteredLabel:(0,o.t)("All"),selects:[{label:(0,o.t)("Yes"),value:!0},{label:(0,o.t)("No"),value:!1}]},{Header:(0,w.tZ)(v.u,{id:"allow-run-async-filter-header-tooltip",title:(0,o.t)("Asynchronous query execution"),placement:"top"},(0,w.tZ)("span",null,(0,o.t)("AQE"))),key:"allow_run_async",id:"allow_run_async",input:"select",operator:I.p.Equals,unfilteredLabel:(0,o.t)("All"),selects:[{label:(0,o.t)("Yes"),value:!0},{label:(0,o.t)("No"),value:!1}]},{Header:(0,o.t)("Modified by"),key:"changed_by",id:"changed_by",input:"select",operator:I.p.RelationOneMany,unfilteredLabel:(0,o.t)("All"),fetchSelects:(0,_.tm)("database","changed_by",(0,_.v$)((e=>(0,o.t)("An error occurred while fetching dataset datasource values: %s",e))),t),paginate:!0}]),[]);return(0,w.tZ)(s.Fragment,null,(0,w.tZ)(P.Z,be),(0,w.tZ)(N.ZP,{databaseId:null==H?void 0:H.id,show:F,onHide:ne,onDatabaseAdd:()=>{R()}}),U&&(0,w.tZ)(E.Z,{description:(0,w.tZ)(s.Fragment,null,(0,w.tZ)("p",null,(0,o.t)("The database %s is linked to %s charts that appear on %s dashboards and users have %s SQL Lab tabs using this database open. Are you sure you want to continue? Deleting the database will break those objects.",U.database_name,U.chart_count,U.dashboard_count,U.sqllab_tab_count)),M&&(0,w.tZ)(M,{database:U})),onConfirm:()=>{U&&function(t){const{id:n,database_name:l}=t;r.Z.delete({endpoint:`/api/v1/database/${n}`}).then((()=>{R(),a((0,o.t)("Deleted: %s",l)),null!=k&&k.onDelete&&k.onDelete(t),(0,g.LS)(g.dR.Database,null),q(null)}),(0,_.v$)((a=>e((0,o.t)("There was an issue deleting %s: %s",l,a)))))}(U)},onHide:()=>q(null),open:!0,title:(0,o.t)("Delete Database?")}),(0,w.tZ)(I.Z,{className:"database-list-view",columns:pe,count:l,data:i,fetchData:Z,filters:_e,initialSort:[{id:"changed_on_delta_humanized",desc:!0}],loading:n,addDangerToast:e,addSuccessToast:a,refreshData:()=>{},pageSize:25}),j&&(0,w.tZ)(b.Z,null))}))},83379:(e,a,t)=>{function n(e){return e?`${e.first_name} ${e.last_name}`:""}t.d(a,{Z:()=>n})},56590:(e,a)=>{a.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"},a.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,a,t)=>{var n=t(56590);a.createFirstEllipsis=function(e){return{type:n.ITEM_TYPES.ELLIPSIS,key:n.ITEM_KEYS.FIRST_ELLIPSIS,value:e,isActive:!1}},a.createSecondEllipsis=function(e){return{type:n.ITEM_TYPES.ELLIPSIS,key:n.ITEM_KEYS.SECOND_ELLIPSIS,value:e,isActive:!1}},a.createFirstPageLink=function(e){var a=e.currentPage;return{type:n.ITEM_TYPES.FIRST_PAGE_LINK,key:n.ITEM_KEYS.FIRST_PAGE_LINK,value:1,isActive:1===a}},a.createPreviousPageLink=function(e){var a=e.currentPage;return{type:n.ITEM_TYPES.PREVIOUS_PAGE_LINK,key:n.ITEM_KEYS.PREVIOUS_PAGE_LINK,value:Math.max(1,a-1),isActive:1===a}},a.createNextPageLink=function(e){var a=e.currentPage,t=e.totalPages;return{type:n.ITEM_TYPES.NEXT_PAGE_LINK,key:n.ITEM_KEYS.NEXT_PAGE_LINK,value:Math.min(t,a+1),isActive:a===t}},a.createLastPageLink=function(e){var a=e.currentPage,t=e.totalPages;return{type:n.ITEM_TYPES.LAST_PAGE_LINK,key:n.ITEM_KEYS.LAST_PAGE_LINK,value:t,isActive:a===t}},a.createPageFunctionFactory=function(e){var a=e.currentPage;return function(e){return{type:n.ITEM_TYPES.PAGE,key:e,value:e,isActive:e===a}}}},1158:(e,a)=>{a.createRange=function(e,a){for(var t=[],n=e;n<=a;n++)t.push(n);return t}},2371:(e,a,t)=>{var n=t(1158),l=t(53804);a.getPaginationModel=function(e){if(null==e)throw new Error("getPaginationModel(): options object should be a passed");var a=Number(e.totalPages);if(isNaN(a))throw new Error("getPaginationModel(): totalPages should be a number");if(a<0)throw new Error("getPaginationModel(): totalPages shouldn't be a negative number");var t=Number(e.currentPage);if(isNaN(t))throw new Error("getPaginationModel(): currentPage should be a number");if(t<0)throw new Error("getPaginationModel(): currentPage shouldn't be a negative number");if(t>a)throw new Error("getPaginationModel(): currentPage shouldn't be greater than totalPages");var o=null==e.boundaryPagesRange?1:Number(e.boundaryPagesRange);if(isNaN(o))throw new Error("getPaginationModel(): boundaryPagesRange should be a number");if(o<0)throw new Error("getPaginationModel(): boundaryPagesRange shouldn't be a negative number");var r=null==e.siblingPagesRange?1:Number(e.siblingPagesRange);if(isNaN(r))throw new Error("getPaginationModel(): siblingPagesRange should be a number");if(r<0)throw new Error("getPaginationModel(): siblingPagesRange shouldn't be a negative number");var s=Boolean(e.hidePreviousAndNextPageLinks),i=Boolean(e.hideFirstAndLastPageLinks),d=Boolean(e.hideEllipsis),u=d?0:1,c=[],g=l.createPageFunctionFactory(e);if(i||c.push(l.createFirstPageLink(e)),s||c.push(l.createPreviousPageLink(e)),1+2*u+2*r+2*o>=a){var b=n.createRange(1,a).map(g);c.push.apply(c,b)}else{var p=o,_=n.createRange(1,p).map(g),h=a+1-o,P=a,E=n.createRange(h,P).map(g),m=Math.min(Math.max(t-r,p+u+1),h-u-2*r-1),f=m+2*r,v=n.createRange(m,f).map(g);if(c.push.apply(c,_),!d){var S=m-1,L=(S===p+1?g:l.createFirstEllipsis)(S);c.push(L)}if(c.push.apply(c,v),!d){var I=f+1,y=(I===h-1?g:l.createSecondEllipsis)(I);c.push(y)}c.push.apply(c,E)}return s||c.push(l.createNextPageLink(e)),i||c.push(l.createLastPageLink(e)),c};var o=t(56590);a.ITEM_TYPES=o.ITEM_TYPES,a.ITEM_KEYS=o.ITEM_KEYS}}]);
//# sourceMappingURL=57ab637a74d3b85bd9de.chunk.js.map