From 0fe55cabcd99f1a767ea547701c855e9d0f58f8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20B=C3=BChler?= <david.buhler@cea.fr>
Date: Tue, 30 Apr 2024 16:35:43 +0200
Subject: [PATCH] [Ivette] Fixes icon of notifications, that have always the
 proper kind.

---
 ivette/src/ivette/display.tsx    | 13 +++++++------
 ivette/src/ivette/laboratory.tsx |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/ivette/src/ivette/display.tsx b/ivette/src/ivette/display.tsx
index 6e7e68c4234..af1bdad3bd5 100644
--- a/ivette/src/ivette/display.tsx
+++ b/ivette/src/ivette/display.tsx
@@ -124,14 +124,15 @@ export function useComponentStatus(
   return Laboratory.getComponentStatus(state, id ?? '');
 }
 
-export type ShortMessage = undefined | null | string;
-export type Message = ShortMessage | Laboratory.Notification;
-export type Warning = ShortMessage | { label: string, title: string };
+export type Message = string | { label: string, title: string };
 
 /** Message notification */
 export function showMessage(msg: Message): void {
   if (!msg) return;
-  Laboratory.showMessage(typeof msg === 'string' ? { label: msg } : msg);
+  const short = typeof msg === 'string';
+  const label = short ? msg : msg.label;
+  const title = short ? msg : msg.title;
+  Laboratory.showMessage({ kind: "message", label, title });
 }
 
 /** Warning notification. */
@@ -139,7 +140,7 @@ export function showWarning(msg: Message): void {
   if (!msg) return;
   const short = typeof msg === 'string';
   const label = short ? msg : msg.label;
-  const title = short ? msg : undefined;
+  const title = short ? msg : msg.title;
   Laboratory.showMessage({ kind: 'warning', label, title });
 }
 
@@ -148,7 +149,7 @@ export function showError(msg: Message): void {
   if (!msg) return;
   const short = typeof msg === 'string';
   const label = short ? msg : msg.label;
-  const title = short ? msg : undefined;
+  const title = short ? msg : msg.title;
   Laboratory.showMessage({ kind: 'error', label, title });
 }
 
diff --git a/ivette/src/ivette/laboratory.tsx b/ivette/src/ivette/laboratory.tsx
index 6413e137811..5b56d653195 100644
--- a/ivette/src/ivette/laboratory.tsx
+++ b/ivette/src/ivette/laboratory.tsx
@@ -913,7 +913,7 @@ function LayoutMenu(): JSX.Element | null {
 type NotificationKind = 'message' | 'warning' | 'error';
 
 export interface Notification {
-  kind?: NotificationKind;
+  kind: NotificationKind;
   label: string;
   title?: string;
 }
-- 
GitLab