Home Navigation Patterns
Overview
This specification defines the user interface patterns for home navigation, including the "Your Project" vs "All Projects" distinction, automatic project detection, and routing logic. These are implementation details that emerged from the design phase rather than business requirements.
Navigation Logic
User Assignment Detection
The system implements automatic project/site assignment detection to provide navigation shortcuts:
// Simplified logic from getCurrentProjectAndRPO
function determineHomeRoute(user: User) {
if (user.type === "RPO") {
const assignedProject = findProjectWhereRPO(user.id);
return assignedProject ? "/your-project" : "/all-projects";
}
if (user.type === "Protector") {
const assignedSite = findSiteWhereProtector(user.id);
const projectForSite = assignedSite ? findProjectForSite(assignedSite.id) : null;
return projectForSite ? "/your-project" : "/all-projects";
}
// Admin, Worker, Visitor default to all projects
return "/all-projects";
}Tab Structure
Users see different tab configurations based on assignments:
| User Type | Has Assignment | Visible Tabs | Default Tab |
|---|---|---|---|
| RPO | ✅ (Project) | Your Project, All Projects | Your Project |
| RPO | ❌ (No Project) | All Projects | All Projects |
| Protector | ✅ (Site) | Your Project, All Projects | Your Project |
| Protector | ❌ (No Site) | All Projects | All Projects |
| Admin | N/A | All Projects | All Projects |
| Worker | N/A | All Projects | All Projects |
| Visitor | N/A | All Projects | All Projects |
Your Project Tab Behaviour
Content Display
When a user has assignments, the "Your Project" tab displays:
- Project Header: Name, status badge, activation controls (if permissions allow)
- RPO Information: Contact details of the responsible RPO
- Lock Count Summary: Total users/plant locked on across all worksites
- Blocking Information: Current protection blockings for the project
- Worksite List: All worksites within the assigned project with their current states
Data Filtering
The "Your Project" tab shows:
- RPO users: The single project they're assigned as RPO for
- Protector users: The project containing the worksite they're assigned to protect
- Multiple assignments: System currently assumes single assignment per user
Search Functionality
Search within "Your Project" operates on:
- Worksite names within the assigned project
- Updates URL with search parameters:
?q=searchTerm - Filters visible worksites in real-time
All Projects Tab Behaviour
Content Display
The "All Projects" tab displays:
- Project Cards: Grid/list of all projects in the system
- Project Information: Name, status, worksite count, lock count, blocking details
- Filter Controls: Hide active projects checkbox
- Search Functionality: Filter projects by name
Universal Access
All users can view all projects regardless of assignments:
- No project-level access restrictions currently implemented
- Future regional filtering may be added for performance/UX
- Assignment-based tabs are convenience features, not security boundaries
Filter Behaviour
- Hide Active Projects: Toggles visibility of projects with
isActive: true - Search: Filters projects by name matching
- URL State: Preserves filter state in URL parameters (
?hideActive=true&q=searchTerm)
Navigation Routes
Route Structure
/_auth/_home/
├── / (index) → Automatic redirect based on assignment
├── your-project → Assigned project view (if applicable)
└── all-projects → All projects viewRedirect Logic
Root home route (/_auth/_home/) implements automatic routing:
- Check if user has
currentProjectAndRPOcontext - If yes → redirect to
/your-project - If no → redirect to
/all-projects
Tab Switching
Users can manually navigate between tabs when both are available:
- Tab switching preserves current search/filter state where possible
- URL updates to reflect current tab selection
- Browser back/forward navigation supported
Technical Implementation
State Management
- Project Assignment: Determined at route load time via
getCurrentProjectAndRPO - Search State: Managed via URL search parameters
- Filter State: Managed via URL search parameters and local component state
- Tab State: Reflected in current route path
Performance Considerations
- Project assignment lookup occurs once per navigation
- Search filtering happens client-side for responsive UX
- All projects data loaded upfront (no pagination currently)
Design Rationale
UX Improvements Implemented
- Reduced Cognitive Load: Users with single assignments see their relevant project first
- Faster Navigation: One-click access to assigned project without searching
- Context Preservation: Search and filters work within appropriate scope
- Universal Access: Users can still access all projects when needed
Non-Requirements
These patterns are not business requirements but design decisions:
- Could be removed in future system rewrites without breaking core functionality
- Assignment-based routing is a convenience feature, not a security control
- Tab structure is optimisation for common use cases, not mandate
Future Considerations
Potential Enhancements
- Regional/area-based filtering for large deployments
- Multiple assignment support per user
- Customisable home page layouts
- Advanced search and filtering options
Scalability Notes
- Current approach loads all projects upfront
- May require pagination/lazy loading for large datasets
- Assignment detection logic may need optimisation for complex organisational structures