"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[818],{51127:e=>{var t=/("(?:[^\\"]|\\.)*")|[:,]/g;e.exports=function(e,a){var l,s,o;return a=a||{},l=JSON.stringify([1],void 0,void 0===a.indent?2:a.indent).slice(2,-3),s=""===l?1/0:void 0===a.maxLength?80:a.maxLength,o=a.replacer,function e(a,r,n){var i,d,c,h,u,m,b,p,g,Z,f,y;if(a&&"function"==typeof a.toJSON&&(a=a.toJSON()),void 0===(f=JSON.stringify(a,o)))return f;if(b=s-r.length-n,f.length<=b&&(g=f.replace(t,(function(e,t){return t||e+" "}))).length<=b)return g;if(null!=o&&(a=JSON.parse(f),o=void 0),"object"==typeof a&&null!==a){if(p=r+l,c=[],d=0,Array.isArray(a))for(Z="[",i="]",b=a.length;d0)return[Z,l+c.join(",\n"+p),i].join("\n"+r)}return f}(e,"",0)}},20818:(e,t,a)=>{a.d(t,{Z:()=>T});var l=a(67294),s=a(9875),o=a(49238),r=a(51127),n=a.n(r),i=a(35932),d=a(4715),c=a(15926),h=a.n(c),u=a(51995),m=a(61988),b=a(31069),p=a(55786),g=a(81545),Z=a(78161),f=a(74069),y=a(94670),v=a(45697),C=a.n(v),S=a(95470),_=a(11965);const w={onChange:C().func,labelMargin:C().number,colorScheme:C().string,hasCustomLabelColors:C().bool};class x extends l.PureComponent{constructor(e){super(e),this.state={hovered:!1},this.categoricalSchemeRegistry=(0,g.Z)(),this.choices=this.categoricalSchemeRegistry.keys().map((e=>[e,e])),this.schemes=this.categoricalSchemeRegistry.getMap()}setHover(e){this.setState({hovered:e})}render(){const{colorScheme:e,labelMargin:t=0,hasCustomLabelColors:a}=this.props;return(0,_.tZ)(S.Z,{description:(0,m.t)("Any color palette selected here will override the colors applied to this dashboard's individual charts"),labelMargin:t,name:"color_scheme",onChange:this.props.onChange,value:e,choices:this.choices,clearable:!0,schemes:this.schemes,hovered:this.state.hovered,hasCustomLabelColors:a})}}x.propTypes=w,x.defaultProps={hasCustomLabelColors:!1,colorScheme:void 0,onChange:()=>{}};const k=x;var J=a(98286),N=a(14114),O=a(91877),X=a(93185);const A=(0,u.iK)(o.xJ)` margin-bottom: 0; `,j=(0,u.iK)(y.Ad)` border-radius: ${({theme:e})=>e.borderRadius}px; border: 1px solid ${({theme:e})=>e.colors.secondary.light2}; `,T=(0,N.ZP)((({addSuccessToast:e,colorScheme:t,dashboardId:a,dashboardInfo:r,dashboardTitle:c,onHide:u=(()=>{}),onlyApply:v=!1,onSubmit:C=(()=>{}),show:S=!1})=>{const[w]=d.qz.useForm(),[x,N]=(0,l.useState)(!1),[T,L]=(0,l.useState)(!1),[I,M]=(0,l.useState)(t),[R,B]=(0,l.useState)(""),[D,F]=(0,l.useState)(),[E,P]=(0,l.useState)([]),[$,z]=(0,l.useState)([]),q=v?(0,m.t)("Apply"):(0,m.t)("Save"),H=async e=>{const{error:t,statusText:a,message:l}=await(0,J.O)(e);let s=t||a||(0,m.t)("An error has occurred");"object"==typeof l&&"json_metadata"in l?s=l.json_metadata:"string"==typeof l&&(s=l,"Forbidden"===l&&(s=(0,m.t)("You do not have permission to edit this dashboard"))),f.Z.error({title:"Error",content:s,okButtonProps:{danger:!0,className:"btn-danger"}})},V=(0,l.useCallback)(((e="owners",t="",a,l)=>{const s=h().encode({filter:t,page:a,page_size:l});return b.Z.get({endpoint:`/api/v1/dashboard/related/${e}?q=${s}`}).then((e=>({data:e.json.result.map((e=>({value:e.value,label:e.text}))),totalCount:e.json.count})))}),[]),K=(0,l.useCallback)((e=>{const{id:t,dashboard_title:a,slug:l,certified_by:s,certification_details:o,owners:r,roles:i,metadata:d,is_managed_externally:c}=e,h={id:t,title:a,slug:l||"",certifiedBy:s||"",certificationDetails:o||"",isManagedExternally:c||!1};w.setFieldsValue(h),F(h),P(r),z(i),M(d.color_scheme),null!=d&&d.positions&&delete d.positions;const u={...d};null!=u&&u.shared_label_colors&&delete u.shared_label_colors,B(u?n()(u):"")}),[w]),U=(0,l.useCallback)((()=>{N(!0),b.Z.get({endpoint:`/api/v1/dashboard/${a}`}).then((e=>{var t;const a=e.json.result,l=null!=(t=a.json_metadata)&&t.length?JSON.parse(a.json_metadata):{};K({...a,metadata:l}),N(!1)}),H)}),[a,K]),G=()=>{try{return null!=R&&R.length?JSON.parse(R):{}}catch(e){return{}}},W=e=>{const t=(0,p.Z)(e).map((e=>({id:e.value,full_name:e.label})));P(t)},Y=e=>{const t=(0,p.Z)(e).map((e=>({id:e.value,name:e.label})));z(t)},Q=()=>(E||[]).map((e=>({value:e.id,label:e.full_name||`${e.first_name} ${e.last_name}`}))),ee=(e,{updateMetadata:t=!0}={})=>{const a=(0,g.Z)().keys(),l=G();if(e&&!a.includes(e))throw f.Z.error({title:"Error",content:(0,m.t)("A valid color scheme is required"),okButtonProps:{danger:!0,className:"btn-danger"}}),new Error("A valid color scheme is required");t&&(l.color_scheme=e,l.label_colors=l.label_colors||{},B(n()(l))),M(e)};return(0,l.useEffect)((()=>{S&&(r?K(r):U()),y.Ad.preload()}),[r,U,K,S]),(0,l.useEffect)((()=>{c&&D&&D.title!==c&&w.setFieldsValue({...D,title:c})}),[D,c,w]),(0,_.tZ)(f.Z,{show:S,onHide:u,title:(0,m.t)("Dashboard properties"),footer:(0,_.tZ)(l.Fragment,null,(0,_.tZ)(i.Z,{htmlType:"button",buttonSize:"small",onClick:u,cta:!0},(0,m.t)("Cancel")),(0,_.tZ)(i.Z,{onClick:w.submit,buttonSize:"small",buttonStyle:"primary",className:"m-r-5",cta:!0,disabled:null==D?void 0:D.isManagedExternally,tooltip:null!=D&&D.isManagedExternally?(0,m.t)("This dashboard is managed externally, and can't be edited in Superset"):""},q)),responsive:!0},(0,_.tZ)(d.qz,{form:w,onFinish:()=>{var t;const{title:l,slug:s,certifiedBy:o,certificationDetails:r}=w.getFieldsValue();let i=I,d="",c=R;if(null!=(t=c)&&t.length){const e=JSON.parse(c);i=(null==e?void 0:e.color_scheme)||I,d=(null==e?void 0:e.color_namespace)||"",null!=e&&e.shared_label_colors&&delete e.shared_label_colors;const t=(0,Z.Z)().getColorMap(d,i,!0);e.shared_label_colors=t,c=n()(e)}ee(i,{updateMetadata:!1});const h={},p={};(0,O.cr)(X.T.DASHBOARD_RBAC)&&(h.roles=$,p.roles=($||[]).map((e=>e.id)));const g={id:a,title:l,slug:s,jsonMetadata:c,owners:E,colorScheme:i,colorNamespace:d,certifiedBy:o,certificationDetails:r,...h};v?(e((0,m.t)("Dashboard properties updated")),C(g),u()):b.Z.put({endpoint:`/api/v1/dashboard/${a}`,headers:{"Content-Type":"application/json"},body:JSON.stringify({dashboard_title:l,slug:s||null,json_metadata:c||null,owners:(E||[]).map((e=>e.id)),certified_by:o||null,certification_details:o&&r?r:null,...p})}).then((()=>{e((0,m.t)("The dashboard has been saved")),C(g),u()}),H)},layout:"vertical",initialValues:D},(0,_.tZ)(d.X2,null,(0,_.tZ)(d.JX,{xs:24,md:24},(0,_.tZ)("h3",null,(0,m.t)("Basic information")))),(0,_.tZ)(d.X2,{gutter:16},(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)(o.xJ,{label:(0,m.t)("Title"),name:"title"},(0,_.tZ)(s.II,{type:"text",disabled:x}))),(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)(A,{label:(0,m.t)("URL slug"),name:"slug"},(0,_.tZ)(s.II,{type:"text",disabled:x})),(0,_.tZ)("p",{className:"help-block"},(0,m.t)("A readable URL for your dashboard")))),(0,O.cr)(X.T.DASHBOARD_RBAC)?(()=>{const e=G(),t=!!Object.keys((null==e?void 0:e.label_colors)||{}).length;return(0,_.tZ)(l.Fragment,null,(0,_.tZ)(d.X2,null,(0,_.tZ)(d.JX,{xs:24,md:24},(0,_.tZ)("h3",{style:{marginTop:"1em"}},(0,m.t)("Access")))),(0,_.tZ)(d.X2,{gutter:16},(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)(A,{label:(0,m.t)("Owners")},(0,_.tZ)(d.Ph,{allowClear:!0,ariaLabel:(0,m.t)("Owners"),disabled:x,mode:"multiple",onChange:W,options:(e,t,a)=>V("owners",e,t,a),value:Q()})),(0,_.tZ)("p",{className:"help-block"},(0,m.t)("Owners is a list of users who can alter the dashboard. Searchable by name or username."))),(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)(A,{label:(0,m.t)("Roles")},(0,_.tZ)(d.Ph,{allowClear:!0,ariaLabel:(0,m.t)("Roles"),disabled:x,mode:"multiple",onChange:Y,options:(e,t,a)=>V("roles",e,t,a),value:($||[]).map((e=>({value:e.id,label:`${e.name}`})))})),(0,_.tZ)("p",{className:"help-block"},(0,m.t)("Roles is a list which defines access to the dashboard. Granting a role access to a dashboard will bypass dataset level checks. If no roles are defined, then the dashboard is available to all roles.")))),(0,_.tZ)(d.X2,null,(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)(k,{hasCustomLabelColors:t,onChange:ee,colorScheme:I,labelMargin:4}))))})():(()=>{const e=G(),t=!!Object.keys((null==e?void 0:e.label_colors)||{}).length;return(0,_.tZ)(d.X2,{gutter:16},(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)("h3",{style:{marginTop:"1em"}},(0,m.t)("Access")),(0,_.tZ)(A,{label:(0,m.t)("Owners")},(0,_.tZ)(d.Ph,{allowClear:!0,ariaLabel:(0,m.t)("Owners"),disabled:x,mode:"multiple",onChange:W,options:(e,t,a)=>V("owners",e,t,a),value:Q()})),(0,_.tZ)("p",{className:"help-block"},(0,m.t)("Owners is a list of users who can alter the dashboard. Searchable by name or username."))),(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)("h3",{style:{marginTop:"1em"}},(0,m.t)("Colors")),(0,_.tZ)(k,{hasCustomLabelColors:t,onChange:ee,colorScheme:I,labelMargin:4})))})(),(0,_.tZ)(d.X2,null,(0,_.tZ)(d.JX,{xs:24,md:24},(0,_.tZ)("h3",null,(0,m.t)("Certification")))),(0,_.tZ)(d.X2,{gutter:16},(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)(A,{label:(0,m.t)("Certified by"),name:"certifiedBy"},(0,_.tZ)(s.II,{type:"text",disabled:x})),(0,_.tZ)("p",{className:"help-block"},(0,m.t)("Person or group that has certified this dashboard."))),(0,_.tZ)(d.JX,{xs:24,md:12},(0,_.tZ)(A,{label:(0,m.t)("Certification details"),name:"certificationDetails"},(0,_.tZ)(s.II,{type:"text",disabled:x})),(0,_.tZ)("p",{className:"help-block"},(0,m.t)("Any additional detail to show in the certification tooltip.")))),(0,_.tZ)(d.X2,null,(0,_.tZ)(d.JX,{xs:24,md:24},(0,_.tZ)("h3",{style:{marginTop:"1em"}},(0,_.tZ)(i.Z,{buttonStyle:"link",onClick:()=>L(!T)},(0,_.tZ)("i",{className:"fa fa-angle-"+(T?"down":"right"),style:{minWidth:"1em"}}),(0,m.t)("Advanced"))),T&&(0,_.tZ)(l.Fragment,null,(0,_.tZ)(A,{label:(0,m.t)("JSON metadata")},(0,_.tZ)(j,{showLoadingForImport:!0,name:"json_metadata",value:R,onChange:B,tabSize:2,width:"100%",height:"200px",wrapEnabled:!0})),(0,_.tZ)("p",{className:"help-block"},(0,m.t)("This JSON object is generated dynamically when clicking the save or overwrite button in the dashboard view. It is exposed here for reference and for power users who may want to alter specific parameters.")))))))}))}}]); //# sourceMappingURL=818.fc6df9391f5306cc2677.entry.js.map