mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-26 14:58:55 +08:00
refactor(core): move actions to footer of notification card (#11894)
This PR move all actions button to the footer of `NotificationCard`. There are some example as following: ### No Changes    ### Changes ### Before  #### After 
This commit is contained in:
+8
-5
@@ -109,12 +109,15 @@ export function copyAsImage(std: BlockStdScope) {
|
||||
notify.error({
|
||||
title: I18n.t('com.affine.copy.asImage.notAvailable.title'),
|
||||
message: I18n.t('com.affine.copy.asImage.notAvailable.message'),
|
||||
action: {
|
||||
label: I18n.t('com.affine.copy.asImage.notAvailable.action'),
|
||||
onClick: () => {
|
||||
window.open('https://affine.pro/download');
|
||||
actions: [
|
||||
{
|
||||
key: 'download',
|
||||
label: I18n.t('com.affine.copy.asImage.notAvailable.action'),
|
||||
onClick: () => {
|
||||
window.open('https://affine.pro/download');
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
Input,
|
||||
type Notification,
|
||||
notify,
|
||||
toast,
|
||||
type ToastOptions,
|
||||
@@ -96,17 +97,25 @@ export function patchNotificationService({
|
||||
throw new Error('Invalid notification accent');
|
||||
}
|
||||
|
||||
const toAffineNotificationActions = (
|
||||
actions: (typeof notification)['actions']
|
||||
): Notification['actions'] => {
|
||||
if (!actions) return undefined;
|
||||
|
||||
return actions.map(({ label, onClick, key }) => {
|
||||
return {
|
||||
key,
|
||||
label: toReactNode(label),
|
||||
onClick,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const toastId = fn(
|
||||
{
|
||||
title: toReactNode(notification.title),
|
||||
message: toReactNode(notification.message),
|
||||
footer: toReactNode(notification.footer),
|
||||
action: notification.action?.onClick
|
||||
? {
|
||||
label: toReactNode(notification.action?.label),
|
||||
onClick: notification.action.onClick,
|
||||
}
|
||||
: undefined,
|
||||
actions: toAffineNotificationActions(notification.actions),
|
||||
onDismiss: notification.onClose,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user