react-autoql 3.4.9 → 3.5.2

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,7 +6,8 @@ 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 React, { Fragment, Component } from 'react';
9
+ import _$1 from 'lodash';
10
+ import React, { Fragment, Component, createRef } 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';
12
13
  import { BsArrowBarDown, BsArrowBarUp } from 'react-icons/bs';
@@ -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,11 @@ 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';
50
51
  import _has from 'lodash.has';
51
52
  import { Scrollbars } from 'react-custom-scrollbars';
52
53
  import LocalizedStrings from 'react-localization';
53
54
  import 'rc-drawer/assets/index.css';
55
+ import Switch from 'react-switch';
54
56
  import sqlFormatter from 'sql-formatter';
55
57
  import ReactPaginate from 'react-paginate';
56
58
  import RGL, { WidthProvider } from 'react-grid-layout';
@@ -354,6 +356,63 @@ function _nonIterableSpread() {
354
356
  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
357
  }
356
358
 
359
+ function _createForOfIteratorHelper(o, allowArrayLike) {
360
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
361
+
362
+ if (!it) {
363
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
364
+ if (it) o = it;
365
+ var i = 0;
366
+
367
+ var F = function () {};
368
+
369
+ return {
370
+ s: F,
371
+ n: function () {
372
+ if (i >= o.length) return {
373
+ done: true
374
+ };
375
+ return {
376
+ done: false,
377
+ value: o[i++]
378
+ };
379
+ },
380
+ e: function (e) {
381
+ throw e;
382
+ },
383
+ f: F
384
+ };
385
+ }
386
+
387
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
388
+ }
389
+
390
+ var normalCompletion = true,
391
+ didErr = false,
392
+ err;
393
+ return {
394
+ s: function () {
395
+ it = it.call(o);
396
+ },
397
+ n: function () {
398
+ var step = it.next();
399
+ normalCompletion = step.done;
400
+ return step;
401
+ },
402
+ e: function (e) {
403
+ didErr = true;
404
+ err = e;
405
+ },
406
+ f: function () {
407
+ try {
408
+ if (!normalCompletion && it.return != null) it.return();
409
+ } finally {
410
+ if (didErr) throw err;
411
+ }
412
+ }
413
+ };
414
+ }
415
+
357
416
  var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
358
417
  _inherits(ErrorBoundary, _React$Component);
359
418
 
@@ -473,6 +532,8 @@ var autoQLConfigDefault = {
473
532
  debug: false,
474
533
  test: false,
475
534
  enableAutocomplete: true,
535
+ enableQueryInterpretation: true,
536
+ defaultShowInterpretation: false,
476
537
  enableQueryValidation: true,
477
538
  enableQuerySuggestions: true,
478
539
  enableColumnVisibilityManager: true,
@@ -1659,8 +1720,10 @@ var lang = new LocalizedStrings({
1659
1720
  queryPrompt: 'Type your queries here ',
1660
1721
  seeMore: 'See more',
1661
1722
  dataMessengerOptions: 'Options menu',
1662
- openConditionLocking: 'Open condition locking menu',
1663
- closeConditionLocking: 'Close condition locking menu',
1723
+ openFilterLocking: 'Manage Filters',
1724
+ closeFilterLocking: 'Close filter menu',
1725
+ filterLockingTitle: 'Filter Locking',
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,10 @@ 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: 'Administrar filtros',
1764
+ closeFilterLocking: 'Cerrar menú de filtrar',
1765
+ filterLockingTitle: 'Menú de Filtro',
1766
+ noFiltersLocked: 'Ningún filtro está bloqueado todavía',
1702
1767
  clearDataResponses: 'Borrar todas las consultas y respuestas',
1703
1768
  closeDataMessenger: 'Cerrar Data mesenger',
1704
1769
  searchQueries: 'Buscar consultas relevantes por tema',
@@ -2178,6 +2243,18 @@ var Icon = /*#__PURE__*/function (_React$Component) {
2178
2243
  break;
2179
2244
  }
2180
2245
 
2246
+ case 'caret-down':
2247
+ {
2248
+ icon = /*#__PURE__*/React.createElement(AiFillCaretDown, null);
2249
+ break;
2250
+ }
2251
+
2252
+ case 'caret-up':
2253
+ {
2254
+ icon = /*#__PURE__*/React.createElement(AiFillCaretUp, null);
2255
+ break;
2256
+ }
2257
+
2181
2258
  case 'react-autoql-bubbles':
2182
2259
  {
2183
2260
  icon = /*#__PURE__*/React.createElement("img", {
@@ -2726,12 +2803,37 @@ var runQueryOnly = function runQueryOnly() {
2726
2803
 
2727
2804
  var url = "".concat(domain, "/autoql/api/v1/query?key=").concat(apiKey);
2728
2805
  var finalUserSelection = transformUserSelection(userSelection);
2806
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
2807
+ var conditions = {};
2808
+
2809
+ if (sessionConditions !== null) {
2810
+ var _loop = function _loop(i) {
2811
+ if (Object.keys(conditions).some(function (item) {
2812
+ return item === sessionConditions[i].key;
2813
+ })) {
2814
+ item = Object.keys(conditions).find(function (key) {
2815
+ return key === sessionConditions[i].key;
2816
+ });
2817
+ conditions[item].push(sessionConditions[i].value);
2818
+ } else {
2819
+ conditions[sessionConditions[i].key] = [sessionConditions[i].value];
2820
+ }
2821
+ };
2822
+
2823
+ for (var i = 0; i < sessionConditions.length; i++) {
2824
+ var item;
2825
+
2826
+ _loop(i);
2827
+ }
2828
+ }
2829
+
2729
2830
  var data = {
2730
2831
  text: query,
2731
2832
  source: formatSourceString(source),
2732
2833
  translation: debug ? 'include' : 'exclude',
2733
2834
  user_selection: finalUserSelection,
2734
- test: test
2835
+ test: test,
2836
+ session_locked_conditions: conditions
2735
2837
  };
2736
2838
 
2737
2839
  if (!query || !query.trim()) {
@@ -3035,8 +3137,7 @@ var setConditions = function setConditions() {
3035
3137
  array.push({
3036
3138
  key: obj.key,
3037
3139
  keyword: obj.keyword,
3038
- // lock_flag: obj.lock_flag,
3039
- lock_flag: 1,
3140
+ lock_flag: obj.lock_flag,
3040
3141
  show_message: obj.show_message,
3041
3142
  value: obj.value
3042
3143
  });
@@ -3309,15 +3410,24 @@ _defineProperty(Dictaphone, "defaultProps", {});
3309
3410
 
3310
3411
  var SpeechToTextButtonBrowser = SpeechRecognition(options$1)(Dictaphone);
3311
3412
 
3312
- var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
3313
- _inherits(SpeechToTextBtn, _React$Component);
3413
+ function LoadingDots() {
3414
+ return /*#__PURE__*/React.createElement("div", {
3415
+ className: "response-loading",
3416
+ "data-test": "loading-dots"
3417
+ }, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null));
3418
+ }
3314
3419
 
3315
- var _super = _createSuper(SpeechToTextBtn);
3420
+ var autoCompleteArray$2 = [];
3316
3421
 
3317
- function SpeechToTextBtn() {
3422
+ var QueryInput = /*#__PURE__*/function (_React$Component) {
3423
+ _inherits(QueryInput, _React$Component);
3424
+
3425
+ var _super = _createSuper(QueryInput);
3426
+
3427
+ function QueryInput() {
3318
3428
  var _this;
3319
3429
 
3320
- _classCallCheck(this, SpeechToTextBtn);
3430
+ _classCallCheck(this, QueryInput);
3321
3431
 
3322
3432
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3323
3433
  args[_key] = arguments[_key];
@@ -3325,14 +3435,15 @@ var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
3325
3435
 
3326
3436
  _this = _super.call.apply(_super, [this].concat(args));
3327
3437
 
3438
+ _defineProperty(_assertThisInitialized(_this), "UNIQUE_ID", uuid.v4());
3439
+
3440
+ _defineProperty(_assertThisInitialized(_this), "autoCompleteTimer", undefined);
3441
+
3328
3442
  _defineProperty(_assertThisInitialized(_this), "state", {
3329
- isRecording: false,
3330
- currentQuery: 0,
3331
- resultHistory: [],
3332
- currentFile: '',
3333
- currentBlob: '',
3334
- showPopoverMessage: false,
3335
- errorMessage: ''
3443
+ inputValue: '',
3444
+ lastQuery: '',
3445
+ suggestions: [],
3446
+ isQueryRunning: false
3336
3447
  });
3337
3448
 
3338
3449
  _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
@@ -3340,323 +3451,115 @@ var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
3340
3451
  });
3341
3452
 
3342
3453
  _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);
3454
+ if (!_isEqual(getThemeConfig(_this.props.themeConfig), getThemeConfig(prevProps.themeConfig))) {
3455
+ setCSSVars(getThemeConfig(_this.props.themeConfig));
3349
3456
  }
3350
- });
3351
-
3352
- _defineProperty(_assertThisInitialized(_this), "startRecording", function () {
3353
- _this.setState({
3354
- isRecording: true
3355
- });
3356
3457
 
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
3458
+ if (_this.props.inputValue && _this.props.inputValue !== prevProps.inputValue) {
3459
+ _this.setState({
3460
+ inputValue: _this.props.inputValue
3367
3461
  });
3368
-
3369
- _this.recordAudio.startRecording();
3370
- }, function (error) {
3371
- console.error(JSON.stringify(error));
3372
- });
3462
+ }
3373
3463
  });
3374
3464
 
3375
- _defineProperty(_assertThisInitialized(_this), "onRecordStop", function (file, blob) {
3376
- _this.setState({
3377
- // isConfirmingRecording: true,
3378
- currentFile: file,
3379
- currentBlob: blob //hasPlayedBack: false,
3465
+ _defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function () {
3466
+ if (_this.autoCompleteTimer) {
3467
+ clearTimeout(_this.autoCompleteTimer);
3468
+ }
3380
3469
 
3381
- }, function () {
3382
- _this.sendWavFile(file);
3383
- });
3470
+ if (_this.queryValidationTimer) {
3471
+ clearTimeout(_this.queryValidationTimer);
3472
+ }
3384
3473
  });
3385
3474
 
3386
- _defineProperty(_assertThisInitialized(_this), "stopRecording", function () {
3387
- _this.setState({
3388
- isRecording: false
3389
- });
3475
+ _defineProperty(_assertThisInitialized(_this), "animateInputTextAndSubmit", function (_ref) {
3476
+ var query = _ref.query,
3477
+ userSelection = _ref.userSelection;
3478
+ _ref.skipQueryValidation;
3479
+ var source = _ref.source;
3390
3480
 
3391
- _this.recordAudio.stopRecording(function () {
3392
- var blob = _this.recordAudio.getBlob();
3481
+ if (typeof query === 'string' && _get(query, 'length')) {
3482
+ var _loop = function _loop(i) {
3483
+ setTimeout(function () {
3484
+ _this.setState({
3485
+ inputValue: query.slice(0, i)
3486
+ });
3393
3487
 
3394
- _this.onRecordStop(_this.blobToFile(blob), blob);
3488
+ if (i === query.length) {
3489
+ setTimeout(function () {
3490
+ _this.submitQuery({
3491
+ queryText: query,
3492
+ userSelection: userSelection,
3493
+ skipQueryValidation: true,
3494
+ source: source
3495
+ });
3496
+ }, 300);
3497
+ }
3498
+ }, i * 50);
3499
+ };
3395
3500
 
3396
- try {
3397
- _this.stream.getTracks().forEach(function (track) {
3398
- return track.stop();
3399
- });
3400
- } catch (error) {
3401
- console.error(error);
3501
+ for (var i = 1; i <= query.length; i++) {
3502
+ _loop(i);
3402
3503
  }
3403
- });
3504
+ }
3404
3505
  });
3405
3506
 
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
- });
3507
+ _defineProperty(_assertThisInitialized(_this), "submitQuery", function () {
3508
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3509
+ queryText = _ref2.queryText,
3510
+ userSelection = _ref2.userSelection,
3511
+ skipQueryValidation = _ref2.skipQueryValidation,
3512
+ source = _ref2.source;
3412
3513
 
3413
- _defineProperty(_assertThisInitialized(_this), "getMediaPermissionStatus", function () {
3414
- return navigator.permissions.query({
3415
- name: 'microphone'
3416
- }).then(function (permissionStatus) {
3417
- return permissionStatus.state;
3514
+ // Cancel subscription to autocomplete since query was already submitted
3515
+ if (_this.autoCompleteTimer) {
3516
+ clearTimeout(_this.autoCompleteTimer);
3517
+ }
3518
+
3519
+ _this.setState({
3520
+ isQueryRunning: true,
3521
+ inputValue: '',
3522
+ suggestions: [],
3523
+ queryValidationResponse: undefined,
3524
+ queryValidationComponentId: uuid.v4()
3418
3525
  });
3419
- });
3420
3526
 
3421
- _defineProperty(_assertThisInitialized(_this), "onMouseDown", function () {
3422
- ReactTooltip.hide();
3527
+ var query = queryText || _this.state.inputValue;
3528
+ var newSource = [].concat(_toConsumableArray(_this.props.source), [source || 'user']);
3423
3529
 
3424
- _this.startRecording();
3425
- });
3530
+ if (query.trim()) {
3531
+ _this.props.onSubmit(query);
3532
+
3533
+ if (skipQueryValidation) {
3534
+ runQueryOnly(_objectSpread2(_objectSpread2(_objectSpread2({
3535
+ query: query,
3536
+ userSelection: userSelection
3537
+ }, getAuthentication(_this.props.authentication)), getAutoQLConfig$1(_this.props.autoQLConfig)), {}, {
3538
+ source: newSource,
3539
+ AutoAEId: _this.props.AutoAEId
3540
+ })).then(function (response) {
3541
+ _this.props.onResponseCallback(response, query);
3426
3542
 
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
3543
  _this.setState({
3445
- showPopoverMessage: true
3544
+ isQueryRunning: false
3446
3545
  });
3447
- });
3448
- } else {
3449
- _this.setState({
3450
- errorMessage: 'Oops! Something wrong with your account'
3451
- }, function () {
3546
+ }).catch(function (error) {
3547
+ console.error(error);
3548
+
3549
+ _this.props.onResponseCallback(error);
3550
+
3452
3551
  _this.setState({
3453
- showPopoverMessage: true
3552
+ isQueryRunning: false
3454
3553
  });
3455
3554
  });
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);
3555
+ } else {
3556
+ runQuery(_objectSpread2(_objectSpread2(_objectSpread2({
3557
+ query: query
3558
+ }, getAuthentication(_this.props.authentication)), getAutoQLConfig$1(_this.props.autoQLConfig)), {}, {
3559
+ source: newSource,
3560
+ AutoAEId: _this.props.AutoAEId
3561
+ })).then(function (response) {
3562
+ _this.props.onResponseCallback(response, query);
3660
3563
 
3661
3564
  _this.setState({
3662
3565
  isQueryRunning: false
@@ -3716,6 +3619,9 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3716
3619
  });
3717
3620
 
3718
3621
  _defineProperty(_assertThisInitialized(_this), "focus", function () {
3622
+ // if (this.queryValidationInputRef) {
3623
+ // this.queryValidationInputRef.focus()
3624
+ // }
3719
3625
  if (_this.inputRef) {
3720
3626
  _this.inputRef.focus();
3721
3627
  } else {
@@ -3738,8 +3644,37 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3738
3644
  }
3739
3645
  });
3740
3646
 
3741
- _defineProperty(_assertThisInitialized(_this), "onSuggestionsFetchRequested", function (_ref3) {
3742
- var value = _ref3.value;
3647
+ _defineProperty(_assertThisInitialized(_this), "runQueryValidation", function (_ref3) {
3648
+ var text = _ref3.text;
3649
+
3650
+ // Reset validation configuration since text has changed
3651
+ _this.setState({
3652
+ queryValidationResponse: undefined,
3653
+ queryValidationComponentId: uuid.v4()
3654
+ });
3655
+
3656
+ if (_this.queryValidationTimer) {
3657
+ clearTimeout(_this.queryValidationTimer);
3658
+ }
3659
+
3660
+ _this.queryValidationTimer = setTimeout(function () {
3661
+ runQueryValidation(_objectSpread2({
3662
+ text: text
3663
+ }, getAuthentication(_this.props.authentication))).then(function (response) {
3664
+ if (_this.state.inputValue === _get(response, 'data.data.query')) {
3665
+ _this.setState({
3666
+ queryValidationResponse: response,
3667
+ queryValidationComponentId: uuid.v4()
3668
+ });
3669
+ }
3670
+ }).catch(function (error) {
3671
+ console.error(error);
3672
+ });
3673
+ }, 300);
3674
+ });
3675
+
3676
+ _defineProperty(_assertThisInitialized(_this), "onSuggestionsFetchRequested", function (_ref4) {
3677
+ var value = _ref4.value;
3743
3678
 
3744
3679
  if (_this.autoCompleteTimer) {
3745
3680
  clearTimeout(_this.autoCompleteTimer);
@@ -3791,6 +3726,8 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3791
3726
  });
3792
3727
 
3793
3728
  _defineProperty(_assertThisInitialized(_this), "onInputChange", function (e) {
3729
+ //WIP
3730
+ // this.runQueryValidation({ text: e.target.value })
3794
3731
  if (_this.userSelectedSuggestion && (e.keyCode === 38 || e.keyCode === 40)) {
3795
3732
  // keyup or keydown
3796
3733
  return; // return to let the component handle it...
@@ -3806,6 +3743,12 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3806
3743
  queryText: _this.userSelectedValue
3807
3744
  });
3808
3745
  }
3746
+
3747
+ if (_this.props.isBackButtonClicked) {
3748
+ _this.setState({
3749
+ inputValue: ''
3750
+ });
3751
+ }
3809
3752
  });
3810
3753
 
3811
3754
  _defineProperty(_assertThisInitialized(_this), "moveCaretAtEnd", function (e) {
@@ -3818,14 +3761,16 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3818
3761
  return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement("div", {
3819
3762
  className: "react-autoql-bar-container ".concat(_this.props.className, " ").concat(_this.props.autoCompletePlacement === 'below' ? 'autosuggest-bottom' : 'autosuggest-top'),
3820
3763
  "data-test": "chat-bar"
3764
+ }, /*#__PURE__*/React.createElement("div", {
3765
+ className: "react-autoql-chatbar-input-container"
3821
3766
  }, getAutoQLConfig$1(_this.props.autoQLConfig).enableAutocomplete ? /*#__PURE__*/React.createElement(Autosuggest, {
3822
- className: "auto-complete-chata",
3767
+ lassName: "auto-complete-chata",
3823
3768
  onSuggestionsFetchRequested: _this.onSuggestionsFetchRequested,
3824
3769
  onSuggestionsClearRequested: _this.onSuggestionsClearRequested,
3825
3770
  getSuggestionValue: _this.userSelectedSuggestionHandler,
3826
3771
  suggestions: _this.state.suggestions,
3827
- ref: function ref(_ref4) {
3828
- _this.autoSuggest = _ref4;
3772
+ ref: function ref(_ref5) {
3773
+ _this.autoSuggest = _ref5;
3829
3774
  },
3830
3775
  renderSuggestion: function renderSuggestion(suggestion) {
3831
3776
  return /*#__PURE__*/React.createElement(Fragment, null, suggestion.name);
@@ -3841,9 +3786,26 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3841
3786
  onFocus: _this.moveCaretAtEnd,
3842
3787
  autoFocus: true
3843
3788
  }
3844
- }) : /*#__PURE__*/React.createElement("div", {
3845
- className: "react-autoql-chatbar-input-container"
3846
- }, /*#__PURE__*/React.createElement("input", {
3789
+ }) :
3790
+ /*#__PURE__*/
3791
+ // <QueryInputWithValidation
3792
+ // authentication={getAuthentication(this.props.authentication)}
3793
+ // themeConfig={getThemeConfig(this.props.themeConfig)}
3794
+ // ref={(ref) => (this.queryValidationInputRef = ref)}
3795
+ // key={this.state.queryValidationComponentId}
3796
+ // response={this.state.queryValidationResponse}
3797
+ // placeholder={this.props.placeholder}
3798
+ // disabled={this.props.isDisabled}
3799
+ // showChataIcon={this.props.showChataIcon}
3800
+ // showLoadingDots={this.props.showLoadingDots}
3801
+ // submitQuery={this.submitQuery}
3802
+ // onKeyDown={this.onKeyDown}
3803
+ // onQueryValidationSelectOption={(query) => {
3804
+ // this.setState({ inputValue: query })
3805
+ // this.focus()
3806
+ // }}
3807
+ // />
3808
+ React.createElement("input", {
3847
3809
  className: "react-autoql-chatbar-input".concat(_this.props.showChataIcon ? ' left-padding' : ''),
3848
3810
  placeholder: _this.props.placeholder || 'Type your queries here',
3849
3811
  value: _this.state.inputValue,
@@ -3865,12 +3827,21 @@ var QueryInput = /*#__PURE__*/function (_React$Component) {
3865
3827
  type: "react-autoql-bubbles-outlined"
3866
3828
  })), _this.props.showLoadingDots && _this.state.isQueryRunning && /*#__PURE__*/React.createElement("div", {
3867
3829
  className: "input-response-loading-container"
3868
- }, /*#__PURE__*/React.createElement(LoadingDots, null)), _this.props.enableVoiceRecord && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SpeechToTextButtonBrowser, {
3830
+ }, /*#__PURE__*/React.createElement(LoadingDots, null)), _this.props.enableVoiceRecord &&
3831
+ /*#__PURE__*/
3832
+ // KEEP THIS FOR NOW
3833
+ // <SpeechToTextBtn
3834
+ // onTranscriptChange={this.onTranscriptChange}
3835
+ // onFinalTranscript={this.onFinalTranscript}
3836
+ // themeConfig={this.props.themeConfig}
3837
+ // authentication={getAuthentication(this.props.authentication)}
3838
+ // />
3839
+ React.createElement(SpeechToTextButtonBrowser, {
3869
3840
  onTranscriptChange: _this.onTranscriptChange,
3870
3841
  onFinalTranscript: _this.onFinalTranscript,
3871
3842
  themeConfig: _this.props.themeConfig,
3872
3843
  authentication: getAuthentication(_this.props.authentication)
3873
- }))));
3844
+ })));
3874
3845
  });
3875
3846
 
3876
3847
  return _this;
@@ -3891,7 +3862,8 @@ _defineProperty(QueryInput, "propTypes", {
3891
3862
  className: string,
3892
3863
  autoCompletePlacement: string,
3893
3864
  showLoadingDots: bool,
3894
- showChataIcon: bool
3865
+ showChataIcon: bool,
3866
+ inputValue: string
3895
3867
  });
3896
3868
 
3897
3869
  _defineProperty(QueryInput, "defaultProps", {
@@ -3905,6 +3877,8 @@ _defineProperty(QueryInput, "defaultProps", {
3905
3877
  className: null,
3906
3878
  showLoadingDots: true,
3907
3879
  showChataIcon: true,
3880
+ isBackButtonClicked: false,
3881
+ inputValue: undefined,
3908
3882
  source: [],
3909
3883
  onSubmit: function onSubmit() {},
3910
3884
  onResponseCallback: function onResponseCallback() {}
@@ -3996,7 +3970,7 @@ var ChataTable = /*#__PURE__*/function (_React$Component) {
3996
3970
  _defineProperty(_assertThisInitialized(_this), "saveAsCSV", function () {
3997
3971
  if (_this.ref && _this.ref.table) {
3998
3972
  _this.ref.table.download('csv', 'table.csv', {
3999
- delimiter: '\t'
3973
+ delimiter: ','
4000
3974
  });
4001
3975
  }
4002
3976
  });
@@ -4064,7 +4038,7 @@ var ChataTable = /*#__PURE__*/function (_React$Component) {
4064
4038
  options: options,
4065
4039
  "data-custom-attr": "test-custom-attribute",
4066
4040
  className: "react-autoql-table",
4067
- height: "100%",
4041
+ height: "98%",
4068
4042
  clipboard: true,
4069
4043
  download: true
4070
4044
  })));
@@ -7938,6 +7912,10 @@ var ChataChart = /*#__PURE__*/function (_Component) {
7938
7912
  _this.updateMargins();
7939
7913
  }
7940
7914
 
7915
+ if (!_isEqual(_this.props.isShowingInterpretation, prevProps.isShowingInterpretation)) {
7916
+ _this.updateMargins();
7917
+ }
7918
+
7941
7919
  if (_this.props.type && _this.props.type !== prevProps.type && _this.props.type !== 'pie') {
7942
7920
  _this.updateMargins();
7943
7921
 
@@ -7998,6 +7976,10 @@ var ChataChart = /*#__PURE__*/function (_Component) {
7998
7976
  });
7999
7977
  var leftMargin = Math.ceil(maxYLabelWidth) + 55; // margin to include axis label
8000
7978
 
7979
+ if (isNaN(leftMargin)) {
7980
+ leftMargin = 96; // if there is no yAxisLabels, set leftMargin to default value as 96
7981
+ }
7982
+
8001
7983
  if (xAxisBBox.width > _this.props.width) {
8002
7984
  leftMargin += xAxisBBox.width - _this.props.width;
8003
7985
  }
@@ -8053,7 +8035,11 @@ var ChataChart = /*#__PURE__*/function (_Component) {
8053
8035
  var xAxis = select(_this.chartRef).select('.axis-Bottom').node();
8054
8036
  var xAxisBBox = xAxis ? xAxis.getBBox() : {};
8055
8037
  var bottomMargin = Math.ceil(xAxisBBox.height) + bottomLegendMargin + 40; // margin to include axis label
8056
- // only for bar charts (vertical grid lines mess with the axis size)
8038
+
8039
+ if (xAxisBBox.height === 0) {
8040
+ bottomMargin = 463; // if no xAxisBBox available, set bottomMarigin to default as 463
8041
+ } // only for bar charts (vertical grid lines mess with the axis size)
8042
+
8057
8043
 
8058
8044
  if (_this.props.type === 'bar' || _this.props.type === 'stacked_bar') {
8059
8045
  var innerTickSize = _this.props.height - _this.state.topMargin - _this.state.bottomMargin;
@@ -8337,7 +8323,9 @@ var ChataChart = /*#__PURE__*/function (_Component) {
8337
8323
  currencySelectorState = _this$state2.currencySelectorState,
8338
8324
  quantitySelectorState = _this$state2.quantitySelectorState,
8339
8325
  ratioSelectorState = _this$state2.ratioSelectorState;
8340
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
8326
+ return /*#__PURE__*/React.createElement("div", {
8327
+ id: "chata-chart-popover"
8328
+ }, /*#__PURE__*/React.createElement("div", {
8341
8329
  className: "axis-selector-container"
8342
8330
  }, !!currencySelectorState.length && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
8343
8331
  className: "number-selector-header"
@@ -9241,14 +9229,15 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
9241
9229
 
9242
9230
  _defineProperty(_assertThisInitialized(_this), "supportedDisplayTypes", []);
9243
9231
 
9244
- _defineProperty(_assertThisInitialized(_this), "SAFETYNET_KEY", uuid.v4());
9232
+ _defineProperty(_assertThisInitialized(_this), "QUERY_VALIDATION_KEY", uuid.v4());
9245
9233
 
9246
9234
  _defineProperty(_assertThisInitialized(_this), "state", {
9247
9235
  displayType: null,
9248
9236
  tableFilters: [],
9249
9237
  suggestionSelection: _this.props.selectedSuggestion,
9250
9238
  QandAResponseCorrect: false,
9251
- QandASuggestions: []
9239
+ QandASuggestions: [],
9240
+ isShowingInterpretation: false
9252
9241
  });
9253
9242
 
9254
9243
  _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
@@ -9270,6 +9259,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
9270
9259
 
9271
9260
 
9272
9261
  _this.setState({
9262
+ isShowingInterpretation: getAutoQLConfig$1(_this.props.autoQLConfig).defaultShowInterpretation,
9273
9263
  displayType: isDisplayTypeValid(_this.props.queryResponse, _this.props.displayType) ? _this.props.displayType : getDefaultDisplayType(_this.props.queryResponse, _this.props.autoChartAggregations)
9274
9264
  });
9275
9265
 
@@ -9345,6 +9335,10 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
9345
9335
  disableScroll.off();
9346
9336
  }
9347
9337
 
9338
+ if (prevState.isShowingInterpretation !== _this.state.isShowingInterpretation) {
9339
+ _this.forceUpdate();
9340
+ }
9341
+
9348
9342
  if (_this.props.optionsToolbarRef) {
9349
9343
  _this.props.optionsToolbarRef._isMounted && _this.props.optionsToolbarRef.forceUpdate();
9350
9344
  }
@@ -10268,7 +10262,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10268
10262
  var formattedColumns = columns.map(function (col, i) {
10269
10263
  /**
10270
10264
  * EDIT:
10271
- * We no longer want to default to one over the other. Howeever,
10265
+ * We no longer want to default to one over the other. Howeever,
10272
10266
  * I would like to hang onto this code for now incase we do want to
10273
10267
  * include either/or in some cases in the future
10274
10268
  */
@@ -10670,7 +10664,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10670
10664
  }
10671
10665
 
10672
10666
  if (_this.state.displayType === 'pivot_table') {
10673
- return /*#__PURE__*/React.createElement(ChataTable, {
10667
+ return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(ChataTable, {
10674
10668
  themeConfig: getThemeConfig(_this.props.themeConfig),
10675
10669
  key: _this.pivotTableID,
10676
10670
  ref: function ref(_ref6) {
@@ -10683,7 +10677,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10683
10677
  onFilterCallback: _this.onTableFilter,
10684
10678
  setFilterTagsCallback: _this.props.setFilterTagsCallback,
10685
10679
  enableColumnHeaderContextMenu: _this.props.enableColumnHeaderContextMenu
10686
- });
10680
+ }));
10687
10681
  }
10688
10682
 
10689
10683
  return /*#__PURE__*/React.createElement(Fragment, null, _this.renderAllColumnsHiddenMessage(), /*#__PURE__*/React.createElement(ChataTable, {
@@ -10725,6 +10719,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10725
10719
  columns: _this.chartTableColumns,
10726
10720
  height: height,
10727
10721
  width: width,
10722
+ isShowingInterpretation: _this.state.isShowingInterpretation,
10728
10723
  dataFormatting: getDataFormatting(_this.props.dataFormatting),
10729
10724
  backgroundColor: _this.props.backgroundColor,
10730
10725
  activeChartElementKey: _this.props.activeChartElementKey,
@@ -10859,7 +10854,7 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10859
10854
  if (_get(queryResponse, 'data.data.replacements')) {
10860
10855
  return /*#__PURE__*/React.createElement(QueryValidationMessage, {
10861
10856
  themeConfig: getThemeConfig(_this.props.themeConfig),
10862
- key: _this.SAFETYNET_KEY,
10857
+ key: _this.QUERY_VALIDATION_KEY,
10863
10858
  response: _this.props.queryResponse,
10864
10859
  onSuggestionClick: function onSuggestionClick(_ref9) {
10865
10860
  var query = _ref9.query,
@@ -10984,30 +10979,103 @@ var QueryOutput = /*#__PURE__*/function (_React$Component) {
10984
10979
  }, /*#__PURE__*/React.createElement("div", null));
10985
10980
  });
10986
10981
 
10987
- _defineProperty(_assertThisInitialized(_this), "render", function () {
10988
- var responseContainer = document.getElementById("react-autoql-response-content-container-".concat(_this.COMPONENT_KEY));
10989
- var height = 0;
10990
- var width = 0;
10982
+ _defineProperty(_assertThisInitialized(_this), "handleShowHide", function (e) {
10983
+ var responseContainer = document.getElementById("react-autoql-response-content-container-".concat(_this.COMPONENT_KEY)); // make room in response container for reverse translation text
10991
10984
 
10992
- if (responseContainer) {
10993
- height = responseContainer.clientHeight - getPadding(responseContainer).top - getPadding(responseContainer).bottom;
10994
- width = responseContainer.clientWidth - getPadding(responseContainer).left - getPadding(responseContainer).right;
10985
+ if (document.getElementById("reverse-translation-".concat(_this.COMPONENT_KEY)) && getAutoQLConfig$1(_this.props.autoQLConfig).enableQueryInterpretation) {
10986
+ if (e.isFullyOpened) {
10987
+ responseContainer.style.height = "calc(100% - ".concat(e.contentHeight, "px)");
10988
+ } else {
10989
+ responseContainer.style.height = "calc(100% - 26px)";
10990
+ }
10995
10991
  }
10992
+ });
10996
10993
 
10997
- if (_this.props.height) {
10998
- height = _this.props.height;
10999
- }
10994
+ _defineProperty(_assertThisInitialized(_this), "renderReverseTranslation", function () {
10995
+ var queryResponse = _this.props.queryResponse;
10996
+ var id = "reverse-translation-".concat(_this.COMPONENT_KEY);
10997
+ var responseContainer = document.getElementById("react-autoql-response-content-container-".concat(_this.COMPONENT_KEY));
11000
10998
 
11001
- if (_this.props.width) {
11002
- width = _this.props.width;
11003
- }
10999
+ if (responseContainer && _get(queryResponse, 'data.data.interpretation')) {
11000
+ // manipulate interpretation string to properly format various substrings
11001
+ var reverseTranslation = _get(queryResponse, 'data.data.interpretation').replace(/(["'])(?:(?=(\\?))\2.)*?\1/gi, function (output) {
11002
+ var text = output.replace(/'/g, '');
11004
11003
 
11005
- return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement("div", {
11006
- key: _this.COMPONENT_KEY,
11007
- id: "react-autoql-response-content-container-".concat(_this.COMPONENT_KEY),
11004
+ if (_get(queryResponse, 'data.data.persistent_locked_conditions').includes(text) || _get(queryResponse, 'data.data.session_locked_conditions').includes(text)) {
11005
+ return "\n <a id=\"react-autoql-interpreted-value-label\" class=\"react-autoql-condition-link-filtered\">\n <span class=\"material-icons react-autoql-custom-icon\">lock</span>\n ".concat(' ', text, "\n </a>\n ");
11006
+ } else {
11007
+ return "<a id=\"react-autoql-interpreted-value-label\" class=\"react-autoql-condition-link\">".concat(text, "</a>");
11008
+ }
11009
+ }).replace(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/gi, function (output) {
11010
+ return moment.utc(output).format('ll').toString();
11011
+ });
11012
+
11013
+ return /*#__PURE__*/React.createElement("div", {
11014
+ id: id,
11015
+ className: "react-autoql-condition-lock-reverse-translation"
11016
+ }, /*#__PURE__*/React.createElement("span", {
11017
+ style: {
11018
+ float: 'left',
11019
+ minHeight: 20
11020
+ } // onClick={() => {
11021
+ // this.setState({
11022
+ // isShowingInterpretation: !this.state.isShowingInterpretation
11023
+ // })
11024
+ // }}
11025
+
11026
+ }, /*#__PURE__*/React.createElement(Icon // type={this.state.isShowingInterpretation ? 'caret-down' : 'caret-right' }
11027
+ // data-tip={this.state.isShowingInterpretation ? "Hide query interpretation" : "Show query interpretation" }
11028
+ , {
11029
+ type: "info" // data-for="react-autoql-interpretation"
11030
+
11031
+ }), ' '), /*#__PURE__*/React.createElement(UnmountClosed, {
11032
+ onRest: _this.handleShowHide,
11033
+ isOpened: true // isOpened={this.state.isShowingInterpretation}
11034
+
11035
+ }, /*#__PURE__*/React.createElement("strong", null, "Interpreted as:", ' '), /*#__PURE__*/React.createElement("span", {
11036
+ onClick: function onClick(e) {
11037
+ return _this.props.onConditionClickCallback(e);
11038
+ },
11039
+ dangerouslySetInnerHTML: {
11040
+ __html: "".concat(reverseTranslation)
11041
+ }
11042
+ })));
11043
+ }
11044
+ });
11045
+
11046
+ _defineProperty(_assertThisInitialized(_this), "render", function () {
11047
+ var responseContainer = document.getElementById("react-autoql-response-content-container-".concat(_this.COMPONENT_KEY));
11048
+ var translationContainer = document.getElementById("reverse-translation-".concat(_this.COMPONENT_KEY));
11049
+ var height = 0;
11050
+ var width = 0;
11051
+
11052
+ if (responseContainer) {
11053
+ height = responseContainer.clientHeight - getPadding(responseContainer).top - getPadding(responseContainer).bottom;
11054
+ width = responseContainer.clientWidth - getPadding(responseContainer).left - getPadding(responseContainer).right;
11055
+ }
11056
+
11057
+ if (_this.props.height) {
11058
+ if (translationContainer && getAutoQLConfig$1(_this.props.autoQLConfig).enableQueryInterpretation && _this.state.isShowingInterpretation) {
11059
+ if (_this.state.isShowingInterpretation) {
11060
+ height = _this.props.height - translationContainer.offsetHeight - 20;
11061
+ } else {
11062
+ height = _this.props.height - translationContainer.offsetHeight - 40;
11063
+ }
11064
+ } else {
11065
+ height = _this.props.height;
11066
+ }
11067
+ }
11068
+
11069
+ if (_this.props.width) {
11070
+ width = _this.props.width;
11071
+ }
11072
+
11073
+ return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement("div", {
11074
+ key: _this.COMPONENT_KEY,
11075
+ id: "react-autoql-response-content-container-".concat(_this.COMPONENT_KEY),
11008
11076
  "data-test": "query-response-wrapper",
11009
11077
  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());
11078
+ }, _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
11079
  });
11012
11080
 
11013
11081
  return _this;
@@ -11022,13 +11090,13 @@ _defineProperty(QueryOutput, "propTypes", (_defineProperty2$1 = {
11022
11090
  authentication: authenticationType,
11023
11091
  themeConfig: themeConfigType,
11024
11092
  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));
11093
+ }, _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
11094
 
11027
11095
  _defineProperty(QueryOutput, "defaultProps", (_defineProperty3 = {
11028
11096
  authentication: authenticationDefault,
11029
11097
  themeConfig: themeConfigDefault,
11030
11098
  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));
11099
+ }, _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
11100
 
11033
11101
  var VizToolbar = /*#__PURE__*/function (_React$Component) {
11034
11102
  _inherits(VizToolbar, _React$Component);
@@ -12086,8 +12154,18 @@ var NotificationIcon = /*#__PURE__*/function (_React$Component) {
12086
12154
  switch (_context.prev = _context.next) {
12087
12155
  case 0:
12088
12156
  _this._isMounted = true;
12089
-
12090
- _this.subscribeToNotificationCount();
12157
+ /**
12158
+ * If Data Messenger has enableNotificationsTab = true and
12159
+ * the NotificationIcon is also present, subscribeToNotificationCount()
12160
+ * will occasionally trigger an infinite loop.
12161
+ *
12162
+ * Data Messenger will first check to see that the NotificationIcon
12163
+ * isn't already present before triggering this function inside.
12164
+ */
12165
+
12166
+ if (!_this.props.isAlreadyMountedInDOM) {
12167
+ _this.subscribeToNotificationCount();
12168
+ }
12091
12169
 
12092
12170
  case 2:
12093
12171
  case "end":
@@ -12221,7 +12299,8 @@ _defineProperty(NotificationIcon, "propTypes", {
12221
12299
  useDot: PropTypes.bool,
12222
12300
  clearCountOnClick: PropTypes.bool,
12223
12301
  onNewNotification: PropTypes.func,
12224
- onErrorCallback: PropTypes.func
12302
+ onErrorCallback: PropTypes.func,
12303
+ isAlreadyMountedInDOM: PropTypes.bool
12225
12304
  });
12226
12305
 
12227
12306
  _defineProperty(NotificationIcon, "defaultProps", {
@@ -12231,7 +12310,8 @@ _defineProperty(NotificationIcon, "defaultProps", {
12231
12310
  style: {},
12232
12311
  clearCountOnClick: true,
12233
12312
  onNewNotification: function onNewNotification() {},
12234
- onErrorCallback: function onErrorCallback() {}
12313
+ onErrorCallback: function onErrorCallback() {},
12314
+ isAlreadyMountedInDOM: false
12235
12315
  });
12236
12316
 
12237
12317
  var _excluded$1 = ["icon", "type"];
@@ -12538,7 +12618,7 @@ var RuleSimple = /*#__PURE__*/function (_React$Component) {
12538
12618
  return '<';
12539
12619
  }
12540
12620
 
12541
- case 'EQUALS':
12621
+ case 'EQUAL_TO':
12542
12622
  {
12543
12623
  return '=';
12544
12624
  }
@@ -12596,9 +12676,9 @@ var RuleSimple = /*#__PURE__*/function (_React$Component) {
12596
12676
  label: '<',
12597
12677
  tooltip: 'Less Than'
12598
12678
  }, {
12599
- value: 'EQUALS',
12679
+ value: 'EQUAL_TO',
12600
12680
  label: '=',
12601
- tooltip: 'Equals'
12681
+ tooltip: 'EQUAL_TO'
12602
12682
  }, {
12603
12683
  value: 'EXISTS',
12604
12684
  label: 'Exists',
@@ -13199,6 +13279,7 @@ var NotificationItem = /*#__PURE__*/function (_React$Component) {
13199
13279
  ref: function ref(r) {
13200
13280
  return _this.OUTPUT_REF = r;
13201
13281
  },
13282
+ isDashboardQuery: true,
13202
13283
  queryResponse: queryResponse,
13203
13284
  autoQLConfig: {
13204
13285
  enableDrilldowns: false
@@ -15014,6 +15095,8 @@ var DataAlerts = /*#__PURE__*/function (_React$Component) {
15014
15095
  }
15015
15096
  }
15016
15097
 
15098
+ _this.props.onSuccessAlert('Notification created!');
15099
+
15017
15100
  _this.setState({
15018
15101
  isEditModalVisible: false,
15019
15102
  customAlertsList: newDataAlertList
@@ -15202,7 +15285,7 @@ var DataAlerts = /*#__PURE__*/function (_React$Component) {
15202
15285
  className: "react-autoql-re-initialize-btn-text"
15203
15286
  }, /*#__PURE__*/React.createElement(Icon, {
15204
15287
  type: "warning-triangle"
15205
- }), ' ', " Resend")), /*#__PURE__*/React.createElement(Checkbox, {
15288
+ }), " Resend")), /*#__PURE__*/React.createElement(Checkbox, {
15206
15289
  themeConfig: getThemeConfig(_this.props.themeConfig),
15207
15290
  type: "switch",
15208
15291
  className: "react-autoql-notification-disable-checkbox"
@@ -15282,7 +15365,8 @@ _defineProperty(DataAlerts, "propTypes", {
15282
15365
  authentication: authenticationType,
15283
15366
  themeConfig: themeConfigType,
15284
15367
  onErrorCallback: PropTypes.func,
15285
- showCreateAlertBtn: PropTypes.bool
15368
+ showCreateAlertBtn: PropTypes.bool,
15369
+ onSuccessAlert: PropTypes.func
15286
15370
  });
15287
15371
 
15288
15372
  _defineProperty(DataAlerts, "defaultProps", {
@@ -15290,7 +15374,8 @@ _defineProperty(DataAlerts, "defaultProps", {
15290
15374
  themeConfig: themeConfigDefault,
15291
15375
  showCreateAlertBtn: false,
15292
15376
  onErrorCallback: function onErrorCallback() {},
15293
- onAlertInitializationCallback: function onAlertInitializationCallback() {}
15377
+ onAlertInitializationCallback: function onAlertInitializationCallback() {},
15378
+ onSuccessAlert: function onSuccessAlert() {}
15294
15379
  });
15295
15380
 
15296
15381
  var getInitialStateData$2 = function getInitialStateData(initialData) {
@@ -15559,7 +15644,7 @@ var Rule = /*#__PURE__*/function (_React$Component) {
15559
15644
  return '<';
15560
15645
  }
15561
15646
 
15562
- case 'EQUALS':
15647
+ case 'EQUAL_TO':
15563
15648
  {
15564
15649
  return '=';
15565
15650
  }
@@ -15622,9 +15707,9 @@ var Rule = /*#__PURE__*/function (_React$Component) {
15622
15707
  label: '<',
15623
15708
  tooltip: 'Less Than'
15624
15709
  }, {
15625
- value: 'EQUALS',
15710
+ value: 'EQUAL_TO',
15626
15711
  label: '=',
15627
- tooltip: 'Equals'
15712
+ tooltip: 'EQUAL_TO'
15628
15713
  }, {
15629
15714
  value: 'EXISTS',
15630
15715
  label: /*#__PURE__*/React.createElement("span", null, "\u2203"),
@@ -18228,12 +18313,17 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18228
18313
  optionsToolbarRef: _this.optionsToolbarRef,
18229
18314
  onNoneOfTheseClick: _this.props.onNoneOfTheseClick,
18230
18315
  autoChartAggregations: _this.props.autoChartAggregations,
18316
+ enableQueryInterpretation: _this.props.enableQueryInterpretation,
18317
+ enableFilterLocking: _this.props.enableFilterLocking,
18231
18318
  reportProblemCallback: function reportProblemCallback() {
18232
18319
  if (_this.optionsToolbarRef) {
18233
18320
  _this.optionsToolbarRef.setState({
18234
18321
  activeMenu: 'other-problem'
18235
18322
  });
18236
18323
  }
18324
+ },
18325
+ onConditionClickCallback: function onConditionClickCallback(e) {
18326
+ _this.props.onConditionClickCallback(e);
18237
18327
  }
18238
18328
  }));
18239
18329
  }
@@ -18253,7 +18343,7 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18253
18343
 
18254
18344
  _this.scrollIntoView();
18255
18345
  } else {
18256
- messageElement.style.maxHeight = '85%';
18346
+ messageElement.style.maxHeight = '90%';
18257
18347
  messageElement.style.height = "".concat(messageElement.offsetHeights, "px");
18258
18348
  }
18259
18349
  } catch (error) {
@@ -18387,7 +18477,7 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18387
18477
  if (_this.props.type === 'text' || _this.state.displayType === 'html') {
18388
18478
  return undefined;
18389
18479
  } else if (chartHeight) {
18390
- return chartHeight + 40;
18480
+ return chartHeight + 120;
18391
18481
  }
18392
18482
 
18393
18483
  return '85%';
@@ -18408,23 +18498,6 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18408
18498
  }
18409
18499
  });
18410
18500
 
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
18501
  _defineProperty(_assertThisInitialized(_this), "render", function () {
18429
18502
  var _this$getChartDimensi2 = _this.getChartDimensions(),
18430
18503
  chartWidth = _this$getChartDimensi2.chartWidth,
@@ -18449,7 +18522,7 @@ var ChatMessage = /*#__PURE__*/function (_React$Component) {
18449
18522
  return !col.visible;
18450
18523
  }) || _this.allColumnsAreHidden() ? '400px' : undefined
18451
18524
  }
18452
- }, _this.renderContent(chartWidth, chartHeight), _this.props.isDataMessengerOpen && _this.renderRightToolbar(), _this.props.isDataMessengerOpen && _this.renderLeftToolbar(), _this.renderDataLimitWarning(), _this.renderLockedConditions())));
18525
+ }, _this.renderContent(chartWidth, chartHeight), _this.props.isDataMessengerOpen && _this.renderRightToolbar(), _this.props.isDataMessengerOpen && _this.renderLeftToolbar(), _this.renderDataLimitWarning())));
18453
18526
  });
18454
18527
 
18455
18528
  return _this;
@@ -18477,7 +18550,7 @@ _defineProperty(ChatMessage, "propTypes", (_defineProperty2 = {
18477
18550
  content: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({})]),
18478
18551
  tableOptions: PropTypes.shape({}),
18479
18552
  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));
18553
+ }, _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
18554
 
18482
18555
  _defineProperty(ChatMessage, "defaultProps", {
18483
18556
  authentication: authenticationDefault,
@@ -18502,7 +18575,8 @@ _defineProperty(ChatMessage, "defaultProps", {
18502
18575
  enableDynamicCharting: true,
18503
18576
  autoChartAggregations: true,
18504
18577
  scrollToBottom: function scrollToBottom() {},
18505
- onNoneOfTheseClick: function onNoneOfTheseClick() {}
18578
+ onNoneOfTheseClick: function onNoneOfTheseClick() {},
18579
+ onConditionClickCallback: function onConditionClickCallback() {}
18506
18580
  });
18507
18581
 
18508
18582
  var QueryTipsTab = /*#__PURE__*/function (_React$Component) {
@@ -18804,15 +18878,30 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18804
18878
 
18805
18879
  _defineProperty(_assertThisInitialized(_this), "UNIQUE_ID", uuid.v4());
18806
18880
 
18881
+ _defineProperty(_assertThisInitialized(_this), "mouseInfoRef", /*#__PURE__*/createRef());
18882
+
18883
+ _defineProperty(_assertThisInitialized(_this), "mouseSettingRef", /*#__PURE__*/createRef());
18884
+
18807
18885
  _defineProperty(_assertThisInitialized(_this), "state", {
18808
18886
  inputValue: '',
18809
18887
  lastQuery: '',
18810
18888
  suggestions: [],
18811
- selectedConditions: []
18889
+ selectedConditions: [],
18890
+ isFetchingConditions: false,
18891
+ isShowingInfo: false,
18892
+ isShowingSettingInfo: false,
18893
+ showMessage: {
18894
+ type: 'unlock',
18895
+ message: 'filter removed'
18896
+ }
18812
18897
  });
18813
18898
 
18814
18899
  _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
18815
18900
  try {
18901
+ _this.setState({
18902
+ isFetchingConditions: true
18903
+ });
18904
+
18816
18905
  fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
18817
18906
  var conditions = _get(response, 'data.data.data');
18818
18907
 
@@ -18829,42 +18918,79 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18829
18918
  });
18830
18919
  }
18831
18920
 
18832
- _this.setState({
18833
- selectedConditions: array,
18834
- inputValue: ''
18835
- });
18921
+ if (JSON.parse(sessionStorage.getItem("conditions")) !== null) {
18922
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
18923
+
18924
+ for (var _i = 0; _i < sessionConditions.length; _i++) {
18925
+ array.push({
18926
+ id: sessionConditions[_i].id,
18927
+ keyword: sessionConditions[_i].value,
18928
+ value: sessionConditions[_i].value,
18929
+ show_message: sessionConditions[_i].show_message,
18930
+ key: sessionConditions[_i].key,
18931
+ lock_flag: sessionConditions[_i].lock_flag
18932
+ });
18933
+ }
18934
+ }
18935
+
18936
+ if (_this.props.initFilterText && _this.props.initFilterText !== '') {
18937
+ _this.setState({
18938
+ selectedConditions: array.sort(),
18939
+ isFetchingConditions: false
18940
+ });
18941
+
18942
+ for (var _i2 = 0; _i2 < array.length; _i2++) {
18943
+ if (array[_i2].keyword === _this.props.initFilterText) {
18944
+ _this.handleHighlightFilterRow(_i2);
18945
+
18946
+ return;
18947
+ }
18948
+ }
18949
+
18950
+ _this.animateInputTextAndSubmit(_this.props.initFilterText);
18951
+ } else {
18952
+ _this.setState({
18953
+ selectedConditions: array.sort(),
18954
+ inputValue: '',
18955
+ isFetchingConditions: false
18956
+ });
18957
+ }
18836
18958
  });
18837
18959
  } catch (error) {
18838
18960
  console.error(error);
18839
18961
  }
18840
18962
  });
18841
18963
 
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
18964
  _defineProperty(_assertThisInitialized(_this), "getSuggestionValue", function (suggestion) {
18851
18965
  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
- });
18966
+ var tempId = uuid.v4();
18859
18967
 
18860
- _this.setState({
18861
- selectedConditions: array,
18862
- inputValue: ''
18863
- });
18864
- });
18968
+ if (array.some(function (item) {
18969
+ return item.key === suggestion.name.canonical && item.value === suggestion.name.keyword;
18970
+ })) {
18971
+ _this.handleShowMessage('warning', 'This condition has already been applied.');
18972
+ } else {
18973
+ array.push({
18974
+ id: tempId,
18975
+ keyword: suggestion.name.keyword,
18976
+ value: suggestion.name.keyword,
18977
+ show_message: suggestion.name.show_message,
18978
+ key: suggestion.name.canonical,
18979
+ lock_flag: 1 // persist by default
18980
+
18981
+ });
18982
+
18983
+ _this.setState({
18984
+ selectedConditions: array,
18985
+ inputValue: ''
18986
+ });
18865
18987
 
18866
- _defineProperty(_assertThisInitialized(_this), "renderSuggestion", function (suggestion) {
18867
- return /*#__PURE__*/React.createElement("div", null, _get(suggestion, 'name.keyword'));
18988
+ setConditions(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
18989
+ conditions: array
18990
+ })).then(function () {
18991
+ _this.handleShowMessage('lock', "".concat(suggestion.name.keyword, " has been locked"));
18992
+ });
18993
+ }
18868
18994
  });
18869
18995
 
18870
18996
  _defineProperty(_assertThisInitialized(_this), "onInputChange", function (e) {
@@ -18881,27 +19007,64 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18881
19007
  });
18882
19008
 
18883
19009
  _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
- }
19010
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
19011
+ var sessionIndex;
19012
+
19013
+ if (sessionConditions) {
19014
+ sessionIndex = sessionConditions.findIndex(function (condition) {
19015
+ return _get(condition, 'key') === _get(item, 'key');
18890
19016
  });
19017
+ }
18891
19018
 
18892
- if (isSaved) {
18893
- unsetCondition(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
18894
- condition: item
18895
- }));
18896
- }
19019
+ if (sessionIndex !== -1 && sessionIndex !== undefined && sessionIndex !== null) {
19020
+ sessionConditions.splice(sessionIndex, 1);
19021
+ sessionStorage.setItem('conditions', JSON.stringify(sessionConditions));
19022
+ } else {
19023
+ unsetCondition(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
19024
+ condition: item
19025
+ }));
19026
+ }
19027
+
19028
+ var array = _this.state.selectedConditions;
19029
+ array.splice(index, 1);
19030
+
19031
+ _this.setState({
19032
+ selectedConditions: array
19033
+ });
18897
19034
 
18898
- var array = _this.state.selectedConditions;
18899
- array.splice(index, 1);
19035
+ _this.handleShowMessage('unlock', 'Filter removed.');
18900
19036
 
19037
+ ReactTooltip.hide();
19038
+ });
19039
+
19040
+ _defineProperty(_assertThisInitialized(_this), "handlePersistConditionToggle", function (item) {
19041
+ var index = _this.state.selectedConditions.findIndex(function (condition) {
19042
+ return condition.id === item.id;
19043
+ });
19044
+
19045
+ var sessionConditions = JSON.parse(sessionStorage.getItem("conditions"));
19046
+
19047
+ if (index === -1) ; else {
18901
19048
  _this.setState({
18902
- selectedConditions: array
19049
+ 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)))
19050
+ }, function () {
19051
+ setConditions(_objectSpread2(_objectSpread2({}, getAuthentication(_this.props.authentication)), {}, {
19052
+ conditions: _this.state.selectedConditions
19053
+ }));
19054
+
19055
+ if (item.lock_flag === 0) {
19056
+ if (sessionConditions == null) sessionConditions = [];
19057
+ sessionConditions.push(item);
19058
+ sessionStorage.setItem("conditions", JSON.stringify(sessionConditions));
19059
+ } else {
19060
+ var sessionIndex = sessionConditions.findIndex(function (condition) {
19061
+ return condition.id === item.id;
19062
+ });
19063
+ sessionConditions.splice(sessionIndex, 1);
19064
+ sessionStorage.setItem('conditions', JSON.stringify(sessionConditions));
19065
+ }
18903
19066
  });
18904
- });
19067
+ }
18905
19068
  });
