Skip to content

Update codeaction menu options availability#2233

Draft
KCSAbeywickrama wants to merge 4 commits into
wso2:release/bi-1.8.xfrom
KCSAbeywickrama:dm-cus-trn-fn-rm-blb
Draft

Update codeaction menu options availability#2233
KCSAbeywickrama wants to merge 4 commits into
wso2:release/bi-1.8.xfrom
KCSAbeywickrama:dm-cus-trn-fn-rm-blb

Conversation

@KCSAbeywickrama
Copy link
Copy Markdown
Contributor

@KCSAbeywickrama KCSAbeywickrama commented May 13, 2026

Purpose

Fixes wso2/product-integrator#1493

Summary by CodeRabbit

  • Bug Fixes
    • Refined availability of "Map Using Custom Function" and "Map Using Transform Function" options based on context conditions to ensure they appear only when appropriate.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@KCSAbeywickrama has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 31 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53e37515-325c-4c9e-a4b2-a525e96d3960

📥 Commits

Reviewing files that changed from the base of the PR and between 7ae4afa and 3a5bb2e.

📒 Files selected for processing (1)
  • workspaces/ballerina/data-mapper/src/components/Diagram/Label/ExpressionLabelWidget.tsx
📝 Walkthrough

Walkthrough

The ExpressionLabelWidget's code action command-building logic adds a conditional check to prevent custom function and transform function actions from being offered when they would hang on record type mappings during variable declaration.

Changes

Function Action Gating for Record Types

Layer / File(s) Summary
Code action gating logic
workspaces/ballerina/data-mapper/src/components/Diagram/Label/ExpressionLabelWidget.tsx
Introduces shouldFnsIncluded boolean derived from context.reusable, context.views.length, and target port fieldFQN to conditionally include "Map Using Custom Function" and "Map Using Transform Function" code actions.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A map that hung on records so tall,
Now gated functions won't be called,
With checks so wise, so swift, so neat,
The hanging dance skips to its beat!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is severely incomplete, providing only the issue link without addressing any required template sections (Goals, Approach, testing, security, etc.). Complete the PR description template including Goals, Approach, test coverage details, security checks, and other required 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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change - updating code action menu options availability for custom and transform function actions.
Linked Issues check ✅ Passed The code changes successfully address issue #1493 by gating custom and transform function actions behind a shouldFnsIncluded condition to prevent hangs on record type mappings.
Out of Scope Changes check ✅ Passed All changes to ExpressionLabelWidget are directly scoped to fixing issue #1493 regarding code action menu availability for custom and transform function actions.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
Contributor

Copilot AI left a 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 updates the Data Mapper expression label code-action menu to align option availability with context (reusable mode / multi-view / nested field FQN), addressing wso2/product-integrator#1493.

Changes:

  • Gate “Custom Function” and “Transform Function” code actions behind a shared shouldFnsIncluded condition.
  • Rename menu titles to “Map Using Custom Function” / “Map Using Transform Function” for consistency.
Comments suppressed due to low confidence (1)

workspaces/ballerina/data-mapper/src/components/Diagram/Label/ExpressionLabelWidget.tsx:265

  • shouldFnsIncluded uses link.getTargetPort().attributes.fieldFQN.includes('.') without guarding for link/targetPort/fieldFQN being undefined (the model types allow link?, and temporary links may not have a target yet). To avoid a render-time crash, consider reusing the already computed targetPort (link?.getTargetPort()) and optional-chain the fieldFQN access, defaulting the condition to false when missing.
    const shouldFnsIncluded = context.reusable ||
        context.views.length !== 1 ||
        (link.getTargetPort() as InputOutputPortModel).attributes.fieldFQN.includes('.');

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@workspaces/ballerina/data-mapper/src/components/Diagram/Label/ExpressionLabelWidget.tsx`:
- Around line 263-265: The conditional computing shouldFnsIncluded uses
link.getTargetPort() unsafely; reuse the previously obtained targetPort (from
link?.getTargetPort()) and guard access with optional chaining so it won't
dereference null: compute shouldFnsIncluded by referencing context and
targetPort (e.g., (targetPort as InputOutputPortModel)?.attributes?.fieldFQN) or
checking targetPort exists before calling attributes.fieldFQN, ensuring no
direct call to link.getTargetPort() when link may be undefined.
- Around line 263-265: The conditional computing shouldFnsIncluded can throw
when getTargetPort() or attributes.fieldFQN is undefined; update the expression
that currently casts and calls .includes on (link.getTargetPort() as
InputOutputPortModel).attributes.fieldFQN to use optional chaining and a safe
fallback (e.g., treat missing fieldFQN as an empty string) so the includes call
is always on a string; apply the same null-safe pattern in ExpressionLabelWidget
(shouldFnsIncluded) and the analogous check in MappingOptionsWidget to prevent
runtime crashes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 93a1100d-532d-4fe4-9d70-a64065120daf

📥 Commits

Reviewing files that changed from the base of the PR and between afd0331 and 7ae4afa.

📒 Files selected for processing (1)
  • workspaces/ballerina/data-mapper/src/components/Diagram/Label/ExpressionLabelWidget.tsx

@KCSAbeywickrama KCSAbeywickrama marked this pull request as draft May 14, 2026 05:46
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