4626b4d7a4
* feat(screenshare): add support for troubleshooting links Adds setting option to specify troubleshooting links to each error code of screenshare. When a troubleshooting link for the given error exists, the toast notification about the error is displayed with a 'Learn more' button that when clicked leads the user to the external link. When there is no link set for the specific error code, the button is not displayed. * fix(screenshare): change toast type for error code 1136 Changed toast type from 'error' to 'warning' for error code 1136 when sharing screen. This adjustment was made because error code 1136 is also returned when the user cancels screen sharing during the tab selection process. Displaying an error toast in this situation could cause unnecessary alarm for users, as they were simply canceling an operation. * fix(notification): help link button element Uses the button element instead of a div to display the 'Learn more' help link button. --------- Co-authored-by: Carlos Henrique <carloshsc1998@gmail.com>
71 lines
1.7 KiB
JavaScript
Executable File
71 lines
1.7 KiB
JavaScript
Executable File
/* eslint react/jsx-filename-extension: 0 */
|
|
import React from 'react';
|
|
import { toast } from 'react-toastify';
|
|
import { isEqual } from 'radash';
|
|
import Styled from './styles';
|
|
import Toast from '/imports/ui/components/common/toast/component';
|
|
|
|
let lastToast = {
|
|
id: null,
|
|
message: null,
|
|
type: null,
|
|
icon: null,
|
|
};
|
|
|
|
export function notify(message, type = 'default', icon, options, content, small) {
|
|
const settings = {
|
|
type,
|
|
...options,
|
|
};
|
|
|
|
const { id: lastToastId, ...lastToastProps } = lastToast;
|
|
const toastProps = {
|
|
message,
|
|
type,
|
|
icon,
|
|
content,
|
|
small,
|
|
};
|
|
|
|
if (!toast.isActive(lastToast.id) || !isEqual(lastToastProps, toastProps)) {
|
|
if (options?.helpLink != null && options?.helpLabel != null) {
|
|
const id = toast(
|
|
<div role="alert">
|
|
<Toast {...toastProps} />
|
|
<Styled.HelpLinkButton
|
|
label={options.helpLabel}
|
|
color="default"
|
|
size="sm"
|
|
onClick={() => { window.open(options.helpLink); }}
|
|
data-test="helpLinkToastButton"
|
|
/>
|
|
</div>, settings,
|
|
);
|
|
|
|
lastToast = { id, ...toastProps };
|
|
|
|
return id;
|
|
}
|
|
if (toast.isActive(lastToast.id)
|
|
&& isEqual(lastToastProps.key, toastProps.key) && options?.autoClose > 0) {
|
|
toast.update(
|
|
lastToast.id,
|
|
{
|
|
render: <div role="alert"><Toast {...toastProps} /></div>,
|
|
autoClose: options.autoClose,
|
|
...toastProps,
|
|
},
|
|
);
|
|
} else {
|
|
const id = toast(<div role="alert"><Toast {...toastProps} /></div>, settings);
|
|
|
|
lastToast = { id, ...toastProps };
|
|
|
|
return id;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export default { notify };
|