Rename ToastMessage into ToastApiMessage

Signed-off-by: Charles de Dreuille <charles.dedreuille@gmail.com>
This commit is contained in:
Charles de Dreuille
2026-02-06 16:16:41 +00:00
committed by Patrik Oldsberg
parent e0b7eb0b64
commit aa1d73a798
9 changed files with 35 additions and 55 deletions
+7 -7
View File
@@ -16,8 +16,8 @@
import {
ToastApi,
ToastMessage,
ToastMessageWithKey,
ToastApiMessage,
ToastApiMessageWithKey,
} from '@backstage/frontend-plugin-api';
import { Observable } from '@backstage/types';
import ObservableImpl from 'zen-observable';
@@ -85,15 +85,15 @@ class PublishSubject<T> {
* @internal
*/
export class ToastApiForwarder implements ToastApi {
private readonly subject = new PublishSubject<ToastMessageWithKey>();
private readonly subject = new PublishSubject<ToastApiMessageWithKey>();
private readonly closeSubject = new PublishSubject<string>();
private readonly recentToasts: ToastMessageWithKey[] = [];
private readonly recentToasts: ToastApiMessageWithKey[] = [];
private readonly closedKeys = new Set<string>();
private readonly maxBufferSize = 10;
post(toast: ToastMessage): string {
post(toast: ToastApiMessage): string {
const key = generateToastKey();
const toastWithKey: ToastMessageWithKey = { ...toast, key };
const toastWithKey: ToastApiMessageWithKey = { ...toast, key };
this.recentToasts.push(toastWithKey);
if (this.recentToasts.length > this.maxBufferSize) {
@@ -121,7 +121,7 @@ export class ToastApiForwarder implements ToastApi {
}
}
toast$(): Observable<ToastMessageWithKey> {
toast$(): Observable<ToastApiMessageWithKey> {
// Filter out any toasts that were closed to handle race conditions
const activeToasts = this.recentToasts.filter(
t => !this.closedKeys.has(t.key),
+2 -2
View File
@@ -16,9 +16,9 @@
// Public exports
export { ToastDisplay } from './ToastDisplay';
export type { ToastContent, ToastLink, ToastDisplayProps } from './types';
export type { ToastDisplayProps } from './types';
// Internal exports (used within the plugin only)
export { ToastContainer } from './ToastContainer';
export { toastQueue } from './ToastQueue';
export type { ToastContainerProps } from './types';
export type { ToastContent, ToastLink, ToastContainerProps } from './types';
+3 -3
View File
@@ -19,7 +19,7 @@ import type { ToastQueue, ToastState, QueuedToast } from 'react-stately';
/**
* Link item for toast notifications
* @public
* @internal
*/
export interface ToastLink {
/** Display text for the link */
@@ -30,7 +30,7 @@ export interface ToastLink {
/**
* Content for a toast notification
* @public
* @internal
*/
export interface ToastContent {
/** Title of the toast (required) */
@@ -72,7 +72,7 @@ export interface ToastProps {
/**
* Props for the ToastContainer component
* @public
* @internal
*/
export interface ToastContainerProps {
/** Toast queue instance */
+1 -5
View File
@@ -18,8 +18,4 @@ export { appPlugin as default } from './plugin';
// Toast components for alert display
export { ToastDisplay } from './components/Toast';
export type {
ToastContent,
ToastLink,
ToastDisplayProps,
} from './components/Toast';
export type { ToastDisplayProps } from './components/Toast';