@jetbrains/ring-ui-built 6.0.31 → 6.0.32

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.
Files changed (225) hide show
  1. package/components/_helpers/_rollupPluginBabelHelpers.js +1 -567
  2. package/components/_helpers/anchor.js +7 -6
  3. package/components/_helpers/button__classes.js +16 -14
  4. package/components/_helpers/caption.js +14 -20
  5. package/components/_helpers/card.js +95 -105
  6. package/components/_helpers/dialog__body-scroll-preventer.js +11 -19
  7. package/components/_helpers/icon__svg.js +22 -25
  8. package/components/_helpers/input.js +146 -177
  9. package/components/_helpers/query-assist__suggestions.js +74 -90
  10. package/components/_helpers/select__filter.js +48 -69
  11. package/components/_helpers/services-link.js +29 -37
  12. package/components/_helpers/sidebar.js +99 -107
  13. package/components/_helpers/tab-link.js +7 -7
  14. package/components/_helpers/theme.js +31 -40
  15. package/components/_helpers/title.js +57 -72
  16. package/components/alert/alert.js +150 -202
  17. package/components/alert/container.js +32 -41
  18. package/components/alert-service/alert-service.js +105 -170
  19. package/components/analytics/analytics.js +12 -22
  20. package/components/analytics/analytics__custom-plugin.js +54 -75
  21. package/components/auth/auth.js +4 -36
  22. package/components/auth/auth__core.js +746 -1471
  23. package/components/auth/background-flow.js +87 -127
  24. package/components/auth/down-notification.js +30 -73
  25. package/components/auth/iframe-flow.js +75 -133
  26. package/components/auth/request-builder.js +46 -82
  27. package/components/auth/response-parser.js +86 -116
  28. package/components/auth/storage.js +171 -334
  29. package/components/auth/token-validator.js +137 -242
  30. package/components/auth/window-flow.js +92 -134
  31. package/components/auth-dialog/auth-dialog.js +114 -172
  32. package/components/auth-dialog-service/auth-dialog-service.js +8 -31
  33. package/components/avatar/avatar-example-datauri.js +23 -1
  34. package/components/avatar/avatar.js +119 -152
  35. package/components/avatar/fallback-avatar.js +22 -38
  36. package/components/badge/badge.js +35 -45
  37. package/components/button/button.js +86 -107
  38. package/components/button-group/button-group.js +19 -33
  39. package/components/button-set/button-set.js +20 -32
  40. package/components/button-toolbar/button-toolbar.js +19 -31
  41. package/components/caret/caret.js +186 -220
  42. package/components/checkbox/checkbox.js +76 -101
  43. package/components/clipboard/clipboard-fallback.js +10 -10
  44. package/components/clipboard/clipboard.js +35 -132
  45. package/components/code/code.js +92 -166
  46. package/components/collapse/collapse-content.js +42 -64
  47. package/components/collapse/collapse-context.js +2 -2
  48. package/components/collapse/collapse-control.js +12 -14
  49. package/components/collapse/collapse.js +11 -17
  50. package/components/collapse/consts.js +4 -4
  51. package/components/collapse/utils.js +1 -3
  52. package/components/confirm/confirm.js +66 -104
  53. package/components/confirm-service/confirm-service.js +37 -59
  54. package/components/content-layout/content-layout.js +43 -64
  55. package/components/content-layout/sidebar.js +0 -1
  56. package/components/contenteditable/contenteditable.js +50 -59
  57. package/components/control-label/control-label.js +9 -9
  58. package/components/data-list/data-list.js +129 -182
  59. package/components/data-list/data-list.mock.js +2 -6
  60. package/components/data-list/item.js +143 -170
  61. package/components/data-list/selection.js +76 -136
  62. package/components/data-list/title.js +1 -12
  63. package/components/date-picker/consts.js +19 -26
  64. package/components/date-picker/date-input.js +113 -144
  65. package/components/date-picker/date-picker.js +227 -282
  66. package/components/date-picker/date-popup.js +350 -395
  67. package/components/date-picker/day.js +87 -116
  68. package/components/date-picker/month-names.js +43 -66
  69. package/components/date-picker/month-slider.js +51 -76
  70. package/components/date-picker/month.js +16 -25
  71. package/components/date-picker/months.js +43 -50
  72. package/components/date-picker/weekdays.js +12 -22
  73. package/components/date-picker/years.js +83 -110
  74. package/components/dialog/dialog.js +142 -190
  75. package/components/dialog/dialog__body-scroll-preventer.js +0 -4
  76. package/components/dropdown/anchor.js +0 -9
  77. package/components/dropdown/dropdown.js +182 -213
  78. package/components/dropdown-menu/dropdown-menu.js +71 -97
  79. package/components/editable-heading/editable-heading.js +75 -127
  80. package/components/error-bubble/error-bubble.js +31 -60
  81. package/components/error-message/error-message.js +39 -59
  82. package/components/footer/footer.js +27 -30
  83. package/components/global/compose.js +1 -10
  84. package/components/global/composeRefs.js +7 -12
  85. package/components/global/controls-height.js +2 -2
  86. package/components/global/create-stateful-context.js +15 -15
  87. package/components/global/data-tests.js +6 -14
  88. package/components/global/dom.js +47 -86
  89. package/components/global/focus-sensor-hoc.js +122 -132
  90. package/components/global/fuzzy-highlight.js +22 -36
  91. package/components/global/get-event-key.js +8 -8
  92. package/components/global/get-uid.js +4 -8
  93. package/components/global/inject-styles.js +10 -15
  94. package/components/global/listeners.js +27 -51
  95. package/components/global/memoize.js +6 -12
  96. package/components/global/normalize-indent.js +19 -50
  97. package/components/global/promise-with-timeout.js +6 -8
  98. package/components/global/prop-types.js +3 -5
  99. package/components/global/react-dom-renderer.js +28 -44
  100. package/components/global/react-render-adapter.js +1 -1
  101. package/components/global/rerender-hoc.js +12 -30
  102. package/components/global/schedule-raf.js +5 -6
  103. package/components/global/sniffer.js +1 -1
  104. package/components/global/theme.js +0 -22
  105. package/components/global/trivial-template-tag.js +3 -10
  106. package/components/global/typescript-utils.js +2 -6
  107. package/components/global/url.js +20 -26
  108. package/components/global/use-event-callback.js +6 -4
  109. package/components/grid/col.js +35 -52
  110. package/components/grid/grid.js +17 -31
  111. package/components/grid/row.js +35 -47
  112. package/components/group/group.js +17 -25
  113. package/components/header/header.js +33 -78
  114. package/components/header/logo.js +20 -36
  115. package/components/header/profile.js +166 -199
  116. package/components/header/services-link.js +0 -4
  117. package/components/header/services.js +73 -116
  118. package/components/header/smart-profile.js +111 -203
  119. package/components/header/smart-services.js +62 -113
  120. package/components/header/tray-icon.js +21 -37
  121. package/components/header/tray.js +21 -32
  122. package/components/heading/heading.js +24 -25
  123. package/components/http/http.d.ts +1 -3
  124. package/components/http/http.js +203 -353
  125. package/components/http/http.mock.js +49 -101
  126. package/components/hub-source/hub-source.js +83 -190
  127. package/components/hub-source/hub-source__user.js +11 -44
  128. package/components/hub-source/hub-source__users-groups.js +37 -65
  129. package/components/i18n/i18n-context.js +7 -10
  130. package/components/i18n/i18n.js +7 -10
  131. package/components/icon/icon.js +76 -93
  132. package/components/icon/icon__svg.js +0 -8
  133. package/components/icon/index.js +0 -8
  134. package/components/input/input.js +0 -13
  135. package/components/island/adaptive-island-hoc.js +30 -43
  136. package/components/island/content.js +115 -132
  137. package/components/island/header.js +57 -70
  138. package/components/island/island.js +28 -40
  139. package/components/island-legacy/content-legacy.js +17 -25
  140. package/components/island-legacy/header-legacy.js +19 -27
  141. package/components/island-legacy/island-legacy.js +17 -25
  142. package/components/link/clickableLink.js +44 -59
  143. package/components/link/link.js +57 -68
  144. package/components/list/consts.js +2 -2
  145. package/components/list/list.js +611 -698
  146. package/components/list/list__custom.js +44 -62
  147. package/components/list/list__hint.js +10 -19
  148. package/components/list/list__item.js +133 -174
  149. package/components/list/list__link.js +37 -50
  150. package/components/list/list__separator.js +14 -24
  151. package/components/list/list__title.js +22 -32
  152. package/components/list/list__users-groups-source.js +54 -126
  153. package/components/loader/loader.js +43 -74
  154. package/components/loader/loader__core.js +198 -263
  155. package/components/loader-inline/loader-inline.js +23 -35
  156. package/components/loader-screen/loader-screen.js +25 -46
  157. package/components/login-dialog/login-dialog.js +111 -158
  158. package/components/login-dialog/service.js +8 -34
  159. package/components/markdown/markdown.js +15 -23
  160. package/components/message/message.js +161 -203
  161. package/components/old-browsers-message/old-browsers-message.js +11 -18
  162. package/components/old-browsers-message/old-browsers-message__stop.js +0 -7
  163. package/components/old-browsers-message/white-list.js +8 -16
  164. package/components/pager/pager.js +212 -271
  165. package/components/panel/panel.js +17 -25
  166. package/components/permissions/permissions.js +127 -172
  167. package/components/permissions/permissions__cache.js +194 -224
  168. package/components/popup/popup.consts.js +1 -1
  169. package/components/popup/popup.js +284 -343
  170. package/components/popup/popup.target.js +9 -8
  171. package/components/popup/position.js +96 -106
  172. package/components/popup-menu/popup-menu.js +44 -80
  173. package/components/progress-bar/progress-bar.js +87 -104
  174. package/components/query-assist/query-assist.js +838 -916
  175. package/components/query-assist/query-assist__suggestions.js +1 -30
  176. package/components/radio/radio.js +19 -34
  177. package/components/radio/radio__item.js +52 -69
  178. package/components/select/select.js +852 -957
  179. package/components/select/select__filter.js +0 -30
  180. package/components/select/select__popup.js +373 -487
  181. package/components/shortcuts/core.js +166 -217
  182. package/components/shortcuts/shortcut-title.js +6 -11
  183. package/components/shortcuts/shortcuts-hoc.js +19 -45
  184. package/components/shortcuts/shortcuts.js +50 -75
  185. package/components/slider/slider.js +99 -122
  186. package/components/slider/slider.utils.js +14 -24
  187. package/components/storage/storage.js +4 -33
  188. package/components/storage/storage__fallback.js +149 -224
  189. package/components/storage/storage__local.js +90 -153
  190. package/components/tab-trap/tab-trap.js +122 -153
  191. package/components/table/cell.js +14 -26
  192. package/components/table/disable-hover-hoc.js +33 -51
  193. package/components/table/header-cell.js +64 -89
  194. package/components/table/header.js +104 -132
  195. package/components/table/multitable.js +107 -125
  196. package/components/table/row-with-focus-sensor.js +25 -69
  197. package/components/table/row.js +175 -216
  198. package/components/table/selection-adapter.js +1 -3
  199. package/components/table/selection-shortcuts-hoc.js +180 -181
  200. package/components/table/selection.js +156 -226
  201. package/components/table/smart-table.js +50 -88
  202. package/components/table/table.js +289 -358
  203. package/components/tabs/collapsible-more.js +46 -79
  204. package/components/tabs/collapsible-tab.js +31 -38
  205. package/components/tabs/collapsible-tabs.js +88 -153
  206. package/components/tabs/custom-item.js +4 -2
  207. package/components/tabs/dumb-tabs.js +74 -117
  208. package/components/tabs/smart-tabs.js +29 -69
  209. package/components/tabs/tab-link.js +1 -5
  210. package/components/tabs/tab.js +19 -31
  211. package/components/tabs/tabs.js +0 -31
  212. package/components/tag/tag.js +133 -173
  213. package/components/tags-input/tags-input.js +329 -427
  214. package/components/tags-list/tags-list.js +57 -78
  215. package/components/text/text.js +28 -39
  216. package/components/toggle/toggle.js +56 -70
  217. package/components/tooltip/tooltip.js +146 -190
  218. package/components/user-agreement/service.js +228 -371
  219. package/components/user-agreement/toolbox.eula.js +160 -1
  220. package/components/user-agreement/user-agreement.js +85 -120
  221. package/components/user-card/card.js +0 -29
  222. package/components/user-card/smart-user-card-tooltip.js +51 -111
  223. package/components/user-card/tooltip.js +47 -84
  224. package/components/user-card/user-card.js +0 -29
  225. package/package.json +1 -1
