versacall-core-library-react 2.0.65 → 2.0.67

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 (121) hide show
  1. package/dist/components/CoreAlert/CoreAlert.js +43 -107
  2. package/dist/components/CoreAlert/index.js +2 -4
  3. package/dist/components/CoreAppBar/CoreAppBar.js +275 -418
  4. package/dist/components/CoreAppBar/CoreAppBarDrawer.js +88 -171
  5. package/dist/components/CoreAppBar/index.js +2 -4
  6. package/dist/components/CoreAppSelector/AppLink.js +36 -60
  7. package/dist/components/CoreAppSelector/CoreAppSelector.js +109 -200
  8. package/dist/components/CoreAppSelector/index.js +2 -4
  9. package/dist/components/CoreDialogueToolBar/CoreDialogueToolBar.js +43 -69
  10. package/dist/components/CoreDialogueToolBar/index.js +2 -4
  11. package/dist/components/CoreDrawer/CoreDrawer.js +168 -286
  12. package/dist/components/CoreDrawer/index.js +2 -4
  13. package/dist/components/CoreDropDownTextfield/CoreDropDownTextfield.js +57 -121
  14. package/dist/components/CoreDropDownTextfield/index.js +2 -4
  15. package/dist/components/CoreElapsedTime/CoreElapsedTime.js +38 -97
  16. package/dist/components/CoreElapsedTime/index.js +2 -4
  17. package/dist/components/CoreFrame/CoreFrame.js +17 -28
  18. package/dist/components/CoreFrame/index.js +2 -4
  19. package/dist/components/CoreImportDialog/CoreImportDialog.js +87 -189
  20. package/dist/components/CoreImportDialog/index.js +2 -4
  21. package/dist/components/CoreImportResultsDialog/CoreImportResultsDialog.js +19 -45
  22. package/dist/components/CoreImportResultsDialog/index.js +2 -4
  23. package/dist/components/CoreImporting/CoreImporting.js +23 -39
  24. package/dist/components/CoreImporting/index.js +2 -4
  25. package/dist/components/CorePlugin/CorePlugin.js +83 -160
  26. package/dist/components/CorePlugin/OldCorePlugin.js +73 -149
  27. package/dist/components/CorePlugin/index.js +2 -4
  28. package/dist/components/CoreSaveChangesDialog/CoreSaveChangesDialog.js +10 -32
  29. package/dist/components/CoreSaveChangesDialog/index.js +2 -4
  30. package/dist/components/CoreShiftTagFilter/CoreShiftTagFilter.js +288 -408
  31. package/dist/components/CoreShiftTagFilter/OldCoreShiftTagFilter.js +161 -257
  32. package/dist/components/CoreShiftTagFilter/index.js +2 -4
  33. package/dist/components/CoreSideBar/CoreSideBar.js +578 -737
  34. package/dist/components/CoreSideBar/CoreSideBarDrawer.js +122 -212
  35. package/dist/components/CoreSideBar/index.js +2 -4
  36. package/dist/components/CoreSnackBar/CoreSnackBar.js +76 -143
  37. package/dist/components/CoreSnackBar/index.js +2 -4
  38. package/dist/components/CoreTable/CoreTable.js +219 -337
  39. package/dist/components/CoreTable/CoreTableChips.js +11 -19
  40. package/dist/components/CoreTable/CoreTableHead.js +125 -205
  41. package/dist/components/CoreTable/CoreTableToolbar.js +34 -56
  42. package/dist/components/CoreTable/index.js +2 -4
  43. package/dist/components/CoreTagFilter/CoreTagFilter.js +212 -319
  44. package/dist/components/CoreTagFilter/OldCoreTagFilter.js +270 -402
  45. package/dist/components/CoreTagFilter/OldTagChip.js +10 -20
  46. package/dist/components/CoreTagFilter/OldTagFilterSelector.js +77 -148
  47. package/dist/components/CoreTagFilter/OldTagOption.js +21 -47
  48. package/dist/components/CoreTagFilter/TagFilterBuilder.js +114 -274
  49. package/dist/components/CoreTagFilter/index.js +2 -4
  50. package/dist/components/CoreTextField/CoreTextField.js +69 -132
  51. package/dist/components/CoreTextField/index.js +2 -4
  52. package/dist/components/CoreTheme/CoreTheme.js +13 -27
  53. package/dist/components/CoreTheme/index.js +2 -4
  54. package/dist/components/CoreTile/CoreTile.js +21 -34
  55. package/dist/components/CoreTile/CoreTileToolbar.js +21 -36
  56. package/dist/components/CoreTile/index.js +2 -4
  57. package/dist/components/CoreTimerInput/CoreTimerInput.js +36 -60
  58. package/dist/components/CoreTimerInput/CoreTimerInputOld.js +29 -47
  59. package/dist/components/CoreTimerInput/index.js +2 -4
  60. package/dist/components/CoreToolbar/CoreToolbar.js +65 -95
  61. package/dist/components/CoreToolbar/index.js +2 -4
  62. package/dist/components/CoreTracker/CoreTracker.js +32 -91
  63. package/dist/components/CoreTracker/index.js +2 -4
  64. package/dist/components/CoreTranslate/CoreTranslate.js +17 -48
  65. package/dist/components/CoreTranslate/index.js +2 -4
  66. package/dist/components/CoreTranslateWrapper/CoreTranslateWrapper.js +7 -15
  67. package/dist/components/CoreTranslateWrapper/index.js +2 -4
  68. package/dist/components/CoreWidget/CoreWidget.js +81 -149
  69. package/dist/components/CoreWidget/index.js +2 -4
  70. package/dist/components/CoreWrapper/CoreWrapper.js +8 -16
  71. package/dist/components/CoreWrapper/index.js +2 -4
  72. package/dist/components/index.js +29 -58
  73. package/dist/constants/index.js +3 -6
  74. package/dist/constants/testOrganization.js +2 -3
  75. package/dist/constants/testToken.js +2 -3
  76. package/dist/context/Authentication/AuthenticationContext.js +3 -8
  77. package/dist/context/Authentication/AuthenticationProvider.js +156 -257
  78. package/dist/context/Authentication/index.js +4 -8
  79. package/dist/context/Authentication/withAuthentication.js +5 -14
  80. package/dist/context/Channels/ChannelsConsumer.js +14 -70
  81. package/dist/context/Channels/ChannelsContext.js +3 -8
  82. package/dist/context/Channels/ChannelsProvider.js +132 -278
  83. package/dist/context/Channels/DataChannel.js +39 -103
  84. package/dist/context/Channels/EntityChannel.js +40 -104
  85. package/dist/context/Channels/EveryoneChannel.js +32 -92
  86. package/dist/context/Channels/OrganizationChannel.js +40 -104
  87. package/dist/context/Channels/UserChannel.js +37 -99
  88. package/dist/context/Channels/index.js +10 -20
  89. package/dist/context/Channels/withChannels.js +5 -14
  90. package/dist/context/Core/CoreContext.js +3 -8
  91. package/dist/context/Core/CoreProvider.js +68 -132
  92. package/dist/context/Core/index.js +4 -8
  93. package/dist/context/Core/withCore.js +5 -14
  94. package/dist/context/Organization/OrganizationContext.js +3 -8
  95. package/dist/context/Organization/OrganizationProvider.js +48 -120
  96. package/dist/context/Organization/index.js +4 -8
  97. package/dist/context/Organization/withOrganization.js +5 -14
  98. package/dist/context/Plugin/PluginContext.js +3 -8
  99. package/dist/context/Plugin/PluginProvider.js +55 -112
  100. package/dist/context/Plugin/index.js +4 -8
  101. package/dist/context/Plugin/withPlugin.js +5 -14
  102. package/dist/context/index.js +5 -15
  103. package/dist/css/index.js +3 -6
  104. package/dist/functions/TagEvaluator.js +107 -156
  105. package/dist/functions/compareObjects.js +0 -7
  106. package/dist/functions/formatElapsedTime.js +5 -6
  107. package/dist/functions/formatNameFileSafe.js +3 -4
  108. package/dist/functions/getIconUrl.js +0 -3
  109. package/dist/functions/getParameterByName.js +9 -12
  110. package/dist/functions/getProperty.js +4 -8
  111. package/dist/functions/getUrl.js +0 -3
  112. package/dist/functions/index.js +9 -18
  113. package/dist/icons/CopyIcon.js +11 -22
  114. package/dist/icons/DeleteIcon.js +11 -22
  115. package/dist/icons/DuplicateIcon.js +11 -22
  116. package/dist/icons/EditIcon.js +11 -22
  117. package/dist/icons/FabAddIcon.js +19 -35
  118. package/dist/icons/PasteIcon.js +11 -22
  119. package/dist/icons/index.js +7 -14
  120. package/dist/index.js +6 -18
  121. package/package.json +89 -79
@@ -4,173 +4,121 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
9
  var _styles = require("@material-ui/core/styles");
13
-
14
10
  var _Avatar = _interopRequireDefault(require("@material-ui/core/Avatar"));
15
-
16
11
  var _Badge = _interopRequireDefault(require("@material-ui/core/Badge"));
17
-
18
12
  var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
19
-
20
13
  var _Divider = _interopRequireDefault(require("@material-ui/core/Divider"));
21
-
22
14
  var _Drawer = _interopRequireDefault(require("@material-ui/core/Drawer"));
23
-
24
15
  var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
25
-
26
16
  var _ListItem = _interopRequireDefault(require("@material-ui/core/ListItem"));
27
-
28
17
  var _ListItemIcon = _interopRequireDefault(require("@material-ui/core/ListItemIcon"));
29
-
30
18
  var _ListItemText = _interopRequireDefault(require("@material-ui/core/ListItemText"));
31
-
32
19
  var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
33
-
34
20
  var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
35
-
36
21
  var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
37
-
38
22
  var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
39
-
40
23
  var _AccountCircle = _interopRequireDefault(require("@material-ui/icons/AccountCircle"));
41
-
42
24
  var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
43
-
44
25
  var _LocationCity = _interopRequireDefault(require("@material-ui/icons/LocationCity"));
45
-
46
26
  var _Menu2 = _interopRequireDefault(require("@material-ui/icons/Menu"));
47
-
48
27
  var _ExitToApp = _interopRequireDefault(require("@material-ui/icons/ExitToApp"));
49
-
50
28
  var _Notifications = _interopRequireDefault(require("@material-ui/icons/Notifications"));
51
-
52
29
  var _Error = _interopRequireDefault(require("@material-ui/icons/Error"));
53
-
54
30
  var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
55
-
56
31
  var _Warning = _interopRequireDefault(require("@material-ui/icons/Warning"));
57
-
58
32
  var _StarBorder = _interopRequireDefault(require("@material-ui/icons/StarBorder"));
59
-
60
33
  var _Star = _interopRequireDefault(require("@material-ui/icons/Star"));
61
-
62
34
  var _reactIntl = require("react-intl");
63
-
64
35
  var _context = require("../../context");
65
-
66
36
  var _CoreSideBarDrawer = _interopRequireDefault(require("./CoreSideBarDrawer"));
67
-
68
37
  var _scrollbarModule = _interopRequireDefault(require("../../css/scrollbar.module.css"));
69
-
70
38
  require("../../css/scrollbar.css");
39
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
40
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
41
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
42
+ // import ListItemAvatar from '@material-ui/core/ListItemAvatar';
71
43
 
72
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
73
-
74
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
75
-
76
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
77
-
78
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
79
-
80
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
81
-
82
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
83
-
84
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
85
-
86
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
44
+ // import Toolbar from '@material-ui/core/Toolbar';
87
45
 
88
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
46
+ // import SettingsIcon from '@material-ui/icons/Settings';
89
47
 
90
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
48
+ // import SubscriptionActiveIcon from '@material-ui/icons/CheckCircleOutline';
49
+ // import SubscriptionInactiveIcon from '@material-ui/icons/ErrorOutline';
91
50
 
