Skip to content

Instantly share code, notes, and snippets.

@guidone
Last active June 3, 2020 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guidone/bd2d4fec49198961e946ce42c5d373ba to your computer and use it in GitHub Desktop.
Save guidone/bd2d4fec49198961e946ce42c5d373ba to your computer and use it in GitHub Desktop.
define(["../../../src/components","../../src/components","code-plug","lodash","prop-types","react","rsuite"],(e,t,o,n,a,r,l)=>(()=>{"use strict";var m={499:(e,t,o)=>{o.r(t),o.d(t,{default:()=>S});var n=o(297),a=o.n(n),r=o(399),l=o(186),m=o(222),s=o(738),c=o(804),i=o.n(c);const{StringType:u,ArrayType:d,ObjectType:p,DateType:g}=m.Schema.Types,f=m.Schema.Model({commands:d().of(p().shape({command:u().isRequired("Specify the command").addRule(e=>e.startsWith("/"),'Command should start with "/"'),slug:u().isRequired("Specifig a slug (shortcut) for a content")})).addRule(e=>{const t=e.map(e=>e.command);return i().uniq(t).length===t.length},"Some contents have the same command")});var b=o(229),h=o.n(b);const y=({value:e,onChange:t,disabled:o=!1})=>a().createElement(m.FlexboxGrid,{justify:"space-between"},a().createElement(m.FlexboxGrid.Item,{colspan:8},a().createElement(m.Input,{value:e.command,placeholder:"/command",onChange:o=>t({...e,command:o})})),a().createElement(m.FlexboxGrid.Item,{colspan:15},a().createElement(s.ContentAutocomplete,{disabled:o,useSlug:!0,canCreate:!0,value:e.slug,fluid:!0,onChange:o=>t({...e,slug:o})})));y.propTypes={value:h().shape({slug:h().string,command:h().string}),onChange:h().func,disabled:h().bool};const E=y,{NodeRedNode:C,SlugHelp:v,TypeCommand:x}=l.HelpElements;console.log("eseguo COMMANDS plugin 3");(0,r.plug)("sidebar",null,{id:"configuration",label:"Configuration",permission:"configure",icon:"cog",options:[{id:"commands",label:"Commands",url:"/configuration-commands"}]}),(0,r.plug)("pages",(0,l.withConfigurationPage)("commands",({value:e,onSubmit:t=(()=>{}),disabled:o=!1})=>{const[r,l]=(0,n.useState)(e),[c,i]=(0,n.useState)(null),u=(0,n.useRef)(null);return a().createElement("div",null,a().createElement(m.Form,{model:f,disabled:!0,formValue:r,formError:c,ref:u,checkTrigger:"none",layout:"vertical",fluid:!0,onChange:e=>{l(e),i(null)},onCheck:e=>{i(e)}},a().createElement(m.FormGroup,null,a().createElement(m.ControlLabel,null,"Content Commands",a().createElement(m.HelpBlock,{tooltip:!0},"Select one or more content to be shown after a command-line message (like ",a().createElement("em",null,"/privacy"),", etc)")),a().createElement(m.FormControl,{name:"commands",accepter:s.CollectionEditor,form:E,labelAdd:"Add command",disabled:o,sortable:!1})),a().createElement(m.FormGroup,{style:{marginTop:"40px"}},a().createElement(m.ButtonToolbar,null,a().createElement(m.Button,{disabled:o,appearance:"primary",onClick:()=>{u.current.check()&&t(r)}},"Save configuration"),a().createElement(m.Button,{disabled:o,appearance:"default",onClick:()=>{confirm("Reset configuration?")&&l(e)}},"Reset")))))},{Legend:()=>a().createElement("div",null,a().createElement(C,null,"Commands"),a().createElement("p",null,"Use the this node to show some contents in response of some command-like messages from users, this is a perfect place to put some statics documents for pricacy or tos (for example ",a().createElement(x,null,"/privacy")," or ",a().createElement(x,null,"/terms"),")."),a().createElement(v,null)),title:"Commands"}),{permission:"configure",url:"/configuration-commands",title:"Commands",id:"configuration-commands"});const S={name:"command plugin"}},738:t=>{t.exports=e},186:e=>{e.exports=t},399:e=>{e.exports=o},804:e=>{e.exports=n},229:e=>{e.exports=a},297:e=>{e.exports=r},222:e=>{e.exports=l}},s={};function c(e){if(s[e])return s[e].exports;var t=s[e]={exports:{}};return m[e](t,t.exports,c),t.exports}return c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c(499)})());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment