Introduce Dialog.alert
Summary: Introduce `Dialog.alert` to show users a FYI message, and be able to wait for it to be handled, as utility around several `Modal` utilities. Reviewed By: jknoxville Differential Revision: D29875484 fbshipit-source-id: 5d2ea83e486631ac18a81800b467f97dfaac6d34
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4b892e7373
commit
8d7caa9dd4
@@ -77,14 +77,33 @@ export const Dialog = {
|
||||
|
||||
confirm({
|
||||
message,
|
||||
onConfirm,
|
||||
...rest
|
||||
}: {
|
||||
message: React.ReactNode;
|
||||
onConfirm?: () => Promise<true>;
|
||||
} & BaseDialogOptions): DialogResult<true> {
|
||||
return Dialog.show<true>({
|
||||
...rest,
|
||||
children: message,
|
||||
onConfirm: async () => true,
|
||||
onConfirm: onConfirm ?? (async () => true),
|
||||
});
|
||||
},
|
||||
|
||||
alert({
|
||||
message,
|
||||
type,
|
||||
...rest
|
||||
}: {
|
||||
message: React.ReactNode;
|
||||
type: 'info' | 'error' | 'warning' | 'success';
|
||||
} & BaseDialogOptions): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
Modal[type]({
|
||||
afterClose: resolve,
|
||||
content: message,
|
||||
...rest,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user