config-editor-base 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1320,7 +1320,6 @@ var saveUpdatedConfiguration = function saveUpdatedConfiguration(filename, conte
1320
1320
  var setUpdatedFormData = function setUpdatedFormData(formData) {
1321
1321
  return function (dispatch) {
1322
1322
  dispatch(setUpdatedFormDataValue(formData));
1323
- dispatch(setConfigContent(formData));
1324
1323
  dispatch(calcCrc32EditorLive());
1325
1324
  };
1326
1325
  };
@@ -19164,10 +19163,8 @@ var selectOptions$1 = function selectOptions(Files) {
19164
19163
  });
19165
19164
  };
19166
19165
  var pastCrc32 = "N/A";
19167
- var _require$1 = require("difflib"),
19168
- unifiedDiff = _require$1.unifiedDiff;
19169
- var _require2 = require("detect-browser"),
19170
- detect$1 = _require2.detect;
19166
+ var _require$1 = require("detect-browser"),
19167
+ detect$1 = _require$1.detect;
19171
19168
  var browser$1 = detect$1();
19172
19169
  var crcBrowserSupport$1 = ["chrome", "firefox", "opera", "safari", "edge"].includes(browser$1.name);
19173
19170
  var EditorChangesComparison = /*#__PURE__*/function (_React$Component) {
@@ -19191,15 +19188,6 @@ var EditorChangesComparison = /*#__PURE__*/function (_React$Component) {
19191
19188
  }
19192
19189
  _inheritsLoose(EditorChangesComparison, _React$Component);
19193
19190
  var _proto = EditorChangesComparison.prototype;
19194
- _proto.buildDiffString = function buildDiffString(past, current) {
19195
- var hunks = unifiedDiff(past.split(/\r\n|\r|\n/), current.split(/\r\n|\r|\n/), {
19196
- fromfile: "original_config",
19197
- tofile: "new_config"
19198
- });
19199
- return "diff --git original_config new_config\n" + hunks.map(function (line) {
19200
- return line.replace(/\n$/, "");
19201
- }).join("\n");
19202
- };
19203
19191
  _proto.render = function render() {
19204
19192
  var _this$props = this.props,
19205
19193
  options = _this$props.options,
@@ -19214,8 +19202,8 @@ var EditorChangesComparison = /*#__PURE__*/function (_React$Component) {
19214
19202
  externalSubmit = _this$props.externalSubmit;
19215
19203
  var pastCleaned = past && Object.keys(past).length ? JSON.stringify(JSON.parse(past), null, 2) : "";
19216
19204
  if (crcBrowserSupport$1 == 1 && past && Object.keys(past).length) {
19217
- var _require3 = require("crc"),
19218
- crc32 = _require3.crc32;
19205
+ var _require2 = require("crc"),
19206
+ crc32 = _require2.crc32;
19219
19207
  pastCrc32 = crc32(past).toString(16).toUpperCase().padStart(8, "0");
19220
19208
  } else {
19221
19209
  pastCrc32 = "N/A";
@@ -19277,15 +19265,16 @@ var EditorChangesComparison = /*#__PURE__*/function (_React$Component) {
19277
19265
  className: "field-description"
19278
19266
  }, "This will be the name of the new Configuration File"))))), /*#__PURE__*/React.createElement("div", {
19279
19267
  className: "modal-custom-content"
19280
- }, /*#__PURE__*/React.createElement("div", null, isCompareChanges ? /*#__PURE__*/React.createElement(reactGhLikeDiff.ReactGhLikeDiff, {
19268
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(reactGhLikeDiff.ReactGhLikeDiff, {
19281
19269
  options: {
19282
19270
  originalFileName: "original_config",
19283
19271
  updatedFileName: "new_config",
19284
19272
  matchWordsThreshold: 0.25,
19285
19273
  matchingMaxComparisons: 5000
19286
19274
  },
19287
- diffString: this.buildDiffString(this.state.hideWhiteSpace ? pastCleaned : past || "", current ? JSON.stringify(current, null, 2) : "")
19288
- }) : null))), /*#__PURE__*/React.createElement("div", {
19275
+ past: this.state.hideWhiteSpace ? pastCleaned : past,
19276
+ current: JSON.stringify(current, null, 2)
19277
+ })))), /*#__PURE__*/React.createElement("div", {
19289
19278
  className: "modal-custom-footer"
19290
19279
  }, /*#__PURE__*/React.createElement("button", {
19291
19280
  type: "submit",
@@ -19363,37 +19352,37 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19363
19352
  }
19364
19353
  };
19365
19354
  _proto.subMenuBtnClick = function subMenuBtnClick(name) {
19366
- var _this2 = this;
19367
19355
  var sideBar = this.state.activeSideBar == name ? 'none' : name;
19356
+ this.props.setConfigContentPreSubmit();
19368
19357
  this.setState({
19369
19358
  activeSideBar: sideBar,
19370
19359
  isSideBarExpanded: sideBar === 'none' ? false : this.state.isSideBarExpanded
19371
- }, function () {
19372
- _this2.props.setConfigContentPreSubmit();
19373
19360
  });
19374
19361
  };
19375
19362
  _proto.toggleSideBarExpand = function toggleSideBarExpand() {
19363
+ this.props.setConfigContentPreSubmit();
19376
19364
  this.setState({
19377
19365
  isSideBarExpanded: !this.state.isSideBarExpanded
19378
19366
  });
19379
19367
  };
19380
19368
  _proto.hideUischemaModal = function hideUischemaModal() {
19369
+ this.props.setConfigContentPreSubmit();
19381
19370
  this.setState({
19382
19371
  showUischemaModal: false
19383
19372
  });
19384
19373
  };
19385
19374
  _proto.handleDropdownChange = function handleDropdownChange(selection, dropdown) {
19386
19375
  var _this$setState,
19387
- _this3 = this;
19376
+ _this2 = this;
19388
19377
  var fileType = getFileType(dropdown);
19389
19378
  this.setState((_this$setState = {}, _this$setState[fileType] = selection, _this$setState['selected' + fileType] = selection, _this$setState[fileType.replace('-', '')] = {
19390
19379
  value: selection,
19391
19380
  label: selection
19392
19381
  }, _this$setState), function () {
19393
- if (_this3.s3 && !selection.includes('Simple') && !selection.includes('Advanced') && !selection.includes('(local)')) {
19394
- _this3.props.fetchFileContentExt(selection, fileType);
19382
+ if (_this2.s3 && !selection.includes('Simple') && !selection.includes('Advanced') && !selection.includes('(local)')) {
19383
+ _this2.props.fetchFileContentExt(selection, fileType);
19395
19384
  } else {
19396
- _this3.props.fetchFileContent(selection, fileType);
19385
+ _this2.props.fetchFileContent(selection, fileType);
19397
19386
  }
19398
19387
  });
19399
19388
  };
@@ -19421,7 +19410,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19421
19410
  document.removeEventListener('keydown', this.escFunction, false);
19422
19411
  };
19423
19412
  _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
19424
- var _this4 = this;
19413
+ var _this3 = this;
19425
19414
  var uiLocal = nextProps.editorUISchemaFiles.filter(function (file) {
19426
19415
  return file.name.includes('(local)');
19427
19416
  });
@@ -19463,15 +19452,15 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19463
19452
  }
19464
19453
  }, function () {
19465
19454
  if (configName.includes('(local)')) {
19466
- _this4.props.fetchFileContent(configName, 'config-review');
19467
- } else if (_this4.s3) {
19468
- _this4.props.fetchFileContentExt(configName, 'config-review');
19455
+ _this3.props.fetchFileContent(configName, 'config-review');
19456
+ } else if (_this3.s3) {
19457
+ _this3.props.fetchFileContentExt(configName, 'config-review');
19469
19458
  }
19470
19459
  });
19471
19460
  }
19472
19461
  };
19473
19462
  _proto.onSubmit = function onSubmit(_ref2) {
19474
- var _this5 = this;
19463
+ var _this4 = this;
19475
19464
  var formData = _ref2.formData;
19476
19465
  if (this.props.schemaContent == undefined || this.props.schemaContent == null) {
19477
19466
  this.props.showAlert('info', 'No Rule Schema has been loaded');
@@ -19491,12 +19480,12 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19491
19480
  isSubmitting: true
19492
19481
  }, function () {
19493
19482
  var tempJson = JSON.stringify(formData, null, 2);
19494
- _this5.props.setConfigContent(JSON.parse(tempJson));
19495
- var revisedConfigFileSchema = _this5.state.schema;
19483
+ _this4.props.setConfigContent(JSON.parse(tempJson));
19484
+ var revisedConfigFileSchema = _this4.state.schema;
19496
19485
  var revisedConfigFile = "config-" + revisedConfigFileSchema.match(regexRevision);
19497
- if (_this5.state.isCompareChanges === false) {
19498
- _this5.props.runConfigurationWarningChecks(formData);
19499
- _this5.setState({
19486
+ if (_this4.state.isCompareChanges === false) {
19487
+ _this4.props.runConfigurationWarningChecks(formData);
19488
+ _this4.setState({
19500
19489
  isCompareChanges: true,
19501
19490
  revisedConfigFile: {
19502
19491
  value: revisedConfigFile,
@@ -19506,16 +19495,16 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19506
19495
  document.body.style.overflow = 'hidden';
19507
19496
  } else {
19508
19497
  if (isDownloadConfig) {
19509
- _this5.props.saveUpdatedConfiguration(revisedConfigFile, formData);
19498
+ _this4.props.saveUpdatedConfiguration(revisedConfigFile, formData);
19510
19499
  isDownloadConfig = false;
19511
19500
  document.body.style.overflow = 'auto';
19512
- _this5.setState({
19501
+ _this4.setState({
19513
19502
  isCompareChanges: false
19514
19503
  });
19515
19504
  } else {
19516
- _this5.props.updateConfigFileExt(JSON.stringify(formData, null, 2), "" + revisedConfigFile);
19505
+ _this4.props.updateConfigFileExt(JSON.stringify(formData, null, 2), "" + revisedConfigFile);
19517
19506
  document.body.style.overflow = 'auto';
19518
- _this5.setState({
19507
+ _this4.setState({
19519
19508
  isCompareChanges: false
19520
19509
  });
19521
19510
  }
@@ -19527,7 +19516,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19527
19516
  this.props.showAlert('danger', 'The config contains validation errors (see top of editor) - please review and try again');
19528
19517
  };
19529
19518
  _proto.render = function render() {
19530
- var _this6 = this;
19519
+ var _this5 = this;
19531
19520
  var _this$props = this.props,
19532
19521
  editorSchemaFiles = _this$props.editorSchemaFiles,
19533
19522
  editorConfigFiles = _this$props.editorConfigFiles,
@@ -19539,7 +19528,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19539
19528
  sideBarPadding = _this$props.sideBarPadding;
19540
19529
  var editorUISchemaFile = editorUISchemaFiles[0] ? editorUISchemaFiles[0].name : "";
19541
19530
  var editorUIAdvancedSimpleTest = editorUISchemaFile.includes("Simple") || editorUISchemaFile.includes("Advanced");
19542
- var FormWithNav = schemaContent ? FormWithNavStable : Form;
19531
+ var FormWithNav = schemaContent ? applyNav__default(Form, EditorNavs) : Form;
19543
19532
  var editorToolsFull = editorTools.concat({
19544
19533
  name: 'partialconfig-modal',
19545
19534
  comment: 'Partial config loader',
@@ -19575,16 +19564,16 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19575
19564
  return /*#__PURE__*/React.createElement("div", {
19576
19565
  key: idx,
19577
19566
  style: {
19578
- display: modal.name == _this6.state.activeSideBar ? '' : 'none'
19567
+ display: modal.name == _this5.state.activeSideBar ? '' : 'none'
19579
19568
  }
19580
19569
  }, /*#__PURE__*/React.createElement(EditorToolModalWrapper, {
19581
19570
  modal: modal.modal,
19582
19571
  name: modal.name,
19583
19572
  onClick: function onClick() {
19584
- return _this6.subMenuBtnClick('none');
19573
+ return _this5.subMenuBtnClick('none');
19585
19574
  },
19586
- isExpanded: _this6.state.isSideBarExpanded,
19587
- onToggleExpand: _this6.toggleSideBarExpand
19575
+ isExpanded: _this5.state.isSideBarExpanded,
19576
+ onToggleExpand: _this5.toggleSideBarExpand
19588
19577
  }));
19589
19578
  }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("div", null, editorConfigFiles.length == 0 && this.props.demoMode == false ? /*#__PURE__*/React.createElement("div", {
19590
19579
  className: "schema-loader-callout config-loader"
@@ -19660,7 +19649,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19660
19649
  return /*#__PURE__*/React.createElement(EditorToolButton, {
19661
19650
  key: idx,
19662
19651
  onClick: function onClick() {
19663
- return _this6.subMenuBtnClick(modal.name);
19652
+ return _this5.subMenuBtnClick(modal.name);
19664
19653
  },
19665
19654
  comment: modal.comment,
19666
19655
  className: modal["class"]