Skip to content

Disable selecting non-immediate child organizations in selective user share tree#10474

Open
SujanSanjula96 wants to merge 1 commit into
wso2:masterfrom
SujanSanjula96:fix/restrict-selective-share-to-direct-sub-orgs
Open

Disable selecting non-immediate child organizations in selective user share tree#10474
SujanSanjula96 wants to merge 1 commit into
wso2:masterfrom
SujanSanjula96:fix/restrict-selective-share-to-direct-sub-orgs

Conversation

@SujanSanjula96

Copy link
Copy Markdown
Contributor

Purpose

Related Issues

  • N/A

Related PRs

  • N/A

Checklist

  • e2e cypress tests locally verified. (for internal contributers)
  • Manual test round performed and verified.
  • UX/UI review done on the final implementation.
  • Documentation provided. (Add links if there are any)
  • Relevant backend changes deployed and verified
  • Unit tests provided. (Add links if there are any)
  • Integration tests provided. (Add links if there are any)

Security checks

Developer Checklist (Mandatory)

  • Complete the Developer Checklist in the related product-is issue to track any behavioral change or migration impact.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a restrictToImmediateChildOrgs boolean prop to SelectiveOrgShareWithSelectiveRoles. When enabled, non-immediate descendant org nodes are selection-disabled in the tree, render a disabled checkbox, and display read-only roles. Agent and user share forms now pass this prop instead of userId.

Changes

Selective org share restriction

Layer / File(s) Summary
Core helper and prop definition
features/common.ui.shared-access.v1/components/selective-org-share-with-selective-roles.tsx
Adds isOrgSelectionDisabled (disables non-immediate children when restrictToImmediateChildOrgs is active), renderSelectionCheckbox (shows disabled checkbox instead of blank gap), updates read-only role condition from userId-based to restrictToImmediateChildOrgs-based, and wires both into RichTreeView via isItemSelectionDisabled and slotProps.
Agent and user form wiring
features/admin.agents.v1/components/edit/share-agent-form.tsx, features/admin.users.v1/components/share-user-form.tsx
Replaces userId={agent?.id} / userId={user?.id} with restrictToImmediateChildOrgs={true} in both share forms.

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Changeset Required ❌ Error No new .changeset/*.md file is included; the only changeset markdown present is .changeset/README.md, which is excluded. Add a new .changeset/*.md file listing the changed packages and version bumps, including the affected @wso2is/* package(s).
Description check ⚠️ Warning The template is present, but the Purpose section is empty and the checklist/security/developer items are not completed. Add a brief purpose summary, any related issue/PR links, and fill in the relevant testing, security, and developer checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: blocking selection of non-immediate child organizations in the share tree.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ create changeset

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.

@SujanSanjula96
SujanSanjula96 force-pushed the fix/restrict-selective-share-to-direct-sub-orgs branch from 3999ebd to e964c3f Compare June 26, 2026 08:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 @.changeset/restrict-selective-share-direct-sub-orgs.md:
- Around line 2-3: The changeset includes an unrelated bump for `@wso2is/i18n`
even though the diff only changes common.ui.shared-access.v1 and reuses existing
translation keys. Update the changeset entry to keep only the package that
actually changed, and use the correct bump type for that package so the release
metadata matches the real code changes.

In
`@features/common.ui.shared-access.v1/components/selective-org-share-with-selective-roles.tsx`:
- Around line 945-953: The org tree is using isOrgSelectionDisabled to disable
items, which also prevents expanding or focusing parent nodes and blocks access
to descendants. Update the selective-org-share-with-selective-roles tree logic
so restricted orgs remain interactive but cannot be selected: remove the use of
item-disabling behavior and enforce the restriction in the item interaction
handlers instead. Keep expansion/collapse working for nodes rendered by the tree
view while only ignoring selection for restricted orgs, preserving the
descendant read-only flow in the related hierarchy logic.
🪄 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.yml

Review profile: CHILL

Plan: Pro

Run ID: d970ba28-090c-40ec-8887-a0b6c400d210

📥 Commits

Reviewing files that changed from the base of the PR and between 0651514 and 3999ebd.

📒 Files selected for processing (2)
  • .changeset/restrict-selective-share-direct-sub-orgs.md
  • features/common.ui.shared-access.v1/components/selective-org-share-with-selective-roles.tsx

Comment on lines +2 to +3
"@wso2is/common.ui.shared-access.v1": patch
"@wso2is/i18n": patch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

@wso2is/i18n looks unrelated to this PR’s actual file changes.

I only see a common.ui.shared-access.v1 source change in this cohort, and the TSX diff reuses existing translation keys. Keeping Line 3 will publish @wso2is/i18n without evidence of a package change here. As per coding guidelines, changesets should include the packages that actually changed with the appropriate bump type.

🤖 Prompt for 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.

In @.changeset/restrict-selective-share-direct-sub-orgs.md around lines 2 - 3,
The changeset includes an unrelated bump for `@wso2is/i18n` even though the diff
only changes common.ui.shared-access.v1 and reuses existing translation keys.
Update the changeset entry to keep only the package that actually changed, and
use the correct bump type for that package so the release metadata matches the
real code changes.

Source: Coding guidelines

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.73%. Comparing base (05c202e) to head (80dcfa5).
⚠️ Report is 100 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #10474    +/-   ##
========================================
  Coverage   72.72%   72.73%            
========================================
  Files         469      469            
  Lines       70888    70908    +20     
  Branches      484      240   -244     
========================================
+ Hits        51555    51572    +17     
- Misses      19037    19225   +188     
+ Partials      296      111   -185     

see 187 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@SujanSanjula96
SujanSanjula96 force-pushed the fix/restrict-selective-share-to-direct-sub-orgs branch 2 times, most recently from 80dcfa5 to cac34d2 Compare June 26, 2026 09:13
@SujanSanjula96
SujanSanjula96 force-pushed the fix/restrict-selective-share-to-direct-sub-orgs branch from cac34d2 to 2de8ffc Compare June 30, 2026 06:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
features/common.ui.shared-access.v1/components/selective-org-share-with-selective-roles.tsx (1)

1249-1258: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Read-only descendant pane is still unreachable.

Restricted descendants never make it into selectedItems, so the earlier !selectedItems.includes(selectedOrgId) return still wins before this new branch runs. Clicking a non-immediate org therefore shows the generic “select from left panel” state instead of the intended read-only roles view.

Suggested fix
-        if (!hideLeftPanel && !disableOrgSelection && !selectedItems.includes(selectedOrgId)) {
-            return (
-                <Box className="role-list-container center">
-                    { t("applications:edit.sections.sharedAccess.toManageOrganizationSelectLeftPanel") }
-                </Box>
-            );
-        }
-
         // When sharing is restricted to immediate child organizations (user and agent sharing),
         // non-immediate sub-organizations (whose parent is not the root organization) do not have their
         // own sharing policy. Their role assignments are inherited and cannot be modified. Show a
         // read-only view of the currently assigned roles instead.
         const selectedOrgParentId: string | undefined = flatOrganizationMap[selectedOrgId]?.parentId;
         const isNonImmediateOrgInUserSharing: boolean =
             restrictToImmediateChildOrgs &&
             !isEmpty(selectedOrgId) &&
             !isEmpty(selectedOrgParentId) &&
             selectedOrgParentId !== organizationId;
+
+        if (
+            !hideLeftPanel &&
+            !disableOrgSelection &&
+            !selectedItems.includes(selectedOrgId) &&
+            !isNonImmediateOrgInUserSharing
+        ) {
+            return (
+                <Box className="role-list-container center">
+                    { t("applications:edit.sections.sharedAccess.toManageOrganizationSelectLeftPanel") }
+                </Box>
+            );
+        }
🤖 Prompt for 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.

In
`@features/common.ui.shared-access.v1/components/selective-org-share-with-selective-roles.tsx`
around lines 1249 - 1258, The read-only descendant view in
selective-org-share-with-selective-roles.tsx is still unreachable because the
earlier selectedItems guard returns before the new non-immediate-org branch can
run. Update the selection flow around the logic that uses selectedItems,
selectedOrgId, and isNonImmediateOrgInUserSharing so that restricted descendants
bypass the “select from left panel” early return and reach the read-only roles
pane. Keep the existing immediate-child/org-sharing checks intact, but reorder
or refine the conditions so non-immediate descendants are handled explicitly.
🤖 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.

Duplicate comments:
In
`@features/common.ui.shared-access.v1/components/selective-org-share-with-selective-roles.tsx`:
- Around line 1249-1258: The read-only descendant view in
selective-org-share-with-selective-roles.tsx is still unreachable because the
earlier selectedItems guard returns before the new non-immediate-org branch can
run. Update the selection flow around the logic that uses selectedItems,
selectedOrgId, and isNonImmediateOrgInUserSharing so that restricted descendants
bypass the “select from left panel” early return and reach the read-only roles
pane. Keep the existing immediate-child/org-sharing checks intact, but reorder
or refine the conditions so non-immediate descendants are handled explicitly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 2cbd92d8-8efe-46ce-ba6f-033c1b41a017

📥 Commits

Reviewing files that changed from the base of the PR and between 3999ebd and 2de8ffc.

📒 Files selected for processing (3)
  • features/admin.agents.v1/components/edit/share-agent-form.tsx
  • features/admin.users.v1/components/share-user-form.tsx
  • features/common.ui.shared-access.v1/components/selective-org-share-with-selective-roles.tsx

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