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

FEATURE: adjust image editor to allow a custom upload screen component #3302

Conversation

andrehoffmann30
Copy link
Contributor

What I did
I adjusted the image editor to allow a custom upload screen / dialog as an replacement option for the default upload behaviour.

How I did it
I adjusted the handleChooseFile function to look for a MediaUploadScreen in the secondary editors registry. If a component is found , it is used and renderd as a secondary editor for the upload of a file. If no component is found, the previous behaviour is used for handeling the file upload.

How to verify it
For testing this behaviour you need to write a plugin and add a component to be used as MediaUploadScreen to the secondary editors registry in your plugin.

Copy link
Member

@Sebobo Sebobo left a comment

Choose a reason for hiding this comment

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

Thx! Left some comments

packages/neos-ui-editors/src/Editors/Image/index.js Outdated Show resolved Hide resolved
packages/neos-ui-editors/src/Editors/Image/index.js Outdated Show resolved Hide resolved
@andrehoffmann30 andrehoffmann30 marked this pull request as draft December 21, 2022 09:05
@andrehoffmann30 andrehoffmann30 marked this pull request as ready for review December 21, 2022 09:20
@crydotsnake crydotsnake added Feature Label to mark the change as feature 8.3 labels Dec 21, 2022
Copy link
Contributor

@grebaldi grebaldi left a comment

Choose a reason for hiding this comment

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

Hi @andrehoffmann30,

thanks for your PR :)

I was able to get it to work locally. But there's one small adjustment I'd like to suggest (see comment below).

On a larger note:

Adding this feature would change the behavior of the ImageEditor, but would leave the behavior of the AssetEditor intact. Imho the upload mechanism should not differ between the two, so it would be necessary to adjust the AssetEditor as well.

// set media type constraint to "image/*" if it is not explicitly specified via options.constraints.mediaTypes
const constraints = {...options.constraints, mediaTypes: (options.constraints && options.constraints.mediaTypes) || ['image/*']};
const {component: AssetUploadScreen} = secondaryEditorsRegistry.get('Neos.Neos/Inspector/Secondary/Editors/AssetUploadScreen');
this.props.renderSecondaryInspector('IMAGE_UPLOAD_MEDIA', () => <AssetUploadScreen type="images" constraints={constraints} onComplete={this.afterUpload}/>);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to pass along propertyName, focusedNodePath, siteNodePath and metadata ("Image" or "Asset") as well, so that all the information the uploadAsset endpoint needs is available in the secondary inspector:
https://github.com/neos/neos-ui/blob/8.3/packages/neos-ui-backend-connector/src/Endpoints/index.ts#L224

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hallo @grebaldi , adjusted the asset editor to be able use the same custom upload dialog as the image editor. I have also adapted the code so that the additional data you mentioned is passed to the dialog. In the implementation of the dialog, you can then use the data accordingly if desired.

@c4ll-m3-j4ck c4ll-m3-j4ck deleted the feature/adjust-image-editor-for-upload-screen branch August 18, 2023 10:27
@andrehoffmann30 andrehoffmann30 restored the feature/adjust-image-editor-for-upload-screen branch December 5, 2023 09:30
@andrehoffmann30 andrehoffmann30 force-pushed the feature/adjust-image-editor-for-upload-screen branch from ecc6218 to 620d858 Compare December 5, 2023 12:15
@andrehoffmann30 andrehoffmann30 changed the base branch from 8.3 to 9.0 December 5, 2023 12:15
@github-actions github-actions bot added 9.0 and removed 8.3 labels Dec 5, 2023
@andrehoffmann30
Copy link
Contributor Author

Hallo @mhsdesign I changed the merge goal to the 9.0 branch. Can you please adjust the labels accordingly? Thank you.

@crydotsnake
Copy link
Member

Copy link
Contributor

@grebaldi grebaldi left a comment

Choose a reason for hiding this comment

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

Hi @andrehoffmann30,

thanks a lot for your adjustments! I was able to test everything locally and it works perfectly 👌

@markusguenther markusguenther force-pushed the feature/adjust-image-editor-for-upload-screen branch from 620d858 to 232e779 Compare January 5, 2024 14:13
@markusguenther markusguenther changed the base branch from 9.0 to 8.4 January 5, 2024 14:13
@github-actions github-actions bot added 8.4 and removed 9.0 labels Jan 5, 2024
@markusguenther markusguenther merged commit f4fb15b into neos:8.4 Jan 5, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.4 Feature Label to mark the change as feature Wrong Branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants