Files
owncast/static/admin/_next/static/chunks/pages/actions-06962496c7d339c5.js

1 line
9.4 KiB
JavaScript
Vendored

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[807],{48689:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var r=n(1413),o=n(67294),a={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"}}]},name:"delete",theme:"outlined"},i=n(42135),c=function(e,t){return o.createElement(i.Z,(0,r.Z)((0,r.Z)({},e),{},{ref:t,icon:a}))};c.displayName="DeleteOutlined";var l=o.forwardRef(c)},98082:function(e,t,n){"use strict";var r=n(97685),o=n(67294),a=n(31808);t.Z=function(){var e=o.useState(!1),t=(0,r.Z)(e,2),n=t[0],i=t[1];return o.useEffect((function(){i((0,a.fk)())}),[]),n}},26713:function(e,t,n){"use strict";n.d(t,{u:function(){return h},Z:function(){return x}});var r=n(87462),o=n(4942),a=n(97685),i=n(67294),c=n(94184),l=n.n(c),u=n(50344),s=n(59844);function d(e){var t=e.className,n=e.direction,a=e.index,c=e.marginDirection,l=e.children,u=e.split,s=e.wrap,d=i.useContext(h),p=d.horizontalSize,f=d.verticalSize,v=d.latestIndex,x={};return d.supportFlexGap||("vertical"===n?a<v&&(x={marginBottom:p/(u?2:1)}):x=(0,r.Z)((0,r.Z)({},a<v&&(0,o.Z)({},c,p/(u?2:1))),s&&{paddingBottom:f})),null===l||void 0===l?null:i.createElement(i.Fragment,null,i.createElement("div",{className:t,style:x},l),a<v&&u&&i.createElement("span",{className:"".concat(t,"-split"),style:x},u))}var p=n(98082),f=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},h=i.createContext({latestIndex:0,horizontalSize:0,verticalSize:0,supportFlexGap:!1}),v={small:8,middle:16,large:24};var x=function(e){var t,n=i.useContext(s.E_),c=n.getPrefixCls,x=n.space,m=n.direction,y=e.size,g=void 0===y?(null===x||void 0===x?void 0:x.size)||"small":y,w=e.align,j=e.className,k=e.children,Z=e.direction,b=void 0===Z?"horizontal":Z,C=e.prefixCls,S=e.split,E=e.style,O=e.wrap,z=void 0!==O&&O,I=f(e,["size","align","className","children","direction","prefixCls","split","style","wrap"]),N=(0,p.Z)(),_=i.useMemo((function(){return(Array.isArray(g)?g:[g,g]).map((function(e){return function(e){return"string"===typeof e?v[e]:e||0}(e)}))}),[g]),T=(0,a.Z)(_,2),A=T[0],P=T[1],R=(0,u.Z)(k,{keepEmpty:!0}),U=void 0===w&&"horizontal"===b?"center":w,B=c("space",C),F=l()(B,"".concat(B,"-").concat(b),(t={},(0,o.Z)(t,"".concat(B,"-rtl"),"rtl"===m),(0,o.Z)(t,"".concat(B,"-align-").concat(U),U),t),j),G="".concat(B,"-item"),H="rtl"===m?"marginLeft":"marginRight",L=0,q=R.map((function(e,t){return null!==e&&void 0!==e&&(L=t),i.createElement(d,{className:G,key:"".concat(G,"-").concat(t),direction:b,index:t,marginDirection:H,split:S,wrap:z},e)})),D=i.useMemo((function(){return{horizontalSize:A,verticalSize:P,latestIndex:L,supportFlexGap:N}}),[A,P,L,N]);if(0===R.length)return null;var M={};return z&&(M.flexWrap="wrap",N||(M.marginBottom=-P)),N&&(M.columnGap=A,M.rowGap=P),i.createElement("div",(0,r.Z)({className:F,style:(0,r.Z)((0,r.Z)({},M),E)},I),i.createElement(h.Provider,{value:D},q))}},75056:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/actions",function(){return n(16293)}])},16293:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return E}});var r=n(28520),o=n.n(r),a=n(85893),i=n(48689),c=n(17256),l=n(56516),u=n(69677),s=n(32808),d=n(26713),p=n(71577),f=n(49919),h=n(67294),v=n(78464),x=n(25964),m=n(83200),y=n(35159),g=n(19411);function w(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(u){return void n(u)}c.done?t(l):Promise.resolve(l).then(r,o)}function j(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){w(a,r,o,i,c,"next",e)}function c(e){w(a,r,o,i,c,"throw",e)}i(void 0)}))}}function k(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var Z=c.Z.Title,b=c.Z.Paragraph,C=null;function S(e){var t=e.onOk,n=e.onCancel,r=e.visible,o=(0,h.useState)(""),i=o[0],c=o[1],d=(0,h.useState)(""),p=d[0],f=d[1],v=(0,h.useState)(""),x=v[0],m=v[1],y=(0,h.useState)(""),w=y[0],j=y[1],k=(0,h.useState)(""),Z=k[0],b=k[1],C=(0,h.useState)(!1),S=C[0],E=C[1],O={disabled:!function(){try{if("https:"!==new URL(i).protocol)return!1}catch(e){return!1}return(0,g.Z)(i)&&""!==p}()};return(0,a.jsx)(l.Z,{title:"Create New Action",visible:r,onOk:function(){t(i,p,x,w,Z,S),c(""),f(""),m(""),j(""),b(""),E(!1)},onCancel:n,okButtonProps:O,children:(0,a.jsxs)("div",{children:["Add the URL for the external action you want to present."," ",(0,a.jsx)("strong",{children:"Only HTTPS urls are supported."}),(0,a.jsx)("p",{children:(0,a.jsx)("a",{href:"https://owncast.online/docs",target:"_blank",rel:"noopener noreferrer",children:"Read more about external actions."})}),(0,a.jsx)("p",{children:(0,a.jsx)(u.Z,{value:i,required:!0,placeholder:"https://myserver.com/action (required)",onChange:function(e){return c(e.currentTarget.value.trim())},type:"url",pattern:g.a})}),(0,a.jsx)("p",{children:(0,a.jsx)(u.Z,{value:p,required:!0,placeholder:"Your action title (required)",onChange:function(e){return f(e.currentTarget.value)}})}),(0,a.jsx)("p",{children:(0,a.jsx)(u.Z,{value:x,placeholder:"Optional description",onChange:function(e){return m(e.currentTarget.value)}})}),(0,a.jsx)("p",{children:(0,a.jsx)(u.Z,{value:w,placeholder:"https://myserver.com/action/icon.png (optional)",onChange:function(e){return j(e.currentTarget.value)}})}),(0,a.jsxs)("p",{children:[(0,a.jsx)(u.Z,{type:"color",value:Z,onChange:function(e){return b(e.currentTarget.value)}}),"Optional background color of the action button."]}),(0,a.jsx)(s.Z,{checked:S,defaultChecked:S,onChange:function(e){E(e.target.checked)},children:"Open in a new tab instead of within your page."})]})})}function E(){var e=(0,h.useContext)(y.aC)||{},t=e.serverConfig,n=e.setFieldInConfigState,r=t.externalActions,c=(0,h.useState)([]),l=c[0],u=c[1],s=(0,h.useState)(!1),g=s[0],w=s[1],E=(0,h.useState)(null),O=E[0],z=E[1],I=function(){z(null),C=null,clearTimeout(C)};function N(e){return _.apply(this,arguments)}function _(){return(_=j(o().mark((function e(t){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,x.Si)({apiPath:x.os,data:{value:t},onSuccess:function(){n({fieldName:"externalActions",value:t,path:""}),z((0,m.kg)(m.zv,"Updated.")),C=setTimeout(I,x.sI)},onError:function(e){console.log(e),z((0,m.kg)(m.Un,e)),C=setTimeout(I,x.sI)}});case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function T(){return(T=j(o().mark((function e(t){var n,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=k(l),r=l.findIndex((function(e){return e.url===t.url})),n.splice(r,1);try{u(n),N(n)}catch(o){console.error(o)}case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(){return(A=j(o().mark((function e(t,n,r,a,i,c){var s,d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,s=k(l),d=s.concat({url:t,title:n,description:r,icon:a,color:i,openExternally:c}),u(d),e.next=6,N(d);case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.error(e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))).apply(this,arguments)}(0,h.useEffect)((function(){u(r||[])}),[r]);var P=[{title:"",key:"delete",render:function(e,t){return(0,a.jsx)(d.Z,{size:"middle",children:(0,a.jsx)(p.Z,{onClick:function(){return function(e){return T.apply(this,arguments)}(t)},icon:(0,a.jsx)(i.Z,{})})})}},{title:"Name",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description"},{title:"URL",dataIndex:"url",key:"url"},{title:"Icon",dataIndex:"icon",key:"icon",render:function(e){return e?(0,a.jsx)("img",{style:{width:"2vw"},src:e,alt:""}):null}},{title:"Color",dataIndex:"color",key:"color",render:function(e){return e?(0,a.jsx)("div",{style:{backgroundColor:e,height:"30px"},children:e}):null}},{title:"Opens",dataIndex:"openExternally",key:"openExternally",render:function(e){return e?"In a new tab":"In a modal"}}];return(0,a.jsxs)("div",{children:[(0,a.jsx)(Z,{children:"External Actions"}),(0,a.jsx)(b,{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,a.jsxs)(b,{children:["Read more about how to use actions, with examples, at"," ",(0,a.jsx)("a",{href:"https://owncast.online/thirdparty/?source=admin",target:"_blank",rel:"noopener noreferrer",children:"our documentation"}),"."]}),(0,a.jsx)(f.Z,{rowKey:function(e){return"".concat(e.title,"-").concat(e.url)},columns:P,dataSource:l,pagination:!1}),(0,a.jsx)("br",{}),(0,a.jsx)(p.Z,{type:"primary",onClick:function(){w(!0)},children:"Create New Action"}),(0,a.jsx)(v.Z,{status:O}),(0,a.jsx)(S,{visible:g,onOk:function(e,t,n,r,o,a){w(!1),function(e,t,n,r,o,a){A.apply(this,arguments)}(e,t,n,r,o,a)},onCancel:function(){w(!1)}})]})}}},function(e){e.O(0,[919,516,774,888,179],(function(){return t=75056,e(e.s=t);var t}));var t=e.O();_N_E=t}]);