"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[7637],{83556:(e,t,a)=>{a.d(t,{P:()=>c});var n=a(67294),l=a(51995),i=a(59361),r=a(58593),o=a(11965);const s=(0,l.iK)(i.Z)`
  ${e=>{let{theme:t}=e;return`\n  margin-top: ${t.gridUnit}px;\n  margin-bottom: ${t.gridUnit}px;\n  font-size: ${t.typography.sizes.s}px;\n  `}};
`,d=e=>{let{name:t,id:a,index:l,onDelete:i,editable:d=!1,onClick:u,toolTipTitle:c=t}=e;const g=(0,n.useMemo)((()=>t.length>20),[t])?`${t.slice(0,20)}...`:t;return(0,o.tZ)(n.Fragment,null,d?(0,o.tZ)(r.u,{title:c,key:c},(0,o.tZ)(s,{key:a,closable:d,onClose:()=>l?null==i?void 0:i(l):null,color:"blue"},g)):(0,o.tZ)(r.u,{title:c,key:c},(0,o.tZ)(s,{role:"link",key:a,onClick:u},a?(0,o.tZ)("a",{href:`/superset/all_entities/?id=${a}`,target:"_blank",rel:"noreferrer"},g):g)))},u=l.iK.div`
  max-width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
`,c=e=>{let{tags:t,editable:a=!1,onDelete:l,maxTags:i}=e;const[r,s]=(0,n.useState)(i),c=e=>{null==l||l(e)},g=(0,n.useMemo)((()=>r?t.length>r:null),[t.length,r]),h=(0,n.useMemo)((()=>"number"==typeof r?t.length-r+1:null),[g,t.length,r]);return(0,o.tZ)(u,{className:"tag-list"},g&&"number"==typeof r?(0,o.tZ)(n.Fragment,null,t.slice(0,r-1).map(((e,t)=>(0,o.tZ)(d,{id:e.id,key:e.id,name:e.name,index:t,onDelete:c,editable:a}))),t.length>r?(0,o.tZ)(d,{name:`+${h}...`,onClick:()=>s(void 0),toolTipTitle:t.map((e=>e.name)).join(", ")}):null):(0,o.tZ)(n.Fragment,null,t.map(((e,t)=>(0,o.tZ)(d,{id:e.id,key:e.id,name:e.name,index:t,onDelete:c,editable:a}))),i&&t.length>i?(0,o.tZ)(d,{name:"...",onClick:()=>s(i)}):null))}},51360:(e,t,a)=>{a.d(t,{Z:()=>v});var n=a(67294),l=a(15926),i=a.n(l),r=a(74069),o=a(84101),s=a(49238),d=a(51995),u=a(31069),c=a(61988),g=a(77808),h=a(4715),p=a(35932),m=a(48273),b=a(11965);const y=d.iK.div`
  .ant-select-dropdown {
    max-height: ${e=>{let{theme:t}=e;return 40*t.gridUnit}}px;
  }
  .tag-input {
    margin-bottom: ${e=>{let{theme:t}=e;return 3*t.gridUnit}}px;
  }
`;var Z;!function(e){e.Chart="chart",e.Dashboard="dashboard",e.SavedQuery="query"}(Z||(Z={}));const v=e=>{let{show:t,onHide:a,editTag:l,refreshData:d,addSuccessToast:v,addDangerToast:f,clearOnHide:x=!1}=e;const[$,S]=(0,n.useState)([]),[T,w]=(0,n.useState)([]),[C,_]=(0,n.useState)([]),[k,D]=(0,n.useState)(""),[U,E]=(0,n.useState)(""),N=!!l,P=N?"Edit Tag":"Create Tag",j=()=>{D(""),E(""),S([]),w([]),_([])};(0,n.useEffect)((()=>{const e={[Z.Dashboard]:[],[Z.Chart]:[],[Z.SavedQuery]:[]},t=t=>{let{id:a,name:n,type:l}=t;const i=e[l];i&&i.push({value:a,label:n,key:a})};S([]),w([]),_([]),N&&((0,m.Y4)({tags:l.name,types:null},(a=>{a.forEach(t),S(e[Z.Dashboard]),w(e[Z.Chart]),_(e[Z.SavedQuery])}),(e=>{f("Error Fetching Tagged Objects")})),D(l.name),E(l.description))}),[l]);const z=async(e,t,a,n,l,r,o)=>{const s=i().encode({columns:n,filters:[{col:l,opr:"ct",value:e}],page:t,order_column:r}),{json:d}=await u.Z.get({endpoint:`/api/v1/${o}/?q=${s}`}),{result:c,count:g}=d;return{data:c.map((e=>({value:e.id,label:e[l]}))),totalCount:g}},F=(e,t)=>{e===Z.Dashboard?S(t):e===Z.Chart?w(t):e===Z.SavedQuery&&_(t)};return(0,b.tZ)(r.default,{title:P,onHide:()=>{x&&j(),a()},show:t,footer:(0,b.tZ)("div",null,(0,b.tZ)(p.Z,{buttonStyle:"secondary",onClick:a},(0,c.t)("Cancel")),(0,b.tZ)(p.Z,{buttonStyle:"primary",onClick:()=>{const e=$.map((e=>["dashboard",e.value])),t=T.map((e=>["chart",e.value])),n=C.map((e=>["query",e.value]));N?u.Z.put({endpoint:`/api/v1/tag/${l.id}`,jsonPayload:{description:U,name:k,objects_to_tag:[...e,...t,...n]}}).then((e=>{let{json:t={}}=e;d(),j(),v((0,c.t)("Tag updated")),a()})).catch((e=>{f(e.message||"Error Updating Tag")})):u.Z.post({endpoint:"/api/v1/tag/",jsonPayload:{description:U,name:k,objects_to_tag:[...e,...t,...n]}}).then((e=>{let{json:t={}}=e;d(),j(),v((0,c.t)("Tag created")),a()})).catch((e=>f(e.message||"Error Creating Tag")))}},(0,c.t)("Save")))},(0,b.tZ)(y,null,(0,b.tZ)(s.lX,null,(0,c.t)("Tag name")),(0,b.tZ)(g.Z,{className:"tag-input",onChange:e=>D(e.target.value),placeholder:(0,c.t)("Name of your tag"),value:k}),(0,b.tZ)(s.lX,null,(0,c.t)("Description")),(0,b.tZ)(g.Z,{className:"tag-input",onChange:e=>E(e.target.value),placeholder:(0,c.t)("Add description of your tag"),value:U}),(0,b.tZ)(h.iz,null),(0,b.tZ)(o.Z,{className:"tag-input",ariaLabel:(0,c.t)("Select dashboards"),mode:"multiple",name:"dashboards",value:$,options:async(e,t,a)=>z(e,t,0,["id","dashboard_title"],"dashboard_title","dashboard_title","dashboard"),onChange:e=>F(Z.Dashboard,e),header:(0,b.tZ)(s.lX,null,(0,c.t)("Dashboards")),allowClear:!0}),(0,b.tZ)(o.Z,{className:"tag-input",ariaLabel:(0,c.t)("Select charts"),mode:"multiple",name:"charts",value:T,options:async(e,t,a)=>z(e,t,0,["id","slice_name"],"slice_name","slice_name","chart"),onChange:e=>F(Z.Chart,e),header:(0,b.tZ)(s.lX,null,(0,c.t)("Charts")),allowClear:!0}),(0,b.tZ)(o.Z,{className:"tag-input",ariaLabel:(0,c.t)("Select saved queries"),mode:"multiple",name:"savedQueries",value:C,options:async(e,t,a)=>z(e,t,0,["id","label"],"label","label","saved_query"),onChange:e=>F(Z.SavedQuery,e),header:(0,b.tZ)(s.lX,null,(0,c.t)("Saved queries")),allowClear:!0})))}},7628:(e,t,a)=>{a.r(t),a.d(t,{default:()=>C});var n=a(67294),l=a(11965),i=a(51995),r=a(61988),o=a(35755),s=a(30381),d=a.n(s),u=a(76962),c=a(83556),g=a(34581),h=a(94301);const p=i.iK.div`
  text-align: left;
  border-radius: ${e=>{let{theme:t}=e;return 1*t.gridUnit}}px 0;
  .table {
    table-layout: fixed;
  }
  .td {
    width: 33%;
  }
  .entity-title {
    font-family: Inter;
    font-size: ${e=>{let{theme:t}=e;return t.typography.sizes.m}}px;
    font-weight: ${e=>{let{theme:t}=e;return t.typography.weights.medium}};
    line-height: 17px;
    letter-spacing: 0px;
    text-align: left;
    margin: ${e=>{let{theme:t}=e;return 4*t.gridUnit}}px 0;
  }
