PageSourceSearch

https://app.memberstack.com/assets/Channels-DhtWqBEx.js

js memberstack.com collected 2026-09-24 17:17:36 UTC 4,979 bytes, 8 lines download raw bytes

1import{j as s,r as m,k as I}from"./vendor-CSdFbWfl.js";import{p as S,G as T,b5 as E,k as v,j,b as A}from"./index-BynWLX9U.js";import{b as M}from"./queries.generated-B6xYtEQO.js";import{D as P}from"./Drawer-C_f0ozxy.js";import{e as B,f as R,g as H,c as O}from"./Community.states-C_HfKy-s.js";import{A as U}from"./Add-D0Px--54.js";import"./empty-comments-BTgLxVsw.js";import"./EmptyState-CHnwuhTZ.js";import"./SuspenseWrapper-BqV6m5Z2.js";import"./PlayCircleOutlined-B5BuOKZn.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"5fdab7154cbea903e2531547e54739370b469773"};var u=new a.Error().stack;u&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[u]="4210aff0-a697-4095-a9b2-2e5e60317246",a._sentryDebugIdIdentifier="sentry-dbid-4210aff0-a697-4095-a9b2-2e5e60317246")}catch{}})();const $=S(s.jsx("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2"}),"ChatBubble"),G=({isPaneOpen:a,closePane:u,mode:o,channelDetails:t})=>{const[e,f]=m.useState({name:(t==null?void 0:t.name)??"",key:(t==null?void 0:t.key)??""}),[n,g]=m.useState(o??"update"),{createToastAlert:d}=T(),l=n==="create"?"Add a New Channel":`Edit ${e==null?void 0:e.name}`,b=n==="create"?"Create Channel":"Save",[c,{loading:p}]=B({update:(r,{data:i})=>{if(i!=null&&i.updateChannel){const C=i.updateChannel;r.modify({id:r.identify({id:C.id,__typename:"Channel"}),fields:{name:()=>C.name,key:()=>C.key}})}},onCompleted:()=>{d({alertType:"success",message:"Channel was successfully updated."})},onError:r=>{console.error(r),d({alertType:"error",message:"Unable to update channel."})}}),[x,{loading:y}]=R({update:(r,{data:i})=>{if(i!=null&&i.createChannel){const C=i.createChannel;r.modify({fields:{getChannels(k=[]){const N=r.writeFragment({data:C,fragment:I`
2                  fragment NewChannel on Channel {
3                    id
4                    name
5                    key
6                    activityCount
7                  }
8                `});return[...k,N]}}})}},onCompleted:({createChannel:r})=>{g("update"),f(r),d({alertType:"success",message:"Channel was successfully created."})},onError:r=>{console.error(r),d({alertType:"error",message:"Unable to create channel."})}}),h=async()=>{d({alertType:"processing"}),n==="create"?await x({variables:{input:{name:(e==null?void 0:e.name)||""}}}):await c({variables:{input:{channelId:(t==null?void 0:t.id)??"",name:(e==null?void 0:e.name)??"",key:(e==null?void 0:e.key)??""}}})},w=m.useMemo(()=>n==="create"?!(e!=null&&e.name):!(e!=null&&e.name)||!(e!=null&&e.key)||t&&(e==null?void 0:e.name)===t.name&&(e==null?void 0:e.key)===t.key,[e,t,n]);return s.jsxs(P,{isOpen:a||!1,children:[s.jsxs("div",{className:"flex p-5 border-b border-border items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(E,{className:"hover:bg-muted rounded p-0.5 cursor-pointer",onClick:u}),s.jsx("h4",{className:"text-base",children:l})]}),s.jsx(v,{disabled:w,onClick:h,children:b})]}),s.jsxs("div",{className:"p-5 flex flex-col gap-4 h-full",children:[s.jsx(j,{id:"name",name:"name",label:"Name",disabled:p||y,value:e==null?void 0:e.name,onChange:({target:{value:r}})=>f({...e,name:r}),hideIndicators:!0}),n==="update"&&s.jsx(j,{id:"channelId",name:"channelId",label:"Channel ID or Page Slug",disabled:p||y,value:e==null?void 0:e.key,onChange:({target:{value:r}})=>f({...e,key:r}),hideIndicators:!0})]})]})},X=()=>{const[a,u]=m.useState("create"),[o,t]=m.useState(void 0),{loading:e,error:f,data:n}=M(),[g,d]=m.useState(!1);if(e&&!n)return s.jsx(H,{title:"Channels"});if(f)return s.jsx("div",{children:"Error..."});const l=n==null?void 0:n.getChannels;return(l==null?void 0:l.length)===0?s.jsx(O,{description:"Channels are groups of comments, each page will have a separate channel. These will appear automatically as comments are added."}):s.jsxs("div",{className:"flex w-full h-full overflow-hidden",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex p-5 border-b border-border items-center justify-between",children:[s.jsx("h4",{className:"text-base",children:"Channels"}),s.jsxs(v,{onClick:()=>{u("create"),t(void 0),d(!0)},children:[s.jsx(U,{})," Add Channel"]})]}),s.jsx("div",{className:"p-5 overflow-auto flex flex-col gap-2 h-full",children:l==null?void 0:l.map(b=>{if(!b)return null;const{id:c,name:p,activityCount:x,key:y}=b;return s.jsxs(A,{hideBorder:!1,hasHoverState:!0,hideShadow:!1,onClick:()=>{u("update"),t({id:c,name:p,key:y,activityCount:x}),d(h=>!(h&&(o==null?void 0:o.id)===c))},className:"p-3 flex items-center justify-between text-base",children:[s.jsx("p",{children:p}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx($,{className:"w-3! h-3!"})," ",s.jsx("p",{children:x})]})]},c)})})]}),s.jsx(G,{channelDetails:o,closePane:()=>d(!1),isPaneOpen:g,mode:a},`${a}-${(o==null?void 0:o.id)??"new"}`)]})};export{X as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.