Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/route based navigation #2689

Merged

Conversation

KVV94
Copy link
Contributor

@KVV94 KVV94 commented Feb 10, 2025

Ticket № 2645

closes #2645

Problem:

Currently, the selected node state is managed through application state, making navigation less predictable and hindering the use of standard browser features (like the Back button). We need to make the node selection mechanism route-based.

Solution:

Implemented a route-based node selection mechanism through a new useSelectedNodeFromUrl hook that synchronizes URL state with the selected node state. This makes node selection more predictable and allows for better browser integration

Changes:

Added new route for selected node: mainroute/episode/{episode_id}/node/{ref_id}
Created useSelectedNodeFromUrl hook for URL state synchronization
Created useNodeNavigation hook to handle node navigation
Integrated the new mechanism into Graph/index.tsx and other components where node selection occurs
Updated existing node selection calls to use the new route-based approach
Testing:

useNodeNavigation tests:

Tests URL formation correctness
Tests node navigation functionality
Tests selected node clearing
useSelectedNodeFromUrl tests:

Tests node setting from URL
Tests node clearing when URL has no ID
Tests invalid ID handling
Notes:

Using replace: true in navigation to prevent unnecessary browser history entries
No state changes occur when node ID from URL is not found
Maintained backward compatibility with existing node selection mechanism
Browser navigation (back/forward) now works seamlessly with node selection

@Rassl Rassl changed the base branch from master to feature/selection-by-route February 10, 2025 11:24
@Rassl Rassl merged commit 9f2bc6a into stakwork:feature/selection-by-route Feb 10, 2025
12 of 17 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.

Make selection node mechanism route based
2 participants