Files
owncast/static/web/_next/static/chunks/pages/admin/actions-f8776e365aabcc95.js
T
2023-03-04 17:19:39 +00:00

1 line
6.8 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5685],{57838:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(97685),l=n(67294);function a(){var e=l.useReducer(function(e){return e+1},0);return(0,r.Z)(e,2)[1]}},25378:function(e,t,n){"use strict";var r=n(67294),l=n(57838),a=n(24308);t.Z=function(){var e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(0,r.useRef)({}),n=(0,l.Z)();return(0,r.useEffect)(function(){var r=a.ZP.subscribe(function(r){t.current=r,e&&n()});return function(){return a.ZP.unsubscribe(r)}},[]),t.current}},97183:function(e,t,n){"use strict";var r=n(2897),l=n(7293),a=r.ZP;a.Header=r.h4,a.Footer=r.$_,a.Content=r.VY,a.Sider=l.Z,t.Z=a},54005:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/actions",function(){return n(4437)}])},4437:function(e,t,n){"use strict";n.r(t);var r=n(85893),l=n(85818),a=n(85402),o=n(79292),i=n(34041),s=n(79531),c=n(32808),u=n(26713),d=n(71577),h=n(54398),p=n(87685),x=n(58909),m=n(13804),v=n(5152),f=n.n(v),j=n(67294),y=n(96412),g=n(25964),Z=n(83192),b=n(35159),k=n(19411),w=n(63921);let{Title:C,Paragraph:I}=l.Z,S=f()(()=>Promise.all([n.e(2074),n.e(7949)]).then(n.t.bind(n,77949,23)),{loadableGenerated:{webpack:()=>[77949]},ssr:!1}),E=f()(()=>Promise.all([n.e(2074),n.e(775)]).then(n.t.bind(n,10775,23)),{loadableGenerated:{webpack:()=>[10775]},ssr:!1}),T=e=>{let{onOk:t,onCancel:n,open:l,action:u}=e,[d,h]=(0,j.useState)("url"),[v,f]=(0,j.useState)(""),[y,g]=(0,j.useState)(""),[Z,b]=(0,j.useState)(""),[w,C]=(0,j.useState)(""),[I,S]=(0,j.useState)(""),[E,T]=(0,j.useState)(""),[_,O]=(0,j.useState)(!1);(0,j.useEffect)(()=>{var e;h(((null==u?void 0:null===(e=u.html)||void 0===e?void 0:e.length)||0)>0?"html":"url"),f((null==u?void 0:u.url)||""),g((null==u?void 0:u.html)||""),b((null==u?void 0:u.title)||""),C((null==u?void 0:u.description)||""),S((null==u?void 0:u.icon)||""),T((null==u?void 0:u.color)||""),O((null==u?void 0:u.openExternally)||!1)},[u]);let P={disabled:!("html"===d?""!==y&&""!==Z:(0,k.jv)(v,["https:"])&&""!==Z)},L=e=>{O(e.target.checked)},N=e=>{g(e)};return(0,r.jsx)(a.Z,{destroyOnClose:!0,title:null==u?"Create New Action":"Edit Action",open:l,onOk:function(){t(u,e.index,"html"===d?"":v,"html"===d?y:"",Z,w,I,E,_),f(""),g(""),b(""),C(""),S(""),T(""),O(!1)},onCancel:n,okButtonProps:P,children:(0,r.jsxs)(o.Z,{initialValues:u,children:["Add the URL for the external action you want to present."," ",(0,r.jsx)("strong",{children:"Only HTTPS URLs and embeds are supported."}),(0,r.jsx)("p",{children:(0,r.jsx)("a",{href:"https://owncast.online/thirdparty/actions/",target:"_blank",rel:"noopener noreferrer",children:"Read more about external actions."})}),(0,r.jsx)(o.Z.Item,{children:(0,r.jsx)(i.Z,{value:d,onChange:h,placeholder:"Select an action type",options:[{label:"Link or embed an URL",value:"url"},{label:"Custom HTML",value:"html"}]})}),"html"===d?(0,r.jsx)(o.Z.Item,{name:"html",children:(0,r.jsx)(p.ZP,{value:y,placeholder:"HTML embed code (required)",theme:x.FZ,height:"200px",extensions:[(0,m.html)()],onChange:N})}):(0,r.jsx)(o.Z.Item,{name:"url",children:(0,r.jsx)(s.Z,{required:!0,placeholder:"https://myserver.com/action (required)",onChange:e=>f(e.currentTarget.value.trim()),type:"url",pattern:k.ax})}),(0,r.jsx)(o.Z.Item,{name:"title",children:(0,r.jsx)(s.Z,{value:Z,required:!0,placeholder:"Your action title (required)",onChange:e=>b(e.currentTarget.value)})}),(0,r.jsx)(o.Z.Item,{name:"description",children:(0,r.jsx)(s.Z,{value:w,placeholder:"Optional description",onChange:e=>C(e.currentTarget.value)})}),(0,r.jsx)(o.Z.Item,{name:"icon",children:(0,r.jsx)(s.Z,{value:I,placeholder:"https://myserver.com/action/icon.png (optional)",onChange:e=>S(e.currentTarget.value)})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(o.Z.Item,{name:"color",style:{marginBottom:"0px"},children:(0,r.jsx)(s.Z,{type:"color",value:E,onChange:e=>T(e.currentTarget.value)})}),"Optional background color of the action button."]}),"html"===d?null:(0,r.jsx)(o.Z.Item,{name:"openExternally",children:(0,r.jsx)(c.Z,{checked:_,defaultChecked:_,onChange:L,children:"Open in a new tab instead of within your page."})})]})})},_=()=>{let e=(0,j.useContext)(b.aC),{serverConfig:t,setFieldInConfigState:n}=e||{},{externalActions:l}=t,[a,o]=(0,j.useState)(null),[i,s]=(0,j.useState)(!1),[c,p]=(0,j.useState)(null),[x,m]=(0,j.useState)(null),[v,f]=(0,j.useState)(-1),k=()=>{p(null),clearTimeout(null)};async function w(e){await (0,g.Si)({apiPath:g.os,data:{value:e},onSuccess:()=>{n({fieldName:"externalActions",value:e,path:""}),p((0,Z.kg)(Z.zv,"Updated.")),setTimeout(k,g.sI)},onError:e=>{console.log(e),p((0,Z.kg)(Z.Un,e)),setTimeout(k,g.sI)}})}async function _(e,t){let n=[...a];n.splice(t,1);try{o(n),w(n)}catch(e){console.error(e)}}async function O(e,t,n,r,l,i,s,c,u){try{let e=[...a],d={url:n,html:r,title:l,description:i,icon:s,color:c,openExternally:u};t>=0?e[t]=d:e.push(d),o(e),await w(e)}catch(e){console.error(e)}}async function P(e,t){f(t),m(e),s(!0)}(0,j.useEffect)(()=>{o(l||[])},[l]);let L=()=>{m(null),f(-1),s(!0)},N=(e,t,n,r,l,a,o,i,c)=>{s(!1),O(e,t,n,r,l,a,o,i,c),m(null),f(-1)},R=()=>{s(!1)};return(0,r.jsxs)("div",{children:[(0,r.jsx)(C,{children:"External Actions"}),(0,r.jsx)(I,{children:"External action URLs are 3rd party UI you can display, embedded, into your Owncast page when a user clicks on a button to launch your action."}),(0,r.jsxs)(I,{children:["Read more about how to use actions, with examples, at"," ",(0,r.jsx)("a",{href:"https://owncast.online/thirdparty/?source=admin",target:"_blank",rel:"noopener noreferrer",children:"our documentation"}),"."]}),(0,r.jsx)(h.Z,{rowKey:e=>"".concat(e.title,"-").concat(e.url),columns:[{title:"",key:"delete-edit",render:(e,t,n)=>(0,r.jsxs)(u.Z,{size:"middle",children:[(0,r.jsx)(d.Z,{onClick:()=>_(t,n),icon:(0,r.jsx)(S,{})}),(0,r.jsx)(d.Z,{onClick:()=>P(t,n),icon:(0,r.jsx)(E,{})})]})},{title:"Name",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description"},{title:"URL / Embed",key:"url",dataIndex:"url",render:(e,t)=>t.html?"HTML embed":t.url},{title:"Icon",dataIndex:"icon",key:"icon",render:e=>e?(0,r.jsx)("img",{style:{width:"2vw"},src:e,alt:""}):null},{title:"Color",dataIndex:"color",key:"color",render:e=>e?(0,r.jsx)("div",{style:{backgroundColor:e,height:"30px"},children:e}):null},{title:"Opens",key:"openExternally",dataIndex:"openExternally",render:(e,t)=>!e||t.html?"In the same tab":"In a new tab"}],dataSource:a,pagination:!1}),(0,r.jsx)("br",{}),(0,r.jsx)(d.Z,{type:"primary",onClick:L,children:"Create New Action"}),(0,r.jsx)(y.E,{status:c}),(0,r.jsx)(T,{action:x,index:v,open:i,onOk:N,onCancel:R})]})};_.getLayout=function(e){return(0,r.jsx)(w.l,{page:e})},t.default=_},9008:function(e,t,n){e.exports=n(5443)}},function(e){e.O(0,[5762,173,164,2744,9680,4931,5402,2231,5818,492,7524,9915,4041,3698,3013,4398,9292,7055,4924,3921,9774,2888,179],function(){return e(e.s=54005)}),_N_E=e.O()}]);