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

IBX-4486: Disabled Autosave feature for content creation #2084

Closed
wants to merge 2 commits into from

Conversation

barw4
Copy link
Member

@barw4 barw4 commented Jan 27, 2023

Question Answer
Tickets https://issues.ibexa.co/browse/IBX-4486
Bug fix? yes
New feature? no
BC breaks? no
Tests pass? yes
Doc needed? no
License GPL-2.0

Autosave shouldn't be enabled for nodraft requests.

Checklist:

  • Coding standards ($ composer fix-cs)
  • Ready for Code Review

@barw4 barw4 requested a review from a team January 27, 2023 15:01
@barw4 barw4 self-assigned this Jan 27, 2023
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

try {
$this->innerContentFormProcessor->processSaveDraft($event);
$statusCode = Response::HTTP_OK;
if ($event->getData() instanceof ContentUpdateData) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this a reliable way to detect /nodraft requests? Can we have some test coverage to be sure that we didn't disabled autosave for cases that shouldn't be affected by this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

@konradoboza I can create some tests, but what other cases do you have in mind that shouldn't be affected by this change? In processSaveDraft we explicitly mention only two cases - ContentCreateData and ContentUpdateData (https://github.com/ezsystems/ezplatform-content-forms/blob/1.3/src/lib/Form/Processor/ContentFormProcessor.php#L83). It's even more reasonable to block other unexpected Datas here and leave only the one fitting.

Copy link
Member

Choose a reason for hiding this comment

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

I assume that with this change we don't block autosaving while being on content creation form, right? The naming itself is a bit hard to wrap a head around without context. That's why I asked about some test coverage. Nevertheless, if it isn't the case, I am fine with proposed changes.

Copy link
Member Author

@barw4 barw4 Jan 30, 2023

Choose a reason for hiding this comment

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

If by "content creation form" you mean creation of content that is in fact updating its first draft then it is not blocking it. That's how Back Office works usually. This PR only affects the "nodraft" content creation when a draft for a given content doesn't exist yet and therefore there is no need to update/autosave it.

Copy link
Member

Choose a reason for hiding this comment

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

If by content creation form you mean creation of content that is in fact updating its first draft

That was indeed my assumption, but wasn't sure.

Copy link
Contributor

@ViniTou ViniTou Feb 7, 2023

Choose a reason for hiding this comment

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

This form has drafts_enabled option, wouldnt that be a better way to check it? It just seems it is set wrong for /nodraft action and it is only used in UDW.

@Nattfarinn

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@ViniTou @Nattfarinn setting it to false will break content create forms - https://github.com/ezsystems/ezplatform-content-forms/blob/1.3/src/lib/Form/Type/Content/ContentEditType.php#L46-L65.

In the create.html.twig (https://github.com/ezsystems/ezplatform-admin-ui/blob/2.3/src/bundle/Resources/views/themes/admin/content/create/create.html.twig#L29-L30) we are using both cancel and save draft buttons. So perhaps we could introduce another option that is autosave_enabled?

Copy link
Contributor

@ViniTou ViniTou Feb 7, 2023

Choose a reason for hiding this comment

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

yup, for me form option sounds better then instance of check.

On the other hand, if it only breaks displaying of buttons, then maybe it is ok. If people wants to have Save draft button, when using /nodraft path, that contradicts a little to each other but I guess thats another discussion.

Copy link
Member Author

Choose a reason for hiding this comment

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

@konradoboza konradoboza requested a review from a team January 30, 2023 08:58
@barw4 barw4 requested a review from konradoboza January 30, 2023 09:15
@konradoboza konradoboza requested a review from a team January 30, 2023 09:44
try {
$this->innerContentFormProcessor->processSaveDraft($event);
$statusCode = Response::HTTP_OK;
if ($event->getData() instanceof ContentUpdateData) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@barw4 barw4 requested review from ViniTou and Nattfarinn February 7, 2023 13:48
@barw4 barw4 closed this Feb 7, 2023
@barw4 barw4 deleted the ibx-4486-disable-autosave-for-content-create branch February 7, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants