Enforce publishing library projects when deploying workspace to Devant#1526
Enforce publishing library projects when deploying workspace to Devant#1526kanushka merged 8 commits intowso2:release/bi-1.8.xfrom
Conversation
…on, proxyEndpointUrl, proxyApiContext, and proxyAccessibility optional
…ved accuracy in metadata processing
… remove unnecessary state management
…onents and update comments for clarity
…ralButton component
📝 WalkthroughWalkthroughFour files were modified to enhance library component handling in component forms and improve validation logic. Changes include a tooltip message update, guards preventing library component deselection, broadened Git validation triggers for multi-component mode, and simplified state management by deriving validation results directly from query data. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx (1)
282-339:⚠️ Potential issue | 🟡 MinorAdd validation to prevent batch submission when only library components are selected.
Library components cannot be deselected in the UI, but users can deselect all non-library components. If only libraries remain selected,
componentRequestsbecomes empty after filtering out libraries at lines 284–287, thensubmitBatchComponentCreatereceives an empty array with no validation.Add a guard after line 339:
Proposed fix
.filter((req): req is NonNullable<typeof req> => req !== null); + if (componentRequests.length === 0) { + console.warn("No deployable components available (only libraries selected)"); + return; + } + // Use batch API for optimized creation with single progress notificationAlso consider disabling the "Next" button when only libraries are selected, so users receive earlier feedback instead of submitting with no deployable components.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx` around lines 282 - 339, The batch creation flow currently builds componentRequests from selectedToCreate but filters out library components, which can yield an empty array and then call submitBatchComponentCreate with no deployable items; after the componentRequests construction (variable componentRequests), add a guard that if componentRequests.length === 0 you surface a user-facing error/notification and return early (do not call submitBatchComponentCreate) to prevent empty submissions; additionally, compute a boolean (e.g., hasDeployable = selectedToCreate.some(s => s.componentType !== "library")) and use it to disable the "Next" button in the form UI so users cannot proceed when only libraries are selected (update the button’s disabled prop and any related submit handler that invokes submitBatchComponentCreate).
🧹 Nitpick comments (2)
workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx (1)
224-231: Indentation is inconsistent with the surrounding JSX.Lines 224–231 break from the indentation level used by sibling elements (e.g.,
{/* Component Info */}at line 231 is on the same line as the closing</div>). This appears to be a copy-paste artifact. Consider re-indenting this block to match the rest of the component's JSX structure.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx` around lines 224 - 231, The JSX block containing the checkbox is mis-indented and merges the closing </div> with the following comment; fix the formatting in MultiComponentSelector.tsx by re-indenting the Checkbox block to match sibling JSX (ensure the {/* Checkbox */} comment, the <div className="mt-0.5 shrink-0" ...> wrapper, the VSCodeCheckbox props including checked={isSelected}, disabled={isLibrary || undefined}, onChange={(e) => handleComponentToggle(index, e.target.checked)}, and the closing </div> each sit on their own properly indented lines so the subsequent {/* Component Info */} comment is on its own line and aligned with other section comments).workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/ComponentFormGenDetailsSection.tsx (1)
228-230:useCallbackdependency onvalidationQueryobject defeats memoization.
validationQueryis a new object reference on each render, sovalidateComponentsPushedis re-created every time. Consider depending on the specific fields used (validationQuery.data,validationQuery.isStale,validationQuery.refetch) instead.Proposed fix
+ const { data: validationData, isStale: isValidationStale, refetch: refetchValidation } = validationQuery; + const validateComponentsPushed = useCallback( async (options?: { force?: boolean }): Promise<boolean> => { if (!shouldRunValidation) { return true; } // If we have fresh cached data and not forcing, reuse it - if (!options?.force && validationQuery.data && !validationQuery.isStale) { - const invalidCount = validationQuery.data.invalidCount ?? 0; + if (!options?.force && validationData && !isValidationStale) { + const invalidCount = validationData.invalidCount ?? 0; return invalidCount === 0; } - const result = await validationQuery.refetch(); + const result = await refetchValidation(); const invalidCount = result.data?.invalidCount ?? 0; return invalidCount === 0; }, - [shouldRunValidation, validationQuery], + [shouldRunValidation, validationData, isValidationStale, refetchValidation], );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/ComponentFormGenDetailsSection.tsx` around lines 228 - 230, The validateComponentsPushed callback is being re-created each render because it depends on the whole validationQuery object; change the dependency list to reference the specific properties used (e.g., validationQuery.data, validationQuery.isStale, validationQuery.refetch) along with shouldRunValidation so memoization works correctly; update the useCallback dependency array in the validateComponentsPushed definition to use those specific symbols instead of validationQuery.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx`:
- Around line 136-140: Replace the hardcoded string "library" with the enum
constant ChoreoComponentType.Library in all three occurrences: inside
MultiComponentSelector.tsx where you check component?.componentType ===
"library" (in the deselect guard and the other comparison around the checkbox
logic referencing selectedComponents, component and checked), and the occurrence
in ComponentFormView.tsx; update those comparisons to use
ChoreoComponentType.Library so they reference the imported enum instead of a
magic string.
---
Outside diff comments:
In
`@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx`:
- Around line 282-339: The batch creation flow currently builds
componentRequests from selectedToCreate but filters out library components,
which can yield an empty array and then call submitBatchComponentCreate with no
deployable items; after the componentRequests construction (variable
componentRequests), add a guard that if componentRequests.length === 0 you
surface a user-facing error/notification and return early (do not call
submitBatchComponentCreate) to prevent empty submissions; additionally, compute
a boolean (e.g., hasDeployable = selectedToCreate.some(s => s.componentType !==
"library")) and use it to disable the "Next" button in the form UI so users
cannot proceed when only libraries are selected (update the button’s disabled
prop and any related submit handler that invokes submitBatchComponentCreate).
---
Nitpick comments:
In
`@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/ComponentFormGenDetailsSection.tsx`:
- Around line 228-230: The validateComponentsPushed callback is being re-created
each render because it depends on the whole validationQuery object; change the
dependency list to reference the specific properties used (e.g.,
validationQuery.data, validationQuery.isStale, validationQuery.refetch) along
with shouldRunValidation so memoization works correctly; update the useCallback
dependency array in the validateComponentsPushed definition to use those
specific symbols instead of validationQuery.
In
`@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx`:
- Around line 224-231: The JSX block containing the checkbox is mis-indented and
merges the closing </div> with the following comment; fix the formatting in
MultiComponentSelector.tsx by re-indenting the Checkbox block to match sibling
JSX (ensure the {/* Checkbox */} comment, the <div className="mt-0.5 shrink-0"
...> wrapper, the VSCodeCheckbox props including checked={isSelected},
disabled={isLibrary || undefined}, onChange={(e) => handleComponentToggle(index,
e.target.checked)}, and the closing </div> each sit on their own properly
indented lines so the subsequent {/* Component Info */} comment is on its own
line and aligned with other section comments).
| // Prevent deselecting library components | ||
| const component = selectedComponents.find((c) => c.index === index); | ||
| if (component?.componentType === "library" && !checked) { | ||
| return; // Library components cannot be deselected | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for "library" as a component type across the codebase
echo "=== Search for 'library' string in TypeScript files ==="
rg -n '"library"' workspaces/ -g '*.ts' -g '*.tsx' | head -50
echo ""
echo "=== Check for componentType enum or constant definitions ==="
rg -n -B2 -A5 'enum.*ComponentType\|const.*ComponentType' workspaces/ -g '*.ts' -g '*.tsx' | head -80
echo ""
echo "=== Search for ChoreoComponentType references ==="
rg -n 'ChoreoComponentType' workspaces/ -g '*.ts' -g '*.tsx' | head -30
echo ""
echo "=== Check ComponentFormView.tsx around line 284 ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx" ]; then
sed -n '280,290p' workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx
fiRepository: wso2/vscode-extensions
Length of output: 7372
🏁 Script executed:
#!/bin/bash
echo "=== Check enums.ts for Library/LIBRARY constant definitions ==="
if [ -f "workspaces/wso2-platform/wso2-platform-core/src/enums.ts" ]; then
sed -n '110,135p' workspaces/wso2-platform/wso2-platform-core/src/enums.ts
fi
echo ""
echo "=== Check what imports are in MultiComponentSelector.tsx ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx" ]; then
head -50 workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx | grep -E "^import|^from"
fi
echo ""
echo "=== Check what imports are in ComponentFormView.tsx ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx" ]; then
head -50 workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx | grep -E "^import|^from"
fiRepository: wso2/vscode-extensions
Length of output: 2161
🏁 Script executed:
#!/bin/bash
echo "=== Verify ChoreoComponentType import in MultiComponentSelector.tsx ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx" ]; then
sed -n '1,30p' workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx | grep -A5 "import.*ChoreoComponentType"
fi
echo ""
echo "=== Verify ChoreoComponentType import in ComponentFormView.tsx ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx" ]; then
sed -n '1,50p' workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx | grep "ChoreoComponentType"
fi
echo ""
echo "=== Check the full context around line 284 in ComponentFormView.tsx ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx" ]; then
sed -n '1,100p' workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx | grep -n "import"
fiRepository: wso2/vscode-extensions
Length of output: 1731
🏁 Script executed:
#!/bin/bash
echo "=== Full import block from ComponentFormView.tsx lines 22-42 ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx" ]; then
sed -n '22,42p' workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx
fi
echo ""
echo "=== Full import block from ComponentFormView.tsx lines 51-64 ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx" ]; then
sed -n '51,64p' workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx
fi
echo ""
echo "=== Verify MultiComponentSelector.tsx has ChoreoComponentType import ==="
if [ -f "workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx" ]; then
sed -n '1,50p' workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx
fiRepository: wso2/vscode-extensions
Length of output: 3378
Replace the magic string "library" with the existing enum constant ChoreoComponentType.Library.
The string "library" is hardcoded in three locations (lines 138, 193 in MultiComponentSelector.tsx and line 284 in ComponentFormView.tsx). Since ChoreoComponentType is already imported in both files and includes a Library member, use ChoreoComponentType.Library instead to maintain consistency with the rest of the codebase and avoid silent breakage if the enum value changes.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/MultiComponentSelector.tsx`
around lines 136 - 140, Replace the hardcoded string "library" with the enum
constant ChoreoComponentType.Library in all three occurrences: inside
MultiComponentSelector.tsx where you check component?.componentType ===
"library" (in the deselect guard and the other comparison around the checkbox
logic referencing selectedComponents, component and checked), and the occurrence
in ComponentFormView.tsx; update those comparisons to use
ChoreoComponentType.Library so they reference the imported enum instead of a
magic string.
Purpose
$title
Related to: wso2/product-ballerina-integrator#2328
Summary by CodeRabbit
New Features
Improvements