Update to latest API event types#325
Conversation
WalkthroughThis update introduces new event reason types, corresponding detail types, and translation entries related to device ownership, fleet operations, internal task failures, and repository status. It expands the event model, augments exported types, and updates UI mapping for event titles, with minor corrections to existing translation keys. Changes
Sequence Diagram(s)sequenceDiagram
participant System
participant EventModel
participant UI
participant i18n
System->>EventModel: Emit event with new reason (e.g., DEVICE_OWNERSHIP_CHANGED)
EventModel->>UI: Pass event details (including new detail types)
UI->>i18n: Lookup translation for event reason
i18n-->>UI: Return localized title
UI-->>User: Display event with correct title and details
Possibly related PRs
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
libs/types/models/FleetSelectorProcessingCompletedDetails.ts (1)
23-25: Specify the unit/format ofprocessingDuration
processingDurationis a plainstring; without a contract (e.g. ISO-8601 duration, milliseconds) consumers can’t reliably parse or sort this value. Consider tightening the type to something likeDurationISO8601or at least documenting the expected format in the comment.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
libs/i18n/locales/en/translation.json(2 hunks)libs/types/index.ts(3 hunks)libs/types/models/DeviceMultipleOwnersDetectedDetails.ts(1 hunks)libs/types/models/DeviceMultipleOwnersResolvedDetails.ts(1 hunks)libs/types/models/DeviceOwnershipChangedDetails.ts(1 hunks)libs/types/models/Event.ts(2 hunks)libs/types/models/EventDetails.ts(1 hunks)libs/types/models/FleetSelectorProcessingCompletedDetails.ts(1 hunks)libs/types/models/InternalTaskFailedDetails.ts(1 hunks)libs/types/models/ResourceUpdatedDetails.ts(1 hunks)libs/ui-components/src/components/Events/useEvents.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (3)
libs/i18n/locales/en/translation.json (2)
Learnt from: celdrake
PR: flightctl/flightctl-ui#207
File: libs/ui-components/src/components/Device/EditDeviceWizard/steps/ReviewDeviceStep.tsx:55-55
Timestamp: 2025-02-04T09:04:36.106Z
Learning: The codebase has automated CI checks ("lint" step) that verify translation coverage for all text strings, ensuring that new or modified strings have corresponding entries in translation files.
Learnt from: celdrake
PR: flightctl/flightctl-ui#201
File: libs/i18n/locales/en/translation.json:67-67
Timestamp: 2025-01-24T11:50:31.860Z
Learning: In translation JSON files, it's valid and common to have identical key-value pairs when the text is a plain string without variables or special formatting.
libs/types/models/FleetSelectorProcessingCompletedDetails.ts (2)
Learnt from: celdrake
PR: flightctl/flightctl-ui#227
File: libs/ui-components/src/components/Device/EditDeviceWizard/EditDeviceWizard.tsx:87-87
Timestamp: 2025-03-12T09:09:44.139Z
Learning: The `getUpdatePolicyValues` function in libs/ui-components/src/components/Fleet/CreateFleet/fleetSpecUtils.ts is designed to handle undefined input through its optional parameter definition and consistent use of optional chaining.
Learnt from: celdrake
PR: flightctl/flightctl-ui#227
File: libs/ui-components/src/components/Device/EditDeviceWizard/EditDeviceWizard.tsx:87-87
Timestamp: 2025-03-12T09:09:44.139Z
Learning: The `getUpdatePolicyValues` function in libs/ui-components/src/components/Fleet/CreateFleet/fleetSpecUtils.ts is designed to safely handle undefined values for the updatePolicy parameter.
libs/types/index.ts (4)
Learnt from: celdrake
PR: flightctl/flightctl-ui#0
File: :0-0
Timestamp: 2025-02-17T08:41:57.993Z
Learning: All files in `libs/types/models` are auto-generated using OpenAPI Generator from the schema defined in https://github.com/flightctl/flightctl/blob/main/api/v1alpha1/openapi.yaml. Changes to these files should be made in the schema instead of modifying the generated files directly.
Learnt from: celdrake
PR: flightctl/flightctl-ui#240
File: libs/types/models/FileSpec.ts:8-8
Timestamp: 2025-03-20T12:34:33.199Z
Learning: Files in the types directory are autogenerated from the OpenAPI spec in the flightctl project and should not be directly modified.
Learnt from: celdrake
PR: flightctl/flightctl-ui#227
File: libs/ui-components/src/components/Device/EditDeviceWizard/EditDeviceWizard.tsx:87-87
Timestamp: 2025-03-12T09:09:44.139Z
Learning: The `getUpdatePolicyValues` function in libs/ui-components/src/components/Fleet/CreateFleet/fleetSpecUtils.ts is designed to handle undefined input through its optional parameter definition and consistent use of optional chaining.
Learnt from: celdrake
PR: flightctl/flightctl-ui#227
File: libs/ui-components/src/components/Device/EditDeviceWizard/EditDeviceWizard.tsx:87-87
Timestamp: 2025-03-12T09:09:44.139Z
Learning: The `getUpdatePolicyValues` function in libs/ui-components/src/components/Fleet/CreateFleet/fleetSpecUtils.ts is designed to safely handle undefined values for the updatePolicy parameter.
🧬 Code Graph Analysis (5)
libs/types/models/InternalTaskFailedDetails.ts (1)
libs/types/index.ts (1)
InternalTaskFailedDetails(103-103)
libs/types/models/EventDetails.ts (6)
libs/types/models/ResourceUpdatedDetails.ts (1)
ResourceUpdatedDetails(5-22)libs/types/models/DeviceOwnershipChangedDetails.ts (1)
DeviceOwnershipChangedDetails(5-18)libs/types/models/DeviceMultipleOwnersDetectedDetails.ts (1)
DeviceMultipleOwnersDetectedDetails(5-14)libs/types/models/DeviceMultipleOwnersResolvedDetails.ts (1)
DeviceMultipleOwnersResolvedDetails(5-22)libs/types/models/InternalTaskFailedDetails.ts (1)
InternalTaskFailedDetails(5-26)libs/types/models/FleetSelectorProcessingCompletedDetails.ts (1)
FleetSelectorProcessingCompletedDetails(5-26)
libs/ui-components/src/components/Events/useEvents.ts (1)
libs/types/models/Event.ts (1)
Event(9-38)
libs/types/models/DeviceMultipleOwnersDetectedDetails.ts (1)
libs/types/index.ts (1)
DeviceMultipleOwnersDetectedDetails(43-43)
libs/types/models/DeviceMultipleOwnersResolvedDetails.ts (1)
libs/types/index.ts (1)
DeviceMultipleOwnersResolvedDetails(44-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: integration-tests
- GitHub Check: Build
- GitHub Check: Build ocp plugin
- GitHub Check: Lint
🔇 Additional comments (20)
libs/types/models/ResourceUpdatedDetails.ts (1)
6-9: LGTM! Discriminator property added correctly.The addition of the
detailTypediscriminator property is well-implemented and follows TypeScript best practices for union type discrimination. The string literal type and documentation are appropriate.libs/types/models/DeviceMultipleOwnersDetectedDetails.ts (1)
1-16: LGTM! Well-structured type definition.The
DeviceMultipleOwnersDetectedDetailstype is properly defined with:
- Appropriate discriminator property for type safety
- Clear documentation for each property
- Correct TypeScript typing with
Array<string>for fleet nameslibs/i18n/locales/en/translation.json (3)
331-331: LGTM! New translation entry added.The translation entry for "Git resource change detected" is appropriate and follows the established pattern.
338-338: Good cleanup of trailing space.Minor formatting improvement by removing the trailing space from the translation key.
351-363: LGTM! Comprehensive event reason translations added.All new translation entries are well-written and provide clear, user-friendly descriptions for the various event reasons related to:
- Device ownership conflicts and changes
- Device specification validation
- Enrollment request outcomes
- Internal task failures
- Repository accessibility
- Fleet reconciliation status
The translations align well with the new event detail types being introduced.
libs/types/models/DeviceOwnershipChangedDetails.ts (1)
1-20: LGTM! Well-designed ownership change type.The
DeviceOwnershipChangedDetailstype is properly structured with:
- Appropriate discriminator property for type safety
- Optional properties that correctly handle ownership scenarios (string | null)
- Clear documentation explaining the purpose of each property
- Proper handling of cases where no previous owner exists or ownership is removed
libs/types/models/InternalTaskFailedDetails.ts (1)
1-28: LGTM! Comprehensive internal task failure type.The
InternalTaskFailedDetailstype is well-designed with:
- Proper discriminator property for type safety
- Required properties (
taskType,errorMessage) for essential failure information- Optional properties (
retryCount,taskParameters) for additional context- Appropriate use of
Record<string, string>for task parameters- Clear documentation for all properties
The type provides good flexibility for representing various internal task failure scenarios.
libs/ui-components/src/components/Events/useEvents.ts (4)
46-53: Well-structured event reason mappings for resource and Git events.The additions follow the existing pattern and provide comprehensive coverage for the new event types. The
GIT_RESOURCE_CHANGE_DETECTEDmapping is properly integrated with the existing resource event mappings.
54-83: Comprehensive device event mappings with good categorization.The device-related event mappings are well-organized and cover ownership conflicts, specification validity, and enrollment scenarios. The categorization with comments enhances readability.
84-90: Complete coverage of internal task, repository, and fleet events.The mappings for internal task failures, repository accessibility, and fleet operations provide good coverage of the new event types. The human-readable descriptions are clear and actionable.
61-61: Minor whitespace fix applied correctly.The whitespace correction in the
DEVICE_MEMORY_WARNINGmapping maintains consistency with the translation structure.libs/types/models/EventDetails.ts (1)
5-14: Properly expanded EventDetails union type with comprehensive imports.The union type expansion correctly incorporates the new event detail types, and the imports are properly structured. Since this is an auto-generated file from the OpenAPI schema, the structure follows the expected pattern for discriminated unions.
libs/types/models/Event.ts (1)
50-83: Comprehensive Event.reason enum extension with proper categorization.The enum extension covers all the new event types systematically:
- Git resource detection
- Device ownership and specification events
- Enrollment request events
- Internal task failures
- Repository accessibility states
- Fleet operations
The values align correctly with the UI mappings in
useEvents.ts, ensuring consistency across the type system and user interface.libs/types/index.ts (3)
43-47: Proper type exports for device ownership event details.The exports correctly expose the new device ownership-related types, with
DeviceMultipleOwnersDetectedDetailsandDeviceOwnershipChangedDetailsas type exports, andDeviceMultipleOwnersResolvedDetailsas a value export (including the enum).
84-84: Appropriate value export for fleet selector processing details.The
FleetSelectorProcessingCompletedDetailsvalue export properly exposes the type and its associated enum for fleet processing events.
103-103: Correctly positioned internal task failure details export.The
InternalTaskFailedDetailstype export is properly positioned and maintains the alphabetical ordering of the exports.libs/types/models/DeviceMultipleOwnersResolvedDetails.ts (2)
5-22: Well-structured discriminated union type for device ownership resolution.The type definition properly implements the discriminated union pattern with:
- A fixed
detailTypediscriminator for type safety- Required
resolutionTypeenum for resolution method- Optional nullable
assignedOwnerfor the final owner- Optional
previousMatchingFleetsarray for audit trailThis structure provides comprehensive information about ownership conflict resolution while maintaining type safety.
23-32: Comprehensive resolution type enum with clear semantics.The
resolutionTypeenum covers the key resolution scenarios:
SINGLE_MATCH: One fleet matched after conflict resolutionNO_MATCH: No fleets matched after resolutionFLEET_DELETED: Conflict resolved by fleet deletionThe enum values are self-documenting and cover the expected resolution pathways.
libs/types/models/FleetSelectorProcessingCompletedDetails.ts (2)
5-26: Well-structured discriminator & mandatory fields
The type cleanly follows the “discriminator + detail payload” pattern used elsewhere and covers all required attributes.
31-35: Double-check enum string literals with backend contract
The enum exports'SelectorUpdated' | 'FleetDeleted' | 'DeviceLabelsUpdated'. Make sure these exact Pascal-case literals are emitted by the API; any mismatch (e.g. snake-case or different capitalisation) will break client-side narrow typing.
Adds the latest event reasons from
mainas well from the branch adding internal tasks events.Summary by CodeRabbit
New Features
Bug Fixes