"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[5936],{18575:(e,a,t)=>{a.w$=a.uv=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=i(t(96540)),r=i(t(5556)),s=t(11447);function i(e){return e&&e.__esModule?e:{default:e}}a.uv=function(e){var a=e.itemTypeToComponent,t=e.WrapperComponent,i=void 0===t?"div":t,o=function(e){var t=e.currentPage,r=e.totalPages,o=e.boundaryPagesRange,d=e.siblingPagesRange,c=e.hideEllipsis,u=e.hidePreviousAndNextPageLinks,h=e.hideFirstAndLastPageLinks,g=e.onChange,b=e.disabled,p=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"]),E=(0,s.getPaginationModel)({currentPage:t,totalPages:r,boundaryPagesRange:o,siblingPagesRange:d,hideEllipsis:c,hidePreviousAndNextPageLinks:u,hideFirstAndLastPageLinks:h}),_=function(e,a,t){return function(r){var s,i,o,d=e[r.type],c=(i=(s=r).value,o=s.isDisabled,function(){!o&&t&&a!==i&&t(i)});return l.default.createElement(d,n({onClick:c},r))}}(a,t,g);return l.default.createElement(i,p,E.map((function(e){return _(n({},e,{isDisabled:!!b}))})))};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},a.w$=s.ITEM_TYPES},12397:(e,a,t)=>{t.d(a,{U:()=>i});var n=t(19129),l=t(25106),r=t(95579),s=t(2445);const i=({user:e,date:a})=>{const t=(0,s.Y)("span",{className:"no-wrap",children:a});if(e){const a=(0,l.A)(e),i=(0,r.t)("Modified by: %s",a);return(0,s.Y)(n.m,{title:i,placement:"bottom",children:t})}return t}},84177:(e,a,t)=>{t.r(a),t.d(a,{default:()=>K});var n=t(72391),l=t(96453),r=t(95579),s=t(35742),i=t(96540),o=t(58561),d=t.n(o),c=t(61225),u=t(33231),h=t(62221),g=t(17444),b=t(50500),p=t(30703),E=t(5261),_=t(51713),P=t(37020),m=t(32132),f=t(27023),S=t(19129),v=t(12249),A=t(65256),L=t(39854),I=t(4780),y=t(76617),T=t(19980),N=t(12397),Y=t(23193),w=t(2445);const k=(0,n.a)(),M=k.get("database.delete.related"),C=k.get("databaseconnection.extraOption"),R=(0,l.I4)(v.A.Check)`
  color: ${({theme:e})=>e.colors.grayscale.dark1};
`,D=(0,l.I4)(v.A.CancelX)`
  color: ${({theme:e})=>e.colors.grayscale.light1};
`,F=l.I4.div`
  color: ${({theme:e})=>e.colors.grayscale.base};

  .action-button {
    display: inline-block;
    height: 100%;
  }
`;function x({value:e}){return e?(0,w.Y)(R,{}):(0,w.Y)(D,{})}const K=(0,E.Ay)((function({addDangerToast:e,addSuccessToast:a,user:t}){const{state:{loading:n,resourceCount:l,resourceCollection:o},hasPerm:E,fetchData:k,refreshData:R}=(0,b.RU)("database",(0,r.t)("database"),e),D=(0,c.d4)((e=>e.user)),K=(0,m.P3)(f.vX.showDatabaseModal),[O,G]=(0,u.sq)({databaseAdded:u.sJ}),[H,U]=(0,i.useState)(K||!1),[q,X]=(0,i.useState)(null),[z,$]=(0,i.useState)(null),[V,j]=(0,i.useState)(!1),[B,Q]=(0,i.useState)(!1),[J,W]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(!1),ae=(0,A.N6)(D),te=Z||ae,[ne,le]=(0,i.useState)(!1),{roles:re}=D,{CSV_EXTENSIONS:se,COLUMNAR_EXTENSIONS:ie,EXCEL_EXTENSIONS:oe,ALLOWED_EXTENSIONS:de}=(0,c.d4)((e=>e.common.conf));function ce({database:e=null,modalOpen:a=!1}={}){$(e),U(a)}(0,i.useEffect)((()=>{null!=O&&O.databaseAdded&&(G({databaseAdded:void 0}),R())}),[O,G,R]);const ue=E("can_write"),he=E("can_write"),ge=E("can_write"),be=E("can_export"),{canUploadCSV:pe,canUploadColumnar:Ee,canUploadExcel:_e}=(0,p.c8)(re,se,ie,oe,de),Pe=ae&&!Z,me=[{label:(0,r.t)("Upload file to database"),childs:[{label:(0,r.t)("Upload CSV"),name:"Upload CSV file",url:"#",onClick:()=>{j(!0)},perm:pe&&te,disable:Pe},{label:(0,r.t)("Upload Excel"),name:"Upload Excel file",url:"#",onClick:()=>{Q(!0)},perm:_e&&te,disable:Pe},{label:(0,r.t)("Upload Columnar"),name:"Upload columnar file",url:"#",onClick:()=>{W(!0)},perm:Ee&&te,disable:Pe}]}];(0,i.useEffect)((()=>{s.A.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})))||[];ee((null==t?void 0:t.length)>=1)}))}),[H]);const fe={activeChild:"Databases",dropDownLinks:me.reduce(((e,a)=>(a.childs=a.childs.filter((e=>e.perm)),a.childs.length?(e.push(a),e):e)),[]),name:(0,r.t)("Databases")};ue&&(fe.buttons=[{name:(0,w.FD)(w.FK,{children:[(0,w.Y)("i",{className:"fa fa-plus"})," ",(0,r.t)("Database")," "]}),buttonStyle:"primary",onClick:()=>{ce({modalOpen:!0})}}]);const Se=(0,i.useMemo)((()=>[{accessor:"database_name",Header:(0,r.t)("Name")},{accessor:"backend",Header:(0,r.t)("Backend"),size:"lg",disableSortBy:!0},{accessor:"allow_run_async",Header:(0,w.Y)(S.m,{id:"allow-run-async-header-tooltip",title:(0,r.t)("Asynchronous query execution"),placement:"top",children:(0,w.Y)("span",{children:(0,r.t)("AQE")})}),Cell:({row:{original:{allow_run_async:e}}})=>(0,w.Y)(x,{value:e}),size:"sm"},{accessor:"allow_dml",Header:(0,w.Y)(S.m,{id:"allow-dml-header-tooltip",title:(0,r.t)("Allow data manipulation language"),placement:"top",children:(0,w.Y)("span",{children:(0,r.t)("DML")})}),Cell:({row:{original:{allow_dml:e}}})=>(0,w.Y)(x,{value:e}),size:"sm"},{accessor:"allow_file_upload",Header:(0,r.t)("File upload"),Cell:({row:{original:{allow_file_upload:e}}})=>(0,w.Y)(x,{value:e}),size:"md"},{accessor:"expose_in_sqllab",Header:(0,r.t)("Expose in SQL Lab"),Cell:({row:{original:{expose_in_sqllab:e}}})=>(0,w.Y)(x,{value:e}),size:"md"},{Cell:({row:{original:{changed_by:e,changed_on_delta_humanized:a}}})=>(0,w.Y)(N.U,{date:a,user:e}),Header:(0,r.t)("Last modified"),accessor:"changed_on_delta_humanized",size:"xl"},{Cell:({row:{original:e}})=>he||ge||be?(0,w.FD)(F,{className:"actions",children:[ge&&(0,w.Y)("span",{role:"button",tabIndex:0,className:"action-button",onClick:()=>{return a=e,s.A.get({endpoint:`/api/v1/database/${a.id}/related_objects/`}).then((({json:e={}})=>{X({...a,charts:e.charts,dashboards:e.dashboards,sqllab_tab_count:e.sqllab_tab_states.count})})).catch((0,p.JF)((e=>(0,r.t)("An error occurred while fetching database related data: %s",e))));var a},children:(0,w.Y)(S.m,{id:"delete-action-tooltip",title:(0,r.t)("Delete database"),placement:"bottom",children:(0,w.Y)(v.A.Trash,{})})}),be&&(0,w.Y)(S.m,{id:"export-action-tooltip",title:(0,r.t)("Export"),placement:"bottom",children:(0,w.Y)("span",{role:"button",tabIndex:0,className:"action-button",onClick:()=>{var a;void 0!==(a=e).id&&((0,I.A)("database",[a.id],(()=>{le(!1)})),le(!0))},children:(0,w.Y)(v.A.Share,{})})}),he&&(0,w.Y)(S.m,{id:"edit-action-tooltip",title:(0,r.t)("Edit"),placement:"bottom",children:(0,w.Y)("span",{role:"button",tabIndex:0,className:"action-button",onClick:()=>ce({database:e,modalOpen:!0}),children:(0,w.Y)(v.A.EditAlt,{})})})]}):null,Header:(0,r.t)("Actions"),id:"actions",hidden:!he&&!ge,disableSortBy:!0},{accessor:Y.H.ChangedBy,hidden:!0}]),[ge,he,be]),ve=(0,i.useMemo)((()=>[{Header:(0,r.t)("Name"),key:"search",id:"database_name",input:"search",operator:L.t.Contains},{Header:(0,r.t)("Expose in SQL Lab"),key:"expose_in_sql_lab",id:"expose_in_sqllab",input:"select",operator:L.t.Equals,unfilteredLabel:(0,r.t)("All"),selects:[{label:(0,r.t)("Yes"),value:!0},{label:(0,r.t)("No"),value:!1}]},{Header:(0,w.Y)(S.m,{id:"allow-run-async-filter-header-tooltip",title:(0,r.t)("Asynchronous query execution"),placement:"top",children:(0,w.Y)("span",{children:(0,r.t)("AQE")})}),key:"allow_run_async",id:"allow_run_async",input:"select",operator:L.t.Equals,unfilteredLabel:(0,r.t)("All"),selects:[{label:(0,r.t)("Yes"),value:!0},{label:(0,r.t)("No"),value:!1}]},{Header:(0,r.t)("Modified by"),key:"changed_by",id:"changed_by",input:"select",operator:L.t.RelationOneMany,unfilteredLabel:(0,r.t)("All"),fetchSelects:(0,p.u1)("database","changed_by",(0,p.JF)((e=>(0,r.t)("An error occurred while fetching dataset datasource values: %s",e))),t),paginate:!0}]),[]);return(0,w.FD)(w.FK,{children:[(0,w.Y)(_.A,{...fe}),(0,w.Y)(y.Ay,{databaseId:null==z?void 0:z.id,show:H,onHide:ce,onDatabaseAdd:()=>{R()}}),(0,w.Y)(T.A,{addDangerToast:e,addSuccessToast:a,onHide:()=>{j(!1)},show:V,allowedExtensions:se,type:"csv"}),(0,w.Y)(T.A,{addDangerToast:e,addSuccessToast:a,onHide:()=>{Q(!1)},show:B,allowedExtensions:oe,type:"excel"}),(0,w.Y)(T.A,{addDangerToast:e,addSuccessToast:a,onHide:()=>{W(!1)},show:J,allowedExtensions:ie,type:"columnar"}),q&&(0,w.Y)(P.A,{description:(0,w.FD)(w.FK,{children:[(0,w.FD)("p",{children:[(0,r.t)("The database")," ",(0,w.Y)("b",{children:q.database_name})," ",(0,r.t)("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.",q.charts.count,q.dashboards.count,q.sqllab_tab_count)]}),q.dashboards.count>=1&&(0,w.FD)(w.FK,{children:[(0,w.Y)("h4",{children:(0,r.t)("Affected Dashboards")}),(0,w.FD)("ul",{children:[q.dashboards.result.slice(0,10).map(((e,a)=>(0,w.Y)("li",{children:(0,w.Y)("a",{href:`/superset/dashboard/${e.id}`,target:"_atRiskItem",children:e.title})},e.id))),q.dashboards.result.length>10&&(0,w.Y)("li",{children:(0,r.t)("... and %s others",q.dashboards.result.length-10)})]})]}),q.charts.count>=1&&(0,w.FD)(w.FK,{children:[(0,w.Y)("h4",{children:(0,r.t)("Affected Charts")}),(0,w.FD)("ul",{children:[q.charts.result.slice(0,10).map(((e,a)=>(0,w.Y)("li",{children:(0,w.Y)("a",{href:`/explore/?slice_id=${e.id}`,target:"_atRiskItem",children:e.slice_name})},e.id))),q.charts.result.length>10&&(0,w.Y)("li",{children:(0,r.t)("... and %s others",q.charts.result.length-10)})]})]}),M&&(0,w.Y)(M,{database:q})]}),onConfirm:()=>{q&&function(t){const{id:n,database_name:l}=t;s.A.delete({endpoint:`/api/v1/database/${n}`}).then((()=>{R(),a((0,r.t)("Deleted: %s",l)),null!=C&&C.onDelete&&C.onDelete(t),(0,h.SO)(h.Hh.Database,null),X(null)}),(0,p.JF)((a=>e((0,r.t)("There was an issue deleting %s: %s",l,a)))))}(q)},onHide:()=>X(null),open:!0,title:(0,r.t)("Delete Database?")}),(0,w.Y)(L.A,{className:"database-list-view",columns:Se,count:l,data:o,fetchData:k,filters:ve,initialSort:[{id:"changed_on_delta_humanized",desc:!0}],loading:n,addDangerToast:e,addSuccessToast:a,refreshData:()=>{},pageSize:25}),ne&&(0,w.Y)(g.A,{})]})}))},30327:(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}},8960:(e,a,t)=>{var n=t(30327);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}}}},17991:(e,a)=>{a.createRange=function(e,a){for(var t=[],n=e;n<=a;n++)t.push(n);return t}},11447:(e,a,t)=>{var n=t(17991),l=t(8960);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 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 s=null==e.siblingPagesRange?1:Number(e.siblingPagesRange);if(isNaN(s))throw new Error("getPaginationModel(): siblingPagesRange should be a number");if(s<0)throw new Error("getPaginationModel(): siblingPagesRange shouldn't be a negative number");var i=Boolean(e.hidePreviousAndNextPageLinks),o=Boolean(e.hideFirstAndLastPageLinks),d=Boolean(e.hideEllipsis),c=d?0:1,u=[],h=l.createPageFunctionFactory(e);if(o||u.push(l.createFirstPageLink(e)),i||u.push(l.createPreviousPageLink(e)),1+2*c+2*s+2*r>=a){var g=n.createRange(1,a).map(h);u.push.apply(u,g)}else{var b=r,p=n.createRange(1,b).map(h),E=a+1-r,_=a,P=n.createRange(E,_).map(h),m=Math.min(Math.max(t-s,b+c+1),E-c-2*s-1),f=m+2*s,S=n.createRange(m,f).map(h);if(u.push.apply(u,p),!d){var v=m-1,A=(v===b+1?h:l.createFirstEllipsis)(v);u.push(A)}if(u.push.apply(u,S),!d){var L=f+1,I=(L===E-1?h:l.createSecondEllipsis)(L);u.push(I)}u.push.apply(u,P)}return i||u.push(l.createNextPageLink(e)),o||u.push(l.createLastPageLink(e)),u};var r=t(30327);a.ITEM_TYPES=r.ITEM_TYPES,a.ITEM_KEYS=r.ITEM_KEYS}}]);