UNPKG

datajunction-ui

Version:
3 lines (2 loc) 28 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),B=require("react"),A=require("./index-h1A5IisM.cjs"),D=require("react-router-dom"),$=require("./NodeListActions-B3Gjsyaa.cjs");;/* empty css */function E(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const c in t)if(c!=="default"){const s=Object.getOwnPropertyDescriptor(t,c);Object.defineProperty(a,c,s.get?s:{enumerable:!0,get:()=>t[c]})}}return a.default=t,Object.freeze(a)}const M=E(B),z=t=>{var a,c,s;return((s=(c=(a=t==null?void 0:t.data)==null?void 0:a.findNodesPaginated)==null?void 0:c.edges)==null?void 0:s.map(d=>d.node))||[]};function O(t){const a=B.useContext(A.DJClientContext).DataJunctionAPI,[c,s]=B.useState({ownedNodes:[],ownedHasMore:{},recentlyEdited:[],editedHasMore:{},watchedNodes:[],collections:[],notifications:[],materializedNodes:[],needsAttention:{nodesMissingDescription:[],invalidNodes:[],staleDrafts:[],orphanedDimensions:[]},hasPersonalNamespace:null}),[d,p]=B.useState({myNodes:!0,collections:!0,notifications:!0,materializations:!0,needsAttention:!0,namespace:!0});return B.useEffect(()=>{if(!t){p({myNodes:!1,collections:!1,notifications:!1,materializations:!1,needsAttention:!1,namespace:!1});return}p({myNodes:!0,collections:!0,notifications:!0,materializations:!0,needsAttention:!0,namespace:!0});const h=["METRIC","TRANSFORM","DIMENSION","CUBE"],i=o=>{var f,x,g;return((g=(x=(f=o==null?void 0:o.data)==null?void 0:f.findNodesPaginated)==null?void 0:x.pageInfo)==null?void 0:g.hasNextPage)??!1},n=async()=>{try{const[o,f,x]=await Promise.all([Promise.all(h.map(y=>a.getWorkspaceOwnedNodes(t,11,y))),Promise.all(h.map(y=>a.getWorkspaceRecentlyEdited(t,11,y))),a.getWorkspaceCollections(t)]),g=Object.fromEntries(h.map((y,j)=>[y.toLowerCase(),i(o[j])])),u=Object.fromEntries(h.map((y,j)=>[y.toLowerCase(),i(f[j])]));s(y=>{var j;return{...y,ownedNodes:o.flatMap(b=>z(b)),ownedHasMore:g,recentlyEdited:f.flatMap(b=>z(b)),editedHasMore:u,collections:((j=x==null?void 0:x.data)==null?void 0:j.listCollections)||[]}})}catch(o){console.error("Error fetching nodes/collections:",o)}p(o=>({...o,myNodes:!1,collections:!1}))},m=async()=>{try{const[o,f]=await Promise.all([a.getNotificationPreferences({entity_type:"node"}),a.getSubscribedHistory(50)]),x=(o||[]).map(w=>w.entity_name),g=f||[],u=Array.from(new Set(g.map(w=>w.entity_name))),[y,j]=await Promise.all([x.length>0?a.getNodesByNames(x):Promise.resolve([]),u.length>0?a.getNodesByNames(u):Promise.resolve([])]),b=Object.fromEntries((j||[]).map(w=>[w.name,w])),N=g.map(w=>{var v,S,k;return{...w,node_type:(v=b[w.entity_name])==null?void 0:v.type,display_name:(k=(S=b[w.entity_name])==null?void 0:S.current)==null?void 0:k.displayName}});s(w=>({...w,watchedNodes:y||[],notifications:N}))}catch(o){console.error("Error fetching watched/notifications:",o)}p(o=>({...o,notifications:!1}))},r=async()=>{try{const o=await a.getWorkspaceMaterializations(t,6);s(f=>({...f,materializedNodes:z(o)}))}catch(o){console.error("Error fetching materializations:",o)}p(o=>({...o,materializations:!1}))},l=async()=>{try{const f=`users.${t.split("@")[0]}`,[x,g,u,y,j]=await Promise.all([a.getWorkspaceNodesMissingDescription(t,100),a.getWorkspaceInvalidNodes(t,100),a.getWorkspaceDraftNodes(t,100),a.getWorkspaceOrphanedDimensions(t,100),a.namespaces()]),b=new Date;b.setDate(b.getDate()-7);const N=z(u);s(w=>({...w,needsAttention:{nodesMissingDescription:z(x),invalidNodes:z(g),staleDrafts:N.filter(v=>{var S;return new Date((S=v.current)==null?void 0:S.updatedAt)<b}),orphanedDimensions:z(y)},hasPersonalNamespace:(j||[]).some(v=>v.namespace===f)}))}catch(o){console.error("Error fetching needs attention:",o)}p(o=>({...o,needsAttention:!1,namespace:!1}))};n(),m(),r(),l()},[a,t]),{data:c,loadingStates:d}}function C({title:t,actionLink:a,actionText:c="View All →",loading:s=!1,emptyState:d=null,children:p,cardStyle:h={},contentStyle:i={},showHeader:n=!0}){const m=M.Children.toArray(p).filter(l=>l!==!1&&l!==null&&l!==void 0).length>0,r=!s&&!m&&d;return e.jsxs("section",{children:[n&&e.jsxs("div",{className:"section-title-row",children:[e.jsx("h2",{className:"settings-section-title",children:t}),a&&e.jsx(D.Link,{to:a,style:{fontSize:"13px"},children:c})]}),e.jsx("div",{className:"settings-card",style:{padding:"0.75rem",...h,...i},children:s?e.jsx("div",{style:{textAlign:"center",padding:"2rem"},children:e.jsx(A.LoadingIcon,{})}):r?d:p})]})}function H({icon:t,message:a,action:c}){return e.jsxs("div",{style:{padding:"2rem",textAlign:"center",color:"#666",fontSize:"12px"},children:[t&&e.jsx("div",{style:{fontSize:"24px",marginBottom:"0.5rem"},children:t}),e.jsx("p",{children:a}),c]})}function L({type:t,size:a="medium",abbreviated:c=!1,style:s={}}){if(!t)return null;const d={small:{fontSize:"7px",padding:"0.44em"},medium:{fontSize:"9px",padding:"0.44em"},large:{fontSize:"11px",padding:"0.44em"}},p=d[a]||d.medium,h=c?t.charAt(0):t;return e.jsx("span",{className:`node_type__${t.toLowerCase()} badge node_type`,style:{...p,flexShrink:0,...s,marginRight:0},children:h})}function _({node:t,size:a="medium",showFullName:c=!1,ellipsis:s=!1,style:d={}}){var m;if(!(t!=null&&t.name))return null;const p={small:{fontSize:"10px",fontWeight:"500"},medium:{fontSize:"12px",fontWeight:"500"},large:{fontSize:"14px",fontWeight:"500"}},h=p[a]||p.medium,i=c?t.name:((m=t.current)==null?void 0:m.displayName)||t.name.split(".").pop(),n=s?{display:"block",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:{};return e.jsx("a",{href:`/nodes/${t.name}`,style:{...h,textDecoration:"none",...n,...d},children:i})}function P({node:t,size:a="medium",showBadge:c=!0,abbreviatedBadge:s=!1,ellipsis:d=!1,gap:p="6px",containerStyle:h={}}){return t?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:p,...d?{minWidth:0,overflow:"hidden"}:{},...h},children:[e.jsx(_,{node:t,size:a,ellipsis:d}),c&&t.type&&e.jsx(L,{type:t.type,size:a,abbreviated:s})]}):null}function F({node:t}){var a;return t?e.jsxs("a",{href:`/nodes/${t.name}`,style:{display:"inline-flex",alignItems:"center",gap:"3px",padding:"2px 6px",fontSize:"12px",border:"1px solid var(--border-color, #ddd)",borderRadius:"3px",textDecoration:"none",color:"inherit",backgroundColor:"var(--card-bg, #f8f9fa)",whiteSpace:"nowrap",flexShrink:0},children:[e.jsx(L,{type:t.type,size:"small",abbreviated:!0}),((a=t.current)==null?void 0:a.displayName)||t.name.split(".").pop()]}):null}function G({notifications:t,username:a,loading:c}){const s={};t.forEach(h=>{s[h.entity_name]||(s[h.entity_name]=[]),s[h.entity_name].push(h)});const p=Object.entries(s).map(([h,i])=>({nodeName:h,entries:i,mostRecent:i[0],count:i.length})).slice(0,15).map(({nodeName:h,entries:i,mostRecent:n,count:m})=>{var g,u,y,j,b;const r=(g=n.details)==null?void 0:g.version,l=r?`/nodes/${n.entity_name}/revisions/${r}`:`/nodes/${n.entity_name}/history`,o=i.map(N=>N.user).filter(N=>N!=null&&N!==""),f=[...new Set(o)],x=f.length===0?n.user===a?"you":((u=n.user)==null?void 0:u.split("@")[0])||"unknown":f.length===1?f[0]===a?"you":(y=f[0])==null?void 0:y.split("@")[0]:f.includes(a)?`you + ${f.length-1} other${f.length-1>1?"s":""}`:`${f.length} users`;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0",borderBottom:"1px solid var(--border-color, #eee)",fontSize:"12px"},children:[e.jsx("a",{href:l,style:{fontSize:"13px",fontWeight:"500",textDecoration:"none",flexShrink:0},children:n.display_name||n.entity_name.split(".").pop()}),n.node_type&&e.jsx(L,{type:n.node_type.toUpperCase(),size:"medium"}),e.jsxs("span",{style:{color:"#888",whiteSpace:"nowrap"},children:[m>1?`${m} updates`:((j=n.activity_type)==null?void 0:j.charAt(0).toUpperCase())+((b=n.activity_type)==null?void 0:b.slice(1))+"d"," ","by ",x," · ",A.formatRelativeTime(n.created_at)]})]},h)});return e.jsx(C,{title:"Notifications",actionLink:"/notifications",loading:c,cardStyle:{padding:"0",maxHeight:"300px",overflowY:"auto"},emptyState:e.jsx(H,{icon:"🔔",message:"No notifications yet.",action:e.jsx("p",{style:{fontSize:"11px",marginTop:"0.5rem"},children:"Watch nodes to get notified of changes."})}),children:t.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",padding:"0.5rem"},children:p})})}function q({nodesMissingDescription:t,invalidNodes:a,staleDrafts:c,staleMaterializations:s,orphanedDimensions:d,username:p,loading:h,personalNamespace:i,hasPersonalNamespace:n,namespaceLoading:m}){const r=[{id:"invalid",icon:"❌",label:"Invalid",nodes:a,viewAllLink:`/?ownedBy=${p}&statuses=INVALID`},{id:"stale-drafts",icon:"⏰",label:"Stale Drafts",nodes:c,viewAllLink:`/?ownedBy=${p}&mode=DRAFT`},{id:"stale-materializations",icon:"📦",label:"Stale Materializations",nodes:s,viewAllLink:`/?ownedBy=${p}&hasMaterialization=true`},{id:"no-description",icon:"📝",label:"No Description",nodes:t,viewAllLink:`/?ownedBy=${p}&missingDescription=true`},{id:"orphaned-dimensions",icon:"🔗",label:"Orphaned Dimensions",nodes:d,viewAllLink:`/?ownedBy=${p}&orphanedDimension=true`}];return e.jsxs("section",{style:{minWidth:0,width:"100%"},children:[e.jsx("h2",{className:"settings-section-title",children:"Needs Attention"}),e.jsx("div",{className:"settings-card",style:{padding:"0.25rem 0.75rem"},children:h?e.jsx("div",{style:{textAlign:"center",padding:"1rem"},children:e.jsx(A.LoadingIcon,{})}):e.jsxs(e.Fragment,{children:[r.map((l,o)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.35rem 0",borderBottom:o<r.length-1?"1px solid var(--border-color, #f0f0f0)":"none",minWidth:0},children:[e.jsxs("span",{style:{fontSize:"11px",fontWeight:600,color:"#555",whiteSpace:"nowrap",flexShrink:0},children:[l.label," ",e.jsxs("span",{style:{color:l.nodes.length>0?"#dc3545":"#28a745",fontWeight:500},children:["(",l.nodes.length,")"]})]}),l.nodes.length>0?e.jsx("div",{style:{flex:1,overflow:"hidden",maskImage:"linear-gradient(to right, black 75%, transparent 100%)",WebkitMaskImage:"linear-gradient(to right, black 75%, transparent 100%)"},children:e.jsx("div",{style:{display:"flex",gap:"0.25rem",flexWrap:"nowrap"},children:l.nodes.slice(0,20).map(f=>e.jsx(F,{node:f},f.name))})}):e.jsx("span",{style:{fontSize:"10px",color:"#28a745",flex:1},children:"All good"}),l.nodes.length>0&&e.jsx(D.Link,{to:l.viewAllLink,style:{fontSize:"11px",flexShrink:0},children:"→"})]},l.id)),!m&&!n&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.35rem 0",fontSize:"11px"},children:[e.jsx("span",{style:{fontWeight:600,color:"#555",flexShrink:0},children:"Personal namespace"}),e.jsxs(D.Link,{to:`/namespaces/${i}`,style:{fontSize:"10px"},children:["Create ",i," →"]})]})]})})]})}function U({nodes:t,showUpdatedAt:a}){const c=s=>new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsx("div",{className:"node-list",children:t.map(s=>{var d;return e.jsxs("div",{className:"subscription-item node-list-item",children:[e.jsxs("div",{className:"node-list-item-content",children:[e.jsx("div",{className:"node-list-item-display",children:e.jsx(P,{node:s,size:"large",ellipsis:!0,gap:"0.5rem"})}),e.jsx("div",{className:"node-list-item-name",children:s.name})]}),e.jsxs("div",{className:"node-list-item-actions",children:[a&&((d=s.current)==null?void 0:d.updatedAt)&&e.jsx("span",{className:"node-list-item-updated",children:c(s.current.updatedAt)}),e.jsx("div",{className:"node-list-item-actions-wrapper",children:e.jsx($.NodeListActions,{nodeName:s.name})})]})]},s.name)})})}function Y(t){const a=new Date(t),s=new Date-a,d=Math.floor(s/(1e3*60)),p=Math.floor(s/(1e3*60*60)),h=Math.floor(s/(1e3*60*60*24));return d<60?`${d}m`:p<24?`${p}h`:h<30?`${h}d`:a.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function J(t){return t.charAt(0).toUpperCase()+t.slice(1)}function V({type:t,nodes:a,hasMore:c,username:s,activeTab:d}){const p=a,h=()=>{const i=new URLSearchParams;return d==="owned"?(i.append("ownedBy",s),i.append("type",t)):d==="watched"?i.append("type",t):d==="edited"&&(i.append("updatedBy",s),i.append("type",t)),`/?${i.toString()}`};return e.jsxs("div",{className:"type-group-card",children:[e.jsx("div",{className:"type-group-header",children:e.jsxs("span",{className:"type-group-title",children:[J(t),"s"]})}),e.jsx("div",{className:"type-group-nodes",children:p.map(i=>{var g,u,y,j;const n=i.status==="invalid",m=i.mode==="draft",r=(g=i.gitInfo)==null?void 0:g.repo,l=(u=i.gitInfo)==null?void 0:u.branch,o=(y=i.gitInfo)==null?void 0:y.defaultBranch,f=l&&l===o,x=r||l;return e.jsxs("div",{className:"type-group-node",children:[e.jsx(L,{type:i.type,size:"small",abbreviated:!0}),n&&e.jsx("span",{className:"type-group-node-status-icon",title:"Invalid node",children:"⚠️"}),m&&e.jsx("span",{className:"type-group-node-status-icon",title:"Draft mode",children:"📝"}),e.jsx(_,{node:i,size:"small",ellipsis:!0,style:{flex:1,minWidth:0}}),x&&e.jsxs("span",{className:`type-group-node-git-info ${f?"type-group-node-git-info--default":""}`,title:`${r||""}${r&&l?" / ":""}${l||""}${f?" (default)":""}`,style:{display:"flex",alignItems:"center",gap:"4px",maxWidth:"40%"},children:[f&&e.jsx("span",{style:{lineHeight:1,flexShrink:0},children:"⭐"}),r&&e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:r}),r&&l&&e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),l&&e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:l})]}),((j=i.current)==null?void 0:j.updatedAt)&&e.jsx("span",{className:"type-group-node-time",children:Y(i.current.updatedAt)}),e.jsx("div",{className:"type-group-node-actions",children:e.jsx($.NodeListActions,{nodeName:i.name})})]},i.name)})}),c&&e.jsx(D.Link,{to:h(),className:"type-group-more",children:"More →"})]})}function K({groupedData:t,username:a,activeTab:c}){return!t||t.length===0?e.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"#666",fontSize:"12px"},children:"No nodes to display"}):e.jsx("div",{className:"type-group-grid",children:t.map(s=>e.jsx(V,{type:s.type,nodes:s.nodes,hasMore:s.hasMore,username:a,activeTab:c},s.type))})}const Q=["metric","cube","dimension","transform","source"];function X(t,a={}){const c={};return t.forEach(s=>{const d=(s.type||"unknown").toLowerCase();c[d]||(c[d]=[]),c[d].push(s)}),Q.filter(s=>{var d;return((d=c[s])==null?void 0:d.length)>0}).map(s=>({type:s,nodes:c[s],hasMore:a[s]??!1}))}function Z({ownedNodes:t,ownedHasMore:a={},watchedNodes:c,recentlyEdited:s,editedHasMore:d={},username:p,loading:h}){const[i,n]=M.useState("owned"),m=M.useRef(!1);M.useEffect(()=>{m.current||(t.length===0&&s.length>0?(n("edited"),m.current=!0):t.length>0&&(m.current=!0))},[t.length,s.length]);const[r,l]=M.useState(()=>{const v=localStorage.getItem("workspace_groupByType");return v===null?!0:v==="true"}),o=new Set(t.map(v=>v.name)),f=c.filter(v=>!o.has(v.name)),x=new Set([...o,...c.map(v=>v.name)]);s.filter(v=>!x.has(v.name));const u=(()=>{switch(i){case"owned":return t;case"watched":return f;case"edited":return s;default:return t}})(),y=t.length>0||f.length>0||s.length>0,j=8,b=v=>{const S=v.target.checked;l(S),localStorage.setItem("workspace_groupByType",S.toString())},w=r?X(u,i==="owned"?a:i==="edited"?d:{}):null;return e.jsx(C,{title:"My Nodes",actionLink:`/?ownedBy=${p}`,loading:h,cardStyle:{padding:"0.25rem 0.75rem"},emptyState:e.jsxs("div",{style:{padding:"0.75rem 0"},children:[e.jsx("p",{style:{fontSize:"12px",color:"#666",marginBottom:"0.75rem"},children:"No nodes yet."}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[e.jsxs("div",{style:{flex:1,padding:"0.75rem",backgroundColor:"var(--card-bg, #f8f9fa)",border:"1px dashed var(--border-color, #dee2e6)",borderRadius:"6px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"16px",marginBottom:"0.25rem"},children:"➕"}),e.jsx("div",{style:{fontSize:"11px",fontWeight:"500",marginBottom:"0.25rem"},children:"Create a node"}),e.jsx("p",{style:{fontSize:"10px",color:"#666",marginBottom:"0.5rem"},children:"Build your data model"}),e.jsx(D.Link,{to:"/create/source",style:{display:"inline-block",padding:"3px 8px",fontSize:"10px",backgroundColor:"var(--primary-color, #4a90d9)",color:"#fff",borderRadius:"4px",textDecoration:"none"},children:"Create →"})]}),e.jsxs("div",{style:{flex:1,padding:"0.75rem",backgroundColor:"var(--card-bg, #f8f9fa)",border:"1px dashed var(--border-color, #dee2e6)",borderRadius:"6px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"16px",marginBottom:"0.25rem"},children:"👤"}),e.jsx("div",{style:{fontSize:"11px",fontWeight:"500",marginBottom:"0.25rem"},children:"Claim ownership"}),e.jsx("p",{style:{fontSize:"10px",color:"#666",marginBottom:"0.5rem"},children:"Add yourself as owner"}),e.jsx(D.Link,{to:"/",style:{display:"inline-block",padding:"3px 8px",fontSize:"10px",backgroundColor:"#6c757d",color:"#fff",borderRadius:"4px",textDecoration:"none"},children:"Browse →"})]})]})]}),children:y&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.5rem",marginBottom:"0.5rem",paddingTop:"0.5rem",paddingBottom:u.length>0?"0.5rem":"0",borderBottom:u.length>0?"1px solid var(--border-color, #eee)":"none"},children:[e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsx("button",{onClick:()=>n("owned"),style:{padding:"4px 10px",fontSize:"11px",border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:i==="owned"?"var(--primary-color, #4a90d9)":"#e9ecef",color:i==="owned"?"#fff":"#495057"},children:"Owned"}),e.jsxs("button",{onClick:()=>n("watched"),style:{padding:"4px 10px",fontSize:"11px",border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:i==="watched"?"var(--primary-color, #4a90d9)":"#e9ecef",color:i==="watched"?"#fff":"#495057"},children:["Watched (",f.length,")"]}),e.jsx("button",{onClick:()=>n("edited"),style:{padding:"4px 10px",fontSize:"11px",border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:i==="edited"?"var(--primary-color, #4a90d9)":"#e9ecef",color:i==="edited"?"#fff":"#495057"},children:"Recent Edits"})]}),u.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("input",{type:"checkbox",id:"groupByType",checked:r,onChange:b,style:{cursor:"pointer"}}),e.jsx("label",{htmlFor:"groupByType",style:{fontSize:"11px",cursor:"pointer",userSelect:"none",color:"#495057",fontWeight:"500"},children:"Group by Type"})]})]}),u.length>0?e.jsx(e.Fragment,{children:r?e.jsx(K,{groupedData:w,username:p,activeTab:i}):e.jsxs(e.Fragment,{children:[e.jsx(U,{nodes:u.slice(0,j),showUpdatedAt:!0}),u.length>j&&e.jsxs("div",{style:{textAlign:"center",padding:"0.5rem",fontSize:"12px",color:"#666"},children:["+",u.length-j," more"]})]})}):e.jsxs("div",{style:{padding:"1rem",textAlign:"center",color:"#666",fontSize:"12px"},children:[i==="owned"&&"No owned nodes",i==="watched"&&"No watched nodes",i==="edited"&&"No recent edits"]})]})})}function ee({nodes:t,loading:a}){const c=(t||[]).slice().sort((i,n)=>{var l,o,f,x;const m=(o=(l=i.current)==null?void 0:l.availability)==null?void 0:o.validThroughTs,r=(x=(f=n.current)==null?void 0:f.availability)==null?void 0:x.validThroughTs;return!m&&!r?0:m?r?r-m:-1:1}),s=i=>{if(!i)return{icon:"⏳",text:"Pending",color:"#6c757d"};const n=i.validThroughTs?new Date(i.validThroughTs):null,r=n?(new Date-n)/(1e3*60*60):null;return n?r<=24?{icon:"🟢",text:d(n),color:"#28a745"}:r<=72?{icon:"🟡",text:d(n),color:"#ffc107"}:{icon:"🔴",text:d(n),color:"#dc3545"}:{icon:"⏳",text:"Pending",color:"#6c757d"}},d=i=>{const m=new Date-i,r=Math.floor(m/(1e3*60*60)),l=Math.floor(r/24);return r<1?"just now":r<24?`${r}h ago`:l===1?"yesterday":`${l}d ago`},p=5,h=c.slice(0,p).map(i=>{var m,r,l,o,f;const n=s((m=i.current)==null?void 0:m.availability);return e.jsxs("div",{style:{padding:"0.5rem",border:"1px solid var(--border-color, #e0e0e0)",borderRadius:"4px",backgroundColor:"var(--card-bg, #fff)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[e.jsx(P,{node:i,size:"medium"}),e.jsxs("span",{style:{fontSize:"10px",color:n.color},children:[n.icon," ",n.text]})]}),e.jsxs("div",{style:{fontSize:"10px",color:"#666"},children:[(l=(r=i.current)==null?void 0:r.materializations)==null?void 0:l.map(x=>e.jsxs("span",{style:{marginRight:"8px"},children:["🕐 ",x.schedule||"No schedule"]},x.name)),((f=(o=i.current)==null?void 0:o.availability)==null?void 0:f.table)&&e.jsxs("span",{style:{color:"#888"},children:["→ ",i.current.availability.table]})]})]},i.name)});return e.jsx(C,{title:"Materializations",actionLink:"/?hasMaterialization=true",loading:a,cardStyle:{padding:"0.75rem 1rem",maxHeight:"300px",overflowY:"auto"},emptyState:e.jsxs("div",{style:{padding:"0"},children:[e.jsx("p",{style:{fontSize:"12px",color:"#666",marginBottom:"0.75rem"},children:"No materializations configured."}),e.jsxs("div",{style:{padding:"0.75rem",backgroundColor:"var(--card-bg, #f8f9fa)",border:"1px dashed var(--border-color, #dee2e6)",borderRadius:"6px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"16px",marginBottom:"0.25rem"},children:"📦"}),e.jsx("div",{style:{fontSize:"11px",fontWeight:"500",marginBottom:"0.25rem"},children:"Materialize a node"}),e.jsx("p",{style:{fontSize:"10px",color:"#666",marginBottom:"0.5rem"},children:"Speed up queries with cached data"}),e.jsx(D.Link,{to:"/",style:{display:"inline-block",padding:"3px 8px",fontSize:"10px",backgroundColor:"var(--primary-color, #4a90d9)",color:"#fff",borderRadius:"4px",textDecoration:"none"},children:"Browse nodes →"})]})]}),children:c.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[h,c.length>p&&e.jsxs("div",{style:{textAlign:"center",padding:"0.5rem",fontSize:"12px",color:"#666"},children:["+",c.length-p," more"]})]})})}function te({ownedNodes:t,recentlyEdited:a,loading:c}){const s=[...t,...a],d=new Map;s.forEach(n=>{var m,r;if(n.gitInfo&&n.gitInfo.repo){const l=n.name.split(".").slice(0,-1).join(".");let o;if(n.gitInfo.parentNamespace)o=n.gitInfo.parentNamespace;else{const u=l.lastIndexOf(".");o=u>0?l.slice(0,u):l}d.has(o)||d.set(o,{baseNamespace:o,repo:n.gitInfo.repo,defaultBranch:n.gitInfo.defaultBranch,branches:new Map});const f=d.get(o),x=n.gitInfo.branch;f.branches.has(x)||f.branches.set(x,{branch:n.gitInfo.branch,isDefault:n.gitInfo.isDefaultBranch,namespace:l,nodes:[],lastActivity:(m=n.current)==null?void 0:m.updatedAt});const g=f.branches.get(x);g.nodes.push(n),(r=n.current)!=null&&r.updatedAt&&(!g.lastActivity||n.current.updatedAt>g.lastActivity)&&(g.lastActivity=n.current.updatedAt)}}),d.forEach(n=>{n.defaultBranch&&!n.branches.has(n.defaultBranch)&&n.branches.set(n.defaultBranch,{branch:n.defaultBranch,isDefault:!0,namespace:`${n.baseNamespace}.${n.defaultBranch}`,nodes:[],lastActivity:null})});const p=Array.from(d.values()).map(n=>({...n,branches:Array.from(n.branches.values()).sort((m,r)=>m.isDefault&&!r.isDefault?-1:!m.isDefault&&r.isDefault?1:!m.lastActivity&&!r.lastActivity?0:m.lastActivity?r.lastActivity?new Date(r.lastActivity)-new Date(m.lastActivity):-1:1)})).sort((n,m)=>{const r=Math.max(...n.branches.map(o=>o.lastActivity?new Date(o.lastActivity).getTime():0));return Math.max(...m.branches.map(o=>o.lastActivity?new Date(o.lastActivity).getTime():0))-r}),h=3,i=p.slice(0,h).map((n,m)=>{const r=m===p.slice(0,h).length-1;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"0.75rem 0 0.5rem 0",marginTop:"0"},children:[e.jsx("a",{href:`/namespaces/${n.baseNamespace}`,style:{fontSize:"12px",fontWeight:"600",textDecoration:"none"},children:n.baseNamespace}),e.jsx("span",{style:{fontSize:"9px",padding:"2px 6px",backgroundColor:"#f0f0f0",color:"#666",borderRadius:"3px",fontWeight:"500"},children:n.repo})]}),n.branches.map(l=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0px 1em 0.4em 1em"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",minWidth:0,flex:1},children:[e.jsx("a",{href:`/namespaces/${l.namespace}`,style:{fontSize:"12px",fontWeight:"500",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.branch}),l.isDefault&&e.jsx("span",{style:{fontSize:"10px"},children:"⭐"})]}),l.lastActivity&&e.jsxs("span",{style:{fontSize:"10px",color:"#888",whiteSpace:"nowrap"},children:["updated ",A.formatRelativeTime(l.lastActivity)]})]},l.branch)),!r&&e.jsx("div",{style:{borderBottom:"1px solid var(--border-color, #ddd)",margin:"0.5rem 0"}})]},n.baseNamespace)});return e.jsx(C,{title:"Git Namespaces",loading:c,cardStyle:{padding:"0.25rem 0.25rem 0.5em 0.75rem",maxHeight:"300px",overflowY:"auto"},emptyState:e.jsxs("div",{style:{padding:"0",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:"12px",color:"#666",marginBottom:"0.75rem"},children:"No git-managed namespaces."}),e.jsxs("div",{style:{padding:"0.75rem",backgroundColor:"var(--card-bg, #f8f9fa)",border:"1px dashed var(--border-color, #dee2e6)",borderRadius:"6px"},children:[e.jsx("div",{style:{fontSize:"16px",marginBottom:"0.25rem"},children:"🌿"}),e.jsx("div",{style:{fontSize:"11px",fontWeight:"500",marginBottom:"0.25rem"},children:"Set up git-backed namespaces"}),e.jsx("p",{style:{fontSize:"10px",color:"#666",marginBottom:"0"},children:"Manage your nodes with version control"})]})]}),children:p.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[i,p.length>h&&e.jsxs("div",{style:{textAlign:"center",padding:"0.5rem",fontSize:"12px",color:"#666"},children:["+",p.length-h," more git namespace",p.length-h!==1?"s":""]})]})})}function ne(){var k;const{currentUser:t,loading:a}=A.useCurrentUser(),{data:c,loadingStates:s}=O(t==null?void 0:t.username),{ownedNodes:d=[],ownedHasMore:p={},recentlyEdited:h=[],editedHasMore:i={},watchedNodes:n=[],notifications:m=[],materializedNodes:r=[],needsAttention:{nodesMissingDescription:l=[],invalidNodes:o=[],staleDrafts:f=[],orphanedDimensions:x=[]}={},hasPersonalNamespace:g=null}=c,u=s.myNodes,y=s.notifications,j=s.materializations,b=s.needsAttention,N=s.namespace,w=r.filter(R=>{var W,I;const T=(I=(W=R.current)==null?void 0:W.availability)==null?void 0:I.validThroughTs;return T?(Date.now()-T)/(1e3*60*60)>72:!1}),S=`users.${((k=t==null?void 0:t.username)==null?void 0:k.split("@")[0])||""}`;return a?e.jsxs("div",{className:"settings-page",style:{padding:"1.5rem 2rem"},children:[e.jsx("h1",{className:"settings-title",children:"Dashboard"}),e.jsx("div",{style:{textAlign:"center",padding:"3rem"},children:e.jsx(A.LoadingIcon,{})})]}):e.jsx("div",{className:"settings-page",style:{padding:"1.5rem 2rem"},children:e.jsxs("div",{className:"workspace-layout",children:[e.jsx("div",{className:"workspace-left-column",children:e.jsx(Z,{ownedNodes:d,ownedHasMore:p,watchedNodes:n,recentlyEdited:h,editedHasMore:i,username:t==null?void 0:t.username,loading:u})}),e.jsxs("div",{className:"workspace-right-column",children:[e.jsx(q,{nodesMissingDescription:l,invalidNodes:o,staleDrafts:f,staleMaterializations:w,orphanedDimensions:x,username:t==null?void 0:t.username,loading:b||j,personalNamespace:S,hasPersonalNamespace:g,namespaceLoading:N}),e.jsx(G,{notifications:m,username:t==null?void 0:t.username,loading:y}),e.jsx(te,{ownedNodes:d,recentlyEdited:h,loading:u}),e.jsx(ee,{nodes:r,loading:j})]})]})})}exports.MyWorkspacePage=ne; //# sourceMappingURL=index-ByFlwzpD.cjs.map