@@ -1,8 +1,3 @@
1
- import { b as _createClass, f as _classCallCheck, _ as _defineProperty, h as _asyncToGenerator, d as _objectSpread2, i as _regeneratorRuntime, j as _slicedToArray } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import 'core-js/modules/es.array.iterator.js';
3
- import 'core-js/modules/es.object.to-string.js';
4
- import 'core-js/modules/es.promise.js';
5
- import 'core-js/modules/web.dom-collections.iterator.js';
6
1
  import React from 'react';
7
2
  import { createRoot } from 'react-dom/client';
8
3
  import ActualStorage from '../storage/storage.js';
@@ -14,24 +9,16 @@ import { ControlsHeightContext, getGlobalControlsHeight } from '../global/contro
14
9
  import UserAgreement from './user-agreement.js';
15
10
  import '../storage/storage__local.js';
16
11
  import '../storage/storage__fallback.js';
17
- import 'core-js/modules/es.array.concat.js';
18
- import 'core-js/modules/es.array.index-of.js';
19
- import 'core-js/modules/es.reflect.delete-property.js';
20
12
  import 'deep-equal';
21
- import 'core-js/modules/es.array.filter.js';
22
- import 'core-js/modules/es.array.map.js';
13
+ import '../_helpers/_rollupPluginBabelHelpers.js';
23
14
  import '../global/get-uid.js';
24
- import 'core-js/modules/es.regexp.to-string.js';
25
15
  import '../alert/container.js';
26
16
  import 'react-dom';
27
17
  import 'classnames';
28
18
  import 'prop-types';
29
19
  import '../global/data-tests.js';
30
- import 'core-js/modules/es.array.reduce.js';
31
- import 'core-js/modules/es.object.entries.js';
32
20
  import '../link/clickableLink.js';
33
21
  import '../_helpers/link.js';
34
- import 'core-js/modules/es.object.values.js';
35
22
  import '@jetbrains/icons/exception';
36
23
  import '@jetbrains/icons/checkmark';
37
24
  import '@jetbrains/icons/warning';
@@ -40,18 +27,9 @@ import '../icon/icon.js';
40
27
  import 'util-deprecate';
41
28
  import '../icon/icon__constants.js';
42
29
  import '../_helpers/icon__svg.js';
43
- import 'core-js/modules/es.regexp.exec.js';
44
- import 'core-js/modules/es.string.replace.js';
45
- import 'core-js/modules/es.string.starts-with.js';
46
30
  import '../global/memoize.js';
47
- import 'core-js/modules/es.map.js';
48
- import 'core-js/modules/es.weak-map.js';
49
31
  import '../loader-inline/loader-inline.js';
