Skip to content

Removed next callback in navigation guards#2818

Open
grolu wants to merge 2 commits intomasterfrom
bug/fix_deprecated_router_next
Open

Removed next callback in navigation guards#2818
grolu wants to merge 2 commits intomasterfrom
bug/fix_deprecated_router_next

Conversation

@grolu
Copy link
Member

@grolu grolu commented Mar 4, 2026

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:


Summary by CodeRabbit

  • Refactor

    • Modernized navigation guard patterns across the app for more consistent navigation behavior
    • Moved component initialization from route-enter hooks to lifecycle mount for more reliable loading
    • Centralized login error handling into store state so errors persist and display predictably
  • Tests

    • Adjusted tests to reflect the updated navigation and login error flows

@gardener-prow gardener-prow bot added do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 4, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

This PR migrates Vue Router navigation guards from the callback-based next() pattern to boolean-return semantics across multiple layout and view components and centralizes some error propagation via store state instead of router callbacks. It also removes several beforeRouteEnter hooks, moving initialization into lifecycle hooks.

Changes

Cohort / File(s) Summary
Layout Navigation Guards
frontend/src/layouts/GDefault.vue
Simplified onBeforeRouteUpdate by removing to, from, and next parameters and eliminating the explicit next() call.
Login State & Guards
frontend/src/layouts/GLogin.vue, frontend/__tests__/components/GLogin.spec.js
Converted beforeRouteEnter to a reduced-signature guard returning values (no next), removed beforeRouteUpdate, moved error propagation into loginStore.loginError, added mounted() to re-emit stored errors, and updated tests to match new guard/store flow.
New Shoot Views
frontend/src/views/GNewShoot.vue, frontend/src/views/GNewShootEditor.vue
Rewrote beforeRouteLeave/beforeRouteUpdate signatures to remove unused parameters and converted next()/next(false) control flow into boolean returns (true/false).
Shoot Item Editor
frontend/src/views/GShootItemEditor.vue
Replaced callback-style onBeforeRouteLeave with parameterless guard returning booleans; removed explicit error forwarding via next(err) inside guard.
List & Placeholder Views
frontend/src/views/GShootList.vue, frontend/src/views/GProjectPlaceholder.vue, frontend/src/views/GShootItemPlaceholder.vue
Removed several beforeRouteEnter guards; moved initialization to mounted()/setup and route-update handlers; simplified beforeRouteUpdate/beforeRouteLeave signatures and removed next() usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • holgerkoser
  • klocke-io

Poem

🐰 I hopped through guards both old and new,
Next() hops out — returns are true!
Errors tucked in a cozy store,
Mount and load, then hop once more. 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description template sections are present but almost entirely empty; required fields like 'What this PR does / why we need it' and 'Which issue(s) this PR fixes' are not filled in with substantive information. Complete the description with details about why this change was needed (e.g., Vue Router API deprecation), what issue it fixes, and any migration notes for reviewers.
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 PR title accurately describes the main change: removal of the next callback in Vue Router navigation guards across multiple components.

✏️ 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
  • Commit unit tests in branch bug/fix_deprecated_router_next

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.

@gardener-prow
Copy link

gardener-prow bot commented Mar 4, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign grolu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

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

🧹 Nitpick comments (1)
frontend/src/views/GNewShoot.vue (1)

177-192: Missing explicit return true at end of beforeRouteLeave.

When the draft is not dirty or navigation is confirmed, the function ends without returning a value. While Vue Router 5 treats undefined as allowing navigation, this is inconsistent with the explicit return true pattern used in beforeRouteUpdate (line 198) and other guards in this PR.

♻️ Add explicit return for consistency
     if (!this.isShootCreated && this.isShootDirty && !await this.confirmNavigation()) {
       return false
     }
+
+    return true
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/views/GNewShoot.vue` around lines 177 - 192, The
beforeRouteLeave guard (function beforeRouteLeave) can end without returning a
value in some branches; update it to explicitly return true at the end so it
consistently allows navigation (matching beforeRouteUpdate). Locate
beforeRouteLeave and add a final "return true" after the existing checks that
reference sortedInfraProviderTypeList, v$.$invalid,
confirmNavigateToYamlIfInvalid(), isShootCreated, isShootDirty, and
confirmNavigation() so all code paths explicitly return a boolean.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@frontend/src/views/GNewShoot.vue`:
- Around line 177-192: The beforeRouteLeave guard (function beforeRouteLeave)
can end without returning a value in some branches; update it to explicitly
return true at the end so it consistently allows navigation (matching
beforeRouteUpdate). Locate beforeRouteLeave and add a final "return true" after
the existing checks that reference sortedInfraProviderTypeList, v$.$invalid,
confirmNavigateToYamlIfInvalid(), isShootCreated, isShootDirty, and
confirmNavigation() so all code paths explicitly return a boolean.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc3a78d1-988c-4edd-89bb-af6463d2eaee

📥 Commits

Reviewing files that changed from the base of the PR and between 53ba9ba and 2d0b0f2.

📒 Files selected for processing (8)
  • frontend/src/layouts/GDefault.vue
  • frontend/src/layouts/GLogin.vue
  • frontend/src/views/GNewShoot.vue
  • frontend/src/views/GNewShootEditor.vue
  • frontend/src/views/GProjectPlaceholder.vue
  • frontend/src/views/GShootItemEditor.vue
  • frontend/src/views/GShootItemPlaceholder.vue
  • frontend/src/views/GShootList.vue
