react-autoql 3.4.9 → 3.5.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.
@@ -6,6 +6,7 @@ import LocalizedFormat from 'dayjs/plugin/localizedFormat';
6
6
  import utc from 'dayjs/plugin/utc';
7
7
  import timezone from 'dayjs/plugin/timezone';
8
8
  import axios from 'axios';
9
+ import _$1 from 'lodash';
9
10
  import React, { Fragment, Component } from 'react';
10
11
  import _regeneratorRuntime from '@babel/runtime/regenerator';
11
12
  import PropTypes, { shape, string, number, bool, oneOf, arrayOf, func, instanceOf, oneOfType, array } from 'prop-types';
@@ -15,7 +16,7 @@ import { MdError, MdLockOpen, MdPlayCircleOutline, MdLock, MdInfoOutline, MdCont
15
16
  import { FiAlertTriangle, FiTrash2, FiSettings, FiSend, FiPlus, FiPauseCircle, FiBellOff, FiBell, FiMoreHorizontal, FiMoreVertical, FiFilter, FiEye, FiDownload, FiDatabase, FiCheck, FiCalendar, FiArrowLeft } from 'react-icons/fi';
16
17
  import { IoIosSearch, IoIosHourglass, IoIosGlobe, IoIosCloseCircleOutline } from 'react-icons/io';
17
18
  import { TiSortNumerically } from 'react-icons/ti';
18
- import { AiOutlineBook, AiOutlineQuestionCircle, AiOutlineMenu, AiOutlineBulb, AiOutlineEdit, AiOutlineFileText, AiOutlineDashboard, AiFillCaretLeft, AiFillCaretRight } from 'react-icons/ai';
19
+ import { AiOutlineBook, AiOutlineQuestionCircle, AiOutlineMenu, AiOutlineBulb, AiOutlineEdit, AiOutlineFileText, AiOutlineDashboard, AiFillCaretUp, AiFillCaretDown, AiFillCaretLeft, AiFillCaretRight } from 'react-icons/ai';
19
20
  import { FaMicrophoneAlt } from 'react-icons/fa';
20
21
  import { GoReport } from 'react-icons/go';
21
22
  import ReactTooltip from 'react-tooltip';
@@ -23,7 +24,6 @@ import _isEqual from 'lodash.isequal';
23
24
  import _cloneDeep from 'lodash.clonedeep';
24
25
  import InfiniteScroll from 'react-infinite-scroller';
25
26
  import uuid from 'uuid';
26
- import _$1 from 'lodash';
27
27
  import parseNum from 'parse-num';
28
28
  import Popover from 'react-tiny-popover';
29
29
  import momentTZ from 'moment-timezone';
@@ -31,6 +31,8 @@ import ReactSelect from 'react-select';
31
31
  import ReactModal from 'react-modal';
32
32
  import _isEmpty from 'lodash.isempty';
33
33
  import disableScroll from 'disable-scroll';
34
+ import moment from 'moment';
35
+ import { UnmountClosed } from 'react-collapse';
34
36
  import HTMLRenderer from 'react-html-renderer';
35
37
  import { scaleOrdinal, scaleBand, scaleLinear } from 'd3-scale';
36
38
  import Autosuggest from 'react-autosuggest';
@@ -46,11 +48,12 @@ import { symbol, symbolCircle, pie, arc } from 'd3-shape';
46
48
  import { entries } from 'd3-collection';
47
49
  import 'd3-transition';
48
50
  import Drawer from 'rc-drawer';
49
- import _includes from 'lodash.includes';
51
+ import 'lodash.includes';
50
52
  import _has from 'lodash.has';
51
53
  import { Scrollbars } from 'react-custom-scrollbars';
52
54
  import LocalizedStrings from 'react-localization';
53
55
  import 'rc-drawer/assets/index.css';
56
+ import Switch from 'react-switch';
54
57
  import sqlFormatter from 'sql-formatter';
55
58
  import ReactPaginate from 'react-paginate';
56
59
  import RGL, { WidthProvider } from 'react-grid-layout';
@@ -354,6 +357,63 @@ function _nonIterableSpread() {
354
357
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
355
358
  }
356
359
 
360
+ function _createForOfIteratorHelper(o, allowArrayLike) {
361
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
362
+
363
+ if (!it) {
364
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
365
+ if (it) o = it;
366
+ var i = 0;
367
+
368
+ var F = function () {};
369
+
370
+ return {
371
+ s: F,
372
+ n: function () {
373
+ if (i >= o.length) return {
374
+ done: true
375
+ };
376
+ return {
377
+ done: false,
378
+ value: o[i++]
379
+ };
380
+ },
381
+ e: function (e) {
382
+ throw e;
383
+ },
384
+ f: F
385
+ };
386
+ }
387
+
388
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
389
+ }
390
+
391
+ var normalCompletion = true,
392
+ didErr = false,
393
+ err;
394
+ return {
395
+ s: function () {
396
+ it = it.call(o);
397
+ },
398
+ n: function () {
399
+ var step = it.next();
400
+ normalCompletion = step.done;
401
+ return step;
402
+ },
403
+ e: function (e) {
404
+ didErr = true;
405
+ err = e;
406
+ },
407
+ f: function () {
408
+ try {
409
+ if (!normalCompletion && it.return != null) it.return();
410
+ } finally {
411
+ if (didErr) throw err;
412
+ }
413
+ }
414
+ };
415
+ }
416
+
357
417
  var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
358
418
  _inherits(ErrorBoundary, _React$Component);
359
419
 
@@ -473,6 +533,8 @@ var autoQLConfigDefault = {
473
533
  debug: false,
474
534
  test: false,
475
535
  enableAutocomplete: true,
536
+ enableQueryInterpretation: true,
537
+ defaultShowInterpretation: false,
476
538
  enableQueryValidation: true,
477
539
  enableQuerySuggestions: true,
478
540
  enableColumnVisibilityManager: true,
@@ -1659,8 +1721,9 @@ var lang = new LocalizedStrings({
1659
1721
  queryPrompt: 'Type your queries here ',
1660
1722
  seeMore: 'See more',
1661
1723
  dataMessengerOptions: 'Options menu',
1662
- openConditionLocking: 'Open condition locking menu',
1663
- closeConditionLocking: 'Close condition locking menu',
1724
+ openFilterLocking: 'Open filter locking menu',
1725
+ closeFilterLocking: 'Close filter menu',
1726
+ noFiltersLocked: 'No Filters are locked yet',
1664
1727
  clearDataResponses: 'Clear all queries & responses',
1665
1728
  closeDataMessenger: 'Close Data Messenger',
1666
1729
  searchQueries: 'Search relevant queries by topic',
@@ -1697,8 +1760,9 @@ var lang = new LocalizedStrings({
1697
1760
  queryPrompt: 'Escribe tus consultas aquí',
1698
1761
  seeMore: 'Ver más',
1699
1762
  dataMessengerOptions: 'Menú de opciones',
1700
- openConditionLocking: 'Abrir menú de bloqueo de condición',
1701
- closeConditionLocking: 'Cerrar menú de bloqueo de condición',
1763
+ openFilterLocking: 'Abrir menú de filtrar',
1764
+ closeFilterLocking: 'Cerrar menú de filtrar',
1765
+ noFiltersLocked: 'Ningún filtro está bloqueado todavía',
1702
1766
  clearDataResponses: 'Borrar todas las consultas y respuestas',
1703
1767
  closeDataMessenger: 'Cerrar Data mesenger',
1704
1768
  searchQueries: 'Buscar consultas relevantes por tema',
@@ -2178,6 +2242,18 @@ var Icon = /*#__PURE__*/function (_React$Component) {
2178
2242
  break;
2179
2243
  }
2180
2244
 
2245
+ case 'caret-down':
2246
+ {
2247
+ icon = /*#__PURE__*/React.createElement(AiFillCaretDown, null);
2248
+ break;
2249
+ }
2250
+
2251
+ case 'caret-up':
2252
+ {
2253
+ icon = /*#__PURE__*/React.createElement(AiFillCaretUp, null);
2254
+ break;
2255
+ }
2256
+
2181
2257
  case 'react-autoql-bubbles':
2182
2258
  {
2183
2259
  icon = /*#__PURE__*/React.createElement("img", {
@@ -2726,12 +2802,37 @@ var runQueryOnly = function runQueryOnly() {
2726
2802
 
2727
2803
  var url = "".concat(domain, "/autoql/api/v1/query?key=").concat(apiKey);
2728
2804
  var finalUserSelection = transformUserSelection(userSelection);
2805
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
2806
+ var conditions = {};
2807
+
2808
+ if (sessionConditions !== null) {
2809
+ var _loop = function _loop(i) {
2810
+ if (Object.keys(conditions).some(function (item) {
2811
+ return item === sessionConditions[i].key;
2812
+ })) {
2813
+ item = Object.keys(conditions).find(function (key) {
2814
+ return key === sessionConditions[i].key;
2815
+ });
2816
+ conditions[item].push(sessionConditions[i].value);
2817
+ } else {
2818
+ conditions[sessionConditions[i].key] = [sessionConditions[i].value];
2819
+ }
2820
+ };
2821
+
2822
+ for (var i = 0; i < sessionConditions.length; i++) {
2823
+ var item;
2824
+
2825
+ _loop(i);
2826
+ }
2827
+ }
2828
+
2729
2829
  var data = {
2730
2830
  text: query,
2731
2831
  source: formatSourceString(source),
2732
2832
  translation: debug ? 'include' : 'exclude',
2733
2833
  user_selection: finalUserSelection,
2734
- test: test
2834
+ test: test,
2835
+ session_locked_conditions: conditions
2735
2836
  };
2736
2837
 
2737
2838
  if (!query || !query.trim()) {
@@ -2996,10 +3097,9 @@ var fetchConditions = function fetchConditions() {
2996
3097
  token = _ref10.token,
2997
3098
  domain = _ref10.domain;
2998
3099
 
2999
- if (!domain || !apiKey || !token) {
3000
- return Promise.reject(new Error('Unauthenticated'));
3001
- }
3002
-
3100
+ // if (!domain || !apiKey || !token) {
3101
+ // return Promise.reject(new Error('Unauthenticated'))
3102
+ // }
3003
3103
  var url = "".concat(domain, "/autoql/api/v1/query/condition-locking?key=").concat(apiKey);
3004
3104
  var config = {
3005
3105
  headers: {
@@ -3035,8 +3135,7 @@ var setConditions = function setConditions() {
3035
3135
  array.push({
3036
3136
  key: obj.key,
3037
3137
  keyword: obj.keyword,
3038
- // lock_flag: obj.lock_flag,
3039
- lock_flag: 1,
3138
+ lock_flag: obj.lock_flag,
3040
3139
  show_message: obj.show_message,
3041
3140
  value: obj.value
3042
3141
  });
@@ -3309,15 +3408,24 @@ _defineProperty(Dictaphone, "defaultProps", {});
3309
3408
 
3310
3409
  var SpeechToTextButtonBrowser = SpeechRecognition(options$1)(Dictaphone);
3311
3410
 
3312
- var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
3313
- _inherits(SpeechToTextBtn, _React$Component);
3411
+ function LoadingDots() {
3412
+ return /*#__PURE__*/React.createElement("div", {
3413
+ className: "response-loading",
3414
+ "data-test": "loading-dots"
3415
+ }, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null));
3416
+ }
3314
3417
 
3315
- var _super = _createSuper(SpeechToTextBtn);
3418
+ var autoCompleteArray$2 = [];
3316
3419
 
3317
- function SpeechToTextBtn() {
3420
+ var QueryInput = /*#__PURE__*/function (_React$Component) {
3421
+ _inherits(QueryInput, _React$Component);
3422
+
3423
+ var _super = _createSuper(QueryInput);
3424
+
3425
+ function QueryInput() {
3318
3426
  var _this;
3319
3427
 
3320
- _classCallCheck(this, SpeechToTextBtn);
3428
+ _classCallCheck(this, QueryInput);
3321
3429
 
3322
3430
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3323
3431
  args[_key] = arguments[_key];
@@ -3325,14 +3433,15 @@ var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
3325
3433
 
3326
3434
  _this = _super.call.apply(_super, [this].concat(args));
3327
3435
 
3436
+ _defineProperty(_assertThisInitialized(_this), "UNIQUE_ID", uuid.v4());
3437
+
3438
+ _defineProperty(_assertThisInitialized(_this), "autoCompleteTimer", undefined);
3439
+
3328
3440
  _defineProperty(_assertThisInitialized(_this), "state", {
3329
- isRecording: false,
3330
- currentQuery: 0,
3331
- resultHistory: [],
3332
- currentFile: '',
3333
- currentBlob: '',
3334
- showPopoverMessage: false,
3335
- errorMessage: ''
3441
+ inputValue: '',
3442
+ lastQuery: '',
3443
+ suggestions: [],
3444
+ isQueryRunning: false
3336
3445
  });
3337
3446
 
3338
3447
  _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
@@ -3340,323 +3449,109 @@ var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
3340
3449
  });
3341
3450
 
3342
3451
  _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (prevProps) {
3343
- if (_this.props.finalTranscript !== prevProps.finalTranscript) {
3344
- _this.props.onFinalTranscript(_this.props.finalTranscript);
3345
- } else if (_this.props.transcript !== prevProps.transcript) {
3346
- _this.props.onTranscriptChange(_this.props.transcript);
3347
- } else if (_this.props.interimTranscript !== prevProps.interimTranscript) {
3348
- _this.props.onTranscriptChange(_this.props.interimTranscript);
3452
+ if (!_isEqual(getThemeConfig(_this.props.themeConfig), getThemeConfig(prevProps.themeConfig))) {
3453
+ setCSSVars(getThemeConfig(_this.props.themeConfig));
3349
3454
  }
3350
3455
  });
3351
3456
 
3352
- _defineProperty(_assertThisInitialized(_this), "startRecording", function () {
3353
- _this.setState({
3354
- isRecording: true
3355
- });
3356
-
3357
- navigator.getUserMedia({
3358
- audio: true
3359
- }, function (stream) {
3360
- _this.stream = stream;
3361
- _this.recordAudio = RecordRTC(_this.stream, {
3362
- type: 'audio',
3363
- mimeType: 'audio/webm',
3364
- desiredSampRate: 16000,
3365
- recorderType: StereoAudioRecorder,
3366
- numberOfAudioChannels: 1
3367
- });
3368
-
3369
- _this.recordAudio.startRecording();
3370
- }, function (error) {
3371
- console.error(JSON.stringify(error));
3372
- });
3373
- });
3374
-
3375
- _defineProperty(_assertThisInitialized(_this), "onRecordStop", function (file, blob) {
3376
- _this.setState({
3377
- // isConfirmingRecording: true,
3378
- currentFile: file,
3379
- currentBlob: blob //hasPlayedBack: false,
3457
+ _defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function () {
3458
+ if (_this.autoCompleteTimer) {
3459
+ clearTimeout(_this.autoCompleteTimer);
3460
+ }
3380
3461
 
3381
- }, function () {
3382
- _this.sendWavFile(file);
3383
- });
3462
+ if (_this.queryValidationTimer) {
3463
+ clearTimeout(_this.queryValidationTimer);
3464
+ }
3384
3465
  });
3385
3466
 
3386
- _defineProperty(_assertThisInitialized(_this), "stopRecording", function () {
3387
- _this.setState({
3388
- isRecording: false
3389
- });
3467
+ _defineProperty(_assertThisInitialized(_this), "animateInputTextAndSubmit", function (_ref) {
3468
+ var query = _ref.query,
3469
+ userSelection = _ref.userSelection;
3470
+ _ref.skipQueryValidation;
3471
+ var source = _ref.source;
3390
3472
 
3391
- _this.recordAudio.stopRecording(function () {
3392
- var blob = _this.recordAudio.getBlob();
3473
+ if (typeof query === 'string' && _get(query, 'length')) {
3474
+ var _loop = function _loop(i) {
3475
+ setTimeout(function () {
3476
+ _this.setState({
3477
+ inputValue: query.slice(0, i)
3478
+ });
3393
3479
 
3394
- _this.onRecordStop(_this.blobToFile(blob), blob);
3480
+ if (i === query.length) {
3481
+ setTimeout(function () {
3482
+ _this.submitQuery({
3483
+ queryText: query,
3484
+ userSelection: userSelection,
3485
+ skipQueryValidation: true,
3486
+ source: source
3487
+ });
3488
+ }, 300);
3489
+ }
3490
+ }, i * 50);
3491
+ };
3395
3492
 
3396
- try {
3397
- _this.stream.getTracks().forEach(function (track) {
3398
- return track.stop();
3399
- });
3400
- } catch (error) {
3401
- console.error(error);
3493
+ for (var i = 1; i <= query.length; i++) {
3494
+ _loop(i);
3402
3495
  }
3403
- });
3496
+ }
3404
3497
  });
3405
3498
 
3406
- _defineProperty(_assertThisInitialized(_this), "blobToFile", function (theBlob) {
3407
- //A Blob() is almost a File() - it's just missing the two properties below which we will add
3408
- theBlob.lastModifiedDate = new Date();
3409
- theBlob.name = 'speech.wav';
3410
- return theBlob;
3411
- });
3499
+ _defineProperty(_assertThisInitialized(_this), "submitQuery", function () {
3500
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3501
+ queryText = _ref2.queryText,
3502
+ userSelection = _ref2.userSelection,
3503
+ skipQueryValidation = _ref2.skipQueryValidation,
3504
+ source = _ref2.source;
3412
3505
 
3413
- _defineProperty(_assertThisInitialized(_this), "getMediaPermissionStatus", function () {
3414
- return navigator.permissions.query({
3415
- name: 'microphone'
3416
- }).then(function (permissionStatus) {
3417
- return permissionStatus.state;
3506
+ // Cancel subscription to autocomplete since query was already submitted
3507
+ if (_this.autoCompleteTimer) {
3508
+ clearTimeout(_this.autoCompleteTimer);
3509
+ }
3510
+
3511
+ _this.setState({
3512
+ isQueryRunning: true,
3513
+ inputValue: '',
3514
+ suggestions: [],
3515
+ queryValidationResponse: undefined,
3516
+ queryValidationComponentId: uuid.v4()
3418
3517
  });
3419
- });
3420
3518
 
3421
- _defineProperty(_assertThisInitialized(_this), "onMouseDown", function () {
3422
- ReactTooltip.hide();
3519
+ var query = queryText || _this.state.inputValue;
3520
+ var newSource = [].concat(_toConsumableArray(_this.props.source), [source || 'user']);
3423
3521
 
3424
- _this.startRecording();
3425
- });
3522
+ if (query.trim()) {
3523
+ _this.props.onSubmit(query);
3524
+
3525
+ if (skipQueryValidation) {
3526
+ runQueryOnly(_objectSpread2(_objectSpread2(_objectSpread2({
3527
+ query: query,
3528
+ userSelection: userSelection
3529
+ }, getAuthentication(_this.props.authentication)), getAutoQLConfig$1(_this.props.autoQLConfig)), {}, {
3530
+ source: newSource,
3531
+ AutoAEId: _this.props.AutoAEId
3532
+ })).then(function (response) {
3533
+ _this.props.onResponseCallback(response, query);
3426
3534
 
3427
- _defineProperty(_assertThisInitialized(_this), "sendWavFile", function (file) {
3428
- var url = "".concat(_this.props.authentication.domain, "/autoql/api/v1/query/speech-to-text?key=").concat(_this.props.authentication.apiKey);
3429
- var data = new FormData();
3430
- data.append('file', file, 'speech.wav');
3431
- var config = {
3432
- headers: {
3433
- Authorization: "Bearer ".concat(_this.props.authentication.token)
3434
- },
3435
- timeout: 30000
3436
- };
3437
- axios.post(url, data, config).then(function (res) {
3438
- _this.props.onTranscriptChange(res.data.data.transcription);
3439
- }).catch(function (error) {
3440
- if (error.response.status === 404) {
3441
- _this.setState({
3442
- errorMessage: 'Oops! Speech-to-text has not been enabled. Try typing a query instead.'
3443
- }, function () {
3444
3535
  _this.setState({
3445
- showPopoverMessage: true
3536
+ isQueryRunning: false
3446
3537
  });
3447
- });
3448
- } else {
3449
- _this.setState({
3450
- errorMessage: 'Oops! Something wrong with your account'
3451
- }, function () {
3538
+ }).catch(function (error) {
3539
+ console.error(error);
3540
+
3541
+ _this.props.onResponseCallback(error);
3542
+
3452
3543
  _this.setState({
3453
- showPopoverMessage: true
3544
+ isQueryRunning: false
3454
3545
  });
3455
3546
  });
3456
- }
3457
- });
3458
- });
3459
-
3460
- _defineProperty(_assertThisInitialized(_this), "render", function () {
3461
- return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Popover, {
3462
- isOpen: _this.state.showPopoverMessage,
3463
- padding: 20,
3464
- content: function content() {
3465
- return /*#__PURE__*/React.createElement("div", {
3466
- style: {
3467
- backgroundColor: '#FFD2D2',
3468
- opacity: 1,
3469
- paddingLeft: '10px',
3470
- paddingRight: '10px'
3471
- }
3472
- }, /*#__PURE__*/React.createElement(Icon, {
3473
- type: "warning-triangle"
3474
- }), " ", _this.state.errorMessage);
3475
- },
3476
- onClickOutside: function onClickOutside() {
3477
- return _this.setState({
3478
- showPopoverMessage: false
3479
- });
3480
- }
3481
- }, /*#__PURE__*/React.createElement("button", {
3482
- id: "react-autoql-voice-record-button",
3483
- "data-test": "speech-to-text-btn",
3484
- className: "chat-voice-record-button".concat(_this.state.isRecording ? ' listening' : ''),
3485
- onMouseDown: _this.onMouseDown,
3486
- onMouseUp: _this.stopRecording,
3487
- onMouseLeave: _this.state.isRecording ? _this.stopRecording : undefined,
3488
- "data-tip": "Hold for voice-to-text",
3489
- "data-for": "react-autoql-speech-to-text-tooltip",
3490
- "data-tip-disable": _this.state.isRecording
3491
- }, /*#__PURE__*/React.createElement(Icon, {
3492
- type: "microphone"
3493
- }))), /*#__PURE__*/React.createElement(ReactTooltip, {
3494
- className: "react-autoql-tooltip",
3495
- id: "react-autoql-speech-to-text-tooltip",
3496
- effect: "solid",
3497
- delayShow: 800
3498
- }));
3499
- });
3500
-
3501
- return _this;
3502
- }
3503
-
3504
- return SpeechToTextBtn;
3505
- }(React.Component);
3506
-
3507
- _defineProperty(SpeechToTextBtn, "propTypes", {
3508
- authentication: authenticationType,
3509
- themeConfig: themeConfigType,
3510
- transcript: PropTypes.string,
3511
- interimTranscript: PropTypes.string,
3512
- finalTranscript: PropTypes.string,
3513
- resetTranscript: PropTypes.func,
3514
- onTranscriptChange: PropTypes.func,
3515
- onFinalTranscript: PropTypes.func
3516
- });
3517
-
3518
- _defineProperty(SpeechToTextBtn, "defaultProps", {
3519
- authentication: authenticationDefault,
3520
- themeConfig: themeConfigDefault
3521
- });
3522
-
3523
- function LoadingDots() {
3524
- return /*#__PURE__*/React.createElement("div", {
3525
- className: "response-loading",
3526
- "data-test": "loading-dots"
3527
- }, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null));
3528
- }
3529
-
3530
- var autoCompleteArray$2 = [];
3531
-
3532
- var QueryInput = /*#__PURE__*/function (_React$Component) {
3533
- _inherits(QueryInput, _React$Component);
3534
-
3535
- var _super = _createSuper(QueryInput);
3536
-
3537
- function QueryInput() {
3538
- var _this;
3539
-
3540
- _classCallCheck(this, QueryInput);
3541
-
3542
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3543
- args[_key] = arguments[_key];
3544
- }
3545
-
3546
- _this = _super.call.apply(_super, [this].concat(args));
3547
-
3548
- _defineProperty(_assertThisInitialized(_this), "UNIQUE_ID", uuid.v4());
3549
-
3550
- _defineProperty(_assertThisInitialized(_this), "autoCompleteTimer", undefined);
3551
-
3552
- _defineProperty(_assertThisInitialized(_this), "state", {
3553
- inputValue: '',
3554
- lastQuery: '',
3555
- suggestions: [],
3556
- isQueryRunning: false
3557
- });
3558
-
3559
- _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
3560
- setCSSVars(getThemeConfig(_this.props.themeConfig));
3561
- });
3562
-
3563
- _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (prevProps) {
3564
- if (!_isEqual(getThemeConfig(_this.props.themeConfig), getThemeConfig(prevProps.themeConfig))) {
3565
- setCSSVars(getThemeConfig(_this.props.themeConfig));
3566
- }
3567
- });
3568
-
3569
- _defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function () {
3570
- if (_this.autoCompleteTimer) {
3571
- clearTimeout(_this.autoCompleteTimer);
3572
- }
3573
- });
3574
-
3575
- _defineProperty(_assertThisInitialized(_this), "animateInputTextAndSubmit", function (_ref) {
3576
- var query = _ref.query,
3577
- userSelection = _ref.userSelection;
3578
- _ref.skipQueryValidation;
3579
- var source = _ref.source;
3580
-
3581
- if (typeof query === 'string' && _get(query, 'length')) {
3582
- var _loop = function _loop(i) {
3583
- setTimeout(function () {
3584
- _this.setState({
3585
- inputValue: query.slice(0, i)
3586
- });
3587
-
3588
- if (i === query.length) {
3589
- setTimeout(function () {
3590
- _this.submitQuery({
3591
- queryText: query,
3592
- userSelection: userSelection,
3593
- skipQueryValidation: true,
3594
- source: source
3595
- });
3596
- }, 300);
3597
- }
3598
- }, i * 50);
3599
- };
3600
-
3601
- for (var i = 1; i <= query.length; i++) {
3602
- _loop(i);
3603
- }
3604
- }
3605
- });
3606
-
3607
- _defineProperty(_assertThisInitialized(_this), "submitQuery", function () {
3608
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3609
- queryText = _ref2.queryText,
3610
- userSelection = _ref2.userSelection,
3611
- skipQueryValidation = _ref2.skipQueryValidation,
3612
- source = _ref2.source;
3613
-
3614
- // Cancel subscription to autocomplete since query was already submitted
3615
- if (_this.autoCompleteTimer) {
3616
- clearTimeout(_this.autoCompleteTimer);
3617
- }
3618
-
3619
- var query = queryText || _this.state.inputValue;
3620
- var newSource = [].concat(_toConsumableArray(_this.props.source), [source || 'user']);
3621
-
3622
- _this.setState({
3623
- isQueryRunning: true,
3624
- inputValue: ''
3625
- });
3626
-
3627
- if (query.trim()) {
3628
- _this.props.onSubmit(query);
3629
-
3630
- if (skipQueryValidation) {
3631
- runQueryOnly(_objectSpread2(_objectSpread2(_objectSpread2({
3632
- query: query,
3633
- userSelection: userSelection
3634
- }, getAuthentication(_this.props.authentication)), getAutoQLConfig$1(_this.props.autoQLConfig)), {}, {
3635
- source: newSource,
3636
- AutoAEId: _this.props.AutoAEId
3637
- })).then(function (response) {
3638
- _this.props.onResponseCallback(response, query);
3639
-
3640
- _this.setState({
3641
- isQueryRunning: false
3642
- });
3643
- }).catch(function (error) {
3644
- console.error(error);
3645
-
3646
- _this.props.onResponseCallback(error);
3647
-
3648
- _this.setState({
3649
- isQueryRunning: false
3650
- });
3651
- });
3652
- } else {
3653
- runQuery(_objectSpread2(_objectSpread2(_objectSpread2({
3654
- query: query
3655
- }, getAuthentication(_this.props.authentication)), getAutoQLConfig$1(_this.props.autoQLConfig)), {}, {
3656
- source: newSource,
3657
- AutoAEId: _this.props.AutoAEId
3658
- })).then(function (response) {
3659
- _this.props.onResponseCallback(response, query);
3547
+ } else {
3548
+ runQuery(_objectSpread2(_objectSpread2(_objectSpread2({
3549
+ query: query
3550
+ }, getAuthentication(_this.props.authentication)), getAutoQLConfig$1(_this.props.autoQLConfig)), {}, {
3551
+ source: newSource,
3552
+ AutoAEId: _this.props.AutoAEId
3553
+ })).then(function (response) {
3554
+ _this.props.onResponseCallback(response, query);
3660
3555
 
3661
3556
  _this.setState({
3662
3557
  isQueryRunning: false
@@ -3716,6 +3611,9 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3716
3611
  });
3717
3612
 
3718
3613
  _defineProperty(_assertThisInitialized(_this), "focus", function () {
3614
+ // if (this.queryValidationInputRef) {
3615
+ // this.queryValidationInputRef.focus()
3616
+ // }
3719
3617
  if (_this.inputRef) {
3720
3618
  _this.inputRef.focus();
3721
3619
  } else {
@@ -3738,8 +3636,37 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3738
3636
  }
3739
3637
  });
3740
3638
 
3741
- _defineProperty(_assertThisInitialized(_this), "onSuggestionsFetchRequested", function (_ref3) {
3742
- var value = _ref3.value;
3639
+ _defineProperty(_assertThisInitialized(_this), "runQueryValidation", function (_ref3) {
3640
+ var text = _ref3.text;
3641
+
3642
+ // Reset validation configuration since text has changed
3643
+ _this.setState({
3644
+ queryValidationResponse: undefined,
3645
+ queryValidationComponentId: uuid.v4()
3646
+ });
3647
+
3648
+ if (_this.queryValidationTimer) {
3649
+ clearTimeout(_this.queryValidationTimer);
3650
+ }
3651
+
3652
+ _this.queryValidationTimer = setTimeout(function () {
3653
+ runQueryValidation(_objectSpread2({
3654
+ text: text
3655
+ }, getAuthentication(_this.props.authentication))).then(function (response) {
3656
+ if (_this.state.inputValue === _get(response, 'data.data.query')) {
3657
+ _this.setState({
3658
+ queryValidationResponse: response,
3659
+ queryValidationComponentId: uuid.v4()
3660
+ });
3661
+ }
3662
+ }).catch(function (error) {
3663
+ console.error(error);
3664
+ });
3665
+ }, 300);
3666
+ });
3667
+
3668
+ _defineProperty(_assertThisInitialized(_this), "onSuggestionsFetchRequested", function (_ref4) {
3669
+ var value = _ref4.value;
3743
3670
 
3744
3671
  if (_this.autoCompleteTimer) {
3745
3672
  clearTimeout(_this.autoCompleteTimer);
@@ -3791,6 +3718,8 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3791
3718
  });
3792
3719
 
3793
3720
  _defineProperty(_assertThisInitialized(_this), "onInputChange", function (e) {
3721
+ //WIP
3722
+ // this.runQueryValidation({ text: e.target.value })
3794
3723
  if (_this.userSelectedSuggestion && (e.keyCode === 38 || e.keyCode === 40)) {
3795
3724
  // keyup or keydown
3796
3725
  return; // return to let the component handle it...
@@ -3818,14 +3747,16 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3818
3747
  return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement("div", {
3819
3748
  className: "react-autoql-bar-container ".concat(_this.props.className, " ").concat(_this.props.autoCompletePlacement === 'below' ? 'autosuggest-bottom' : 'autosuggest-top'),
3820
3749
  "data-test": "chat-bar"
3750
+ }, /*#__PURE__*/React.createElement("div", {
3751
+ className: "react-autoql-chatbar-input-container"
3821
3752
  }, getAutoQLConfig$1(_this.props.autoQLConfig).enableAutocomplete ? /*#__PURE__*/React.createElement(Autosuggest, {
3822
- className: "auto-complete-chata",
3753
+ lassName: "auto-complete-chata",
3823
3754
  onSuggestionsFetchRequested: _this.onSuggestionsFetchRequested,
3824
3755
  onSuggestionsClearRequested: _this.onSuggestionsClearRequested,
3825
3756
  getSuggestionValue: _this.userSelectedSuggestionHandler,
3826
3757
  suggestions: _this.state.suggestions,
3827
- ref: function ref(_ref4) {
3828
- _this.autoSuggest = _ref4;
3758
+ ref: function ref(_ref5) {
3759
+ _this.autoSuggest = _ref5;
3829
3760
  },
3830
3761
  renderSuggestion: function renderSuggestion(suggestion) {
3831
3762
  return /*#__PURE__*/React.createElement(Fragment, null, suggestion.name);
@@ -3841,9 +3772,24 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3841
3772
  onFocus: _this.moveCaretAtEnd,
3842
3773
  autoFocus: true
3843
3774
  }
3844
- }) : /*#__PURE__*/React.createElement("div", {
3845
- className: "react-autoql-chatbar-input-container"
3846
- }, /*#__PURE__*/React.createElement("input", {
3775
+ }) // <QueryInputWithValidation
3776
+ // authentication={getAuthentication(this.props.authentication)}
3777
+ // themeConfig={getThemeConfig(this.props.themeConfig)}
3778
+ // ref={(ref) => (this.queryValidationInputRef = ref)}
3779
+ // key={this.state.queryValidationComponentId}
3780
+ // response={this.state.queryValidationResponse}
3781
+ // placeholder={this.props.placeholder}
3782
+ // disabled={this.props.isDisabled}
3783
+ // showChataIcon={this.props.showChataIcon}
3784
+ // showLoadingDots={this.props.showLoadingDots}
3785
+ // submitQuery={this.submitQuery}
3786
+ // onKeyDown={this.onKeyDown}
3787
+ // onQueryValidationSelectOption={(query) => {
3788
+ // this.setState({ inputValue: query })
3789
+ // this.focus()
3790
+ // }}
3791
+ // />
3792
+ : /*#__PURE__*/React.createElement("input", {
3847
3793
  className: "react-autoql-chatbar-input".concat(_this.props.showChataIcon ? ' left-padding' : ''),
3848
3794
  placeholder: _this.props.placeholder || 'Type your queries here',
3849
3795
  value: _this.state.inputValue,
@@ -3865,12 +3811,21 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3865
3811
  type: "react-autoql-bubbles-outlined"
3866
3812
  })), _this.props.showLoadingDots && _this.state.isQueryRunning && /*#__PURE__*/React.createElement("div", {
3867
3813
  className: "input-response-loading-container"
3868
- }, /*#__PURE__*/React.createElement(LoadingDots, null)), _this.props.enableVoiceRecord && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SpeechToTextButtonBrowser, {
3814
+ }, /*#__PURE__*/React.createElement(LoadingDots, null)), _this.props.enableVoiceRecord &&
3815
+ /*#__PURE__*/
3816
+ // KEEP THIS FOR NOW
3817
+ // <SpeechToTextBtn
3818
+ // onTranscriptChange={this.onTranscriptChange}
3819
+ // onFinalTranscript={this.onFinalTranscript}
3820
+ // themeConfig={this.props.themeConfig}
3821
+ // authentication={getAuthentication(this.props.authentication)}
3822
+ // />
3823
+ React.createElement(SpeechToTextButtonBrowser, {
3869
3824
  onTranscriptChange: _this.onTranscriptChange,
3870
3825
  onFinalTranscript: _this.onFinalTranscript,
3871
3826
  themeConfig: _this.props.themeConfig,
3872
3827
  authentication: getAuthentication(_this.props.authentication)
3873
- }))));
3828
+ })));
3874
3829
  });
3875
3830
 
3876
3831
  return _this;
@@ -3996,7 +3951,7 @@ var ChataTable = /*#__PURE__*/function (_React$Component) {
3996
3951
  _defineProperty(_assertThisInitialized(_this), "saveAsCSV", function () {
3997
3952
  if (_this.ref && _this.ref.table) {
3998
3953
  _this.ref.table.download('csv', 'table.csv', {
3999
- delimiter: '\t'
3954
+ delimiter: ','
4000
3955
  });
4001
3956
  }
4002
3957
  });
@@ -4064,7 +4019,7 @@ var ChataTable = /*#__PURE__*/function (_React$Component) {
4064
4019
  options: options,
4065
4020
  "data-custom-attr": "test-custom-attribute",
4066
4021
  className: "react-autoql-table",
4067
- height: "100%",
4022
+ height: "98%",
4068
4023
  clipboard: true,
4069
4024
  download: true
4070
4025
  })));
@@ -7938,6 +7893,10 @@ var ChataChart = /*#__PURE__*/function (_Component) {
7938
7893
  _this.updateMargins();
7939
7894
  }
7940
7895
 
7896
+ if (!_isEqual(_this.props.isShowingInterpretation, prevProps.isShowingInterpretation)) {
7897
+ _this.updateMargins();
7898
+ }
7899
+
7941
7900
  if (_this.props.type && _this.props.type !== prevProps.type && _this.props.type !== 'pie') {
7942
7901
  _this.updateMargins();
7943
7902
 
@@ -9241,14 +9200,15 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
9241
9200
 
9242
9201
  _defineProperty(_assertThisInitialized(_this), "supportedDisplayTypes", []);
9243
9202
 
9244
- _defineProperty(_assertThisInitialized(_this), "SAFETYNET_KEY", uuid.v4());
9203
+ _defineProperty(_assertThisInitialized(_this), "QUERY_VALIDATION_KEY", uuid.v4());
9245
9204
 
9246
9205
  _defineProperty(_assertThisInitialized(_this), "state", {
9247
9206
  displayType: null,
9248
9207
  tableFilters: [],
9249
9208
  suggestionSelection: _this.props.selectedSuggestion,
9250
9209
  QandAResponseCorrect: false,
9251
- QandASuggestions: []
9210
+ QandASuggestions: [],
9211
+ isShowingInterpretation: false
9252
9212
  });
9253
9213
 
9254
9214
  _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
@@ -9270,6 +9230,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
9270
9230
 
9271
9231
 
9272
9232
  _this.setState({
9233
+ isShowingInterpretation: getAutoQLConfig$1(_this.props.autoQLConfig).defaultShowInterpretation,
9273
9234
  displayType: isDisplayTypeValid(_this.props.queryResponse, _this.props.displayType) ? _this.props.displayType : getDefaultDisplayType(_this.props.queryResponse, _this.props.autoChartAggregations)
9274
9235
  });
9275
9236
 
@@ -9345,6 +9306,10 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
9345
9306
  disableScroll.off();
9346
9307
  }
9347
9308
 
9309
+ if (prevState.isShowingInterpretation !== _this.state.isShowingInterpretation) {
9310
+ _this.forceUpdate();
9311
+ }
9312
+
9348
9313
  if (_this.props.optionsToolbarRef) {
9349
9314
  _this.props.optionsToolbarRef._isMounted && _this.props.optionsToolbarRef.forceUpdate();
9350
9315
  }
@@ -10670,7 +10635,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10670
10635
  }
10671
10636
 
10672
10637
  if (_this.state.displayType === 'pivot_table') {
10673
- return /*#__PURE__*/React.createElement(ChataTable, {
10638
+ return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(ChataTable, {
10674
10639
  themeConfig: getThemeConfig(_this.props.themeConfig),
10675
10640
  key: _this.pivotTableID,
10676
10641
  ref: function ref(_ref6) {
@@ -10683,7 +10648,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10683
10648
  onFilterCallback: _this.onTableFilter,
10684
10649
  setFilterTagsCallback: _this.props.setFilterTagsCallback,
10685
10650
  enableColumnHeaderContextMenu: _this.props.enableColumnHeaderContextMenu
10686
- });
10651
+ }));
10687
10652
  }
10688
10653
 
10689
10654
  return /*#__PURE__*/React.createElement(Fragment, null, _this.renderAllColumnsHiddenMessage(), /*#__PURE__*/React.createElement(ChataTable, {
@@ -10725,6 +10690,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10725
10690
  columns: _this.chartTableColumns,
10726
10691
  height: height,
10727
10692
  width: width,
10693
+ isShowingInterpretation: _this.state.isShowingInterpretation,
10728
10694
  dataFormatting: getDataFormatting(_this.props.dataFormatting),
10729
10695
  backgroundColor: _this.props.backgroundColor,
10730
10696
  activeChartElementKey: _this.props.activeChartElementKey,
@@ -10859,7 +10825,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10859
10825
  if (_get(queryResponse, 'data.data.replacements')) {
10860
10826
  return /*#__PURE__*/React.createElement(QueryValidationMessage, {
10861
10827
  themeConfig: getThemeConfig(_this.props.themeConfig),
10862
- key: _this.SAFETYNET_KEY,
10828
+ key: _this.QUERY_VALIDATION_KEY,
10863
10829
  response: _this.props.queryResponse,
10864
10830
  onSuggestionClick: function onSuggestionClick(_ref9) {
10865
10831
  var query = _ref9.query,
@@ -10984,8 +10950,73 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10984
10950
  }, /*#__PURE__*/React.createElement("div", null));
10985
10951
  });
10986
10952
 
10953
+ _defineProperty(_assertThisInitialized(_this), "handleShowHide", function (e) {
10954
+ var responseContainer = document.getElementById("react-autoql-response-content-container-".concat(_this.COMPONENT_KEY)); // make room in response container for reverse translation text
10955
+
10956
+ if (document.getElementById("reverse-translation-".concat(_this.COMPONENT_KEY)) && getAutoQLConfig$1(_this.props.autoQLConfig).enableQueryInterpretation) {
10957
+ if (e.isFullyOpened) {
10958
+ responseContainer.style.height = "calc(100% - ".concat(e.contentHeight, "px)");
10959
+ } else {
10960
+ responseContainer.style.height = "calc(100% - 26px)";
10961
+ }
10962
+ }
10963
+ });
10964
+
10965
+ _defineProperty(_assertThisInitialized(_this), "renderReverseTranslation", function () {
10966
+ var queryResponse = _this.props.queryResponse;
10967
+ var id = "reverse-translation-".concat(_this.COMPONENT_KEY);
10968
+ var responseContainer = document.getElementById("react-autoql-response-content-container-".concat(_this.COMPONENT_KEY));
10969
+
10970
+ if (responseContainer && _get(queryResponse, 'data.data.interpretation')) {
10971
+ // manipulate interpretation string to properly format various substrings
10972
+ var reverseTranslation = _get(queryResponse, 'data.data.interpretation').replace(/(["'])(?:(?=(\\?))\2.)*?\1/gi, function (output) {
10973
+ var text = output.replace(/'/g, '');
10974
+
10975
+ if (_get(queryResponse, 'data.data.persistent_locked_conditions').includes(text) || _get(queryResponse, 'data.data.session_locked_conditions').includes(text)) {
10976
+ return "\n <a class=\"react-autoql-condition-link-filtered\">\n <span class=\"material-icons react-autoql-custom-icon\">lock</span>\n ".concat(' ', text, "\n </a>\n ");
10977
+ } else {
10978
+ return "<a class=\"react-autoql-condition-link\">".concat(text, "</a>");
10979
+ }
10980
+ }).replace(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/gi, function (output) {
10981
+ return moment.utc(output).format('ll').toString();
10982
+ });
10983
+
10984
+ return /*#__PURE__*/React.createElement("div", {
10985
+ id: id,
10986
+ className: "condition-lock-reverse-translation"
10987
+ }, /*#__PURE__*/React.createElement("span", {
10988
+ style: {
10989
+ float: 'left',
10990
+ minHeight: 20
10991
+ } // onClick={() => {
10992
+ // this.setState({
10993
+ // isShowingInterpretation: !this.state.isShowingInterpretation
10994
+ // })
10995
+ // }}
10996
+
10997
+ }, /*#__PURE__*/React.createElement(Icon // type={this.state.isShowingInterpretation ? 'caret-down' : 'caret-right' }
10998
+ // data-tip={this.state.isShowingInterpretation ? "Hide query interpretation" : "Show query interpretation" }
10999
+ , {
11000
+ type: "info" // data-for="react-autoql-interpretation"
11001
+
11002
+ }), ' '), /*#__PURE__*/React.createElement(UnmountClosed, {
11003
+ onRest: _this.handleShowHide,
11004
+ isOpened: true // isOpened={this.state.isShowingInterpretation}
11005
+
11006
+ }, /*#__PURE__*/React.createElement("strong", null, "Interpreted as:", ' '), /*#__PURE__*/React.createElement("span", {
11007
+ onClick: function onClick() {
11008
+ return _this.props.onConditionClickCallback();
11009
+ },
11010
+ dangerouslySetInnerHTML: {
11011
+ __html: "".concat(reverseTranslation)
11012
+ }
11013
+ })));
11014
+ }
11015
+ });
11016
+
10987
11017
  _defineProperty(_assertThisInitialized(_this), "render", function () {
10988
11018
  var responseContainer = document.getElementById("react-autoql-response-content-container-".concat(_this.COMPONENT_KEY));
11019
+ var translationContainer = document.getElementById("reverse-translation-".concat(_this.COMPONENT_KEY));
10989
11020
  var height = 0;
10990
11021
  var width = 0;
10991
11022
 
@@ -10995,10 +11026,18 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10995
11026
  }
10996
11027
 
10997
11028
  if (_this.props.height) {
10998
- height = _this.props.height;
10999
- }
11000
-
11001
- if (_this.props.width) {
11029
+ if (translationContainer && getAutoQLConfig$1(_this.props.autoQLConfig).enableQueryInterpretation && _this.state.isShowingInterpretation) {
11030
+ if (_this.state.isShowingInterpretation) {
11031
+ height = _this.props.height - translationContainer.offsetHeight - 20;
11032
+ } else {
11033
+ height = _this.props.height - translationContainer.offsetHeight - 40;
11034
+ }
11035
+ } else {
11036
+ height = _this.props.height;
11037
+ }
11038
+ }
11039
+
11040
+ if (_this.props.width) {
11002
11041
  width = _this.props.width;
11003
11042
  }
11004
11043
 
@@ -11007,7 +11046,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
11007
11046
  id: "react-autoql-response-content-container-".concat(_this.COMPONENT_KEY),
11008
11047
  "data-test": "query-response-wrapper",
11009
11048
  className: "react-autoql-response-content-container\n ".concat(isTableType(_this.state.displayType) ? 'table' : '', "\n ").concat(_this.state.displayType === 'html' ? 'html-content' : '')
11010
- }, _this.renderResponse(width, height), _get(getAuthentication(_this.props.authentication), 'isQandA') && _this.renderQandAResponseConfirmation()), _this.renderContextMenu());
11049
+ }, _this.renderResponse(width, height), _get(getAuthentication(_this.props.authentication), 'isQandA') && _this.renderQandAResponseConfirmation()), !_this.props.isDashboardQuery && getAutoQLConfig$1(_this.props.autoQLConfig).enableQueryInterpretation ? _this.renderReverseTranslation() : null, _this.renderContextMenu());
11011
11050
  });
11012
11051
 
11013
11052
  return _this;
@@ -11022,13 +11061,13 @@ _defineProperty(QueryOutput, "propTypes", (_defineProperty2$1 = {
11022
11061
  authentication: authenticationType,
11023
11062
  themeConfig: themeConfigType,
11024
11063
  autoQLConfig: autoQLConfigType
11025
- }, _defineProperty(_defineProperty2$1, "authentication", authenticationType), _defineProperty(_defineProperty2$1, "dataFormatting", dataFormattingType), _defineProperty(_defineProperty2$1, "dataConfig", shape({})), _defineProperty(_defineProperty2$1, "onSuggestionClick", func), _defineProperty(_defineProperty2$1, "displayType", string), _defineProperty(_defineProperty2$1, "renderTooltips", bool), _defineProperty(_defineProperty2$1, "onQueryValidationSelectOption", func), _defineProperty(_defineProperty2$1, "autoSelectQueryValidationSuggestion", bool), _defineProperty(_defineProperty2$1, "queryValidationSelections", arrayOf(shape({}))), _defineProperty(_defineProperty2$1, "renderSuggestionsAsDropdown", bool), _defineProperty(_defineProperty2$1, "suggestionSelection", string), _defineProperty(_defineProperty2$1, "height", number), _defineProperty(_defineProperty2$1, "width", number), _defineProperty(_defineProperty2$1, "hideColumnCallback", func), _defineProperty(_defineProperty2$1, "activeChartElementKey", string), _defineProperty(_defineProperty2$1, "onTableFilterCallback", func), _defineProperty(_defineProperty2$1, "enableColumnHeaderContextMenu", bool), _defineProperty(_defineProperty2$1, "isResizing", bool), _defineProperty(_defineProperty2$1, "enableDynamicCharting", bool), _defineProperty(_defineProperty2$1, "onDataConfigChange", func), _defineProperty(_defineProperty2$1, "onDisplayTypeUpdate", func), _defineProperty(_defineProperty2$1, "onColumnsUpdate", func), _defineProperty(_defineProperty2$1, "onNoneOfTheseClick", func), _defineProperty(_defineProperty2$1, "autoChartAggregations", bool), _defineProperty(_defineProperty2$1, "onSupportedDisplayTypesChange", func), _defineProperty2$1));
11064
+ }, _defineProperty(_defineProperty2$1, "authentication", authenticationType), _defineProperty(_defineProperty2$1, "dataFormatting", dataFormattingType), _defineProperty(_defineProperty2$1, "dataConfig", shape({})), _defineProperty(_defineProperty2$1, "onSuggestionClick", func), _defineProperty(_defineProperty2$1, "displayType", string), _defineProperty(_defineProperty2$1, "renderTooltips", bool), _defineProperty(_defineProperty2$1, "onQueryValidationSelectOption", func), _defineProperty(_defineProperty2$1, "autoSelectQueryValidationSuggestion", bool), _defineProperty(_defineProperty2$1, "queryValidationSelections", arrayOf(shape({}))), _defineProperty(_defineProperty2$1, "renderSuggestionsAsDropdown", bool), _defineProperty(_defineProperty2$1, "suggestionSelection", string), _defineProperty(_defineProperty2$1, "height", number), _defineProperty(_defineProperty2$1, "width", number), _defineProperty(_defineProperty2$1, "hideColumnCallback", func), _defineProperty(_defineProperty2$1, "activeChartElementKey", string), _defineProperty(_defineProperty2$1, "onTableFilterCallback", func), _defineProperty(_defineProperty2$1, "enableColumnHeaderContextMenu", bool), _defineProperty(_defineProperty2$1, "isResizing", bool), _defineProperty(_defineProperty2$1, "enableDynamicCharting", bool), _defineProperty(_defineProperty2$1, "onDataConfigChange", func), _defineProperty(_defineProperty2$1, "onDisplayTypeUpdate", func), _defineProperty(_defineProperty2$1, "onColumnsUpdate", func), _defineProperty(_defineProperty2$1, "onNoneOfTheseClick", func), _defineProperty(_defineProperty2$1, "autoChartAggregations", bool), _defineProperty(_defineProperty2$1, "onSupportedDisplayTypesChange", func), _defineProperty(_defineProperty2$1, "onConditionClickCallback", func), _defineProperty(_defineProperty2$1, "isDashboardQuery", bool), _defineProperty(_defineProperty2$1, "enableQueryInterpretation", bool), _defineProperty(_defineProperty2$1, "defaultShowInterpretation", bool), _defineProperty2$1));
11026
11065
 
11027
11066
  _defineProperty(QueryOutput, "defaultProps", (_defineProperty3 = {
11028
11067
  authentication: authenticationDefault,
11029
11068
  themeConfig: themeConfigDefault,
11030
11069
  autoQLConfig: autoQLConfigDefault
11031
- }, _defineProperty(_defineProperty3, "authentication", authenticationDefault), _defineProperty(_defineProperty3, "dataFormatting", dataFormattingDefault), _defineProperty(_defineProperty3, "dataConfig", undefined), _defineProperty(_defineProperty3, "queryResponse", undefined), _defineProperty(_defineProperty3, "displayType", undefined), _defineProperty(_defineProperty3, "queryInputRef", undefined), _defineProperty(_defineProperty3, "onSuggestionClick", undefined), _defineProperty(_defineProperty3, "renderTooltips", true), _defineProperty(_defineProperty3, "autoSelectQueryValidationSuggestion", true), _defineProperty(_defineProperty3, "queryValidationSelections", undefined), _defineProperty(_defineProperty3, "renderSuggestionsAsDropdown", false), _defineProperty(_defineProperty3, "selectedSuggestion", undefined), _defineProperty(_defineProperty3, "height", undefined), _defineProperty(_defineProperty3, "width", undefined), _defineProperty(_defineProperty3, "activeChartElementKey", undefined), _defineProperty(_defineProperty3, "enableColumnHeaderContextMenu", false), _defineProperty(_defineProperty3, "isResizing", false), _defineProperty(_defineProperty3, "enableDynamicCharting", true), _defineProperty(_defineProperty3, "onNoneOfTheseClick", undefined), _defineProperty(_defineProperty3, "autoChartAggregations", true), _defineProperty(_defineProperty3, "onDataClick", function onDataClick() {}), _defineProperty(_defineProperty3, "onQueryValidationSelectOption", function onQueryValidationSelectOption() {}), _defineProperty(_defineProperty3, "onSupportedDisplayTypesChange", function onSupportedDisplayTypesChange() {}), _defineProperty(_defineProperty3, "hideColumnCallback", function hideColumnCallback() {}), _defineProperty(_defineProperty3, "onTableFilterCallback", function onTableFilterCallback() {}), _defineProperty(_defineProperty3, "onDataConfigChange", function onDataConfigChange() {}), _defineProperty(_defineProperty3, "onErrorCallback", function onErrorCallback() {}), _defineProperty(_defineProperty3, "onDisplayTypeUpdate", function onDisplayTypeUpdate() {}), _defineProperty(_defineProperty3, "onColumnsUpdate", function onColumnsUpdate() {}), _defineProperty3));
11070
+ }, _defineProperty(_defineProperty3, "authentication", authenticationDefault), _defineProperty(_defineProperty3, "dataFormatting", dataFormattingDefault), _defineProperty(_defineProperty3, "dataConfig", undefined), _defineProperty(_defineProperty3, "queryResponse", undefined), _defineProperty(_defineProperty3, "displayType", undefined), _defineProperty(_defineProperty3, "queryInputRef", undefined), _defineProperty(_defineProperty3, "onSuggestionClick", undefined), _defineProperty(_defineProperty3, "renderTooltips", true), _defineProperty(_defineProperty3, "autoSelectQueryValidationSuggestion", true), _defineProperty(_defineProperty3, "queryValidationSelections", undefined), _defineProperty(_defineProperty3, "renderSuggestionsAsDropdown", false), _defineProperty(_defineProperty3, "selectedSuggestion", undefined), _defineProperty(_defineProperty3, "height", undefined), _defineProperty(_defineProperty3, "width", undefined), _defineProperty(_defineProperty3, "activeChartElementKey", undefined), _defineProperty(_defineProperty3, "enableColumnHeaderContextMenu", false), _defineProperty(_defineProperty3, "isResizing", false), _defineProperty(_defineProperty3, "enableDynamicCharting", true), _defineProperty(_defineProperty3, "onNoneOfTheseClick", undefined), _defineProperty(_defineProperty3, "autoChartAggregations", true), _defineProperty(_defineProperty3, "isDashboardQuery", false), _defineProperty(_defineProperty3, "enableFilterLocking", false), _defineProperty(_defineProperty3, "onDataClick", function onDataClick() {}), _defineProperty(_defineProperty3, "onQueryValidationSelectOption", function onQueryValidationSelectOption() {}), _defineProperty(_defineProperty3, "onSupportedDisplayTypesChange", function onSupportedDisplayTypesChange() {}), _defineProperty(_defineProperty3, "hideColumnCallback", function hideColumnCallback() {}), _defineProperty(_defineProperty3, "onTableFilterCallback", function onTableFilterCallback() {}), _defineProperty(_defineProperty3, "onDataConfigChange", function onDataConfigChange() {}), _defineProperty(_defineProperty3, "onErrorCallback", function onErrorCallback() {}), _defineProperty(_defineProperty3, "onDisplayTypeUpdate", function onDisplayTypeUpdate() {}), _defineProperty(_defineProperty3, "onColumnsUpdate", function onColumnsUpdate() {}), _defineProperty(_defineProperty3, "onConditionClickCallback", function onConditionClickCallback() {}), _defineProperty3));
11032
11071
 
11033
11072
  var VizToolbar = /*#__PURE__*/function (_React$Component) {
11034
11073
  _inherits(VizToolbar, _React$Component);
@@ -12086,8 +12125,18 @@ var NotificationIcon = /*#__PURE__*/function (_React$Component) {
12086
12125
  switch (_context.prev = _context.next) {
12087
12126
  case 0:
12088
12127
  _this._isMounted = true;
12089
-
12090
- _this.subscribeToNotificationCount();
12128
+ /**
12129
+ * If Data Messenger has enableNotificationsTab = true and
12130
+ * the NotificationIcon is also present, subscribeToNotificationCount()
12131
+ * will occasionally trigger an infinite loop.
12132
+ *
12133
+ * Data Messenger will first check to see that the NotificationIcon
12134
+ * isn't already present before triggering this function inside.
12135
+ */
12136
+
12137
+ if (!_this.props.isAlreadyMountedInDOM) {
12138
+ _this.subscribeToNotificationCount();
12139
+ }
12091
12140
 
12092
12141
  case 2:
12093
12142
  case "end":
@@ -12221,7 +12270,8 @@ _defineProperty(NotificationIcon, "propTypes", {
12221
12270
  useDot: PropTypes.bool,
12222
12271
  clearCountOnClick: PropTypes.bool,
12223
12272
  onNewNotification: PropTypes.func,
12224
- onErrorCallback: PropTypes.func
12273
+ onErrorCallback: PropTypes.func,
12274
+ isAlreadyMountedInDOM: PropTypes.bool
12225
12275
  });
12226
12276
 
12227
12277
  _defineProperty(NotificationIcon, "defaultProps", {
@@ -12231,7 +12281,8 @@ _defineProperty(NotificationIcon, "defaultProps", {
12231
12281
  style: {},
12232
12282
  clearCountOnClick: true,
12233
12283
  onNewNotification: function onNewNotification() {},
12234
- onErrorCallback: function onErrorCallback() {}
12284
+ onErrorCallback: function onErrorCallback() {},
12285
+ isAlreadyMountedInDOM: false
12235
12286
  });
12236
12287
 
12237
12288
  var _excluded$1 = ["icon", "type"];
@@ -12538,7 +12589,7 @@ var RuleSimple = /*#__PURE__*/function (_React$Component) {
12538
12589
  return '<';
12539
12590
  }
12540
12591
 
12541
- case 'EQUALS':
12592
+ case 'EQUAL_TO':
12542
12593
  {
12543
12594
  return '=';
12544
12595
  }
@@ -12596,9 +12647,9 @@ var RuleSimple = /*#__PURE__*/function (_React$Component) {
12596
12647
  label: '<',
12597
12648
  tooltip: 'Less Than'
12598
12649
  }, {
12599
- value: 'EQUALS',
12650
+ value: 'EQUAL_TO',
12600
12651
  label: '=',
12601
- tooltip: 'Equals'
12652
+ tooltip: 'EQUAL_TO'
12602
12653
  }, {
12603
12654
  value: 'EXISTS',
12604
12655
  label: 'Exists',
@@ -15559,7 +15610,7 @@ var Rule = /*#__PURE__*/function (_React$Component) {
15559
15610
  return '<';
15560
15611
  }
15561
15612
 
15562
- case 'EQUALS':
15613
+ case 'EQUAL_TO':
15563
15614
  {
15564
15615
  return '=';
15565
15616
  }
@@ -15622,9 +15673,9 @@ var Rule = /*#__PURE__*/function (_React$Component) {
15622
15673
  label: '<',
15623
15674
  tooltip: 'Less Than'
15624
15675
  }, {
15625
- value: 'EQUALS',
15676
+ value: 'EQUAL_TO',
15626
15677
  label: '=',
15627
- tooltip: 'Equals'
15678
+ tooltip: 'EQUAL_TO'
15628
15679
  }, {
15629
15680
  value: 'EXISTS',
15630
15681
  label: /*#__PURE__*/React.createElement("span", null, "\u2203"),
@@ -18228,12 +18279,17 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18228
18279
  optionsToolbarRef: _this.optionsToolbarRef,
18229
18280
  onNoneOfTheseClick: _this.props.onNoneOfTheseClick,
18230
18281
  autoChartAggregations: _this.props.autoChartAggregations,
18282
+ enableQueryInterpretation: _this.props.enableQueryInterpretation,
18283
+ enableFilterLocking: _this.props.enableFilterLocking,
18231
18284
  reportProblemCallback: function reportProblemCallback() {
18232
18285
  if (_this.optionsToolbarRef) {
18233
18286
  _this.optionsToolbarRef.setState({
18234
18287
  activeMenu: 'other-problem'
18235
18288
  });
18236
18289
  }
18290
+ },
18291
+ onConditionClickCallback: function onConditionClickCallback() {
18292
+ _this.props.onConditionClickCallback();
18237
18293
  }
18238
18294
  }));
18239
18295
  }
@@ -18387,7 +18443,7 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18387
18443
  if (_this.props.type === 'text' || _this.state.displayType === 'html') {
18388
18444
  return undefined;
18389
18445
  } else if (chartHeight) {
18390
- return chartHeight + 40;
18446
+ return chartHeight + 120;
18391
18447
  }
18392
18448
 
18393
18449
  return '85%';
@@ -18408,23 +18464,6 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18408
18464
  }
18409
18465
  });
18410
18466
 
18411
- _defineProperty(_assertThisInitialized(_this), "renderLockedConditions", function () {
18412
- var response = _this.props.response;
18413
-
18414
- var numRows = _get(response, 'data.data.rows.length');
18415
-
18416
- var maxRowLimit = _get(response, 'data.data.row_limit');
18417
-
18418
- if (_get(response, 'data.data.persistent_locked_conditions.length') > 0) {
18419
- return /*#__PURE__*/React.createElement(Icon, {
18420
- type: "lock",
18421
- className: maxRowLimit && numRows === maxRowLimit && !_this.allColumnsAreHidden() ? 'condition-info-icon-left-align' : 'condition-info-icon',
18422
- "data-tip": response.data.data.persistent_locked_conditions,
18423
- "data-for": "chart-element-tooltip"
18424
- });
18425
- }
18426
- });
18427
-
18428
18467
  _defineProperty(_assertThisInitialized(_this), "render", function () {
18429
18468
  var _this$getChartDimensi2 = _this.getChartDimensions(),
18430
18469
  chartWidth = _this$getChartDimensi2.chartWidth,
@@ -18449,7 +18488,7 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18449
18488
  return !col.visible;
18450
18489
  }) || _this.allColumnsAreHidden() ? '400px' : undefined
18451
18490
  }
18452
- }, _this.renderContent(chartWidth, chartHeight), _this.props.isDataMessengerOpen && _this.renderRightToolbar(), _this.props.isDataMessengerOpen && _this.renderLeftToolbar(), _this.renderDataLimitWarning(), _this.renderLockedConditions())));
18491
+ }, _this.renderContent(chartWidth, chartHeight), _this.props.isDataMessengerOpen && _this.renderRightToolbar(), _this.props.isDataMessengerOpen && _this.renderLeftToolbar(), _this.renderDataLimitWarning())));
18453
18492
  });
18454
18493
 
18455
18494
  return _this;
@@ -18477,7 +18516,7 @@ _defineProperty(ChatMessage, "propTypes", (_defineProperty2 = {
18477
18516
  content: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({})]),
18478
18517
  tableOptions: PropTypes.shape({}),
18479
18518
  enableColumnVisibilityManager: PropTypes.bool
18480
- }, _defineProperty(_defineProperty2, "dataFormatting", dataFormattingType), _defineProperty(_defineProperty2, "onErrorCallback", PropTypes.func), _defineProperty(_defineProperty2, "onSuccessAlert", PropTypes.func), _defineProperty(_defineProperty2, "isResizing", PropTypes.bool), _defineProperty(_defineProperty2, "enableDynamicCharting", PropTypes.bool), _defineProperty(_defineProperty2, "scrollToBottom", PropTypes.func), _defineProperty(_defineProperty2, "onNoneOfTheseClick", PropTypes.func), _defineProperty(_defineProperty2, "autoChartAggregations", PropTypes.bool), _defineProperty2));
18519
+ }, _defineProperty(_defineProperty2, "dataFormatting", dataFormattingType), _defineProperty(_defineProperty2, "onErrorCallback", PropTypes.func), _defineProperty(_defineProperty2, "onSuccessAlert", PropTypes.func), _defineProperty(_defineProperty2, "isResizing", PropTypes.bool), _defineProperty(_defineProperty2, "enableDynamicCharting", PropTypes.bool), _defineProperty(_defineProperty2, "scrollToBottom", PropTypes.func), _defineProperty(_defineProperty2, "onNoneOfTheseClick", PropTypes.func), _defineProperty(_defineProperty2, "autoChartAggregations", PropTypes.bool), _defineProperty(_defineProperty2, "onConditionClickCallback", PropTypes.func), _defineProperty2));
18481
18520
 
18482
18521
  _defineProperty(ChatMessage, "defaultProps", {
18483
18522
  authentication: authenticationDefault,
@@ -18502,7 +18541,8 @@ _defineProperty(ChatMessage, "defaultProps", {
18502
18541
  enableDynamicCharting: true,
18503
18542
  autoChartAggregations: true,
18504
18543
  scrollToBottom: function scrollToBottom() {},
18505
- onNoneOfTheseClick: function onNoneOfTheseClick() {}
18544
+ onNoneOfTheseClick: function onNoneOfTheseClick() {},
18545
+ onConditionClickCallback: function onConditionClickCallback() {}
18506
18546
  });
18507
18547
 
18508
18548
  var QueryTipsTab = /*#__PURE__*/function (_React$Component) {
@@ -18808,11 +18848,22 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18808
18848
  inputValue: '',
18809
18849
  lastQuery: '',
18810
18850
  suggestions: [],
18811
- selectedConditions: []
18851
+ selectedConditions: [],
18852
+ isFetchingConditions: false,
18853
+ isShowingInfo: false,
18854
+ isShowingSettingInfo: false,
18855
+ showMessage: {
18856
+ type: 'unlock',
18857
+ message: 'filter removed'
18858
+ }
18812
18859
  });
18813
18860
 
18814
18861
  _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
18815
18862
  try {
18863
+ _this.setState({
18864
+ isFetchingConditions: true
18865
+ });
18866
+
18816
18867
  fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
18817
18868
  var conditions = _get(response, 'data.data.data');
18818
18869
 
@@ -18829,9 +18880,25 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18829
18880
  });
18830
18881
  }
18831
18882
 
18883
+ if (JSON.parse(sessionStorage.getItem("conditions")) !== null) {
18884
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
18885
+
18886
+ for (var _i = 0; _i < sessionConditions.length; _i++) {
18887
+ array.push({
18888
+ id: sessionConditions[_i].id,
18889
+ keyword: sessionConditions[_i].value,
18890
+ value: sessionConditions[_i].value,
18891
+ show_message: sessionConditions[_i].show_message,
18892
+ key: sessionConditions[_i].key,
18893
+ lock_flag: sessionConditions[_i].lock_flag
18894
+ });
18895
+ }
18896
+ }
18897
+
18832
18898
  _this.setState({
18833
- selectedConditions: array,
18834
- inputValue: ''
18899
+ selectedConditions: array.sort(),
18900
+ inputValue: '',
18901
+ isFetchingConditions: false
18835
18902
  });
18836
18903
  });
18837
18904
  } catch (error) {
@@ -18839,32 +18906,34 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18839
18906
  }
18840
18907
  });
18841
18908
 
18842
- _defineProperty(_assertThisInitialized(_this), "getSuggestions", function (value) {
18843
- var inputValue = value.trim().toLowerCase();
18844
- var inputLength = inputValue.length;
18845
- return inputLength === 0 ? [] : languages.filter(function (lang) {
18846
- return lang.name.toLowerCase().slice(0, inputLength) === inputValue;
18847
- });
18848
- });
18849
-
18850
18909
  _defineProperty(_assertThisInitialized(_this), "getSuggestionValue", function (suggestion) {
18851
18910
  var array = _this.state.selectedConditions;
18852
- array.push({
18853
- keyword: suggestion.name.keyword,
18854
- value: suggestion.name.keyword,
18855
- show_message: suggestion.name.show_message,
18856
- key: suggestion.name.canonical,
18857
- lock_flag: suggestion.name.lock_flag
18858
- });
18911
+ var tempId = uuid.v4();
18859
18912
 
18860
- _this.setState({
18861
- selectedConditions: array,
18862
- inputValue: ''
18863
- });
18864
- });
18913
+ if (array.some(function (item) {
18914
+ return item.key === suggestion.name.canonical && item.value === suggestion.name.keyword;
18915
+ })) {
18916
+ _this.handleShowMessage('warning', 'This condition has already been applied.');
18917
+ } else {
18918
+ array.push({
18919
+ id: tempId,
18920
+ keyword: suggestion.name.keyword,
18921
+ value: suggestion.name.keyword,
18922
+ show_message: suggestion.name.show_message,
18923
+ key: suggestion.name.canonical,
18924
+ lock_flag: 1 // persist by default
18865
18925
 
18866
- _defineProperty(_assertThisInitialized(_this), "renderSuggestion", function (suggestion) {
18867
- return /*#__PURE__*/React.createElement("div", null, _get(suggestion, 'name.keyword'));
18926
+ });
18927
+
18928
+ _this.setState({
18929
+ selectedConditions: array,
18930
+ inputValue: ''
18931
+ });
18932
+
18933
+ setConditions(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
18934
+ conditions: array
18935
+ }));
18936
+ }
18868
18937
  });
18869
18938
 
18870
18939
  _defineProperty(_assertThisInitialized(_this), "onInputChange", function (e) {
@@ -18881,27 +18950,62 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18881
18950
  });
18882
18951
 
18883
18952
  _defineProperty(_assertThisInitialized(_this), "removeCondition", function (item, index) {
18884
- var isSaved;
18885
- fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
18886
- _get(response, 'data.data.data').map(function (r) {
18887
- if (_includes(r, item.id)) {
18888
- isSaved = true;
18889
- }
18953
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
18954
+ var sessionIndex;
18955
+
18956
+ if (sessionConditions) {
18957
+ sessionIndex = sessionConditions.findIndex(function (condition) {
18958
+ return _get(condition, 'key') === _get(item, 'key');
18890
18959
  });
18960
+ }
18891
18961
 
18892
- if (isSaved) {
18893
- unsetCondition(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
18894
- condition: item
18895
- }));
18896
- }
18962
+ if (sessionIndex !== -1 && sessionIndex !== undefined && sessionIndex !== null) {
18963
+ sessionConditions.splice(sessionIndex, 1);
18964
+ sessionStorage.setItem('conditions', JSON.stringify(sessionConditions));
18965
+ } else {
18966
+ unsetCondition(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
18967
+ condition: item
18968
+ }));
18969
+ }
18970
+
18971
+ var array = _this.state.selectedConditions;
18972
+ array.splice(index, 1);
18973
+
18974
+ _this.setState({
18975
+ selectedConditions: array
18976
+ });
18977
+
18978
+ _this.handleShowMessage('unlock', 'Filter removed.');
18979
+ });
18980
+
18981
+ _defineProperty(_assertThisInitialized(_this), "handlePersistConditionToggle", function (item) {
18982
+ var index = _this.state.selectedConditions.findIndex(function (condition) {
18983
+ return condition.id === item.id;
18984
+ });
18897
18985
 
18898
- var array = _this.state.selectedConditions;
18899
- array.splice(index, 1);
18986
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
18900
18987
 
18988
+ if (index === -1) ; else {
18901
18989
  _this.setState({
18902
- selectedConditions: array
18990
+ selectedConditions: [].concat(_toConsumableArray(_this.state.selectedConditions.slice(0, index)), [Object.assign({}, _this.state.selectedConditions[index], item.lock_flag === 1 ? _this.state.selectedConditions[index].lock_flag = 0 : _this.state.selectedConditions[index].lock_flag = 1)], _toConsumableArray(_this.state.selectedConditions.slice(index + 1)))
18991
+ }, function () {
18992
+ setConditions(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
18993
+ conditions: _this.state.selectedConditions
18994
+ }));
18995
+
18996
+ if (item.lock_flag === 0) {
18997
+ if (sessionConditions == null) sessionConditions = [];
18998
+ sessionConditions.push(item);
18999
+ sessionStorage.setItem("conditions", JSON.stringify(sessionConditions));
19000
+ } else {
19001
+ var sessionIndex = sessionConditions.findIndex(function (condition) {
19002
+ return condition.id === item.id;
19003
+ });
19004
+ sessionConditions.splice(sessionIndex, 1);
19005
+ sessionStorage.setItem('conditions', JSON.stringify(sessionConditions));
19006
+ }
18903
19007
  });
18904
- });
19008
+ }
18905
19009
  });
18906
19010
 
18907
19011
  _defineProperty(_assertThisInitialized(_this), "onSuggestionsFetchRequested", function (_ref) {
@@ -18925,13 +19029,13 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18925
19029
  for (var i = 0; i < suggestionsMatchArray.length; i++) {
18926
19030
  sortingArray.push(suggestionsMatchArray[i]);
18927
19031
 
18928
- if (i === 4) {
19032
+ if (i === 5) {
18929
19033
  break;
18930
19034
  }
18931
19035
  }
18932
19036
 
18933
19037
  sortingArray.sort(function (a, b) {
18934
- return b.length - a.length;
19038
+ return a.keyword.toUpperCase() < b.keyword.toUpperCase() ? -1 : a.keyword > b.keyword ? 1 : 0;
18935
19039
  });
18936
19040
 
18937
19041
  for (var idx = 0; idx < sortingArray.length; idx++) {
@@ -18956,6 +19060,14 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18956
19060
  });
18957
19061
  });
18958
19062
 
19063
+ _defineProperty(_assertThisInitialized(_this), "renderShowMessage", function () {
19064
+ return /*#__PURE__*/React.createElement("div", {
19065
+ id: "react-autoql-condition-show-message"
19066
+ }, /*#__PURE__*/React.createElement(Icon, {
19067
+ type: _this.state.showMessage.type
19068
+ }), " ", _this.state.showMessage.message);
19069
+ });
19070
+
18959
19071
  _defineProperty(_assertThisInitialized(_this), "renderAcceptConditionsButton", function () {
18960
19072
  return /*#__PURE__*/React.createElement("div", {
18961
19073
  key: "accept-conditions-btn",
@@ -18986,72 +19098,136 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18986
19098
  style: {
18987
19099
  width: containerWidth
18988
19100
  }
18989
- }, /*#__PURE__*/React.createElement("div", {
19101
+ }, _this.renderShowMessage(), /*#__PURE__*/React.createElement("div", {
18990
19102
  className: "react-autoql-condition-lock-header"
18991
19103
  }, /*#__PURE__*/React.createElement("div", {
18992
- className: "autoql-condition-locking-menu-container"
18993
- }, /*#__PURE__*/React.createElement("button", {
19104
+ className: "react-autoql-filter-locking-title-container"
19105
+ }, /*#__PURE__*/React.createElement("h3", null, "Filter Locking ", ' ', /*#__PURE__*/React.createElement(Icon, {
19106
+ type: "info",
19107
+ onMouseEnter: function onMouseEnter() {
19108
+ return setTimeout(function () {
19109
+ _this.setState({
19110
+ isShowingInfo: true
19111
+ });
19112
+ }, 300);
19113
+ },
19114
+ onMouseLeave: function onMouseLeave() {
19115
+ return _this.setState({
19116
+ isShowingInfo: false
19117
+ });
19118
+ }
19119
+ })), /*#__PURE__*/React.createElement("button", {
18994
19120
  onClick: function onClick() {
18995
19121
  _this.props.onClose();
18996
19122
  },
18997
19123
  className: "autoql-close-button",
18998
- "data-tip": lang.closeConditionLocking,
19124
+ "data-tip": lang.closeFilterLocking,
18999
19125
  "data-for": "react-autoql-header-tooltip"
19000
19126
  }, /*#__PURE__*/React.createElement(Icon, {
19001
19127
  type: "close"
19002
- })), /*#__PURE__*/React.createElement(Autosuggest, {
19128
+ }))), /*#__PURE__*/React.createElement("div", {
19129
+ className: "autoql-condition-locking-menu-container"
19130
+ }, _this.state.isShowingInfo ? /*#__PURE__*/React.createElement("div", {
19131
+ className: "react-autoql-filter-locking-empty-list"
19132
+ }, /*#__PURE__*/React.createElement(Icon, {
19133
+ type: "info"
19134
+ }), /*#__PURE__*/React.createElement("p", null, "Filters can be applied to narrow down your query results. Locking a filter ensures that only the specific data you wish to see is returned.")) : null, /*#__PURE__*/React.createElement(Autosuggest, {
19003
19135
  ref: function ref(_ref2) {
19004
19136
  _this.autoSuggest = _ref2;
19005
19137
  },
19138
+ highlightFirstSuggestion: true,
19006
19139
  suggestions: _this.state.suggestions,
19007
19140
  onSuggestionsFetchRequested: _this.onSuggestionsFetchRequested,
19008
19141
  onSuggestionsClearRequested: _this.onSuggestionsClearRequested,
19009
19142
  getSuggestionValue: _this.getSuggestionValue,
19010
19143
  renderSuggestion: function renderSuggestion(suggestion) {
19011
- return /*#__PURE__*/React.createElement(Fragment, null, suggestion.name.keyword);
19144
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("table", {
19145
+ className: "autoql-condition-locking-menu-list"
19146
+ }, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
19147
+ style: {
19148
+ width: 300
19149
+ }
19150
+ }, suggestion.name.keyword), /*#__PURE__*/React.createElement("td", null, suggestion.name.show_message)))));
19012
19151
  },
19013
19152
  inputProps: {
19014
19153
  onChange: _this.onInputChange,
19015
19154
  value: _this.state.inputValue,
19016
- placeholder: 'Search for a condition.',
19155
+ disabled: _this.state.isFetchingConditions,
19156
+ placeholder: 'Search & select a filter',
19017
19157
  className: 'react-autoql-condition-locking-input'
19018
19158
  }
19019
- }))), /*#__PURE__*/React.createElement("div", {
19159
+ }), _this.state.isShowingSettingInfo ? /*#__PURE__*/React.createElement("div", {
19160
+ className: "react-autoql-filter-setting-info-card"
19161
+ }, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(Icon, {
19162
+ type: "info"
19163
+ }), ' ', /*#__PURE__*/React.createElement("strong", null, "Persistent"), " filters remain locked at all times, unless the filter is removed.", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Icon, {
19164
+ type: "info"
19165
+ }), ' ', /*#__PURE__*/React.createElement("strong", null, "Session"), " filters remain locked until you end your browser session.")) : null)), _this.state.isFetchingConditions ? /*#__PURE__*/React.createElement("div", {
19166
+ className: "condition-list-loading-container"
19167
+ }, /*#__PURE__*/React.createElement(LoadingDots, null)) : /*#__PURE__*/React.createElement("div", {
19020
19168
  className: "condition-list"
19021
19169
  }, _get(_this.state.selectedConditions, 'length') === 0 ? /*#__PURE__*/React.createElement("div", {
19022
19170
  className: "empty-condition-list"
19023
- }, /*#__PURE__*/React.createElement("p", null, "Condition locking is a tool to help you track a condition across many queries. This is useful if you want to focus on a specific location or timeframe but don't want to have to type it out for every query."), /*#__PURE__*/React.createElement("p", null, "You currently have no conditions locked. Use the search bar to find a condition you would like to track.")) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
19171
+ }, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("i", null, lang.noFiltersLocked))) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
19024
19172
  style: {
19025
- minHeight: 100
19173
+ minHeight: 150
19026
19174
  }
19027
19175
  }, /*#__PURE__*/React.createElement("table", {
19028
19176
  className: "condition-table"
19029
19177
  }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("th", {
19030
19178
  scope: "col"
19031
- }, "Condition"), /*#__PURE__*/React.createElement("th", {
19032
- scope: "col"
19033
- }, "Category"), /*#__PURE__*/React.createElement("th", {
19179
+ }, "Filter"), /*#__PURE__*/React.createElement("th", {
19180
+ scope: "col",
19181
+ style: {
19182
+ minWidth: 154
19183
+ }
19184
+ }, "Settings", /*#__PURE__*/React.createElement(Icon, {
19185
+ type: "info",
19186
+ onMouseEnter: function onMouseEnter() {
19187
+ return setTimeout(function () {
19188
+ _this.setState({
19189
+ isShowingSettingInfo: true
19190
+ });
19191
+ }, 300);
19192
+ },
19193
+ onMouseLeave: function onMouseLeave() {
19194
+ return _this.setState({
19195
+ isShowingSettingInfo: false
19196
+ });
19197
+ }
19198
+ })), /*#__PURE__*/React.createElement("th", {
19034
19199
  scope: "col",
19035
19200
  style: {
19036
19201
  display: 'table-cell',
19037
19202
  verticalAlign: 'middle',
19038
19203
  textAlign: 'right'
19039
19204
  }
19040
- }, "Actions")), /*#__PURE__*/React.createElement("tbody", null, _this.state.selectedConditions.map(function (item, index) {
19205
+ })), /*#__PURE__*/React.createElement("tbody", null, _this.state.selectedConditions.map(function (item, index) {
19041
19206
  return /*#__PURE__*/React.createElement("tr", {
19042
19207
  key: index
19043
- }, /*#__PURE__*/React.createElement("td", null, item.keyword), /*#__PURE__*/React.createElement("td", null, item.show_message), /*#__PURE__*/React.createElement("td", {
19208
+ }, /*#__PURE__*/React.createElement("td", {
19209
+ className: "condition-table-list-item"
19210
+ }, item.keyword, ' ', "(".concat(item.show_message, ")")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Switch, {
19211
+ onChange: function onChange() {
19212
+ return _this.handlePersistConditionToggle(item, index);
19213
+ },
19214
+ checked: item.lock_flag,
19215
+ onColor: "#86d3ff",
19216
+ onHandleColor: "#2693e6",
19217
+ uncheckedIcon: false,
19218
+ checkedIcon: false,
19219
+ boxShadow: "0px 1px 5px rgba(0, 0, 0, 0.6)",
19220
+ activeBoxShadow: "0px 0px 1px 1px rgba(0, 0, 0, 0.2)",
19221
+ handleDiameter: 16,
19222
+ height: 18,
19223
+ width: 34
19224
+ }), ' ', item.lock_flag ? 'Persistent' : 'Session')), /*#__PURE__*/React.createElement("td", {
19044
19225
  style: {
19045
19226
  display: 'table-cell',
19046
19227
  verticalAlign: 'middle',
19047
19228
  textAlign: 'right'
19048
19229
  }
19049
19230
  }, /*#__PURE__*/React.createElement(ReactTooltip, {
19050
- className: "react-autoql-chart-tooltip",
19051
- id: "condition-lock-persist",
19052
- effect: "solid",
19053
- html: true
19054
- }), /*#__PURE__*/React.createElement(ReactTooltip, {
19055
19231
  className: "react-autoql-chart-tooltip",
19056
19232
  id: "react-autoql-remove-condition",
19057
19233
  effect: "solid",
@@ -19061,24 +19237,54 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
19061
19237
  paddingLeft: 5,
19062
19238
  color: 'red'
19063
19239
  },
19064
- "data-tip": "Remove this condition",
19240
+ "data-tip": "Remove filter",
19065
19241
  "data-for": "react-autoql-remove-condition",
19066
19242
  type: "trash",
19067
19243
  onClick: function onClick() {
19068
19244
  return _this.removeCondition(item, index);
19069
19245
  }
19070
19246
  })));
19071
- })), /*#__PURE__*/React.createElement("tfoot", null)))), _this.renderAcceptConditionsButton())));
19247
+ })), /*#__PURE__*/React.createElement("tfoot", null))))), /*#__PURE__*/React.createElement("div", {
19248
+ className: "react-autoql-condition-lock-menu-footer"
19249
+ }, /*#__PURE__*/React.createElement(Button, {
19250
+ size: "small",
19251
+ disabled: _this.state.isFetchingConditions,
19252
+ onClick: function onClick() {
19253
+ _this.props.onClose();
19254
+ }
19255
+ }, "Continue"))));
19072
19256
  });
19073
19257
 
19074
19258
  return _this;
19075
19259
  }
19076
19260
 
19261
+ _createClass(ConditionLockMenu, [{
19262
+ key: "handleShowMessage",
19263
+ value: function handleShowMessage(type, message) {
19264
+ var el = document.getElementById('react-autoql-condition-show-message');
19265
+ el.className = 'show';
19266
+ el.style.animation = 'none';
19267
+ setTimeout(function () {
19268
+ el.style.animation = '';
19269
+ }, 10);
19270
+ setTimeout(function () {
19271
+ el.className = el.className.replace('show', '');
19272
+ }, 3000);
19273
+ this.setState({
19274
+ inputValue: '',
19275
+ showMessage: {
19276
+ type: type,
19277
+ message: message
19278
+ }
19279
+ });
19280
+ }
19281
+ }]);
19282
+
19077
19283
  return ConditionLockMenu;
19078
19284
  }(React.Component);
19079
19285
 
19080
19286
  _defineProperty(ConditionLockMenu, "propTypes", {
19081
- containerWidth: PropTypes.string,
19287
+ containerWidth: PropTypes.number,
19082
19288
  isOpen: PropTypes.bool,
19083
19289
  onClose: PropTypes.func,
19084
19290
  authentication: authenticationType
@@ -19145,11 +19351,20 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19145
19351
  } // WIP
19146
19352
 
19147
19353
 
19148
- fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
19149
- _this.setState({
19150
- conditions: _get(response, 'data.data.data')
19354
+ try {
19355
+ fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
19356
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
19357
+
19358
+ _this.setState({
19359
+ conditions: {
19360
+ persistent: _get(response, 'data.data.data'),
19361
+ session: sessionConditions
19362
+ }
19363
+ });
19151
19364
  });
19152
- });
19365
+ } catch (e) {
19366
+ console.error(e);
19367
+ }
19153
19368
  });
19154
19369
 
19155
19370
  _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (prevProps, prevState) {
@@ -19179,6 +19394,25 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19179
19394
  if (thisTheme && thisTheme !== prevTheme) {
19180
19395
  setCSSVars(getThemeConfig(getThemeConfig(_this.props.themeConfig)));
19181
19396
  }
19397
+
19398
+ if (_this.state.isConditionLockingMenuOpen !== prevState.isConditionLockingMenuOpen) {
19399
+ fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
19400
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
19401
+
19402
+ _this.setState({
19403
+ conditions: {
19404
+ persistent: _get(response, 'data.data.data'),
19405
+ session: sessionConditions
19406
+ }
19407
+ });
19408
+ });
19409
+ }
19410
+
19411
+ if (_this.state.activePage !== prevState.activePage) {
19412
+ _this.setState({
19413
+ isConditionLockingMenuOpen: false
19414
+ });
19415
+ }
19182
19416
  } catch (error) {
19183
19417
  console.error(error);
19184
19418
 
@@ -19360,6 +19594,10 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19360
19594
 
19361
19595
  if (_this.props.onMaskClick) {
19362
19596
  _this.props.onMaskClick();
19597
+
19598
+ _this.setState({
19599
+ isConditionLockingMenuOpen: false
19600
+ });
19363
19601
  }
19364
19602
 
19365
19603
  if (_this.props.onHandleClick) {
@@ -19733,6 +19971,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19733
19971
  },
19734
19972
  overflowCount: 9,
19735
19973
  useDot: true,
19974
+ isAlreadyMountedInDOM: /*#__PURE__*/React.isValidElement( /*#__PURE__*/React.createElement(NotificationIcon, null)),
19736
19975
  onNewNotification: function onNewNotification() {
19737
19976
  // If a new notification is detected, refresh the list
19738
19977
  if (_this.notificationListRef && _this.state.activePage === 'notifications') {
@@ -19753,7 +19992,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19753
19992
  position: 'absolute',
19754
19993
  right: 30
19755
19994
  }
19756
- }, window.location.href.includes('localhost') || window.location.href.includes('chata-ai-test-page') ? /*#__PURE__*/React.createElement("button", {
19995
+ }, getAutoQLConfig$1(getAutoQLConfig$1(_this.props.autoQLConfig)).enableFilterLocking ? /*#__PURE__*/React.createElement("button", {
19757
19996
  id: "condition-dropdown",
19758
19997
  onClick: function onClick() {
19759
19998
  _this.setState({
@@ -19761,10 +20000,10 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19761
20000
  });
19762
20001
  },
19763
20002
  className: "react-autoql-drawer-header-btn clear-all",
19764
- "data-tip": lang.dataMessengerOptions,
20003
+ "data-tip": lang.openFilterLocking,
19765
20004
  "data-for": "react-autoql-header-tooltip"
19766
20005
  }, /*#__PURE__*/React.createElement(Icon, {
19767
- type: _get(_this.state.conditions, 'length') > 0 ? "lock" : "unlock"
20006
+ type: _get(_this.state.conditions, 'persistent.length') > 0 || _get(_this.state.conditions, 'session.length') > 0 ? "lock" : "unlock"
19768
20007
  })) : /*#__PURE__*/React.createElement("span", null)), /*#__PURE__*/React.createElement(Popover, {
19769
20008
  isOpen: _this.state.isOptionsDropdownOpen,
19770
20009
  onClickOutside: function onClickOutside() {
@@ -19812,7 +20051,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19812
20051
  });
19813
20052
  },
19814
20053
  className: "react-autoql-drawer-header-btn clear-all",
19815
- "data-tip": lang.dataMessengerOptions,
20054
+ "data-tip": lang.clearDataResponses,
19816
20055
  "data-for": "react-autoql-header-tooltip"
19817
20056
  }, /*#__PURE__*/React.createElement(Icon, {
19818
20057
  type: "trash"
@@ -19840,14 +20079,6 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19840
20079
  }, title);
19841
20080
  });
19842
20081
 
19843
- _defineProperty(_assertThisInitialized(_this), "renderShowSuccessMessage", function () {
19844
- return /*#__PURE__*/React.createElement("div", {
19845
- id: "condition-lock-snackbar-success"
19846
- }, /*#__PURE__*/React.createElement(Icon, {
19847
- type: "check"
19848
- }), " Conditions Applied");
19849
- });
19850
-
19851
20082
  _defineProperty(_assertThisInitialized(_this), "renderHeaderContent", function () {
19852
20083
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
19853
20084
  className: "react-autoql-header-left-container"
@@ -19864,7 +20095,9 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19864
20095
  "data-for": "react-autoql-header-tooltip"
19865
20096
  }, /*#__PURE__*/React.createElement(Icon, {
19866
20097
  type: "close"
19867
- }))), /*#__PURE__*/React.createElement(Popover, {
20098
+ }))), !getAutoQLConfig$1(getAutoQLConfig$1(_this.props.autoQLConfig)).enableFilterLocking ? /*#__PURE__*/React.createElement("div", {
20099
+ className: "react-autoql-header-center-container"
20100
+ }, _this.renderHeaderTitle()) : /*#__PURE__*/React.createElement(Popover, {
19868
20101
  containerStyle: _this.getConditionMenuPosition(),
19869
20102
  isOpen: _this.state.isConditionLockingMenuOpen,
19870
20103
  position: "bottom",
@@ -19879,15 +20112,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19879
20112
  authentication: getAuthentication(getAuthentication(_this.props.authentication)),
19880
20113
  containerWidth: _this.getDrawerWidth(),
19881
20114
  isOpen: _this.state.isConditionLockingMenuOpen,
19882
- onClose: function onClose(isSaved) {
19883
- if (isSaved) {
19884
- var el = document.getElementById('condition-lock-snackbar-success');
19885
- el.className = 'show';
19886
- setTimeout(function () {
19887
- el.className = el.className.replace('show', '');
19888
- }, 3000);
19889
- }
19890
-
20115
+ onClose: function onClose() {
19891
20116
  _this.setState({
19892
20117
  isConditionLockingMenuOpen: false
19893
20118
  });
@@ -19895,7 +20120,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19895
20120
  }))
19896
20121
  }, /*#__PURE__*/React.createElement("div", {
19897
20122
  className: "react-autoql-header-center-container"
19898
- }, _this.renderHeaderTitle(), _this.renderShowSuccessMessage())), /*#__PURE__*/React.createElement("div", {
20123
+ }, _this.renderHeaderTitle())), /*#__PURE__*/React.createElement("div", {
19899
20124
  className: "react-autoql-header-right-container"
19900
20125
  }, _this.renderOptionsDropdown()));
19901
20126
  });
@@ -19978,7 +20203,12 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19978
20203
  isResizing: _this.state.isResizing,
19979
20204
  enableDynamicCharting: _this.props.enableDynamicCharting,
19980
20205
  onNoneOfTheseClick: _this.onNoneOfTheseClick,
19981
- autoChartAggregations: _this.props.autoChartAggregations
20206
+ autoChartAggregations: _this.props.autoChartAggregations,
20207
+ onConditionClickCallback: function onConditionClickCallback() {
20208
+ _this.setState({
20209
+ isConditionLockingMenuOpen: !_this.state.isConditionLockingMenuOpen
20210
+ });
20211
+ }
19982
20212
  });
19983
20213
  })), _this.state.isChataThinking && /*#__PURE__*/React.createElement("div", {
19984
20214
  className: "response-loading-container"
@@ -20380,6 +20610,36 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
20380
20610
  });
20381
20611
  }
20382
20612
  }
20613
+ }, {
20614
+ key: "removeDuplicateMessengerInstance",
20615
+ value:
20616
+ /**
20617
+ * For some indiscernible reason, the Data Messenger drawer duplicates itself in the DOM.
20618
+ * three times when first opened, then a number more times with each and every query
20619
+ * being made.
20620
+ *
20621
+ * This function removes unnecessary duplicate instances of the Data Messenger Drawer
20622
+ * and should help improve performance a bit by reducing the amount of renders.
20623
+ *
20624
+ * https://stackoverflow.com/questions/57946748/remove-duplicate-dom-element-javascript-not-jquery
20625
+ */
20626
+ function removeDuplicateMessengerInstance() {
20627
+ var instance = {};
20628
+
20629
+ var _iterator = _createForOfIteratorHelper(document.querySelectorAll('.ReactModalPortal')),
20630
+ _step;
20631
+
20632
+ try {
20633
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
20634
+ var item = _step.value;
20635
+ if (instance[item]) item.parentNode.removeChild(item);else instance[item] = true;
20636
+ }
20637
+ } catch (err) {
20638
+ _iterator.e(err);
20639
+ } finally {
20640
+ _iterator.f();
20641
+ }
20642
+ }
20383
20643
  }]);
20384
20644
 
20385
20645
  return DataMessenger;
@@ -20415,6 +20675,9 @@ _defineProperty(DataMessenger, "propTypes", {
20415
20675
  enableDynamicCharting: bool,
20416
20676
  defaultTab: string,
20417
20677
  autoChartAggregations: bool,
20678
+ enableQueryInterpretation: bool,
20679
+ defaultShowInterpretation: bool,
20680
+ enableFilterLocking: bool,
20418
20681
  // Callbacks
20419
20682
  onVisibleChange: func,
20420
20683
  onHandleClick: func,
@@ -20452,6 +20715,9 @@ _defineProperty(DataMessenger, "defaultProps", {
20452
20715
  enableDynamicCharting: true,
20453
20716
  defaultTab: 'data-messenger',
20454
20717
  autoChartAggregations: true,
20718
+ enableQueryInterpretation: false,
20719
+ defaultShowInterpretation: false,
20720
+ enableFilterLocking: false,
20455
20721
  // Callbacks
20456
20722
  onHandleClick: function onHandleClick() {},
20457
20723
  onVisibleChange: function onVisibleChange() {},
@@ -21331,6 +21597,7 @@ var DashboardTile = /*#__PURE__*/function (_React$Component) {
21331
21597
  renderSuggestionsAsDropdown: _this.props.tile.h < 4,
21332
21598
  enableDynamicCharting: _this.props.enableDynamicCharting,
21333
21599
  backgroundColor: document.documentElement.style.getPropertyValue('--react-autoql-background-color-primary'),
21600
+ isDashboardQuery: true,
21334
21601
  onDisplayTypeUpdate: function onDisplayTypeUpdate() {
21335
21602
  // This is necessary to update the toolbar with the newly rendered QueryOutput
21336
21603
  setTimeout(function () {
@@ -21974,6 +22241,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
21974
22241
  dataFormatting: getDataFormatting(_this.props.dataFormatting),
21975
22242
  queryResponse: _this.state.activeDrilldownResponse,
21976
22243
  renderTooltips: false,
22244
+ isDashboardQuery: true,
21977
22245
  autoChartAggregations: _this.props.autoChartAggregations,
21978
22246
  backgroundColor: document.documentElement.style.getPropertyValue('--react-autoql-background-color-primary'),
21979
22247
  reportProblemCallback: _this.reportProblemCallback,
@@ -21995,6 +22263,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
21995
22263
  dataFormatting: getDataFormatting(_this.props.dataFormatting),
21996
22264
  queryResponse: _this.state.activeDrilldownResponse,
21997
22265
  renderTooltips: false,
22266
+ isDashboardQuery: true,
21998
22267
  autoChartAggregations: _this.props.autoChartAggregations,
21999
22268
  backgroundColor: document.documentElement.style.getPropertyValue('--react-autoql-background-color-primary'),
22000
22269
  reportProblemCallback: _this.reportProblemCallback,
@@ -22053,7 +22322,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
22053
22322
  displayType = tile.secondDisplayType;
22054
22323
  dataConfig = tile.secondDataConfig;
22055
22324
  } else if (tile && !_this.state.isDrilldownSecondHalf) {
22056
- title = tile.query;
22325
+ title = tile.title;
22057
22326
  queryResponse = tile.queryResponse;
22058
22327
  displayType = tile.displayType;
22059
22328
  dataConfig = tile.dataConfig;
@@ -22092,6 +22361,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
22092
22361
  queryResponse: queryResponse,
22093
22362
  displayType: displayType,
22094
22363
  dataConfig: dataConfig,
22364
+ isDashboardQuery: true,
22095
22365
  autoChartAggregations: _this.props.autoChartAggregations,
22096
22366
  onDataClick: function onDataClick(drilldownData, queryID) {
22097
22367
  _this.startDrilldown(drilldownData, queryID, tile.i);
@@ -22272,4 +22542,215 @@ _defineProperty(Dashboard, "defaultProps", {
22272
22542
  onChange: function onChange() {}
22273
22543
  });
22274
22544
 
22545
+ var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
22546
+ _inherits(SpeechToTextBtn, _React$Component);
22547
+
22548
+ var _super = _createSuper(SpeechToTextBtn);
22549
+
22550
+ function SpeechToTextBtn() {
22551
+ var _this;
22552
+
22553
+ _classCallCheck(this, SpeechToTextBtn);
22554
+
22555
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22556
+ args[_key] = arguments[_key];
22557
+ }
22558
+
22559
+ _this = _super.call.apply(_super, [this].concat(args));
22560
+
22561
+ _defineProperty(_assertThisInitialized(_this), "state", {
22562
+ isRecording: false,
22563
+ currentQuery: 0,
22564
+ resultHistory: [],
22565
+ currentFile: '',
22566
+ currentBlob: '',
22567
+ showPopoverMessage: false,
22568
+ errorMessage: ''
22569
+ });
22570
+
22571
+ _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
22572
+ setCSSVars(getThemeConfig(_this.props.themeConfig));
22573
+ });
22574
+
22575
+ _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (prevProps) {
22576
+ if (_this.props.finalTranscript !== prevProps.finalTranscript) {
22577
+ _this.props.onFinalTranscript(_this.props.finalTranscript);
22578
+ } else if (_this.props.transcript !== prevProps.transcript) {
22579
+ _this.props.onTranscriptChange(_this.props.transcript);
22580
+ } else if (_this.props.interimTranscript !== prevProps.interimTranscript) {
22581
+ _this.props.onTranscriptChange(_this.props.interimTranscript);
22582
+ }
22583
+ });
22584
+
22585
+ _defineProperty(_assertThisInitialized(_this), "startRecording", function () {
22586
+ _this.setState({
22587
+ isRecording: true
22588
+ });
22589
+
22590
+ navigator.getUserMedia({
22591
+ audio: true
22592
+ }, function (stream) {
22593
+ _this.stream = stream;
22594
+ _this.recordAudio = RecordRTC(_this.stream, {
22595
+ type: 'audio',
22596
+ mimeType: 'audio/webm',
22597
+ desiredSampRate: 16000,
22598
+ recorderType: StereoAudioRecorder,
22599
+ numberOfAudioChannels: 1
22600
+ });
22601
+
22602
+ _this.recordAudio.startRecording();
22603
+ }, function (error) {
22604
+ console.error(JSON.stringify(error));
22605
+ });
22606
+ });
22607
+
22608
+ _defineProperty(_assertThisInitialized(_this), "onRecordStop", function (file, blob) {
22609
+ _this.setState({
22610
+ // isConfirmingRecording: true,
22611
+ currentFile: file,
22612
+ currentBlob: blob //hasPlayedBack: false,
22613
+
22614
+ }, function () {
22615
+ _this.sendWavFile(file);
22616
+ });
22617
+ });
22618
+
22619
+ _defineProperty(_assertThisInitialized(_this), "stopRecording", function () {
22620
+ _this.setState({
22621
+ isRecording: false
22622
+ });
22623
+
22624
+ _this.recordAudio.stopRecording(function () {
22625
+ var blob = _this.recordAudio.getBlob();
22626
+
22627
+ _this.onRecordStop(_this.blobToFile(blob), blob);
22628
+
22629
+ try {
22630
+ _this.stream.getTracks().forEach(function (track) {
22631
+ return track.stop();
22632
+ });
22633
+ } catch (error) {
22634
+ console.error(error);
22635
+ }
22636
+ });
22637
+ });
22638
+
22639
+ _defineProperty(_assertThisInitialized(_this), "blobToFile", function (theBlob) {
22640
+ //A Blob() is almost a File() - it's just missing the two properties below which we will add
22641
+ theBlob.lastModifiedDate = new Date();
22642
+ theBlob.name = 'speech.wav';
22643
+ return theBlob;
22644
+ });
22645
+
22646
+ _defineProperty(_assertThisInitialized(_this), "getMediaPermissionStatus", function () {
22647
+ return navigator.permissions.query({
22648
+ name: 'microphone'
22649
+ }).then(function (permissionStatus) {
22650
+ return permissionStatus.state;
22651
+ });
22652
+ });
22653
+
22654
+ _defineProperty(_assertThisInitialized(_this), "onMouseDown", function () {
22655
+ ReactTooltip.hide();
22656
+
22657
+ _this.startRecording();
22658
+ });
22659
+
22660
+ _defineProperty(_assertThisInitialized(_this), "sendWavFile", function (file) {
22661
+ var url = "".concat(_this.props.authentication.domain, "/autoql/api/v1/query/speech-to-text?key=").concat(_this.props.authentication.apiKey);
22662
+ var data = new FormData();
22663
+ data.append('file', file, 'speech.wav');
22664
+ var config = {
22665
+ headers: {
22666
+ Authorization: "Bearer ".concat(_this.props.authentication.token)
22667
+ },
22668
+ timeout: 30000
22669
+ };
22670
+ axios.post(url, data, config).then(function (res) {
22671
+ _this.props.onTranscriptChange(res.data.data.transcription);
22672
+ }).catch(function (error) {
22673
+ if (error.response.status === 404) {
22674
+ _this.setState({
22675
+ errorMessage: 'Oops! Speech-to-text has not been enabled. Try typing a query instead.'
22676
+ }, function () {
22677
+ _this.setState({
22678
+ showPopoverMessage: true
22679
+ });
22680
+ });
22681
+ } else {
22682
+ _this.setState({
22683
+ errorMessage: 'Oops! Something wrong with your account'
22684
+ }, function () {
22685
+ _this.setState({
22686
+ showPopoverMessage: true
22687
+ });
22688
+ });
22689
+ }
22690
+ });
22691
+ });
22692
+
22693
+ _defineProperty(_assertThisInitialized(_this), "render", function () {
22694
+ return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Popover, {
22695
+ isOpen: _this.state.showPopoverMessage,
22696
+ padding: 20,
22697
+ content: function content() {
22698
+ return /*#__PURE__*/React.createElement("div", {
22699
+ style: {
22700
+ backgroundColor: '#FFD2D2',
22701
+ opacity: 1,
22702
+ paddingLeft: '10px',
22703
+ paddingRight: '10px'
22704
+ }
22705
+ }, /*#__PURE__*/React.createElement(Icon, {
22706
+ type: "warning-triangle"
22707
+ }), " ", _this.state.errorMessage);
22708
+ },
22709
+ onClickOutside: function onClickOutside() {
22710
+ return _this.setState({
22711
+ showPopoverMessage: false
22712
+ });
22713
+ }
22714
+ }, /*#__PURE__*/React.createElement("button", {
22715
+ id: "react-autoql-voice-record-button",
22716
+ "data-test": "speech-to-text-btn",
22717
+ className: "chat-voice-record-button".concat(_this.state.isRecording ? ' listening' : ''),
22718
+ onMouseDown: _this.onMouseDown,
22719
+ onMouseUp: _this.stopRecording,
22720
+ onMouseLeave: _this.state.isRecording ? _this.stopRecording : undefined,
22721
+ "data-tip": "Hold for voice-to-text",
22722
+ "data-for": "react-autoql-speech-to-text-tooltip",
22723
+ "data-tip-disable": _this.state.isRecording
22724
+ }, /*#__PURE__*/React.createElement(Icon, {
22725
+ type: "microphone"
22726
+ }))), /*#__PURE__*/React.createElement(ReactTooltip, {
22727
+ className: "react-autoql-tooltip",
22728
+ id: "react-autoql-speech-to-text-tooltip",
22729
+ effect: "solid",
22730
+ delayShow: 800
22731
+ }));
22732
+ });
22733
+
22734
+ return _this;
22735
+ }
22736
+
22737
+ return SpeechToTextBtn;
22738
+ }(React.Component);
22739
+
22740
+ _defineProperty(SpeechToTextBtn, "propTypes", {
22741
+ authentication: authenticationType,
22742
+ themeConfig: themeConfigType,
22743
+ transcript: PropTypes.string,
22744
+ interimTranscript: PropTypes.string,
22745
+ finalTranscript: PropTypes.string,
22746
+ resetTranscript: PropTypes.func,
22747
+ onTranscriptChange: PropTypes.func,
22748
+ onFinalTranscript: PropTypes.func
22749
+ });
22750
+
22751
+ _defineProperty(SpeechToTextBtn, "defaultProps", {
22752
+ authentication: authenticationDefault,
22753
+ themeConfig: themeConfigDefault
22754
+ });
22755
+
22275
22756
  export { Dashboard, DashboardTile, DataAlertModal, DataAlerts, DataMessenger, ExpressionBuilder, ExpressionBuilderSimple, Icon, LoadingDots, NotificationFeed, NotificationIcon, NotificationItem, QueryInput, QueryOutput, ScheduleBuilder, SpeechToTextBtn as SpeechToTextButton, SpeechToTextButtonBrowser, executeDashboard, fetchQueryTips, getDefaultDisplayType, getSupportedDisplayTypes, isDisplayTypeValid, unExecuteDashboard };