Skip to content

Add CustomAlert HOC with primary/secondary CTA support#7539

Draft
kruulik wants to merge 7 commits intomainfrom
agent-briefing-card
Draft

Add CustomAlert HOC with primary/secondary CTA support#7539
kruulik wants to merge 7 commits intomainfrom
agent-briefing-card

Conversation

@kruulik
Copy link
Contributor

@kruulik kruulik commented Mar 2, 2026

Ticket

Description Of Changes

Adds a CustomAlert HOC to fidesui that wraps Ant Design's Alert component with support for primaryAction and secondaryAction props. When provided, these render styled CTA buttons below the alert's message/description content. Button colors are derived from the alert's type via ConfigProvider, so warning alerts get orange buttons, error alerts get red, etc.

The Ant Design action prop (top-right slot) is preserved and passes through unchanged. All existing Alert usages across the codebase are fully backwards-compatible since the new props are optional.

image

Code Changes

  • clients/fidesui/src/hoc/CustomAlert.tsx - New HOC wrapping Alert with primaryAction/secondaryAction props and type-aware button colors via ConfigProvider
  • clients/fidesui/src/hoc/CustomAlert.module.scss - Flexbox layout for the action button container
  • clients/fidesui/src/hoc/CustomAlert.stories.tsx - Storybook story with a briefing-style alert example and type selector
  • clients/fidesui/src/hoc/index.tsx - Added barrel export
  • clients/fidesui/src/index.ts - Moved Alert from direct antd re-export to HOC layer; added AlertProps and AlertAction type exports

Steps to Confirm

turbo run storybook from clients and check Custom/Alerts
Verify existing Alert usages (e.g. in DatasetEditorSection, ConsentBreakdownModal) are visually unchanged

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • No migrations
  • Documentation:
    • No documentation updates required

Wraps Ant Design Alert with `primaryAction` and `secondaryAction` props
that render type-aware CTA buttons below the alert content.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Mar 3, 2026 5:55pm
fides-privacy-center Ignored Ignored Mar 3, 2026 5:55pm

Request Review

@kruulik kruulik marked this pull request as ready for review March 2, 2026 17:02
@kruulik kruulik requested a review from a team as a code owner March 2, 2026 17:02
@kruulik kruulik requested review from jpople and removed request for a team March 2, 2026 17:02
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Added a CustomAlert HOC that extends Ant Design's Alert component with optional primaryAction and secondaryAction props. The implementation uses Ant Design's Flex component for layout and ConfigProvider to dynamically set button colors based on the alert type (success, info, warning, error).

Key changes:

  • New CustomAlert HOC in clients/fidesui/src/hoc/CustomAlert.tsx with type-aware button styling
  • Moved Alert export from direct antd import to the HOC layer while maintaining full backwards compatibility
  • Added AlertAction and AlertProps type exports
  • Included Storybook story demonstrating the briefing-style alert pattern

Note: The PR description mentions a .module.scss file that doesn't exist in the changes. The implementation uses inline styles with Ant Design's Flex component instead, which is cleaner and more consistent with the Ant Design approach.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, well-documented, and follows React best practices. The HOC pattern properly extends Ant Design's Alert component while maintaining backwards compatibility through optional props. Only one minor style suggestion was identified (using Flex instead of div in Storybook decorator). No logical errors, security issues, or breaking changes detected.
  • No files require special attention

Important Files Changed

Filename Overview
clients/fidesui/src/hoc/CustomAlert.stories.tsx Storybook story with example usage; uses div element in decorator where Flex component would be preferred
clients/fidesui/src/hoc/CustomAlert.tsx Clean HOC implementation wrapping Ant Design Alert with primary/secondary CTA support using Flex layout and ConfigProvider for type-aware button colors
clients/fidesui/src/index.ts Moved Alert from direct antd export to HOC layer; added AlertProps and AlertAction type exports while maintaining backwards compatibility

Last reviewed commit: 6983488

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@speaker-ender speaker-ender left a comment

Choose a reason for hiding this comment

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

Only reviewed and left feedback on storybook related changes

export interface AlertAction {
label: React.ReactNode;
onClick: () => void;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like there might be a situation where we would want to, e.g., disable one of the actions, or configure them more in some other way-- would it be reasonable to use a type based on ButtonProps here?

@kruulik kruulik marked this pull request as draft March 6, 2026 20:04
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.

3 participants