`;function m(e){let{search:t="",setShowTagModal:a,objects:i}=e;const o=i.dashboard.length>0||i.chart.length>0||i.query.length>0,s=e=>{const t=i[e].map((t=>({[e]:(0,l.tZ)("a",{href:t.url},t.name),modified:d().utc(t.changed_on).fromNow(),tags:t.tags,owners:t.owners})));return(0,l.tZ)(u.Z,{className:"table-condensed",emptyWrapperType:u.u.Small,data:t,pageSize:10,columns:[{accessor:e,Header:"Title"},{Cell:e=>{let{row:{original:{tags:t=[]}}}=e;return(0,l.tZ)(c.P,{tags:t.filter((e=>"TagTypes.custom"===e.type||1===e.type)),maxTags:3})},Header:(0,r.t)("Tags"),accessor:"tags",disableSortBy:!0},{Cell:e=>{let{row:{original:{owners:t=[]}}}=e;return(0,l.tZ)(g.Z,{users:t})},Header:(0,r.t)("Owners"),accessor:"owners",disableSortBy:!0,size:"xl"}]})};return(0,l.tZ)(p,null,o?(0,l.tZ)(n.Fragment,null,(0,l.tZ)("div",{className:"entity-title"},(0,r.t)("Dashboards")),s("dashboard"),(0,l.tZ)("div",{className:"entity-title"},(0,r.t)("Charts")),s("chart"),(0,l.tZ)("div",{className:"entity-title"},(0,r.t)("Queries")),s("query")):(0,l.tZ)(h.XJ,{image:"dashboard.svg",title:(0,r.t)("No entities have this tag currently assigned"),buttonAction:()=>a(!0),buttonText:(0,r.t)("Add tag to entities")}))}var b=a(35932),y=a(67697),Z=a(52564),v=a(51360),f=a(14114),x=a(48273),$=a(38703);const S=e=>l.iv`
  display: flex;
  align-items: center;
  margin-left: ${e.gridUnit}px;
  & > span {
    margin-right: ${3*e.gridUnit}px;
  }
`,T=i.iK.div`
  ${e=>{let{theme:t}=e;return`\n  background-color: ${t.colors.grayscale.light4};\n  .select-control {\n    margin-left: ${4*t.gridUnit}px;\n    margin-right: ${4*t.gridUnit}px;\n    margin-bottom: ${2*t.gridUnit}px;\n  }\n  .select-control-label {\n    text-transform: uppercase;\n    font-size: ${3*t.gridUnit}px;\n    color: ${t.colors.grayscale.base};\n    margin-bottom: ${1*t.gridUnit}px;\n  }\n  .entities {\n    margin: ${6*t.gridUnit}px; 0px;\n  }\n  .pagination-container {\n    background-color: transparent;\n  }\n  `}}
`,w=i.iK.div`
  ${e=>{let{theme:t}=e;return`\n  height: ${12.5*t.gridUnit}px;\n  background-color: ${t.colors.grayscale.light5};\n  margin-bottom: ${4*t.gridUnit}px;\n  .navbar-brand {\n    margin-left: ${2*t.gridUnit}px;\n    font-weight: ${t.typography.weights.bold};\n  }\n  .header {\n    font-weight: ${t.typography.weights.bold};\n    margin-right:  ${3*t.gridUnit}px;\n    text-align: left;\n    font-size: ${4.5*t.gridUnit}px;\n    padding: ${3*t.gridUnit}px;\n    display: inline-block;\n    line-height: ${9*t.gridUnit}px;\n  }\n  `}};
`,C=(0,f.ZP)((function(){const[e]=(0,o.Wd)("id",o.yz),[t,a]=(0,n.useState)(null),[i,s]=(0,n.useState)(!1),{addSuccessToast:d,addDangerToast:u}=(0,f.e1)(),[c,g]=(0,n.useState)(!1),[h,p]=(0,n.useState)({dashboard:[],chart:[],query:[]}),C={title:(null==t?void 0:t.name)||"",placeholder:"testing",onSave:e=>{},canEdit:!1,label:(0,r.t)("dataset name")},_=[];if(null!=t&&t.description){const e={type:y.pG.DESCRIPTION,value:(null==t?void 0:t.description)||""};_.push(e)}const k={type:y.pG.OWNER,createdBy:`${null==t?void 0:t.created_by.first_name} ${null==t?void 0:t.created_by.last_name}`,createdOn:(null==t?void 0:t.created_on_delta_humanized)||""};_.push(k);const D={type:y.pG.LAST_MODIFIED,value:(null==t?void 0:t.changed_on_delta_humanized)||"",modifiedBy:`${null==t?void 0:t.changed_by.first_name} ${null==t?void 0:t.changed_by.last_name}`};_.push(D);const U=()=>{g(!0),(0,x.Y4)({tags:(null==t?void 0:t.name)||"",types:null},(e=>{const t={dashboard:[],chart:[],query:[]};e.forEach((function(e){const a=e.type;t[a].push(e)})),p(t),g(!1)}),(e=>{u("Error Fetching Tagged Objects"),g(!1)}))},E=e=>{(0,x.LS)(e,(e=>{a(e),g(!1)}),(e=>{u((0,r.t)("Error Fetching Tagged Objects")),g(!1)}))};return(0,n.useEffect)((()=>{e&&(g(!0),E(e))}),[e]),(0,n.useEffect)((()=>{t&&U()}),[t]),c?(0,l.tZ)($.Z,null):(0,l.tZ)(T,null,(0,l.tZ)(v.Z,{show:i,onHide:()=>{s(!1)},editTag:t,addSuccessToast:d,addDangerToast:u,refreshData:()=>{U(),e&&E(e)}}),(0,l.tZ)(w,null,(0,l.tZ)(Z.u,{additionalActionsMenu:(0,l.tZ)(n.Fragment,null),editableTitleProps:C,faveStarProps:{itemId:1,saveFaveStar:()=>{}},showFaveStar:!1,showTitlePanelItems:!0,titlePanelAdditionalItems:(0,l.tZ)("div",{css:S},(0,l.tZ)(y.ZP,{items:_,tooltipPlacement:"bottom"})),rightPanelAdditionalItems:(0,l.tZ)(n.Fragment,null,(0,l.tZ)(b.Z,{buttonStyle:"secondary",onClick:()=>s(!0),showMarginRight:!1},(0,r.t)("Edit Tag")," ")),menuDropdownProps:{disabled:!0},showMenuDropdown:!1})),(0,l.tZ)("div",{className:"entities"},(0,l.tZ)(m,{search:(null==t?void 0:t.name)||"",setShowTagModal:s,objects:h})))}))}}]);
//# sourceMappingURL=6666216ad7b3d132c367.chunk.js.map