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