"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[4109],{301510:(e,t,n)=>{n.d(t,{GW:()=>y,Rz:()=>v,X3:()=>m,on:()=>u,vk:()=>g,zi:()=>p});var a=n(5364),i=n(616355),s=n(593185),r=n(61988),l=n(870400),o=n(81255),d=n(680621),c=n(920292);const h=()=>{var e,t;const n=(0,c.Z)();return(null==n||null==(e=n.common)||null==(t=e.conf)?void 0:t.NATIVE_FILTER_DEFAULT_ROW_LIMIT)||1e3},p=({datasetId:e,dependencies:t={},groupby:n,defaultDataMask:a,controlValues:i,filterType:s,sortMetric:r,adhoc_filters:o,time_range:d,granularity_sqla:c,type:p,dashboardId:u,id:g})=>{var m;const b={};return e&&(b.datasource=`${e}__table`),n&&(b.groupby=[n]),r&&(b.sortMetric=r),{...i,...b,adhoc_filters:null!=o?o:[],extra_filters:[],extra_form_data:t,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,l.Z)("regular"),inView:!0,viz_type:s,type:p,dashboardId:u,native_filter_id:g}};function u(e={},t={}){const n={};return a.Ci.forEach((a=>{const i=[...e[a]||[],...t[a]||[]];i.length&&(n[a]=i)})),a.Ay.forEach((a=>{const i=e[a];void 0!==i&&(n[a]=i);const s=t[a];void 0!==s&&(n[a]=s)})),n}function g(e,t){let n={};return t.forEach((t=>{var a,i;n=u(n,null!=(a=null==(i=e[t])?void 0:i.extraFormData)?a:{})})),n}function m(e){return!e.includes(i.cg.NativeFilter)||(0,s.cr)(s.TT.DashboardCrossFilters)&&e.includes(i.cg.InteractiveChart)}const b=(e,t)=>{var n;return(null==e||null==(n=e[t])?void 0:n.type)===o.gn},f=(e,t,n,a,i,s)=>{var r,l,d,c,h,p;s.has(n)||(s.add(n),(null==e||null==(r=e[n])?void 0:r.type)===o.dW&&t.includes(null==(l=e[n])||null==(d=l.meta)?void 0:d.chartId)&&a.forEach(i.add,i),0===(null==e||null==(c=e[n])||null==(h=c.children)?void 0:h.length)||b(e,n)&&i.has(n)||null==(p=e[n])||p.children.forEach((n=>f(e,t,n,b(e,n)?[...a,n]:a,i,s))))},v=(e,t)=>{const n=e[d._4].children[0],a=n!==d.PV,i=new Set,s=new Set;var r,l;return a?null==(r=e[n])||null==(l=r.children)||l.forEach((n=>f(e,t,n,[n],i,s))):Object.values(e).filter((e=>(null==e?void 0:e.type)===o.gn)).forEach((n=>f(e,t,n.id,[n.id],i,s))),i},y=e=>null==e?"":"string"==typeof e||"number"==typeof e?`${e}`:Array.isArray(e)?e.join(", "):"object"==typeof e?JSON.stringify(e):(0,r.t)("Unknown value")},878423:(e,t,n)=>{n.d(t,{V:()=>u});var a=n(358593),i=n(751995),s=n(61988),r=n(135944);const l=i.iK.div`
  ${({theme:e})=>`\n    .tooltip-header {\n      font-size: ${e.typography.sizes.m}px;\n      font-weight: ${e.typography.weights.bold};\n    }\n\n    .tooltip-description {\n      margin-top: ${2*e.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:e})=>`\n    left: ${3*e.gridUnit}px;\n    right: ${3*e.gridUnit}px;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    display: block;\n  `}
`,d=i.iK.span`
  ${({theme:e})=>`\n    left: ${3*e.gridUnit}px;\n    right: ${3*e.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:e,weights:t}}})=>`\n    overflow: hidden;\n    text-overflow: ellipsis;\n    font-size: ${e.s}px;\n    font-weight: ${t.light};\n    line-height: 1.6;\n  `}
`,p=e=>!["null","none"].includes(e.toLowerCase())&&""!==e.trim(),u=e=>(0,r.tZ)(a.u,{mouseEnterDelay:.2,placement:"right",title:(0,r.BX)(l,{children:[(0,r.tZ)("div",{className:"tooltip-header",children:e.table_name&&p(e.table_name)?e.table_name:(0,s.t)("Not defined")}),(0,r.BX)("div",{className:"tooltip-description",children:[(0,r.BX)("div",{children:[(0,s.t)("Database"),": ",e.database.database_name]}),(0,r.BX)("div",{children:[(0,s.t)("Schema"),":"," ",e.schema&&p(e.schema)?e.schema:(0,s.t)("Not defined")]})]})]}),children:(0,r.BX)(o,{children:[(0,r.tZ)(d,{children:e.table_name&&p(e.table_name)?e.table_name:e.database.database_name}),(0,r.BX)(c,{children:[(0,r.tZ)(h,{children:e.database.database_name}),e.schema&&p(e.schema)&&(0,r.BX)(h,{children:[" - ",e.schema]})]})]})})},976499:(e,t,n)=>{n.r(t),n.d(t,{ChartCreation:()=>T,default:()=>C});var a=n(667294),i=n(115926),s=n.n(i),r=n(517563),l=n(751995),o=n(61988),d=n(237731),c=n(431069),h=n(23525),p=n(427600),u=n(473727),g=n(616550),m=n(835932),b=n(104715),f=n(414114),v=n(13284),y=n(212617),x=n(920292),$=n(878423),_=n(135944);const w=((0,x.Z)().common.conf.VIZ_TYPE_DENYLIST||[]).concat(Object.values(p.g2)),D=l.iK.div`
  ${({theme:e})=>`\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: ${e.gridUnit}px;\n    background-color: ${e.colors.grayscale.light5};\n    margin-left: auto;\n    margin-right: auto;\n    padding-left: ${4*e.gridUnit}px;\n    padding-right: ${4*e.gridUnit}px;\n    padding-bottom: ${4*e.gridUnit}px;\n\n    h3 {\n      padding-bottom: ${3*e.gridUnit}px;\n    }\n\n    & .dataset {\n      display: flex;\n      flex-direction: row;\n      align-items: center;\n      margin-bottom: ${5*e.gridUnit}px;\n\n      & > div {\n        min-width: 200px;\n        width: 300px;\n      }\n\n      & > span {\n        color: ${e.colors.grayscale.light1};\n        margin-left: ${4*e.gridUnit}px;\n      }\n    }\n\n    & .viz-gallery {\n      border: 1px solid ${e.colors.grayscale.light2};\n      border-radius: ${e.gridUnit}px;\n      margin: ${e.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: ${e.colors.grayscale.light1};\n        margin-right: ${4*e.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*e.gridUnit}px;\n      width: ${5*e.gridUnit}px;\n      height: ${5*e.gridUnit}px;\n      line-height: ${5*e.gridUnit}px;\n    }\n\n    &&&& .ant-steps-item-title {\n      line-height: ${5*e.gridUnit}px;\n    }\n\n    &&&& .ant-steps-item-content {\n      overflow: unset;\n\n      .ant-steps-item-description {\n        margin-top: ${e.gridUnit}px;\n        padding-bottom: ${e.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*e.gridUnit}px;\n    }\n\n    &&&& .ant-select-selection-item {\n      padding-left: ${3*e.gridUnit}px;\n    }\n  `}
`,U=l.iK.span`
  ${({theme:{typography:{sizes:e,weights:t}}})=>`\n      font-size: ${e.m}px;\n      font-weight: ${t.bold};\n    `}
`,z=l.iK.div`
  ${({theme:{gridUnit:e}})=>`\n    margin-top: ${4*e}px;\n    margin-bottom: ${3*e}px;\n  `}
`;class T extends a.PureComponent{constructor(e){super(e),this.state={vizType:null,canCreateDataset:(0,y.R)("can_write","Dataset",e.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 e;const t=null==(e=r.parse(window.location.search))?void 0:e.dataset;t&&(this.loadDatasources(t,0,1).then((e=>{const t=e.data[0];t.label=t.customLabel,this.setState({datasource:t})})),this.props.addSuccessToast((0,o.t)("The dataset has been saved")))}exploreUrl(){var e;const t=(0,h.eY)(p.KD.dashboardId);let n=`/explore/?viz_type=${this.state.vizType}&datasource=${null==(e=this.state.datasource)?void 0:e.value}`;return(0,d.Z)(t)&&(n+=`&dashboard_id=${t}`),n}gotoSlice(){this.props.history.push(this.exploreUrl())}changeDatasource(e){this.setState({datasource:e})}changeVizType(e){this.setState({vizType:e})}isBtnDisabled(){var e;return!(null!=(e=this.state.datasource)&&e.value&&this.state.vizType)}onVizTypeDoubleClick(){this.isBtnDisabled()||this.gotoSlice()}loadDatasources(e,t,n){const a=s().encode({columns:["id","table_name","datasource_type","database.database_name","schema"],filters:[{col:"table_name",opr:"ct",value:e}],page:t,page_size:n,order_column:"table_name",order_direction:"asc"});return c.Z.get({endpoint:`/api/v1/dataset/?q=${a}`}).then((e=>({data:e.json.result.map((e=>({id:e.id,value:`${e.id}__${e.datasource_type}`,customLabel:(0,$.V)(e),label:e.table_name}))),totalCount:e.json.count})))}render(){var e;const t=this.isBtnDisabled(),n=(0,o.t)("view instructions"),a=this.state.canCreateDataset?(0,_.BX)("span",{children:[(0,_.BX)(u.rU,{to:"/dataset/add/",children:[(0,o.t)("Add a dataset")," "]}),(0,o.t)("or")," ",(0,_.BX)("a",{href:"https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#registering-a-new-table",rel:"noopener noreferrer",target:"_blank",children:[`${n} `,(0,_.tZ)("i",{className:"fa fa-external-link"})]}),"."]}):(0,_.BX)("span",{children:[(0,_.BX)("a",{href:"https://superset.apache.org/docs/creating-charts-dashboards/creating-your-first-dashboard/#registering-a-new-table",rel:"noopener noreferrer",target:"_blank",children:[`${n} `,(0,_.tZ)("i",{className:"fa fa-external-link"})]}),"."]});return(0,_.BX)(D,{children:[(0,_.tZ)("h3",{children:(0,o.t)("Create a new chart")}),(0,_.BX)(b.Rg,{direction:"vertical",size:"small",children:[(0,_.tZ)(b.Rg.Step,{title:(0,_.tZ)(U,{children:(0,o.t)("Choose a dataset")}),status:null!=(e=this.state.datasource)&&e.value?"finish":"process",description:(0,_.BX)(z,{className:"dataset",children:[(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)(U,{children:(0,o.t)("Choose chart type")}),status:this.state.vizType?"finish":"process",description:(0,_.tZ)(z,{children:(0,_.tZ)(v.ZP,{denyList:w,className:"viz-gallery",onChange:this.changeVizType,onDoubleClick:this.onVizTypeDoubleClick,selectedViz:this.state.vizType})})})]}),(0,_.BX)("div",{className:"footer",children:[t&&(0,_.tZ)("span",{children:(0,o.t)("Please select both a Dataset and a Chart type to proceed")}),(0,_.tZ)(m.Z,{buttonStyle:"primary",disabled:t,onClick:this.gotoSlice,children:(0,o.t)("Create new chart")})]})]})}}const C=(0,g.EN)((0,f.ZP)(T))}}]);
//# sourceMappingURL=4099d548ad72ee9fb2f3.chunk.js.map