💤 Files with no reviewable changes (2)
  • frontend/src/views/GShootItemPlaceholder.vue
  • frontend/src/views/GProjectPlaceholder.vue

Copy link

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

🧹 Nitpick comments (4)
frontend/__tests__/components/GLogin.spec.js (4)

152-152: Same cleanup: remove unnecessary undefined argument.

♻️ Suggested cleanup
-        await GLogin.beforeRouteEnter.call(wrapper.vm, to, undefined)
+        await GLogin.beforeRouteEnter.call(wrapper.vm, to)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/__tests__/components/GLogin.spec.js` at line 152, The test calls
GLogin.beforeRouteEnter with an unnecessary explicit undefined for the second
argument; update the invocation to remove that argument so it becomes await
GLogin.beforeRouteEnter.call(wrapper.vm, to), referencing the
GLogin.beforeRouteEnter method and wrapper.vm/to variables in the test.

138-140: Same cleanup: remove unnecessary undefined argument.

♻️ Suggested cleanup
-        await GLogin.beforeRouteEnter.call(wrapper.vm, to, undefined)
+        await GLogin.beforeRouteEnter.call(wrapper.vm, to)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/__tests__/components/GLogin.spec.js` around lines 138 - 140, Remove
the unnecessary undefined argument passed to the navigation guard call: update
the test to call GLogin.beforeRouteEnter via .call(wrapper.vm, to) without the
extra undefined; leave the mounted invocation as await
GLogin.mounted.call(wrapper.vm). This targets the GLogin.beforeRouteEnter call
site in the test and simply removes the spurious third parameter.

34-34: Consider removing unused loginStore variable.

The loginStore variable is assigned in beforeEach but never used directly in the tests. Tests access store state through the component instance (wrapper.vm.loginError) instead. If there's no planned usage, the variable and its initialization at line 88 can be removed.

♻️ Suggested cleanup
-    let loginStore // eslint-disable-line no-unused-vars

And in beforeEach:

-      loginStore = useLoginStore()
+      useLoginStore() // Initialize store for tests

Or remove the line entirely if initialization happens implicitly through the component.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/__tests__/components/GLogin.spec.js` at line 34, Remove the unused
test-scoped variable loginStore: delete the declaration "let loginStore" and its
assignment in the beforeEach setup (where loginStore is set), and keep tests
using the component instance and wrapper.vm (e.g., wrapper.vm.loginError) as the
source of store/state; ensure no other references to loginStore remain.

116-119: Remove unnecessary undefined argument for consistency with new guard signature.

The beforeRouteEnter function now only takes (to) as its parameter. Passing undefined as a second argument is a remnant of the old (to, from, next) pattern and can be removed for clarity.

♻️ Suggested cleanup
-        await GLogin.beforeRouteEnter.call(wrapper.vm, to, undefined)
+        await GLogin.beforeRouteEnter.call(wrapper.vm, to)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/__tests__/components/GLogin.spec.js` around lines 116 - 119, The
test calls GLogin.beforeRouteEnter with an extra undefined second argument from
the old (to, from, next) signature; update the call to match the new
single-parameter guard by removing the extraneous argument — change the
invocation of GLogin.beforeRouteEnter.call(wrapper.vm, to, undefined) to
GLogin.beforeRouteEnter.call(wrapper.vm, to) and keep the subsequent
GLogin.mounted.call(wrapper.vm) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@frontend/__tests__/components/GLogin.spec.js`:
- Line 152: The test calls GLogin.beforeRouteEnter with an unnecessary explicit
undefined for the second argument; update the invocation to remove that argument
so it becomes await GLogin.beforeRouteEnter.call(wrapper.vm, to), referencing
the GLogin.beforeRouteEnter method and wrapper.vm/to variables in the test.
- Around line 138-140: Remove the unnecessary undefined argument passed to the
navigation guard call: update the test to call GLogin.beforeRouteEnter via
.call(wrapper.vm, to) without the extra undefined; leave the mounted invocation
as await GLogin.mounted.call(wrapper.vm). This targets the
GLogin.beforeRouteEnter call site in the test and simply removes the spurious
third parameter.
- Line 34: Remove the unused test-scoped variable loginStore: delete the
declaration "let loginStore" and its assignment in the beforeEach setup (where
loginStore is set), and keep tests using the component instance and wrapper.vm
(e.g., wrapper.vm.loginError) as the source of store/state; ensure no other
references to loginStore remain.
- Around line 116-119: The test calls GLogin.beforeRouteEnter with an extra
undefined second argument from the old (to, from, next) signature; update the
call to match the new single-parameter guard by removing the extraneous argument
— change the invocation of GLogin.beforeRouteEnter.call(wrapper.vm, to,
undefined) to GLogin.beforeRouteEnter.call(wrapper.vm, to) and keep the
subsequent GLogin.mounted.call(wrapper.vm) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7024180-94ca-4ad1-87ff-cf0b75498492

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0b0f2 and 77da8c7.

📒 Files selected for processing (1)
  • frontend/__tests__/components/GLogin.spec.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant