@trops/dash-core 0.1.703 → 0.1.704

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/index.js CHANGED
@@ -57126,6 +57126,8 @@ var BotDetail = function BotDetail(_ref) {
57126
57126
  onDirtyChange = _ref$onDirtyChange === void 0 ? null : _ref$onDirtyChange,
57127
57127
  _ref$onDiscard = _ref.onDiscard,
57128
57128
  onDiscard = _ref$onDiscard === void 0 ? null : _ref$onDiscard,
57129
+ _ref$onDiscardDraft = _ref.onDiscardDraft,
57130
+ onDiscardDraft = _ref$onDiscardDraft === void 0 ? null : _ref$onDiscardDraft,
57129
57131
  _ref$suggestions = _ref.suggestions,
57130
57132
  suggestions = _ref$suggestions === void 0 ? null : _ref$suggestions,
57131
57133
  _ref$gaps = _ref.gaps,
@@ -58049,6 +58051,11 @@ var BotDetail = function BotDetail(_ref) {
58049
58051
  title: "Cancel",
58050
58052
  onClick: onCancel,
58051
58053
  size: "sm"
58054
+ }) : null, isCreating && onDiscardDraft ? /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
58055
+ title: "Discard draft",
58056
+ onClick: onDiscardDraft,
58057
+ size: "sm",
58058
+ disabled: saving
58052
58059
  }) : null, onDiscard && !isCreating ? /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
58053
58060
  title: "Discard changes",
58054
58061
  onClick: onDiscard,
@@ -59656,49 +59663,76 @@ var BotsView = function BotsView(_ref3) {
59656
59663
  return _ref10.apply(this, arguments);
59657
59664
  };
59658
59665
  }();
59659
- var discardDraft = /*#__PURE__*/function () {
59666
+
59667
+ // Discarding a draft (row ×, the draft form's button, its banner) asks
59668
+ // first; the lead can draft it again if asked.
59669
+ var _useState41 = React.useState(null),
59670
+ _useState42 = _slicedToArray(_useState41, 2),
59671
+ discardTarget = _useState42[0],
59672
+ setDiscardTarget = _useState42[1];
59673
+ var discardDraft = function discardDraft() {
59674
+ if (selectedDraft) setDiscardTarget(selectedDraft);
59675
+ };
59676
+ var confirmDiscardDraft = /*#__PURE__*/function () {
59660
59677
  var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
59678
+ var d;
59661
59679
  return _regeneratorRuntime.wrap(function (_context7) {
59662
59680
  while (1) switch (_context7.prev = _context7.next) {
59663
59681
  case 0:
59664
- if (!(!selectedDraft || !team || !team.dismissDraft)) {
59682
+ d = discardTarget;
59683
+ setDiscardTarget(null);
59684
+ if (!(!d || !team || !team.dismissDraft)) {
59665
59685
  _context7.next = 1;
59666
59686
  break;
59667
59687
  }
59668
59688
  return _context7.abrupt("return");
59669
59689
  case 1:
59670
59690
  _context7.next = 2;
59671
- return team.dismissDraft(selectedDraft.id);
59691
+ return team.dismissDraft(d.id);
59672
59692
  case 2:
59673
- setDirty(false);
59674
- setSelectedId(lead && lead.id || members[0] && members[0].id || null);
59675
- setTab("conversation");
59693
+ if (selectedId === DRAFT_PREFIX + d.id) {
59694
+ setDirty(false);
59695
+ setSelectedId(lead && lead.id || members[0] && members[0].id || null);
59696
+ setTab("conversation");
59697
+ setDetailOpen(false);
59698
+ }
59676
59699
  case 3:
59677
59700
  case "end":
59678
59701
  return _context7.stop();
59679
59702
  }
59680
59703
  }, _callee7);
59681
59704
  }));
59682
- return function discardDraft() {
59705
+ return function confirmDiscardDraft() {
59683
59706
  return _ref11.apply(this, arguments);
59684
59707
  };
59685
59708
  }();
59686
59709
  var draftRow = function draftRow(d) {
59687
59710
  var id = DRAFT_PREFIX + d.id;
59688
59711
  var active = id === selectedId;
59689
- return /*#__PURE__*/jsxRuntime.jsxs("button", {
59690
- type: "button",
59691
- onClick: function onClick() {
59692
- return select(id);
59693
- },
59694
- "aria-current": active ? "true" : undefined,
59695
- className: "w-full text-left rounded-lg px-3 py-2 flex flex-col border ".concat(active ? "".concat(selectedBg, " ").concat(selectedBorder) : "border-transparent"),
59696
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
59697
- className: "text-sm font-medium truncate",
59698
- children: d.definition && d.definition.name
59699
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
59700
- className: "text-xs ".concat(muted),
59701
- children: "Drafted by the lead \xB7 not created yet"
59712
+ var name = d.definition && d.definition.name || "draft";
59713
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
59714
+ className: "w-full rounded-lg flex flex-row items-center gap-1 border ".concat(active ? "".concat(selectedBg, " ").concat(selectedBorder) : "border-transparent"),
59715
+ children: [/*#__PURE__*/jsxRuntime.jsxs("button", {
59716
+ type: "button",
59717
+ onClick: function onClick() {
59718
+ return select(id);
59719
+ },
59720
+ "aria-current": active ? "true" : undefined,
59721
+ className: "flex-1 min-w-0 text-left px-3 py-2 flex flex-col",
59722
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
59723
+ className: "text-sm font-medium truncate",
59724
+ children: name
59725
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
59726
+ className: "text-xs ".concat(muted),
59727
+ children: "Drafted by the lead \xB7 not created yet"
59728
+ })]
59729
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.ButtonIcon, {
59730
+ icon: "xmark",
59731
+ size: "xs",
59732
+ ariaLabel: "Discard draft ".concat(name),
59733
+ onClick: function onClick() {
59734
+ return setDiscardTarget(d);
59735
+ }
59702
59736
  })]
59703
59737
  }, id);
59704
59738
  };
@@ -60614,6 +60648,7 @@ var BotsView = function BotsView(_ref3) {
60614
60648
  onSave: saveBot,
60615
60649
  canShowOnDashboard: !!workspace,
60616
60650
  onDirtyChange: setDirty,
60651
+ onDiscardDraft: selectedDraft ? discardDraft : null,
60617
60652
  onDiscard: function onDiscard() {
60618
60653
  setDirty(false);
60619
60654
  setFormKey(function (k) {
@@ -60642,6 +60677,20 @@ var BotsView = function BotsView(_ref3) {
60642
60677
  onCancel: function onCancel() {
60643
60678
  return setPendingNav(null);
60644
60679
  }
60680
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.ConfirmationModal, {
60681
+ isOpen: !!discardTarget,
60682
+ setIsOpen: function setIsOpen(open) {
60683
+ return !open && setDiscardTarget(null);
60684
+ },
60685
+ title: "Discard this draft?",
60686
+ message: "\"".concat(discardTarget && discardTarget.definition && discardTarget.definition.name || "This draft", "\" won't be created. Your team lead can draft it again if you ask."),
60687
+ confirmLabel: "Discard",
60688
+ cancelLabel: "Keep draft",
60689
+ variant: "danger",
60690
+ onConfirm: confirmDiscardDraft,
60691
+ onCancel: function onCancel() {
60692
+ return setDiscardTarget(null);
60693
+ }
60645
60694
  }), /*#__PURE__*/jsxRuntime.jsx(DashReact.ConfirmationModal, {
60646
60695
  isOpen: confirmDelete,
60647
60696
  setIsOpen: setConfirmDelete,