"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[7637],{25772:(e,t,a)=>{a.d(t,{P:()=>n.Z});var n=a(465477);a(908420)},745181:(e,t,a)=>{a.d(t,{Z:()=>Z});var n=a(667294),i=a(115926),r=a.n(i),s=a(774069),o=a(784101),d=a(49238),l=a(751995),c=a(431069),h=a(61988),g=a(477808),u=a(104715),p=a(835932),m=a(848273),b=a(135944);const y=l.iK.div`
  .ant-select-dropdown {
    max-height: ${({theme:e})=>40*e.gridUnit}px;
  }
  .tag-input {
    margin-bottom: ${({theme:e})=>3*e.gridUnit}px;
  }
`;var v;!function(e){e.Chart="chart",e.Dashboard="dashboard",e.SavedQuery="query"}(v||(v={}));const Z=({show:e,onHide:t,editTag:a,refreshData:i,addSuccessToast:l,addDangerToast:Z,clearOnHide:f=!1})=>{const[S,w]=(0,n.useState)([]),[x,T]=(0,n.useState)([]),[$,C]=(0,n.useState)([]),[_,U]=(0,n.useState)(""),[D,N]=(0,n.useState)(""),E=!!a,j=E?"Edit Tag":"Create Tag",P=()=>{U(""),N(""),w([]),T([]),C([])};(0,n.useEffect)((()=>{const e={[v.Dashboard]:[],[v.Chart]:[],[v.SavedQuery]:[]},t=({id:t,name:a,type:n})=>{const i=e[n];i&&i.push({value:t,label:a,key:t})};w([]),T([]),C([]),E&&((0,m.AN)({tagIds:[a.id],types:null},(a=>{a.forEach(t),w(e[v.Dashboard]),T(e[v.Chart]),C(e[v.SavedQuery])}),(e=>{Z("Error Fetching Tagged Objects")})),U(a.name),N(a.description))}),[a]);const k=async(e,t,a,n,i,s,o)=>{const d=r().encode({columns:n,filters:[{col:i,opr:"ct",value:e}],page:t,order_column:s}),{json:l}=await c.Z.get({endpoint:`/api/v1/${o}/?q=${d}`}),{result:h,count:g}=l;return{data:h.map((e=>({value:e.id,label:e[i]}))),totalCount:g}},X=(e,t)=>{e===v.Dashboard?w(t):e===v.Chart?T(t):e===v.SavedQuery&&C(t)};return(0,b.tZ)(s.default,{title:j,onHide:()=>{f&&P(),t()},show:e,footer:(0,b.BX)("div",{children:[(0,b.tZ)(p.Z,{buttonStyle:"secondary",onClick:t,children:(0,h.t)("Cancel")}),(0,b.tZ)(p.Z,{buttonStyle:"primary",onClick:()=>{const e=S.map((e=>["dashboard",e.value])),n=x.map((e=>["chart",e.value])),r=$.map((e=>["query",e.value]));E?c.Z.put({endpoint:`/api/v1/tag/${a.id}`,jsonPayload:{description:D,name:_,objects_to_tag:[...e,...n,...r]}}).then((({json:e={}})=>{i(),P(),l((0,h.t)("Tag updated")),t()})).catch((e=>{Z(e.message||"Error Updating Tag")})):c.Z.post({endpoint:"/api/v1/tag/",jsonPayload:{description:D,name:_,objects_to_tag:[...e,...n,...r]}}).then((({json:e={}})=>{i(),P(),l((0,h.t)("Tag created")),t()})).catch((e=>Z(e.message||"Error Creating Tag")))},children:(0,h.t)("Save")})]}),children:(0,b.BX)(y,{children:[(0,b.tZ)(d.lX,{children:(0,h.t)("Tag name")}),(0,b.tZ)(g.Z,{className:"tag-input",onChange:e=>U(e.target.value),placeholder:(0,h.t)("Name of your tag"),value:_}),(0,b.tZ)(d.lX,{children:(0,h.t)("Description")}),(0,b.tZ)(g.Z,{className:"tag-input",onChange:e=>N(e.target.value),placeholder:(0,h.t)("Add description of your tag"),value:D}),(0,b.tZ)(u.iz,{}),(0,b.tZ)(o.Z,{className:"tag-input",ariaLabel:(0,h.t)("Select dashboards"),mode:"multiple",name:"dashboards",value:S,options:async(e,t,a)=>k(e,t,0,["id","dashboard_title"],"dashboard_title","dashboard_title","dashboard"),onChange:e=>X(v.Dashboard,e),header:(0,b.tZ)(d.lX,{children:(0,h.t)("Dashboards")}),allowClear:!0}),(0,b.tZ)(o.Z,{className:"tag-input",ariaLabel:(0,h.t)("Select charts"),mode:"multiple",name:"charts",value:x,options:async(e,t,a)=>k(e,t,0,["id","slice_name"],"slice_name","slice_name","chart"),onChange:e=>X(v.Chart,e),header:(0,b.tZ)(d.lX,{children:(0,h.t)("Charts")}),allowClear:!0}),(0,b.tZ)(o.Z,{className:"tag-input",ariaLabel:(0,h.t)("Select saved queries"),mode:"multiple",name:"savedQueries",value:$,options:async(e,t,a)=>k(e,t,0,["id","label"],"label","label","saved_query"),onChange:e=>X(v.SavedQuery,e),header:(0,b.tZ)(d.lX,{children:(0,h.t)("Saved queries")}),allowClear:!0})]})})}},707628:(e,t,a)=>{a.r(t),a.d(t,{default:()=>U});var n=a(667294),i=a(211965),r=a(751995),s=a(61988),o=a(535755),d=a(730381),l=a.n(d),c=a(676962),h=a(25772),g=a(222545),u=a(94301),p=a(135944);const m=r.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 b({search:e="",setShowTagModal:t,objects:a}){const n=a.dashboard.length>0||a.chart.length>0||a.query.length>0,i=e=>{const t=a[e].map((t=>({[e]:(0,p.tZ)("a",{href:t.url,children:t.name}),modified:l().utc(t.changed_on).fromNow(),tags:t.tags,owners:t.owners})));return(0,p.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,p.tZ)(h.P,{tags:e.filter((e=>"TagTypes.custom"===e.type||1===e.type)),maxTags:3}),Header:(0,s.t)("Tags"),accessor:"tags",disableSortBy:!0},{Cell:({row:{original:{owners:e=[]}}})=>(0,p.tZ)(g.Z,{users:e}),Header:(0,s.t)("Owners"),accessor:"owners",disableSortBy:!0,size:"xl"}]})};return(0,p.tZ)(m,{children:n?(0,p.BX)(p.HY,{children:[(0,p.tZ)("div",{className:"entity-title",children:(0,s.t)("Dashboards")}),i("dashboard"),(0,p.tZ)("div",{className:"entity-title",children:(0,s.t)("Charts")}),i("chart"),(0,p.tZ)("div",{className:"entity-title",children:(0,s.t)("Queries")}),i("query")]}):(0,p.tZ)(u.XJ,{image:"dashboard.svg",title:(0,s.t)("No entities have this tag currently assigned"),buttonAction:()=>t(!0),buttonText:(0,s.t)("Add tag to entities")})})}var y=a(835932),v=a(767697),Z=a(852564),f=a(745181),S=a(414114),w=a(848273),x=a(838703),T=a(83379);const $=e=>i.iv`
  display: flex;
  align-items: center;
  margin-left: ${e.gridUnit}px;
  & > span {
    margin-right: ${3*e.gridUnit}px;
  }
`,C=r.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  `}
`,_=r.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  `};
`,U=(0,S.ZP)((function(){const[e]=(0,o.Wd)("id",o.yz),[t,a]=(0,n.useState)(null),[i,r]=(0,n.useState)(!1),{addSuccessToast:d,addDangerToast:l}=(0,S.e1)(),[c,h]=(0,n.useState)(!1),[g,u]=(0,n.useState)({dashboard:[],chart:[],query:[]}),m={title:(null==t?void 0:t.name)||"",placeholder:"testing",onSave:e=>{},canEdit:!1,label:(0,s.t)("dataset name")},U=[];if(null!=t&&t.description){const e={type:v.pG.Description,value:(null==t?void 0:t.description)||""};U.push(e)}const D={type:v.pG.Owner,createdBy:(0,T.Z)(null==t?void 0:t.created_by),createdOn:(null==t?void 0:t.created_on_delta_humanized)||""};U.push(D);const N={type:v.pG.LastModified,value:(null==t?void 0:t.changed_on_delta_humanized)||"",modifiedBy:(0,T.Z)(null==t?void 0:t.changed_by)};U.push(N);const E=()=>{h(!0),t?(0,w.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)})),u(t),h(!1)}),(e=>{l("Error Fetching Tagged Objects"),h(!1)})):l("Error tag object is not referenced!")},j=e=>{(0,w.LS)(e,(e=>{a(e),h(!1)}),(e=>{l((0,s.t)("Error Fetching Tagged Objects")),h(!1)}))};return(0,n.useEffect)((()=>{e&&(h(!0),j(e))}),[e]),(0,n.useEffect)((()=>{t&&E()}),[t]),c?(0,p.tZ)(x.Z,{}):(0,p.BX)(C,{children:[(0,p.tZ)(f.Z,{show:i,onHide:()=>{r(!1)},editTag:t,addSuccessToast:d,addDangerToast:l,refreshData:()=>{E(),e&&j(e)}}),(0,p.tZ)(_,{children:(0,p.tZ)(Z.u,{additionalActionsMenu:(0,p.tZ)(p.HY,{}),editableTitleProps:m,faveStarProps:{itemId:1,saveFaveStar:()=>{}},showFaveStar:!1,showTitlePanelItems:!0,titlePanelAdditionalItems:(0,p.tZ)("div",{css:$,children:(0,p.tZ)(v.ZP,{items:U,tooltipPlacement:"bottom"})}),rightPanelAdditionalItems:(0,p.tZ)(p.HY,{children:(0,p.BX)(y.Z,{buttonStyle:"secondary",onClick:()=>r(!0),showMarginRight:!1,children:[(0,s.t)("Edit Tag")," "]})}),menuDropdownProps:{disabled:!0},showMenuDropdown:!1})}),(0,p.tZ)("div",{className:"entities",children:(0,p.tZ)(b,{search:(null==t?void 0:t.name)||"",setShowTagModal:r,objects:g})})]})}))}}]);
//# sourceMappingURL=b60773738757235fed38.chunk.js.map