Skip to content

refactor(ui-react): extract shared Alert component#6389

Merged
gustavosbarreto merged 1 commit into
masterfrom
feature/alert-component
May 30, 2026
Merged

refactor(ui-react): extract shared Alert component#6389
gustavosbarreto merged 1 commit into
masterfrom
feature/alert-component

Conversation

@luannmoreira
Copy link
Copy Markdown
Member

@luannmoreira luannmoreira commented May 29, 2026

What

Added a shared Alert primitive to src/components/common/Alert.tsx and replaced 27 duplicated inline alert blocks across 22 files with it.

Why

Every page that needed to show an error, warning, or status message implemented its own <div> with duplicated Tailwind classes, icon imports, and inconsistent (or missing) ARIA attributes. Several success alerts used role="alert" when they should use role="status", and several others had no live-region semantics at all.

Changes

  • Alert.tsx: supports error | success | warning | info variants. Each variant maps to a colour token, icon, role, and aria-live value — error/warning use role=alert/assertive, success/info use role=status/polite. Accepts an optional onDismiss callback that renders a dismiss button with type="button" and aria-label="Dismiss alert". className is for layout overrides only (margins, display).

  • 22 consumer files: removed per-file ExclamationCircleIcon, CheckCircleIcon, and ExclamationTriangleIcon imports that existed solely to serve the inline alert block. Icons retained where they are used elsewhere in the file (e.g. ExclamationCircleIcon in MfaResetComplete for the expired-token error page, ExclamationTriangleIcon in Sessions for the table decorator).

  • Alert.test.tsx: 33 tests covering variant classes (bg/border/text), ARIA role and aria-live per variant, icon count, dismiss button presence/absence/click/type, className passthrough, and base layout classes.

Testing

./bin/docker-compose exec ui-react sh -c 'cd /src/apps/console && npx vitest run'
./bin/docker-compose exec ui-react sh -c 'cd /src/apps/console && npx tsc --noEmit'
./bin/docker-compose exec ui-react sh -c 'cd /src/apps/console && npx eslint src/'
./bin/docker-compose exec ui-react npm run build

All pass. Two visual edge cases worth checking in the browser:

  • /signup?email=test@example.com&sig=fakesig — invite warning (was items-start/py-3/rounded-lg; now standardised to items-center/py-2.5/rounded-md)
  • /profile → MFA → Disable → wrong OTP — error alert now includes animate-slide-down which the original block lacked

@luannmoreira luannmoreira requested a review from a team as a code owner May 29, 2026 20:04
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 29, 2026

Claude finished @luannmoreira's task in 9m 39s —— View job


Code Review Complete

Reviewed 24 files across code quality, security, testing, language patterns, and architecture — no issues found. The code looks good as-is.

The Alert component is well-structured: clean variant config pattern, proper ARIA semantics (role="alert"/"status" with matching aria-live), optional dismiss callback with correct type="button", and className for layout overrides. The 197-line test suite covers all variants, roles, content rendering, icon presence, dismiss behavior, and class passthrough. The 22 consumer migrations are faithful replacements of the previous inline markup — and several pages gain ARIA roles they were previously missing.

Note on merge: this branch was created before 39ed6aa landed on master. A rebase before merge will avoid any conflicts with the encoding utility changes on master.


If you push additional changes and want a new review, tag @shellhub-io/admin and a team member can trigger it.

27 duplicate inline alert blocks across 22 files had no consistent
ARIA semantics — success messages used role="alert" or no role at
all. The new Alert primitive centralises color, icon, and live-region
attributes (role=alert/assertive for error and warning; role=status/
polite for success and info) and ships with 33 unit tests.
@luannmoreira luannmoreira force-pushed the feature/alert-component branch from e7b2465 to 6c5c6f8 Compare May 29, 2026 20:15
@gustavosbarreto
Copy link
Copy Markdown
Member

/review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 30, 2026

Claude finished @gustavosbarreto's task in 1m 44s —— View job


Code Review Complete

Reviewed 24 files across code quality, security, testing, language patterns, and architecture — no issues found. The code looks good as-is.

The Alert component is well-structured: clean variant config pattern, proper ARIA semantics (role="alert"/"status" with matching aria-live), optional dismiss callback with correct type="button", and className for layout overrides. The 197-line test suite covers all variants, roles, content rendering, icon presence, dismiss behavior, and class passthrough. The 22 consumer migrations are faithful replacements of the previous inline markup — and several pages gain ARIA roles they were previously missing. All retained icon imports in consumer files are confirmed to be used elsewhere in their respective files.

Note on merge: this branch was created before 39ed6aa landed on master. A rebase before merge will avoid any conflicts with the encoding utility changes on master.


If you've addressed the feedback and want a new review, tag @shellhub-io/admin and a team member can trigger it.

@gustavosbarreto gustavosbarreto merged commit 2556ee0 into master May 30, 2026
32 checks passed
@gustavosbarreto gustavosbarreto deleted the feature/alert-component branch May 30, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants