datajunction-ui
Version:
DataJunction UI
3 lines (2 loc) • 2.51 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("react"),m=require("./index-h1A5IisM.cjs"),x=(a,c)=>{const p=new Map(c.map(n=>[n.name,n]));return a.map(n=>{var r;const i=p.get(n.entity_name);return{...n,node_type:i==null?void 0:i.type,display_name:(r=i==null?void 0:i.current)==null?void 0:r.displayName}})};function u(){const a=l.useContext(m.DJClientContext).DataJunctionAPI,[c,p]=l.useState([]),[n,i]=l.useState(!0);l.useEffect(()=>{async function o(){try{const e=await a.getSubscribedHistory(50)||[],s=Array.from(new Set(e.map(f=>f.entity_name))),h=s.length?await a.getNodesByNames(s):[],d=x(e,h);p(d)}catch(e){console.error("Error fetching notifications:",e)}finally{i(!1)}}o()},[a]);const r=m.groupByDate(c);return t.jsx("div",{className:"mid",children:t.jsxs("div",{className:"card",children:[t.jsx("div",{className:"card-header",children:t.jsx("h2",{children:"Notifications"})}),t.jsx("div",{className:"card-body",children:t.jsx("div",{className:"notifications-list",children:n?t.jsx("div",{style:{padding:"2rem",textAlign:"center"},children:t.jsx(m.LoadingIcon,{})}):c.length===0?t.jsx("div",{style:{padding:"2rem 1rem",color:"#666",textAlign:"center"},children:"No notifications yet. Watch nodes to receive updates when they change."}):r.map(o=>t.jsxs("div",{className:"notification-group",children:[t.jsx("div",{style:{padding:"0.5rem 0.75rem",backgroundColor:"#f8f9fa",borderBottom:"1px solid #eee",fontSize:"12px",fontWeight:600,color:"#666",textTransform:"uppercase",letterSpacing:"0.5px"},children:o.label}),o.items.map(e=>{var d;const s=(d=e.details)==null?void 0:d.version,h=s?`/nodes/${e.entity_name}/revisions/${s}`:`/nodes/${e.entity_name}/history`;return t.jsxs("a",{className:"notification-item",href:h,children:[t.jsxs("span",{className:"notification-node",children:[t.jsxs("span",{className:"notification-title",children:[e.display_name||e.entity_name,s&&t.jsx("span",{className:"badge version",children:s})]}),e.display_name&&t.jsx("span",{className:"notification-entity",children:e.entity_name})]}),t.jsxs("span",{className:"notification-meta",children:[e.node_type&&t.jsx("span",{className:`node_type__${e.node_type} badge node_type`,children:e.node_type.toUpperCase()}),e.activity_type,"d by"," ",t.jsx("span",{style:{color:"#333"},children:e.user})," ·"," ",m.formatRelativeTime(e.created_at)]})]},e.id)})]},o.label))})})]})})}exports.NotificationsPage=u;
//# sourceMappingURL=index-jSF4FAFZ.cjs.map