UNPKG

datajunction-ui

Version:
3 lines (2 loc) 29.7 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ee=require("react-router-dom"),r=require("react"),x=require("./index-h1A5IisM.cjs"),ct=require("./NodeListActions-B3Gjsyaa.cjs"),dt=process.env.REACT_APP_PERSONAL_NAMESPACE_PREFIX||"users";function pt(a,n){if(a&&a!=="default")return a;if(!n)return"default";const s=n.split("@")[0].toLowerCase().replace(/[^a-z0-9_]/g,"_");return`${dt}.${s}`}function ut({namespace:a}){const n=r.useContext(x.DJClientContext).DataJunctionAPI,{currentUser:s}=x.useCurrentUser(),c=ee.useNavigate(),p=pt(a,s==null?void 0:s.username),l=(!a||a==="default")&&(s==null?void 0:s.username),g=d=>async S=>{if(S.preventDefault(),l)try{await n.addNamespace(p)}catch(j){console.error("Failed to ensure namespace exists:",j)}c(d)};return e.jsx("span",{className:"menu-link",style:{display:"inline-flex",alignItems:"center",margin:0,width:"130px"},children:e.jsx("span",{className:"menu-title",children:e.jsxs("div",{className:"dropdown",children:[e.jsx("span",{className:"add_node",children:"+ Add Node"}),e.jsxs("div",{className:"dropdown-content add-node-dropdown-content",children:[e.jsx("a",{href:"/create/source",children:e.jsx("div",{className:"node_type__source node_type_creation_heading",children:"Register Table"})}),e.jsx("a",{href:`/create/transform/${p}`,onClick:g(`/create/transform/${p}`),children:e.jsx("div",{className:"node_type__transform node_type_creation_heading",children:"Transform"})}),e.jsx("a",{href:`/create/metric/${p}`,onClick:g(`/create/metric/${p}`),children:e.jsx("div",{className:"node_type__metric node_type_creation_heading",children:"Metric"})}),e.jsx("a",{href:`/create/dimension/${p}`,onClick:g(`/create/dimension/${p}`),children:e.jsx("div",{className:"node_type__dimension node_type_creation_heading",children:"Dimension"})}),e.jsx("a",{href:"/create/tag",children:e.jsx("div",{className:"entity__tag node_type_creation_heading",children:"Tag"})}),e.jsx("a",{href:`/create/cube/${p}`,onClick:g(`/create/cube/${p}`),children:e.jsx("div",{className:"node_type__cube node_type_creation_heading",children:"Cube"})})]})]})})})}const pe=100,ht=a=>{const{children:n}=a;return Array.isArray(n)&&n.length>pe?e.jsxs(x.components.MenuList,{...a,children:[n.slice(0,pe),e.jsxs("div",{style:{padding:"6px 12px",fontSize:"11px",color:"#888"},children:["Showing first ",pe," of ",n.length,". Type to narrow…"]})]}):e.jsx(x.components.MenuList,{...a,children:n})};function Q({label:a,name:n,options:s,value:c,onChange:p,isMulti:l=!1,isClearable:g=!0,placeholder:d="Select...",minWidth:S="100px",flex:j=1,isLoading:T=!1,testId:v=null,formatOptionLabel:E=void 0,onMenuOpen:P=void 0}){const R=l?c!=null&&c.length?s.filter(y=>c.includes(y.value)):[]:c?s.find(y=>y.value===c):null;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px",flex:j,minWidth:S},"data-testid":v,children:[e.jsx("label",{style:{fontSize:"10px",fontWeight:"600",color:"#666",textTransform:"uppercase",letterSpacing:"0.5px"},children:a}),e.jsx(x.StateManagedSelect$1,{name:n,isClearable:g,isMulti:l,isLoading:T,placeholder:d,onChange:p,onMenuOpen:P,value:R,formatOptionLabel:E,components:{MenuList:ht},styles:{control:y=>({...y,minHeight:"32px",height:l?"auto":"32px",fontSize:"12px",backgroundColor:"white"}),valueContainer:y=>({...y,padding:"0 6px"}),input:y=>({...y,margin:0,padding:0}),indicatorSeparator:()=>({display:"none"}),dropdownIndicator:y=>({...y,padding:"4px"}),clearIndicator:y=>({...y,padding:"4px"}),option:y=>({...y,fontSize:"12px",padding:"6px 10px"}),multiValue:y=>({...y,fontSize:"11px"})},options:s})]})}function Ce({open:a=!1,size:n=12}){return e.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:a?"rotate(90deg)":"none",transition:"transform 0.12s ease"},children:e.jsx("polyline",{points:"9 6 15 12 9 18"})})}const ue="dj.ns.pinned";function _e(a){try{const n=JSON.parse(localStorage.getItem(a));return Array.isArray(n)?n.filter(s=>typeof s=="string"):[]}catch{return[]}}function ft(a,n){try{localStorage.setItem(a,JSON.stringify(n))}catch{}}function mt(){return _e(ue)}function xt(a){const n=_e(ue),s=n.includes(a)?n.filter(c=>c!==a):[...n,a];return ft(ue,s),s}function we({nodes:a,depth:n,expanded:s,onToggle:c,onSelect:p}){return a.map(l=>{var S;const g=((S=l.children)==null?void 0:S.length)>0,d=s.has(l.path);return e.jsxs(r.Fragment,{children:[e.jsxs("div",{className:"dj-ns-nav-item",role:"button",tabIndex:0,title:l.path,style:{paddingLeft:`${n*14}px`},onClick:()=>p(l.path),onKeyDown:j=>{j.key==="Enter"&&p(l.path)},children:[g?e.jsx("button",{type:"button","aria-label":d?"Collapse":"Expand","aria-expanded":d,onClick:j=>{j.stopPropagation(),c(l.path)},style:{width:"18px",minWidth:"18px",flexShrink:0,padding:0,margin:0,border:"none",background:"none",cursor:"pointer",color:"#64748b",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Ce,{open:d})}):e.jsx("span",{style:{width:"18px",minWidth:"18px",flexShrink:0}}),e.jsx("span",{className:"dj-ns-nav-name",children:l.namespace})]}),g&&d?e.jsx(we,{nodes:l.children,depth:n+1,expanded:s,onToggle:c,onSelect:p}):null]},l.path)})}function gt({folders:a,onSelect:n}){const[s,c]=r.useState(()=>new Set);if(!a||a.length===0)return null;const p=l=>c(g=>{const d=new Set(g);return d.has(l)?d.delete(l):d.add(l),d});return e.jsxs("div",{className:"dj-ns-folder-nav",children:[e.jsx("div",{className:"dj-ns-tree-heading",children:"Folders"}),e.jsx(we,{nodes:a,depth:0,expanded:s,onToggle:p,onSelect:n})]})}function yt({parent:a,onCreate:n}){const[s,c]=r.useState(!1),[p,l]=r.useState(""),[g,d]=r.useState(null),S=p.trim().replace(/[^a-zA-Z0-9_]/g,"_"),j=()=>{c(!1),l(""),d(null)},T=async()=>{if(!S){j();return}const v=await n(`${a}.${S}`);v!=null&&v._error?d(v.message||"Failed to create namespace"):j()};return s?e.jsxs("div",{style:{marginTop:"4px",paddingLeft:"18px",paddingRight:"8px"},children:[e.jsx("input",{autoFocus:!0,type:"text",value:p,onChange:v=>l(v.target.value),onKeyDown:v=>{v.key==="Enter"?T():v.key==="Escape"&&j()},onBlur:()=>{p.trim()||j()},placeholder:"Folder name","aria-label":"New sub-namespace name",style:{width:"100%",boxSizing:"border-box",padding:"6px 8px",fontSize:"15px",border:"1px solid #cbd5e1",borderRadius:"6px",outline:"none"}}),g?e.jsx("div",{style:{marginTop:"4px",fontSize:"12px",color:"#b91c1c"},children:g}):null]}):e.jsxs("button",{type:"button",className:"dj-ns-nav-item",onClick:()=>c(!0),style:{paddingLeft:0,color:"#64748b"},children:[e.jsx("span",{style:{width:"18px",minWidth:"18px",flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"16px",lineHeight:1},children:"+"}),e.jsx("span",{className:"dj-ns-nav-name",children:"New folder"})]})}function bt(a,n){var c;const s=a[n];return s?s.__typename==="GitRootConfig"?{root:n,defaultBranch:s.defaultBranch,activeBranch:s.defaultBranch,isRoot:!0}:s.__typename==="GitBranchConfig"?{root:s.parentNamespace,defaultBranch:(c=s.root)==null?void 0:c.defaultBranch,activeBranch:s.branch,isRoot:!1}:null:null}function jt({namespaces:a,hierarchy:n,currentNamespace:s,gitRoots:c,onSelect:p,canCreateNamespace:l=!1,onCreateNamespace:g}){const[d,S]=r.useState({"Top-level":!0}),[j,T]=r.useState(()=>mt()),[v,E]=r.useState(""),P=v.trim()!=="",R=P?x.searchNamespaces(a||[],v):[],y=!s,q=y?x.buildNamespaceOptions(a||[]):[],z={};for(const h of a||[])z[h.namespace]=h.git;const I=new Set(j),M=h=>!d[h],$=h=>S(b=>({...b,[h]:!b[h]})),F=(h,b)=>{h.stopPropagation(),T(xt(b))},i=(h,b)=>e.jsxs("div",{className:"dj-ns-nav-item",role:"button",tabIndex:0,title:h,onClick:()=>p(h),onKeyDown:D=>{D.key==="Enter"&&p(h)},children:[e.jsx("span",{className:"dj-ns-nav-name",children:h}),e.jsx("button",{type:"button",className:`dj-ns-star${I.has(h)?" pinned":""}`,"aria-label":`${I.has(h)?"Unpin":"Pin"} ${h}`,"aria-pressed":I.has(h),onClick:D=>F(D,h),children:I.has(h)?"★":"☆"})]},`${b}-${h}`),W=(h,b,D)=>{const A=M(h);return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:"dj-ns-group-heading","aria-expanded":A,onClick:()=>$(h),children:[e.jsx("span",{className:"dj-ns-chevron",children:e.jsx(Ce,{open:A})}),e.jsx("span",{className:"dj-ns-group-label",children:h}),e.jsx("span",{className:"dj-ns-group-count",children:b.length})]}),A?b.map(te=>i(te,D)):null]},D)},_=s?bt(z,s):null,H=_!=null&&_.isRoot&&_.defaultBranch?`${_.root}.${_.defaultBranch}`:s;return e.jsx("div",{children:y?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dj-ns-filter",children:[e.jsx("input",{type:"text",className:"dj-ns-filter-input",value:v,onChange:h=>E(h.target.value),placeholder:"Filter namespaces…","aria-label":"Filter namespaces"}),P?e.jsx("button",{type:"button",className:"dj-ns-filter-clear","aria-label":"Clear filter",title:"Clear filter",onClick:()=>E(""),children:"✕"}):null]}),P?R.length===0?e.jsxs("div",{style:{padding:"6px",color:"#64748b",fontSize:"12px"},children:['No namespaces match "',v.trim(),'".']}):W("Matches",R,"matches"):e.jsxs(e.Fragment,{children:[j.length>0?W("Pinned",j,"pin"):null,q.map(h=>W(h.label,h.options.map(b=>b.value),`grp-${h.label}`))]})]}):e.jsxs(e.Fragment,{children:[e.jsx(gt,{folders:x.immediateChildren(n||[],H),onSelect:p},H),l?e.jsx(yt,{parent:H,onCreate:g}):null]})})}const Se=["metric","cube","dimension","transform","source"],Ne={metric:{bg:"#fad7dd",color:"#a2283e"},cube:{bg:"#dbafff",color:"#580076"},dimension:{bg:"#ffefd0",color:"#a96621"},transform:{bg:"#ccefff",color:"#0063b4"},source:{bg:"#ccf7e5",color:"#00b368"}},De=[["#dbeafe","#1e40af"],["#dcfce7","#166534"],["#fef3c7","#92400e"],["#fce7f3","#9d174d"],["#ede9fe","#5b21b6"],["#ffedd5","#9a3412"],["#fee2e2","#991b1b"],["#d1fae5","#065f46"]];function vt(a){let n=0;for(let s=0;s<a.length;s++)n=n*31+a.charCodeAt(s)>>>0;return n%De.length}const St={name:{label:"Name"},displayName:{label:"Display name"},type:{label:"Type"},status:{label:"Validation",tooltip:"Whether this node validates successfully."},mode:{label:"Publish state",tooltip:"Whether this node is published or still a draft."},owners:{label:"Owners"},updatedAt:{label:"Updated"}},ke={padding:"8px 16px"},B={...ke,verticalAlign:"middle"},Nt={CUBE:"A curated set of metrics and dimensions for querying together.",DIMENSION:"Descriptive attributes used to group, filter, and join metrics.",METRIC:"A reusable business calculation or measure.",SOURCE:"A physical table registered in DJ as a source node.",TRANSFORM:"A SQL-defined node derived from sources or other DJ nodes."};function Ct(a){const n=a.lastIndexOf(".");return n===-1?{leafName:a,namespacePath:""}:{leafName:a.slice(n+1),namespacePath:a.slice(0,n)}}function _t(a){const n=a.mode==="PUBLISHED",s=a.status==="VALID";return{isPublished:n,isValid:s,publishLabel:n?"Published":"Draft",validationLabel:s?"Valid":"Needs fixes",publishTooltip:n?"This version is published and expected to be usable by downstream nodes.":"This version is a draft and may still be incomplete.",validationTooltip:s?"This node validates successfully.":"This node has validation errors. Open it to see what needs to be fixed.",needsAttention:!n||!s,borderColor:s&&n?"#28a745":"#d39e00",backgroundColor:s&&n?"#eaf7ee":"#fff7df",color:s&&n?"#1f7a3a":"#8a5b00"}}function wt(a){return new Date(a).toLocaleString("en-us",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Dt(a){const n=new Date(a),s=Date.now()-n.getTime(),c=Math.abs(s),p=[["year",365*24*60*60*1e3],["month",30*24*60*60*1e3],["week",7*24*60*60*1e3],["day",24*60*60*1e3],["hour",60*60*1e3],["minute",60*1e3]];for(const[l,g]of p)if(c>=g){const d=Math.round(c/g);return`${d} ${l}${d===1?"":"s"} ${s>=0?"ago":"from now"}`}return"just now"}function kt(){var ve;const a="ascending",n="descending",s=["name","displayName","type","status","mode","owners","updatedAt"],c=r.useContext(x.DJClientContext).DataJunctionAPI,{currentUser:p}=x.useCurrentUser();var{namespace:l}=ee.useParams();const g=ee.useNavigate(),[d,S]=ee.useSearchParams(),[j,T]=r.useState([]),[v,E]=r.useState([]),[P,R]=r.useState(!1),[y,q]=r.useState(!1),z=r.useRef(!1),I=r.useRef(!1),M=r.useCallback(async()=>{if(!z.current){z.current=!0,R(!0);try{const t=await c.users();T(t||[])}finally{R(!1)}}},[c]),$=r.useCallback(async()=>{if(!I.current){I.current=!0,q(!0);try{const t=await c.listTags();E(t||[])}finally{q(!1)}}},[c]);r.useEffect(()=>{(d.get("editedBy")||d.get("ownedBy"))&&M().catch(console.error),d.get("tags")&&$().catch(console.error)},[d,M,$]);const F=r.useCallback(()=>({node_type:d.get("type")||"",tags:d.get("tags")?d.get("tags").split(","):[],edited_by:d.get("editedBy")||"",mode:d.get("mode")||"",ownedBy:d.get("ownedBy")||"",statuses:d.get("statuses")||"",missingDescription:d.get("missingDescription")==="true",hasMaterialization:d.get("hasMaterialization")==="true",orphanedDimension:d.get("orphanedDimension")==="true"}),[d]),[i,W]=r.useState(F),[_,H]=r.useState(!1),h=r.useRef(!1);r.useEffect(()=>{if(!h.current){h.current=!0;return}W(F())},[d,F]);const b=r.useCallback(t=>{var u;const o=new URLSearchParams;t.node_type&&o.set("type",t.node_type),(u=t.tags)!=null&&u.length&&o.set("tags",t.tags.join(",")),t.edited_by&&o.set("editedBy",t.edited_by),t.mode&&o.set("mode",t.mode),t.ownedBy&&o.set("ownedBy",t.ownedBy),t.statuses&&o.set("statuses",t.statuses),t.missingDescription&&o.set("missingDescription","true"),t.hasMaterialization&&o.set("hasMaterialization","true"),t.orphanedDimension&&o.set("orphanedDimension","true"),S(o)},[S]),D=()=>{S(new URLSearchParams)},A=i.node_type||((ve=i.tags)==null?void 0:ve.length)||i.edited_by||i.mode||i.ownedBy||i.statuses||i.missingDescription||i.hasMaterialization||i.orphanedDimension,te=[{id:"my-nodes",label:"My Nodes",filters:{ownedBy:p==null?void 0:p.username}},{id:"needs-attention",label:"Needs Attention",filters:{ownedBy:p==null?void 0:p.username,statuses:"INVALID"}},{id:"drafts",label:"Drafts",filters:{ownedBy:p==null?void 0:p.username,mode:"draft"}}],Le=t=>{const o={node_type:"",tags:[],edited_by:"",mode:t.filters.mode||"",ownedBy:t.filters.ownedBy||"",statuses:t.filters.statuses||"",missingDescription:t.filters.missingDescription||!1,hasMaterialization:t.filters.hasMaterialization||!1,orphanedDimension:t.filters.orphanedDimension||!1};b(o)},K=t=>{var u;const o=t.filters;return(o.ownedBy||"")===(i.ownedBy||"")&&(o.statuses||"")===(i.statuses||"")&&(o.mode||"")===(i.mode||"")&&!i.node_type&&!((u=i.tags)!=null&&u.length)&&!i.edited_by&&!i.missingDescription&&!i.hasMaterialization&&!i.orphanedDimension},[he,Pe]=r.useState({namespace:l||"",nodes:[]}),[ne,fe]=r.useState(!1),[Te,Re]=r.useState([]),[me,Ie]=r.useState([]),[Be,Ee]=r.useState(new Set),[f,Me]=r.useState(void 0),[k,Ae]=r.useState({key:"updatedAt",direction:n}),[xe,se]=r.useState(null),[ge,ae]=r.useState(null),[ye,Oe]=r.useState(!0),[be,ze]=r.useState(!0),[$e,Fe]=r.useState(!0),[We,He]=r.useState(!0),[ie,Ve]=r.useState(""),[oe,Ue]=r.useState("");r.useEffect(()=>{const t=setTimeout(()=>Ue(ie.trim()),300);return()=>clearTimeout(t)},[ie]),r.useEffect(()=>{se(null),ae(null)},[oe]);const[re,le]=r.useState(null),[Ge,Je]=r.useState(void 0),L=f!==void 0,V=L&&!!(f!=null&&f.github_repo_path)&&(f==null?void 0:f.git_root_namespace)===l,X=Ge===!1,Ye=!!(f!=null&&f.github_repo_path||f!=null&&f.branch_namespace),qe=L&&!Ye,Ke=async t=>{var u,m;const o=await c.addNamespace(t);return o.status===200||o.status===201?((u=c.invalidateNamespacesCache)==null||u.call(c),g(`/namespaces/${t}`),{}):{_error:!0,message:((m=o.json)==null?void 0:m.message)||"Failed to create namespace"}},ce=V&&!(f!=null&&f.git_branch),U=ce&&(f!=null&&f.default_branch)?`${l}.${f.default_branch}`:l;r.useEffect(()=>{ce&&(f!=null&&f.default_branch)&&g(`/namespaces/${l}.${f.default_branch}`,{replace:!0})},[ce,f,l,g]),r.useEffect(()=>{if(!L||V&&(f!=null&&f.default_branch))return;let t=!1;if(!U){le(null);return}return c.nodeTypeCounts(U,Se).then(o=>{t||le(o)}).catch(()=>{t||le(null)}),()=>{t=!0}},[c,U,L,V,f]);const Xe=t=>{let o=a;k.key===t&&k.direction===a&&(o=n),(k.key!==t||k.direction!==o)&&Ae({key:t,direction:o})},Ze=t=>{if(k.key===t)return k.direction},Qe=t=>{const o=[],u=new Map,m=new Map;for(const N of t){const w=N.namespace.split(".");let O=o,G=u,J="";for(const Z of w){J+=Z;let Y=G.get(Z);Y||(Y={namespace:Z,children:[],path:J},O.push(Y),G.set(Z,Y),m.set(J,new Map)),O=Y.children,G=m.get(J),J+="."}}const C=N=>{N.sort((w,O)=>w.namespace.localeCompare(O.namespace)),N.forEach(w=>C(w.children))};return C(o),o};r.useEffect(()=>{(async()=>{const u=(await c.listNamespacesWithGit()).filter(N=>!x.isHiddenNamespace(N.namespace));Ie(u);const m=Qe(u);Re(m);const C=new Set(u.filter(N=>{var w;return((w=N.git)==null?void 0:w.__typename)==="GitRootConfig"}).map(N=>N.namespace));Ee(C)})().catch(console.error)},[c]),r.useEffect(()=>{if(!L||V&&(f!=null&&f.default_branch))return;(async()=>{fe(!1);const o={ownedBy:i.ownedBy||null,statuses:i.statuses?[i.statuses]:null,missingDescription:i.missingDescription,hasMaterialization:i.hasMaterialization,orphanedDimension:i.orphanedDimension,search:oe||null},u=await c.listNodesForLanding(U,i.node_type?[i.node_type.toUpperCase()]:[],i.tags,i.edited_by,xe,ge,50,k,i.mode?i.mode.toUpperCase():null,o);Pe({namespace:l,nodes:u.data?u.data.findNodesPaginated.edges.map(m=>m.node):[]}),u.data&&(Oe(u.data?u.data.findNodesPaginated.pageInfo.startCursor:""),ze(u.data?u.data.findNodesPaginated.pageInfo.endCursor:""),He(u.data?u.data.findNodesPaginated.pageInfo.hasPrevPage:!1),Fe(u.data?u.data.findNodesPaginated.pageInfo.hasNextPage:!1)),fe(!0)})().catch(console.error)},[c,i,xe,ge,k.key,k.direction,U,l,oe,L,V,f]);const et=()=>{be&&(ae(be),se(null))},tt=()=>{ye&&(ae(null),se(ye))},nt={metric:"Metric",cube:"Cube",dimension:"Dimension",transform:"Transform",source:"Source"},st=Se.map(t=>({value:t,label:nt[t],count:(re==null?void 0:re[t])??null})),at=(t,o)=>{var m,C;const u=t.count!=null?e.jsx("span",{style:{backgroundColor:((m=Ne[t.value])==null?void 0:m.bg)??"#f1f5f9",color:((C=Ne[t.value])==null?void 0:C.color)??"#475569",borderRadius:"8px",padding:"1px 8px",fontSize:"11px",fontWeight:600,fontVariantNumeric:"tabular-nums"},children:t.count}):null;return e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px",justifyContent:(o==null?void 0:o.context)==="menu"?"space-between":"flex-start",width:(o==null?void 0:o.context)==="menu"?"100%":"auto"},children:[e.jsx("span",{children:t.label}),u]})},it=[{value:"published",label:"Published"},{value:"draft",label:"Draft"}],ot=[{value:"VALID",label:"Valid"},{value:"INVALID",label:"Needs fixes"}],je=r.useMemo(()=>j.map(t=>({value:t.username,label:t.username})),[j]),rt=r.useMemo(()=>v.map(t=>({value:t.name,label:t.display_name})),[v]),lt=ne?he.nodes.length>0?he.nodes.map(t=>{const{leafName:o,namespacePath:u}=Ct(t.name),m=_t(t.current),C=t.owners||[];return e.jsxs("tr",{style:{backgroundColor:m.needsAttention?"#fffbeb":void 0},children:[e.jsxs("td",{style:{...ke,maxWidth:"300px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:[e.jsxs("div",{children:[e.jsx("a",{href:"/nodes/"+t.name,className:"link-table",title:t.name,style:{fontWeight:600,color:"#334155"},children:o}),e.jsx("span",{className:"rounded-pill badge bg-secondary-soft",style:{marginLeft:"0.5rem"},children:t.currentVersion})]}),u?e.jsx("div",{title:u,style:{color:"#64748b",fontSize:"12px",marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis"},children:u}):null]}),e.jsx("td",{style:{...B,maxWidth:"250px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",color:"#64748b"},children:e.jsx("a",{href:"/nodes/"+t.name,className:"link-table",style:{color:"#475569",fontWeight:400},children:t.type!=="source"?t.current.displayName:""})}),e.jsx("td",{style:B,children:e.jsx(x.Tooltip,{content:Nt[t.type],children:e.jsx("span",{className:"node_type__"+t.type.toLowerCase()+" badge node_type",children:t.type})})}),e.jsx("td",{style:B,children:e.jsx(x.Tooltip,{content:m.validationTooltip,children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",borderRadius:"999px",border:`1px solid ${m.isValid?"#28a745":"#d39e00"}`,backgroundColor:m.isValid?"#eaf7ee":"#fff7df",color:m.isValid?"#1f7a3a":"#8a5b00",fontWeight:"600",fontSize:"12px",lineHeight:1.2,padding:"6px 10px",whiteSpace:"nowrap"},children:m.validationLabel})})}),e.jsx("td",{style:B,children:e.jsx(x.Tooltip,{content:m.publishTooltip,children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",borderRadius:"999px",border:`1px solid ${m.isPublished?"#28a745":"#d39e00"}`,backgroundColor:m.isPublished?"#eaf7ee":"#fff7df",color:m.isPublished?"#1f7a3a":"#8a5b00",fontWeight:"600",fontSize:"12px",lineHeight:1.2,padding:"6px 10px",whiteSpace:"nowrap"},children:m.publishLabel})})}),e.jsx("td",{style:B,children:C.length>0&&e.jsx("div",{style:{display:"flex",gap:"2px"},children:C.slice(0,3).map(N=>{const w=N.username.split("@")[0].slice(0,2).toUpperCase(),[O,G]=De[vt(N.username)];return e.jsx("span",{title:N.username,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:O,color:G,fontSize:"9px",fontWeight:"600",flexShrink:0},children:w},N.username)})})}),e.jsx("td",{style:B,children:e.jsx(x.Tooltip,{content:wt(t.current.updatedAt),children:e.jsx("span",{className:"status",children:Dt(t.current.updatedAt)})})}),X&&e.jsx("td",{style:B,children:e.jsx(ct.NodeListActions,{nodeName:t==null?void 0:t.name})})]},t.name)}):e.jsx("tr",{children:e.jsx("td",{colSpan:s.length+(X?1:0),children:e.jsx("span",{style:{display:"block",marginTop:"2rem",marginLeft:"2rem",fontSize:"16px"},children:A?e.jsxs(e.Fragment,{children:["No nodes match the current filters.",e.jsx("a",{href:"#",onClick:t=>{t.preventDefault(),D()},style:{marginLeft:"0.5rem"},children:"Clear filters"})]}):"No nodes in this namespace yet."})})}):e.jsx("tr",{children:e.jsx("td",{children:e.jsx("span",{style:{display:"block",marginTop:"2rem"},children:e.jsx(x.LoadingIcon,{})})})}),de=[!!i.edited_by,i.missingDescription,i.hasMaterialization,i.orphanedDimension].filter(Boolean).length;return e.jsx("div",{className:"mid",children:e.jsx("div",{className:"card",children:e.jsxs("div",{className:"card-header",children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:e.jsx("h2",{style:{margin:0},children:"Browse"})}),L&&e.jsxs("div",{style:{marginBottom:"1rem",padding:"1rem",backgroundColor:"#f8fafc",borderRadius:"8px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"12px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.5px",color:"#64748b"},children:"Quick"}),te.map(t=>e.jsx("button",{onClick:()=>Le(t),style:{padding:"4px 10px",fontSize:"11px",border:"1px solid",borderColor:K(t)?"#1976d2":"#ddd",borderRadius:"12px",backgroundColor:K(t)?"#e3f2fd":"white",color:K(t)?"#1976d2":"#666",cursor:"pointer",fontWeight:K(t)?"600":"400"},children:t.label},t.id)),A&&e.jsx("button",{onClick:D,style:{padding:"4px 10px",fontSize:"11px",border:"none",backgroundColor:"transparent",color:"#dc3545",cursor:"pointer"},children:"Clear all ×"})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:"12px"},children:[e.jsx(Q,{label:"Type",name:"type",options:st,value:i.node_type,onChange:t=>b({...i,node_type:(t==null?void 0:t.value)||""}),formatOptionLabel:at,flex:1,minWidth:"80px",testId:"select-node-type"}),e.jsx(Q,{label:"Owner",name:"owner",options:je,value:i.ownedBy,onChange:t=>b({...i,ownedBy:(t==null?void 0:t.value)||""}),isLoading:P,onMenuOpen:M,flex:1,minWidth:"80px"}),e.jsx(Q,{label:"Tags",name:"tags",options:rt,value:i.tags,onChange:t=>b({...i,tags:t?t.map(o=>o.value):[]}),isMulti:!0,isLoading:y,onMenuOpen:$,flex:1.2,minWidth:"100px",testId:"select-tag"}),e.jsx(x.SplitFilter,{label:"Publish state",options:it,value:i.mode,onChange:t=>b({...i,mode:t})}),e.jsx(x.SplitFilter,{label:"Validation",options:ot,value:i.statuses,onChange:t=>b({...i,statuses:t})}),e.jsxs("div",{style:{position:"relative",flex:0,minWidth:"auto"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("label",{style:{fontSize:"10px",fontWeight:"600",color:"#666",textTransform:"uppercase",letterSpacing:"0.5px"},children:"More filters"}),e.jsxs("button",{onClick:()=>H(!_),style:{height:"32px",minHeight:"32px",padding:"0 12px",fontSize:"12px",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:de>0?"#e3f2fd":"white",color:"#666",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px",whiteSpace:"nowrap"},children:[de>0?`${de} active`:"Filters",e.jsx("span",{style:{fontSize:"8px"},children:_?"▲":"▼"})]})]}),_&&e.jsxs("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",padding:"12px",backgroundColor:"white",border:"1px solid #ddd",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:1e3,minWidth:"320px"},children:[e.jsx("div",{style:{display:"grid",gap:"12px",marginBottom:"12px"},children:e.jsx(Q,{label:"Edited By",name:"editedBy",options:je,value:i.edited_by,onChange:t=>b({...i,edited_by:(t==null?void 0:t.value)||""}),isLoading:P,onMenuOpen:M,flex:"none",minWidth:"100%",testId:"select-user"})}),e.jsxs("div",{style:{borderTop:"1px solid #e2e8f0",paddingTop:"12px"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:"#444",marginBottom:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.missingDescription,onChange:t=>b({...i,missingDescription:t.target.checked})}),"Missing Description"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:"#444",marginBottom:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.orphanedDimension,onChange:t=>b({...i,orphanedDimension:t.target.checked})}),"Orphaned Dimensions"]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"12px",color:"#444",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.hasMaterialization,onChange:t=>b({...i,hasMaterialization:t.target.checked})}),"Has Materialization"]})]})]})]})]})]}),e.jsxs(x.NamespaceHeader,{namespace:l,onGitConfigLoaded:Me,onReadOnlyChange:Je,namespaceOptions:me,currentNamespace:l,children:[l&&e.jsx(x.Tooltip,{content:`Download every node in "${l}" as a YAML project (.zip) you can version in git and re-deploy with the DJ client.`,children:e.jsxs("button",{type:"button",onClick:async()=>{const t=await fetch(`${x.getDJUrl()}/namespaces/${l}/export/yaml`,{method:"POST",credentials:"include"});if(!t.ok)return;const o=await t.blob(),u=URL.createObjectURL(o),m=document.createElement("a"),C=l.replace(/\./g,"_");m.href=u,m.download=`${C}_export.zip`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u)},style:x.secondaryButtonStyle,onMouseOver:x.onSecondaryHover,onMouseOut:x.onSecondaryOut,"aria-label":"Export namespace to YAML",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Export YAML"]})}),X&&e.jsx(ut,{namespace:l})]}),e.jsxs("div",{className:"table-responsive",children:[e.jsx("div",{className:"sidebar",style:{borderRight:"1px solid #e2e8f0",paddingRight:"1rem"},children:e.jsx(jt,{namespaces:me,hierarchy:Te,currentNamespace:l,gitRoots:Be,onSelect:t=>g(t?`/namespaces/${t}`:"/"),canCreateNamespace:qe,onCreateNamespace:Ke})}),e.jsxs("div",{style:{flex:1,minWidth:0,marginLeft:"1.5rem"},children:[L&&e.jsx("input",{type:"text",className:"dj-node-search",value:ie,onChange:t=>Ve(t.target.value),placeholder:"Search nodes in this namespace…","aria-label":"Search nodes in this namespace"}),L?e.jsxs("table",{className:"card-table table",style:{marginBottom:0},children:[e.jsx("thead",{children:e.jsxs("tr",{children:[s.map(t=>{const o=St[t]||{},u=o.sortable!==!1,m={fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",fontSize:"11px",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.5px",color:"#64748b",padding:"12px 16px",borderBottom:"1px solid #e2e8f0",backgroundColor:"transparent"};return e.jsx("th",{style:m,children:e.jsx(x.Tooltip,{content:o.tooltip,placement:"top",children:u?e.jsx("button",{type:"button",onClick:()=>Xe(t),className:"sortable "+Ze(t),style:{fontSize:"inherit",fontWeight:"inherit",letterSpacing:"inherit",textTransform:"inherit",fontFamily:"inherit"},children:o.label||t.replace(/([a-z](?=[A-Z]))/g,"$1 ")}):e.jsx("span",{children:o.label||t.replace(/([a-z](?=[A-Z]))/g,"$1 ")})})},t)}),X&&e.jsx("th",{style:{fontFamily:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif",fontSize:"11px",fontWeight:"600",textTransform:"uppercase",letterSpacing:"0.5px",color:"#64748b",padding:"12px 16px",borderBottom:"1px solid #e2e8f0",backgroundColor:"transparent"},children:"Actions"})]})}),e.jsx("tbody",{className:"nodes-table-body",children:lt}),e.jsx("tfoot",{children:e.jsx("tr",{children:e.jsxs("td",{children:[ne&&We?e.jsx("a",{onClick:tt,className:"previous round pagination",children:"← Previous"}):"",ne&&$e?e.jsx("a",{onClick:et,className:"next round pagination",children:"Next →"}):""]})})})]}):null]})]})]})})})}exports.NamespacePage=kt; //# sourceMappingURL=index-B8BCP1aG.cjs.map