18906
19069
 
18907
19070
  _defineProperty(_assertThisInitialized(_this), "onSuggestionsFetchRequested", function (_ref) {
@@ -18925,13 +19088,13 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18925
19088
  for (var i = 0; i < suggestionsMatchArray.length; i++) {
18926
19089
  sortingArray.push(suggestionsMatchArray[i]);
18927
19090
 
18928
- if (i === 4) {
19091
+ if (i === 5) {
18929
19092
  break;
18930
19093
  }
18931
19094
  }
18932
19095
 
18933
19096
  sortingArray.sort(function (a, b) {
18934
- return b.length - a.length;
19097
+ return a.keyword.toUpperCase() < b.keyword.toUpperCase() ? -1 : a.keyword > b.keyword ? 1 : 0;
18935
19098
  });
18936
19099
 
18937
19100
  for (var idx = 0; idx < sortingArray.length; idx++) {
@@ -18956,6 +19119,65 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18956
19119
  });
18957
19120
  });
18958
19121
 
19122
+ _defineProperty(_assertThisInitialized(_this), "timer", void 0);
19123
+
19124
+ _defineProperty(_assertThisInitialized(_this), "onEnterFilterHeaderInfo", function () {
19125
+ var el = document.getElementById('react-autoql-filter-description-id');
19126
+ _this.timer = setTimeout(function () {
19127
+ el.className = 'show';
19128
+ }, 500);
19129
+ });
19130
+
19131
+ _defineProperty(_assertThisInitialized(_this), "onLeaveFilterHeaderInfo", function () {
19132
+ var el = document.getElementById('react-autoql-filter-description-id');
19133
+ el.className = el.className.replace('show', '');
19134
+ clearTimeout(_this.timer);
19135
+ });
19136
+
19137
+ _defineProperty(_assertThisInitialized(_this), "onEnterFilterSettingInfo", function () {
19138
+ var el = document.getElementById('react-autoql-filter-setting-info-card');
19139
+ _this.timer = setTimeout(function () {
19140
+ el.className = 'show';
19141
+ }, 500);
19142
+ });
19143
+
19144
+ _defineProperty(_assertThisInitialized(_this), "onLeaveFilterSettingInfo", function () {
19145
+ var el = document.getElementById('react-autoql-filter-setting-info-card');
19146
+ el.className = el.className.replace('show', '');
19147
+ clearTimeout(_this.timer);
19148
+ });
19149
+
19150
+ _defineProperty(_assertThisInitialized(_this), "animateInputTextAndSubmit", function (text) {
19151
+ if (typeof text === 'string' && _get(text, 'length')) {
19152
+ var _loop = function _loop(i) {
19153
+ setTimeout(function () {
19154
+ _this.setState({
19155
+ inputValue: text.slice(0, i)
19156
+ });
19157
+
19158
+ if (i === text.length) {
19159
+ setTimeout(function () {
19160
+ var input = document.querySelector('#react-autoql-filter-menu-input');
19161
+ input.focus();
19162
+ }, 300);
19163
+ }
19164
+ }, i * 50);
19165
+ };
19166
+
19167
+ for (var i = 1; i <= text.length; i++) {
19168
+ _loop(i);
19169
+ }
19170
+ }
19171
+ });
19172
+
19173
+ _defineProperty(_assertThisInitialized(_this), "renderShowMessage", function () {
19174
+ return /*#__PURE__*/React.createElement("div", {
19175
+ id: "react-autoql-condition-show-message"
19176
+ }, /*#__PURE__*/React.createElement(Icon, {
19177
+ type: _this.state.showMessage.type
19178
+ }), " ", _this.state.showMessage.message);
19179
+ });
19180
+
18959
19181
  _defineProperty(_assertThisInitialized(_this), "renderAcceptConditionsButton", function () {
18960
19182
  return /*#__PURE__*/React.createElement("div", {
18961
19183
  key: "accept-conditions-btn",
@@ -18986,107 +19208,211 @@ var ConditionLockMenu = /*#__PURE__*/function (_React$Component) {
18986
19208
  style: {
18987
19209
  width: containerWidth
18988
19210
  }
18989
- }, /*#__PURE__*/React.createElement("div", {
19211
+ }, _this.renderShowMessage(), /*#__PURE__*/React.createElement("div", {
18990
19212
  className: "react-autoql-condition-lock-header"
18991
19213
  }, /*#__PURE__*/React.createElement("div", {
18992
- className: "autoql-condition-locking-menu-container"
18993
- }, /*#__PURE__*/React.createElement("button", {
19214
+ className: "react-autoql-filter-locking-title-container"
19215
+ }, /*#__PURE__*/React.createElement("h3", {
19216
+ className: "react-autoql-filter-locking-title"
19217
+ }, lang.filterLockingTitle, " ", ' ', /*#__PURE__*/React.createElement(Icon, {
19218
+ type: "info",
19219
+ ref: _this.mouseInfoRef,
19220
+ onMouseEnter: _this.onEnterFilterHeaderInfo,
19221
+ onMouseLeave: _this.onLeaveFilterHeaderInfo
19222
+ })), /*#__PURE__*/React.createElement("button", {
18994
19223
  onClick: function onClick() {
18995
19224
  _this.props.onClose();
18996
19225
  },
18997
19226
  className: "autoql-close-button",
18998
- "data-tip": lang.closeConditionLocking,
19227
+ "data-tip": lang.closeFilterLocking,
18999
19228
  "data-for": "react-autoql-header-tooltip"
19000
19229
  }, /*#__PURE__*/React.createElement(Icon, {
19001
19230
  type: "close"
19002
- })), /*#__PURE__*/React.createElement(Autosuggest, {
19231
+ }))), /*#__PURE__*/React.createElement("div", {
19232
+ className: "autoql-condition-locking-menu-container"
19233
+ }, /*#__PURE__*/React.createElement("div", {
19234
+ id: "react-autoql-filter-description-id"
19235
+ }, /*#__PURE__*/React.createElement(Icon, {
19236
+ type: "info"
19237
+ }), /*#__PURE__*/React.createElement("p", {
19238
+ className: "react-autoql-filter-info-text"
19239
+ }, "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.")), /*#__PURE__*/React.createElement(Autosuggest, {
19003
19240
  ref: function ref(_ref2) {
19004
19241
  _this.autoSuggest = _ref2;
19005
19242
  },
19243
+ id: "react-autoql-filter-menu-input",
19244
+ highlightFirstSuggestion: true,
19006
19245
  suggestions: _this.state.suggestions,
19007
19246
  onSuggestionsFetchRequested: _this.onSuggestionsFetchRequested,
19008
19247
  onSuggestionsClearRequested: _this.onSuggestionsClearRequested,
19009
19248
  getSuggestionValue: _this.getSuggestionValue,
19010
19249
  renderSuggestion: function renderSuggestion(suggestion) {
19011
- return /*#__PURE__*/React.createElement(Fragment, null, suggestion.name.keyword);
19250
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
19251
+ id: "react-autoql-filter-table",
19252
+ className: "autoql-condition-locking-menu-list"
19253
+ }, /*#__PURE__*/React.createElement("tr", {
19254
+ id: "react-autoql-filter-table-row"
19255
+ }, /*#__PURE__*/React.createElement("td", {
19256
+ id: "react-autoql-filter-table-data",
19257
+ style: {
19258
+ width: 300
19259
+ }
19260
+ }, suggestion.name.keyword), /*#__PURE__*/React.createElement("td", {
19261
+ id: "react-autoql-filter-table-data"
19262
+ }, suggestion.name.show_message))));
19012
19263
  },
19013
19264
  inputProps: {
19014
19265
  onChange: _this.onInputChange,
19015
19266
  value: _this.state.inputValue,
19016
- placeholder: 'Search for a condition.',
19017
- className: 'react-autoql-condition-locking-input'
19267
+ disabled: _this.state.isFetchingConditions,
19268
+ placeholder: 'Search & select a filter',
19269
+ className: 'react-autoql-condition-locking-input',
19270
+ id: 'react-autoql-filter-menu-input'
19018
19271
  }
19019
- }))), /*#__PURE__*/React.createElement("div", {
19020
- className: "condition-list"
19272
+ }), /*#__PURE__*/React.createElement("div", {
19273
+ id: "react-autoql-filter-setting-info-card"
19274
+ }, /*#__PURE__*/React.createElement("p", {
19275
+ className: "react-autoql-filter-info-text"
19276
+ }, /*#__PURE__*/React.createElement(Icon, {
19277
+ type: "info"
19278
+ }), ' ', /*#__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, {
19279
+ type: "info"
19280
+ }), ' ', /*#__PURE__*/React.createElement("strong", null, "Session"), " filters remain locked until you end your browser session.")))), _this.state.isFetchingConditions ? /*#__PURE__*/React.createElement("div", {
19281
+ className: "react-autoql-condition-list-loading-container"
19282
+ }, /*#__PURE__*/React.createElement(LoadingDots, null)) : /*#__PURE__*/React.createElement("div", {
19283
+ className: "react-autoql-condition-list"
19021
19284
  }, _get(_this.state.selectedConditions, 'length') === 0 ? /*#__PURE__*/React.createElement("div", {
19022
- 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", {
19285
+ className: "react-autoql-empty-condition-list"
19286
+ }, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("i", null, lang.noFiltersLocked))) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("table", {
19287
+ className: "react-autoql-condition-table"
19288
+ }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
19024
19289
  style: {
19025
- minHeight: 100
19026
- }
19027
- }, /*#__PURE__*/React.createElement("table", {
19028
- className: "condition-table"
19029
- }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("th", {
19030
- scope: "col"
19031
- }, "Condition"), /*#__PURE__*/React.createElement("th", {
19032
- scope: "col"
19033
- }, "Category"), /*#__PURE__*/React.createElement("th", {
19034
- scope: "col",
19290
+ width: '60%'
19291
+ }
19292
+ }, "Filter"), /*#__PURE__*/React.createElement("th", null, "Settings", /*#__PURE__*/React.createElement(Icon, {
19293
+ type: "info",
19294
+ ref: _this.mouseSettingRef,
19295
+ onMouseEnter: _this.onEnterFilterSettingInfo,
19296
+ onMouseLeave: _this.onLeaveFilterSettingInfo
19297
+ })), /*#__PURE__*/React.createElement("th", {
19035
19298
  style: {
19036
19299
  display: 'table-cell',
19037
19300
  verticalAlign: 'middle',
19038
- textAlign: 'right'
19301
+ textAlign: 'right',
19302
+ width: '35px'
19039
19303
  }
19040
- }, "Actions")), /*#__PURE__*/React.createElement("tbody", null, _this.state.selectedConditions.map(function (item, index) {
19304
+ }))), /*#__PURE__*/React.createElement("tbody", null, _this.state.selectedConditions.map(function (item, index) {
19041
19305
  return /*#__PURE__*/React.createElement("tr", {
19042
- key: index
19043
- }, /*#__PURE__*/React.createElement("td", null, item.keyword), /*#__PURE__*/React.createElement("td", null, item.show_message), /*#__PURE__*/React.createElement("td", {
19306
+ key: index,
19307
+ id: "react-autoql-condition-table-list-item-".concat(index)
19308
+ }, /*#__PURE__*/React.createElement("td", {
19309
+ className: "react-autoql-condition-table-list-item"
19310
+ }, item.keyword, ' ', "(".concat(item.show_message, ")")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Switch, {
19311
+ onChange: function onChange() {
19312
+ return _this.handlePersistConditionToggle(item, index);
19313
+ },
19314
+ checked: item.lock_flag,
19315
+ onColor: "#86d3ff",
19316
+ onHandleColor: "#2693e6",
19317
+ uncheckedIcon: false,
19318
+ checkedIcon: false,
19319
+ boxShadow: "0px 1px 5px rgba(0, 0, 0, 0.6)",
19320
+ activeBoxShadow: "0px 0px 1px 1px rgba(0, 0, 0, 0.2)",
19321
+ handleDiameter: 16,
19322
+ height: 18,
19323
+ width: 34
19324
+ }), ' ', item.lock_flag ? 'Persistent' : 'Session')), /*#__PURE__*/React.createElement("td", {
19325
+ id: "react-autoql-remove-filter-container",
19044
19326
  style: {
19045
19327
  display: 'table-cell',
19046
19328
  verticalAlign: 'middle',
19047
- textAlign: 'right'
19329
+ textAlign: 'right',
19330
+ width: '35px'
19048
19331
  }
19049
19332
  }, /*#__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
19333
  className: "react-autoql-chart-tooltip",
19056
19334
  id: "react-autoql-remove-condition",
19057
19335
  effect: "solid",
19058
19336
  html: true
19059
19337
  }), /*#__PURE__*/React.createElement(Icon, {
19338
+ id: "react-autoql-remove-filtered-condition-icon",
19060
19339
  style: {
19061
19340
  paddingLeft: 5,
19062
- color: 'red'
19341
+ color: 'red',
19342
+ cursor: 'pointer'
19063
19343
  },
19064
- "data-tip": "Remove this condition",
19344
+ "data-tip": "Remove filter",
19065
19345
  "data-for": "react-autoql-remove-condition",
19066
19346
  type: "trash",
19067
19347
  onClick: function onClick() {
19068
19348
  return _this.removeCondition(item, index);
19069
19349
  }
19070
19350
  })));
19071
- })), /*#__PURE__*/React.createElement("tfoot", null)))), _this.renderAcceptConditionsButton())));
19351
+ })), /*#__PURE__*/React.createElement("tfoot", null))))), /*#__PURE__*/React.createElement("div", {
19352
+ className: "react-autoql-condition-lock-menu-footer"
19353
+ }, /*#__PURE__*/React.createElement(Button, {
19354
+ size: "small",
19355
+ disabled: _this.state.isFetchingConditions,
19356
+ onClick: function onClick() {
19357
+ _this.props.onClose();
19358
+ }
19359
+ }, "Continue"))));
19072
19360
  });
19073
19361
 
19074
19362
  return _this;
19075
19363
  }
19076
19364
 
19365
+ _createClass(ConditionLockMenu, [{
19366
+ key: "handleShowMessage",
19367
+ value: function handleShowMessage(type, message) {
19368
+ var el = document.getElementById('react-autoql-condition-show-message');
19369
+ el.className = 'show';
19370
+ el.style.animation = 'none';
19371
+ setTimeout(function () {
19372
+ el.style.animation = '';
19373
+ }, 10);
19374
+ setTimeout(function () {
19375
+ el.className = el.className.replace('show', '');
19376
+ }, 3000);
19377
+ this.setState({
19378
+ inputValue: '',
19379
+ showMessage: {
19380
+ type: type,
19381
+ message: message
19382
+ }
19383
+ });
19384
+ }
19385
+ }, {
19386
+ key: "handleHighlightFilterRow",
19387
+ value: function handleHighlightFilterRow(index) {
19388
+ var el = document.getElementById("react-autoql-condition-table-list-item-".concat(index));
19389
+
19390
+ if (el) {
19391
+ el.className = 'react-autoql-highlight-row';
19392
+ setTimeout(function () {
19393
+ el.className = el.className.replace('react-autoql-highlight-row', '');
19394
+ }, 1800);
19395
+ }
19396
+ }
19397
+ }]);
19398
+
19077
19399
  return ConditionLockMenu;
19078
19400
  }(React.Component);
19079
19401
 
19080
19402
  _defineProperty(ConditionLockMenu, "propTypes", {
19081
- containerWidth: PropTypes.string,
19403
+ containerWidth: PropTypes.number,
19082
19404
  isOpen: PropTypes.bool,
19083
19405
  onClose: PropTypes.func,
19084
- authentication: authenticationType
19406
+ authentication: authenticationType,
19407
+ initFilterText: PropTypes.string
19085
19408
  });
19086
19409
 
19087
19410
  _defineProperty(ConditionLockMenu, "defaultProps", {
19088
19411
  containerWidth: undefined,
19089
- onClose: function onClose() {}
19412
+ onClose: function onClose() {},
19413
+ isOpen: false,
19414
+ authentication: undefined,
19415
+ initFilterText: undefined
19090
19416
  });
19091
19417
 
19092
19418
  var DataMessenger = /*#__PURE__*/function (_React$Component) {
@@ -19113,7 +19439,8 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19113
19439
  isResizing: false,
19114
19440
  lastMessageId: undefined,
19115
19441
  isOptionsDropdownOpen: false,
19116
- isConditionLockingMenuOpen: false,
19442
+ isFilterLockingMenuOpen: false,
19443
+ selectedValueLabel: undefined,
19117
19444
  conditions: undefined,
19118
19445
  messages: [],
19119
19446
  queryTipsList: undefined,
@@ -19145,11 +19472,20 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19145
19472
  } // WIP
19146
19473
 
19147
19474
 
19148
- fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
19149
- _this.setState({
19150
- conditions: _get(response, 'data.data.data')
19475
+ try {
19476
+ fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
19477
+ var sessionConditions = JSON.parse(sessionStorage.getItem('conditions'));
19478
+
19479
+ _this.setState({
19480
+ conditions: {
19481
+ persistent: _get(response, 'data.data.data'),
19482
+ session: sessionConditions
19483
+ }
19484
+ });
19151
19485
  });
19152
- });
19486
+ } catch (e) {
19487
+ console.error(e);
19488
+ }
19153
19489
  });
19154
19490
 
19155
19491
  _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (prevProps, prevState) {
@@ -19179,6 +19515,26 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19179
19515
  if (thisTheme && thisTheme !== prevTheme) {
19180
19516
  setCSSVars(getThemeConfig(getThemeConfig(_this.props.themeConfig)));
19181
19517
  }
19518
+
19519
+ if (_this.state.isFilterLockingMenuOpen !== prevState.isFilterLockingMenuOpen) {
19520
+ fetchConditions(_objectSpread2({}, getAuthentication(_this.props.authentication))).then(function (response) {
19521
+ var sessionConditions = JSON.parse(sessionStorage.getItem('conditions'));
19522
+
19523
+ _this.setState({
19524
+ conditions: {
19525
+ persistent: _get(response, 'data.data.data'),
19526
+ session: sessionConditions
19527
+ }
19528
+ });
19529
+ });
19530
+ }
19531
+
19532
+ if (_this.state.activePage !== prevState.activePage) {
19533
+ _this.setState({
19534
+ isFilterLockingMenuOpen: false,
19535
+ selectedValueLabel: undefined
19536
+ });
19537
+ }
19182
19538
  } catch (error) {
19183
19539
  console.error(error);
19184
19540
 
@@ -19297,7 +19653,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19297
19653
  messages: introMessages,
19298
19654
  lastMessageId: introMessages[introMessages.length - 1].id,
19299
19655
  isOptionsDropdownOpen: false,
19300
- isConditionLockingMenuOpen: false
19656
+ isFilterLockingMenuOpen: false
19301
19657
  });
19302
19658
  });
19303
19659
 
@@ -19359,7 +19715,10 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19359
19715
  }
19360
19716
 
19361
19717
  if (_this.props.onMaskClick) {
19362
- _this.props.onMaskClick();
19718
+ _this.setState({
19719
+ isFilterLockingMenuOpen: false,
19720
+ selectedValueLabel: undefined
19721
+ }, _this.props.onMaskClick());
19363
19722
  }
19364
19723
 
19365
19724
  if (_this.props.onHandleClick) {
@@ -19639,7 +19998,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19639
19998
  }
19640
19999
  });
19641
20000
 
19642
- _defineProperty(_assertThisInitialized(_this), "getConditionMenuPosition", function () {
20001
+ _defineProperty(_assertThisInitialized(_this), "getFilterMenuPosition", function () {
19643
20002
  switch (_this.getPlacementProp()) {
19644
20003
  case 'right':
19645
20004
  return {
@@ -19733,6 +20092,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19733
20092
  },
19734
20093
  overflowCount: 9,
19735
20094
  useDot: true,
20095
+ isAlreadyMountedInDOM: /*#__PURE__*/React.isValidElement( /*#__PURE__*/React.createElement(NotificationIcon, null)),
19736
20096
  onNewNotification: function onNewNotification() {
19737
20097
  // If a new notification is detected, refresh the list
19738
20098
  if (_this.notificationListRef && _this.state.activePage === 'notifications') {
@@ -19747,24 +20107,24 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19747
20107
  _defineProperty(_assertThisInitialized(_this), "renderOptionsDropdown", function () {
19748
20108
  if (_this.state.activePage === 'data-messenger') {
19749
20109
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
19750
- id: "condition-dropdown",
20110
+ id: "react-autoql-filter-menu-dropdown",
19751
20111
  style: {
19752
20112
  justifyContent: 'left',
19753
20113
  position: 'absolute',
19754
20114
  right: 30
19755
20115
  }
19756
- }, window.location.href.includes('localhost') || window.location.href.includes('chata-ai-test-page') ? /*#__PURE__*/React.createElement("button", {
19757
- id: "condition-dropdown",
20116
+ }, getAutoQLConfig$1(getAutoQLConfig$1(_this.props.autoQLConfig)).enableFilterLocking ? /*#__PURE__*/React.createElement("button", {
20117
+ id: "react-autoql-filter-menu-dropdown-button",
19758
20118
  onClick: function onClick() {
19759
20119
  _this.setState({
19760
- isConditionLockingMenuOpen: !_this.state.isConditionLockingMenuOpen
20120
+ isFilterLockingMenuOpen: !_this.state.isFilterLockingMenuOpen
19761
20121
  });
19762
20122
  },
19763
20123
  className: "react-autoql-drawer-header-btn clear-all",
19764
- "data-tip": lang.dataMessengerOptions,
20124
+ "data-tip": lang.openFilterLocking,
19765
20125
  "data-for": "react-autoql-header-tooltip"
19766
20126
  }, /*#__PURE__*/React.createElement(Icon, {
19767
- type: _get(_this.state.conditions, 'length') > 0 ? "lock" : "unlock"
20127
+ type: _get(_this.state.conditions, 'persistent.length') > 0 || _get(_this.state.conditions, 'session.length') > 0 ? 'lock' : 'unlock'
19768
20128
  })) : /*#__PURE__*/React.createElement("span", null)), /*#__PURE__*/React.createElement(Popover, {
19769
20129
  isOpen: _this.state.isOptionsDropdownOpen,
19770
20130
  onClickOutside: function onClickOutside() {
@@ -19812,7 +20172,7 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19812
20172
  });
19813
20173
  },
19814
20174
  className: "react-autoql-drawer-header-btn clear-all",
19815
- "data-tip": lang.dataMessengerOptions,
20175
+ "data-tip": lang.clearDataResponses,
19816
20176
  "data-for": "react-autoql-header-tooltip"
19817
20177
  }, /*#__PURE__*/React.createElement(Icon, {
19818
20178
  type: "trash"
@@ -19840,23 +20200,11 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19840
20200
  }, title);
19841
20201
  });
19842
20202
 
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
20203
  _defineProperty(_assertThisInitialized(_this), "renderHeaderContent", function () {
19852
20204
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
19853
20205
  className: "react-autoql-header-left-container"
19854
20206
  }, /*#__PURE__*/React.createElement("button", {
19855
20207
  onClick: function onClick() {
19856
- _this.setState({
19857
- isConditionLockingMenuOpen: false
19858
- });
19859
-
19860
20208
  _this.props.onHandleClick();
19861
20209
  },
19862
20210
  className: "react-autoql-drawer-header-btn close",
@@ -19864,9 +20212,25 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19864
20212
  "data-for": "react-autoql-header-tooltip"
19865
20213
  }, /*#__PURE__*/React.createElement(Icon, {
19866
20214
  type: "close"
19867
- }))), /*#__PURE__*/React.createElement(Popover, {
19868
- containerStyle: _this.getConditionMenuPosition(),
19869
- isOpen: _this.state.isConditionLockingMenuOpen,
20215
+ }))), !getAutoQLConfig$1(getAutoQLConfig$1(_this.props.autoQLConfig)).enableFilterLocking && _this.state.isFilterLockingMenuOpen ? /*#__PURE__*/React.createElement("div", {
20216
+ className: "react-autoql-header-center-container"
20217
+ }, _this.renderHeaderTitle()) : /*#__PURE__*/React.createElement(Popover, {
20218
+ containerStyle: _this.getFilterMenuPosition(),
20219
+ isOpen: _this.state.isFilterLockingMenuOpen,
20220
+ onClickOutside: function onClickOutside(e) {
20221
+ /**
20222
+ * Because the popover anchor is over the header title instead of the button,
20223
+ * the button is considered part of an "outside" event. This also includes
20224
+ * some elements inside of the popover as well for some reason.
20225
+ *
20226
+ * This is a hacky solution, but it works.
20227
+ */
20228
+ if (_get(e, 'target.id') !== 'react-autoql-interpreted-value-label' && _get(e, 'target.parentElement.parentElement.parentElement.id') !== 'react-autoql-filter-menu-dropdown-button' && _get(e, 'target.parentElement.parentElement.parentElement.id') !== 'react-autoql-filter-menu-dropdown' && _get(e, 'target.parentElement.id') !== 'react-autoql-filter-table-row' && _get(e, 'target.parentElement.id') !== 'react-autoql-remove-filtered-condition-icon' && _get(e, 'target.parentElement.parentElement.id') !== 'react-autoql-remove-filtered-condition-icon' && _get(e, 'target.parentElement.id') !== 'react-autoql-remove-filter-container' && !_get(e, 'target.classList.value').includes('react-autoql-drawer-resize-handle')) {
20229
+ _this.setState({
20230
+ isFilterLockingMenuOpen: false
20231
+ });
20232
+ }
20233
+ },
19870
20234
  position: "bottom",
19871
20235
  padding: 2,
19872
20236
  align: "center",
@@ -19878,24 +20242,18 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19878
20242
  }, /*#__PURE__*/React.createElement(ConditionLockMenu, {
19879
20243
  authentication: getAuthentication(getAuthentication(_this.props.authentication)),
19880
20244
  containerWidth: _this.getDrawerWidth(),
19881
- 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
-
20245
+ isOpen: _this.state.isFilterLockingMenuOpen,
20246
+ initFilterText: _this.state.selectedValueLabel,
20247
+ onClose: function onClose() {
19891
20248
  _this.setState({
19892
- isConditionLockingMenuOpen: false
20249
+ isFilterLockingMenuOpen: false,
20250
+ selectedValueLabel: undefined
19893
20251
  });
19894
20252
  }
19895
20253
  }))
19896
20254
  }, /*#__PURE__*/React.createElement("div", {
19897
20255
  className: "react-autoql-header-center-container"
19898
- }, _this.renderHeaderTitle(), _this.renderShowSuccessMessage())), /*#__PURE__*/React.createElement("div", {
20256
+ }, _this.renderHeaderTitle())), /*#__PURE__*/React.createElement("div", {
19899
20257
  className: "react-autoql-header-right-container"
19900
20258
  }, _this.renderOptionsDropdown()));
19901
20259
  });
@@ -19978,7 +20336,18 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
19978
20336
  isResizing: _this.state.isResizing,
19979
20337
  enableDynamicCharting: _this.props.enableDynamicCharting,
19980
20338
  onNoneOfTheseClick: _this.onNoneOfTheseClick,
19981
- autoChartAggregations: _this.props.autoChartAggregations
20339
+ autoChartAggregations: _this.props.autoChartAggregations,
20340
+ onConditionClickCallback: function onConditionClickCallback(e) {
20341
+ if (_get(e, 'target.classList.value').includes('react-autoql-condition-link')) {
20342
+ _this.setState({
20343
+ selectedValueLabel: _get(e, 'target.innerText').replace('lock ', '').trim()
20344
+ });
20345
+ }
20346
+
20347
+ _this.setState({
20348
+ isFilterLockingMenuOpen: true
20349
+ });
20350
+ }
19982
20351
  });
19983
20352
  })), _this.state.isChataThinking && /*#__PURE__*/React.createElement("div", {
19984
20353
  className: "response-loading-container"
@@ -20324,7 +20693,12 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
20324
20693
  width: _this.getDrawerWidth(),
20325
20694
  height: _this.getDrawerHeight(),
20326
20695
  onMaskClick: _this.handleMaskClick,
20327
- onHandleClick: _this.props.onHandleClick,
20696
+ onHandleClick: function onHandleClick() {
20697
+ _this.setState({
20698
+ isFilterLockingMenuOpen: false,
20699
+ selectedValueLabel: undefined
20700
+ }, _this.props.onHandleClick);
20701
+ },
20328
20702
  afterVisibleChange: _this.props.onVisibleChange,
20329
20703
  handler: _this.getHandlerProp(),
20330
20704
  level: _this.props.shiftScreen ? 'all' : null,
@@ -20380,6 +20754,36 @@ var DataMessenger = /*#__PURE__*/function (_React$Component) {
20380
20754
  });
20381
20755
  }
20382
20756
  }
20757
+ }, {
20758
+ key: "removeDuplicateMessengerInstance",
20759
+ value:
20760
+ /**
20761
+ * For some indiscernible reason, the Data Messenger drawer duplicates itself in the DOM.
20762
+ * three times when first opened, then a number more times with each and every query
20763
+ * being made.
20764
+ *
20765
+ * This function removes unnecessary duplicate instances of the Data Messenger Drawer
20766
+ * and should help improve performance a bit by reducing the amount of renders.
20767
+ *
20768
+ * https://stackoverflow.com/questions/57946748/remove-duplicate-dom-element-javascript-not-jquery
20769
+ */
20770
+ function removeDuplicateMessengerInstance() {
20771
+ var instance = {};
20772
+
20773
+ var _iterator = _createForOfIteratorHelper(document.querySelectorAll('.ReactModalPortal')),
20774
+ _step;
20775
+
20776
+ try {
20777
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
20778
+ var item = _step.value;
20779
+ if (instance[item]) item.parentNode.removeChild(item);else instance[item] = true;
20780
+ }
20781
+ } catch (err) {
20782
+ _iterator.e(err);
20783
+ } finally {
20784
+ _iterator.f();
20785
+ }
20786
+ }
20383
20787
  }]);
20384
20788
 
20385
20789
  return DataMessenger;
@@ -20415,6 +20819,9 @@ _defineProperty(DataMessenger, "propTypes", {
20415
20819
  enableDynamicCharting: bool,
20416
20820
  defaultTab: string,
20417
20821
  autoChartAggregations: bool,
20822
+ enableQueryInterpretation: bool,
20823
+ defaultShowInterpretation: bool,
20824
+ enableFilterLocking: bool,
20418
20825
  // Callbacks
20419
20826
  onVisibleChange: func,
20420
20827
  onHandleClick: func,
@@ -20452,6 +20859,9 @@ _defineProperty(DataMessenger, "defaultProps", {
20452
20859
  enableDynamicCharting: true,
20453
20860
  defaultTab: 'data-messenger',
20454
20861
  autoChartAggregations: true,
20862
+ enableQueryInterpretation: false,
20863
+ defaultShowInterpretation: false,
20864
+ enableFilterLocking: false,
20455
20865
  // Callbacks
20456
20866
  onHandleClick: function onHandleClick() {},
20457
20867
  onVisibleChange: function onVisibleChange() {},
@@ -21299,6 +21709,8 @@ var DashboardTile = /*#__PURE__*/function (_React$Component) {
21299
21709
  });
21300
21710
 
21301
21711
  _defineProperty(_assertThisInitialized(_this), "renderQueryOutput", function (_ref12) {
21712
+ var _extends2;
21713
+
21302
21714
  var _ref12$queryOutputPro = _ref12.queryOutputProps,
21303
21715
  queryOutputProps = _ref12$queryOutputPro === void 0 ? {} : _ref12$queryOutputPro,
21304
21716
  _ref12$vizToolbarProp = _ref12.vizToolbarProps,
@@ -21320,24 +21732,24 @@ var DashboardTile = /*#__PURE__*/function (_React$Component) {
21320
21732
  }, !queryOutputProps.queryResponse || isExecuting || _this.props.isUnExecuted ? _this.renderContentPlaceholder({
21321
21733
  isExecuting: isExecuting,
21322
21734
  isExecuted: isExecuted
21323
- }) : /*#__PURE__*/React.createElement(Fragment, null, _this.getIsSuggestionResponse(queryOutputProps.queryResponse) && _this.renderSuggestionMessage(customMessage), !customMessage && /*#__PURE__*/React.createElement(QueryOutput, _extends({
21735
+ }) : /*#__PURE__*/React.createElement(Fragment, null, _this.getIsSuggestionResponse(queryOutputProps.queryResponse) && _this.renderSuggestionMessage(customMessage), !customMessage && /*#__PURE__*/React.createElement(QueryOutput, _extends((_extends2 = {
21324
21736
  authentication: getAuthentication(_this.props.authentication),
21325
21737
  themeConfig: getThemeConfig(_this.props.themeConfig),
21326
21738
  autoQLConfig: getAutoQLConfig$1(_this.props.autoQLConfig),
21327
21739
  dataFormatting: getDataFormatting(_this.props.dataFormatting),
21328
21740
  renderTooltips: false,
21329
21741
  autoSelectQueryValidationSuggestion: false,
21742
+ isDashboardQuery: true,
21330
21743
  autoChartAggregations: _this.props.autoChartAggregations,
21331
21744
  renderSuggestionsAsDropdown: _this.props.tile.h < 4,
21332
21745
  enableDynamicCharting: _this.props.enableDynamicCharting,
21333
- backgroundColor: document.documentElement.style.getPropertyValue('--react-autoql-background-color-primary'),
21334
- onDisplayTypeUpdate: function onDisplayTypeUpdate() {
21335
- // This is necessary to update the toolbar with the newly rendered QueryOutput
21336
- setTimeout(function () {
21337
- _this.forceUpdate();
21338
- }, 0);
21339
- }
21340
- }, queryOutputProps)), _this.renderDataLimitWarning()), _this.props.isEditing && /*#__PURE__*/React.createElement("div", {
21746
+ backgroundColor: document.documentElement.style.getPropertyValue('--react-autoql-background-color-primary')
21747
+ }, _defineProperty(_extends2, "isDashboardQuery", true), _defineProperty(_extends2, "onDisplayTypeUpdate", function onDisplayTypeUpdate() {
21748
+ // This is necessary to update the toolbar with the newly rendered QueryOutput
21749
+ setTimeout(function () {
21750
+ _this.forceUpdate();
21751
+ }, 0);
21752
+ }), _extends2), queryOutputProps)), _this.renderDataLimitWarning()), _this.props.isEditing && /*#__PURE__*/React.createElement("div", {
21341
21753
  className: "dashboard-tile-viz-toolbar-container"
21342
21754
  }, _this.props.isEditing && showSplitViewBtn && _this.renderSplitViewBtn(), /*#__PURE__*/React.createElement(VizToolbar$1, _extends({
21343
21755
  themeConfig: getThemeConfig(_this.props.themeConfig)
@@ -21974,6 +22386,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
21974
22386
  dataFormatting: getDataFormatting(_this.props.dataFormatting),
21975
22387
  queryResponse: _this.state.activeDrilldownResponse,
21976
22388
  renderTooltips: false,
22389
+ isDashboardQuery: true,
21977
22390
  autoChartAggregations: _this.props.autoChartAggregations,
21978
22391
  backgroundColor: document.documentElement.style.getPropertyValue('--react-autoql-background-color-primary'),
21979
22392
  reportProblemCallback: _this.reportProblemCallback,
@@ -21995,6 +22408,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
21995
22408
  dataFormatting: getDataFormatting(_this.props.dataFormatting),
21996
22409
  queryResponse: _this.state.activeDrilldownResponse,
21997
22410
  renderTooltips: false,
22411
+ isDashboardQuery: true,
21998
22412
  autoChartAggregations: _this.props.autoChartAggregations,
21999
22413
  backgroundColor: document.documentElement.style.getPropertyValue('--react-autoql-background-color-primary'),
22000
22414
  reportProblemCallback: _this.reportProblemCallback,
@@ -22053,7 +22467,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
22053
22467
  displayType = tile.secondDisplayType;
22054
22468
  dataConfig = tile.secondDataConfig;
22055
22469
  } else if (tile && !_this.state.isDrilldownSecondHalf) {
22056
- title = tile.query;
22470
+ title = tile.title;
22057
22471
  queryResponse = tile.queryResponse;
22058
22472
  displayType = tile.displayType;
22059
22473
  dataConfig = tile.dataConfig;
@@ -22092,6 +22506,7 @@ var Dashboard = /*#__PURE__*/function (_React$Component) {
22092
22506
  queryResponse: queryResponse,
22093
22507
  displayType: displayType,
22094
22508
  dataConfig: dataConfig,
22509
+ isDashboardQuery: true,
22095
22510
  autoChartAggregations: _this.props.autoChartAggregations,
22096
22511
  onDataClick: function onDataClick(drilldownData, queryID) {
22097
22512
  _this.startDrilldown(drilldownData, queryID, tile.i);
@@ -22272,4 +22687,215 @@ _defineProperty(Dashboard, "defaultProps", {
22272
22687
  onChange: function onChange() {}
22273
22688
  });
22274
22689
 
22690
+ var SpeechToTextBtn = /*#__PURE__*/function (_React$Component) {
22691
+ _inherits(SpeechToTextBtn, _React$Component);
22692
+
22693
+ var _super = _createSuper(SpeechToTextBtn);
22694
+
22695
+ function SpeechToTextBtn() {
22696
+ var _this;
22697
+
22698
+ _classCallCheck(this, SpeechToTextBtn);
22699
+
22700
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22701
+ args[_key] = arguments[_key];
22702
+ }
22703
+
22704
+ _this = _super.call.apply(_super, [this].concat(args));
22705
+
22706
+ _defineProperty(_assertThisInitialized(_this), "state", {
22707
+ isRecording: false,
22708
+ currentQuery: 0,
22709
+ resultHistory: [],
22710
+ currentFile: '',
22711
+ currentBlob: '',
22712
+ showPopoverMessage: false,
22713
+ errorMessage: ''
22714
+ });
22715
+
22716
+ _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {
22717
+ setCSSVars(getThemeConfig(_this.props.themeConfig));
22718
+ });
22719
+
22720
+ _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (prevProps) {
22721
+ if (_this.props.finalTranscript !== prevProps.finalTranscript) {
22722
+ _this.props.onFinalTranscript(_this.props.finalTranscript);
22723
+ } else if (_this.props.transcript !== prevProps.transcript) {
22724
+ _this.props.onTranscriptChange(_this.props.transcript);
22725
+ } else if (_this.props.interimTranscript !== prevProps.interimTranscript) {
22726
+ _this.props.onTranscriptChange(_this.props.interimTranscript);
22727
+ }
22728
+ });
22729
+
22730
+ _defineProperty(_assertThisInitialized(_this), "startRecording", function () {
22731
+ _this.setState({
22732
+ isRecording: true
22733
+ });
22734
+
22735
+ navigator.getUserMedia({
22736
+ audio: true
22737
+ }, function (stream) {
22738
+ _this.stream = stream;
22739
+ _this.recordAudio = RecordRTC(_this.stream, {
22740
+ type: 'audio',
22741
+ mimeType: 'audio/webm',
22742
+ desiredSampRate: 16000,
22743
+ recorderType: StereoAudioRecorder,
22744
+ numberOfAudioChannels: 1
22745
+ });
22746
+
22747
+ _this.recordAudio.startRecording();
22748
+ }, function (error) {
22749
+ console.error(JSON.stringify(error));
22750
+ });
22751
+ });
22752
+
22753
+ _defineProperty(_assertThisInitialized(_this), "onRecordStop", function (file, blob) {
22754
+ _this.setState({
22755
+ // isConfirmingRecording: true,
22756
+ currentFile: file,
22757
+ currentBlob: blob //hasPlayedBack: false,
22758
+
22759
+ }, function () {
22760
+ _this.sendWavFile(file);
22761
+ });
22762
+ });
22763
+
22764
+ _defineProperty(_assertThisInitialized(_this), "stopRecording", function () {
22765
+ _this.setState({
22766
+ isRecording: false
22767
+ });
22768
+
22769
+ _this.recordAudio.stopRecording(function () {
22770
+ var blob = _this.recordAudio.getBlob();
22771
+
22772
+ _this.onRecordStop(_this.blobToFile(blob), blob);
22773
+
22774
+ try {
22775
+ _this.stream.getTracks().forEach(function (track) {
22776
+ return track.stop();
22777
+ });
22778
+ } catch (error) {
22779
+ console.error(error);
22780
+ }
22781
+ });
22782
+ });
22783
+
22784
+ _defineProperty(_assertThisInitialized(_this), "blobToFile", function (theBlob) {
22785
+ //A Blob() is almost a File() - it's just missing the two properties below which we will add
22786
+ theBlob.lastModifiedDate = new Date();
22787
+ theBlob.name = 'speech.wav';
22788
+ return theBlob;
22789
+ });
22790
+
22791
+ _defineProperty(_assertThisInitialized(_this), "getMediaPermissionStatus", function () {
22792
+ return navigator.permissions.query({
22793
+ name: 'microphone'
22794
+ }).then(function (permissionStatus) {
22795
+ return permissionStatus.state;
22796
+ });
22797
+ });
22798
+
22799
+ _defineProperty(_assertThisInitialized(_this), "onMouseDown", function () {
22800
+ ReactTooltip.hide();
22801
+
22802
+ _this.startRecording();
22803
+ });
22804
+
22805
+ _defineProperty(_assertThisInitialized(_this), "sendWavFile", function (file) {
22806
+ var url = "".concat(_this.props.authentication.domain, "/autoql/api/v1/query/speech-to-text?key=").concat(_this.props.authentication.apiKey);
22807
+ var data = new FormData();
22808
+ data.append('file', file, 'speech.wav');
22809
+ var config = {
22810
+ headers: {
22811
+ Authorization: "Bearer ".concat(_this.props.authentication.token)
22812
+ },
22813
+ timeout: 30000
22814
+ };
22815
+ axios.post(url, data, config).then(function (res) {
22816
+ _this.props.onTranscriptChange(res.data.data.transcription);
22817
+ }).catch(function (error) {
22818
+ if (error.response.status === 404) {
22819
+ _this.setState({
22820
+ errorMessage: 'Oops! Speech-to-text has not been enabled. Try typing a query instead.'
22821
+ }, function () {
22822
+ _this.setState({
22823
+ showPopoverMessage: true
22824
+ });
22825
+ });
22826
+ } else {
22827
+ _this.setState({
22828
+ errorMessage: 'Oops! Something wrong with your account'
22829
+ }, function () {
22830
+ _this.setState({
22831
+ showPopoverMessage: true
22832
+ });
22833
+ });
22834
+ }
22835
+ });
22836
+ });
22837
+
22838
+ _defineProperty(_assertThisInitialized(_this), "render", function () {
22839
+ return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Popover, {
22840
+ isOpen: _this.state.showPopoverMessage,
22841
+ padding: 20,
22842
+ content: function content() {
22843
+ return /*#__PURE__*/React.createElement("div", {
22844
+ style: {
22845
+ backgroundColor: '#FFD2D2',
22846
+ opacity: 1,
22847
+ paddingLeft: '10px',
22848
+ paddingRight: '10px'
22849
+ }
22850
+ }, /*#__PURE__*/React.createElement(Icon, {
22851
+ type: "warning-triangle"
22852
+ }), " ", _this.state.errorMessage);
22853
+ },
22854
+ onClickOutside: function onClickOutside() {
22855
+ return _this.setState({
22856
+ showPopoverMessage: false
22857
+ });
22858
+ }
22859
+ }, /*#__PURE__*/React.createElement("button", {
22860
+ id: "react-autoql-voice-record-button",
22861
+ "data-test": "speech-to-text-btn",
22862
+ className: "chat-voice-record-button".concat(_this.state.isRecording ? ' listening' : ''),
22863
+ onMouseDown: _this.onMouseDown,
22864
+ onMouseUp: _this.stopRecording,
22865
+ onMouseLeave: _this.state.isRecording ? _this.stopRecording : undefined,
22866
+ "data-tip": "Hold for voice-to-text",
22867
+ "data-for": "react-autoql-speech-to-text-tooltip",
22868
+ "data-tip-disable": _this.state.isRecording
22869
+ }, /*#__PURE__*/React.createElement(Icon, {
22870
+ type: "microphone"
22871
+ }))), /*#__PURE__*/React.createElement(ReactTooltip, {
22872
+ className: "react-autoql-tooltip",
22873
+ id: "react-autoql-speech-to-text-tooltip",
22874
+ effect: "solid",
22875
+ delayShow: 800
22876
+ }));
22877
+ });
22878
+
22879
+ return _this;
22880
+ }
22881
+
22882
+ return SpeechToTextBtn;
22883
+ }(React.Component);
22884
+
22885
+ _defineProperty(SpeechToTextBtn, "propTypes", {
22886
+ authentication: authenticationType,
22887
+ themeConfig: themeConfigType,
22888
+ transcript: PropTypes.string,
22889
+ interimTranscript: PropTypes.string,
22890
+ finalTranscript: PropTypes.string,
22891
+ resetTranscript: PropTypes.func,
22892
+ onTranscriptChange: PropTypes.func,
22893
+ onFinalTranscript: PropTypes.func
22894
+ });
22895
+
22896
+ _defineProperty(SpeechToTextBtn, "defaultProps", {
22897
+ authentication: authenticationDefault,
22898
+ themeConfig: themeConfigDefault
22899
+ });
22900
+
22275
22901
  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 };