Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
web-interface.assets.b999a7e7-71.9472d5d0a285679cf68d.js.map Maven / Gradle / Ivy
{"version":3,"sources":["webpack:///./src/components/rules/mode-pipeline.js","webpack:///./src/components/common/SourceCodeEditor.jsx"],"names":["builtinFunctions","PipelineHighlightRules","ace","require","TextHighlightRules","keywordMapper","createKeywordMapper","keyword","$rules","start","token","regex","next","comment","defaultToken","PipelineRulesMode","Mode","args","HighlightRules","SourceCodeContainer","styled","div","darkMode","resizable","theme","color","gray","Toolbar","global","contentBackground","SourceCodeEditor","props","event","size","height","width","setState","reloadEditor","reactAce","editor","resize","readOnly","state","selectedText","getSession","getUndoManager","hasRedo","hasUndo","redo","focusEditor","undo","selection","toolbar","getTextRange","getRange","focus","this","mode","url","URLUtils","qualifyUrl","ApiRoutes","RulesController","functions","fetch","then","response","map","res","name","join","pipelineRulesMode","setMode","prevProps","annotations","fontSize","id","onLoad","onChange","value","validCssWidth","lodash","isFinite","overlay","style","ClipboardButton","title","Icon","fixedWidth","bsStyle","bsSize","onSuccess","text","buttonTitle","disabled","isCopyDisabled","placement","trigger","rootClose","isPasteDisabled","onClick","handleUndo","isUndoDisabled","handleRedo","isRedoDisabled","minConstraints","onResize","handleResize","ref","c","editorProps","$blockScrolling","setOptions","newLineMode","onSelectionChange","handleSelectionChange","React","Component","PropTypes","array","bool","number","string","isRequired","oneOf","func","Infinity"],"mappings":"mpDAEA,IAAIA,EAAmB,GAEVC,EAAb,gBAA4CC,IAAIC,QAAQ,iCAAiCC,oBAAzF,WACE,aAAc,gBAEZ,IAIMC,GALN,gBAK2BC,oBAAoB,CAC7C,oBAAqB,QACrB,eAAgB,WAChB,mBAAoBN,EACpBO,QARe,yBASf,oBAPuB,qBAQtB,cAZS,OAcZ,EAAKC,OAAS,CACZC,MAAO,CACL,CACEC,MAAO,UACPC,MAAO,aAET,CACED,MAAO,UAC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PipelineHighlightRules extends ace.require('ace/mode/text_highlight_rules').TextHighlightRules {\n constructor() {\n super();\n const keywords = 'let|when|then|rule|end';\n\n const builtinConstants = 'and|or|not|during';\n\n const keywordMapper = this.createKeywordMapper({\n 'variable.language': 'stage',\n 'support.type': '$message',\n 'support.function': builtinFunctions,\n keyword: keywords,\n 'constant.language': builtinConstants,\n }, 'identifier');\n\n this.$rules = {\n start: [\n {\n token: 'comment',\n regex: '\\\\/\\\\/.*$',\n },\n {\n token: 'comment', // multi line comment\n regex: '\\\\/\\\\*',\n next: 'comment',\n },\n {\n token: 'string', // single line\n regex: '[\"](?:(?:\\\\\\\\.)|(?:[^\"\\\\\\\\]))*?[\"]',\n },\n {\n token: 'string', // single line\n regex: \"['](?:(?:\\\\\\\\.)|(?:[^'\\\\\\\\]))*?[']\",\n },\n {\n token: 'constant.numeric', // hex\n regex: /0(?:[xX][0-9a-fA-F][0-9a-fA-F_]*|[bB][01][01_]*)[LlSsDdFfYy]?\\b/,\n },\n {\n token: 'constant.numeric', // float\n regex: /[+-]?\\d[\\d_]*(?:(?:\\.[\\d_]*)?(?:[eE][+-]?[\\d_]+)?)?[LlSsDdFfYy]?\\b/,\n },\n {\n token: 'constant.language.boolean',\n regex: '(?:true|false)\\\\b',\n },\n {\n token: 'language.support.class',\n regex: '&&',\n },\n {\n token: keywordMapper,\n regex: '[a-zA-Z_$][a-zA-Z0-9_$]*\\\\b',\n },\n {\n token: 'text',\n regex: '\\\\s+',\n },\n ],\n comment: [\n {\n token: 'comment', // closing comment\n regex: '\\\\*\\\\/',\n next: 'start',\n }, {\n defaultToken: 'comment',\n },\n ],\n };\n }\n}\n\nexport default class PipelineRulesMode extends ace.require('ace/mode/text').Mode {\n constructor(args) {\n super(args);\n\n builtinFunctions = args;\n this.HighlightRules = PipelineHighlightRules;\n }\n}\n","import React from 'react';\nimport lodash from 'lodash';\nimport { PropTypes } from 'prop-types';\nimport { Resizable } from 'react-resizable';\nimport AceEditor from 'react-ace';\nimport styled from 'styled-components';\n\nimport URLUtils from 'util/URLUtils';\nimport ApiRoutes from 'routing/ApiRoutes';\nimport fetch from 'logic/rest/FetchProvider';\n\nimport { Button, ButtonGroup, ButtonToolbar, OverlayTrigger, Tooltip } from 'components/graylog';\nimport PipelineRulesMode from 'components/rules/mode-pipeline';\n\nimport ClipboardButton from './ClipboardButton';\nimport Icon from './Icon';\nimport './webpack-resolver';\n\nconst SourceCodeContainer = styled.div(({ darkMode, resizable, theme }) => `\n .ace_editor {\n border: 1px solid ${theme.color.gray[80]};\n border-radius: 5px;\n }\n\n .react-resizable-handle {\n /* Ensure resize handle is over text editor */\n z-index: 100;\n /* Make resize handle visible on a dark background */\n filter: ${darkMode ? 'invert(100%) brightness(180%);' : 'none'};\n display: ${resizable ? 'block' : 'none'};\n }\n`);\n\nconst Toolbar = styled.div(({ theme }) => `\n background: ${theme.color.global.contentBackground};\n border: 1px solid ${theme.color.gray[80]};\n border-bottom: 0;\n border-radius: 5px 5px 0 0;\n\n .btn-link {\n color: #333;\n }\n\n & + ${SourceCodeContainer} {\n /* Do not add border radius if code editor comes after toolbar */\n .ace_editor {\n border-radius: 0 0 5px 5px;\n }\n }\n`);\n\n/**\n * Component that renders a source code editor input. This is what powers the pipeline rules and collector\n * editors.\n *\n * **Note:** The component needs to be used in a [controlled way](https://reactjs.org/docs/forms.html#controlled-components).\n * Letting the component handle its own internal state may lead to weird errors while typing.\n */\nclass SourceCodeEditor extends React.Component {\n static propTypes = {\n /**\n * Annotations to show in the editor's gutter. The format should be:\n * `[{ row: 0, column: 2, type: 'error', text: 'Some error.'}]`\n * The type value must be one of `error`, `warning`, or `info`.\n */\n annotations: PropTypes.array,\n /** Specifies if the source code editor should have the input focus or not. */\n focus: PropTypes.bool,\n /** Specifies the font size in pixels to use in the text editor. */\n fontSize: PropTypes.number,\n /** Editor height in pixels. */\n height: PropTypes.number,\n /** Specifies a unique ID for the source code editor. */\n id: PropTypes.string.isRequired,\n /** Specifies the mode to use in the editor. This is used for highlighting and auto-completion. */\n mode: PropTypes.oneOf(['json', 'lua', 'markdown', 'text', 'yaml', 'pipeline']),\n /** Function called on editor load. The first argument is the instance of the editor. */\n onLoad: PropTypes.func,\n /** Function called when the value of the text changes. It receives the the new value and an event as arguments. */\n onChange: PropTypes.func,\n /** Specifies if the editor should be in read-only mode. */\n readOnly: PropTypes.bool,\n /** Specifies if the editor should be resizable by the user. */\n resizable: PropTypes.bool,\n /** Specifies the theme to use for the editor. */\n theme: PropTypes.oneOf(['light', 'dark']),\n /** Specifies if the editor should also include a toolbar. */\n toolbar: PropTypes.bool,\n /** Text to use in the editor. */\n value: PropTypes.string,\n /** Editor width in pixels. Use `Infinity` to indicate the editor should use 100% of its container's width. */\n width: PropTypes.number,\n }\n\n static defaultProps = {\n annotations: [],\n focus: false,\n fontSize: 13,\n height: 200,\n mode: 'text',\n onChange: () => {},\n onLoad: () => {},\n readOnly: false,\n resizable: true,\n theme: 'light',\n toolbar: true,\n value: '',\n width: Infinity,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n height: props.height,\n width: props.width,\n selectedText: '',\n };\n }\n\n componentDidMount() {\n const { mode } = this.props;\n\n if (mode === 'pipeline') {\n const url = URLUtils.qualifyUrl(ApiRoutes.RulesController.functions().url);\n\n fetch('GET', url).then((response) => {\n const functions = response.map((res) => res.name).join('|');\n const pipelineRulesMode = new PipelineRulesMode(functions);\n\n this.reactAce.editor.getSession().setMode(pipelineRulesMode);\n\n return functions;\n });\n }\n }\n\n\n componentDidUpdate(prevProps) {\n const { height, width } = this.props;\n if (height !== prevProps.height || width !== prevProps.width) {\n this.reloadEditor();\n }\n }\n\n handleResize = (event, { size }) => {\n const { height, width } = size;\n this.setState({ height: height, width: width }, this.reloadEditor);\n };\n\n reloadEditor = () => {\n const { resizable } = this.props;\n if (resizable) {\n this.reactAce.editor.resize();\n }\n };\n\n /* eslint-disable-next-line react/destructuring-assignment */\n isCopyDisabled = () => this.props.readOnly || this.state.selectedText === '';\n\n /* eslint-disable-next-line react/destructuring-assignment */\n isPasteDisabled = () => this.props.readOnly;\n\n /* eslint-disable-next-line react/destructuring-assignment */\n isRedoDisabled = () => this.props.readOnly || !this.reactAce || !this.reactAce.editor.getSession().getUndoManager().hasRedo();\n\n /* eslint-disable-next-line react/destructuring-assignment */\n isUndoDisabled = () => this.props.readOnly || !this.reactAce || !this.reactAce.editor.getSession().getUndoManager().hasUndo();\n\n handleRedo = () => {\n this.reactAce.editor.redo();\n this.focusEditor();\n };\n\n handleUndo = () => {\n this.reactAce.editor.undo();\n this.focusEditor();\n };\n\n handleSelectionChange = (selection) => {\n const { toolbar, readOnly } = this.props;\n if (!this.reactAce || !toolbar || readOnly) {\n return;\n }\n\n const selectedText = this.reactAce.editor.getSession().getTextRange(selection.getRange());\n this.setState({ selectedText: selectedText });\n };\n\n focusEditor = () => {\n this.reactAce.editor.focus();\n };\n\n render() {\n const { height, width, selectedText } = this.state;\n const {\n theme,\n resizable,\n toolbar,\n annotations,\n focus,\n fontSize,\n mode,\n id,\n onLoad,\n onChange,\n readOnly,\n value,\n } = this.props;\n const validCssWidth = lodash.isFinite(width) ? width : '100%';\n const overlay = Press Ctrl+V (⌘V in macOS) or select Edit → Paste to paste from clipboard. ;\n return (\n \n {toolbar\n && (\n
\n \n \n }\n bsStyle=\"link\"\n bsSize=\"sm\"\n onSuccess={this.focusEditor}\n text={selectedText}\n buttonTitle=\"Copy (Ctrl+C / ⌘C)\"\n disabled={this.isCopyDisabled()} />\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n )}\n
\n \n { this.reactAce = c; }}\n annotations={annotations}\n editorProps={{ $blockScrolling: 'Infinity' }}\n // Convert Windows line breaks to Unix. See issue #7889\n setOptions={{ newLineMode: 'unix' }}\n focus={focus}\n fontSize={fontSize}\n mode={mode}\n theme={theme === 'light' ? 'tomorrow' : 'monokai'}\n name={id}\n height=\"100%\"\n onLoad={onLoad}\n onChange={onChange}\n onSelectionChange={this.handleSelectionChange}\n readOnly={readOnly}\n value={value}\n width=\"100%\" />\n \n \n
\n );\n }\n}\n\nexport default SourceCodeEditor;\n"],"sourceRoot":""}