Files
owncast/static/web/_next/static/chunks/1017-c26780a26480b2de.js
2022-08-16 02:47:50 +00:00

1 line
6.0 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1017],{91017:function(e,n,a){a.d(n,{Z:function(){return O}});var t=a(47568),s=a(14924),l=a(26042),i=a(69396),c=a(29815),o=a(34051),r=a.n(o),u=a(85893),d=a(67294),p=a(84485),f=a(71577),m=a(69677),h=a(10355),x=a(85402),v=a(48689),j=a(38939),N=a(58827),k=a(25964);function Z(e){var n=e.iconList,a=e.selectedOption,t=e.onSelected,s=""===a?null:a;return(0,u.jsxs)("div",{className:"social-dropdown-container",children:[(0,u.jsx)("p",{className:"description",children:"If you are looking for a platform name not on this list, please select Other and type in your own name. A logo will not be provided."}),(0,u.jsxs)("div",{className:"formfield-container",children:[(0,u.jsx)("div",{className:"label-side",children:(0,u.jsx)("span",{className:"formfield-label",children:"Social Platform"})}),(0,u.jsx)("div",{className:"input-side",children:(0,u.jsxs)(j.Z,{style:{width:240},className:"social-dropdown",placeholder:"Social platform...",defaultValue:s,value:s,onSelect:function(e){t&&t(e)},children:[n.map((function(e){var n=e.platform,a=e.icon,t=e.key,s="".concat(N.WB).concat(a.slice(1));return(0,u.jsxs)(j.Z.Option,{className:"social-option",value:t,children:[(0,u.jsx)("span",{className:"option-icon",children:(0,u.jsx)("img",{src:s,alt:"",className:"option-icon"})}),(0,u.jsx)("span",{className:"option-label",children:n})]},"platform-".concat(t))})),(0,u.jsx)(j.Z.Option,{className:"social-option",value:k.z_,children:"Other..."},"platform-".concat(k.z_))]})})]})]})}var S=a(35159),b=a(19411),y=a(13468),g=a(83192),w=a(78464),C=p.Z.Title;function O(){var e=(0,d.useState)([]),n=e[0],a=e[1],o=(0,d.useState)([]),p=o[0],j=o[1],O=(0,d.useState)(!1),z=O[0],_=O[1],E=(0,d.useState)(!1),I=E[0],T=E[1],H=(0,d.useState)(!1),L=H[0],P=H[1],A=(0,d.useState)(-1),B=A[0],U=A[1],D=(0,d.useState)(k.wC),V=D[0],W=D[1],F=(0,d.useState)(null),K=F[0],Q=F[1],R=(0,d.useContext)(S.aC)||{},Y=R.serverConfig,$=R.setFieldInConfigState,q=Y.instanceDetails,G=q.socialHandles,J=null,M=function(){var e=(0,t.Z)(r().mark((function e(){var n,t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,N.rQ)(N.$i,{auth:!1});case 3:n=e.sent,t=Object.keys(n).map((function(e){return(0,l.Z)({key:e},n[e])})),a(t),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.log(e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}(),X=function(e){return n.find((function(n){return n.key===e}))||!1},ee=""!==V.platform&&!n.find((function(e){return e.key===V.platform}));(0,d.useEffect)((function(){M()}),[]),(0,d.useEffect)((function(){q.socialHandles&&j(G)}),[q]);var ne=function(){Q(null),J=null,clearTimeout(J)},ae=function(){_(!1),U(-1),T(!1),P(!1),W((0,l.Z)({},k.wC))},te=function(){ae()},se=function(e,n){W((0,i.Z)((0,l.Z)({},V),(0,s.Z)({},e,n)))},le=function(){var e=(0,t.Z)(r().mark((function e(n){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,k.Si)({apiPath:k.c9,data:{value:n},onSuccess:function(){$({fieldName:"socialHandles",value:n,path:"instanceDetails"}),P(!1),te(),Q((0,g.kg)(g.zv)),J=setTimeout(ne,k.sI)},onError:function(e){Q((0,g.kg)(g.Un,"There was an error: ".concat(e))),P(!1),J=setTimeout(ne,k.sI)}});case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),ie=[{title:"Social Link",dataIndex:"",key:"combo",render:function(e,n){var a=n.platform,t=n.url,s=X(a);if(!s)return(0,u.jsx)("div",{className:"social-handle-cell",children:(0,u.jsxs)("p",{className:"option-label",children:[(0,u.jsx)("strong",{children:a}),(0,u.jsx)("span",{className:"handle-url",title:t,children:t})]})});var l=s.icon,i=s.platform,c="".concat(N.WB).concat(l.slice(1));return(0,u.jsxs)("div",{className:"social-handle-cell",children:[(0,u.jsx)("span",{className:"option-icon",children:(0,u.jsx)("img",{src:c,alt:"",className:"option-icon"})}),(0,u.jsxs)("p",{className:"option-label",children:[(0,u.jsx)("strong",{children:i}),(0,u.jsx)("span",{className:"handle-url",title:t,children:t})]})]})}},{title:"",dataIndex:"",key:"edit",render:function(e,n,a){return(0,u.jsxs)("div",{className:"actions",children:[(0,u.jsx)(f.Z,{size:"small",onClick:function(){var e=p[a];U(a),W((0,l.Z)({},e)),_(!0),X(e.platform)||T(!0)},children:"Edit"}),(0,u.jsx)(f.Z,{className:"delete-button",icon:(0,u.jsx)(v.Z,{}),size:"small",onClick:function(){return function(e){var n=(0,c.Z)(p);n.splice(e,1),le(n)}(a)}})]})}}],ce={disabled:!(0,b.Z)(V.url)},oe=(0,u.jsxs)("div",{className:"other-field-container formfield-container",children:[(0,u.jsx)("div",{className:"label-side"}),(0,u.jsx)("div",{className:"input-side",children:(0,u.jsx)(m.Z,{placeholder:"Other platform name",defaultValue:V.platform,onChange:function(e){var n=e.target.value;se("platform",n)}})})]});return(0,u.jsxs)("div",{className:"social-links-edit-container",children:[(0,u.jsx)(C,{level:3,className:"section-title",children:"Your Social Handles"}),(0,u.jsx)("p",{className:"description",children:"Add all your social media handles and links to your other profiles here."}),(0,u.jsx)(w.Z,{status:K}),(0,u.jsx)(h.Z,{className:"social-handles-table",pagination:!1,size:"small",rowKey:function(e){return"".concat(e.platform,"-").concat(e.url)},columns:ie,dataSource:p}),(0,u.jsx)(x.Z,{title:"Edit Social Handle",visible:z,onOk:function(){P(!0);var e=p.length?(0,c.Z)(p):[];-1===B?e.push(V):e.splice(B,1,V),le(e)},onCancel:te,confirmLoading:L,okButtonProps:ce,children:(0,u.jsxs)("div",{className:"social-handle-modal-content",children:[(0,u.jsx)(Z,{iconList:n,selectedOption:ee?k.z_:V.platform,onSelected:function(e){e===k.z_?(T(!0),se("platform","")):(T(!1),se("platform",e))}}),I&&oe,(0,u.jsx)("br",{}),(0,u.jsx)(y.ZP,{fieldName:"social-url",label:"URL",placeholder:{mastodon:"https://mastodon.social/@username",twitter:"https://twitter.com/username"}[V.platform]||"Url to page",value:V.url,onChange:function(e){var n=e.value;se("url",n)},useTrim:!0,type:"url",pattern:b.a}),(0,u.jsx)(w.Z,{status:K})]})}),(0,u.jsx)("br",{}),(0,u.jsx)(f.Z,{type:"primary",onClick:function(){ae(),_(!0)},children:"Add a new social link"})]})}}}]);