Skip to content

Conversation

@reneshen0328
Copy link
Contributor

@reneshen0328 reneshen0328 commented Oct 15, 2025

What

Before this PR: user cannot create shared link, remove shared link, or change access dropdown
After this PR: updateSharedLink and share API call (created and used by existing contentSharingV1) are called and user can update access dropdown, user can create shared link, and user can remove shared link successfully.

Testing:

Summary by CodeRabbit

  • New Features

    • Added explicit create/delete shared link actions and a separate "change access" action.
    • Shared-link handling split into distinct update vs. remove callbacks to improve clarity and control.
  • Bug Fixes

    • Removing a shared link now updates item state without resetting displayed server URL or enterprise name.
  • Tests

    • Expanded tests cover create, change-access, update, and delete flows and validate the new update/remove callback behavior.

@reneshen0328 reneshen0328 requested review from a team as code owners October 15, 2025 21:52
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

createSharingService splits the single onSuccess callback into onUpdateSharedLink and onRemoveSharedLink, adds createSharedLink/changeSharedLinkAccess/deleteSharedLink methods, updates hook wiring and tests to use the new callbacks, and uses ACCESS_NONE for deletion flows.

Changes

Cohort / File(s) Summary
Sharing service core
src/elements/content-sharing/sharingService.ts
Replaces single onSuccess with onUpdateSharedLink and onRemoveSharedLink in createSharingService args; renames props/type; adds createSharedLink, changeSharedLinkAccess, and deleteSharedLink; uses ACCESS_NONE for deletions and CONTENT_SHARING_SHARED_LINK_UPDATE_PARAMS for update calls.
Hook integration
src/elements/content-sharing/hooks/useSharingService.ts
Renames handler to handleUpdateSharedLink, adds handleRemoveSharedLink; passes { onUpdateSharedLink, onRemoveSharedLink } to createSharingService; removal handler clears sharedLink while preserving other item fields.
Service tests
src/elements/content-sharing/__tests__/sharingService.test.ts
Adds ACCESS_NONE import; replaces onSuccess mock with mockOnUpdateSharedLink and mockOnRemoveSharedLink; introduces createSharingServiceWrapper; tests for changeSharedLinkAccess, createSharedLink, and deleteSharedLink; verifies itemApi.share calls and correct handler routing/params.
Hook tests
src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts
Calls createSharingService with new { onUpdateSharedLink, onRemoveSharedLink } handlers and itemApiInstance as {}; adds mocks for deleteSharedLink, changeSharedLinkAccess, createSharedLink, updateSharedLink; introduces mockConvertedData; asserts state changes for update and remove flows for file and folder types.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Hook as useSharingService
  participant Service as createSharingService
  participant ItemAPI

  rect rgba(227,242,253,0.5)
  note right of Hook: Initialization
  User->>Hook: useSharingService()
  Hook->>Service: createSharingService({ onUpdateSharedLink, onRemoveSharedLink })
  end

  rect rgba(232,245,233,0.5)
  note left of User: Create / Update shared link
  User->>Hook: createSharedLink() / updateSharedLink(...)
  Hook->>Service: createSharedLink()/updateSharedLink(...)
  Service->>ItemAPI: share(..., onUpdateSharedLink, CONTENT_SHARING_SHARED_LINK_UPDATE_PARAMS)
  ItemAPI-->>Service: itemData
  Service-->>Hook: onUpdateSharedLink(itemData)
  end

  rect rgba(255,243,224,0.5)
  note right of User: Change access
  User->>Hook: changeSharedLinkAccess(access)
  Hook->>Service: changeSharedLinkAccess(access)
  Service->>ItemAPI: share(access, onUpdateSharedLink, CONTENT_SHARING_SHARED_LINK_UPDATE_PARAMS)
  ItemAPI-->>Service: itemData
  Service-->>Hook: onUpdateSharedLink(itemData)
  end

  rect rgba(255,235,238,0.6)
  note right of User: Delete shared link
  User->>Hook: deleteSharedLink()
  Hook->>Service: deleteSharedLink()
  Service->>ItemAPI: share(ACCESS_NONE, onRemoveSharedLink, CONTENT_SHARING_SHARED_LINK_UPDATE_PARAMS)
  ItemAPI-->>Service: itemData
  Service-->>Hook: onRemoveSharedLink(itemData)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • tjuanitas
  • jfox-box
  • jpan-box

