Constructor
new Messaging()
- Source:
Example
import { React } from 'react';
import { Message } from 'oskari-ui';
import { Messaging } from 'oskari-ui/util';
// Simple usage
Messaging.open('Hello world');
// The localized way
Messaging.open(<Message messageKey='hello' bundleKey='my-hello-world-bundle'/>);
// Localized error message
Messaging.open({
title: <Message messageKey='error.notfound.title' bundleKey='my-bundle'/>,
content: <Message messageKey='error.notfound.content' bundleKey='my-bundle'/>,
level: Messaging.LEVEL.ERROR
});
// Localized error alert with a shortcut
Messaging.error(<Message messageKey='error.notfound.content' bundleKey='my-bundle'/>);
Members
(static, constant) LEVEL
Properties:
Name | Type | Description |
---|---|---|
SUCCESS |
string | Message with success icon. |
INFO |
string | Message with info icon. |
LOADING |
string | Message with warning loading icon. Only valid for ALERT and MESSAGE types. |
WARN |
string | Message with warning icon. |
WARNING |
string | Alias for WARN. |
ERROR |
string | Message with error icon. |
- Source:
(static, constant) TYPE
Properties:
Name | Type | Description |
---|---|---|
NOTIFICATION |
string | Notification with a title. |
ALERT |
string | Message box on upper-center. |
MESSAGE |
string | Alias for ALERT. |
- Source:
Methods
alert(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
close(key)
Parameters:
Name | Type | Description |
---|---|---|
key |
string |
- Source:
error(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
info(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
loading(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
notify(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
open(option)
Parameters:
Name | Type | Description |
---|---|---|
option |
Messaging~Options |
- Source:
success(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
warn(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
warning(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
Messaging~Options |
- Source:
Type Definitions
Options
The options object for Messaging.
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string |
<optional> |
Message type. One of ('notification'|'message'). |
level |
string |
<optional> |
Message level. One of ('success'|'info'|'loading'|'warn'|'error'). |
content |
ReactNode | Content for the message. | |
key |
string |
<optional> |
Message identifier. |
duration |
number |
<optional> |
Duration for auto-closing. Null means no auto-closing. |
onClose |
function |
<optional> |
Close callback. |
icon |
ReactNode |
<optional> |
Customized icon. |
title |
ReactNode |
<optional> |
Title for the message, only supported for notification type. |
placement |
string |
<optional> |
Only for notification type, location of the message. One of ('topLeft'|'topRight|'bottomLeft'|'bottomRight'). |
closeIcon |
ReactNode |
<optional> |
Custom close icon. |
onClick |
function |
<optional> |
Click callback. |
style |
object |
<optional> |
Inline style. |
- Source: