Skip to content

Enforce publishing library projects when deploying workspace to Devant#1526

Merged
kanushka merged 8 commits intowso2:release/bi-1.8.xfrom
madushajg:lib-deploy
Feb 20, 2026
Merged

Enforce publishing library projects when deploying workspace to Devant#1526
kanushka merged 8 commits intowso2:release/bi-1.8.xfrom
madushajg:lib-deploy

Conversation

@madushajg
Copy link
Member

@madushajg madushajg commented Feb 20, 2026

Purpose

$title

Related to: wso2/product-ballerina-integrator#2328

Summary by CodeRabbit

  • New Features

    • Git validation now triggers during multi-component form creation in addition to Devant mode
    • Library components are now locked and cannot be deselected, with visual indicators and tooltips explaining they are required
  • Improvements

    • Improved messaging clarity for Ballerina Central PAT configuration prompts

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

Four 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

Cohort / File(s) Summary
UI Tooltip Update
workspaces/ballerina/ballerina-visualizer/src/views/BI/PackageOverview/PublishToCentralButton.tsx
Updated tooltip message for missing Central PAT from generic "central PAT" to explicit "Ballerina Central PAT" for clarity.
Library Component Handling
workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/ComponentFormView.tsx, MultiComponentSelector.tsx
Added guards to prevent library component deselection. Library components are now skipped during batch creation and their checkboxes are disabled with explanatory tooltips.
Validation Logic Refactoring
workspaces/wso2-platform/wso2-platform-webviews/src/views/ComponentFormView/sections/ComponentFormGenDetailsSection.tsx
Broadened Git validation trigger to multi-component mode alongside Devant, removed local state management for validation error counts, and derived UI state directly from query results instead of redundant local state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Library components held tight,
No deselection in our sight,
Validation flows through query streams,
Cleaner state fulfills our dreams,
Guards ensure the right ones stay! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete and significantly deviates from the required template. It only provides Purpose with a title reference and a related issue link, but omits all other required sections including Goals, Approach, UI Component Development checklist, Release notes, Documentation, and other critical sections. Complete the PR description by filling in all required template sections: Goals, Approach (with UI screenshots/GIFs if applicable), relevant checklists, Release notes, Documentation links, and other applicable sections from the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: enforcing the publishing of library projects during workspace deployment to Devant, which aligns with the multiple file changes across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Add 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, componentRequests becomes empty after filtering out libraries at lines 284–287, then submitBatchComponentCreate receives 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 notification

Also 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: useCallback dependency on validationQuery object defeats memoization.

validationQuery is a new object reference on each render, so validateComponentsPushed is 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).

Comment on lines +136 to +140
// Prevent deselecting library components
const component = selectedComponents.find((c) => c.index === index);
if (component?.componentType === "library" && !checked) {
return; // Library components cannot be deselected
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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
fi

Repository: 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"
fi

Repository: 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"
fi

Repository: 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
fi

Repository: 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.

@kanushka kanushka merged commit 2f8d90c into wso2:release/bi-1.8.x Feb 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants