config-editor-base 3.0.8 → 3.1.0

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",
@@ -19311,7 +19300,6 @@ var EditorChangesComparison$1 = reactRedux.connect(mapStateToProps$1)(EditorChan
19311
19300
  var regexRevision = new RegExp('\\d{2}\\.\\d{2}\\.json', 'g');
19312
19301
  var isDownloadConfig = false;
19313
19302
  var activatedTab;
19314
- var FormWithNavStable = applyNav__default(Form, EditorNavs);
19315
19303
  var EditorSection = /*#__PURE__*/function (_React$Component) {
19316
19304
  function EditorSection(props) {
19317
19305
  var _this;
@@ -19363,37 +19351,37 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19363
19351
  }
19364
19352
  };
19365
19353
  _proto.subMenuBtnClick = function subMenuBtnClick(name) {
19366
- var _this2 = this;
19367
19354
  var sideBar = this.state.activeSideBar == name ? 'none' : name;
19355
+ this.props.setConfigContentPreSubmit();
19368
19356
  this.setState({
19369
19357
  activeSideBar: sideBar,
19370
19358
  isSideBarExpanded: sideBar === 'none' ? false : this.state.isSideBarExpanded
19371
- }, function () {
19372
- _this2.props.setConfigContentPreSubmit();
19373
19359
  });
19374
19360
  };
19375
19361
  _proto.toggleSideBarExpand = function toggleSideBarExpand() {
19362
+ this.props.setConfigContentPreSubmit();
19376
19363
  this.setState({
19377
19364
  isSideBarExpanded: !this.state.isSideBarExpanded
19378
19365
  });
19379
19366
  };
19380
19367
  _proto.hideUischemaModal = function hideUischemaModal() {
19368
+ this.props.setConfigContentPreSubmit();
19381
19369
  this.setState({
19382
19370
  showUischemaModal: false
19383
19371
  });
19384
19372
  };
19385
19373
  _proto.handleDropdownChange = function handleDropdownChange(selection, dropdown) {
19386
19374
  var _this$setState,
19387
- _this3 = this;
19375
+ _this2 = this;
19388
19376
  var fileType = getFileType(dropdown);
19389
19377
  this.setState((_this$setState = {}, _this$setState[fileType] = selection, _this$setState['selected' + fileType] = selection, _this$setState[fileType.replace('-', '')] = {
19390
19378
  value: selection,
19391
19379
  label: selection
19392
19380
  }, _this$setState), function () {
19393
- if (_this3.s3 && !selection.includes('Simple') && !selection.includes('Advanced') && !selection.includes('(local)')) {
19394
- _this3.props.fetchFileContentExt(selection, fileType);
19381
+ if (_this2.s3 && !selection.includes('Simple') && !selection.includes('Advanced') && !selection.includes('(local)')) {
19382
+ _this2.props.fetchFileContentExt(selection, fileType);
19395
19383
  } else {
19396
- _this3.props.fetchFileContent(selection, fileType);
19384
+ _this2.props.fetchFileContent(selection, fileType);
19397
19385
  }
19398
19386
  });
19399
19387
  };
@@ -19421,7 +19409,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19421
19409
  document.removeEventListener('keydown', this.escFunction, false);
19422
19410
  };
19423
19411
  _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
19424
- var _this4 = this;
19412
+ var _this3 = this;
19425
19413
  var uiLocal = nextProps.editorUISchemaFiles.filter(function (file) {
19426
19414
  return file.name.includes('(local)');
19427
19415
  });
@@ -19463,15 +19451,15 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19463
19451
  }
19464
19452
  }, function () {
19465
19453
  if (configName.includes('(local)')) {
19466
- _this4.props.fetchFileContent(configName, 'config-review');
19467
- } else if (_this4.s3) {
19468
- _this4.props.fetchFileContentExt(configName, 'config-review');
19454
+ _this3.props.fetchFileContent(configName, 'config-review');
19455
+ } else if (_this3.s3) {
19456
+ _this3.props.fetchFileContentExt(configName, 'config-review');
19469
19457
  }
19470
19458
  });
19471
19459
  }
19472
19460
  };
19473
19461
  _proto.onSubmit = function onSubmit(_ref2) {
19474
- var _this5 = this;
19462
+ var _this4 = this;
19475
19463
  var formData = _ref2.formData;
19476
19464
  if (this.props.schemaContent == undefined || this.props.schemaContent == null) {
19477
19465
  this.props.showAlert('info', 'No Rule Schema has been loaded');
@@ -19491,12 +19479,12 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19491
19479
  isSubmitting: true
19492
19480
  }, function () {
19493
19481
  var tempJson = JSON.stringify(formData, null, 2);
19494
- _this5.props.setConfigContent(JSON.parse(tempJson));
19495
- var revisedConfigFileSchema = _this5.state.schema;
19482
+ _this4.props.setConfigContent(JSON.parse(tempJson));
19483
+ var revisedConfigFileSchema = _this4.state.schema;
19496
19484
  var revisedConfigFile = "config-" + revisedConfigFileSchema.match(regexRevision);
19497
- if (_this5.state.isCompareChanges === false) {
19498
- _this5.props.runConfigurationWarningChecks(formData);
19499
- _this5.setState({
19485
+ if (_this4.state.isCompareChanges === false) {
19486
+ _this4.props.runConfigurationWarningChecks(formData);
19487
+ _this4.setState({
19500
19488
  isCompareChanges: true,
19501
19489
  revisedConfigFile: {
19502
19490
  value: revisedConfigFile,
@@ -19506,16 +19494,16 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19506
19494
  document.body.style.overflow = 'hidden';
19507
19495
  } else {
19508
19496
  if (isDownloadConfig) {
19509
- _this5.props.saveUpdatedConfiguration(revisedConfigFile, formData);
19497
+ _this4.props.saveUpdatedConfiguration(revisedConfigFile, formData);
19510
19498
  isDownloadConfig = false;
19511
19499
  document.body.style.overflow = 'auto';
19512
- _this5.setState({
19500
+ _this4.setState({
19513
19501
  isCompareChanges: false
19514
19502
  });
19515
19503
  } else {
19516
- _this5.props.updateConfigFileExt(JSON.stringify(formData, null, 2), "" + revisedConfigFile);
19504
+ _this4.props.updateConfigFileExt(JSON.stringify(formData, null, 2), "" + revisedConfigFile);
19517
19505
  document.body.style.overflow = 'auto';
19518
- _this5.setState({
19506
+ _this4.setState({
19519
19507
  isCompareChanges: false
19520
19508
  });
19521
19509
  }
@@ -19527,7 +19515,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19527
19515
  this.props.showAlert('danger', 'The config contains validation errors (see top of editor) - please review and try again');
19528
19516
  };
19529
19517
  _proto.render = function render() {
19530
- var _this6 = this;
19518
+ var _this5 = this;
19531
19519
  var _this$props = this.props,
19532
19520
  editorSchemaFiles = _this$props.editorSchemaFiles,
19533
19521
  editorConfigFiles = _this$props.editorConfigFiles,
@@ -19539,7 +19527,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19539
19527
  sideBarPadding = _this$props.sideBarPadding;
19540
19528
  var editorUISchemaFile = editorUISchemaFiles[0] ? editorUISchemaFiles[0].name : "";
19541
19529
  var editorUIAdvancedSimpleTest = editorUISchemaFile.includes("Simple") || editorUISchemaFile.includes("Advanced");
19542
- var FormWithNav = schemaContent ? FormWithNavStable : Form;
19530
+ var FormWithNav = schemaContent ? applyNav__default(Form, EditorNavs) : Form;
19543
19531
  var editorToolsFull = editorTools.concat({
19544
19532
  name: 'partialconfig-modal',
19545
19533
  comment: 'Partial config loader',
@@ -19575,16 +19563,16 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19575
19563
  return /*#__PURE__*/React.createElement("div", {
19576
19564
  key: idx,
19577
19565
  style: {
19578
- display: modal.name == _this6.state.activeSideBar ? '' : 'none'
19566
+ display: modal.name == _this5.state.activeSideBar ? '' : 'none'
19579
19567
  }
19580
19568
  }, /*#__PURE__*/React.createElement(EditorToolModalWrapper, {
19581
19569
  modal: modal.modal,
19582
19570
  name: modal.name,
19583
19571
  onClick: function onClick() {
19584
- return _this6.subMenuBtnClick('none');
19572
+ return _this5.subMenuBtnClick('none');
19585
19573
  },
19586
- isExpanded: _this6.state.isSideBarExpanded,
19587
- onToggleExpand: _this6.toggleSideBarExpand
19574
+ isExpanded: _this5.state.isSideBarExpanded,
19575
+ onToggleExpand: _this5.toggleSideBarExpand
19588
19576
  }));
19589
19577
  }), /*#__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
19578
  className: "schema-loader-callout config-loader"
@@ -19660,7 +19648,7 @@ var EditorSection = /*#__PURE__*/function (_React$Component) {
19660
19648
  return /*#__PURE__*/React.createElement(EditorToolButton, {
19661
19649
  key: idx,
19662
19650
  onClick: function onClick() {
19663
- return _this6.subMenuBtnClick(modal.name);
19651
+ return _this5.subMenuBtnClick(modal.name);
19664
19652
  },
19665
19653
  comment: modal.comment,
19666
19654
  className: modal["class"]