-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add validation hooks to surface prerequisites for installation mutations #1388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…mutations Add useInstallationValidation hook that exposes validation state (canCreate, canUpdate, canDelete) and detailed error information. This makes it clear to developers when prerequisites are missing before attempting mutations. Changes: - Created useInstallationValidation hook with canCreate/canUpdate/canDelete flags - Updated useCreateInstallation to expose canCreate and validationErrors - Updated useUpdateInstallation to expose canUpdate and validationErrors - Updated useDeleteInstallation to expose canDelete and validationErrors - Exported useInstallationValidation from headless index Benefits: - Developers can check validation state before calling mutations - Clearer error messaging about what's missing (no integration, no installation, etc.) - Enables UI to disable buttons or show warnings proactively 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds upfront validation capabilities to installation mutation hooks, allowing developers to check prerequisites before attempting operations. Previously, validation errors were only discoverable after calling mutation functions.
Key Changes:
- Introduced
useInstallationValidationhook for centralized validation logic - Enhanced mutation hooks (
useCreateInstallation,useUpdateInstallation,useDeleteInstallation) to expose validation state - Added public export of the new validation hook
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/headless/installation/useInstallationValidation.ts | New hook providing validation flags and detailed error states for installation operations |
| src/headless/installation/useCreateInstallation.ts | Enhanced to expose canCreate and validationErrors from validation hook |
| src/headless/installation/useUpdateInstallation.ts | Enhanced to expose canUpdate and validationErrors from validation hook |
| src/headless/installation/useDeleteInstallation.ts | Enhanced to expose canDelete and validationErrors from validation hook |
| src/headless/index.ts | Added public export for useInstallationValidation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| const { integrationNameOrId } = useInstallationProps(); | ||
| const { data: integrationObj } = useIntegrationQuery(integrationNameOrId); | ||
| const { installation } = useInstallation(); | ||
| const { canDelete, validationErrors } = useInstallationValidation(); |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The useInstallationValidation hook internally calls useIntegrationQuery and useInstallation, resulting in duplicate hook calls since these are already invoked on lines 25-26. This creates redundant queries and state management. Consider refactoring useInstallationValidation to accept integrationObj and installation as parameters to avoid duplicate hook invocations.
| const { canDelete, validationErrors } = useInstallationValidation(); | |
| const { canDelete, validationErrors } = useInstallationValidation(integrationObj, installation); |
| const { integrationNameOrId } = useInstallationProps(); | ||
| const { data: integrationObj } = useIntegrationQuery(integrationNameOrId); | ||
| const { installation } = useInstallation(); | ||
| const { canUpdate, validationErrors } = useInstallationValidation(); |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The useInstallationValidation hook internally calls useIntegrationQuery and useInstallation, resulting in duplicate hook calls since these are already invoked on lines 31-32. This creates redundant queries and state management. Consider refactoring useInstallationValidation to accept integrationObj and installation as parameters to avoid duplicate hook invocations.
| const { canUpdate, validationErrors } = useInstallationValidation(); | |
| const { canUpdate, validationErrors } = useInstallationValidation(integrationObj, installation); |
| const { data: integrationObj } = useIntegrationQuery(integrationNameOrId); | ||
| const { connection } = useConnection(); | ||
| const { installation } = useInstallation(); | ||
| const { canCreate, validationErrors } = useInstallationValidation(); |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The useInstallationValidation hook internally calls useIntegrationQuery and useInstallation, resulting in duplicate hook calls since these are already invoked on lines 32 and 34. This creates redundant queries and state management. Consider refactoring useInstallationValidation to accept integrationObj and installation as parameters to avoid duplicate hook invocations.
| const { canCreate, validationErrors } = useInstallationValidation(); | |
| const { canCreate, validationErrors } = useInstallationValidation(integrationObj, installation); |
Summary
useInstallationValidationhook that exposes clear validation statescanCreate,canUpdate,canDeleteflagsvalidationErrorsobject for better developer experienceChanges
New hook:
useInstallationValidation- centralized validation logiccanCreate,canUpdate,canDeleteboolean flagsvalidationErrorsobject with detailed error statesinstallationandintegrationObjfor convenienceUpdated hooks:
useCreateInstallation- now exportscanCreateandvalidationErrorsuseUpdateInstallation- now exportscanUpdateandvalidationErrorsuseDeleteInstallation- now exportscanDeleteandvalidationErrorsWhy
Previously, developers had to call mutation functions to discover validation errors. Now validation state is exposed upfront, allowing:
Example Usage