50
32
  import '../global/dom.js';
51
- import 'core-js/modules/es.object.assign.js';
52
- import 'core-js/modules/es.set.js';
53
- import 'core-js/modules/es.string.split.js';
54
- import 'core-js/modules/web.dom-collections.for-each.js';
55
33
  import '../button/button.js';
56
34
  import '@jetbrains/icons/chevron-10px';
57
35
  import '../_helpers/button__classes.js';
@@ -61,18 +39,11 @@ import '../popup/popup.js';
61
39
  import '../global/schedule-raf.js';
62
40
  import '../shortcuts/shortcuts.js';
63
41
  import '../shortcuts/core.js';
64
- import 'core-js/modules/es.array.find-index.js';
65
- import 'core-js/modules/es.array.includes.js';
66
- import 'core-js/modules/es.array.slice.js';
67
- import 'core-js/modules/es.array.splice.js';
68
- import 'core-js/modules/es.string.includes.js';
69
- import 'core-js/modules/es.string.match.js';
70
42
  import 'combokeys';
71
43
  import '../global/sniffer.js';
72
44
  import 'sniffr';
73
45
  import '../tab-trap/tab-trap.js';
74
46
  import '../popup/position.js';
75
- import 'core-js/modules/es.array.sort.js';
76
47
  import '../popup/popup.consts.js';
77
48
  import '../dialog/dialog.js';
78
49
  import '../island/island.js';
@@ -88,400 +59,286 @@ import '../panel/panel.js';
88
59
  import '../i18n/i18n-context.js';
89
60
  import '../i18n/i18n.js';
90
61
 
