Skip to content

Conversation

@takaokouji
Copy link

Summary

This PR enhances the URL loader functionality with comprehensive Google Drive URL support and improves the modal UI for better user experience.

Key Features Added

  • Google Drive URL Support: Users can now load Smalruby projects directly from Google Drive URLs
  • Improved Modal UI: Simplified interface with dedicated URL examples section
  • Enhanced URL Parser: Added robust URL validation for both Scratch and Google Drive URLs

Implementation Details

Google Drive URL Support

  • Added url-parser.js with functions to detect and extract Google Drive file IDs
  • Supports multiple Google Drive URL formats:
    • https://drive.google.com/file/d/{file_id}/view
    • https://drive.google.com/file/d/{file_id}/view?usp=sharing
    • https://drive.google.com/file/d/{file_id}/view?usp=drive_link
  • Uses CORS proxy (https://api.smalruby.app/cors-proxy) for secure file access
  • Proper error handling for failed downloads and invalid files

URL Loader Modal UI Improvements

  • Before: Long placeholder text with embedded examples
  • After: Short placeholder with dedicated "URL Examples" section below input field
  • Cleaner, more intuitive interface following existing design patterns
  • Better accessibility with proper semantic HTML structure

Technical Enhancements

  • Fixed React prop warnings by implementing proper prop filtering in HOC
  • Resolved CloudManager VM prop access issues
  • Corrected bindAll method references after refactoring
  • Comprehensive internationalization support (English, Japanese, Japanese-Hiragana)

URL Examples Supported

Scratch Projects

https://scratch.mit.edu/projects/{project_id}/

Google Drive Files

https://drive.google.com/file/d/{file_id}/view?usp=drive_link

Testing

  • ✅ ESLint checks pass
  • ✅ All error scenarios handled gracefully
  • ✅ Proper loading states and user feedback
  • ✅ Compatible with existing file upload workflows

Files Changed

  • src/components/url-loader-modal/url-loader-modal.jsx - Enhanced modal component
  • src/components/url-loader-modal/url-loader-modal.css - Updated styling for examples section
  • src/lib/url-loader-hoc.jsx - Added Google Drive loading logic and fixed prop issues
  • src/lib/url-parser.js - New URL validation and parsing utilities
  • src/locales/*.js - Updated internationalization messages

Breaking Changes

None. This is a backward-compatible enhancement that extends existing functionality.

Related Issues

Closes #411

🤖 Generated with Claude Code

takaokouji and others added 5 commits September 19, 2025 00:08
Implements support for loading Smalruby projects from Google Drive URLs
in addition to existing Scratch project URLs:

**New Features:**
- Google Drive URL pattern support:
  - https://drive.google.com/file/d/FILE_ID/view
  - https://drive.google.com/open?id=FILE_ID
  - https://drive.google.com/uc?export=download&id=FILE_ID

**Technical Implementation:**
- Updated URL parser with Google Drive detection functions
- Enhanced URL Loader HOC to handle both Scratch and Google Drive URLs
- Google Drive projects loaded as SB3 files via CORS proxy
- Scratch projects continue to work with JSON format as before

**UI Improvements:**
- Updated placeholder text to show both URL types
- Updated prompt message to be more generic
- Enhanced validation messages for both URL types

**Localization:**
- Updated all locale files (en.js, ja.js, ja-Hira.js)
- Added Google Drive support to error messages and UI text

**File Loading Logic:**
- Scratch URLs: JSON format via scratch-api-proxy (existing)
- Google Drive URLs: SB3 format via CORS proxy (new)
- Uses https://api.smalruby.app/cors-proxy for Google Drive access

This enhancement allows users to easily load and share Smalruby projects
stored in Google Drive, expanding the URL loader functionality while
maintaining full backward compatibility.

Resolves: #411

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fixed "Expected a function" error by updating bindAll to reference
the correct method names after refactoring:
- loadProjectFromUrl -> loadScratchProjectFromUrl
- Added loadGoogleDriveProjectFromUrl and clearLoadingReferences

This resolves the runtime error preventing the URL loader from
initializing properly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fixed React warnings about unknown event handlers and props being
passed to DOM elements by properly filtering out all URL loader
HOC-specific props in the render method:

- closeUrlLoaderModal -> closeUrlLoaderModalProp
- onLoadedProject -> onLoadedProjectProp
- openUrlLoaderModal -> openUrlLoaderModalProp
- setProjectId -> setProjectIdProp
- Plus other HOC-specific props (intl, vm, onError, etc.)

This prevents the props from being spread to DOM elements where
they would cause React warnings about unknown properties.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fixed CloudManager error "Cannot read properties of undefined (reading 'on')"
by explicitly passing the vm prop to WrappedComponent. The CloudManager
component requires the vm prop to register event listeners in its
constructor, but it was being filtered out during prop destructuring.

Changes:
- Added explicit vm={vm} prop to WrappedComponent in render method
- CloudManager can now access vm.on() for event listener registration
- Maintains prop filtering to prevent React warnings while ensuring
  required props reach child components

This resolves the TypeError that prevented CloudManager from initializing
properly and causing the application to crash.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Remove prompt text "Enter a project URL:" to simplify the modal
- Add dedicated URL examples section below input field
- Update placeholder text to be shorter and clearer
- Clean up unused CSS styles and internationalization messages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@takaokouji takaokouji merged commit 1a11c6a into develop Sep 18, 2025
2 checks passed
@takaokouji takaokouji deleted the feature/google-drive-url-support branch September 18, 2025 16:38
github-actions bot pushed a commit that referenced this pull request Sep 18, 2025
…e-drive-url-support

feat: enhance URL loader with Google Drive support and improved UI
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.

Add Google Drive URL support to URL loader

1 participant