feat(web): better UX when creating a new album (#8270)

* feat(web): ask user before going to newly created album

* feat(web): add button option to notification cards

* feat(web): allow html messages in notification cards

* show album -> view album

* remove 'link' action from notifications

* remove unused type
This commit is contained in:
Ethan Margaillan
2024-03-27 20:47:42 +01:00
committed by GitHub
parent 613b544bf0
commit 8bf571bf48
8 changed files with 134 additions and 54 deletions

View File

@@ -6,20 +6,31 @@ export enum NotificationType {
Warning = 'Warning',
}
export type NotificationButton = {
text: string;
onClick: () => unknown;
};
export type Notification = {
id: number;
type: NotificationType;
message: string;
/**
* Allow HTML to be inserted within the message. Make sure to verify/encode
* variables that may be interpoalted into 'message'
*/
html?: boolean;
/** The action to take when the notification is clicked */
action: NotificationAction;
button?: NotificationButton;
/** Timeout in miliseconds */
timeout: number;
};
type DiscardAction = { type: 'discard' };
type NoopAction = { type: 'noop' };
type LinkAction = { type: 'link'; target: string };
export type NotificationAction = DiscardAction | NoopAction | LinkAction;
export type NotificationAction = DiscardAction | NoopAction;
export type NotificationOptions = Partial<Exclude<Notification, 'id'>> & { message: string };
@@ -32,7 +43,9 @@ function createNotificationList() {
currentList.push({
id: count++,
type: NotificationType.Info,
action: { type: 'discard' },
action: {
type: options.button ? 'noop' : 'discard',
},
timeout: 3000,
...options,
});