91
- var GUEST_SESSION_KEY = 'end-user-agreement-consent';
92
- var ONE_HOUR = 60 * 60 * 1000; // eslint-disable-line @typescript-eslint/no-magic-numbers
93
- var storageKey = 'userAgreementKey';
94
- var showMessage = 'userAgreementShow';
95
- var hideMessage = 'userAgreementHide';
96
- var DEFAULT_CONSENT = {
62
+ const GUEST_SESSION_KEY = 'end-user-agreement-consent';
63
+ const ONE_HOUR = 60 * 60 * 1000; // eslint-disable-line @typescript-eslint/no-magic-numbers
64
+ const storageKey = 'userAgreementKey';
65
+ const showMessage = 'userAgreementShow';
66
+ const hideMessage = 'userAgreementHide';
67
+ const DEFAULT_CONSENT = {
97
68
  accepted: false,
98
69
  majorVersion: 0,
99
70
  minorVersion: 0
100
71
  };
101
- var DEFAULT_AGREEMENT = {
72
+ const DEFAULT_AGREEMENT = {
102
73
  enabled: false,
103
74
  majorVersion: 0,
104
75
  minorVersion: 0,
105
76
  requiredForREST: false,
106
77
  content: ''
107
78
  };
108
- var UserAgreementService = /*#__PURE__*/_createClass(function UserAgreementService(config) {
109
- var _this = this;
110
- _classCallCheck(this, UserAgreementService);
111
- _defineProperty(this, "config", void 0);
112
- _defineProperty(this, "_dialogPromise", null);
113
- _defineProperty(this, "_alertPromise", null);
114
- _defineProperty(this, "tabId", Math.random());
115
- _defineProperty(this, "interval", ONE_HOUR);
116
- _defineProperty(this, "container", document.createElement('div'));
117
- _defineProperty(this, "reactRoot", createRoot(this.container));
118
- _defineProperty(this, "storage", new ActualStorage());
119
- _defineProperty(this, "checkingPromise", null);
120
- _defineProperty(this, "guest", false);
121
- _defineProperty(this, "userAgreement", DEFAULT_AGREEMENT);
122
- _defineProperty(this, "userConsent", DEFAULT_CONSENT);
123
- _defineProperty(this, "intervalId", void 0);
124
- _defineProperty(this, "startChecking", function () {
125
- _this.intervalId = window.setInterval(_this.checkConsentAndShowDialog, _this.interval);
126
- window.addEventListener('storage', _this.onStorageEvent);
127
- _this.checkConsentAndShowDialog();
128
- });
129
- _defineProperty(this, "stopChecking", function () {
130
- clearInterval(_this.intervalId);
131
- window.removeEventListener('storage', _this.onStorageEvent);
132
- _this.hideDialog();
133
- });
134
- _defineProperty(this, "onStorageEvent", function (event) {
79
+ class UserAgreementService {
80
+ config;
81
+ constructor(config) {
82
+ if (!config) {
83
+ throw new Error('Please pass a config to UserAgreementService');
84
+ }
85
+ if (!config.getUserAgreement) {
86
+ throw new Error('Please pass a "getUserAgreement" option to UserAgreementService');
87
+ }
88
+ if (!config.getUserConsent) {
89
+ throw new Error('Please pass a "getUserConsent" option to UserAgreementService');
90
+ }
91
+ if (!config.setUserConsent) {
92
+ throw new Error('Please pass a "setUserConsent" option to UserAgreementService');
93
+ }
94
+ this.config = config;
95
+ this.interval = config.interval || this.interval;
96
+ }
97
+ _dialogPromise = null;
98
+ _alertPromise = null;
99
+ tabId = Math.random();
100
+ interval = ONE_HOUR;
101
+ container = document.createElement('div');
102
+ reactRoot = createRoot(this.container);
103
+ storage = new ActualStorage();
104
+ checkingPromise = null;
105
+ guest = false;
106
+ userAgreement = DEFAULT_AGREEMENT;
107
+ userConsent = DEFAULT_CONSENT;
108
+ intervalId;
109
+ startChecking = () => {
110
+ this.intervalId = window.setInterval(this.checkConsentAndShowDialog, this.interval);
111
+ window.addEventListener('storage', this.onStorageEvent);
112
+ this.checkConsentAndShowDialog();
113
+ };
114
+ stopChecking = () => {
115
+ clearInterval(this.intervalId);
116
+ window.removeEventListener('storage', this.onStorageEvent);
117
+ this.hideDialog();
118
+ };
119
+ onStorageEvent = event => {
135
120
  if (event.key === storageKey && event.newValue != null) {
136
- var _JSON$parse = JSON.parse(event.newValue),
137
- tabId = _JSON$parse.tabId,
138
- command = _JSON$parse.command;
139
- if (tabId !== _this.tabId) {
121
+ const {
122
+ tabId,
123
+ command
124
+ } = JSON.parse(event.newValue);
125
+ if (tabId !== this.tabId) {
140
126
  if (command === showMessage) {
141
- _this.checkConsentAndShowDialog(true);
127
+ this.checkConsentAndShowDialog(true);
142
128
  } else if (command === hideMessage) {
143
- _this.hideDialogAndAlert(true);
129
+ this.hideDialogAndAlert(true);
144
130
  }
145
131
  }
146
132
  }
147
- });
148
- _defineProperty(this, "_notifyAboutShowing", function () {
133
+ };
134
+ _notifyAboutShowing = () => {
149
135
  localStorage.setItem(storageKey, JSON.stringify({
150
136
  command: showMessage,
151
- tabId: _this.tabId
137
+ tabId: this.tabId
152
138
  }));
153
- });
154
- _defineProperty(this, "_notifyAboutHiding", function () {
139
+ };
140
+ _notifyAboutHiding = () => {
155
141
  localStorage.setItem(storageKey, JSON.stringify({
156
142
  command: hideMessage,
157
- tabId: _this.tabId
158
- }));
159
- });
160
- _defineProperty(this, "getUserAgreement", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
161
- return _regeneratorRuntime().wrap(function _callee$(_context) {
162
- while (1) switch (_context.prev = _context.next) {
163
- case 0:
164
- _context.next = 2;
165
- return _this.config.getUserAgreement();
166
- case 2:
167
- _context.t0 = _context.sent;
168
- if (_context.t0) {
169
- _context.next = 5;
170
- break;
171
- }
172
- _context.t0 = DEFAULT_AGREEMENT;
173
- case 5:
174
- _this.userAgreement = _context.t0;
175
- return _context.abrupt("return", _this.userAgreement);
176
- case 7:
177
- case "end":
178
- return _context.stop();
179
- }
180
- }, _callee);
181
- })));
182
- _defineProperty(this, "getUserConsent", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
183
- var _yield$_this$config$g, guest, endUserAgreementConsent;
184
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
185
- while (1) switch (_context2.prev = _context2.next) {
186
- case 0:
187
- _context2.next = 2;
188
- return _this.config.getUserConsent();
189
- case 2:
190
- _yield$_this$config$g = _context2.sent;
191
- guest = _yield$_this$config$g.guest;
192
- endUserAgreementConsent = _yield$_this$config$g.endUserAgreementConsent;
193
- _this.guest = guest;
194
- if (!guest) {
195
- _context2.next = 15;
196
- break;
197
- }
198
- _context2.next = 9;
199
- return _this.storage.get(GUEST_SESSION_KEY);
200
- case 9:
201
- _context2.t0 = _context2.sent;
202
- if (_context2.t0) {
203
- _context2.next = 12;
204
- break;
205
- }
206
- _context2.t0 = _this.userConsent;
207
- case 12:
208
- _this.userConsent = _context2.t0;
209
- _context2.next = 16;
210
- break;
211
- case 15:
212
- _this.userConsent = endUserAgreementConsent || _this.userConsent;
213
- case 16:
214
- return _context2.abrupt("return", _this.userConsent);
215
- case 17:
216
- case "end":
217
- return _context2.stop();
218
- }
219
- }, _callee2);
220
- })));
221
- _defineProperty(this, "checkConsentAndShowDialog", /*#__PURE__*/function () {
222
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(withoutNotifications) {
223
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
224
- while (1) switch (_context3.prev = _context3.next) {
225
- case 0:
226
- _context3.next = 2;
227
- return _this.checkConsent();
228
- case 2:
229
- if (!_context3.sent) {
230
- _context3.next = 6;
231
- break;
232
- }
233
- return _context3.abrupt("return", _this.hideDialogAndAlert(withoutNotifications));
234
- case 6:
235
- return _context3.abrupt("return", _this.showDialogOrAlert(withoutNotifications));
236
- case 7:
237
- case "end":
238
- return _context3.stop();
239
- }
240
- }, _callee3);
143
+ tabId: this.tabId
241
144
  }));
242
- return function (_x) {
243
- return _ref3.apply(this, arguments);
244
- };
245
- }());
246
- _defineProperty(this, "checkConsent", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
247
- var _yield$_this$checking, _yield$_this$checking2, userAgreement, userConsent, enabled, actualVersion, accepted, acceptedVersion;
248
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
249
- while (1) switch (_context4.prev = _context4.next) {
250
- case 0:
251
- if (!_this.checkingPromise) {
252
- _this.checkingPromise = Promise.all([_this.getUserAgreement(), _this.getUserConsent()]);
253
- }
254
- _context4.next = 3;
255
- return _this.checkingPromise;
256
- case 3:
257
- _yield$_this$checking = _context4.sent;
258
- _yield$_this$checking2 = _slicedToArray(_yield$_this$checking, 2);
259
- userAgreement = _yield$_this$checking2[0];
260
- userConsent = _yield$_this$checking2[1];
261
- _this.checkingPromise = null;
262
- enabled = userAgreement.enabled, actualVersion = userAgreement.majorVersion;
263
- accepted = userConsent.accepted, acceptedVersion = userConsent.majorVersion;
264
- return _context4.abrupt("return", !enabled || accepted && actualVersion === acceptedVersion);
265
- case 11:
266
- case "end":
267
- return _context4.stop();
268
- }
269
- }, _callee4);
270
- })));
271
- _defineProperty(this, "alertKey", void 0);
272
- _defineProperty(this, "showAlert", function (withoutNotifications) {
273
- if (_this._alertPromise) {
274
- return _this._alertPromise;
145
+ };
146
+ getUserAgreement = async () => {
147
+ this.userAgreement = (await this.config.getUserAgreement()) || DEFAULT_AGREEMENT;
148
+ return this.userAgreement;
149
+ };
150
+ getUserConsent = async () => {
151
+ const {
152
+ guest,
153
+ endUserAgreementConsent
154
+ } = await this.config.getUserConsent();
155
+ this.guest = guest;
156
+ if (guest) {
157
+ this.userConsent = (await this.storage.get(GUEST_SESSION_KEY)) || this.userConsent;
158
+ } else {
159
+ this.userConsent = endUserAgreementConsent || this.userConsent;
160
+ }
161
+ return this.userConsent;
162
+ };
163
+ checkConsentAndShowDialog = async withoutNotifications => {
164
+ if (await this.checkConsent()) {
165
+ return this.hideDialogAndAlert(withoutNotifications);
166
+ } else {
167
+ return this.showDialogOrAlert(withoutNotifications);
168
+ }
169
+ };
170
+ checkConsent = async () => {
171
+ if (!this.checkingPromise) {
172
+ this.checkingPromise = Promise.all([this.getUserAgreement(), this.getUserConsent()]);
173
+ }
174
+ const [userAgreement, userConsent] = await this.checkingPromise;
175
+ this.checkingPromise = null;
176
+ const {
177
+ enabled,
178
+ majorVersion: actualVersion
179
+ } = userAgreement;
180
+ const {
181
+ accepted,
182
+ majorVersion: acceptedVersion
183
+ } = userConsent;
184
+ return !enabled || accepted && actualVersion === acceptedVersion;
185
+ };
186
+ alertKey;
187
+ showAlert = withoutNotifications => {
188
+ if (this._alertPromise) {
189
+ return this._alertPromise;
275
190
  }
276
- _this._alertPromise = new Promise(function (resolve, reject) {
277
- var _ref5 = _this.config.translations || {},
278
- userAgreement = _ref5.userAgreement,
279
- reviewNow = _ref5.reviewNow,
280
- remindLater = _ref5.remindLater;
281
- var onRemind = function onRemind() {
282
- _this.hideDialogAndAlert(withoutNotifications);
191
+ this._alertPromise = new Promise((resolve, reject) => {
192
+ const {
193
+ userAgreement,
194
+ reviewNow,
195
+ remindLater
196
+ } = this.config.translations || {};
197
+ const onRemind = () => {
198
+ this.hideDialogAndAlert(withoutNotifications);
283
199
  reject('Postponed');
284
200
  };
285
- var onReview = /*#__PURE__*/function () {
286
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
287
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
288
- while (1) switch (_context5.prev = _context5.next) {
289
- case 0:
290
- _context5.next = 2;
291
- return _this.showDialog(true, false, {
292
- onRemindLater: onRemind
293
- });
294
- case 2:
295
- _this.hideAlert(withoutNotifications);
296
- resolve();
297
- case 4:
298
- case "end":
299
- return _context5.stop();
300
- }
301
- }, _callee5);
302
- }));
303
- return function onReview() {
304
- return _ref6.apply(this, arguments);
305
- };
306
- }();
307
- var message = /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement("span", null, userAgreement || 'User Agreement'), /*#__PURE__*/React.createElement(Link, {
201
+ const onReview = async () => {
202
+ await this.showDialog(true, false, {
203
+ onRemindLater: onRemind
204
+ });
205
+ this.hideAlert(withoutNotifications);
206
+ resolve();
207
+ };
208
+ const message = /*#__PURE__*/React.createElement(Group, null, /*#__PURE__*/React.createElement("span", null, userAgreement || 'User Agreement'), /*#__PURE__*/React.createElement(Link, {
308
209
  onClick: onReview,
309
210
  "data-test": "review"
310
211
  }, reviewNow || 'Review now'), /*#__PURE__*/React.createElement(Link, {
311
212
  onClick: onRemind,
312
213
  "data-test": "later"
313
214
  }, remindLater || 'Remind me later'));
314
- _this.alertKey = alertService.addAlert(message, Alert.Type.WARNING, 0, {
215
+ this.alertKey = alertService.addAlert(message, Alert.Type.WARNING, 0, {
315
216
  closeable: false
316
217
  });
317
218
  });
318
219
  if (!withoutNotifications) {
319
- _this._notifyAboutShowing();
220
+ this._notifyAboutShowing();
320
221
  }
321
- return _this._alertPromise;
322
- });
323
- _defineProperty(this, "hideAlert", function (withoutNotifications) {
324
- var onRemindLater = _this.config.onRemindLater;
325
- alertService.remove(_this.alertKey);
326
- _this.alertKey = null;
327
- _this._alertPromise = null;
222
+ return this._alertPromise;
223
+ };
224
+ hideAlert = withoutNotifications => {
225
+ const {
226
+ onRemindLater
227
+ } = this.config;
228
+ alertService.remove(this.alertKey);
229
+ this.alertKey = null;
230
+ this._alertPromise = null;
328
231
  if (onRemindLater) {
329
232
  onRemindLater();
330
233
  }
331
234
  if (!withoutNotifications) {
332
- _this._notifyAboutHiding();
235
+ this._notifyAboutHiding();
333
236
  }
334
- });
335
- _defineProperty(this, "showDialog", function (withoutNotifications) {
336
- var preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
337
- var restOptions = arguments.length > 2 ? arguments[2] : undefined;
338
- var _this$config = _this.config,
339
- translations = _this$config.translations,
340
- onDialogShow = _this$config.onDialogShow;
341
- var content = _this.userAgreement.content;
342
- var show = true;
343
- if (!_this._dialogPromise) {
344
- _this._dialogPromise = new Promise(function (resolve, reject) {
345
- var onAccept = /*#__PURE__*/function () {
346
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
347
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
348
- while (1) switch (_context6.prev = _context6.next) {
349
- case 0:
350
- _context6.next = 2;
351
- return _this.onAccept();
352
- case 2:
353
- resolve();
354
- case 3:
355
- case "end":
356
- return _context6.stop();
357
- }
358
- }, _callee6);
359
- }));
360
- return function onAccept() {
361
- return _ref7.apply(this, arguments);
237
+ };
238
+ showDialog = (() => {
239
+ var _this = this;
240
+ return function (withoutNotifications) {
241
+ let preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
242
+ let restOptions = arguments.length > 2 ? arguments[2] : undefined;
243
+ const {
244
+ translations,
245
+ onDialogShow
246
+ } = _this.config;
247
+ const {
248
+ content
249
+ } = _this.userAgreement;
250
+ const show = true;
251
+ if (!_this._dialogPromise) {
252
+ _this._dialogPromise = new Promise((resolve, reject) => {
253
+ const onAccept = async () => {
254
+ await _this.onAccept();
255
+ resolve();
256
+ };
257
+ const onDecline = async () => {
258
+ await _this.onDecline();
259
+ reject();
362
260
  };
363
- }();
364
- var onDecline = /*#__PURE__*/function () {
365
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
366
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
367
- while (1) switch (_context7.prev = _context7.next) {
368
- case 0:
369
- _context7.next = 2;
370
- return _this.onDecline();
371
- case 2:
372
- reject();
373
- case 3:
374
- case "end":
375
- return _context7.stop();
376
- }
377
- }, _callee7);
378
- }));
379
- return function onDecline() {
380
- return _ref8.apply(this, arguments);
261
+ const onClose = _this.hideDialogAndAlert;
262
+ const props = {
263
+ children: content,
264
+ show,
265
+ onAccept,
266
+ onDecline,
267
+ onClose,
268
+ translations,
269
+ preview,
270
+ ...restOptions
381
271
  };
382
- }();
383
- var onClose = _this.hideDialogAndAlert;
384
- var props = _objectSpread2({
385
- children: content,
386
- show,
387
- onAccept,
388
- onDecline,
389
- onClose,
390
- translations,
391
- preview
392
- }, restOptions);
393
- _this.reactRoot.render( /*#__PURE__*/React.createElement(ControlsHeightContext.Provider, {
394
- value: getGlobalControlsHeight()
395
- }, /*#__PURE__*/React.createElement(UserAgreement, props)));
396
- if (onDialogShow) {
397
- onDialogShow();
272
+ _this.reactRoot.render( /*#__PURE__*/React.createElement(ControlsHeightContext.Provider, {
273
+ value: getGlobalControlsHeight()
274
+ }, /*#__PURE__*/React.createElement(UserAgreement, props)));
275
+ if (onDialogShow) {
276
+ onDialogShow();
277
+ }
278
+ });
279
+ if (!withoutNotifications) {
280
+ _this._notifyAboutShowing();
398
281
  }
399
- });
400
- if (!withoutNotifications) {
401
- _this._notifyAboutShowing();
402
282
  }
403
- }
404
- return _this._dialogPromise;
405
- });
406
- _defineProperty(this, "hideDialog", function (withoutNotifications) {
407
- var onDialogHide = _this.config.onDialogHide;
408
- _this.reactRoot.render(null);
283
+ return _this._dialogPromise;
284
+ };
285
+ })();
286
+ hideDialog = withoutNotifications => {
287
+ const {
288
+ onDialogHide
289
+ } = this.config;
290
+ this.reactRoot.render(null);
409
291
  if (onDialogHide) {
410
292
  onDialogHide();
411
- _this._dialogPromise = null;
293
+ this._dialogPromise = null;
412
294
  if (!withoutNotifications) {
413
- _this._notifyAboutHiding();
295
+ this._notifyAboutHiding();
414
296
  }
415
297
  }
416
- });
417
- _defineProperty(this, "showDialogOrAlert", function (withoutNotifications, preview, restOptions) {
418
- if (_this.guest && !_this.userAgreement.requiredForREST) {
419
- return _this.showAlert(withoutNotifications);
298
+ };
299
+ showDialogOrAlert = (withoutNotifications, preview, restOptions) => {
300
+ if (this.guest && !this.userAgreement.requiredForREST) {
301
+ return this.showAlert(withoutNotifications);
420
302
  }
421
- return _this.showDialog(withoutNotifications, preview, restOptions);
422
- });
423
- _defineProperty(this, "hideDialogAndAlert", function (withoutNotifications) {
424
- _this.hideAlert(withoutNotifications);
425
- _this.hideDialog(withoutNotifications);
426
- });
427
- _defineProperty(this, "onAccept", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
428
- var _this$config2, setUserConsent, onAccept, _this$userAgreement, majorVersion, minorVersion;
429
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
430
- while (1) switch (_context8.prev = _context8.next) {
431
- case 0:
432
- _this$config2 = _this.config, setUserConsent = _this$config2.setUserConsent, onAccept = _this$config2.onAccept;
433
- if (!_this.guest) {
434
- _context8.next = 8;
435
- break;
436
- }
437
- _this$userAgreement = _this.userAgreement, majorVersion = _this$userAgreement.majorVersion, minorVersion = _this$userAgreement.minorVersion;
438
- _this.userConsent = {
439
- majorVersion,
440
- minorVersion,
441
- accepted: true
442
- };
443
- _context8.next = 6;
444
- return _this.storage.set(GUEST_SESSION_KEY, _this.userConsent);
445
- case 6:
446
- _context8.next = 11;
447
- break;
448
- case 8:
449
- _context8.next = 10;
450
- return setUserConsent();
451
- case 10:
452
- _this.userConsent = _context8.sent;
453
- case 11:
454
- _this.hideDialog();
455
- if (onAccept) {
456
- onAccept();
457
- }
458
- case 13:
459
- case "end":
460
- return _context8.stop();
461
- }
462
- }, _callee8);
463
- })));
464
- _defineProperty(this, "onDecline", function () {
465
- var onDecline = _this.config.onDecline;
466
- _this.hideDialog();
303
+ return this.showDialog(withoutNotifications, preview, restOptions);
304
+ };
305
+ hideDialogAndAlert = withoutNotifications => {
306
+ this.hideAlert(withoutNotifications);
307
+ this.hideDialog(withoutNotifications);
308
+ };
309
+ onAccept = async () => {
310
+ const {
311
+ setUserConsent,
312
+ onAccept
313
+ } = this.config;
314
+ if (this.guest) {
315
+ const {
316
+ majorVersion,
317
+ minorVersion
318
+ } = this.userAgreement;
319
+ this.userConsent = {
320
+ majorVersion,
321
+ minorVersion,
322
+ accepted: true
323
+ };
324
+ await this.storage.set(GUEST_SESSION_KEY, this.userConsent);
325
+ } else {
326
+ this.userConsent = await setUserConsent();
327
+ }
328
+ this.hideDialog();
329
+ if (onAccept) {
330
+ onAccept();
331
+ }
332
+ };
333
+ onDecline = () => {
334
+ const {
335
+ onDecline
336
+ } = this.config;
337
+ this.hideDialog();
467
338
  if (onDecline) {
468
339
  onDecline();
469
340
  }
470
- });
471
- if (!config) {
472
- throw new Error('Please pass a config to UserAgreementService');
473
- }
474
- if (!config.getUserAgreement) {
475
- throw new Error('Please pass a "getUserAgreement" option to UserAgreementService');
476
- }
477
- if (!config.getUserConsent) {
478
- throw new Error('Please pass a "getUserConsent" option to UserAgreementService');
479
- }
480
- if (!config.setUserConsent) {
481
- throw new Error('Please pass a "setUserConsent" option to UserAgreementService');
482
- }
483
- this.config = config;
484
- this.interval = config.interval || this.interval;
485
- });
341
+ };
342
+ }
486
343
 
487
344
  export { UserAgreementService as default, hideMessage, showMessage };