feat: simplify target handling to use full paths#12
Merged
screwyprof merged 11 commits intomainfrom Dec 23, 2024
Merged
Conversation
- Add Desktop as a special Target type alongside Downloads - Add path detection for user's Desktop folder (/Users/*/Desktop/) - Display Desktop target as ~/Desktop in sidebar - Add acceptance test for Desktop folder handling
- Replace custom URL handling with MacOsPath type - Use standard Rust traits (From, Display) instead of custom methods - Centralize path detection logic in MacOsPath
- Replace TargetUrl and MacOsPath with a single FavoriteItem type - Move item-related code to favorites/item.rs - Improve naming to better reflect domain concepts
- Add MacOsUrl enum to handle all URL types (AirDrop, Recents, Applications, Downloads, Desktop, Custom) - Move URL constants and path validation logic from FavoriteItem to MacOsUrl - Implement From<&str> for MacOsUrl for direct URL parsing - Add helper methods is_user_downloads and is_user_desktop - Add USER_HOME_FOLDER_DEPTH constant for path validation
- Extract path validation logic into is_inside_home_dir helper method - Make MacOsUrl public and derive common traits (Debug, Clone, PartialEq, Eq) - Make constants public for reuse in tests - Add Display implementation for FavoriteItem - Add comprehensive test coverage for path validation edge cases - Use AsRef<str> for more flexible string handling - Use functional style with Option methods for prefix handling
- Remove redundant is_user_downloads and is_user_desktop helper methods - Add USER_PREFIX, DOWNLOADS, and DESKTOP constants for better maintainability - Simplify is_user_folder by removing separate is_inside_home_dir function - Use direct path component validation instead of string manipulation - Make path validation more explicit with take(2) and component checks - Use constants in pattern matching for better readability
- Strip file:// prefix and trailing slash from custom location paths - Use display name as label for custom locations - Update tests to verify custom location handling - Add constants for Projects location in tests - Remove redundant test case for Documents location The changes ensure custom locations are displayed in a user-friendly format: Label -> last part of the URL Path -> absolute path without file:// prefix and trailing slash
- Move clean_path function to MacOsUrl impl block - Implement From<Url> instead of From<&str> for MacOsUrl - Remove duplicate path cleaning logic from Target conversion - Update tests to use proper URL creation
- Add Target::custom constructor in domain layer - Update all Target::Custom creations to use the constructor - Update tests to use the new constructor
- Rename test to better describe what it verifies - Remove redundant test cases that check the same behavior - Keep only essential test for deep path recognition
- Remove special Desktop and Downloads targets - Treat all user directory items as custom locations - Update tests to reflect simplified target handling - Remove unused constants and test cases BREAKING CHANGE: Desktop and Downloads are now handled as custom locations with full paths instead of special targets with ~ notation.
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #12 +/- ##
===========================================
+ Coverage 99.82% 100.00% +0.17%
===========================================
Files 12 12
Lines 584 595 +11
Branches 3 0 -3
===========================================
+ Hits 583 595 +12
+ Partials 1 0 -1 ☔ View full report in Codecov by Sentry. |
This was referenced Dec 23, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat!: simplify target handling to use full paths
This PR simplifies how FavKit handles Finder favorites by treating all user directory items as custom locations with full paths.
BREAKING CHANGE: Desktop and Downloads are now handled as custom locations with full paths instead of special targets with ~ notation.