Spaces:
Runtime error
Runtime error
Update src/components/menu-bar/google-drive-save.jsx
Browse files
src/components/menu-bar/google-drive-save.jsx
CHANGED
|
@@ -255,67 +255,102 @@ class GoogleDriveSave extends React.Component {
|
|
| 255 |
);
|
| 256 |
}
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
-
|
| 264 |
-
<div
|
| 265 |
-
<
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
</div>
|
| 276 |
-
)}
|
| 277 |
-
</div>
|
| 278 |
-
|
| 279 |
-
<h3 className={styles.fileName}>
|
| 280 |
-
{project.name.replace('.s4s.txt', '')}
|
| 281 |
-
</h3>
|
| 282 |
-
|
| 283 |
-
{this.renderShareLink(project.id)}
|
| 284 |
-
|
| 285 |
-
<div className={styles.buttonGroup}>
|
| 286 |
-
<button
|
| 287 |
-
onClick={() => this.handleLoadFile(project)}
|
| 288 |
-
className={styles.actionButton}
|
| 289 |
-
disabled={this.state.isProcessing}
|
| 290 |
-
>
|
| 291 |
-
読み込む
|
| 292 |
-
</button>
|
| 293 |
-
<button
|
| 294 |
-
onClick={() => this.handleReplaceFile(project)}
|
| 295 |
-
className={styles.actionButton}
|
| 296 |
-
disabled={this.state.isProcessing}
|
| 297 |
-
>
|
| 298 |
-
上書き
|
| 299 |
-
</button>
|
| 300 |
-
<button
|
| 301 |
-
onClick={() => this.handleShareFile(project.id)}
|
| 302 |
-
className={classNames(styles.actionButton, styles.shareButton)}
|
| 303 |
-
disabled={this.state.isProcessing}
|
| 304 |
-
>
|
| 305 |
-
共有
|
| 306 |
-
</button>
|
| 307 |
-
<button
|
| 308 |
-
onClick={() => this.handleDeleteFile(project, thumbnailFiles)}
|
| 309 |
-
className={classNames(styles.actionButton, styles.deleteButton)}
|
| 310 |
-
disabled={this.state.isProcessing}
|
| 311 |
-
>
|
| 312 |
-
削除
|
| 313 |
-
</button>
|
| 314 |
-
</div>
|
| 315 |
</div>
|
| 316 |
-
|
| 317 |
-
|
|
|
|
| 318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
renderShareLink(fileId) {
|
| 320 |
const SHORT_URL = "https://s4.rf.gd/";
|
| 321 |
|
|
|
|
| 255 |
);
|
| 256 |
}
|
| 257 |
|
| 258 |
+
renderFileItem(project, thumbnailFiles) {
|
| 259 |
+
const thumbnail = thumbnailFiles.find(
|
| 260 |
+
thumb => thumb.name === `Scratch-Thumbnail-${project.id}.png`
|
| 261 |
+
);
|
| 262 |
+
|
| 263 |
+
return (
|
| 264 |
+
<div key={project.id} className={styles.fileItem}>
|
| 265 |
+
<div className={styles.thumbnailContainer}>
|
| 266 |
+
{thumbnail ? (
|
| 267 |
+
<img
|
| 268 |
+
src={`https://drive.google.com/thumbnail?id=${thumbnail.id}&sz=w300`}
|
| 269 |
+
alt="プロジェクトサムネイル"
|
| 270 |
+
className={styles.thumbnail}
|
| 271 |
+
/>
|
| 272 |
+
) : (
|
| 273 |
+
<div className={styles.thumbnailPlaceholder}>
|
| 274 |
+
サムネイルなし
|
| 275 |
+
</div>
|
| 276 |
+
)}
|
| 277 |
+
</div>
|
| 278 |
+
|
| 279 |
+
<h3 className={styles.fileName}>
|
| 280 |
+
{project.name.replace('.s4s.txt', '')}
|
| 281 |
+
</h3>
|
| 282 |
+
|
| 283 |
+
{this.renderShareLink(project.id)}
|
| 284 |
+
|
| 285 |
+
<div className={styles.buttonGroup}>
|
| 286 |
+
<button
|
| 287 |
+
onClick={() => this.handleLoadFile(project)}
|
| 288 |
+
className={styles.actionButton}
|
| 289 |
+
disabled={this.state.isProcessing}
|
| 290 |
+
>
|
| 291 |
+
読み込む
|
| 292 |
+
</button>
|
| 293 |
+
<button
|
| 294 |
+
onClick={() => this.handleReplaceFile(project)}
|
| 295 |
+
className={styles.actionButton}
|
| 296 |
+
disabled={this.state.isProcessing}
|
| 297 |
+
>
|
| 298 |
+
上書き
|
| 299 |
+
</button>
|
| 300 |
+
<button
|
| 301 |
+
onClick={() => this.handleShareFile(project.id)}
|
| 302 |
+
className={classNames(styles.actionButton, styles.shareButton)}
|
| 303 |
+
disabled={this.state.isProcessing}
|
| 304 |
+
>
|
| 305 |
+
共有
|
| 306 |
+
</button>
|
| 307 |
+
<button
|
| 308 |
+
onClick={() => this.handleDeleteFile(project, thumbnailFiles)}
|
| 309 |
+
className={classNames(styles.actionButton, styles.deleteButton)}
|
| 310 |
+
disabled={this.state.isProcessing}
|
| 311 |
+
>
|
| 312 |
+
削除
|
| 313 |
+
</button>
|
| 314 |
+
</div>
|
| 315 |
|
| 316 |
+
{/* ここにアクセス権限設定のドロップダウンを追加 */}
|
| 317 |
+
<div className={styles.permissionDropdown}>
|
| 318 |
+
<label>アクセス権限: </label>
|
| 319 |
+
<select
|
| 320 |
+
value={this.state.sharePermission}
|
| 321 |
+
onChange={(e) => this.updateFilePermission(project.id, e.target.value)}
|
| 322 |
+
disabled={this.state.isProcessing}
|
| 323 |
+
>
|
| 324 |
+
<option value="reader">閲覧のみ</option>
|
| 325 |
+
<option value="writer">編集可能</option>
|
| 326 |
+
<option value="owner">所有者</option>
|
| 327 |
+
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
</div>
|
| 329 |
+
</div>
|
| 330 |
+
);
|
| 331 |
+
}
|
| 332 |
|
| 333 |
+
updateFilePermission = async (fileId, permission) => {
|
| 334 |
+
this.setState({isProcessing: true});
|
| 335 |
+
try {
|
| 336 |
+
await fetch(`https://www.googleapis.com/drive/v3/files/${fileId}/permissions/anyone`, {
|
| 337 |
+
method: "PATCH",
|
| 338 |
+
headers: {
|
| 339 |
+
Authorization: `Bearer ${this.state.accessToken}`,
|
| 340 |
+
"Content-Type": "application/json",
|
| 341 |
+
},
|
| 342 |
+
body: JSON.stringify({
|
| 343 |
+
role: permission,
|
| 344 |
+
}),
|
| 345 |
+
});
|
| 346 |
+
alert("success", "アクセス権限を更新しました");
|
| 347 |
+
} catch (error) {
|
| 348 |
+
console.error("権限更新エラー:", error);
|
| 349 |
+
alert("error", "アクセス権限の更新に失敗しました");
|
| 350 |
+
} finally {
|
| 351 |
+
this.setState({isProcessing: false});
|
| 352 |
+
}
|
| 353 |
+
};
|
| 354 |
renderShareLink(fileId) {
|
| 355 |
const SHORT_URL = "https://s4.rf.gd/";
|
| 356 |
|