Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function showApiErrorNotification({ errors, source }) {
return showNotification(
{
kind: 'api-error',
values: {
source,
// NOTE: Some sources or errors (e.g. GraphQL) return an array or object.
// The cast into an array happens here so that consumers can pass both types.
errors: Array.isArray(errors) ? errors : [errors],
},
domain: DOMAINS.PAGE,
},
{
dismissAfter: 0,
}
);
}
export default function showApiErrorNotification({
errors,
}: TApiErrorNotificationOptions) {
return showNotification(
{
id: 0,
domain: DOMAINS.PAGE,
kind: 'api-error',
values: {
// NOTE: Some sources or errors (e.g. GraphQL) return an array or object.
// The cast into an array happens here so that consumers can pass both types.
errors: Array.isArray(errors) ? errors : [errors],
},
},
{
dismissAfter: 0,
}
);
}
{'These are not the droids you are looking for!'}
{`It's a trap!`}
{'I am your father.'}
{'Do or do not, there is no try.'}
{'These are not the droids you are looking for!'}
{`It's a trap!`}
{'Do or do not, there is no try.'}
const ReduxProviders = ({ children }) => (
<div>
{children}
</div>
);
ReduxProviders.propTypes = {
it('should select global notifications', () => {
expect(
selectGlobalNotifications.resultFunc([
{ domain: DOMAINS.GLOBAL },
{ domain: DOMAINS.PAGE },
])
).toEqual([{ domain: DOMAINS.GLOBAL }]);
});
});
it('should select side notifications', () => {
expect(
selectSideNotifications.resultFunc([
{ domain: DOMAINS.SIDE },
{ domain: DOMAINS.PAGE },
])
).toEqual([{ domain: DOMAINS.SIDE }]);
});
});
domain={props.notification.domain}
onCloseClick={props.dismiss}
>
{props.notification.values.errorId && <br>}
{props.notification.values.errorId && (
<span>{`ID (${props.notification.values.errorId})`}</span>
)}
);
UnexpectedErrorNotification.displayName = 'UnexpectedErrorNotification';
UnexpectedErrorNotification.propTypes = {
dismiss: PropTypes.func.isRequired,
notification: PropTypes.shape({
id: PropTypes.number.isRequired,
domain: PropTypes.oneOf([DOMAINS.PAGE]).isRequired,
kind: PropTypes.oneOf(['unexpected-error']).isRequired,
values: PropTypes.shape({ errorId: PropTypes.string }),
}),
};
export default UnexpectedErrorNotification;
);
}}
);
})()}
{isLoadingUser || isLoadingLocaleData ? (
) : (
<div is=""> wrapping the
</div>
export default function showUnexpectedErrorNotification({
errorId,
}: TAppNotificationValuesUnexpectedError = {}) {
return showNotification(
{
id: 0,
domain: DOMAINS.PAGE,
kind: 'unexpected-error',
values: {
errorId,
},
},
{
dismissAfter: 0,
}
);
}
function mapNotificationToComponent(notification) {
switch (notification.domain) {
case DOMAINS.PAGE:
switch (notification.kind) {
case 'error':
case 'warning':
case 'info':
case 'success':
return GenericNotification;
case 'api-error':
return ApiErrorNotification;
case 'unexpected-error':
return UnexpectedErrorNotification;
default:
return null;
}
case DOMAINS.GLOBAL:
switch (notification.kind) {
case 'error':