AI-specific guidance for working with the nmstate-console-plugin codebase.
This is an OpenShift console dynamic plugin for kubernetes-nmstate. It provides UI views for managing node network configuration policies, states, physical networks, and topology visualization.
Stack: React 18, TypeScript, PatternFly 6, OpenShift Dynamic Plugin SDK, Webpack, i18next
src/
├── console-models/ # K8s resource model definitions (K8sModel objects)
├── nmstate-types/ # NMState CRD types and custom models
├── utils/
│ ├── components/ # Shared UI components (Loading, HelpTextIcon, etc.)
│ ├── hooks/ # Shared React hooks (useNMStateTranslation, etc.)
│ ├── flags/ # Feature flag detection (NMState operator presence)
│ ├── resources/ # K8s resource fetching utilities
│ └── telemetry/ # Usage tracking
├── views/
│ ├── policies/ # NodeNetworkConfigurationPolicy CRUD
│ │ ├── manifest.ts # Plugin extension registration
│ │ ├── list/ # List page component
│ │ ├── details/ # Details page component
│ │ ├── new/ # Create/edit form
│ │ ├── actions/ # Action menu items
│ │ └── components/ # Policy-specific UI components
│ ├── states/ # NodeNetworkState list + details
│ ├── physical-networks/ # Physical network overview
│ └── nodenetworkconfiguration/ # Topology visualization (PatternFly Topology)
├── __mocks__/ # Jest mocks for SDK and i18n
└── plugin-manifest.ts # Root plugin metadata and extension aggregation
Each view has a manifest.ts that exports:
{View}ExposedModules— maps module names to file paths for code splitting{View}Extensions— array ofEncodedExtensionobjects defining console nav items, pages, and templates
These are aggregated in the root plugin-manifest.ts.
Models live in src/console-models/ as individual files exporting K8sModel objects. Each model defines apiGroup, apiVersion, kind, plural, and a GroupVersionKind constant. Import models via @models path alias.
Defined in tsconfig.json:
@images/*→images/*@utils/*→src/utils/*@models→src/console-models/index.ts
For coding standards (component rules, PatternFly usage, i18n, linting), see CONTRIBUTING.md.
Key details for code generation:
- Translation keys use the
plugin__nmstate-console-plugin~prefix - In manifest files, use
%plugin__nmstate-console-plugin~Label%syntax for nav item names - Shared hooks (used in 2+ components) live in
src/utils/hooks/; single-use hooks must be co-located with the component that uses them — do not add to shared utils - One component per file — utility functions, types (aside from props), and constants go in a
utils/folder within the component's directory - Prefer PatternFly utility classes (e.g.,
pf-v6-u-mt-md) over custom CSS for spacing and layout
- No global state library — uses OpenShift SDK's
useK8sWatchResourcefor K8s data - Local component state via React
useState/useReducer
For full coding standards, linting rules, testing, and PR process, see CONTRIBUTING.md.
- React components:
PascalCase.tsx - Utilities, hooks, constants:
camelCase.ts - Directories for components use PascalCase, directories for hooks use camelCase, all other directories use kebab-case
- Each view directory has a
manifest.ts,constants.ts, and optionallyutils.ts
- Webpack builds the plugin as a dynamic console remote module
- Deployed via Helm chart (
deployment/nmstate-console-plugin/) or OpenShift templates (oc-manifest.yaml) - Container images published to
quay.io/nmstate/nmstate-console-plugin
When reviewing changes to this codebase:
- SDK compatibility — verify that
@openshift-console/dynamic-plugin-sdkAPIs are used correctly; the SDK version must match the target release branch (e.g.,release-4.22uses SDK 4.22.x) - i18n — all user-visible strings must use the
useNMStateTranslationhook or theTranscomponent; never hardcode English text - PatternFly — use PatternFly components and PF utility classes instead of custom HTML/CSS; follow PatternFly 6 patterns
- Type safety —
strictisfalsein tsconfig, but new code should use explicit types - Model consistency — new K8s resources need a model in
console-models/, a manifest entry, and registration inplugin-manifest.ts - No direct K8s API calls — use the OpenShift SDK hooks (
useK8sWatchResource,k8sCreate,k8sPatch, etc.) - Component isolation — one component per file; single-use hooks stay co-located with their component, not in shared
utils/hooks/ - Naming conventions — new resource utility files should use
selectors.ts(notgetters.ts); some older directories still usegetters.tsbut the project is migrating to theselectorsnaming