@bigbinary/neeto-folders-frontend 2.0.26 → 2.0.27

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.
package/dist/cjs/hooks.js CHANGED
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var useFolderActions = require('../useFolderActions-hz2Q6yci.js');
3
+ var useFolderActions = require('../useFolderActions-BqMYtjKs.js');
4
4
  require('@babel/runtime/helpers/defineProperty');
5
5
  require('i18next');
6
6
  require('@bigbinary/neeto-cist');
7
- require('../internal-D5q2PCbM.js');
7
+ require('../internal-DKHdgJas.js');
8
+ require('@bigbinary/neetoui/Toastr');
8
9
  require('ramda');
9
10
  require('react-router-dom');
10
11
  require('zustand/shallow');
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"hooks.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
package/dist/cjs/utils.js CHANGED
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  require('ramda');
4
- var utils = require('../index-DshpXNOY.js');
4
+ var utils = require('../index-DxzvHr2u.js');
5
5
  require('@babel/runtime/helpers/defineProperty');
6
6
  require('@bigbinary/neeto-cist');
7
- require('../internal-D5q2PCbM.js');
7
+ require('../internal-DKHdgJas.js');
8
+ require('@bigbinary/neetoui/Toastr');
8
9
  require('react-router-dom');
9
10
 
10
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -7,10 +7,10 @@ import { buildUrl, showThumbsUpToastr } from '@bigbinary/neeto-commons-frontend/
7
7
  import Alert from '@bigbinary/neetoui/Alert';
8
8
  import { useTranslation as useTranslation$1, Trans } from 'react-i18next';
9
9
  import { useHistory, Link, NavLink } from 'react-router-dom';
10
- import { c as useFolderStore, d as useDestroyFolder, a as useFolders, e as useFetchFolders, f as useCreateFolder, g as useUpdateFolder, h as useReorderFolders, D as DEFAULT_CONFIG, u as useFolder, b as useFolderActions } from './useFolderActions-C247TYkG.js';
10
+ import { c as useFolderStore, d as useDestroyFolder, a as useFolders, e as useFetchFolders, f as useCreateFolder, g as useUpdateFolder, h as useReorderFolders, D as DEFAULT_CONFIG, u as useFolder, b as useFolderActions } from './useFolderActions-3UUWnCm9.js';
11
11
  import { QUERY_KEYS } from './constants.js';
12
- import { p as pathToFolder, t as treeToMap, m as measureDepth, a as mapToTree, b as mapToSortedTree } from './index-ohGlXbZu.js';
13
- import { a as isActiveFolder, g as getActiveFolderId, i as isArray, m as mapObj } from './internal-33v6k2oX.js';
12
+ import { p as pathToFolder, t as treeToMap, m as measureDepth, a as mapToTree, b as mapToSortedTree } from './index-CfSLBCVx.js';
13
+ import { a as isActiveFolder, g as getActiveFolderId, t as toastApiError, i as isArray, m as mapObj } from './internal-DUPKoXC_.js';
14
14
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
15
15
  import Pane from '@bigbinary/neetoui/Pane';
