@microsoft/omnichannel-chat-widget 1.0.1 → 1.0.2-main.054759b
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/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +13 -7
- package/lib/cjs/components/livechatwidget/common/endChat.js +0 -4
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +6 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +13 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +27 -13
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +13 -7
- package/lib/esm/components/livechatwidget/common/endChat.js +0 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +6 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +13 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +27 -13
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/package.json +1 -1
|
@@ -817,7 +817,7 @@ const dummyDefaultProps = {
|
|
|
817
817
|
minHeight: "25px",
|
|
818
818
|
width: "100%",
|
|
819
819
|
minWidth: "250px",
|
|
820
|
-
padding: "
|
|
820
|
+
padding: "5px"
|
|
821
821
|
},
|
|
822
822
|
downloadTranscriptButtonStyleProps: {
|
|
823
823
|
icon: {
|
|
@@ -1756,13 +1756,19 @@ const dummyDefaultProps = {
|
|
|
1756
1756
|
}
|
|
1757
1757
|
},
|
|
1758
1758
|
localizedTexts: {
|
|
1759
|
+
/*
|
|
1760
|
+
MIDDLEWARE_BANNER_FILE parameters:
|
|
1761
|
+
{0} = File limit size
|
|
1762
|
+
{1} = File extension
|
|
1763
|
+
{2} = File name
|
|
1764
|
+
*/
|
|
1759
1765
|
MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
|
|
1760
|
-
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
1761
|
-
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
1762
|
-
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
|
|
1763
|
-
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{
|
|
1764
|
-
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
|
|
1765
|
-
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
|
|
1766
|
+
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
1767
|
+
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
1768
|
+
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
|
|
1769
|
+
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
|
|
1770
|
+
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
|
|
1771
|
+
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
|
|
1766
1772
|
MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
|
|
1767
1773
|
MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You're back online.",
|
|
1768
1774
|
MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
|
|
@@ -77,10 +77,6 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
// Need to clear these states immediately when chat ended from OC.
|
|
80
|
-
dispatch({
|
|
81
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
82
|
-
payload: undefined
|
|
83
|
-
});
|
|
84
80
|
dispatch({
|
|
85
81
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
86
82
|
payload: undefined
|
|
@@ -198,6 +198,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
+
if (props.initialCustomContext) {
|
|
202
|
+
dispatch({
|
|
203
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
204
|
+
payload: props.initialCustomContext
|
|
205
|
+
});
|
|
206
|
+
}
|
|
201
207
|
|
|
202
208
|
// Initialize global dir
|
|
203
209
|
const globalDir = ((_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.dir) ?? (0, _utils.getLocaleDirection)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Ch = _props$chatConfig2.ChatWidgetLanguage) === null || _props$chatConfig2$Ch === void 0 ? void 0 : _props$chatConfig2$Ch.msdyn_localeid);
|
|
@@ -7,6 +7,7 @@ exports.default = exports.PreChatSurveyPaneStateful = void 0;
|
|
|
7
7
|
var _Constants = require("../../common/Constants");
|
|
8
8
|
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _markdownIt = _interopRequireDefault(require("markdown-it"));
|
|
10
11
|
var _utils = require("../../common/utils");
|
|
11
12
|
var _ConversationState = require("../../contexts/common/ConversationState");
|
|
12
13
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
@@ -21,6 +22,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
23
|
const PreChatSurveyPaneStateful = props => {
|
|
23
24
|
var _surveyProps$stylePro, _props$surveyProps, _props$surveyProps$co;
|
|
25
|
+
// Set MarkDown global variable to be used for prechat adaptive cards
|
|
26
|
+
window["markdownit"] = _markdownIt.default;
|
|
24
27
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
25
28
|
const {
|
|
26
29
|
surveyProps,
|
|
@@ -4,14 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.defaultMiddlewareLocalizedTexts = void 0;
|
|
7
|
+
/*
|
|
8
|
+
MIDDLEWARE_BANNER_FILE parameters:
|
|
9
|
+
{0} = File limit size
|
|
10
|
+
{1} = File extension
|
|
11
|
+
{2} = File name
|
|
12
|
+
*/
|
|
13
|
+
|
|
7
14
|
const defaultMiddlewareLocalizedTexts = {
|
|
8
15
|
MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
|
|
9
|
-
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
10
|
-
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
11
|
-
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
|
|
12
|
-
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{
|
|
13
|
-
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
|
|
14
|
-
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
|
|
16
|
+
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
17
|
+
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
18
|
+
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
|
|
19
|
+
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
|
|
20
|
+
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
|
|
21
|
+
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
|
|
15
22
|
MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
|
|
16
23
|
MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You’re back online.",
|
|
17
24
|
MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
|
|
@@ -76,6 +76,11 @@ const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) =>
|
|
|
76
76
|
const isImage = contentType => {
|
|
77
77
|
return _Constants.AMSConstants.supportedImagesMimeTypes.includes(contentType);
|
|
78
78
|
};
|
|
79
|
+
const textEllipsis = function (str) {
|
|
80
|
+
let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
|
|
81
|
+
const ellipsis = "...";
|
|
82
|
+
return str.length > maxLength ? str.slice(0, maxLength - ellipsis.length) + ellipsis : str;
|
|
83
|
+
};
|
|
79
84
|
const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
80
85
|
let errorMessage = "";
|
|
81
86
|
if (!fileName || !maxUploadFileSize) {
|
|
@@ -91,10 +96,11 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
|
|
|
91
96
|
if (!supportedFileExtension && !supportedFileSize) {
|
|
92
97
|
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
93
98
|
} else if (!supportedFileSize) {
|
|
94
|
-
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
99
|
+
errorMessage = getFileSizeErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
95
100
|
} else if (!supportedFileExtension) {
|
|
96
101
|
errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
|
|
97
102
|
} else if (fileIsEmpty) {
|
|
103
|
+
var _errorMessage;
|
|
98
104
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
99
105
|
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
100
106
|
Description: "Attachment validation failed",
|
|
@@ -102,7 +108,8 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
|
|
|
102
108
|
ErrorDetails: "File provided is empty"
|
|
103
109
|
}
|
|
104
110
|
});
|
|
105
|
-
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR
|
|
111
|
+
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR || "";
|
|
112
|
+
if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{2}")) errorMessage = errorMessage.replace("{2}", textEllipsis(fileName));
|
|
106
113
|
} else {
|
|
107
114
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
108
115
|
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -116,19 +123,18 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
|
|
|
116
123
|
return errorMessage;
|
|
117
124
|
};
|
|
118
125
|
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
126
|
+
var _errorMessage3;
|
|
119
127
|
const index = fileName.lastIndexOf(".");
|
|
120
128
|
let errorMessage, exceptionDetails;
|
|
121
129
|
if (index < 0) {
|
|
122
130
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
|
|
123
131
|
exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
|
|
124
132
|
} else {
|
|
125
|
-
var
|
|
133
|
+
var _errorMessage2;
|
|
126
134
|
const fileExtension = fileName.substring(index);
|
|
127
135
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
|
|
136
|
+
if ((_errorMessage2 = errorMessage) !== null && _errorMessage2 !== void 0 && _errorMessage2.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
128
137
|
exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
|
|
129
|
-
if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
|
|
130
|
-
errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
131
|
-
}
|
|
132
138
|
}
|
|
133
139
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
134
140
|
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -137,10 +143,12 @@ const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, ma
|
|
|
137
143
|
ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${_Constants.AMSConstants.maxSupportedImageSize} AMS file size limit=${_Constants.AMSConstants.maxSupportedFileSize}`
|
|
138
144
|
}
|
|
139
145
|
});
|
|
140
|
-
|
|
146
|
+
if ((_errorMessage3 = errorMessage) !== null && _errorMessage3 !== void 0 && _errorMessage3.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
|
|
147
|
+
return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
|
|
141
148
|
};
|
|
142
149
|
const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
143
150
|
const index = fileName.lastIndexOf(".");
|
|
151
|
+
let errorMessage;
|
|
144
152
|
if (index < 0) {
|
|
145
153
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
146
154
|
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -149,8 +157,10 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
|
149
157
|
ErrorDetails: "File provided without file extension"
|
|
150
158
|
}
|
|
151
159
|
});
|
|
152
|
-
|
|
160
|
+
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION;
|
|
161
|
+
return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
|
|
153
162
|
} else {
|
|
163
|
+
var _errorMessage4, _errorMessage5;
|
|
154
164
|
const fileExtension = fileName.substring(index);
|
|
155
165
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
156
166
|
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -159,11 +169,14 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
|
159
169
|
ErrorDetails: `${fileExtension} files extension is not supported.`
|
|
160
170
|
}
|
|
161
171
|
});
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
|
|
173
|
+
if ((_errorMessage4 = errorMessage) !== null && _errorMessage4 !== void 0 && _errorMessage4.includes("{0}")) errorMessage = errorMessage.replace("{0}", fileExtension); //keeping backwards compatibility for this localized string
|
|
174
|
+
if ((_errorMessage5 = errorMessage) !== null && _errorMessage5 !== void 0 && _errorMessage5.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
175
|
+
return errorMessage && errorMessage.length > 0 ? errorMessage : "";
|
|
164
176
|
}
|
|
165
177
|
};
|
|
166
|
-
const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
178
|
+
const getFileSizeErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
179
|
+
var _errorMessage6;
|
|
167
180
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
168
181
|
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
169
182
|
Description: "Attachment validation failed",
|
|
@@ -171,8 +184,9 @@ const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynami
|
|
|
171
184
|
ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${_Constants.AMSConstants.maxSupportedImageSize} AMS file size limit=${_Constants.AMSConstants.maxSupportedFileSize}`
|
|
172
185
|
}
|
|
173
186
|
});
|
|
174
|
-
|
|
175
|
-
|
|
187
|
+
let errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
|
|
188
|
+
if ((_errorMessage6 = errorMessage) !== null && _errorMessage6 !== void 0 && _errorMessage6.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
|
|
189
|
+
return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
|
|
176
190
|
};
|
|
177
191
|
|
|
178
192
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
@@ -811,7 +811,7 @@ export const dummyDefaultProps = {
|
|
|
811
811
|
minHeight: "25px",
|
|
812
812
|
width: "100%",
|
|
813
813
|
minWidth: "250px",
|
|
814
|
-
padding: "
|
|
814
|
+
padding: "5px"
|
|
815
815
|
},
|
|
816
816
|
downloadTranscriptButtonStyleProps: {
|
|
817
817
|
icon: {
|
|
@@ -1750,13 +1750,19 @@ export const dummyDefaultProps = {
|
|
|
1750
1750
|
}
|
|
1751
1751
|
},
|
|
1752
1752
|
localizedTexts: {
|
|
1753
|
+
/*
|
|
1754
|
+
MIDDLEWARE_BANNER_FILE parameters:
|
|
1755
|
+
{0} = File limit size
|
|
1756
|
+
{1} = File extension
|
|
1757
|
+
{2} = File name
|
|
1758
|
+
*/
|
|
1753
1759
|
MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
|
|
1754
|
-
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
1755
|
-
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
1756
|
-
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
|
|
1757
|
-
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{
|
|
1758
|
-
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
|
|
1759
|
-
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
|
|
1760
|
+
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
1761
|
+
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
1762
|
+
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
|
|
1763
|
+
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
|
|
1764
|
+
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
|
|
1765
|
+
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
|
|
1760
1766
|
MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
|
|
1761
1767
|
MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You're back online.",
|
|
1762
1768
|
MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
|
|
@@ -71,10 +71,6 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
// Need to clear these states immediately when chat ended from OC.
|
|
74
|
-
dispatch({
|
|
75
|
-
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
76
|
-
payload: undefined
|
|
77
|
-
});
|
|
78
74
|
dispatch({
|
|
79
75
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
80
76
|
payload: undefined
|
|
@@ -190,6 +190,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
+
if (props.initialCustomContext) {
|
|
194
|
+
dispatch({
|
|
195
|
+
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
196
|
+
payload: props.initialCustomContext
|
|
197
|
+
});
|
|
198
|
+
}
|
|
193
199
|
|
|
194
200
|
// Initialize global dir
|
|
195
201
|
const globalDir = ((_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.dir) ?? getLocaleDirection((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Ch = _props$chatConfig2.ChatWidgetLanguage) === null || _props$chatConfig2$Ch === void 0 ? void 0 : _props$chatConfig2$Ch.msdyn_localeid);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HtmlAttributeNames, Regex } from "../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
|
+
import MarkdownIt from "markdown-it";
|
|
4
5
|
import { extractPreChatSurveyResponseValues, findAllFocusableElement, getStateFromCache, isUndefinedOrEmpty, parseAdaptiveCardPayload } from "../../common/utils";
|
|
5
6
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
6
7
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -13,6 +14,8 @@ import useChatContextStore from "../../hooks/useChatContextStore";
|
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
15
|
export const PreChatSurveyPaneStateful = props => {
|
|
15
16
|
var _surveyProps$stylePro, _props$surveyProps, _props$surveyProps$co;
|
|
17
|
+
// Set MarkDown global variable to be used for prechat adaptive cards
|
|
18
|
+
window["markdownit"] = MarkdownIt;
|
|
16
19
|
const [state, dispatch] = useChatContextStore();
|
|
17
20
|
const {
|
|
18
21
|
surveyProps,
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIDDLEWARE_BANNER_FILE parameters:
|
|
3
|
+
{0} = File limit size
|
|
4
|
+
{1} = File extension
|
|
5
|
+
{2} = File name
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
export const defaultMiddlewareLocalizedTexts = {
|
|
2
9
|
MIDDLEWARE_BANNER_FILE_NULL_ERROR: "There was an error uploading the file, please try again.",
|
|
3
|
-
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
4
|
-
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
5
|
-
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file with an appropriate file extension.",
|
|
6
|
-
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{
|
|
7
|
-
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File exceeds the allowed limit of {0} MB.",
|
|
8
|
-
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file can't be attached because it's empty. Please try again with a different file.",
|
|
10
|
+
MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and please upload the file with an appropriate file extension.",
|
|
11
|
+
MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR: "File {2} exceeds the allowed limit of {0} MB and {1} files are not supported.",
|
|
12
|
+
MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION: "File upload error. Please upload the file {2} with an appropriate file extension.",
|
|
13
|
+
MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR: "{1} files are not supported.",
|
|
14
|
+
MIDDLEWARE_BANNER_FILE_SIZE_ERROR: "File {2} exceeds the allowed limit of {0} MB.",
|
|
15
|
+
MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR: "This file {2} can't be attached because it's empty. Please try again with a different file.",
|
|
9
16
|
MIDDLEWARE_BANNER_ERROR_MESSAGE: "Upload failed, please try again.",
|
|
10
17
|
MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE: "You’re back online.",
|
|
11
18
|
MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION: "Unable to connect—please check your internet connection.",
|
|
@@ -70,6 +70,11 @@ const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) =>
|
|
|
70
70
|
const isImage = contentType => {
|
|
71
71
|
return AMSConstants.supportedImagesMimeTypes.includes(contentType);
|
|
72
72
|
};
|
|
73
|
+
const textEllipsis = function (str) {
|
|
74
|
+
let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
|
|
75
|
+
const ellipsis = "...";
|
|
76
|
+
return str.length > maxLength ? str.slice(0, maxLength - ellipsis.length) + ellipsis : str;
|
|
77
|
+
};
|
|
73
78
|
const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
74
79
|
let errorMessage = "";
|
|
75
80
|
if (!fileName || !maxUploadFileSize) {
|
|
@@ -85,10 +90,11 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
|
|
|
85
90
|
if (!supportedFileExtension && !supportedFileSize) {
|
|
86
91
|
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
87
92
|
} else if (!supportedFileSize) {
|
|
88
|
-
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
93
|
+
errorMessage = getFileSizeErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
89
94
|
} else if (!supportedFileExtension) {
|
|
90
95
|
errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
|
|
91
96
|
} else if (fileIsEmpty) {
|
|
97
|
+
var _errorMessage;
|
|
92
98
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
93
99
|
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
94
100
|
Description: "Attachment validation failed",
|
|
@@ -96,7 +102,8 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
|
|
|
96
102
|
ErrorDetails: "File provided is empty"
|
|
97
103
|
}
|
|
98
104
|
});
|
|
99
|
-
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR
|
|
105
|
+
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR || "";
|
|
106
|
+
if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{2}")) errorMessage = errorMessage.replace("{2}", textEllipsis(fileName));
|
|
100
107
|
} else {
|
|
101
108
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
102
109
|
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -110,19 +117,18 @@ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize,
|
|
|
110
117
|
return errorMessage;
|
|
111
118
|
};
|
|
112
119
|
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
120
|
+
var _errorMessage3;
|
|
113
121
|
const index = fileName.lastIndexOf(".");
|
|
114
122
|
let errorMessage, exceptionDetails;
|
|
115
123
|
if (index < 0) {
|
|
116
124
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
|
|
117
125
|
exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
|
|
118
126
|
} else {
|
|
119
|
-
var
|
|
127
|
+
var _errorMessage2;
|
|
120
128
|
const fileExtension = fileName.substring(index);
|
|
121
129
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
|
|
130
|
+
if ((_errorMessage2 = errorMessage) !== null && _errorMessage2 !== void 0 && _errorMessage2.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
122
131
|
exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
|
|
123
|
-
if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
|
|
124
|
-
errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
125
|
-
}
|
|
126
132
|
}
|
|
127
133
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
128
134
|
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -131,10 +137,12 @@ const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, ma
|
|
|
131
137
|
ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
|
|
132
138
|
}
|
|
133
139
|
});
|
|
134
|
-
|
|
140
|
+
if ((_errorMessage3 = errorMessage) !== null && _errorMessage3 !== void 0 && _errorMessage3.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
|
|
141
|
+
return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
|
|
135
142
|
};
|
|
136
143
|
const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
137
144
|
const index = fileName.lastIndexOf(".");
|
|
145
|
+
let errorMessage;
|
|
138
146
|
if (index < 0) {
|
|
139
147
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
140
148
|
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -143,8 +151,10 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
|
143
151
|
ErrorDetails: "File provided without file extension"
|
|
144
152
|
}
|
|
145
153
|
});
|
|
146
|
-
|
|
154
|
+
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION;
|
|
155
|
+
return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
|
|
147
156
|
} else {
|
|
157
|
+
var _errorMessage4, _errorMessage5;
|
|
148
158
|
const fileExtension = fileName.substring(index);
|
|
149
159
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
150
160
|
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
@@ -153,11 +163,14 @@ const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
|
153
163
|
ErrorDetails: `${fileExtension} files extension is not supported.`
|
|
154
164
|
}
|
|
155
165
|
});
|
|
156
|
-
|
|
157
|
-
|
|
166
|
+
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
|
|
167
|
+
if ((_errorMessage4 = errorMessage) !== null && _errorMessage4 !== void 0 && _errorMessage4.includes("{0}")) errorMessage = errorMessage.replace("{0}", fileExtension); //keeping backwards compatibility for this localized string
|
|
168
|
+
if ((_errorMessage5 = errorMessage) !== null && _errorMessage5 !== void 0 && _errorMessage5.includes("{1}")) errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
169
|
+
return errorMessage && errorMessage.length > 0 ? errorMessage : "";
|
|
158
170
|
}
|
|
159
171
|
};
|
|
160
|
-
const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
172
|
+
const getFileSizeErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
173
|
+
var _errorMessage6;
|
|
161
174
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
162
175
|
Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
163
176
|
Description: "Attachment validation failed",
|
|
@@ -165,8 +178,9 @@ const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynami
|
|
|
165
178
|
ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
|
|
166
179
|
}
|
|
167
180
|
});
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
let errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
|
|
182
|
+
if ((_errorMessage6 = errorMessage) !== null && _errorMessage6 !== void 0 && _errorMessage6.includes("{0}")) errorMessage = errorMessage.replace("{0}", maxUploadFileSize);
|
|
183
|
+
return errorMessage ? errorMessage.includes("{2}") ? errorMessage.replace("{2}", textEllipsis(fileName)) : errorMessage : "";
|
|
170
184
|
};
|
|
171
185
|
|
|
172
186
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
@@ -53,5 +53,6 @@ export interface ILiveChatWidgetProps {
|
|
|
53
53
|
liveChatContextFromCache?: ILiveChatWidgetContext;
|
|
54
54
|
contextDataStore?: IContextDataStore;
|
|
55
55
|
getAuthToken?: (authClientFunction?: string) => Promise<string | null>;
|
|
56
|
+
initialCustomContext?: any;
|
|
56
57
|
scrollBarProps?: IScrollBarProps;
|
|
57
58
|
}
|