-
Notifications
You must be signed in to change notification settings - Fork 6
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-3265: Disabled User account form during translation #61
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,8 @@ | |
|
||
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; | ||
use eZ\Publish\Core\FieldType\User\Value as ApiUserValue; | ||
use EzSystems\EzPlatformContentForms\Data\Content\ContentUpdateData; | ||
use EzSystems\EzPlatformContentForms\Data\Content\FieldData; | ||
use EzSystems\EzPlatformContentForms\Data\ContentTranslationData; | ||
use EzSystems\EzPlatformContentForms\Data\User\UserAccountFieldData; | ||
use EzSystems\EzPlatformContentForms\FieldType\FieldValueFormMapperInterface; | ||
use EzSystems\EzPlatformContentForms\Form\Type\FieldType\UserAccountFieldType; | ||
|
@@ -46,22 +46,23 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data) | |
$formConfig = $fieldForm->getConfig(); | ||
$rootForm = $fieldForm->getRoot()->getRoot(); | ||
$formIntent = $rootForm->getConfig()->getOption('intent'); | ||
$isTranslation = $rootForm->getData() instanceof ContentTranslationData; | ||
$formData = $rootForm->getData(); | ||
$isTranslation = $formData instanceof ContentUpdateData; | ||
if ($isTranslation) { | ||
return; | ||
} | ||
|
||
$formBuilder = $formConfig->getFormFactory()->createBuilder() | ||
->create('value', UserAccountFieldType::class, [ | ||
'required' => true, | ||
'label' => $fieldDefinition->getName(), | ||
'intent' => $formIntent, | ||
'constraints' => [ | ||
new UserAccountPassword(['contentType' => $rootForm->getData()->contentType]), | ||
new UserAccountPassword(['contentType' => $formData->contentType]), | ||
], | ||
]); | ||
|
||
if ($isTranslation) { | ||
$formBuilder->addModelTransformer($this->getModelTransformerForTranslation($fieldDefinition)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adamwojs could you, please, take a look at #61 (comment)? This PR has to be put on hold until we decide what to do with content translating, as discussed: Dawid says we should use |
||
} else { | ||
$formBuilder->addModelTransformer($this->getModelTransformer()); | ||
} | ||
$formBuilder->addModelTransformer($this->getModelTransformer()); | ||
|
||
$formBuilder->setAutoInitialize(false); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you now verifying instance of
ContentUpdateData
instead? If it's needed, at least$isTranslation
should be properly renamed. Besides, since this variable is used only once, maybe:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because ContentUpdateData is used when translating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isnt that the root of the bug? That
ContentUpdateData
is used for User instead ofContentTranslationData
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ViniTou @konradoboza
translating action goes through
proxyTranslateAction
and then, its response is alwayscontent/edit/draft
, then hitseditVersionDraftAction
and then we are inContentEditViewFilter
when we are usingContentUpdateMapper
->ContentUpdateData
. The same happens for every other content which seems logical because we are in fact editing drafts when translating.Besides even in
TranslationFormProcessor
ContentUpdateData
is built.The source of the bug is the fact that at this point in the form we don't have
UserCreateData
andUserUpdateData
. There is no such thing asUserTranslateData
at all. Every translation ends up withContentUpdateData
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. Not sure if we want to block translating users from the business point of view though. Besides, obtaining content type via
$rootForm->getData()->contentDraft->contentType
seems to work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but
ContentTranslationData
is not used when translating any content, not just user one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and it just means that the issue is bigger.
I believe similar logic is (disabling when translating) is done with CustomerGroup FT in product catalog. Do we have similar issue there as well?? @adamwojs @Steveb-p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Customer Group is rather a separate object not a Field Type so the approach is quite different there.brainfart 😓There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put this topic on hold until we decide how it should really work and by that I mean:
ContentTranslationData
user_account
data be copied? set to null? don't insert anything?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, it is the same issue here then:
https://github.com/ibexa/product-catalog/blob/main/src/bundle/FieldType/CustomerGroup/FieldValueFormMapper.php#L23
I would say, we should use
ContentTranslationData/UserTranslationData
if needed.And show form as disabled, as we did till now.
Even in the PR title you stated disabling and not hiding/removing ;)
But I agree, we can wait for some proper decisions.