"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[1262],{377775:(e,t,a)=>{a.d(t,{Q:()=>k,W:()=>X});var n=a(667294),r=a(229487),i=a(61988),o=a(751995),l=a(431069),s=a(844818),d=a(676962),c=a(774069),u=a(835932),m=a(34858),h=a(112515),p=a(427600),g=a(838703),_=a(9875),f=a(633228),y=a(414114),b=a(222545),v=a(135944);const w=(0,i.t)("Warning! Changing the dataset may break the chart if the metadata does not exist."),x=(0,i.t)("Changing the dataset may break the chart if the chart relies on columns or metadata that does not exist in the target dataset"),Z=(0,o.iK)(c.default)`
  .ant-modal-body {
    display: flex;
    flex-direction: column;
  }
`,S=o.iK.div`
  .btn-container {
    display: flex;
    justify-content: flex-end;
    padding: 0px 15px;
    margin: 10px 0 0 0;
  }

  .confirm-modal-container {
    margin: 9px;
  }
`,C=o.iK.span`
  cursor: pointer;
  color: ${({theme:e})=>e.colors.primary.dark1};
  &: hover {
    color: ${({theme:e})=>e.colors.primary.dark2};
  }
`,k=(0,y.ZP)((({addDangerToast:e,addSuccessToast:t,onChange:a,onDatasourceSave:o,onHide:c,show:y})=>{const[k,B]=(0,n.useState)(void 0),[T,H]=(0,n.useState)(0),[N,I]=(0,n.useState)(f.dY),[P,Y]=(0,n.useState)(!1),[z,X]=(0,n.useState)(),O=(0,n.useRef)(null),{state:{loading:$,resourceCollection:D,resourceCount:E},fetchData:K}=(0,m.Yi)("dataset",(0,i.t)("dataset"),e),U=(0,n.useCallback)((e=>{Y(!0),X(e)}),[]),j={pageIndex:T,pageSize:f.IV,filters:[],sortBy:N};(0,h.bX)((()=>{K({...j,...k&&{filters:[{id:"table_name",operator:"ct",value:k}]}})}),p.M$,[k,T,N]),(0,n.useEffect)((()=>{y&&(async()=>{setTimeout((()=>{var e;return null==O||null==(e=O.current)?void 0:e.focus()}),200)})()}),[e,K,a,o,c,U,y]);const q=[{Cell:({row:{original:e}})=>(0,v.tZ)(C,{role:"button",tabIndex:0,onClick:()=>U({type:"table",...e}),children:null==e?void 0:e.table_name}),Header:(0,i.t)("Name"),accessor:"table_name"},{Header:(0,i.t)("Type"),accessor:"kind",disableSortBy:!0},{Header:(0,i.t)("Schema"),accessor:"schema"},{Header:(0,i.t)("Connection"),accessor:"database.database_name",disableSortBy:!0},{Cell:({row:{original:{owners:e=[]}}})=>(0,v.tZ)(b.Z,{users:e}),Header:(0,i.t)("Owners"),id:"owners",disableSortBy:!0}];return(0,v.tZ)(Z,{show:y,onHide:c,responsive:!0,title:(0,i.t)("Swap dataset"),width:P?"432px":"",height:P?"auto":"540px",hideFooter:!P,footer:(0,v.tZ)(v.HY,{children:P&&(0,v.tZ)(S,{children:(0,v.BX)("div",{className:"btn-container",children:[(0,v.tZ)(u.Z,{onClick:()=>{Y(!1)},children:(0,i.t)("Cancel")}),(0,v.tZ)(u.Z,{className:"proceed-btn",buttonStyle:"primary",onClick:()=>{l.Z.get({endpoint:`/api/v1/dataset/${null==z?void 0:z.id}`}).then((({json:e})=>{e.result.type="table",o(e.result),a(`${null==z?void 0:z.id}__table`)})).catch((t=>{(0,s.O$)(t).then((({error:t,message:a})=>{const n=t?t.error||t.statusText||t:a;e(n)}))})),c(),t((0,i.t)("Successfully changed dataset!"))},children:(0,i.t)("Proceed")})]})})}),children:(0,v.BX)(v.HY,{children:[!P&&(0,v.BX)(v.HY,{children:[(0,v.tZ)(r.Z,{roomBelow:!0,type:"warning",css:e=>({marginBottom:4*e.gridUnit}),message:(0,v.BX)(v.HY,{children:[(0,v.tZ)("strong",{children:(0,i.t)("Warning!")})," ",x]})}),(0,v.tZ)(_.II,{ref:O,type:"text",value:k,placeholder:(0,i.t)("Search / Filter"),onChange:e=>{var t;const a=null!=(t=e.target.value)?t:"";B(a),H(0)}}),$&&(0,v.tZ)(g.Z,{}),!$&&(0,v.tZ)(d.Z,{columns:q,data:D,pageSize:f.IV,initialPageIndex:T,initialSortBy:N,totalCount:E,onServerPagination:e=>{H(e.pageIndex),e.sortBy&&I(e.sortBy.length>0?e.sortBy:f.dY)},className:"table-condensed",emptyWrapperType:d.u.Small,serverPagination:!0,isPaginationSticky:!0,scrollTable:!0})]}),P&&(0,v.tZ)(v.HY,{children:w})]})})}));var B=a(237731),T=a(593185),H=a(967913),N=a(272875),I=a(828216);const P=(0,H.Z)((()=>Promise.all([a.e(1216),a.e(8573),a.e(6334),a.e(6048),a.e(6217),a.e(1456),a.e(6607)]).then(a.bind(a,701862)))),Y=(0,o.iK)(c.default)`
  .modal-content {
    height: 900px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .modal-header {
    flex: 0 1 auto;
  }
  .modal-body {
    flex: 1 1 auto;
    overflow: auto;
  }

  .modal-footer {
    flex: 0 1 auto;
  }
`;function z(e){const t=null!=e&&e.certified_by||null!=e&&e.certification_details?{certified_by:null==e?void 0:e.certified_by,details:null==e?void 0:e.certification_details}:void 0;return JSON.stringify({certification:t,warning_markdown:null==e?void 0:e.warning_markdown})}const X=(0,y.ZP)((({addSuccessToast:e,datasource:t,onDatasourceSave:a,onHide:o,show:d})=>{var m;const[h,p]=(0,n.useState)({...t,metrics:null==t||null==(m=t.metrics)?void 0:m.map((e=>({...e,currency:JSON.parse(e.currency||"null")})))}),g=(0,I.v9)((e=>{var t;return null==(t=e.common)?void 0:t.currencies})),[_,f]=(0,n.useState)([]),[y,b]=(0,n.useState)(!1),[w,x]=(0,n.useState)(!1),Z=(0,n.useRef)(null),[S,C]=c.default.useModal(),k=()=>{var t,n,r,d,c;const u=(null==(t=h.tableSelector)?void 0:t.schema)||(null==(n=h.databaseSelector)?void 0:n.schema)||h.schema;b(!0),l.Z.put({endpoint:`/api/v1/dataset/${h.id}`,jsonPayload:{table_name:h.table_name,database_id:null==(r=h.database)?void 0:r.id,sql:h.sql,filter_select_enabled:h.filter_select_enabled,fetch_values_predicate:h.fetch_values_predicate,schema:u,description:h.description,main_dttm_col:h.main_dttm_col,normalize_columns:h.normalize_columns,always_filter_main_dttm:h.always_filter_main_dttm,offset:h.offset,default_endpoint:h.default_endpoint,cache_timeout:""===h.cache_timeout?null:h.cache_timeout,is_sqllab_view:h.is_sqllab_view,template_params:h.template_params,extra:h.extra,is_managed_externally:h.is_managed_externally,external_url:h.external_url,metrics:null==h||null==(d=h.metrics)?void 0:d.map((e=>{const t={expression:e.expression,description:e.description,metric_name:e.metric_name,metric_type:e.metric_type,d3format:e.d3format||null,currency:(0,B.Z)(e.currency)?JSON.stringify(e.currency):null,verbose_name:e.verbose_name,warning_text:e.warning_text,uuid:e.uuid,extra:z(e)};return Number.isNaN(Number(e.id))||(t.id=e.id),t})),columns:null==h||null==(c=h.columns)?void 0:c.map((e=>({id:"number"==typeof e.id?e.id:void 0,column_name:e.column_name,type:e.type,advanced_data_type:e.advanced_data_type,verbose_name:e.verbose_name,description:e.description,expression:e.expression,filterable:e.filterable,groupby:e.groupby,is_active:e.is_active,is_dttm:e.is_dttm,python_date_format:e.python_date_format||null,uuid:e.uuid,extra:z(e)}))),owners:h.owners.map((e=>e.value||e.id))}}).then((()=>(e((0,i.t)("The dataset has been saved")),l.Z.get({endpoint:`/api/v1/dataset/${null==h?void 0:h.id}`})))).then((({json:e})=>{e.result.type="table",a({...e.result,owners:h.owners}),o()})).catch((e=>{b(!1),(0,s.O$)(e).then((e=>{var t;let a,n;null!=e&&null!=(t=e.errors)&&t.length?a=e.errors[0]:"string"==typeof e.error&&(n=e.error),S.error({title:(0,i.t)("Error saving dataset"),okButtonProps:{danger:!0,className:"btn-danger"},content:(0,v.tZ)(N.Z,{error:a,source:"crud",fallback:n})})}))}))},H=!(0,T.cr)(T.TT.DisableLegacyDatasourceEditor);return(0,v.BX)(Y,{show:d,onHide:o,title:(0,v.BX)("span",{children:[(0,i.t)("Edit Dataset "),(0,v.tZ)("strong",{children:h.table_name})]}),maskClosable:!w,footer:(0,v.BX)(v.HY,{children:[H&&(0,v.tZ)(u.Z,{buttonSize:"small",buttonStyle:"default",className:"m-r-5",onClick:()=>{window.location.href=h.edit_url||h.url},children:(0,i.t)("Use legacy datasource editor")}),(0,v.tZ)(u.Z,{buttonSize:"small",className:"m-r-5",onClick:o,children:(0,i.t)("Cancel")}),(0,v.tZ)(u.Z,{buttonSize:"small",buttonStyle:"primary",onClick:()=>{Z.current=S.confirm({title:(0,i.t)("Confirm save"),content:(0,v.BX)("div",{children:[(0,v.tZ)(r.Z,{css:e=>({marginTop:4*e.gridUnit,marginBottom:4*e.gridUnit}),type:"warning",showIcon:!0,message:(0,i.t)("The dataset configuration exposed here\n                affects all the charts using this dataset.\n                Be mindful that changing settings\n                here may affect other charts\n                in undesirable ways.")}),(0,i.t)("Are you sure you want to save and apply changes?")]}),onOk:k,icon:null,okText:(0,i.t)("OK"),cancelText:(0,i.t)("Cancel")})},disabled:y||_.length>0||h.is_managed_externally,tooltip:h.is_managed_externally?(0,i.t)("This dataset is managed externally, and can't be edited in Superset"):"",children:(0,i.t)("Save")})]}),responsive:!0,children:[(0,v.tZ)(P,{showLoadingForImport:!0,height:500,datasource:h,onChange:(e,t)=>{p({...e,metrics:null==e?void 0:e.metrics.map((e=>({...e,is_certified:(null==e?void 0:e.certified_by)||(null==e?void 0:e.certification_details)})))}),f(t)},setIsEditing:x,currencies:g}),C]})}))},486057:(e,t,a)=>{a.d(t,{Z:()=>d});var n=a(211965),r=a(751995),i=a(178186),o=a(313322),l=a(358593),s=a(135944);const d=function({warningMarkdown:e,size:t,marginRight:a}){const d=(0,r.Fg)();return(0,s.tZ)(l.u,{id:"warning-tooltip",title:(0,s.tZ)(i.Z,{source:e}),children:(0,s.tZ)(o.Z.AlertSolid,{iconColor:d.colors.alert.base,iconSize:t,css:(0,n.iv)({marginRight:null!=a?a:2*d.gridUnit},"","")})})}},633228:(e,t,a)=>{a.d(t,{IV:()=>r,dY:()=>i,iX:()=>o,mI:()=>l});var n=a(61988);const r=25,i=[{id:"changed_on_delta_humanized",desc:!0}],o=(0,n.t)('The passwords for the databases below are needed in order to import them together with the datasets. Please note that the "Secure Extra" and "Certificate" sections of the database configuration are not present in export files, and should be added manually after the import if they are needed.'),l=(0,n.t)("You are importing one or more datasets that already exist. Overwriting might cause you to lose some of your work. Are you sure you want to overwrite?")}}]);
//# sourceMappingURL=0643f9dda1415a62582d.chunk.js.map