"Import a collection" button redirects to incorrect URL missing /hero_books/admin/ prefix #136

Closed
opened 2026-05-25 15:05:01 +00:00 by mahmoud · 3 comments
Owner

Description

When pressing the "Import a collection to get started." button, it redirects to an incorrect URL that is missing the proper route prefix.

  • Actual redirect: http://[50c:2786:2581:b5fe:3::1]:9988/import
  • Expected redirect: http://[50c:2786:2581:b5fe:3::1]:9988/hero_books/admin/import (same as the working link in the navbar)

The navbar link to import works correctly, but this button uses the wrong path.

Expected behavior: The "Import a collection" button should redirect to the same correctly-prefixed URL as the navbar link (/hero_books/admin/import).

### Description When pressing the "Import a collection to get started." button, it redirects to an incorrect URL that is missing the proper route prefix. - Actual redirect: `http://[50c:2786:2581:b5fe:3::1]:9988/import` - Expected redirect: `http://[50c:2786:2581:b5fe:3::1]:9988/hero_books/admin/import` (same as the working link in the navbar) The navbar link to import works correctly, but this button uses the wrong path. Expected behavior: The "Import a collection" button should redirect to the same correctly-prefixed URL as the navbar link (`/hero_books/admin/import`).
Author
Owner

Implementation Spec for Issue #136

Objective

Fix the empty-state "Import" links in the hero_books admin UI so they point at the base-path-prefixed /import route (e.g. /hero_books/admin/import) instead of a hardcoded /import, matching the navbar link and working correctly behind the router prefix.

Root Cause

The admin templates hardcode href="/import", which resolves to the router root (/import) rather than the service-prefixed path. The navbar link already uses the template's {{ base }} prefix variable (base.html: href="{{ base }}/import"), populated by base_path_middleware from the x-forwarded-prefix header. The two empty-state links were missed.

Files to Modify

  • crates/hero_books_admin/templates/collections.html (line 44) — the "Import a collection to get started" link named in the issue.
  • crates/hero_books_admin/templates/index.html (line 48) — the identical defect on the Libraries empty state ("Import a library to get started").

Both templates {% extends "base.html" %}, and their render structs (CollectionsTemplate, IndexTemplate in src/main.rs) already carry a base: String field, so {{ base }} is in scope.

Implementation Plan

Files: crates/hero_books_admin/templates/collections.html, crates/hero_books_admin/templates/index.html

  • Change href="/import" to href="{{ base }}/import" in both empty-state paragraphs.
    Dependencies: none

Acceptance Criteria

  • Collections empty state links to {{ base }}/import (e.g. /hero_books/admin/import).
  • Libraries (index) empty state links to {{ base }}/import.
  • Both match the navbar Import link prefix.
  • Templates compile (cargo check).

Notes

  • Out of scope: hero_books_app (Dioxus SPA) uses client-side hash routing (#/import) and is correct as-is; hero_books_web templates already use {{ base }}/import.
  • The broader /ui/ vs /admin/ route redundancy is tracked separately in #135 (a hero_router concern), not part of this fix.
## Implementation Spec for Issue #136 ### Objective Fix the empty-state "Import" links in the hero_books admin UI so they point at the base-path-prefixed `/import` route (e.g. `/hero_books/admin/import`) instead of a hardcoded `/import`, matching the navbar link and working correctly behind the router prefix. ### Root Cause The admin templates hardcode `href="/import"`, which resolves to the router root (`/import`) rather than the service-prefixed path. The navbar link already uses the template's `{{ base }}` prefix variable (`base.html`: `href="{{ base }}/import"`), populated by `base_path_middleware` from the `x-forwarded-prefix` header. The two empty-state links were missed. ### Files to Modify - `crates/hero_books_admin/templates/collections.html` (line 44) — the "Import a collection to get started" link named in the issue. - `crates/hero_books_admin/templates/index.html` (line 48) — the identical defect on the Libraries empty state ("Import a library to get started"). Both templates `{% extends "base.html" %}`, and their render structs (`CollectionsTemplate`, `IndexTemplate` in `src/main.rs`) already carry a `base: String` field, so `{{ base }}` is in scope. ### Implementation Plan #### Step 1: Prefix the import links Files: `crates/hero_books_admin/templates/collections.html`, `crates/hero_books_admin/templates/index.html` - Change `href="/import"` to `href="{{ base }}/import"` in both empty-state paragraphs. Dependencies: none ### Acceptance Criteria - [ ] Collections empty state links to `{{ base }}/import` (e.g. `/hero_books/admin/import`). - [ ] Libraries (index) empty state links to `{{ base }}/import`. - [ ] Both match the navbar Import link prefix. - [ ] Templates compile (`cargo check`). ### Notes - Out of scope: `hero_books_app` (Dioxus SPA) uses client-side hash routing (`#/import`) and is correct as-is; `hero_books_web` templates already use `{{ base }}/import`. - The broader `/ui/` vs `/admin/` route redundancy is tracked separately in #135 (a hero_router concern), not part of this fix.
mahmoud self-assigned this 2026-05-25 15:14:20 +00:00
mahmoud added this to the ACTIVE project 2026-05-25 15:14:22 +00:00
mahmoud added this to the next milestone 2026-05-25 15:14:24 +00:00
mahmoud modified the milestone from next to now 2026-05-25 15:14:26 +00:00
Author
Owner

Implementation Summary

Fixed the empty-state "Import" links in the hero_books admin UI to use the base-path prefix, matching the navbar link.

Changes

  • crates/hero_books_admin/templates/collections.htmlhref="/import" -> href="{{ base }}/import" (the "Import a collection to get started" link from the issue).
  • crates/hero_books_admin/templates/index.htmlhref="/import" -> href="{{ base }}/import" (the "Import a library to get started" empty state, identical defect).

Behind the router prefix these now render /hero_books/admin/import — the same target as the navbar Import link.

Tests

  • cargo check -p hero_books_admin — passes (Askama compiles the templates with the change).
  • cargo test -p hero_books_admin — 2 passed, 0 failed (round_trip_ok, upstream_unreachable_returns_502).

Acceptance Criteria

  • Collections empty state links to {{ base }}/import.
  • Libraries (index) empty state links to {{ base }}/import.
  • Both match the navbar Import link prefix.
  • Templates compile.

Note: the running hero_books_admin instance needs a rebuild + restart to pick up the change.

## Implementation Summary Fixed the empty-state "Import" links in the hero_books admin UI to use the base-path prefix, matching the navbar link. ### Changes - `crates/hero_books_admin/templates/collections.html` — `href="/import"` -> `href="{{ base }}/import"` (the "Import a collection to get started" link from the issue). - `crates/hero_books_admin/templates/index.html` — `href="/import"` -> `href="{{ base }}/import"` (the "Import a library to get started" empty state, identical defect). Behind the router prefix these now render `/hero_books/admin/import` — the same target as the navbar Import link. ### Tests - `cargo check -p hero_books_admin` — passes (Askama compiles the templates with the change). - `cargo test -p hero_books_admin` — 2 passed, 0 failed (`round_trip_ok`, `upstream_unreachable_returns_502`). ### Acceptance Criteria - [x] Collections empty state links to `{{ base }}/import`. - [x] Libraries (index) empty state links to `{{ base }}/import`. - [x] Both match the navbar Import link prefix. - [x] Templates compile. Note: the running hero_books_admin instance needs a rebuild + restart to pick up the change.
Author
Owner

Fixed in commit 60494989, pushed to development. Both empty-state Import links now use the {{ base }} prefix and render /hero_books/admin/import. The running hero_books_admin instance needs a rebuild + restart to pick up the change.

Fixed in commit `60494989`, pushed to `development`. Both empty-state Import links now use the `{{ base }}` prefix and render `/hero_books/admin/import`. The running hero_books_admin instance needs a rebuild + restart to pick up the change.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_books#136
No description provided.