@iobroker/adapter-react-v5 4.5.3 → 4.5.5

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 (284) hide show
  1. package/AdminConnection.js +1 -2
  2. package/AdminConnection.js.map +1 -1
  3. package/Components/404.js +6 -7
  4. package/Components/404.js.map +1 -1
  5. package/Components/ColorPicker.js +4 -5
  6. package/Components/ColorPicker.js.map +1 -1
  7. package/Components/ComplexCron.js +1 -2
  8. package/Components/ComplexCron.js.map +1 -1
  9. package/Components/CustomModal.js +1 -2
  10. package/Components/CustomModal.js.map +1 -1
  11. package/Components/FileBrowser.d.ts +4 -1
  12. package/Components/FileBrowser.js +133 -53
  13. package/Components/FileBrowser.js.map +1 -1
  14. package/Components/FileViewer.js +2 -4
  15. package/Components/FileViewer.js.map +1 -1
  16. package/Components/Icon.js +3 -4
  17. package/Components/Icon.js.map +1 -1
  18. package/Components/IconPicker.js +1 -2
  19. package/Components/IconPicker.js.map +1 -1
  20. package/Components/IconSelector.js +1 -2
  21. package/Components/IconSelector.js.map +1 -1
  22. package/Components/Image.js +1 -2
  23. package/Components/Image.js.map +1 -1
  24. package/Components/JsonConfigComponent/ChipInput.js +4 -6
  25. package/Components/JsonConfigComponent/ChipInput.js.map +1 -1
  26. package/Components/JsonConfigComponent/ConfigAccordion.js +3 -4
  27. package/Components/JsonConfigComponent/ConfigAccordion.js.map +1 -1
  28. package/Components/JsonConfigComponent/ConfigAlive.js +1 -2
  29. package/Components/JsonConfigComponent/ConfigAlive.js.map +1 -1
  30. package/Components/JsonConfigComponent/ConfigAutocomplete.js +1 -2
  31. package/Components/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
  32. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js +1 -2
  33. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
  34. package/Components/JsonConfigComponent/ConfigCRON.js +1 -2
  35. package/Components/JsonConfigComponent/ConfigCRON.js.map +1 -1
  36. package/Components/JsonConfigComponent/ConfigCertCollection.js +1 -2
  37. package/Components/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
  38. package/Components/JsonConfigComponent/ConfigCertificateSelect.js +1 -2
  39. package/Components/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
  40. package/Components/JsonConfigComponent/ConfigCertificates.js +1 -2
  41. package/Components/JsonConfigComponent/ConfigCertificates.js.map +1 -1
  42. package/Components/JsonConfigComponent/ConfigCheckLicense.js +1 -2
  43. package/Components/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
  44. package/Components/JsonConfigComponent/ConfigCheckbox.js +1 -2
  45. package/Components/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
  46. package/Components/JsonConfigComponent/ConfigChip.js +1 -2
  47. package/Components/JsonConfigComponent/ConfigChip.js.map +1 -1
  48. package/Components/JsonConfigComponent/ConfigColor.js +1 -2
  49. package/Components/JsonConfigComponent/ConfigColor.js.map +1 -1
  50. package/Components/JsonConfigComponent/ConfigCoordinates.js +1 -2
  51. package/Components/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
  52. package/Components/JsonConfigComponent/ConfigCustom.js +3 -4
  53. package/Components/JsonConfigComponent/ConfigCustom.js.map +1 -1
  54. package/Components/JsonConfigComponent/ConfigDatePicker.js +1 -2
  55. package/Components/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
  56. package/Components/JsonConfigComponent/ConfigFile.js +1 -2
  57. package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
  58. package/Components/JsonConfigComponent/ConfigFileSelector.js +1 -2
  59. package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
  60. package/Components/JsonConfigComponent/ConfigFunc.js +1 -2
  61. package/Components/JsonConfigComponent/ConfigFunc.js.map +1 -1
  62. package/Components/JsonConfigComponent/ConfigGeneric.js +3 -4
  63. package/Components/JsonConfigComponent/ConfigGeneric.js.map +1 -1
  64. package/Components/JsonConfigComponent/ConfigIP.js +1 -2
  65. package/Components/JsonConfigComponent/ConfigIP.js.map +1 -1
  66. package/Components/JsonConfigComponent/ConfigImageSendTo.js +1 -2
  67. package/Components/JsonConfigComponent/ConfigImageSendTo.js.map +1 -1
  68. package/Components/JsonConfigComponent/ConfigImageUpload.js +1 -2
  69. package/Components/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
  70. package/Components/JsonConfigComponent/ConfigInstanceSelect.js +1 -2
  71. package/Components/JsonConfigComponent/ConfigInstanceSelect.js.map +1 -1
  72. package/Components/JsonConfigComponent/ConfigJsonEditor.js +1 -2
  73. package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
  74. package/Components/JsonConfigComponent/ConfigLanguage.js +1 -2
  75. package/Components/JsonConfigComponent/ConfigLanguage.js.map +1 -1
  76. package/Components/JsonConfigComponent/ConfigLicense.js +1 -2
  77. package/Components/JsonConfigComponent/ConfigLicense.js.map +1 -1
  78. package/Components/JsonConfigComponent/ConfigNumber.js +1 -2
  79. package/Components/JsonConfigComponent/ConfigNumber.js.map +1 -1
  80. package/Components/JsonConfigComponent/ConfigObjectId.js +1 -2
  81. package/Components/JsonConfigComponent/ConfigObjectId.js.map +1 -1
  82. package/Components/JsonConfigComponent/ConfigPanel.js +3 -4
  83. package/Components/JsonConfigComponent/ConfigPanel.js.map +1 -1
  84. package/Components/JsonConfigComponent/ConfigPassword.js +1 -2
  85. package/Components/JsonConfigComponent/ConfigPassword.js.map +1 -1
  86. package/Components/JsonConfigComponent/ConfigPattern.js +1 -2
  87. package/Components/JsonConfigComponent/ConfigPattern.js.map +1 -1
  88. package/Components/JsonConfigComponent/ConfigPort.js +1 -2
  89. package/Components/JsonConfigComponent/ConfigPort.js.map +1 -1
  90. package/Components/JsonConfigComponent/ConfigRoom.js +1 -2
  91. package/Components/JsonConfigComponent/ConfigRoom.js.map +1 -1
  92. package/Components/JsonConfigComponent/ConfigSelect.js +1 -2
  93. package/Components/JsonConfigComponent/ConfigSelect.js.map +1 -1
  94. package/Components/JsonConfigComponent/ConfigSelectSendTo.js +1 -2
  95. package/Components/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
  96. package/Components/JsonConfigComponent/ConfigSendto.js +3 -4
  97. package/Components/JsonConfigComponent/ConfigSendto.js.map +1 -1
  98. package/Components/JsonConfigComponent/ConfigSetState.js +1 -2
  99. package/Components/JsonConfigComponent/ConfigSetState.js.map +1 -1
  100. package/Components/JsonConfigComponent/ConfigSlider.js +1 -2
  101. package/Components/JsonConfigComponent/ConfigSlider.js.map +1 -1
  102. package/Components/JsonConfigComponent/ConfigStaticDivider.js +1 -2
  103. package/Components/JsonConfigComponent/ConfigStaticDivider.js.map +1 -1
  104. package/Components/JsonConfigComponent/ConfigStaticHeader.js +1 -2
  105. package/Components/JsonConfigComponent/ConfigStaticHeader.js.map +1 -1
  106. package/Components/JsonConfigComponent/ConfigStaticImage.js +1 -2
  107. package/Components/JsonConfigComponent/ConfigStaticImage.js.map +1 -1
  108. package/Components/JsonConfigComponent/ConfigStaticText.js +1 -2
  109. package/Components/JsonConfigComponent/ConfigStaticText.js.map +1 -1
  110. package/Components/JsonConfigComponent/ConfigTable.js +1 -2
  111. package/Components/JsonConfigComponent/ConfigTable.js.map +1 -1
  112. package/Components/JsonConfigComponent/ConfigTabs.js +1 -2
  113. package/Components/JsonConfigComponent/ConfigTabs.js.map +1 -1
  114. package/Components/JsonConfigComponent/ConfigText.js +1 -2
  115. package/Components/JsonConfigComponent/ConfigText.js.map +1 -1
  116. package/Components/JsonConfigComponent/ConfigTextSendTo.js +1 -2
  117. package/Components/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
  118. package/Components/JsonConfigComponent/ConfigTimePicker.js +1 -2
  119. package/Components/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
  120. package/Components/JsonConfigComponent/ConfigTopic.js +1 -2
  121. package/Components/JsonConfigComponent/ConfigTopic.js.map +1 -1
  122. package/Components/JsonConfigComponent/ConfigUUID.js +1 -2
  123. package/Components/JsonConfigComponent/ConfigUUID.js.map +1 -1
  124. package/Components/JsonConfigComponent/ConfigUser.js +1 -2
  125. package/Components/JsonConfigComponent/ConfigUser.js.map +1 -1
  126. package/Components/JsonConfigComponent/index.js +8 -9
  127. package/Components/JsonConfigComponent/index.js.map +1 -1
  128. package/Components/JsonConfigComponent/wrapper/Components/ColorPicker.js +1 -2
  129. package/Components/JsonConfigComponent/wrapper/Components/ColorPicker.js.map +1 -1
  130. package/Components/JsonConfigComponent/wrapper/Components/Icon.js +1 -2
  131. package/Components/JsonConfigComponent/wrapper/Components/Icon.js.map +1 -1
  132. package/Components/JsonConfigComponent/wrapper/Components/TextWithIcon.js +1 -2
  133. package/Components/JsonConfigComponent/wrapper/Components/TextWithIcon.js.map +1 -1
  134. package/Components/JsonConfigComponent/wrapper/Components/UploadImage.js +1 -2
  135. package/Components/JsonConfigComponent/wrapper/Components/UploadImage.js.map +1 -1
  136. package/Components/JsonConfigComponent/wrapper/Components/Utils.js +1 -2
  137. package/Components/JsonConfigComponent/wrapper/Components/Utils.js.map +1 -1
  138. package/Components/JsonConfigComponent/wrapper/Dialogs/Confirm.js +1 -2
  139. package/Components/JsonConfigComponent/wrapper/Dialogs/Confirm.js.map +1 -1
  140. package/Components/JsonConfigComponent/wrapper/Dialogs/Cron.js +1 -2
  141. package/Components/JsonConfigComponent/wrapper/Dialogs/Cron.js.map +1 -1
  142. package/Components/JsonConfigComponent/wrapper/Dialogs/Error.js +1 -2
  143. package/Components/JsonConfigComponent/wrapper/Dialogs/Error.js.map +1 -1
  144. package/Components/JsonConfigComponent/wrapper/Dialogs/Message.js +1 -2
  145. package/Components/JsonConfigComponent/wrapper/Dialogs/Message.js.map +1 -1
  146. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectFile.js +1 -2
  147. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectFile.js.map +1 -1
  148. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectID.js +1 -2
  149. package/Components/JsonConfigComponent/wrapper/Dialogs/SelectID.js.map +1 -1
  150. package/Components/JsonConfigComponent/wrapper/i18n.js +1 -2
  151. package/Components/JsonConfigComponent/wrapper/i18n.js.map +1 -1
  152. package/Components/JsonConfigComponent/wrapper/icons/IconCopy.js +1 -2
  153. package/Components/JsonConfigComponent/wrapper/icons/IconCopy.js.map +1 -1
  154. package/Components/Loader.js +3 -4
  155. package/Components/Loader.js.map +1 -1
  156. package/Components/Loaders/PT.css +1 -1
  157. package/Components/Loaders/PT.js +1 -2
  158. package/Components/Loaders/PT.js.map +1 -1
  159. package/Components/Loaders/Vendor.css +1 -1
  160. package/Components/Loaders/Vendor.js +2 -3
  161. package/Components/Loaders/Vendor.js.map +1 -1
  162. package/Components/Logo.js +2 -3
  163. package/Components/Logo.js.map +1 -1
  164. package/Components/MDUtils.js +2 -3
  165. package/Components/MDUtils.js.map +1 -1
  166. package/Components/ObjectBrowser.js +4 -5
  167. package/Components/ObjectBrowser.js.map +1 -1
  168. package/Components/Router.js +1 -2
  169. package/Components/Router.js.map +1 -1
  170. package/Components/SaveCloseButtons.js +3 -4
  171. package/Components/SaveCloseButtons.js.map +1 -1
  172. package/Components/Schedule.js +3 -4
  173. package/Components/Schedule.js.map +1 -1
  174. package/Components/SelectWithIcon.js +1 -2
  175. package/Components/SelectWithIcon.js.map +1 -1
  176. package/Components/SimpleCron/cron2text.js +1 -2
  177. package/Components/SimpleCron/cron2text.js.map +1 -1
  178. package/Components/SimpleCron/cronText.js +1 -2
  179. package/Components/SimpleCron/cronText.js.map +1 -1
  180. package/Components/SimpleCron/index.js +1 -2
  181. package/Components/SimpleCron/index.js.map +1 -1
  182. package/Components/SimpleCron/jquery.cron.locale.js +1 -2
  183. package/Components/SimpleCron/jquery.cron.locale.js.map +1 -1
  184. package/Components/TabContainer.js +1 -2
  185. package/Components/TabContainer.js.map +1 -1
  186. package/Components/TabContent.js +1 -2
  187. package/Components/TabContent.js.map +1 -1
  188. package/Components/TabHeader.js +1 -2
  189. package/Components/TabHeader.js.map +1 -1
  190. package/Components/TableResize.js +3 -4
  191. package/Components/TableResize.js.map +1 -1
  192. package/Components/TextWithIcon.js +3 -4
  193. package/Components/TextWithIcon.js.map +1 -1
  194. package/Components/TreeTable.js +3 -4
  195. package/Components/TreeTable.js.map +1 -1
  196. package/Components/UploadImage.js +1 -2
  197. package/Components/UploadImage.js.map +1 -1
  198. package/Components/Utils.js +1 -2
  199. package/Components/Utils.js.map +1 -1
  200. package/Components/loader.css +1 -1
  201. package/Components/withWidth.js +1 -2
  202. package/Components/withWidth.js.map +1 -1
  203. package/Connection.js +1 -2
  204. package/Connection.js.map +1 -1
  205. package/Dialogs/ComplexCron.js +1 -2
  206. package/Dialogs/ComplexCron.js.map +1 -1
  207. package/Dialogs/Confirm.js +2 -3
  208. package/Dialogs/Confirm.js.map +1 -1
  209. package/Dialogs/Cron.js +1 -2
  210. package/Dialogs/Cron.js.map +1 -1
  211. package/Dialogs/Error.js +2 -3
  212. package/Dialogs/Error.js.map +1 -1
  213. package/Dialogs/Message.js +2 -3
  214. package/Dialogs/Message.js.map +1 -1
  215. package/Dialogs/SelectFile.d.ts +2 -0
  216. package/Dialogs/SelectFile.js +19 -19
  217. package/Dialogs/SelectFile.js.map +1 -1
  218. package/Dialogs/SelectID.js +4 -5
  219. package/Dialogs/SelectID.js.map +1 -1
  220. package/Dialogs/SimpleCron.js +1 -2
  221. package/Dialogs/SimpleCron.js.map +1 -1
  222. package/Dialogs/TextInput.js +1 -2
  223. package/Dialogs/TextInput.js.map +1 -1
  224. package/GenericApp.d.ts +4 -1
  225. package/GenericApp.js +11 -6
  226. package/GenericApp.js.map +1 -1
  227. package/LegacyConnection.js +4 -7
  228. package/LegacyConnection.js.map +1 -1
  229. package/Prompt.js +1 -2
  230. package/Prompt.js.map +1 -1
  231. package/README.md +6 -0
  232. package/Theme.js +1 -2
  233. package/Theme.js.map +1 -1
  234. package/i18n/de.json +3 -1
  235. package/i18n/en.json +3 -1
  236. package/i18n/es.json +3 -1
  237. package/i18n/fr.json +3 -1
  238. package/i18n/it.json +3 -1
  239. package/i18n/nl.json +3 -1
  240. package/i18n/pl.json +3 -1
  241. package/i18n/pt.json +3 -1
  242. package/i18n/ru.json +3 -1
  243. package/i18n/uk.json +3 -1
  244. package/i18n/zh-cn.json +3 -1
  245. package/i18n.d.ts +1 -1
  246. package/i18n.js +2 -3
  247. package/i18n.js.map +1 -1
  248. package/icons/IconAdapter.js +1 -2
  249. package/icons/IconAdapter.js.map +1 -1
  250. package/icons/IconAlias.js +1 -2
  251. package/icons/IconAlias.js.map +1 -1
  252. package/icons/IconChannel.js +1 -2
  253. package/icons/IconChannel.js.map +1 -1
  254. package/icons/IconClearFilter.js +1 -2
  255. package/icons/IconClearFilter.js.map +1 -1
  256. package/icons/IconClosed.js +1 -2
  257. package/icons/IconClosed.js.map +1 -1
  258. package/icons/IconCopy.js +1 -2
  259. package/icons/IconCopy.js.map +1 -1
  260. package/icons/IconDevice.js +1 -2
  261. package/icons/IconDevice.js.map +1 -1
  262. package/icons/IconDocument.js +1 -2
  263. package/icons/IconDocument.js.map +1 -1
  264. package/icons/IconDocumentReadOnly.js +1 -2
  265. package/icons/IconDocumentReadOnly.js.map +1 -1
  266. package/icons/IconExpert.js +1 -2
  267. package/icons/IconExpert.js.map +1 -1
  268. package/icons/IconFx.js +1 -2
  269. package/icons/IconFx.js.map +1 -1
  270. package/icons/IconInstance.js +1 -2
  271. package/icons/IconInstance.js.map +1 -1
  272. package/icons/IconLogout.js +1 -2
  273. package/icons/IconLogout.js.map +1 -1
  274. package/icons/IconNoIcon.js +1 -2
  275. package/icons/IconNoIcon.js.map +1 -1
  276. package/icons/IconOpen.js +1 -2
  277. package/icons/IconOpen.js.map +1 -1
  278. package/icons/IconState.js +1 -2
  279. package/icons/IconState.js.map +1 -1
  280. package/index.css +1 -1
  281. package/index.d.ts +2 -0
  282. package/index.js +3 -0
  283. package/package.json +10 -10
  284. package/types.d.ts +5 -1
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
14
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
15
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
16
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -323,6 +325,9 @@ var styles = function styles(theme) {
323
325
  menuButtonExpertActive: {
324
326
  color: '#c00000'
325
327
  },
328
+ menuButtonRestrictActive: {
329
+ color: '#c05000'
330
+ },
326
331
  pathDiv: {
327
332
  display: 'flex',
328
333
  width: "calc(100% - ".concat(theme.spacing(2), ")"),
@@ -479,18 +484,29 @@ var FileBrowser = /*#__PURE__*/function (_Component) {
479
484
  viewType = TABLE;
480
485
  }
481
486
  var selected = _this.props.selected || (window._localStorage || window.localStorage).getItem('files.selected') || USER_DATA;
482
-
483
- // TODO: Now we do not support multiple selection
484
- if (Array.isArray(selected)) {
485
- selected = selected[0];
486
- }
487
487
  var currentDir = '';
488
- if (isFile(selected)) {
489
- currentDir = getParentDir(selected);
488
+ var _backgroundImage = (window._localStorage || window.localStorage).getItem('files.backgroundImage') || null;
489
+ if (props.restrictToFolder) {
490
+ selected = props.restrictToFolder;
491
+ currentDir = props.restrictToFolder;
492
+ var _parts = props.restrictToFolder.split('/');
493
+ expanded = [];
494
+ var path = '';
495
+ for (var i = 0; i < _parts.length; i++) {
496
+ path += (path ? '/' : '') + _parts[i];
497
+ expanded.push(path);
498
+ }
490
499
  } else {
491
- currentDir = selected;
500
+ // TODO: Now we do not support multiple selection
501
+ if (Array.isArray(selected)) {
502
+ selected = selected[0];
503
+ }
504
+ if (isFile(selected)) {
505
+ currentDir = getParentDir(selected);
506
+ } else {
507
+ currentDir = selected;
508
+ }
492
509
  }
493
- var _backgroundImage = (window._localStorage || window.localStorage).getItem('files.backgroundImage') || null;
494
510
  _this.state = {
495
511
  viewType: viewType,
496
512
  folders: {},
@@ -514,7 +530,8 @@ var FileBrowser = /*#__PURE__*/function (_Component) {
514
530
  // allFoldersLoaded: false,
515
531
  fileErrors: [],
516
532
  filterByType: props.filterByType || window.localStorage.getItem('files.filterByType') || '',
517
- showTypesMenu: null
533
+ showTypesMenu: null,
534
+ restrictToFolder: props.restrictToFolder || ''
518
535
  };
519
536
  _this.imagePrefix = _this.props.imagePrefix || './files/';
520
537
  _this.levelPadding = _this.props.levelPadding || 20;
@@ -529,40 +546,75 @@ var FileBrowser = /*#__PURE__*/function (_Component) {
529
546
  }
530
547
  (0, _createClass2["default"])(FileBrowser, [{
531
548
  key: "loadFolders",
532
- value: function loadFolders() {
533
- var _this2 = this;
534
- this.initialReadFinished = false;
535
- return this.browseFolder('/').then(function (folders) {
536
- return _this2.state.viewType === TABLE ? _this2.browseFolders((0, _toConsumableArray2["default"])(_this2.state.expanded), folders) : _this2.state.currentDir && _this2.state.currentDir !== '/' && (!_this2.limitToObjectID || _this2.state.currentDir.startsWith(_this2.limitToObjectID)) ? _this2.browseFolder(_this2.state.currentDir, folders) : Promise.resolve(folders);
537
- }).then(function (folders) {
538
- return _this2.setState({
539
- folders: folders
540
- }, function () {
541
- if (_this2.state.viewType === TABLE && !_this2.findItem(_this2.state.selected)) {
542
- var parts = _this2.state.selected.split('/');
543
- while (parts.length && !_this2.findItem(parts.join('/'))) {
544
- parts.pop();
545
- }
546
- var selected;
547
- if (parts.length) {
548
- selected = parts.join('/');
549
- } else {
550
- selected = USER_DATA;
551
- }
552
- _this2.setState({
553
- selected: selected,
554
- path: selected,
555
- pathFocus: false
556
- }, function () {
557
- return _this2.scrollToSelected();
558
- });
559
- } else {
560
- _this2.scrollToSelected();
549
+ value: function () {
550
+ var _loadFolders = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
551
+ var _this2 = this;
552
+ var folders;
553
+ return _regenerator["default"].wrap(function _callee$(_context) {
554
+ while (1) switch (_context.prev = _context.next) {
555
+ case 0:
556
+ this.initialReadFinished = false;
557
+ _context.next = 3;
558
+ return this.browseFolder('/');
559
+ case 3:
560
+ folders = _context.sent;
561
+ if (!(this.state.viewType === TABLE)) {
562
+ _context.next = 10;
563
+ break;
564
+ }
565
+ _context.next = 7;
566
+ return this.browseFolders((0, _toConsumableArray2["default"])(this.state.expanded), folders);
567
+ case 7:
568
+ folders = _context.sent;
569
+ _context.next = 14;
570
+ break;
571
+ case 10:
572
+ if (!(this.state.currentDir && this.state.currentDir !== '/' && (!this.limitToObjectID || this.state.currentDir.startsWith(this.limitToObjectID)))) {
573
+ _context.next = 14;
574
+ break;
575
+ }
576
+ _context.next = 13;
577
+ return this.browseFolder(this.state.currentDir, folders);
578
+ case 13:
579
+ folders = _context.sent;
580
+ case 14:
581
+ this.setState({
582
+ folders: folders
583
+ }, function () {
584
+ if (_this2.state.viewType === TABLE && !_this2.findItem(_this2.state.selected)) {
585
+ var parts = _this2.state.selected.split('/');
586
+ while (parts.length && !_this2.findItem(parts.join('/'))) {
587
+ parts.pop();
588
+ }
589
+ var selected;
590
+ if (parts.length) {
591
+ selected = parts.join('/');
592
+ } else {
593
+ selected = USER_DATA;
594
+ }
595
+ _this2.setState({
596
+ selected: selected,
597
+ path: selected,
598
+ pathFocus: false
599
+ }, function () {
600
+ return _this2.scrollToSelected();
601
+ });
602
+ } else {
603
+ _this2.scrollToSelected();
604
+ }
605
+ _this2.initialReadFinished = true;
606
+ });
607
+ case 15:
608
+ case "end":
609
+ return _context.stop();
561
610
  }
562
- _this2.initialReadFinished = true;
563
- });
564
- });
565
- }
611
+ }, _callee, this);
612
+ }));
613
+ function loadFolders() {
614
+ return _loadFolders.apply(this, arguments);
615
+ }
616
+ return loadFolders;
617
+ }()
566
618
  }, {
567
619
  key: "scrollToSelected",
568
620
  value: function scrollToSelected() {
@@ -757,9 +809,13 @@ var FileBrowser = /*#__PURE__*/function (_Component) {
757
809
  return this.props.socket.readMetaItems().then(function (objs) {
758
810
  var _folders = [];
759
811
  var userData = null;
760
-
761
- // load only adapter.admin and not other meta files like hm-rpc.0.devices.blablabla
762
- if (!_this7.state.expertMode) {
812
+ if (_this7.state.restrictToFolder) {
813
+ var _adapter = _this7.state.restrictToFolder.split('/')[0];
814
+ objs = objs.filter(function (obj) {
815
+ return obj._id === _adapter;
816
+ });
817
+ } else if (!_this7.state.expertMode) {
818
+ // load only adapter.admin and not other meta files like hm-rpc.0.devices.blablabla
763
819
  objs = objs.filter(function (obj) {
764
820
  return !obj._id.endsWith('.admin');
765
821
  });
@@ -834,7 +890,13 @@ var FileBrowser = /*#__PURE__*/function (_Component) {
834
890
  acl: file.acl,
835
891
  level: level
836
892
  };
837
- if (_this7.limitToPath) {
893
+ if (_this7.state.restrictToFolder) {
894
+ if (item.folder && (item.id.startsWith("".concat(_this7.state.restrictToFolder, "/")) || item.id === _this7.state.restrictToFolder || _this7.state.restrictToFolder.startsWith("".concat(item.id, "/")))) {
895
+ _folders.push(item);
896
+ } else if (item.id.startsWith("".concat(_this7.state.restrictToFolder, "/"))) {
897
+ _folders.push(item);
898
+ }
899
+ } else if (_this7.limitToPath) {
838
900
  if (item.folder && (item.id.startsWith("".concat(_this7.limitToPath, "/")) || item.id === _this7.limitToPath || _this7.limitToPath.startsWith("".concat(item.id, "/")))) {
839
901
  _folders.push(item);
840
902
  } else if (item.id.startsWith("".concat(_this7.limitToPath, "/"))) {
@@ -1272,7 +1334,21 @@ var FileBrowser = /*#__PURE__*/function (_Component) {
1272
1334
  return /*#__PURE__*/_react["default"].createElement(_material.Toolbar, {
1273
1335
  key: "toolbar",
1274
1336
  variant: "dense"
1275
- }, this.props.showExpertButton ? /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
1337
+ }, this.props.allowNonRestricted && this.props.restrictToFolder ? /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
1338
+ edge: "start",
1339
+ title: this.state.restrictToFolder ? this.props.t('ra_Show all folders') : this.props.t('ra_Restrict to folder'),
1340
+ className: _Utils["default"].clsx(this.props.classes.menuButton, this.state.restrictToFolder && this.props.classes.menuButtonRestrictActive),
1341
+ "aria-label": "restricted to folder",
1342
+ onClick: function onClick() {
1343
+ return _this16.setState({
1344
+ restrictToFolder: _this16.state.restrictToFolder ? '' : _this16.props.restrictToFolder,
1345
+ loadAllFolders: true
1346
+ });
1347
+ },
1348
+ size: "small"
1349
+ }, /*#__PURE__*/_react["default"].createElement(_iconsMaterial.FolderSpecial, {
1350
+ fontSize: "small"
1351
+ })) : null, this.props.showExpertButton ? /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
1276
1352
  edge: "start",
1277
1353
  title: this.props.t('ra_Toggle expert mode'),
1278
1354
  className: _Utils["default"].clsx(this.props.classes.menuButton, this.state.expertMode && this.props.classes.menuButtonExpertActive),
@@ -1688,9 +1764,9 @@ var FileBrowser = /*#__PURE__*/function (_Component) {
1688
1764
  })) : Promise.resolve()).then(function () {
1689
1765
  // If it is folder of second level
1690
1766
  if (item.level >= 1) {
1691
- var _parts = id.split('/');
1692
- var _adapter = _parts.shift();
1693
- _this20.props.socket.deleteFolder(_adapter, _parts.join('/')).then(function () {
1767
+ var _parts2 = id.split('/');
1768
+ var _adapter2 = _parts2.shift();
1769
+ _this20.props.socket.deleteFolder(_adapter2, _parts2.join('/')).then(function () {
1694
1770
  // remove this folder
1695
1771
  var folders = JSON.parse(JSON.stringify(_this20.state.folders));
1696
1772
  delete folders[item.id];
@@ -2060,6 +2136,11 @@ FileBrowser.propTypes = {
2060
2136
  showExpertButton: _propTypes["default"].bool,
2061
2137
  viewType: _propTypes["default"].string,
2062
2138
  showViewTypeButton: _propTypes["default"].bool,
2139
+ restrictToFolder: _propTypes["default"].string,
2140
+ // If defined, allow selecting only files from this folder
2141
+ allowNonRestricted: _propTypes["default"].bool,
2142
+ // If restrictToFolder defined, allow selecting files outside of this folder
2143
+
2063
2144
  selected: _propTypes["default"].string,
2064
2145
  tileView: _propTypes["default"].bool,
2065
2146
  filterFiles: _propTypes["default"].array,
@@ -2074,6 +2155,5 @@ FileBrowser.propTypes = {
2074
2155
 
2075
2156
  /** @type {typeof FileBrowser} */
2076
2157
  var _export = (0, _withWidth["default"])()((0, _styles.withStyles)(styles)(FileBrowser));
2077
- var _default = _export;
2078
- exports["default"] = _default;
2158
+ var _default = exports["default"] = _export;
2079
2159
  //# sourceMappingURL=FileBrowser.js.map