A shared component library for Red Hat Insights projects, specifically designed for Advanced Cluster Management (ACM) and OpenShift Cluster Manager (OCM).
This repository provides reusable React components built with PatternFly that serve the common needs of both ACM and OCM applications. The components are designed to be generic enough to accommodate both products while maintaining consistency and reducing code duplication.
- Shared Components: Reusable React components for ACM and OCM
- PatternFly Integration: Built on top of PatternFly React components
- TypeScript Support: Fully typed components with TypeScript
- Storybook: Interactive component documentation and development environment
- Testing: Comprehensive unit tests with Jest and React Testing Library
- Modern Tooling: Vite, modern JavaScript features, and fast HMR
View our live component documentation and examples at:
https://redhatinsights.github.io/nxtcm-components/
The documentation site is automatically updated when changes are merged to the main branch and provides interactive examples of all components.
- Node.js 24.15+ (see
engines.nodeinpackage.json)
# Clone the repository
git clone https://github.com/RedHatInsights/nxtcm-components.git
cd nxtcm-components
# Install dependencies
npm install
# Start development server
npm start
# Or start Storybook
npm run storybook-
Clone the repository:
git clone https://github.com/RedHatInsights/nxtcm-components.git cd nxtcm-components -
Install dependencies:
npm install
Once published, you can install this package in your project:
npm install nxtcm-componentsTo develop and test components in isolation:
npm run storybookThis will start Storybook on http://localhost:6006 where you can interact with components and see their documentation.
To build the library for production:
npm run buildThis creates a dist folder with the compiled components.
Run all unit tests:
npm testRun tests in watch mode:
npm test:watchRun playwright tests:
npx playwright testRun playwright component tests:
npm run test-ctStryker is a mutation testing framework. Mutation testing measures how effective your tests are at catching bugs — not just whether they pass.
Stryker makes small, deliberate changes (mutants) to your source code — for example, flipping a condition, removing a statement, or changing an operator. For each mutant, it re-runs your tests:
- If a test fails, the mutant was killed — your tests caught the change.
- If all tests still pass, the mutant survived — your tests may not be exercising that behavior.
The mutation score (killed mutants ÷ total mutants) is a rough signal of test quality: are your tests actually detecting potential bugs, or only checking happy paths?
Our Stryker setup is scoped to individual components:
- Pass a component
.tsxfile as the target — not the spec file. - Stryker mutates that component and runs only the co-located Playwright component test (
ComponentName.spec.tsxnext toComponentName.tsx). - Jest unit tests are not run by Stryker today; only Playwright CT (
*.spec.tsx) specs are supported. - E2E tests are not included.
Reach for mutation testing anytime you are updating tests, reviewing a PR that touches specs, or suspect a component test is not fully exercising the component — for example, it passes but only covers rendering or a single happy path. It is also useful before refactoring, when you want confidence that existing tests would catch regressions.
From the repo root, pass one or more component paths after --:
npm run test:stryker -- packages/nxtcm-rosa-hcp-wizard/src/Steps/BasicSetup/ClusterWideProxy/ClusterWideProxy.tsxMultiple components in one run:
npm run test:stryker -- \
packages/nxtcm-rosa-hcp-wizard/src/Steps/BasicSetup/ClusterWideProxy/ClusterWideProxy.tsx \
packages/nxtcm-rosa-hcp-wizard/src/Footer/RosaHcpWizardFooter.tsxGenerate an HTML report when finished:
npm run test:stryker:report -- packages/nxtcm-rosa-hcp-wizard/src/Steps/BasicSetup/ClusterWideProxy/ClusterWideProxy.tsxLimit parallel workers on a laptop or while you are working on other tasks:
STRYKER_CONCURRENCY=2 npm run test:stryker -- path/to/Component.tsxYou can describe what you want to mutate in Cursor instead of assembling paths by hand. Attach or invoke the stryker-mutation-test skill (.agents/skills/stryker-mutation-test/SKILL.md) and ask in plain language — it will output a copy-paste command without running it.
Example prompt:
I want to run /stryker-mutation-test on all files that have tests located in nxtcm-components/packages/nxtcm-rosa-hcp-wizard/src/Steps/BasicSetup and its subdirectories
Mutation testing is slow. Each mutant spins up Playwright CT with a fresh cache and port. A single component can take several minutes; runs across many files or directories can take multiple hours, depending on mutant count and your machine. Plan accordingly — this is a local quality check, not part of CI.
When the run completes, Stryker prints a summary (mutation score, killed/survived counts). Paste that output into a chat if you want help interpreting survived mutants.
Run TypeScript type checking:
npm run type-checkFormat code with Prettier:
npm run prettier:fixStart the Vite development server:
npm startPreview the production build:
npm run previewnxtcm-components/
├── .github/ # GitHub configuration files
│ ├── REVIEW_PROCESS.md # PR review guidelines
│ └── pull_request_template.md
├── .storybook/ # Storybook configuration
├── public/ # Public assets
├── src/ # Source code
│ ├── index.ts # Main entry point
│ └── index.scss # Global styles
├── babel.config.js # Babel configuration (for Jest)
├── jest.config.js # Jest test configuration
├── jest.setup.js # Jest setup file
├── tsconfig.json # TypeScript configuration
└── vite.config.ts # Vite configuration
After installation, import components in your React application:
import { YourComponent } from 'nxtcm-components';
function App() {
return <YourComponent />;
}This library requires PatternFly CSS. Import it in your application:
// In your main application entry file (e.g., index.ts or App.tsx)
import '@patternfly/react-core/dist/styles/base.css';
import '@patternfly/patternfly/patternfly.css';Or include it in your HTML:
<link rel="stylesheet" href="node_modules/@patternfly/patternfly/patternfly.css">The components are designed to work seamlessly with both ACM and OCM projects. They use PatternFly's flexible design system to accommodate different requirements while maintaining consistency.
We welcome contributions! Please follow these guidelines:
- Fork the repository and create a feature branch
- Follow coding standards: Pre-commit hooks will automatically check your code
- Write tests: Add unit tests for new components or features
- Update documentation: Add or update Storybook stories
- Fill out the PR template: Provide clear description and testing steps
- Request reviews: Tag appropriate team members
See our Pull Request Template for detailed submission guidelines.
This repository uses Husky and lint-staged to automatically check code quality before every commit:
What happens when you commit:
- ✅ ESLint runs on staged TypeScript files and auto-fixes issues
- ✅ Prettier formats staged files automatically
- ✅ Only checks files you're committing (fast!)
- ❌ Commit is blocked if unfixable errors are found
Setup (Automatic):
npm install # Installs Git hooks automaticallyExample workflow:
# Make changes
vim src/components/MyComponent.tsx
# Stage changes
git add src/components/MyComponent.tsx
# Commit (hooks run automatically!)
git commit -m "feat: add MyComponent"
# → ESLint checks MyComponent.tsx
# → Prettier formats MyComponent.tsx
# → If all pass, commit succeeds ✅Bypass hooks (emergency only):
git commit --no-verify -m "emergency fix"--no-verify sparingly, as it bypasses all quality checks.
To test components in ACM or OCM applications:
- Build the component library:
npm run build - Link the package locally:
npm link
- In your ACM/OCM project:
npm link nxtcm-components
Alternatively, wait for the package to be published to npm and install it normally.
Components in this library follow these principles:
- Shared Foundation: Built on PatternFly components to ensure consistency
- Flexible but Opinionated: Generic enough for both ACM and OCM, but specific enough to provide value beyond raw PatternFly components
- Well-Tested: Every component includes unit tests
- Well-Documented: Storybook stories demonstrate usage and variants
- Accessible: Follow WCAG accessibility standards
- TypeScript First: Full type safety and IntelliSense support
- React 18: Modern React with hooks
- TypeScript: Type-safe component development
- PatternFly: Red Hat's open source design system
- Storybook: Component documentation and development
- Jest: Unit testing framework
- React Testing Library: Testing utilities
- Playwright: End-to-end and component testing
- Vite: Lightning-fast build tool and dev server
- ESLint: Code linting with React, TypeScript, and a11y rules
- Prettier: Code formatting
- Husky: Git hooks for pre-commit quality checks
- lint-staged: Run linters only on staged files
- SASS: CSS preprocessing
The repository includes the following configuration files:
| File | Purpose |
|---|---|
.eslintrc.json |
ESLint configuration with React, TypeScript, and accessibility rules |
.prettierrc |
Prettier code formatting rules |
.prettierignore |
Files to exclude from Prettier formatting |
.npmignore |
Files to exclude from npm package |
.husky/pre-commit |
Pre-commit Git hook (runs lint-staged) |
package.json → lint-staged |
Configuration for running linters on staged files |
tsconfig.json |
TypeScript compiler configuration |
vite.config.ts |
Vite build tool configuration |
jest.config.js |
Jest testing framework configuration |
playwright.config.ts |
Playwright E2E testing configuration |
.github/workflows/ci.yml |
GitHub Actions CI/CD pipeline |
This project uses GitHub Actions for CI/CD. On every pull request and push to main, the following checks run automatically:
- ✅ Lint: ESLint and Prettier checks
- ✅ Type Check: TypeScript compilation
- ✅ Unit Tests: Jest tests with coverage
- ✅ Build: Library build verification
- ✅ E2E Tests: Playwright end-to-end tests
- ✅ Storybook Build: Documentation build verification
See .github/workflows/ci.yml for the complete workflow configuration.
@redhat-cloud-services/nxtcm-dashboard and @redhat-cloud-services/nxtcm-rosa-hcp-wizard are published to npm via .github/workflows/publish-package.yml when a GitHub Release is published targeting main.
The release tag must match the package version in that workspace's package.json:
| Package | Tag pattern | Example (6.0.0) |
|---|---|---|
| Dashboard | nxtcm-dashboard-v{version} |
nxtcm-dashboard-v6.0.0 |
| ROSA HCP Wizard | nxtcm-rosa-hcp-wizard-v{version} |
nxtcm-rosa-hcp-wizard-v6.0.0 |
Tags that do not match either pattern will fail the workflow.
- Workflow resolves the package from the release tag
- Verifies the tag is reachable from
mainand matchespackage.jsonversion - Runs lint, type-check, unit tests, component tests, and build for that package
- Publishes to npm with provenance (requires
npm-publishenvironment approval)
- Bump
versionin the target package'spackage.json - Merge the version bump to
main - Create a GitHub Release on
mainwith the exact tag above - Approve the
npm-publishenvironment when prompted
| Command | Description |
|---|---|
npm start |
Start Vite dev server on port 4004 |
npm run storybook |
Start Storybook dev server on port 6006 |
npm run preview |
Preview production build locally |
| Command | Description |
|---|---|
npm run build |
Build library for production (outputs to dist/) |
npm run build-storybook |
Build static Storybook site |
| Command | Description |
|---|---|
npm run type-check |
Run TypeScript type checking without emitting files |
npm run lint |
Check code for linting errors (ESLint) |
npm run lint:fix |
Auto-fix linting errors where possible |
npm run prettier:check |
Check if files are formatted correctly |
npm run prettier:fix |
Auto-format code with Prettier |
| Command | Description |
|---|---|
npm test |
Run all unit tests with Jest |
npm run test:watch |
Run tests in watch mode |
npm run test:coverage |
Run tests with coverage report |
npm run test:e2e |
Run Playwright end-to-end tests |
npm run test:ct |
Run Playwright component tests |
npm run test:stryker -- <component.tsx> |
Run Stryker mutation testing on one or more component .tsx files |
npm run test:stryker:report -- <component.tsx> |
Same as test:stryker with an HTML mutation report |
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
For questions, issues, or contributions:
- Issues: GitHub Issues
- Pull Requests: GitHub PRs
- Review Process: See REVIEW_PROCESS.md