@copart/ops-tool-kit 1.12.4-alpha.2 → 1.12.5-alpha.0
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/ops-tool-kit.js +101 -43
- package/dist/ops-tool-kit.js.map +1 -1
- package/package.json +1 -1
package/dist/ops-tool-kit.js
CHANGED
|
@@ -47,7 +47,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
47
47
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
48
48
|
|
|
49
49
|
const name$r = "@copart/ops-tool-kit";
|
|
50
|
-
const version$8 = "1.12.
|
|
50
|
+
const version$8 = "1.12.5-alpha.0";
|
|
51
51
|
const main$1 = "dist/ops-tool-kit.js";
|
|
52
52
|
const style = "dist/ops-tool-kit.css";
|
|
53
53
|
const files = [
|
|
@@ -57669,6 +57669,8 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
57669
57669
|
};
|
|
57670
57670
|
}, []);
|
|
57671
57671
|
var chatBodyRef = React.useRef(null);
|
|
57672
|
+
var previousConversationLengthRef = React.useRef(conversations.length);
|
|
57673
|
+
var previousShowChatWindowRef = React.useRef(showChatWindow);
|
|
57672
57674
|
var scroll = function scroll() {
|
|
57673
57675
|
chatBodyRef.current && chatBodyRef.current.scrollTo({
|
|
57674
57676
|
top: chatBodyRef.current.scrollHeight,
|
|
@@ -57829,10 +57831,19 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
57829
57831
|
}
|
|
57830
57832
|
};
|
|
57831
57833
|
React.useEffect(function () {
|
|
57832
|
-
|
|
57834
|
+
var conversationLengthChanged = previousConversationLengthRef.current !== conversations.length;
|
|
57835
|
+
var chatWindowJustOpened = !previousShowChatWindowRef.current && showChatWindow && conversations.length;
|
|
57836
|
+
if (showChatWindow && conversations.length && (conversationLengthChanged || chatWindowJustOpened)) {
|
|
57833
57837
|
scroll();
|
|
57834
57838
|
}
|
|
57839
|
+
previousConversationLengthRef.current = conversations.length;
|
|
57840
|
+
previousShowChatWindowRef.current = showChatWindow;
|
|
57835
57841
|
}, [conversations, showChatWindow]);
|
|
57842
|
+
React.useEffect(function () {
|
|
57843
|
+
if (messageError) {
|
|
57844
|
+
scroll();
|
|
57845
|
+
}
|
|
57846
|
+
}, [messageError]);
|
|
57836
57847
|
// useEffect(
|
|
57837
57848
|
// () => {
|
|
57838
57849
|
// if (!collection || typeof collection !== 'string') {
|
|
@@ -57949,36 +57960,55 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
57949
57960
|
var updateFeedback = /*#__PURE__*/function () {
|
|
57950
57961
|
var _ref4 = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee3(feedback, Currentconversation, conversations) {
|
|
57951
57962
|
var _storage$getLocalItem3, _storage$getLocalItem4;
|
|
57952
|
-
var payload, endpoint, newConversations;
|
|
57963
|
+
var payload, feedbackEndpoint, endpoint, newConversations, _t3;
|
|
57953
57964
|
return _regenerator().w(function (_context3) {
|
|
57954
|
-
while (1) switch (_context3.n) {
|
|
57965
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
57955
57966
|
case 0:
|
|
57967
|
+
setMessageError(false);
|
|
57956
57968
|
payload = {
|
|
57957
57969
|
feedback: feedback
|
|
57958
57970
|
};
|
|
57971
|
+
feedbackEndpoint = (_storage$getLocalItem3 = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem3 === void 0 ? void 0 : (_storage$getLocalItem4 = _storage$getLocalItem3.endpoints) === null || _storage$getLocalItem4 === void 0 ? void 0 : _storage$getLocalItem4.mihelpChatFeedback;
|
|
57972
|
+
if (feedbackEndpoint) {
|
|
57973
|
+
_context3.n = 1;
|
|
57974
|
+
break;
|
|
57975
|
+
}
|
|
57976
|
+
console.log('MiHelpAgent: feedback endpoint missing from config');
|
|
57977
|
+
setMessageError(true);
|
|
57978
|
+
return _context3.a(2);
|
|
57979
|
+
case 1:
|
|
57980
|
+
endpoint = "".concat(feedbackEndpoint, "/").concat(Currentconversation === null || Currentconversation === void 0 ? void 0 : Currentconversation.feedbackId);
|
|
57959
57981
|
setIsFeedbackLoading(true);
|
|
57960
|
-
|
|
57961
|
-
_context3.n =
|
|
57982
|
+
_context3.p = 2;
|
|
57983
|
+
_context3.n = 3;
|
|
57962
57984
|
return fetcher.put(endpoint, payload, {
|
|
57963
57985
|
headers: {
|
|
57964
57986
|
'Content-Type': 'application/json'
|
|
57965
57987
|
}
|
|
57966
57988
|
});
|
|
57967
|
-
case
|
|
57968
|
-
|
|
57969
|
-
|
|
57970
|
-
|
|
57971
|
-
|
|
57972
|
-
}
|
|
57973
|
-
return conversation;
|
|
57989
|
+
case 3:
|
|
57990
|
+
newConversations = conversations.map(function (conversation) {
|
|
57991
|
+
return (conversation === null || conversation === void 0 ? void 0 : conversation.id) === (Currentconversation === null || Currentconversation === void 0 ? void 0 : Currentconversation.id) ? _objectSpread2(_objectSpread2({}, conversation), {}, {
|
|
57992
|
+
feedback: feedback
|
|
57993
|
+
}) : conversation;
|
|
57974
57994
|
});
|
|
57975
57995
|
setConversations(newConversations);
|
|
57976
|
-
setIsFeedbackLoading(false);
|
|
57977
57996
|
storage$1.setLocalItem('mihelpAgentConversations', newConversations);
|
|
57978
|
-
|
|
57997
|
+
_context3.n = 5;
|
|
57998
|
+
break;
|
|
57999
|
+
case 4:
|
|
58000
|
+
_context3.p = 4;
|
|
58001
|
+
_t3 = _context3.v;
|
|
58002
|
+
console.log('MiHelpAgent: failed to update feedback', _t3);
|
|
58003
|
+
setMessageError(true);
|
|
58004
|
+
case 5:
|
|
58005
|
+
_context3.p = 5;
|
|
58006
|
+
setIsFeedbackLoading(false);
|
|
58007
|
+
return _context3.f(5);
|
|
58008
|
+
case 6:
|
|
57979
58009
|
return _context3.a(2);
|
|
57980
58010
|
}
|
|
57981
|
-
}, _callee3);
|
|
58011
|
+
}, _callee3, null, [[2, 4, 5, 6]]);
|
|
57982
58012
|
}));
|
|
57983
58013
|
return function updateFeedback(_x2, _x3, _x4) {
|
|
57984
58014
|
return _ref4.apply(this, arguments);
|
|
@@ -57987,9 +58017,9 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
57987
58017
|
var handleFeedback = /*#__PURE__*/function () {
|
|
57988
58018
|
var _ref5 = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee4(feedback, Currentconversation, conversations) {
|
|
57989
58019
|
var _storage$getLocalItem5, _storage$getLocalItem6;
|
|
57990
|
-
var conversationsUntilCurrentMessage, lastFeedbackIndex, chatHistoryAfterLastFeedback, chatHistoryWithoutSystemPrompts, payload, endpoint, response, newConversations, newFeedbacks;
|
|
58020
|
+
var conversationsUntilCurrentMessage, lastFeedbackIndex, chatHistoryAfterLastFeedback, chatHistoryWithoutSystemPrompts, payload, endpoint, response, newConversations, newFeedbacks, _t4;
|
|
57991
58021
|
return _regenerator().w(function (_context4) {
|
|
57992
|
-
while (1) switch (_context4.n) {
|
|
58022
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
57993
58023
|
case 0:
|
|
57994
58024
|
if (!((Currentconversation === null || Currentconversation === void 0 ? void 0 : Currentconversation.feedback) === feedback)) {
|
|
57995
58025
|
_context4.n = 1;
|
|
@@ -58003,6 +58033,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
58003
58033
|
}
|
|
58004
58034
|
return _context4.a(2, updateFeedback(feedback, Currentconversation, conversations));
|
|
58005
58035
|
case 2:
|
|
58036
|
+
setMessageError(false);
|
|
58006
58037
|
conversationsUntilCurrentMessage = _toConsumableArray(conversations).slice(0, conversations.findIndex(function (c) {
|
|
58007
58038
|
return (c === null || c === void 0 ? void 0 : c.id) === (Currentconversation === null || Currentconversation === void 0 ? void 0 : Currentconversation.id);
|
|
58008
58039
|
}) + 1);
|
|
@@ -58024,34 +58055,51 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
58024
58055
|
user_email: storage$1.userEmail
|
|
58025
58056
|
};
|
|
58026
58057
|
endpoint = (_storage$getLocalItem5 = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem5 === void 0 ? void 0 : (_storage$getLocalItem6 = _storage$getLocalItem5.endpoints) === null || _storage$getLocalItem6 === void 0 ? void 0 : _storage$getLocalItem6.mihelpChatFeedback;
|
|
58058
|
+
if (endpoint) {
|
|
58059
|
+
_context4.n = 3;
|
|
58060
|
+
break;
|
|
58061
|
+
}
|
|
58062
|
+
console.log('MiHelpAgent: feedback endpoint missing from config');
|
|
58063
|
+
setMessageError(true);
|
|
58064
|
+
return _context4.a(2);
|
|
58065
|
+
case 3:
|
|
58027
58066
|
setIsFeedbackLoading(true);
|
|
58028
|
-
_context4.
|
|
58067
|
+
_context4.p = 4;
|
|
58068
|
+
_context4.n = 5;
|
|
58029
58069
|
return fetcher.post(endpoint, payload, {
|
|
58030
58070
|
headers: {
|
|
58031
58071
|
'Content-Type': 'application/json'
|
|
58032
58072
|
}
|
|
58033
58073
|
});
|
|
58034
|
-
case
|
|
58074
|
+
case 5:
|
|
58035
58075
|
response = _context4.v;
|
|
58036
|
-
newConversations =
|
|
58037
|
-
|
|
58038
|
-
|
|
58039
|
-
|
|
58040
|
-
|
|
58041
|
-
}
|
|
58042
|
-
return conversation;
|
|
58076
|
+
newConversations = conversations.map(function (conversation) {
|
|
58077
|
+
var _response$data3;
|
|
58078
|
+
return (conversation === null || conversation === void 0 ? void 0 : conversation.id) === (Currentconversation === null || Currentconversation === void 0 ? void 0 : Currentconversation.id) ? _objectSpread2(_objectSpread2({}, conversation), {}, {
|
|
58079
|
+
feedback: feedback,
|
|
58080
|
+
feedbackId: response === null || response === void 0 ? void 0 : (_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : _response$data3.feedback_id
|
|
58081
|
+
}) : conversation;
|
|
58043
58082
|
});
|
|
58044
|
-
newFeedbacks = _objectSpread2({}, feedbacks);
|
|
58045
|
-
newFeedbacks[Currentconversation === null || Currentconversation === void 0 ? void 0 : Currentconversation.id] = chatHistoryWithoutSystemPrompts;
|
|
58083
|
+
newFeedbacks = _objectSpread2(_objectSpread2({}, feedbacks), {}, _defineProperty$2({}, Currentconversation === null || Currentconversation === void 0 ? void 0 : Currentconversation.id, chatHistoryWithoutSystemPrompts));
|
|
58046
58084
|
setFeedbacks(newFeedbacks);
|
|
58047
58085
|
setConversations(newConversations);
|
|
58048
|
-
setIsFeedbackLoading(false);
|
|
58049
58086
|
storage$1.setLocalItem('mihelpAgentConversations', newConversations);
|
|
58050
58087
|
storage$1.setLocalItem('mihelpAgentFeedbacks', newFeedbacks);
|
|
58051
|
-
|
|
58088
|
+
_context4.n = 7;
|
|
58089
|
+
break;
|
|
58090
|
+
case 6:
|
|
58091
|
+
_context4.p = 6;
|
|
58092
|
+
_t4 = _context4.v;
|
|
58093
|
+
console.log('MiHelpAgent: failed to submit feedback', _t4);
|
|
58094
|
+
setMessageError(true);
|
|
58095
|
+
case 7:
|
|
58096
|
+
_context4.p = 7;
|
|
58097
|
+
setIsFeedbackLoading(false);
|
|
58098
|
+
return _context4.f(7);
|
|
58099
|
+
case 8:
|
|
58052
58100
|
return _context4.a(2);
|
|
58053
58101
|
}
|
|
58054
|
-
}, _callee4);
|
|
58102
|
+
}, _callee4, null, [[4, 6, 7, 8]]);
|
|
58055
58103
|
}));
|
|
58056
58104
|
return function handleFeedback(_x5, _x6, _x7) {
|
|
58057
58105
|
return _ref5.apply(this, arguments);
|
|
@@ -69604,20 +69652,31 @@ var AppFrame = function AppFrame(props) {
|
|
|
69604
69652
|
var isCoreRoute = ['settings', 'home', 'webChat', 'embedded', ''].includes(getRouteName());
|
|
69605
69653
|
var hasChatBotAccess = userHasChatBotAccess(chatBotAppFunctionId);
|
|
69606
69654
|
var chatBotEnabled = isCoreRoute && !window.location.pathname.includes('embedded') ? enableChatBot && hasChatBotAccess : (tileData === null || tileData === void 0 ? void 0 : tileData.enableChatBot) && hasChatBotAccess;
|
|
69607
|
-
console.log("***chatBotEnabled=", chatBotEnabled, coreAppConfig);
|
|
69608
|
-
console.log("***isCoreRoute=", isCoreRoute, enableChatBot, window.location.pathname, !window.location.pathname.includes('embedded'));
|
|
69609
69655
|
setChatBotEnabled(chatBotEnabled);
|
|
69610
69656
|
chatBotEnabledRef.current = chatBotEnabled;
|
|
69611
69657
|
};
|
|
69658
|
+
React.useEffect(function () {
|
|
69659
|
+
// Check if config is not loaded, start polling
|
|
69660
|
+
var coreAppConfig = storage$1.getLocalItem('opsportal-core:config');
|
|
69661
|
+
if (!coreAppConfig || Object.keys(coreAppConfig).length === 0) {
|
|
69662
|
+
// Poll for config until it's available
|
|
69663
|
+
var pollInterval = setInterval(function () {
|
|
69664
|
+
var config = storage$1.getLocalItem('opsportal-core:config');
|
|
69665
|
+
if (config && Object.keys(config).length > 0) {
|
|
69666
|
+
setChatBotEnableStatus();
|
|
69667
|
+
clearInterval(pollInterval);
|
|
69668
|
+
}
|
|
69669
|
+
}, 100);
|
|
69612
69670
|
|
|
69613
|
-
|
|
69614
|
-
|
|
69615
|
-
|
|
69616
|
-
|
|
69617
|
-
|
|
69618
|
-
|
|
69619
|
-
|
|
69620
|
-
|
|
69671
|
+
// Stop polling after 5 seconds
|
|
69672
|
+
setTimeout(function () {
|
|
69673
|
+
clearInterval(pollInterval);
|
|
69674
|
+
}, 5000);
|
|
69675
|
+
return function () {
|
|
69676
|
+
clearInterval(pollInterval);
|
|
69677
|
+
};
|
|
69678
|
+
}
|
|
69679
|
+
}, []);
|
|
69621
69680
|
React.useEffect(function () {
|
|
69622
69681
|
if (appBarMounted) {
|
|
69623
69682
|
var event = new Event('localStorageChanged');
|
|
@@ -69629,7 +69688,6 @@ var AppFrame = function AppFrame(props) {
|
|
|
69629
69688
|
if (props.env) {
|
|
69630
69689
|
window.toolkitEnv = props.env;
|
|
69631
69690
|
}
|
|
69632
|
-
console.log('***props=', props.location.pathname);
|
|
69633
69691
|
setChatBotEnableStatus();
|
|
69634
69692
|
}, [props]);
|
|
69635
69693
|
var authGuardProps = _objectSpread2(_objectSpread2({}, props), {}, {
|