diff --git a/package-lock.json b/package-lock.json index a9d1ba1..a3bb200 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13289,15 +13289,16 @@ } }, "semantic-ui-react": { - "version": "0.77.2", - "resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.77.2.tgz", - "integrity": "sha512-VwxY6oGLrBO2xoJiAW/vn40GL4WGZYWxtbrHIKYE1xChTOFlDxyIULMdnuAHOTbrbOYbLQ0X7LpdvEEYmieiJw==", + "version": "0.80.2", + "resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-0.80.2.tgz", + "integrity": "sha512-1sQ8NkxoDrd2c8wM+kdZ7mz3QMEYsbM1dV7uNe4b8D9VEaHdp640Ktp9DhmyCgXIo5BqdigJcZtb0jcWWGFfQg==", "requires": { - "babel-runtime": "^6.25.0", + "@babel/runtime": "^7.0.0-beta.48", "classnames": "^2.2.5", "fbjs": "^0.8.16", - "lodash": "^4.17.4", - "prop-types": "^15.5.10" + "keyboard-key": "^1.0.1", + "lodash": "^4.17.10", + "prop-types": "^15.6.1" } }, "semver": { diff --git a/package.json b/package.json index 70f87d1..9eb2f2e 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "react-dom": "^15.6.1", "react-joyride": "^1.11.4", "react-sortable-hoc": "^0.6.8", - "semantic-ui-react": "^0.77.2", + "semantic-ui-react": "^0.80.0", "yargs-parser": "^18.1.3" }, "devDependencies": { diff --git a/src/js/components/Preview.react.js b/src/js/components/Preview.react.js index f10e633..e6668b0 100644 --- a/src/js/components/Preview.react.js +++ b/src/js/components/Preview.react.js @@ -21,7 +21,7 @@ type Props = BaseProps & { hidden: boolean }; type State = { previewLoading: boolean, sourceLoading: boolean, - activeTab: number + activeTab: number, }; class Preview extends React.Component { @@ -53,25 +53,31 @@ class Preview extends React.Component { reloadPreview = debounce(() => { if (this.state.activeTab == 0 && this.preview != null) { + const generatedRules = RuleExporter.export( + this.props.rules, + this.props.settings + ); + const hasRequiredField = !!( + generatedRules && + generatedRules.rules.find(rule => rule.class === 'GlobalRule') + ); this.preview.loadURL( 'http://127.0.0.1:8105/preview.php?url=' + encodeURIComponent(this.props.editor.url), - { - postData: [ - { - type: 'rawData', - bytes: Buffer.from( - 'rules=' + - encodeURIComponent( - JSON.stringify( - RuleExporter.export(this.props.rules, this.props.settings) - ) - ) - ), - }, - ], - extraHeaders: 'Content-Type: application/x-www-form-urlencoded', - } + hasRequiredField + ? { + postData: [ + { + type: 'rawData', + bytes: Buffer.from( + 'rules=' + + encodeURIComponent(JSON.stringify(generatedRules)) + ), + }, + ], + extraHeaders: 'Content-Type: application/x-www-form-urlencoded', + } + : null ); } }, 1000);