From ad7149f26fce804e1a8f5bb5a93adc38e2d4587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Wed, 18 Oct 2023 10:32:19 +0100 Subject: [PATCH] refactor: move message banner interface to common file (#5076) https://linear.app/unleash/issue/2-1527/set-up-message-banner-interfaces Tiny refactor to move the message banner interface to its own file, since it will be used in multiple places. --- .../MessageBanner/MessageBanner.tsx | 15 +-------------- .../ExternalMessageBanners.tsx | 6 ++---- frontend/src/interfaces/messageBanner.ts | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 frontend/src/interfaces/messageBanner.ts diff --git a/frontend/src/component/messageBanners/MessageBanner/MessageBanner.tsx b/frontend/src/component/messageBanners/MessageBanner/MessageBanner.tsx index 150053694c31..2e7a3783291b 100644 --- a/frontend/src/component/messageBanners/MessageBanner/MessageBanner.tsx +++ b/frontend/src/component/messageBanners/MessageBanner/MessageBanner.tsx @@ -10,6 +10,7 @@ import { useNavigate } from 'react-router-dom'; import { MessageBannerDialog } from './MessageBannerDialog/MessageBannerDialog'; import { useState } from 'react'; import ReactMarkdown from 'react-markdown'; +import { BannerVariant, IMessageBanner } from 'interfaces/messageBanner'; const StyledBar = styled('aside', { shouldForwardProp: (prop) => prop !== 'variant' && prop !== 'sticky', @@ -42,20 +43,6 @@ const StyledIcon = styled('div', { color: theme.palette[variant].main, })); -type BannerVariant = 'warning' | 'info' | 'error' | 'success'; - -export interface IMessageBanner { - message: string; - variant?: BannerVariant; - sticky?: boolean; - icon?: string; - link?: string; - linkText?: string; - plausibleEvent?: string; - dialogTitle?: string; - dialog?: string; -} - interface IMessageBannerProps { messageBanner: IMessageBanner; } diff --git a/frontend/src/component/messageBanners/externalMessageBanners/ExternalMessageBanners.tsx b/frontend/src/component/messageBanners/externalMessageBanners/ExternalMessageBanners.tsx index 49eb0a8d0c33..ee991ca89c96 100644 --- a/frontend/src/component/messageBanners/externalMessageBanners/ExternalMessageBanners.tsx +++ b/frontend/src/component/messageBanners/externalMessageBanners/ExternalMessageBanners.tsx @@ -1,9 +1,7 @@ -import { - IMessageBanner, - MessageBanner, -} from 'component/messageBanners/MessageBanner/MessageBanner'; +import { MessageBanner } from 'component/messageBanners/MessageBanner/MessageBanner'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import { useVariant } from 'hooks/useVariant'; +import { IMessageBanner } from 'interfaces/messageBanner'; export const ExternalMessageBanners = () => { const { uiConfig } = useUiConfig(); diff --git a/frontend/src/interfaces/messageBanner.ts b/frontend/src/interfaces/messageBanner.ts new file mode 100644 index 000000000000..4cd168c88a24 --- /dev/null +++ b/frontend/src/interfaces/messageBanner.ts @@ -0,0 +1,19 @@ +export type BannerVariant = 'warning' | 'info' | 'error' | 'success'; + +export interface IMessageBanner { + message: string; + variant?: BannerVariant; + sticky?: boolean; + icon?: string; + link?: string; + linkText?: string; + plausibleEvent?: string; + dialogTitle?: string; + dialog?: string; +} + +export interface IInternalMessageBanner extends IMessageBanner { + id: number; + enabled: boolean; + createdAt: string; +}