"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[4109],{1510:(t,e,n)=>{n.d(e,{GW:()=>y,Rz:()=>v,X3:()=>m,on:()=>u,vk:()=>g,zi:()=>p});var a=n(5364),i=n(16355),s=n(93185),l=n(61988),r=n(70400),o=n(81255),d=n(80621),c=n(20292);const h=()=>{var t,e;const n=(0,c.Z)();return(null==n||null==(t=n.common)||null==(e=t.conf)?void 0:e.NATIVE_FILTER_DEFAULT_ROW_LIMIT)||1e3},p=({datasetId:t,dependencies:e={},groupby:n,defaultDataMask:a,controlValues:i,filterType:s,sortMetric:l,adhoc_filters:o,time_range:d,granularity_sqla:c,type:p,dashboardId:u,id:g})=>{var m;const b={};return t&&(b.datasource=`${t}__table`),n&&(b.groupby=[n]),l&&(b.sortMetric=l),{...i,...b,adhoc_filters:null!=o?o:[],extra_filters:[],extra_form_data:e,granularity_sqla:c,metrics:["count"],row_limit:h(),showSearch:!0,defaultValue:null==a||null==(m=a.filterState)?void 0:m.value,time_range:d,url_params:(0,r.Z)("regular"),inView:!0,viz_type:s,type:p,dashboardId:u,native_filter_id:g}};function u(t={},e={}){const n={};return a.Ci.forEach((a=>{const i=[...t[a]||[],...e[a]||[]];i.length&&(n[a]=i)})),a.Ay.forEach((a=>{const i=t[a];void 0!==i&&(n[a]=i);const s=e[a];void 0!==s&&(n[a]=s)})),n}function g(t,e){let n={};return e.forEach((e=>{var a,i;n=u(n,null!=(a=null==(i=t[e])?void 0:i.extraFormData)?a:{})})),n}function m(t){return!t.includes(i.cg.NativeFilter)||(0,s.cr)(s.TT.DashboardCrossFilters)&&t.includes(i.cg.InteractiveChart)}const b=(t,e)=>{var n;return(null==t||null==(n=t[e])?void 0:n.type)===o.gn},f=(t,e,n,a,i,s)=>{var l,r,d,c,h,p;s.has(n)||(s.add(n),(null==t||null==(l=t[n])?void 0:l.type)===o.dW&&e.includes(null==(r=t[n])||null==(d=r.meta)?void 0:d.chartId)&&a.forEach(i.add,i),0===(null==t||null==(c=t[n])||null==(h=c.children)?void 0:h.length)||b(t,n)&&i.has(n)||null==(p=t[n])||p.children.forEach((n=>f(t,e,n,b(t,n)?[...a,n]:a,i,s))))},v=(t,e)=>{const n=t[d._4].children[0],a=n!==d.PV,i=new Set,s=new Set;var l,r;return a?null==(l=t[n])||null==(r=l.children)||r.forEach((n=>f(t,e,n,[n],i,s))):Object.values(t).filter((t=>(null==t?void 0:t.type)===o.gn)).forEach((n=>f(t,e,n.id,[n.id],i,s))),i},y=t=>null==t?"":"string"==typeof t||"number"==typeof t?`${t}`:Array.isArray(t)?t.join(", "):"object"==typeof t?JSON.stringify(t):(0,l.t)("Unknown value")},78423:(t,e,n)=>{n.d(e,{V:()=>u}),n(67294);var a=n(58593),i=n(51995),s=n(61988),l=n(11965);const r=i.iK.div`
  ${({theme:t})=>`\n    .tooltip-header {\n      font-size: ${t.typography.sizes.m}px;\n      font-weight: ${t.typography.weights.bold};\n    }\n\n    .tooltip-description {\n      margin-top: ${2*t.gridUnit}px;\n      display: -webkit-box;\n      -webkit-line-clamp: 20;\n      -webkit-box-orient: vertical;\n      overflow: hidden;\n      text-overflow: ellipsis;\n    }\n  `}
`,o=i.iK.div`
  ${({theme:t})=>`\n    left: ${3*t.gridUnit}px;\n    right: ${3*t.gridUnit}px;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    display: block;\n  `}
`,d=i.iK.span`
  ${({theme:t})=>`\n    left: ${3*t.gridUnit}px;\n    right: ${3*t.gridUnit}px;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    display: block;\n  `}
`,c=i.iK.div`
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  width: 100%;
`,h=i.iK.span`
  ${({theme:{typography:{sizes:t,weights:e}}})=>`\n    overflow: hidden;\n    text-overflow: ellipsis;\n    font-size: ${t.s}px;\n    font-weight: ${e.light};\n    line-height: 1.6;\n  `}
`,p=t=>!["null","none"].includes(t.toLowerCase())&&""!==t.trim(),u=t=>(0,l.tZ)(a.u,{mouseEnterDelay:.2,placement:"right",title:(0,l.tZ)(r,null,(0,l.tZ)("div",{className:"tooltip-header"},t.table_name&&p(t.table_name)?t.table_name:(0,s.t)("Not defined")),(0,l.tZ)("div",{className:"tooltip-description"},(0,l.tZ)("div",null,(0,s.t)("Database"),": ",t.database.database_name),(0,l.tZ)("div",null,(0,s.t)("Schema"),":"," ",t.schema&&p(t.schema)?t.schema:(0,s.t)("Not defined"))))},(0,l.tZ)(o,null,(0,l.tZ)(d,null,t.table_name&&p(t.table_name)?t.table_name:t.database.database_name),(0,l.tZ)(c,null,(0,l.tZ)(h,null,t.database.database_name),t.schema&&p(t.schema)&&(0,l.tZ)(h,null," - ",t.schema))))},76499:(t,e,n)=>{n.r(e),n.d(e,{ChartCreation:()=>U,default:()=>T});var a=n(67294),i=n(15926),s=n.n(i),l=n(17563),r=n(51995),o=n(61988),d=n(37731),c=n(31069),h=n(23525),p=n(27600),u=n(73727),g=n(16550),m=n(35932),b=n(4715),f=n(14114),v=n(13284),y=n(12617),x=n(20292),$=n(78423),_=n(11965);const w=(0,x.Z)().common.conf.VIZ_TYPE_DENYLIST||[],Z=r.iK.div`
  ${({theme:t})=>`\n    flex: 1 1 auto;\n    display: flex;\n    flex-direction: column;\n    justify-content: space-between;\n    width: 100%;\n    max-width: ${v.UB}px;\n    max-height: calc(100vh - 56px);\n    border-radius: ${t.gridUnit}px;\n    background-color: ${t.colors.grayscale.light5};\n    margin-left: auto;\n    margin-right: auto;\n    padding-left: ${4*t.gridUnit}px;\n    padding-right: ${4*t.gridUnit}px;\n    padding-bottom: ${4*t.gridUnit}px;\n\n    h3 {\n      padding-bottom: ${3*t.gridUnit}px;\n    }\n\n    & .dataset {\n      display: flex;\n      flex-direction: row;\n      align-items: center;\n\n      & > div {\n        min-width: 200px;\n        width: 300px;\n      }\n\n      & > span {\n        color: ${t.colors.grayscale.light1};\n        margin-left: ${4*t.gridUnit}px;\n      }\n    }\n\n    & .viz-gallery {\n      border: 1px solid ${t.colors.grayscale.light2};\n      border-radius: ${t.gridUnit}px;\n      margin: ${t.gridUnit}px 0px;\n      max-height: calc(100vh - 306px);\n      flex: 1;\n    }\n\n    & .footer {\n      flex: 1;\n      display: flex;\n      flex-direction: row;\n      justify-content: flex-end;\n      align-items: center;\n\n      & > span {\n        color: ${t.colors.grayscale.light1};\n        margin-right: ${4*t.gridUnit}px;\n      }\n    }\n\n    /* The following extra ampersands (&&&&) are used to boost selector specificity */\n\n    &&&& .ant-steps-item-tail {\n      display: none;\n    }\n\n    &&&& .ant-steps-item-icon {\n      margin-right: ${2*t.gridUnit}px;\n      width: ${5*t.gridUnit}px;\n      height: ${5*t.gridUnit}px;\n      line-height: ${5*t.gridUnit}px;\n    }\n\n    &&&& .ant-steps-item-title {\n      line-height: ${5*t.gridUnit}px;\n    }\n\n    &&&& .ant-steps-item-content {\n      overflow: unset;\n\n      .ant-steps-item-description {\n        margin-top: ${t.gridUnit}px;\n      }\n    }\n\n    &&&& .ant-tooltip-open {\n      display: inline;\n    }\n\n    &&&& .ant-select-selector {\n      padding: 0;\n    }\n\n    &&&& .ant-select-selection-placeholder {\n      padding-left: ${3*t.gridUnit}px;\n    }\n\n    &&&& .ant-select-selection-item {\n      padding-left: ${3*t.gridUnit}px;\n    }\n  `}
`,D=r.iK.span`
  ${({theme:{typography:{sizes:t,weights:e}}})=>`\n      font-size: ${t.m}px;\n      font-weight: ${e.bold};\n    `}
