refactor: merge cluster service arrays into record#33
Draft
matejvasek wants to merge 1 commit into
Draft
Conversation
useClusterService returned Knative Services and Deployments as separate arrays. Consumers had to manually correlate them by revision label, and a naming bug stored the ksvc in a field called "deployment". The hook now returns a Record<string, ClusterFunctionInfo> with pre-correlated pairs. The revision-matching logic moves into the hook, simplifying every consumer to a single record lookup. Renamed the misleading field to "knativeService" on FunctionTableItem and fixed the test fixture to use an actual Knative Service object. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors cluster resource consumption by changing useClusterService to return a correlated record of Knative Service + Deployment info per function name, moving revision-based matching logic out of FunctionsListPage into the hook, and updating consumers/tests accordingly.
Changes:
- Refactor
useClusterServiceto returnfunctions: Record<string, ClusterFunctionInfo>with ksvc/deployment correlation bylatestReadyRevisionName(fallback to function label). - Simplify
FunctionsListPageto use the correlated record, and renameFunctionTableItem.deployment→knativeService(since it actually held a Knative Service). - Update/expand tests to match the new API and to cover correlation/error scenarios.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/function-list/FunctionsListPage.tsx | Switches list enrichment from ad-hoc array matching to record lookup and renames stored Knative resource field. |
| src/pages/function-list/FunctionsListPage.test.tsx | Updates cluster service mocks/fixtures to the new return shape; removes list-page revision matching test now covered at the hook level. |
| src/pages/function-list/components/FunctionTable.tsx | Renames delete target prop to knativeService and updates FunctionTableItem accordingly. |
| src/pages/function-list/components/FunctionTable.test.tsx | Fixes fixture to use a real Knative Service object and updates expectations for delete modal invocation. |
| src/pages/function-create/FunctionCreatePage.test.tsx | Adjusts mocked useClusterService return shape. |
| src/common/services/cluster/useClusterService.ts | Implements the new correlated functions record and centralizes revision-based pairing logic. |
| src/common/services/cluster/useClusterService.test.tsx | Adds/updates tests for correlation behavior and error propagation with the new return type. |
| docs/features.json | Documents the refactor work item in the feature checklist. |
| docs/claude-progress.txt | Updates the progress log with the work completed in this refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useClusterServicereturn type from{ knativeServices[], deployments[] }to{ functions: Record<string, ClusterFunctionInfo> }with pre-correlated ksvc/deployment pairsFunctionsListPageinto the hookdeploymentfield toknativeServiceonFunctionTableItem(the field held a Knative Service, not a Deployment)FunctionTable.test.tsxfixture to use an actual Knative Service object instead of a DeploymentTest plan
yarn lintpasses (0 errors, 0 warnings)yarn testpasses (14 suites, 129 tests)🤖 Generated with Claude Code