16
16
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
@@ -424,7 +424,7 @@ var _SelectableNode = function SelectableNode(_ref) {
424
424
  var folder = _ref.folder,
425
425
  item = _ref.item,
426
426
  _ref$depth = _ref.depth,
427
- depth = _ref$depth === void 0 ? 0 : _ref$depth,
427
+ depth = _ref$depth === void 0 ? 1 : _ref$depth,
428
428
  maxDepth = _ref.maxDepth,
429
429
  disabled = _ref.disabled,
430
430
  config = _ref.config,
@@ -479,8 +479,17 @@ var _SelectableNode = function SelectableNode(_ref) {
479
479
 
480
480
  function ownKeys$e(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
481
481
  function _objectSpread$e(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$e(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$e(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
482
+ var createTree = function createTree(folders, isRootEnabled) {
483
+ return isRootEnabled ? [{
484
+ name: "/",
485
+ id: null,
486
+ children: folders
487
+ }] : folders;
488
+ };
482
489
  var PaneBody = function PaneBody(_ref) {
483
- var item = _ref.item,
490
+ var _ref$isRootEnabled = _ref.isRootEnabled,
491
+ isRootEnabled = _ref$isRootEnabled === void 0 ? true : _ref$isRootEnabled,
492
+ item = _ref.item,
484
493
  config = _ref.config,
485
494
  submitButtonProps = _ref.submitButtonProps,
486
495
  cancelButtonProps = _ref.cancelButtonProps,
@@ -514,20 +523,19 @@ var PaneBody = function PaneBody(_ref) {
514
523
  }, shallow),
515
524
  type = _useFolderStore2.type;
516
525
  var tree = useMemo(function () {
517
- return [{
518
- name: "/",
519
- id: null,
520
- children: folders
521
- }];
522
- }, [folders]);
523
- var folderDepth = 0;
526
+ return createTree(folders, isRootEnabled);
527
+ }, [folders, isRootEnabled]);
528
+ var maxDepth = Number.POSITIVE_INFINITY;
524
529
  if (item) {
525
530
  // If item is a folder, measure the current depth from current folder to longest leaf.
526
531
  var foldersMap = treeToMap(folders);
527
532
  var folder = foldersMap[item.id];
528
- if (folder) folderDepth = measureDepth(folder);
533
+ if (folder) {
534
+ var folderDepth = measureDepth(folder) + 1; // +1 for own depth;
535
+ maxDepth = config.maxDepth - folderDepth;
536
+ if (isRootEnabled) maxDepth += 1; // +1 for root folder.
537
+ }
529
538
  }
530
- var maxDepth = config.maxDepth - folderDepth + 1;
531
539
  var onAddFolder = function onAddFolder() {
532
540
  setFolderState({
533
541
  paneState: {
@@ -582,14 +590,14 @@ var PaneBody = function PaneBody(_ref) {
582
590
  children: [/*#__PURE__*/jsxs("div", {
583
591
  className: "flex flex-1 space-x-2",
584
592
  children: [/*#__PURE__*/jsx(Button, _objectSpread$e(_objectSpread$e({
585
- disabled: selection === parent,
586
593
  label: t("common.save"),
587
594
  style: "primary",
588
595
  onClick: function onClick() {
589
596
  return onSubmit(selection);
590
597
  }
591
598
  }, submitButtonProps), {}, {
592
- "data-cy": "save-changes-button"
599
+ "data-cy": "save-changes-button",
600
+ disabled: selection === parent || (submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.disabled)
593
601
  })), /*#__PURE__*/jsx(Button, _objectSpread$e(_objectSpread$e({
594
602
  label: t("common.cancel"),
595
603
  style: "text",
@@ -619,6 +627,7 @@ var MoveFolderPane = function MoveFolderPane(_ref) {
619
627
  }, shallow),
620
628
  item = _useFolderStore.item;
621
629
  var _useUpdateFolder = useUpdateFolder(config),
630
+ isPending = _useUpdateFolder.isPending,
622
631
  updateFolder = _useUpdateFolder.mutate;
623
632
  var onSaveSelection = function onSaveSelection(parentId) {
624
633
  var payload = {
@@ -627,19 +636,27 @@ var MoveFolderPane = function MoveFolderPane(_ref) {
627
636
  };
628
637
  updateFolder({
629
638
  id: item.id,
630
- payload: payload
639
+ payload: payload,
640
+ config: {
641
+ showToastr: false
642
+ }
631
643
  }, {
632
644
  onSuccess: function onSuccess() {
633
645
  var _config$onUpdateSucce;
634
646
  onClose();
635
647
  (_config$onUpdateSucce = config.onUpdateSuccess) === null || _config$onUpdateSucce === void 0 || _config$onUpdateSucce.call(config);
636
- }
648
+ },
649
+ onError: toastApiError
637
650
  });
638
651
  };
639
652
  return /*#__PURE__*/jsx(PaneBody, {
640
653
  config: config,
641
654
  item: item,
642
655
  onClose: onClose,
656
+ submitButtonProps: {
657
+ loading: isPending,
658
+ disabled: isPending
659
+ },
643
660
  onSubmit: onSaveSelection
644
661
  });
645
662
  };