`,z=r.iK.div`
  ${({theme:{gridUnit:t}})=>`\n    margin-top: ${4*t}px;\n    margin-bottom: ${3*t}px;\n  `}
`;class U extends a.PureComponent{constructor(t){super(t),this.state={vizType:null,canCreateDataset:(0,y.R)("can_write","Dataset",t.user.roles)},this.changeDatasource=this.changeDatasource.bind(this),this.changeVizType=this.changeVizType.bind(this),this.gotoSlice=this.gotoSlice.bind(this),this.loadDatasources=this.loadDatasources.bind(this),this.onVizTypeDoubleClick=this.onVizTypeDoubleClick.bind(this)}componentDidMount(){var t;const e=null==(t=l.parse(window.location.search))?void 0:t.dataset;e&&(this.loadDatasources(e,0,1).then((t=>{const e=t.data[0];e.label=e.customLabel,this.setState({datasource:e})})),this.props.addSuccessToast((0,o.t)("The dataset has been saved")))}exploreUrl(){var t;const e=(0,h.eY)(p.KD.dashboardId);let n=`/explore/?viz_type=${this.state.vizType}&datasource=${null==(t=this.state.datasource)?void 0:t.value}`;return(0,d.Z)(e)&&(n+=`&dashboard_id=${e}`),n}gotoSlice(){this.props.history.push(this.exploreUrl())}changeDatasource(t){this.setState({datasource:t})}changeVizType(t){this.setState({vizType:t})}isBtnDisabled(){var t;return!(null!=(t=this.state.datasource)&&t.value&&this.state.vizType)}onVizTypeDoubleClick(){this.isBtnDisabled()||this.gotoSlice()}loadDatasources(t,e,n){const a=s().encode({columns:["id","table_name","datasource_type","database.database_name","schema"],filters:[{col:"table_name",opr:"ct",value:t}],page:e,page_size:n,order_column:"table_name",order_direction:"asc"});return c.Z.get({endpoint:`/api/v1/dataset/?q=${a}`}).then((t=>({data:t.json.result.map((t=>({id:t.id,value:`${t.id}__${t.datasource_type}`,customLabel:(0,$.V)(t),label:t.table_name}))),totalCount:t.json.count})))}render(){var t;const e=this.isBtnDisabled(),n=(0,o.t)("view instructions"),a=this.state.canCreateDataset?(0,_.tZ)("span",null,(0,_.tZ)(u.rU,{to:"/dataset/add/"},(0,o.t)("Add a dataset")," "),(0,o.t)("or")," ",(0,_.tZ)("a",{href:"https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#registering-a-new-table",rel:"noopener noreferrer",target:"_blank"},`${n} `,(0,_.tZ)("i",{className:"fa fa-external-link"})),"."):(0,_.tZ)("span",null,(0,_.tZ)("a",{href:"https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#registering-a-new-table",rel:"noopener noreferrer",target:"_blank"},`${n} `,(0,_.tZ)("i",{className:"fa fa-external-link"})),".");return(0,_.tZ)(Z,null,(0,_.tZ)("h3",null,(0,o.t)("Create a new chart")),(0,_.tZ)(b.Rg,{direction:"vertical",size:"small"},(0,_.tZ)(b.Rg.Step,{title:(0,_.tZ)(D,null,(0,o.t)("Choose a dataset")),status:null!=(t=this.state.datasource)&&t.value?"finish":"process",description:(0,_.tZ)(z,{className:"dataset"},(0,_.tZ)(b.qb,{autoFocus:!0,ariaLabel:(0,o.t)("Dataset"),name:"select-datasource",onChange:this.changeDatasource,options:this.loadDatasources,optionFilterProps:["id","label"],placeholder:(0,o.t)("Choose a dataset"),showSearch:!0,value:this.state.datasource}),a)}),(0,_.tZ)(b.Rg.Step,{title:(0,_.tZ)(D,null,(0,o.t)("Choose chart type")),status:this.state.vizType?"finish":"process",description:(0,_.tZ)(z,null,(0,_.tZ)(v.ZP,{denyList:w,className:"viz-gallery",onChange:this.changeVizType,onDoubleClick:this.onVizTypeDoubleClick,selectedViz:this.state.vizType}))})),(0,_.tZ)("div",{className:"footer"},e&&(0,_.tZ)("span",null,(0,o.t)("Please select both a Dataset and a Chart type to proceed")),(0,_.tZ)(m.Z,{buttonStyle:"primary",disabled:e,onClick:this.gotoSlice},(0,o.t)("Create new chart"))))}}const T=(0,g.EN)((0,f.ZP)(U))}}]);
//# sourceMappingURL=959c43e96a07d2bdf551.chunk.js.map