Poem

A twitch of whiskers, links realigned,
I hop through handlers, tidy and kind.
Create, update, or tuck links away,
ACCESS_NONE saves the day.
🥕 — the rabbit tests with joy and play

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the primary feature implemented—defining the content-sharing service for shared link operations and access control—and follows the conventional feat(scope): summary format without extraneous details.
Description Check ✅ Passed The pull request description clearly explains the before-and-after behavior, provides links for manual testing of creating, removing, and updating shared links, and includes the required ready-to-merge label instructions exactly as specified in the repository template.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch create-changeSharedLinkAccess-createSharedLink-deleteSharedLink

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b39a482 and 1bf0665.

📒 Files selected for processing (4)
  • src/elements/content-sharing/__tests__/sharingService.test.ts (7 hunks)
  • src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (7 hunks)
  • src/elements/content-sharing/hooks/useSharingService.ts (1 hunks)
  • src/elements/content-sharing/sharingService.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/elements/content-sharing/hooks/useSharingService.ts (2)
src/elements/content-sharing/utils/convertItemResponse.ts (1)
  • convertItemResponse (8-109)
src/elements/content-sharing/sharingService.ts (1)
  • createSharingService (31-94)
src/elements/content-sharing/__tests__/sharingService.test.ts (1)
src/elements/content-sharing/sharingService.ts (1)
  • createSharingService (31-94)
src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (2)
src/elements/content-sharing/utils/convertItemResponse.ts (1)
  • convertItemResponse (8-109)
src/elements/content-sharing/sharingService.ts (1)
  • createSharingService (31-94)
src/elements/content-sharing/sharingService.ts (2)
src/elements/content-sharing/__tests__/useSharedLink.test.js (2)
  • handleUpdateSharedLinkSuccess (21-21)
  • handleRemoveSharedLinkSuccess (20-20)
