Skip to content

Commit 8bd2f1e

Browse files
takaokoujiclaude
andcommitted
feat: improve Google Picker filtering and add i18n for dialog title
- Use .setQuery('.sb3') to filter files in Google Picker - Add internationalization for picker dialog title - Add Japanese translation for picker title: "Google ドライブから Scratch 3.0 プロジェクト (.sb3) を選択" - Pass localized title from HOC to Google Drive API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent c111656 commit 8bd2f1e

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

src/containers/google-drive-loader-hoc.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const messages = defineMessages({
3535
id: 'gui.googleDriveLoader.configError',
3636
defaultMessage: 'Google Drive is not configured. Please contact the administrator.',
3737
description: 'An error that displays when Google Drive API is not configured.'
38+
},
39+
pickerTitle: {
40+
id: 'gui.googleDriveLoader.pickerTitle',
41+
defaultMessage: 'Select a Scratch 3.0 project (.sb3) from Google Drive',
42+
description: 'Title for Google Drive file picker dialog.'
3843
}
3944
});
4045

@@ -79,9 +84,12 @@ const GoogleDriveLoaderHOC = function (WrappedComponent) {
7984
// Close file menu
8085
this.props.closeFileMenu();
8186

87+
// Get localized title
88+
const title = this.props.intl.formatMessage(messages.pickerTitle);
89+
8290
// Initialize and show Google Picker
8391
// Don't show loading modal yet - wait until user selects a file
84-
googleDriveAPI.showPicker(this.handlePickerCallback, this.props.locale)
92+
googleDriveAPI.showPicker(this.handlePickerCallback, this.props.locale, title)
8593
.catch(error => {
8694
log.error('Failed to show Google Picker:', error);
8795
alert(this.props.intl.formatMessage(messages.authError)); // eslint-disable-line no-alert

src/lib/google-drive-api.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ class GoogleDriveAPI {
113113
* Show Google Picker to select a file
114114
* @param {Function} callback - Called when user selects a file
115115
* @param {string} locale - Locale code (e.g., 'en', 'ja') for picker UI language
116+
* @param {string} title - Title for the picker dialog
116117
* @returns {Promise<void>} Promise that resolves when picker is shown
117118
*/
118-
async showPicker (callback, locale = 'en') {
119+
async showPicker (callback, locale = 'en', title = 'Select a Scratch 3.0 project (.sb3) from Google Drive') {
119120
if (!this.isInitialized) {
120121
await this.initialize();
121122
}
@@ -126,21 +127,21 @@ class GoogleDriveAPI {
126127

127128
this.pickerCallback = callback;
128129

129-
// Create and show picker
130+
// Create DocsView with .sb3 query filter
131+
const docsView = new window.google.picker.DocsView()
132+
.setIncludeFolders(true)
133+
.setQuery('.sb3');
134+
130135
const picker = new window.google.picker.PickerBuilder()
131-
.addView(
132-
new window.google.picker.DocsView()
133-
.setIncludeFolders(true)
134-
// No MIME type filter - show all files and validate by extension
135-
)
136+
.addView(docsView)
136137
.addView(
137138
new window.google.picker.DocsUploadView()
138139
.setIncludeFolders(true)
139140
)
140141
.setOAuthToken(token)
141142
.setDeveloperKey(API_KEY)
142143
.setCallback(this.handlePickerResponse.bind(this))
143-
.setTitle('Select a Scratch 3.0 project (.sb3) from Google Drive')
144+
.setTitle(title)
144145
.setLocale(locale)
145146
.build();
146147

src/locales/ja.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default {
44
'gui.googleDriveLoader.loadError': 'Google ドライブからプロジェクトの読み込みに失敗しました。',
55
'gui.googleDriveLoader.authError': 'Google ドライブの認証に失敗しました。もう一度お試しください。',
66
'gui.googleDriveLoader.configError': 'Google ドライブが設定されていません。管理者に連絡してください。',
7+
'gui.googleDriveLoader.pickerTitle': 'Google ドライブから Scratch 3.0 プロジェクト (.sb3) を選択',
78
'gui.urlLoader.loadError': 'プロジェクトURLの読み込みに失敗しました。',
89
'gui.urlLoader.invalidUrl': '有効なScratchプロジェクトURLまたはGoogle DriveのURLを入力してください。',
910
'gui.urlLoader.title': 'URLから読み込む',

0 commit comments

Comments
 (0)