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

Uploaders - Refactor and fixes #5478

Open
wants to merge 78 commits into
base: main
Choose a base branch
from
Open

Uploaders - Refactor and fixes #5478

wants to merge 78 commits into from

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Mar 21, 2024

This PR aims to fix and at the same time refactor uploaders and it's related validation classes.

Since launched some issues were identified for example the lack of validation support inside repeatables, or the tight coupling between an "ajax uploader" and a "dropzone uploader", that would prevent us from adding other types of ajax uploads like EasyMDE. Issues in dropzone validation .. etc.

There is a companion PR to this one in: https://github.com/Laravel-Backpack/PRO/pull/232

@tabacitu
Copy link
Member

Please please PLEASE start writing a title and description for every PR you create Pedro. It takes 2-3 minutes, man. And it helps YOU and the rest of the team understand what's happening there.

I swear I will start closing PRs that are not descriptive. You've been warned.

@pxpm pxpm changed the title WIP Uploaders - Refactor and fixes Apr 3, 2024
@pxpm
Copy link
Contributor Author

pxpm commented Apr 4, 2024

Check #5484 before merging this.

@karandatwani92
Copy link
Contributor

karandatwani92 commented Apr 5, 2024

Hey @pxpm

I tested fields of uploaders-test-branch. I'm facing many issues with it:

  • 1) Base64 Image CRUD::field('image')->type('image'); results✔️(fixed in demo branch):
    image

  • 2) Dropezone not working without validation, results:❌

image

  • 3) EasyMDE
    Setting custom destination & path breaks it.❌
CRUD::field('easymde')->type('easymde')->withFiles([
  'disk' => 'public',
  'path' => 'destinations'
]);
  • 4) Upload Multiple IDK exactly when, but some combination empty the array and removes the past stored items of another Multiple Upload field.❌

I'm considering testing subfields after the Green Flag on the above direct-use fields.

@pxpm
Copy link
Contributor Author

pxpm commented Apr 5, 2024

I am sorry @karandatwani92

But I am not able to reproduce any of the issue you mentioned:
image

I think I made the mistake of giving the test branch I used, I should have just let you guys create your own tests. It was intended to be used aa a guide, the branch it's not working AFAIK, it's missing routes for example.

I think in 1) it's clearly missing ->withFiles(). 🤷

I couldn't reproduce any of the other bugs you mentioned. The image of the easy mde in the screenshot is in:

CRUD::field('easymde')->type('easymde')->withFiles([
            'path' => 'test',
        ]);

image

Let me know if I can help you with something.

@karandatwani92
Copy link
Contributor

Hey @pxpm, I'm facing the same issues even with a fresh installation.
PLUS, I found one more bug:

  • Using an upload field with ['disk'=>'public', 'path'=>'destination'] attributes appends the path to the stored path(old file on different path), which breaks the URL. It is not supposed to append anything to the DB stored path/value. The deletion of the old file is working fine in this case.

@pxpm
Copy link
Contributor Author

pxpm commented Apr 10, 2024

@karandatwani92 test issues:

  • Dropzone don't work without defining validation.

  • EasyMDE appends an extra slash (/) when defining the upload with some custom path and that breaks file url.

  • Single file upload behaves different than multiple file. Single file upload builds the file using the disk and prefix, while multiple uploads use the file as is in the database.
    I am not sure this one is related with this PR specifically. As far as I can see, this PR does not touch Uploaders.php class, so it does not change the retrieve behavior, nor the changes done in upload.blade.php touch any of this bit.
    Looking at upload.blade.php history https://github.com/Laravel-Backpack/CRUD/blame/main/src/resources/views/crud/fields/upload.blade.php I don't see any changes that would have changed this behavior, so I can assume that's something @karandatwani92 found while testing this, but it's not specifically related to this changes, so I opened [WIP] upload vs upload_multiple file display inconsistent behavior.  #5491 for further discussion on the topic.

@karandatwani92
Copy link
Contributor

Hey @pxpm

The above bugs are fixed✅. Now I started testing subfields under repeatable and there is an issue:

  • Suppose we created two rows and saved them. Go to Edit and Reorder - (It breaks saving: causes validation error)❌

@pxpm
Copy link
Contributor Author

pxpm commented Apr 17, 2024

Hey @pxpm

The above bugs are fixed✅. Now I started testing subfields under repeatable and there is an issue:

  • Suppose we created two rows and saved them. Go to Edit and Reorder - (It breaks saving: causes validation error)❌

Thanks @karandatwani92 haven't spotted that. 🙏 nice catch!

I've just pushed fixes both in this PR and in PRO PR to address that issue.
Please note that I rebased both branches, so if you have any troubles with a git pull, please just delete the local branch and download a new copy.

Thanks again 🙏

@karandatwani92
Copy link
Contributor

Hey @pxpm

New Issue: Create new, edit, and save without changes(validation error even when the file is already attached):
Screenshot 2024-04-18 at 2 47 54 PM

@karandatwani92
Copy link
Contributor

New Bugs:

  1. Message for Default Validation Error is missing. (See the difference.)
    Screenshot 2024-05-24 at 9 09 27 PM
  2. If I switch the repeatable row position, the subfield upload value stays, but the file gets deleted.
    Screenshot 2024-05-24 at 9 19 08 PM

@pxpm
Copy link
Contributor Author

pxpm commented May 24, 2024

1 is not a bug, in the demo app mimetypes is not added to translations, it comes by default with Laravel since Laravel 9 if I am not mistaken, we never bothered adding it to the demo because we don't use it.

2 might be a bug, I am not sure if I have a test case covering that, if not I will add one and evaluate that scenario.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

5 participants