92
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
93
-
94
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
95
-
96
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
97
-
98
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
99
-
100
- var namespace = 'CoreSideBar';
101
-
102
- var styles = function styles(theme) {
103
- return {
104
- root: {
105
- display: 'flex',
106
- height: '100vh',
107
- overflow: 'hidden'
108
- },
109
- content: {
110
- position: 'relative',
111
- width: '100%'
112
- },
113
- topPadding: {
114
- minHeight: 56,
115
- '@media (min-width:600px)': {
116
- minHeight: 64
117
- }
118
- },
119
- drawerPaper: {
120
- position: 'relative',
121
- whiteSpace: 'nowrap',
122
- backgroundColor: '#496b78',
123
- color: '#ffffff',
124
- display: 'flex',
125
- flexDirection: 'column'
126
- },
127
- listItemRoot: {
128
- color: '#ffffff'
129
- },
130
- menuPaper: {
131
- backgroundColor: '#3f5c67'
132
- },
133
- menuItemRoot: {
134
- color: '#ffffff'
135
- },
136
- icon: {
137
- verticalAlign: 'middle',
138
- height: 24,
139
- width: 24
140
- },
141
- svgIcon: {
142
- verticalAlign: 'middle',
143
- height: 24,
144
- width: 24,
145
- filter: 'invert(1)'
146
- },
147
- inline: {
148
- display: 'inline',
149
- color: '#cccccc'
150
- },
151
- notificationRoot: {
152
- width: 200
153
- },
154
- badgeError: {
155
- backgroundColor: theme.palette.error.light,
156
- color: theme.palette.error.contrastText
157
- },
158
- badgeWarning: {
159
- backgroundColor: theme.palette.warning.light,
160
- color: theme.palette.warning.contrastText
161
- },
162
- badgeInfo: {
163
- backgroundColor: theme.palette.info.light,
164
- color: theme.palette.info.contrastText
165
- },
166
- menuIconButton: {// background: '#3f5c67',
167
- // borderRadius: 10,
168
- // marginRight: 10,
51
+ const namespace = 'CoreSideBar';
52
+ const styles = theme => ({
53
+ root: {
54
+ display: 'flex',
55
+ height: '100vh',
56
+ overflow: 'hidden'
57
+ },
58
+ content: {
59
+ position: 'relative',
60
+ width: '100%'
61
+ },
62
+ topPadding: {
63
+ minHeight: 56,
64
+ '@media (min-width:600px)': {
65
+ minHeight: 64
169
66
  }
170
- };
171
- };
172
-
173
- var style = {
67
+ },
68
+ drawerPaper: {
69
+ position: 'relative',
70
+ whiteSpace: 'nowrap',
71
+ backgroundColor: '#496b78',
72
+ color: '#ffffff',
73
+ display: 'flex',
74
+ flexDirection: 'column'
75
+ },
76
+ listItemRoot: {
77
+ color: '#ffffff'
78
+ },
79
+ menuPaper: {
80
+ backgroundColor: '#3f5c67'
81
+ },
82
+ menuItemRoot: {
83
+ color: '#ffffff'
84
+ },
85
+ icon: {
86
+ verticalAlign: 'middle',
87
+ height: 24,
88
+ width: 24
89
+ },
90
+ svgIcon: {
91
+ verticalAlign: 'middle',
92
+ height: 24,
93
+ width: 24,
94
+ filter: 'invert(1)'
95
+ },
96
+ inline: {
97
+ display: 'inline',
98
+ color: '#cccccc'
99
+ },
100
+ notificationRoot: {
101
+ width: 200
102
+ },
103
+ badgeError: {
104
+ backgroundColor: theme.palette.error.light,
105
+ color: theme.palette.error.contrastText
106
+ },
107
+ badgeWarning: {
108
+ backgroundColor: theme.palette.warning.light,
109
+ color: theme.palette.warning.contrastText
110
+ },
111
+ badgeInfo: {
112
+ backgroundColor: theme.palette.info.light,
113
+ color: theme.palette.info.contrastText
114
+ },
115
+ menuIconButton: {
116
+ // background: '#3f5c67',
117
+ // borderRadius: 10,
118
+ // marginRight: 10,
119
+ }
120
+ });
121
+ const style = {
174
122
  title: {
175
123
  // flexGrow: 1,
176
124
  textAlign: 'center',
@@ -205,6 +153,7 @@ var style = {
205
153
  pointerEvents: 'none'
206
154
  }
207
155
  };
156
+
208
157
  /* const getNotificationsBadgeColor = notifications => {
209
158
  return 'warning';
210
159
  let hasError = false;
@@ -224,18 +173,10 @@ var style = {
224
173
  return 'primary';
225
174
  }; */
226
175
 
227
- var CoreSideBar = /*#__PURE__*/function (_Component) {
228
- _inherits(CoreSideBar, _Component);
229
-
230
- var _super = _createSuper(CoreSideBar);
231
-
232
- function CoreSideBar() {
233
- var _this;
234
-
235
- _classCallCheck(this, CoreSideBar);
236
-
237
- _this = _super.call(this);
238
- _this.state = {
176
+ class CoreSideBar extends _react.Component {
177
+ constructor() {
178
+ super();
179
+ this.state = {
239
180
  drawer: false,
240
181
  organizationAnchorEl: null,
241
182
  entityAnchorEl: null,
@@ -248,629 +189,532 @@ var CoreSideBar = /*#__PURE__*/function (_Component) {
248
189
  // subscription: null,
249
190
  notifications: []
250
191
  };
251
- return _this;
252
192
  }
253
-
254
- _createClass(CoreSideBar, [{
255
- key: "componentDidMount",
256
- value: function componentDidMount() {
257
- this.getOrganizations(); // this.getSubscription();
258
-
193
+ componentDidMount() {
194
+ this.getOrganizations();
195
+ // this.getSubscription();
196
+ this.getNotifications();
197
+ }
198
+ componentDidUpdate(prevProps) {
199
+ if (this.props.authentication.didChange(prevProps.authentication)) {
200
+ this.getOrganizations();
201
+ }
202
+ if (this.props.organization.didOrganizationChange(prevProps.organization.organization)) {
203
+ this.getEntities();
204
+ }
205
+ if (this.props.authentication.didChange(prevProps.authentication) || this.props.organization.didChange(prevProps.organization)) {
206
+ this.getApps();
207
+ this.getFavorites();
208
+ // this.getSubscription();
259
209
  this.getNotifications();
260
210
  }
261
- }, {
262
- key: "componentDidUpdate",
263
- value: function componentDidUpdate(prevProps) {
264
- if (this.props.authentication.didChange(prevProps.authentication)) {
265
- this.getOrganizations();
266
- }
267
-
268
- if (this.props.organization.didOrganizationChange(prevProps.organization.organization)) {
269
- this.getEntities();
270
- }
271
-
272
- if (this.props.authentication.didChange(prevProps.authentication) || this.props.organization.didChange(prevProps.organization)) {
273
- this.getApps();
274
- this.getFavorites(); // this.getSubscription();
275
-
276
- this.getNotifications();
211
+ }
212
+ getOrganizations() {
213
+ const methodName = 'getOrganizations()';
214
+ this.props.authentication.http({
215
+ method: 'get',
216
+ url: "".concat(this.props.core.baseUrl, "/api/administration/organizations")
217
+ }).then(res => {
218
+ if (res.data.length > 0 && typeof res.data[0] === 'object') {
219
+ this.setState({
220
+ organizations: res.data
221
+ });
222
+ if (this.props.organization.organization === null || res.data.find(x => x.id === this.props.organization.organization.id) === undefined) {
223
+ this.props.organization.setOrganization(res.data[0]);
224
+ }
277
225
  }
278
- }
279
- }, {
280
- key: "getOrganizations",
281
- value: function getOrganizations() {
282
- var _this2 = this;
283
-
284
- var methodName = 'getOrganizations()';
226
+ }).catch(error => {
227
+ this.props.core.log('error', namespace, methodName, error);
228
+ });
229
+ }
230
+ getEntities() {
231
+ const methodName = 'getEntities()';
232
+ if (this.props.organization.organization !== null) {
285
233
  this.props.authentication.http({
286
234
  method: 'get',
287
- url: "".concat(this.props.core.baseUrl, "/api/administration/organizations")
288
- }).then(function (res) {
289
- if (res.data.length > 0 && _typeof(res.data[0]) === 'object') {
290
- _this2.setState({
291
- organizations: res.data
235
+ url: "".concat(this.props.core.baseUrl, "/api/administration/entities/organization/").concat(this.props.organization.organization.key)
236
+ }).then(res => {
237
+ if (res.data.length > 0 && typeof res.data[0] === 'object') {
238
+ this.setState({
239
+ entities: res.data
292
240
  });
293
-
294
- if (_this2.props.organization.organization === null || res.data.find(function (x) {
295
- return x.id === _this2.props.organization.organization.id;
296
- }) === undefined) {
297
- _this2.props.organization.setOrganization(res.data[0]);
241
+ if (this.props.organization.entity === null || res.data.find(x => x.id === this.props.organization.entity.id) === undefined) {
242
+ this.props.organization.setEntity(res.data[0]);
298
243
  }
299
244
  }
300
- }).catch(function (error) {
301
- _this2.props.core.log('error', namespace, methodName, error);
245
+ }).catch(error => {
246
+ this.props.core.log('error', namespace, methodName, error);
302
247
  });
303
248
  }
304
- }, {
305
- key: "getEntities",
306
- value: function getEntities() {
307
- var _this3 = this;
308
-
309
- var methodName = 'getEntities()';
310
-
311
- if (this.props.organization.organization !== null) {
312
- this.props.authentication.http({
313
- method: 'get',
314
- url: "".concat(this.props.core.baseUrl, "/api/administration/entities/organization/").concat(this.props.organization.organization.key)
315
- }).then(function (res) {
316
- if (res.data.length > 0 && _typeof(res.data[0]) === 'object') {
317
- _this3.setState({
318
- entities: res.data
319
- });
320
-
321
- if (_this3.props.organization.entity === null || res.data.find(function (x) {
322
- return x.id === _this3.props.organization.entity.id;
323
- }) === undefined) {
324
- _this3.props.organization.setEntity(res.data[0]);
325
- }
326
- }
327
- }).catch(function (error) {
328
- _this3.props.core.log('error', namespace, methodName, error);
329
- });
330
- }
331
- }
332
- }, {
333
- key: "getApps",
334
- value: function getApps() {
335
- var _this4 = this;
336
-
337
- var methodName = 'getApps()';
338
-
339
- if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
340
- this.props.authentication.http({
341
- method: 'get',
342
- url: "".concat(this.props.core.baseUrl, "/api/components/tiered"),
343
- params: {
344
- type: 'UI',
345
- organizationId: this.props.organization.organization.id,
346
- entityId: this.props.organization.entity.id
347
- }
348
- }).then(function (res) {
349
- if (res.data.length > 0 && _typeof(res.data[0]) === 'object') {
350
- _this4.setState({
351
- apps: res.data
352
- });
353
- }
354
- }).catch(function (error) {
355
- _this4.props.core.log('error', namespace, methodName, error);
356
- });
357
- }
358
- }
359
- }, {
360
- key: "getFavorites",
361
- value: function getFavorites() {
362
- var _this5 = this;
363
-
364
- var methodName = 'getFavorites()';
365
-
366
- if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
367
- this.props.authentication.http({
368
- method: 'get',
369
- url: "".concat(this.props.core.baseUrl, "/api/user/activity/favorites"),
370
- params: {
371
- type: 'App'
372
- }
373
- }).then(function (res) {
374
- _this5.setState({
375
- favorites: res.data
376
- });
377
- }).catch(function (error) {
378
- _this5.props.core.log('error', namespace, methodName, error);
379
- });
380
- }
381
- }
382
- }, {
383
- key: "getNotifications",
384
- value: function getNotifications() {
385
- var _this6 = this;
386
-
387
- var methodName = 'getNotifications()';
388
- var _this$props = this.props,
389
- authentication = _this$props.authentication,
390
- core = _this$props.core,
391
- organization = _this$props.organization;
392
-
393
- if (organization.organization !== null && organization.entity !== null) {
394
- authentication.http({
395
- method: 'get',
396
- url: "".concat(core.baseUrl, "/api/user/activity/notifications"),
397
- params: {
398
- organizationId: organization.organization.id,
399
- entityId: organization.entity.id
400
- }
401
- }).then(function (res) {
402
- _this6.setState({
403
- notifications: res.data
404
- });
405
- }).catch(function (error) {
406
- core.log('error', namespace, methodName, error);
407
- });
408
- }
409
- }
410
- /* getSubscription() {
411
- const methodName = 'getSubscription()';
412
- const { authentication, core, organization } = this.props;
413
- if (organization.organization !== null && organization.entity !== null) {
414
- authentication.http({
415
- method: 'get',
416
- url: `${core.baseUrl}/api/subscriptions/primary`,
417
- params: {
418
- organizationId: organization.organization.id,
419
- entityId: organization.entity.id,
420
- },
421
- }).then(res => {
422
- this.setState({ subscription: res.data });
423
- }).catch(error => {
424
- core.log('error', namespace, methodName, error);
425
- });
426
- }
427
- } */
428
-
429
- }, {
430
- key: "getUsersInitials",
431
- value: function getUsersInitials() {
432
- var authentication = this.props.authentication;
433
- var initials = '';
434
-
435
- if (authentication.token && authentication.token.userInfo) {
436
- if (authentication.token.userInfo.firstName.length > 0) {
437
- initials += authentication.token.userInfo.firstName[0].toUpperCase();
249
+ }
250
+ getApps() {
251
+ const methodName = 'getApps()';
252
+ if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
253
+ this.props.authentication.http({
254
+ method: 'get',
255
+ url: "".concat(this.props.core.baseUrl, "/api/components/tiered"),
256
+ params: {
257
+ type: 'UI',
258
+ organizationId: this.props.organization.organization.id,
259
+ entityId: this.props.organization.entity.id
438
260
  }
439
-
440
- if (authentication.token.userInfo.lastName.length > 0) {
441
- initials += authentication.token.userInfo.lastName[0].toUpperCase();
261
+ }).then(res => {
262
+ if (res.data.length > 0 && typeof res.data[0] === 'object') {
263
+ this.setState({
264
+ apps: res.data
265
+ });
442
266
  }
443
- }
444
-
445
- return initials;
267
+ }).catch(error => {
268
+ this.props.core.log('error', namespace, methodName, error);
269
+ });
446
270
  }
447
- }, {
448
- key: "getNotificationBadgeClass",
449
- value: function getNotificationBadgeClass() {
450
- var notifications = this.state.notifications;
451
- var classes = this.props.classes;
452
- var hasError = false;
453
- var hasWarning = false;
454
- notifications.forEach(function (notification) {
455
- if (notification.type === 'error') {
456
- hasError = true;
271
+ }
272
+ getFavorites() {
273
+ const methodName = 'getFavorites()';
274
+ if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
275
+ this.props.authentication.http({
276
+ method: 'get',
277
+ url: "".concat(this.props.core.baseUrl, "/api/user/activity/favorites"),
278
+ params: {
279
+ type: 'App'
457
280
  }
458
-
459
- if (notification.type === 'warning') {
460
- hasWarning = true;
281
+ }).then(res => {
282
+ this.setState({
283
+ favorites: res.data
284
+ });
285
+ }).catch(error => {
286
+ this.props.core.log('error', namespace, methodName, error);
287
+ });
288
+ }
289
+ }
290
+ getNotifications() {
291
+ const methodName = 'getNotifications()';
292
+ const {
293
+ authentication,
294
+ core,
295
+ organization
296
+ } = this.props;
297
+ if (organization.organization !== null && organization.entity !== null) {
298
+ authentication.http({
299
+ method: 'get',
300
+ url: "".concat(core.baseUrl, "/api/user/activity/notifications"),
301
+ params: {
302
+ organizationId: organization.organization.id,
303
+ entityId: organization.entity.id
461
304
  }
305
+ }).then(res => {
306
+ this.setState({
307
+ notifications: res.data
308
+ });
309
+ }).catch(error => {
310
+ core.log('error', namespace, methodName, error);
462
311
  });
312
+ }
313
+ }
463
314
 
464
- if (hasError) {
465
- return classes.badgeError;
315
+ /* getSubscription() {
316
+ const methodName = 'getSubscription()';
317
+ const { authentication, core, organization } = this.props;
318
+ if (organization.organization !== null && organization.entity !== null) {
319
+ authentication.http({
320
+ method: 'get',
321
+ url: `${core.baseUrl}/api/subscriptions/primary`,
322
+ params: {
323
+ organizationId: organization.organization.id,
324
+ entityId: organization.entity.id,
325
+ },
326
+ }).then(res => {
327
+ this.setState({ subscription: res.data });
328
+ }).catch(error => {
329
+ core.log('error', namespace, methodName, error);
330
+ });
331
+ }
332
+ } */
333
+
334
+ getUsersInitials() {
335
+ const {
336
+ authentication
337
+ } = this.props;
338
+ let initials = '';
339
+ if (authentication.token && authentication.token.userInfo) {
340
+ if (authentication.token.userInfo.firstName.length > 0) {
341
+ initials += authentication.token.userInfo.firstName[0].toUpperCase();
466
342
  }
467
-
468
- if (hasWarning) {
469
- return classes.badgeWarning;
343
+ if (authentication.token.userInfo.lastName.length > 0) {
344
+ initials += authentication.token.userInfo.lastName[0].toUpperCase();
470
345
  }
471
-
472
- return classes.badgeInfo;
473
346
  }
474
- }, {
475
- key: "getNotificationIcon",
476
- value: function getNotificationIcon(type) {
477
- var theme = this.props.theme;
478
-
479
- switch (type.toLowerCase()) {
480
- case 'error':
481
- // '#ff6666'
482
- return /*#__PURE__*/_react.default.createElement(_Error.default, {
483
- style: {
484
- color: theme.palette.error.light
485
- }
486
- });
487
-
488
- case 'warning':
489
- // 'yellow'
490
- return /*#__PURE__*/_react.default.createElement(_Warning.default, {
491
- style: {
492
- color: theme.palette.warning.light
493
- }
494
- });
495
-
496
- default:
497
- // 'lightblue'
498
- return /*#__PURE__*/_react.default.createElement(_Info.default, {
499
- style: {
500
- color: theme.palette.info.light
501
- }
502
- });
347
+ return initials;
348
+ }
349
+ getNotificationBadgeClass() {
350
+ const {
351
+ notifications
352
+ } = this.state;
353
+ const {
354
+ classes
355
+ } = this.props;
356
+ let hasError = false;
357
+ let hasWarning = false;
358
+ notifications.forEach(notification => {
359
+ if (notification.type === 'error') {
360
+ hasError = true;
503
361
  }
504
- }
505
- }, {
506
- key: "favoriteApp",
507
- value: function favoriteApp() {
508
- var _this7 = this;
509
-
510
- var methodName = 'favoriteApp()';
511
-
512
- if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
513
- this.props.authentication.http({
514
- method: 'post',
515
- url: "".concat(this.props.core.baseUrl, "/api/user/activity/favorite"),
516
- params: {
517
- type: 'App',
518
- itemId: this.props.componentID,
519
- favorite: !this.state.favorites.includes(this.props.componentID)
520
- }
521
- }).then(function () {
522
- _this7.getFavorites();
523
- }).catch(function (error) {
524
- _this7.props.core.log('error', namespace, methodName, error);
525
- });
362
+ if (notification.type === 'warning') {
363
+ hasWarning = true;
526
364
  }
365
+ });
366
+ if (hasError) {
367
+ return classes.badgeError;
527
368
  }
528
- }, {
529
- key: "dismissNotification",
530
- value: function dismissNotification(id) {
531
- var methodName = "dismissNotification(".concat(id, ")");
532
- var _this$props2 = this.props,
533
- authentication = _this$props2.authentication,
534
- core = _this$props2.core;
535
- authentication.http({
536
- method: 'delete',
537
- url: "".concat(core.baseUrl, "/api/user/activity/notifications/").concat(id)
538
- }).catch(function (error) {
539
- core.log('error', namespace, methodName, error);
540
- });
369
+ if (hasWarning) {
370
+ return classes.badgeWarning;
541
371
  }
542
- }, {
543
- key: "handleMessage",
544
- value: function handleMessage(channel, obj) {
545
- switch (obj.what) {
546
- case 'notifications_changed':
547
- this.getNotifications();
548
- break;
549
-
550
- case 'package_enabled':
551
- case 'package_disabled':
552
- case 'package_added':
553
- case 'package_updated':
554
- case 'package_deleted':
555
- this.getApps();
556
- break;
557
-
558
- case 'entities_added':
559
- case 'entities_updated':
560
- case 'entities_deleted':
561
- this.getEntities();
562
- break;
563
-
564
- default:
565
- break;
566
- }
567
- }
568
- }, {
569
- key: "render",
570
- value: function render() {
571
- var _this8 = this;
572
-
573
- var _this$props3 = this.props,
574
- title = _this$props3.title,
575
- componentID = _this$props3.componentID,
576
- authentication = _this$props3.authentication,
577
- organization = _this$props3.organization,
578
- classes = _this$props3.classes;
579
- var _this$state = this.state,
580
- notificationsAnchorEl = _this$state.notificationsAnchorEl,
581
- notifications = _this$state.notifications;
582
- return /*#__PURE__*/_react.default.createElement("div", {
583
- className: classes.root
584
- }, /*#__PURE__*/_react.default.createElement(_context.ChannelsConsumer, {
585
- id: "coreappbar",
586
- handler: function handler(channel, obj) {
587
- return _this8.handleMessage(channel, obj);
588
- }
589
- }), /*#__PURE__*/_react.default.createElement(_Drawer.default, {
590
- variant: "permanent",
591
- classes: {
592
- paper: classes.drawerPaper
593
- }
594
- }, /*#__PURE__*/_react.default.createElement("div", {
595
- style: {
596
- display: 'flex',
597
- flexDirection: ' row',
598
- backgroundColor: '#3f5c67'
599
- }
600
- }, /*#__PURE__*/_react.default.createElement("div", {
601
- style: {
602
- backgroundColor: '#496b78',
603
- alignItems: 'center',
604
- justifyContent: 'center'
605
- }
606
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
607
- style: {
608
- margin: 8
609
- },
610
- color: "inherit",
611
- onClick: function onClick() {
612
- return _this8.setState({
613
- drawer: true
614
- });
615
- }
616
- }, /*#__PURE__*/_react.default.createElement(_Menu2.default, null))), /*#__PURE__*/_react.default.createElement("div", {
617
- style: style.orgEntity
618
- }, /*#__PURE__*/_react.default.createElement(_Button.default, {
619
- color: "inherit",
620
- style: style.titleButton,
621
- variant: "text",
622
- onClick: this.state.entities.length > 1 ? function (e) {
623
- return _this8.setState({
624
- entityAnchorEl: e.currentTarget
625
- });
626
- } : null
627
- }, /*#__PURE__*/_react.default.createElement("div", null, organization.organization ? organization.organization.name : null, this.props.showEntity && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("br", null), organization.entity ? organization.entity.name : null))))), /*#__PURE__*/_react.default.createElement(_Typography.default, {
628
- style: style.title,
629
- variant: "h6",
630
- color: "inherit"
631
- }, title), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("div", {
632
- className: "".concat(_scrollbarModule.default.scroll, " ").concat(_scrollbarModule.default.white),
633
- style: {
634
- flexGrow: 1,
635
- minHeight: 0,
636
- overflow: 'auto'
637
- }
638
- }, this.props.content), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("div", {
639
- style: {
640
- padding: 5
641
- }
642
- }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
643
- title: "".concat(this.props.authentication.token.userInfo.firstName, " ").concat(this.props.authentication.token.userInfo.lastName)
644
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
645
- color: "inherit",
646
- onClick: function onClick(e) {
647
- return _this8.setState({
648
- authenticationAnchorEl: e.currentTarget
649
- });
650
- },
651
- className: classes.menuIconButton
652
- }, /*#__PURE__*/_react.default.createElement(_AccountCircle.default, null))), /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
653
- title: notifications.length > 0 ? "You have ".concat(notifications.length, " notification").concat(notifications.length > 0 ? 's' : '') : 'There are no notifications'
654
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
655
- color: "inherit",
656
- onClick: notifications.length > 0 ? function (e) {
657
- return _this8.setState({
658
- notificationsAnchorEl: e.currentTarget
659
- });
660
- } : null,
661
- className: classes.menuIconButton
662
- }, /*#__PURE__*/_react.default.createElement(_Badge.default, {
663
- badgeContent: notifications.length,
664
- classes: {
665
- badge: this.getNotificationBadgeClass()
666
- },
667
- showZero: false
668
- }, /*#__PURE__*/_react.default.createElement(_Notifications.default, null)))), componentID.length > 0 && /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
669
- title: this.state.favorites.includes(componentID) ? /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
670
- id: "__favorite"
671
- }) : /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
672
- id: "__click_to_favorite"
673
- })
674
- }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
675
- color: "inherit",
676
- onClick: function onClick() {
677
- return _this8.favoriteApp();
678
- },
679
- className: classes.menuIconButton
680
- }, this.state.favorites.includes(componentID) ? /*#__PURE__*/_react.default.createElement(_Star.default, {
681
- color: "inherit"
682
- }) : /*#__PURE__*/_react.default.createElement(_StarBorder.default, {
683
- color: "inherit"
684
- }))))), /*#__PURE__*/_react.default.createElement("div", {
685
- className: classes.content
686
- }, this.props.children), /*#__PURE__*/_react.default.createElement(_CoreSideBarDrawer.default, {
687
- open: this.state.drawer,
688
- onClose: function onClose() {
689
- return _this8.setState({
690
- drawer: false
691
- });
692
- },
693
- apps: this.state.apps
694
- }), /*#__PURE__*/_react.default.createElement(_Menu.default, {
695
- open: !!this.state.organizationAnchorEl,
696
- anchorEl: this.state.organizationAnchorEl,
697
- anchorOrigin: {
698
- vertical: 'top',
699
- horizontal: 'center'
700
- },
701
- transformOrigin: {
702
- vertical: 'top',
703
- horizontal: 'center'
704
- },
705
- onClose: function onClose() {
706
- return _this8.setState({
707
- organizationAnchorEl: null
708
- });
709
- }
710
- }, this.state.organizations.map(function (org) {
711
- return /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
712
- key: org.id,
713
- onClick: function onClick() {
714
- organization.setOrganization(org);
715
-
716
- _this8.setState({
717
- organizationAnchorEl: null
718
- });
719
- }
720
- }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_LocationCity.default, null)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
721
- primary: org.name,
722
- inset: true
723
- }));
724
- })), /*#__PURE__*/_react.default.createElement(_Menu.default, {
725
- classes: {
726
- paper: classes.menuPaper
727
- },
728
- anchorEl: this.state.entityAnchorEl,
729
- anchorOrigin: {
730
- vertical: 'top',
731
- horizontal: 'center'
732
- },
733
- transformOrigin: {
734
- vertical: 'top',
735
- horizontal: 'center'
736
- },
737
- open: !!this.state.entityAnchorEl,
738
- onClose: function onClose() {
739
- return _this8.setState({
740
- entityAnchorEl: null
741
- });
742
- }
743
- }, this.state.entities.map(function (entity) {
744
- return /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
745
- classes: {
746
- root: classes.menuItemRoot
747
- },
748
- key: entity.key,
749
- onClick: function onClick() {
750
- organization.setEntity(entity);
751
-
752
- _this8.setState({
753
- entityAnchorEl: null
754
- });
755
- }
756
- }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, {
757
- classes: {
758
- root: classes.listItemRoot
759
- }
760
- }, /*#__PURE__*/_react.default.createElement(_LocationCity.default, null)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
761
- classes: {
762
- primary: classes.listItemRoot
763
- },
764
- primary: entity.name,
765
- inset: true
766
- }));
767
- })), /*#__PURE__*/_react.default.createElement(_Menu.default, {
768
- classes: {
769
- paper: classes.menuPaper
770
- },
771
- open: !!this.state.authenticationAnchorEl,
772
- anchorEl: this.state.authenticationAnchorEl,
773
- onClose: function onClose() {
774
- return _this8.setState({
775
- authenticationAnchorEl: null
776
- });
777
- }
778
- }, /*#__PURE__*/_react.default.createElement(_ListItem.default, {
779
- classes: {
780
- root: classes.menuItemRoot
781
- },
782
- style: {
783
- outline: 0
784
- }
785
- }, /*#__PURE__*/_react.default.createElement(_Avatar.default, {
786
- style: {
787
- marginRight: 10
788
- }
789
- }, this.getUsersInitials()), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
790
- classes: {
791
- primary: classes.menuItemRoot,
792
- secondary: classes.menuItemRoot
793
- },
794
- primary: "".concat(this.props.authentication.token.userInfo.firstName, " ").concat(this.props.authentication.token.userInfo.lastName),
795
- secondary: this.props.authentication.token.userInfo.emailAddress
796
- })), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("a", {
797
- href: this.props.core.formatUrl('/profile'),
798
- style: {
799
- all: 'unset'
800
- }
801
- }, /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
802
- classes: {
803
- root: classes.menuItemRoot
804
- }
805
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
806
- id: "__my_profile"
807
- }))), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
808
- classes: {
809
- root: classes.menuItemRoot
810
- },
811
- onClick: function onClick() {
812
- return authentication.logout();
813
- }
814
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
815
- id: "__log_out"
816
- }))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
817
- classes: {
818
- paper: classes.menuPaper,
819
- root: classes.notificationRoot
820
- },
821
- open: !!notificationsAnchorEl,
822
- anchorEl: notificationsAnchorEl,
823
- onClose: function onClose() {
824
- return _this8.setState({
825
- notificationsAnchorEl: null
826
- });
827
- }
828
- }, notifications.map(function (notification) {
829
- return /*#__PURE__*/_react.default.createElement(_ListItem.default, {
830
- key: notification.id,
831
- classes: {
832
- root: classes.menuItemRoot
833
- }
834
- }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, _this8.getNotificationIcon(notification.type)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
835
- primary: notification.title,
836
- secondary: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
837
- component: "span",
838
- variant: "body2",
839
- className: classes.inline,
840
- color: "inherit"
841
- }, notification.description))
842
- }), notification.url && notification.url.length > 0 && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
843
- style: {
844
- marginLeft: 5
845
- },
846
- "aria-label": "navigate",
847
- onClick: function onClick() {
848
- return window.open(notification.url, '__BLANK');
849
- }
850
- }, /*#__PURE__*/_react.default.createElement(_ExitToApp.default, {
372
+ return classes.badgeInfo;
373
+ }
374
+ getNotificationIcon(type) {
375
+ const {
376
+ theme
377
+ } = this.props;
378
+ switch (type.toLowerCase()) {
379
+ case 'error':
380
+ // '#ff6666'
381
+ return /*#__PURE__*/_react.default.createElement(_Error.default, {
851
382
  style: {
852
- color: '#ffffff'
383
+ color: theme.palette.error.light
853
384
  }
854
- })), notification.isDismissable && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
385
+ });
386
+ case 'warning':
387
+ // 'yellow'
388
+ return /*#__PURE__*/_react.default.createElement(_Warning.default, {
855
389
  style: {
856
- marginLeft: 5
857
- },
858
- "aria-label": "delete",
859
- onClick: function onClick() {
860
- return _this8.dismissNotification(notification.id);
390
+ color: theme.palette.warning.light
861
391
  }
862
- }, /*#__PURE__*/_react.default.createElement(_Delete.default, {
392
+ });
393
+ default:
394
+ // 'lightblue'
395
+ return /*#__PURE__*/_react.default.createElement(_Info.default, {
863
396
  style: {
864
- color: '#ffffff'
397
+ color: theme.palette.info.light
865
398
  }
866
- })));
867
- })));
399
+ });
868
400
  }
869
- }]);
870
-
871
- return CoreSideBar;
872
- }(_react.Component);
873
-
401
+ }
402
+ favoriteApp() {
403
+ const methodName = 'favoriteApp()';
404
+ if (this.props.organization.organization !== null && this.props.organization.entity !== null) {
405
+ this.props.authentication.http({
406
+ method: 'post',
407
+ url: "".concat(this.props.core.baseUrl, "/api/user/activity/favorite"),
408
+ params: {
409
+ type: 'App',
410
+ itemId: this.props.componentID,
411
+ favorite: !this.state.favorites.includes(this.props.componentID)
412
+ }
413
+ }).then(() => {
414
+ this.getFavorites();
415
+ }).catch(error => {
416
+ this.props.core.log('error', namespace, methodName, error);
417
+ });
418
+ }
419
+ }
420
+ dismissNotification(id) {
421
+ const methodName = "dismissNotification(".concat(id, ")");
422
+ const {
423
+ authentication,
424
+ core
425
+ } = this.props;
426
+ authentication.http({
427
+ method: 'delete',
428
+ url: "".concat(core.baseUrl, "/api/user/activity/notifications/").concat(id)
429
+ }).catch(error => {
430
+ core.log('error', namespace, methodName, error);
431
+ });
432
+ }
433
+ handleMessage(channel, obj) {
434
+ switch (obj.what) {
435
+ case 'notifications_changed':
436
+ this.getNotifications();
437
+ break;
438
+ case 'package_enabled':
439
+ case 'package_disabled':
440
+ case 'package_added':
441
+ case 'package_updated':
442
+ case 'package_deleted':
443
+ this.getApps();
444
+ break;
445
+ case 'entities_added':
446
+ case 'entities_updated':
447
+ case 'entities_deleted':
448
+ this.getEntities();
449
+ break;
450
+ default:
451
+ break;
452
+ }
453
+ }
454
+ render() {
455
+ const {
456
+ title,
457
+ componentID,
458
+ authentication,
459
+ organization,
460
+ classes
461
+ } = this.props;
462
+ const {
463
+ notificationsAnchorEl,
464
+ notifications
465
+ } = this.state;
466
+ return /*#__PURE__*/_react.default.createElement("div", {
467
+ className: classes.root
468
+ }, /*#__PURE__*/_react.default.createElement(_context.ChannelsConsumer, {
469
+ id: "coreappbar",
470
+ handler: (channel, obj) => this.handleMessage(channel, obj)
471
+ }), /*#__PURE__*/_react.default.createElement(_Drawer.default, {
472
+ variant: "permanent",
473
+ classes: {
474
+ paper: classes.drawerPaper
475
+ }
476
+ }, /*#__PURE__*/_react.default.createElement("div", {
477
+ style: {
478
+ display: 'flex',
479
+ flexDirection: ' row',
480
+ backgroundColor: '#3f5c67'
481
+ }
482
+ }, /*#__PURE__*/_react.default.createElement("div", {
483
+ style: {
484
+ backgroundColor: '#496b78',
485
+ alignItems: 'center',
486
+ justifyContent: 'center'
487
+ }
488
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
489
+ style: {
490
+ margin: 8
491
+ },
492
+ color: "inherit",
493
+ onClick: () => this.setState({
494
+ drawer: true
495
+ })
496
+ }, /*#__PURE__*/_react.default.createElement(_Menu2.default, null))), /*#__PURE__*/_react.default.createElement("div", {
497
+ style: style.orgEntity
498
+ }, /*#__PURE__*/_react.default.createElement(_Button.default, {
499
+ color: "inherit",
500
+ style: style.titleButton,
501
+ variant: "text",
502
+ onClick: this.state.entities.length > 1 ? e => this.setState({
503
+ entityAnchorEl: e.currentTarget
504
+ }) : null
505
+ }, /*#__PURE__*/_react.default.createElement("div", null, organization.organization ? organization.organization.name : null, this.props.showEntity && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("br", null), organization.entity ? organization.entity.name : null))))), /*#__PURE__*/_react.default.createElement(_Typography.default, {
506
+ style: style.title,
507
+ variant: "h6",
508
+ color: "inherit"
509
+ }, title), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("div", {
510
+ className: "".concat(_scrollbarModule.default.scroll, " ").concat(_scrollbarModule.default.white),
511
+ style: {
512
+ flexGrow: 1,
513
+ minHeight: 0,
514
+ overflow: 'auto'
515
+ }
516
+ }, this.props.content), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("div", {
517
+ style: {
518
+ padding: 5
519
+ }
520
+ }, /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
521
+ title: "".concat(this.props.authentication.token.userInfo.firstName, " ").concat(this.props.authentication.token.userInfo.lastName)
522
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
523
+ color: "inherit",
524
+ onClick: e => this.setState({
525
+ authenticationAnchorEl: e.currentTarget
526
+ }),
527
+ className: classes.menuIconButton
528
+ }, /*#__PURE__*/_react.default.createElement(_AccountCircle.default, null))), /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
529
+ title: notifications.length > 0 ? "You have ".concat(notifications.length, " notification").concat(notifications.length > 0 ? 's' : '') : 'There are no notifications'
530
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
531
+ color: "inherit",
532
+ onClick: notifications.length > 0 ? e => this.setState({
533
+ notificationsAnchorEl: e.currentTarget
534
+ }) : null,
535
+ className: classes.menuIconButton
536
+ }, /*#__PURE__*/_react.default.createElement(_Badge.default, {
537
+ badgeContent: notifications.length,
538
+ classes: {
539
+ badge: this.getNotificationBadgeClass()
540
+ },
541
+ showZero: false
542
+ }, /*#__PURE__*/_react.default.createElement(_Notifications.default, null)))), componentID.length > 0 && /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
543
+ title: this.state.favorites.includes(componentID) ? /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
544
+ id: "__favorite"
545
+ }) : /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
546
+ id: "__click_to_favorite"
547
+ })
548
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
549
+ color: "inherit",
550
+ onClick: () => this.favoriteApp(),
551
+ className: classes.menuIconButton
552
+ }, this.state.favorites.includes(componentID) ? /*#__PURE__*/_react.default.createElement(_Star.default, {
553
+ color: "inherit"
554
+ }) : /*#__PURE__*/_react.default.createElement(_StarBorder.default, {
555
+ color: "inherit"
556
+ }))))), /*#__PURE__*/_react.default.createElement("div", {
557
+ className: classes.content
558
+ }, this.props.children), /*#__PURE__*/_react.default.createElement(_CoreSideBarDrawer.default, {
559
+ open: this.state.drawer,
560
+ onClose: () => this.setState({
561
+ drawer: false
562
+ }),
563
+ apps: this.state.apps
564
+ }), /*#__PURE__*/_react.default.createElement(_Menu.default, {
565
+ open: !!this.state.organizationAnchorEl,
566
+ anchorEl: this.state.organizationAnchorEl,
567
+ anchorOrigin: {
568
+ vertical: 'top',
569
+ horizontal: 'center'
570
+ },
571
+ transformOrigin: {
572
+ vertical: 'top',
573
+ horizontal: 'center'
574
+ },
575
+ onClose: () => this.setState({
576
+ organizationAnchorEl: null
577
+ })
578
+ }, this.state.organizations.map(org => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
579
+ key: org.id,
580
+ onClick: () => {
581
+ organization.setOrganization(org);
582
+ this.setState({
583
+ organizationAnchorEl: null
584
+ });
585
+ }
586
+ }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_LocationCity.default, null)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
587
+ primary: org.name,
588
+ inset: true
589
+ })))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
590
+ classes: {
591
+ paper: classes.menuPaper
592
+ },
593
+ anchorEl: this.state.entityAnchorEl,
594
+ anchorOrigin: {
595
+ vertical: 'top',
596
+ horizontal: 'center'
597
+ },
598
+ transformOrigin: {
599
+ vertical: 'top',
600
+ horizontal: 'center'
601
+ },
602
+ open: !!this.state.entityAnchorEl,
603
+ onClose: () => this.setState({
604
+ entityAnchorEl: null
605
+ })
606
+ }, this.state.entities.map(entity => /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
607
+ classes: {
608
+ root: classes.menuItemRoot
609
+ },
610
+ key: entity.key,
611
+ onClick: () => {
612
+ organization.setEntity(entity);
613
+ this.setState({
614
+ entityAnchorEl: null
615
+ });
616
+ }
617
+ }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, {
618
+ classes: {
619
+ root: classes.listItemRoot
620
+ }
621
+ }, /*#__PURE__*/_react.default.createElement(_LocationCity.default, null)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
622
+ classes: {
623
+ primary: classes.listItemRoot
624
+ },
625
+ primary: entity.name,
626
+ inset: true
627
+ })))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
628
+ classes: {
629
+ paper: classes.menuPaper
630
+ },
631
+ open: !!this.state.authenticationAnchorEl,
632
+ anchorEl: this.state.authenticationAnchorEl,
633
+ onClose: () => this.setState({
634
+ authenticationAnchorEl: null
635
+ })
636
+ }, /*#__PURE__*/_react.default.createElement(_ListItem.default, {
637
+ classes: {
638
+ root: classes.menuItemRoot
639
+ },
640
+ style: {
641
+ outline: 0
642
+ }
643
+ }, /*#__PURE__*/_react.default.createElement(_Avatar.default, {
644
+ style: {
645
+ marginRight: 10
646
+ }
647
+ }, this.getUsersInitials()), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
648
+ classes: {
649
+ primary: classes.menuItemRoot,
650
+ secondary: classes.menuItemRoot
651
+ },
652
+ primary: "".concat(this.props.authentication.token.userInfo.firstName, " ").concat(this.props.authentication.token.userInfo.lastName),
653
+ secondary: this.props.authentication.token.userInfo.emailAddress
654
+ })), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement("a", {
655
+ href: this.props.core.formatUrl('/profile'),
656
+ style: {
657
+ all: 'unset'
658
+ }
659
+ }, /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
660
+ classes: {
661
+ root: classes.menuItemRoot
662
+ }
663
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
664
+ id: "__my_profile"
665
+ }))), /*#__PURE__*/_react.default.createElement(_Divider.default, null), /*#__PURE__*/_react.default.createElement(_MenuItem.default, {
666
+ classes: {
667
+ root: classes.menuItemRoot
668
+ },
669
+ onClick: () => authentication.logout()
670
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
671
+ id: "__log_out"
672
+ }))), /*#__PURE__*/_react.default.createElement(_Menu.default, {
673
+ classes: {
674
+ paper: classes.menuPaper,
675
+ root: classes.notificationRoot
676
+ },
677
+ open: !!notificationsAnchorEl,
678
+ anchorEl: notificationsAnchorEl,
679
+ onClose: () => this.setState({
680
+ notificationsAnchorEl: null
681
+ })
682
+ }, notifications.map(notification => /*#__PURE__*/_react.default.createElement(_ListItem.default, {
683
+ key: notification.id,
684
+ classes: {
685
+ root: classes.menuItemRoot
686
+ }
687
+ }, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, this.getNotificationIcon(notification.type)), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
688
+ primary: notification.title,
689
+ secondary: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
690
+ component: "span",
691
+ variant: "body2",
692
+ className: classes.inline,
693
+ color: "inherit"
694
+ }, notification.description))
695
+ }), notification.url && notification.url.length > 0 && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
696
+ style: {
697
+ marginLeft: 5
698
+ },
699
+ "aria-label": "navigate",
700
+ onClick: () => window.open(notification.url, '__BLANK')
701
+ }, /*#__PURE__*/_react.default.createElement(_ExitToApp.default, {
702
+ style: {
703
+ color: '#ffffff'
704
+ }
705
+ })), notification.isDismissable && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
706
+ style: {
707
+ marginLeft: 5
708
+ },
709
+ "aria-label": "delete",
710
+ onClick: () => this.dismissNotification(notification.id)
711
+ }, /*#__PURE__*/_react.default.createElement(_Delete.default, {
712
+ style: {
713
+ color: '#ffffff'
714
+ }
715
+ }))))));
716
+ }
717
+ }
874
718
  CoreSideBar.propTypes = {
875
719
  title: _propTypes.default.string,
876
720
  showEntity: _propTypes.default.bool,
@@ -891,7 +735,4 @@ CoreSideBar.defaultProps = {
891
735
  children: null,
892
736
  content: null
893
737
  };
894
-
895
- var _default = (0, _reactIntl.injectIntl)((0, _context.withCore)((0, _context.withAuthentication)((0, _context.withOrganization)((0, _styles.withTheme)((0, _styles.withStyles)(styles)(CoreSideBar))))));
896
-
897
- exports.default = _default;
738
+ var _default = exports.default = (0, _reactIntl.injectIntl)((0, _context.withCore)((0, _context.withAuthentication)((0, _context.withOrganization)((0, _styles.withTheme)((0, _styles.withStyles)(styles)(CoreSideBar))))));