Skip to content

[Port to dtq-dev] fix(bitstream): restore item UUID in edit redirect#1319

Merged
milanmajchrak merged 1 commit into
dataquest-dev:dtq-devfrom
ufal:backport-154-to-dtq-dev
Jun 23, 2026
Merged

[Port to dtq-dev] fix(bitstream): restore item UUID in edit redirect#1319
milanmajchrak merged 1 commit into
dataquest-dev:dtq-devfrom
ufal:backport-154-to-dtq-dev

Conversation

@kosarko

@kosarko kosarko commented Jun 19, 2026

Copy link
Copy Markdown

Port of ufal#154 by @amadulhaxxani to dtq-dev.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced bitstream editing page navigation to handle cases where the item ID is unavailable by deriving it from available item data when possible.

* fix(bitstream): restore item UUID in edit redirect

fix(bitstream): restore item UUID in edit redirect

* fix(bitstream): improve fallback navigation and error handling

fix(bitstream): improve fallback navigation and error handling

* proper cleanup on destroy

(cherry picked from commit b4d2fac)
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The edit-bitstream-bundle template now forwards itemId and entityType as query params on the bitstream edit link. The navigateToItemEditBitstreams() method is updated to navigate immediately if itemId is available, or resolve it asynchronously from bundle.item remote data, and falls back to location.back() when resolution fails. A corresponding unit test covers the missing-itemId path.

Changes

Bitstream Edit Navigation with itemId Resolution

Layer / File(s) Summary
Template query params and component navigation logic
src/app/item-page/.../item-edit-bitstream-bundle.component.html, src/app/bitstream-page/.../edit-bitstream-page.component.ts
The "edit" button's routerLink now includes queryParams with itemId and entityType. navigateToItemEditBitstreams() gains a local navigate helper and conditional logic: navigate immediately if itemId exists; otherwise subscribe to bundle.item remote data to resolve itemId and optionally entityType; fall back to location.back() on failure or missing data.
Unit test for missing-itemId resolution
src/app/bitstream-page/.../edit-bitstream-page.component.spec.ts
Adds a test that clears comp.itemId, sets a mock bundle.item with an Item uuid, triggers navigation, and asserts router.navigate is called with the resolved uuid on the bitstreams tab.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It identifies the PR as a backport but lacks critical sections from the template including Problem description, Analysis, and Manual Testing documentation. Add the required template sections: elaborate on the bug being fixed, provide technical analysis, and document any manual testing performed to verify the fix works correctly.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: restoring item UUID in edit redirect for bitstream functionality, which aligns with the core fix across all modified files.
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.

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


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts (1)

418-429: ⚡ Quick win

Add a unit test for the fallback branch (location.back()).

This test covers the success path, but the new non-success RemoteData path in navigateToItemEditBitstreams() is still untested. Adding that case will lock in the new error-handling behavior.

As per coding guidelines, "New features must include new unit tests".

🤖 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
`@src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts`
around lines 418 - 429, The test file currently only covers the success path
where bundle.item resolves successfully, but the navigateToItemEditBitstreams()
method also has a non-success RemoteData path that should trigger
location.back(). Add a new test case that mocks a failed RemoteData object for
bundle.item (using something like createFailedRemoteDataObject$) and verify that
location.back() is called instead of router.navigate, ensuring the
error-handling fallback behavior is properly tested.

Source: Coding guidelines

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

Nitpick comments:
In
`@src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts`:
- Around line 418-429: The test file currently only covers the success path
where bundle.item resolves successfully, but the navigateToItemEditBitstreams()
method also has a non-success RemoteData path that should trigger
location.back(). Add a new test case that mocks a failed RemoteData object for
bundle.item (using something like createFailedRemoteDataObject$) and verify that
location.back() is called instead of router.navigate, ensuring the
error-handling fallback behavior is properly tested.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 443adec9-3173-451e-b398-17fdc73066b0

📥 Commits

Reviewing files that changed from the base of the PR and between d8c5d54 and 3cbe2b2.

📒 Files selected for processing (3)
  • src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts
  • src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts
  • src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.html

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes navigation back to an Item’s edit → bitstreams tab after editing a Bitstream by ensuring the originating Item UUID (and entity type when available) is preserved via query params and recoverable from the owning bundle when missing.

Changes:

  • Pass itemId and entityType as query params when navigating from the Item bitstreams edit table to the Bitstream edit page.
  • Update navigateToItemEditBitstreams() to recover a missing itemId from bundle.item before redirecting (fallback to location.back() if unavailable).
  • Add unit test coverage for the fallback resolution of itemId from bundle.item.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.html Adds query params (itemId, entityType) to the Bitstream edit routerLink to preserve context for return navigation.
src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts Makes the “back to item bitstreams tab” navigation resilient when itemId is absent by resolving it from the owning bundle’s item.
src/app/bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts Adds a spec asserting that missing itemId is resolved from bundle.item and redirects correctly.

@milanmajchrak milanmajchrak merged commit 714c92b into dataquest-dev:dtq-dev Jun 23, 2026
6 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.

4 participants