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

feat(manage): allow users to upload game icon images #2682

Closed

Conversation

wescopeland
Copy link
Member

This PR makes a change to allow developers to upload new game icon images via the management app's game edit page.

Other media types will be supported in the future, but this felt like a good chunk to knock out first just to establish a pattern that can be applied to those other fields.

Brave.Browser.mp4

@wescopeland wescopeland requested a review from a team September 7, 2024 13:06
->image()
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/gif'])
->maxSize(1024)
->rules('dimensions:width=96,height=96')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are "uploaded" files stored? Do they automatically get cleaned up? I attached a wrongly sized file and it still appears to have been uploaded:
image

Also, the error message remains after uploading a different (correctly sized) image.

And uploading that generated an error:
image

What permission do I need?
If the user doesn't have permission, should the field even be there?

Copy link
Member Author

@wescopeland wescopeland Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Draft" files (for lack of a better term) are uploaded to storage/app/temp. Filament only tries to associate them with the game when the user clicks the form submit button.

They are indeed automatically cleaned up (see ProcessUploadedImageAction::cleanUpTempFiles()), but it's a side effect. Maybe it would make sense for the cleanup code to run on some kind of schedule?

The permission needed is GamePolicy::update().

Visibility is indeed conditional based on this policy in GameResource.php on line 347.

Authorization passes if the user has any role of GAME_HASH_MANAGER, DEVELOPER_STAFF, DEVELOPER, or DEVELOPER_JUNIOR.

The authorization call occurs in GameResource/Pages/Edit.php on line 20.

My user account has the DEVELOPER role. This is what I see when I use the control locally:

Brave.Browser.mp4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Draft" files (for lack of a better term) are uploaded to storage/app/temp.

It seems like it maintains the filename of the uploaded file. If two users both upload a "icon.png" at roughly the same time, will one overwrite the other?

Wrongly sized files don't appear in that folder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still getting the error. And I have at least two of the roles you've identified.

2024-09-08.08-27-40.mp4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the error still stays on screen when uploading a second (correctly sized) image.
image

You can see it in your video at the 25 second mark.

@wescopeland
Copy link
Member Author

I'm going to attack this in a separate branch using a different approach.

I think Filament's built-in file upload component enforces a few assumptions that may not make sense for how we want to handle uploading and storing these assets right now.

I'd like to try again with a simple native file input from within Filament. However, Filament doesn't support this out of the box, so I'll need to build the component by hand.

@wescopeland wescopeland closed this Sep 8, 2024
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.

2 participants