src/elements/content-sharing/utils/convertSharingServiceData.ts (1)
  • convertSharedLinkPermissions (16-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bf0665 and fd2a1f6.

📒 Files selected for processing (1)
  • src/elements/content-sharing/hooks/useSharingService.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/elements/content-sharing/hooks/useSharingService.ts (3)
src/elements/content-sharing/__tests__/useSharedLink.test.js (2)
  • handleUpdateSharedLinkSuccess (21-21)
  • handleRemoveSharedLinkSuccess (20-20)
src/elements/content-sharing/utils/convertItemResponse.ts (1)
  • convertItemResponse (8-109)
src/elements/content-sharing/sharingService.ts (1)
  • createSharingService (31-94)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint_test_build
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Summary
🔇 Additional comments (3)
src/elements/content-sharing/hooks/useSharingService.ts (3)

46-50: LGTM!

The rename from handleSuccess to handleUpdateSharedLinkSuccess clarifies the handler's purpose. The logic correctly merges previous and updated shared link data.


58-61: LGTM!

The onSuccess object structure correctly matches the updated createSharingService API expectations, providing both handleUpdateSharedLinkSuccess and handleRemoveSharedLinkSuccess handlers.


63-63: LGTM!

The createSharingService invocation correctly passes the onSuccess object containing both handlers, aligning with the updated service API.

@reneshen0328 reneshen0328 force-pushed the create-changeSharedLinkAccess-createSharedLink-deleteSharedLink branch from 4e682a5 to 020f1aa Compare October 15, 2025 22:35
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: 0

🧹 Nitpick comments (1)
src/elements/content-sharing/sharingService.ts (1)

89-95: Consider alphabetical ordering for consistency.

The returned methods are almost alphabetically ordered, but createSharedLink appears first. Consider this ordering for consistency:

 return {
-    createSharedLink,
     changeSharedLinkAccess,
     changeSharedLinkPermission,
+    createSharedLink,
     deleteSharedLink,
     updateSharedLink,
 };

However, this is purely a stylistic preference and not required.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e682a5 and 2a09934.

📒 Files selected for processing (4)
  • src/elements/content-sharing/__tests__/sharingService.test.ts (8 hunks)
  • src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (7 hunks)
  • src/elements/content-sharing/hooks/useSharingService.ts (1 hunks)
  • src/elements/content-sharing/sharingService.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/elements/content-sharing/hooks/useSharingService.ts
🧰 Additional context used
🧬 Code graph analysis (3)
src/elements/content-sharing/__tests__/sharingService.test.ts (1)
src/elements/content-sharing/sharingService.ts (1)
  • createSharingService (29-96)
src/elements/content-sharing/sharingService.ts (1)
src/elements/content-sharing/utils/convertSharingServiceData.ts (1)
  • convertSharedLinkPermissions (16-25)
src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (2)
src/elements/content-sharing/utils/convertItemResponse.ts (1)
  • convertItemResponse (8-109)
src/elements/content-sharing/sharingService.ts (1)
  • createSharingService (29-96)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (14)
src/elements/content-sharing/__tests__/sharingService.test.ts (4)

1-23: LGTM! Clean test setup with good patterns.

The test file setup is well-structured:

  • ACCESS_NONE import supports deletion flows
  • Mock callbacks clearly separate update vs. remove concerns
  • The wrapper function eliminates duplication across tests

68-90: Good test coverage for changeSharedLinkAccess.

The parameterized test covers multiple access levels and properly validates the share API call with the correct parameters.


92-111: createSharedLink test validates undefined access behavior.

The test correctly verifies that undefined is passed as the access parameter, allowing the backend to set the default access level.


113-132: deleteSharedLink test properly validates removal flow.

The test correctly verifies:

  • ACCESS_NONE is used for deletion
  • onRemoveSharedLink callback is invoked instead of onUpdateSharedLink
src/elements/content-sharing/sharingService.ts (5)

2-2: LGTM! ACCESS_NONE import supports deletion flows.


22-27: LGTM! Callback split enables distinct update and removal handling.

The split from a single onSuccess callback into onUpdateSharedLink and onRemoveSharedLink provides better semantic clarity and allows different handling for update vs. delete operations.


37-45: LGTM! changeSharedLinkAccess properly invokes share API.


69-77: Good practice documenting undefined behavior.

The inline comment clearly explains that undefined allows the backend to set the default access level, which addresses the previous reviewer's feedback.


79-87: LGTM! deleteSharedLink correctly uses ACCESS_NONE and removal callback.

The implementation properly:

  • Uses ACCESS_NONE to signal deletion to the backend
  • Invokes onRemoveSharedLink for distinct removal handling
src/elements/content-sharing/hooks/__tests__/useSharingService.test.ts (5)

16-21: LGTM! Mock service includes all new methods.


47-50: Good refactor introducing shared test fixture.

The mockConvertedData fixture eliminates duplication and makes tests more maintainable.


113-134: LGTM! Test validates createSharingService call for TYPE_FILE.

The test properly verifies that both callbacks are passed and the options are correctly structured.


136-160: Excellent test coverage for both update and remove callbacks.

These tests properly:

  • Extract callbacks from the mock calls
  • Invoke them with mock data
  • Verify convertItemResponse is called
  • Assert setItem and setSharedLink are invoked

163-212: LGTM! Folder tests mirror file tests for consistency.

The tests for TYPE_FOLDER properly cover the same scenarios as TYPE_FILE, ensuring both item types are handled correctly.

@mergify mergify bot added the queued label Oct 16, 2025
@mergify mergify bot merged commit 2f7185d into master Oct 16, 2025
10 checks passed
@mergify mergify bot deleted the create-changeSharedLinkAccess-createSharedLink-deleteSharedLink branch October 16, 2025 16:56
@mergify mergify bot removed the queued label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants