@follow-up to #3571917: UI Support for Multi-Value Prop Configuration for Code Components, which created the UI but the actual saving of array items in the code editor. It was able to do this by only enabling the changes if the canvas_dev_mode module was enable, otherwise it would be a broken feature

Description

Persist the array prop configuration defined in the Component Builder UI so that component props can be correctly saved and reloaded in the Canvas editor.

Scope

This issued assumed the UI functionality would be done in #3571917: UI Support for Multi-Value Prop Configuration for Code Components and this issue would only be backend API changes but there are still changes under /ui because.....

When adding a component with props and values, the selected values do not persist after adding the component and revisiting its page.

For limited cardinality, set the minimum value to 2 for all components supporting multi-value.

Note for reviewer

This issue still needs a summary update for it to be worked on

There are 2 MRs

  1. Postponed: !576: scope is too large, issue summary here never accurately defined the scope
  2. !706 Extract the protion of !576 that still deals with schema, this should be committed first

Issue fork canvas-3572553

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

vipin.mittal18 created an issue. See original summary.

chandu7929’s picture

Assigned: Unassigned » chandu7929
wim leers’s picture

Component: Code » Config management
Category: Task » Feature request
Issue tags: +blocker, +Needs tests, +Configuration schema

AFAICT this is the blocking back-end piece? If so: updating issue metadata.

wim leers’s picture

FYI see the video at #3571917-12: UI Support for Multi-Value Prop Configuration for Code Components that demonstrates the UI.

This bit in it has me wondering:

… how do we model that in SDC metadata and in equivalent code component config entity representation? In SDC we definitely can: tests/modules/canvas_test_sdc/components/sparkline/sparkline.component.yml does this. But we want to be sure about code components, too.

→ that would need explicit \Drupal\Tests\canvas\Kernel\Config\JavaScriptComponentValidationTest test coverage additions.

chandu7929’s picture

The multi-value property support is now fully functional. My next steps are to refactor the code, implement unit tests, and resolve the current CI pipeline failures.

chandu7929’s picture

Build is green! 🟢 I'm going to wrap this up by adding test coverage for the new code and doing some final deep testing

chandu7929’s picture

Assigned: chandu7929 » Unassigned
Status: Needs work » Needs review

Added required changes to support Save Multi-Value Prop Configuration for Code Components, hence NR.

chandu7929’s picture

Rebase from UI branch causes some issue, I have fixed all of it, now its ready for review.

narendrar’s picture

Found one issue while testing:

  • Create an image field, mark it as required.
  • Check 'Allow multiple values'
  • Click 'Add to components', and Add
  • Component breaks rendering

Similar is the case with Integer field, if we add decimal values and try to Add component, we can not recover from this state.

chandu7929’s picture

Issue summary: View changes

tedbow made their first commit to this issue’s fork.

narendrar’s picture

Required Image field related issue reported in #10 also exists in 1.x. Hence create new issue #3575410: Code component editor does not require providing an example for required "image" props, then results in 500

tedbow’s picture

Status: Needs review » Needs work

@chandu7929 please clarify the relationship between this MR and the one in #3571917: UI Support for Multi-Value Prop Configuration for Code Components

I updated the MR description based on your update to the issue summary. You added

MR of this issue contains changes from UI issue: https://www.drupal.org/project/canvas/issues/3571917 please keep this in mind while reviewing the changes.

Which makes me think the current MR will not commit the changes to /ui and they are just there for manual testing, but then in #7 you said

Build is green! 🟢 I'm going to wrap this up by adding test coverage for the new code and doing some final deep testing

Then you added 1 commit with test coverage https://git.drupalcode.org/project/canvas/-/merge_requests/567/diffs?com...
But that test coverage is under /ui, so without the other UI changes, these won't pass. So that makes me think we will be committing *all* the changes under /ui, which I am guessing is not correct, hence the need for clarification in the summary.

We really need a phpunit test for this. See @wimleers' comment in #5. Basically, for every change under /src, we need to be asking, "does this need phpunit test changes? Where?"

When you set it to "needs review" in #8, as far as I can tell, there was only a 1-line change under /tests/src https://git.drupalcode.org/project/canvas/-/merge_requests/567/diffs#ddc...

I added some test coverage but only in response to @NarendraR's comment https://git.drupalcode.org/project/canvas/-/merge_requests/567#note_704589 and while trying to unblock that specific point. As a reviewer, I am not going to add all the test coverage needed, and it should be added before setting to Needs Review (or adding a comment as to why it has not been yet).

tedbow’s picture

see #14

tedbow’s picture

@chandu7929 re the test coverage @wimleers asked for in #5

→ that would need explicit \Drupal\Tests\canvas\Kernel\Config\JavaScriptComponentValidationTest test coverage additions.

That is now in https://git.drupalcode.org/project/canvas/-/merge_requests/645

I think it makes more sense to get that issue committed first @isholgueras I think is going to take that back over today

chandu7929’s picture

Issue summary: View changes
chandu7929’s picture

@tedbow - With respect to comment #14:

@chandu7929 please clarify the relationship between this MR and the one in #3571917: UI Support for Multi-Value Prop Configuration for Code Components

I updated the MR description based on your update to the issue summary. You added

MR of this issue contains changes from UI issue: https://www.drupal.org/project/canvas/issues/3571917 please keep this in mind while reviewing the changes.

I already mention over our standup call, we are including UI changes to verify overall functionality of this ticket without it we won't be able to test the functionality.

Which makes me think the current MR will not commit the changes to /ui and they are just there for manual testing, but then in #7 you said

Build is green! 🟢 I'm going to wrap this up by adding test coverage for the new code and doing some final deep testing

Then you added 1 commit with test coverage https://git.drupalcode.org/project/canvas/-/merge_requests/567/diffs?com...
But that test coverage is under /ui, so without the other UI changes, these won't pass. So that makes me think we will be committing *all* the changes under /ui, which I am guessing is not correct, hence the need for clarification in the summary.

Again, As I mention UI changes will require to keep this functionality working it means UI changes will go first then this ticket changes will get merge. In the test I have covered all multi-value support which is needed for this ticket.

We really need a phpunit test for this. See @wimleers' comment in #5. Basically, for every change under /src, we need to be asking, "does this need phpunit test changes? Where?"

When you set it to "needs review" in #8, as far as I can tell, there was only a 1-line change under /tests/src https://git.drupalcode.org/project/canvas/-/merge_requests/567/diffs#ddc...

I don't see the reason not to move in review if all test are coverd for the code I have written.

I added some test coverage but only in response to @NarendraR's comment https://git.drupalcode.org/project/canvas/-/merge_requests/567#note_704589 and while trying to unblock that specific point. As a reviewer, I am not going to add all the test coverage needed, and it should be added before setting to Needs Review (or adding a comment as to why it has not been yet).

I would request reviewer to just review and provide feedback instead on working on the issue directly, let developer work on the feedback otherwise it will be hard for developer to follow what is completed and what's pending.

chandu7929’s picture

@tedbow - After looking at #16 and #17, I don't think anything is pending now, please let me know if that's not the case, except for fixing the CI.

chandu7929’s picture

Rebased from UI branch.

tedbow’s picture

Started to review but I am not clear on what the difference is between the 2 MRs. One branch name ends in "on-1.x" but they are both against 1.x🤔 and new MR has no description and there was no comments to why it was opened.

Anyways, I was reviewing !567 but for some reason it is still showing differences with 1.x that don't make sense, see https://git.drupalcode.org/project/canvas/-/merge_requests/567#note_707104 and https://git.drupalcode.org/project/canvas/-/merge_requests/567#note_707113

So I am going to hold off on reviewing until it is clear which MR I should be reviewing.

@chandu7929 let me know which MR should be reviewed. It looks like they both have /ui changes from #3571917: UI Support for Multi-Value Prop Configuration for Code Components.

I am guessing in #20

Rebased from UI branch.

you meant you were creating a new MR that had the latest changes from #3571917: UI Support for Multi-Value Prop Configuration for Code Components. It sounded like you were rebasing the original MR, also because it was posted before #21, the system message with "chandu7929 opened merge request !649". Maybe a drupal.org glitch 🤷

Anyways, if just 1 MR should be reviewed, please close the other MR for clarity. If they both should be open, please explain the purpose of each.

@chandu7929 I remember in our call you did mention opening up another MR but looked at many other things after the call before I got back to this. Please document the reasons for those actions on the issue, for me or anyone else who might be looking at the issue and wasn't on the call. It doesn't need to be long comment. It could just be

Opening a new MR, please it and ignore !567

But ideally you would close the old one too if it really is outdated

chandu7929 changed the visibility of the branch 3572553-multivalue-props-on-1x to hidden.

chandu7929’s picture

I marked the branch 572553-multivalue-props-on-1x as hidden, as it not require anymore.

chandu7929’s picture

Latest rebase from UI branch.

chandu7929’s picture

Combine all changes for this issue in single commit for ease of review.

chandu7929’s picture

Status: Needs work » Needs review

@tedbow - Combined all changes for this issue in single commit for ease of review, please have a look.

tedbow’s picture

Status: Needs review » Needs work

See MR comments.

I documented which files will be committed in #3568264: Update code component props schema to support 'array' type first but there are still some threads to be addressed in this issue

chandu7929’s picture

Status: Needs work » Needs review

Addressed all feedback and suggestions from MR; moving back to review.

chandu7929’s picture

Rebase with latest 1.x, since UI branch is merged.

tedbow’s picture

Status: Needs review » Needs work

re https://git.drupalcode.org/project/canvas/-/merge_requests/567#note_709870

I think after #3571917: UI Support for Multi-Value Prop Configuration for Code Components we shouldn't see so many /ui changes

From summary

This ticket is limited to saving and retrieving the configuration only. All UI behavior and interactions are handled in a separate ticket

so still needs "Needs issue summary update"

So setting to "Needs work" but to be clear I can still review the other /src portions, I am not blocked on that

chandu7929’s picture

I think after #3571917: UI Support for Multi-Value Prop Configuration for Code Components we shouldn't see so many /ui changes

From summary

This ticket is limited to saving and retrieving the configuration only. All UI behavior and interactions are handled in a separate ticket

so still needs "Needs issue summary update"

So setting to "Needs work" but to be clear I can still review the other /src portions, I am not blocked on that

@tebow - These UI changes are specific to this ticket. They address a regression from version 1.x where component form values failed to persist/display after saving.

As per summary: Persist the multi-value prop configuration defined in the Component Builder UI so that component props can be correctly retrieved and reloaded in the Canvas editor.

tedbow’s picture

Assigned: Unassigned » tedbow

@chandu7929 thanks for addressing the latest point. As per our chat I am going to work on this issue for the next couple days until you are back on it

tedbow’s picture

@chandu7929 once you are working on this again please stop git force pushing and wiping out the commit history. It makes it very hard to review and work on this. Right now the MR only has 3 commits on it. If the commit history existed after MR comments I can often find the git commit the relates to the MR comment but it is not possible now

Ping me if you are having problems bringing in the latest 1.x changes without forcing pusing

tedbow’s picture

Issue summary: View changes

updating summary now that #3571917: UI Support for Multi-Value Prop Configuration for Code Components is merged

@chandu7929 I leaving it tagged as "Needs issue summary update" because there is still info I need to you to update regarding you comment in #32. I left placeholder in the summary

tedbow’s picture

After I merged in 1.x about 17 phpunit started to fail https://git.drupalcode.org/project/canvas/-/pipelines/758486/test_report...

not sure why yet

It might be related to schema related changes I brought in from #3568264: Update code component props schema to support 'array' type. That issue was green but I merged it with 1.x also to see if there are the same test failures there also . running https://git.drupalcode.org/project/canvas/-/pipelines/758601

UPDATE: that job ran with just 1 test fail for new test there, so still have to figure out what is causing the 13 phpunit test fails in this MR

tedbow’s picture

Status: Needs work » Postponed

Regarding #36, I think this issue should be postponed on #3568264: Update code component props schema to support 'array' type. I tested locally and if I revert bringing in those changes it does cause of some of the schema validation errors in test to go away. The problem I think the schema changes in #3568264: Update code component props schema to support 'array' type are probably more correct. Hopefully that issue will be. committed soon(tomorrow?)

I think trying to get the tests passing here is waste of time right now because if there are further changes to #3568264: Update code component props schema to support 'array' type they will break again when it is commited.

@chandu7929 I have some open questions for you on the MR and those would still be good to get answers on while we are waiting on #3568264, just further code changes should probably wait

wim leers’s picture

Title: Save Multi-Value Prop Configuration for Code Components » [PP-1] Save Multi-Value Prop Configuration for Code Components
Issue tags: -Configuration schema

I think this issue should be postponed on

💯 — I don't understand why it hadn't been already. The issue summary is in dire need of an update.

I tagged this Configuration schema in #3, but that's because this only linked to #3571917: UI Support for Multi-Value Prop Configuration for Code Components, even though #3568264: Update code component props schema to support 'array' type predates this. The original issue summary is what AFAICT caused this confusing situation.

wim leers’s picture

Assigned: tedbow » Unassigned
Status: Postponed » Needs work

In fact, the issue summary is so confusing that I'm marking this Needs work instead. While this waits for that issue to land, we should make it clear what the scope/intent is here, and how it relates to/builds upon other issues. 🙏

chandu7929’s picture

Issue summary: View changes

@tedbow - With respect to your comment #37, I verify the changes applying from SCP-261especially this commit and removing the same file changes from branch 3572553-save-multi-value-prop, the following issues occur:

  1. Image with limited/unlimited cardinality
  2. 2 Errors
    Prop "imageLimited" has invalid example value: [[0]] Array value found, but an object is required [[1]] Array value found, but an object is required

  3. Video with limited/unlimited cardinality
  4. Prop "videoLimited" has invalid example value: [[0]] Array value found, but an object is required [[1]] Array value found, but an object is required

  5. List text limited/unlimited cardinality
  6. 2 Errors
    'enum' is not a supported key.
    'meta:enum' is not a supported key.

  7. List number with limited/unlimited cardinality.
  8. 2 Errors
    'enum' is not a supported key.
    'meta:enum' is not a supported key.

So, there's no point in blocking this ticket. We must keep our version of the following files to resolve the issues and fix the failing test.

  • config/schema/canvas.json_schema.yml
  • modules/canvas_dev_mode/src/Hook/UsePrivateApis.php
  • src/Config/Schema/JsonSchemaObject.php
  • tests/src/Kernel/Config/JavascriptComponentStorageTest.php
tedbow’s picture

#3568264: Update code component props schema to support 'array' type is now in!

So, there's no point in blocking this ticket. We must keep our version of the following files to resolve the issues and fix the failing test.

@chandu7929 thanks for investigating. I think, though, that the failures might be legit failures now that the schema has changed. But you mentioned in chat that we need to keep our changes on top of the ones from #3568264: Update code component props schema to support 'array' type. You may be correct.

For now, though, I am going to bring the changes in from 1.x (made in #3568264) exactly as they are so we can get a GitLab CI run with the failures.

re
modules/canvas_dev_mode/src/Hook/UsePrivateApis.php
I don't think we need this anymore. I probably am the one who originally suggested making the schema changes dependent on canvas_dev_mode, but I think that is overly cautious. #3571917: UI Support for Multi-Value Prop Configuration for Code Components already will not show the new UI if canvas_dev_mode is not enabled, so I do not think we need to have the schema be dependent on this.

re src/Config/Schema/JsonSchemaObject.php b/src/Config/Schema/JsonSchemaObject.php. I checked and the only difference is code comments.

re ests/src/Kernel/Config/JavascriptComponentStorageTest.php there is a small test expectation.

tedbow’s picture

Assigned: Unassigned » tedbow

I am going to merge in 1.x

tedbow’s picture

Title: [PP-1] Save Multi-Value Prop Configuration for Code Components » Save Multi-Value Prop Configuration for Code Components

Looking at failures

tedbow’s picture

  1. Tagging needs follow-up because I removing unrelated changes see https://git.drupalcode.org/project/canvas/-/merge_requests/567#note_710320

    commit https://git.drupalcode.org/project/canvas/-/merge_requests/567/diffs?com...

  2. Remove not in summary about duplicate files from #3568264: Update code component props schema to support 'array' type, as this was committed
  3. I agree with @wim-leers regarding in #38 and #39 the summary confusing enough to where it needs to be fixed before it can be worked on.

    but I think part of the problem is the current MR tries to do much. We need to fix the scope. See my next point

  4. This will has parts, validate schema of JavaScriptComponent, does normalization for the client, and fixes UI parts from #3571917: UI Support for Multi-Value Prop Configuration for Code Components.
    We postponed it on #3568264: Update code component props schema to support 'array' type but this issue I think has at least 1 change that probably should have been done there, the changes to src/ComponentMetadataRequirementsChecker.php and the related test coverage changes, which since they bring in a new test component affect a few files.

    I am going to up an MR here, that could mergeed by itself. It might better to move that to its own issue, or just a quick follow-up on #3568264 itself but to save time I am going to add it here.

tedbow’s picture

re #45 4) I have created a new merge https://git.drupalcode.org/project/canvas/-/merge_requests/706

which updates \Drupal\canvas\ComponentMetadataRequirementsChecker::check to valid enum and meta:enum

If we can merge this first it will help get https://git.drupalcode.org/project/canvas/-/merge_requests/567 into something that is more managable.

@wim-leers if you want we can split !706 into its own issue just re-open #3568264: Update code component props schema to support 'array' type instead, and add this a follow-up MR there. It feels like left over from that issue.

tedbow’s picture

Issue summary: View changes
chandu7929’s picture

@tedbow - I don't see the point of creating a separate MR!706 and blocking other merge requests MR!567 for a single line of change you added here . Apart from some tests which are already there in the main branch, we could have worked directly on the main MR and saved two days.

I will validate the main MR!567 with the latest changes and proceed as needed. Let's avoid such practices to prevent wasted time and delayed tickets.

Please let me know if I misunderstood.

  • tedbow committed 91a0c74f on 1.x
    feat: #3572553 Enum validation for array props
    
    By: chandu7929
    By:...
chandu7929’s picture

Issue summary: View changes
tedbow’s picture

@chandu7929 re #49

@tedbow - I don't see the point of creating a separate MR!706 and blocking other merge requests MR!567 for a single line of change you added here .

MR !567 had, and probably still has unyielding scope that, at least for me, makes it hard to review. It is just tackling too many things: schema, validation changes, backend client request normalization, and UI fixes. It has been made worse because the issue summary was very out of date at the time I made !706.

!706 extracted schema and validation changes for one file and the related test changes. There are 8 files total, and it was very clear how the production changes were related to the changes.

It allowed improvements to the one non-test file, not just a one-line change. The one-line change just got rid of the last PHP warning in the test.
I should have committed the file exactly as it was in the other branch first. Sorry, I meant to. If you want to see the first difference, run git diff 4b16d8870fdc50c4fcfa11459c55e4829ef11740 -- src/ComponentMetadataRequirementsChecker.php

Let's avoid such practices to prevent wasted time and delayed tickets.

Sorry, I respectfully disagree that this has wasted time on the issue. !706 made a well-defined MR that could be committed quickly, leaving !567 closer to manageable and reviewable scope.

tedbow’s picture

Assigned: tedbow » Unassigned
vipin.mittal18’s picture

  • The main intention of this ticket is to ensure that multi-value prop components are correctly saved
  • Any validation related to dropping components in the Canvas editor should not be considered part of this ticket. I would request the team to keep that scope separate. Ted , Chandan and I have already connected and aligned on this approach.
  • Wim you are already contributing, I just wanted to make sure you are aligned with this direction. If any work related to that has already been done, that is fine—we don’t need to revert it. However, for this ticket, let’s keep the focus strictly on the shape component and its specific behavior.
  • Once this part is completed, we can then focus on dragging components for each prop type in the Canvas editor and address those issues separately.
tedbow’s picture

Assigned: Unassigned » tedbow
Status: Needs work » Needs review

Reviewing

chandu7929’s picture

Issue summary: View changes
chandu7929’s picture

MR567 is ready for review from UI perspective as well. No further changes. some tests are failing which need to be fixed.

kunal.sachdev’s picture

Status: Needs review » Needs work

Added some feedback!

chandu7929’s picture

Status: Needs work » Needs review

Setting to NR since I have addressed all feedback related to FE

kunal.sachdev’s picture

Status: Needs review » Needs work

Just one more nit!!

chandu7929’s picture

Status: Needs work » Needs review

  • tedbow committed 0920a02a on 1.x authored by chandu7929
    feat: #3572553 Save Multi-Value Prop Configuration for Code Components...
tedbow’s picture

wim leers’s picture

Priority: Normal » Critical
Status: Needs review » Needs work
Issue tags: +technical debt

Progress++ — so +1 to merging this to unblock more progress 😊

@tedbow walked me through the parts he was most concerned about. The one that stood out the most to me: the changes to \Drupal\canvas\Entity\JavaScriptComponent::updateFromClientSide() to auto-fix invalid props provided by the client must be reverted. Specifically, the entirety of \Drupal\canvas\Entity\JavaScriptComponent::normalizePropsSchema() must be reverted — that is pure technical debt being added, and is literally opposed to what #3568264: Update code component props schema to support 'array' type did, which is what this was blocked on in the first place! Details on the MR.

tedbow’s picture

Assigned: chandu7929 » wim leers
Status: Needs work » Needs review

@wimleers assign to your for review on https://git.drupalcode.org/project/canvas/-/merge_requests/742
good news we were able to remove the backend changes you were concerned about in #64. I should caught this in review

wim leers’s picture

Assigned: wim leers » tedbow
Status: Needs review » Reviewed & tested by the community

LGTM!

tedbow’s picture

Assigned: tedbow » Unassigned
Status: Reviewed & tested by the community » Needs work

!742 needs to updated against 1.x

wim leers’s picture

  • tedbow committed 94e27a47 on 1.x
    feat: #3572553 Correct client request to eliminate need for...
wim leers’s picture

Assigned: Unassigned » tedbow
Status: Needs work » Patch (to be ported)

Wanted to mark this Fixed but spotted the Needs followup tag. Is that still accurate?

tedbow’s picture

Status: Patch (to be ported) » Fixed
Issue tags: -Needs followup

Does not need a follow-up see https://git.drupalcode.org/project/canvas/-/merge_requests/567#note_716773 . Was code that was already in 1.x

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.