Skip to content

add system alerts banner component in order to display alerts via jso… #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

SaqAsh
Copy link

@SaqAsh SaqAsh commented May 14, 2025

Pull Request

Description

Add a flexible SystemAlerts component that supports both env-based and prop-based alert inputs, similarly implemented in virusseq, where inspiration was taken.

Addresses ticket #227

Type of change

Please choose only the relevant options and remove the others.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

  • [X]Renders alerts from hardcoded alerts prop and verifies display persists when not dismissed.
  • [X]Parses alerts from NEXT_PUBLIC_SYSTEM_ALERTS and confirm dismissal removes alert from subsequent renders.
  • Confirm that local storage is storing the key via chrome developer tools

Checklist:

You do not need to fullfill all requirements of this checklist, select all that apply:

  • [X ] My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • [X ] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Additional context

A lot of the code was straight from the virus seq portal, the key difference that I had was that I separated types for ease of readability as well as added an outline which would be one shade darker than the background color for appropriate distinction as per the exemplar.

@@ -0,0 +1,95 @@
import { default as defaultTheme, default as theme } from '@/components/theme';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultTheme and theme are referring to the same object default
this can be one import

@@ -0,0 +1,95 @@
import { default as defaultTheme, default as theme } from '@/components/theme';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add copyright

export const SystemAlert: React.FC<Props> = ({ alert, onClose }) => {
const { backgroundColor, icon, textColor, outline } = AlertVariants[alert.level];

const createMarkup = (msg: string) => ({ __html: msg });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is pretty pointless. it's used once, not exported, created on every render and all it does is put a string into an object. This can be moved inline to where it's called. something like:

dangerouslySetInnerHTML={{_html:alert.message}}

@@ -0,0 +1,27 @@
export type AlertLevel = 'info' | 'warning' | 'critical';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add copyright

@@ -0,0 +1,31 @@
import { ReactElement } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add copyright

@ciaranschutte
Copy link
Contributor

@SaqAsh couple of comments to get started with. I need to double check some of the css theme usage tomorrow

@ciaranschutte ciaranschutte self-requested a review May 21, 2025 13:03
@SaqAsh SaqAsh merged commit ceb3d3e into overture-stack:feature/bannerComponent May 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants