@trops/dash-core 0.1.680 → 0.1.681
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.esm.js +29 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -53153,6 +53153,11 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53153
53153
|
_useState54 = _slicedToArray(_useState53, 2),
|
|
53154
53154
|
error = _useState54[0],
|
|
53155
53155
|
setError = _useState54[1];
|
|
53156
|
+
// "Saved" shows after a successful save until the next edit.
|
|
53157
|
+
var _useState55 = useState(false),
|
|
53158
|
+
_useState56 = _slicedToArray(_useState55, 2),
|
|
53159
|
+
justSaved = _useState56[0],
|
|
53160
|
+
setJustSaved = _useState56[1];
|
|
53156
53161
|
|
|
53157
53162
|
// Unsaved changes: the editable fields now vs. when the form opened (or
|
|
53158
53163
|
// last saved).
|
|
@@ -53175,11 +53180,14 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53175
53180
|
subscriptions: subscriptions,
|
|
53176
53181
|
team: team
|
|
53177
53182
|
});
|
|
53178
|
-
var
|
|
53179
|
-
|
|
53180
|
-
baseline =
|
|
53181
|
-
setBaseline =
|
|
53183
|
+
var _useState57 = useState(snapshot),
|
|
53184
|
+
_useState58 = _slicedToArray(_useState57, 2),
|
|
53185
|
+
baseline = _useState58[0],
|
|
53186
|
+
setBaseline = _useState58[1];
|
|
53182
53187
|
var dirty = snapshot !== baseline;
|
|
53188
|
+
useEffect(function () {
|
|
53189
|
+
if (dirty) setJustSaved(false);
|
|
53190
|
+
}, [dirty]);
|
|
53183
53191
|
useEffect(function () {
|
|
53184
53192
|
if (typeof onDirtyChange === "function") onDirtyChange(dirty);
|
|
53185
53193
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -53372,7 +53380,10 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53372
53380
|
});
|
|
53373
53381
|
});
|
|
53374
53382
|
};
|
|
53375
|
-
|
|
53383
|
+
|
|
53384
|
+
// An existing bot saves only when something changed, so Save visibly does
|
|
53385
|
+
// something; a new bot can always be created once it has a name.
|
|
53386
|
+
var canSave = name.trim() && instructions.trim() && !saving && (isCreating || dirty);
|
|
53376
53387
|
var handleSave = /*#__PURE__*/function () {
|
|
53377
53388
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
53378
53389
|
var cron, schedules, definition, _t2;
|
|
@@ -53380,6 +53391,7 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53380
53391
|
while (1) switch (_context2.prev = _context2.next) {
|
|
53381
53392
|
case 0:
|
|
53382
53393
|
setError(null);
|
|
53394
|
+
setJustSaved(false);
|
|
53383
53395
|
cron = advanced ? advancedCron.trim() : buildCron({
|
|
53384
53396
|
frequency: frequency,
|
|
53385
53397
|
time: time,
|
|
@@ -53416,6 +53428,7 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53416
53428
|
return onSave(definition);
|
|
53417
53429
|
case 2:
|
|
53418
53430
|
setBaseline(snapshot);
|
|
53431
|
+
setJustSaved(true);
|
|
53419
53432
|
_context2.next = 4;
|
|
53420
53433
|
break;
|
|
53421
53434
|
case 3:
|
|
@@ -53811,11 +53824,9 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53811
53824
|
className: "text-xs opacity-50",
|
|
53812
53825
|
children: "The bot runs automatically when one of these events fires."
|
|
53813
53826
|
})]
|
|
53814
|
-
})
|
|
53815
|
-
className: "text-sm text-red-400",
|
|
53816
|
-
children: error
|
|
53817
|
-
}) : null]
|
|
53827
|
+
})]
|
|
53818
53828
|
}), /*#__PURE__*/jsxs("div", {
|
|
53829
|
+
"data-testid": "bot-detail-footer",
|
|
53819
53830
|
className: "flex-shrink-0 flex flex-row justify-between gap-2 px-6 py-4 border-t ".concat(hairline),
|
|
53820
53831
|
children: [/*#__PURE__*/jsx("div", {
|
|
53821
53832
|
children: !isCreating && onDelete ? /*#__PURE__*/jsx(Button, {
|
|
@@ -53824,8 +53835,14 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53824
53835
|
size: "sm"
|
|
53825
53836
|
}) : null
|
|
53826
53837
|
}), /*#__PURE__*/jsxs("div", {
|
|
53827
|
-
className: "flex flex-row gap-2",
|
|
53828
|
-
children: [
|
|
53838
|
+
className: "flex flex-row items-center gap-2",
|
|
53839
|
+
children: [error ? /*#__PURE__*/jsx("span", {
|
|
53840
|
+
className: "text-sm text-red-400",
|
|
53841
|
+
children: error
|
|
53842
|
+
}) : justSaved ? /*#__PURE__*/jsx("span", {
|
|
53843
|
+
className: "text-sm opacity-70",
|
|
53844
|
+
children: "Saved"
|
|
53845
|
+
}) : null, isCreating && onCancel ? /*#__PURE__*/jsx(Button, {
|
|
53829
53846
|
title: "Cancel",
|
|
53830
53847
|
onClick: onCancel,
|
|
53831
53848
|
size: "sm"
|
|
@@ -53835,7 +53852,7 @@ var BotDetail = function BotDetail(_ref) {
|
|
|
53835
53852
|
size: "sm",
|
|
53836
53853
|
disabled: !dirty || saving
|
|
53837
53854
|
}) : null, /*#__PURE__*/jsx(Button, {
|
|
53838
|
-
title: isCreating ? "Create" : "Save",
|
|
53855
|
+
title: saving ? "Saving…" : isCreating ? "Create" : "Save",
|
|
53839
53856
|
onClick: handleSave,
|
|
53840
53857
|
size: "sm",
|
|
53841
53858
|
disabled: !canSave
|