Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

P2 786 only render ok when block is valid #1146

Merged
merged 41 commits into from
May 10, 2021

Conversation

andizer
Copy link
Contributor

@andizer andizer commented Apr 7, 2021

Summary

This PR can be summarized in the following changelog entry:

  • [@yoast/schema-blocks] Shows the ok only when the added block suggestion hasn't any validation issues.

Relevant technical choices:

  • removed unneeded transform in jest config.
  • prevent error in Instruction base class.
  • Added required option to BaseInstruction to reduce code duplication.
  • Moved default validation logic to a function; not all blocks need validation at all. Now, validation is UNKNOWN by default, or blocks can (re)use the default validation function.
  • Moved some definitions to their own files.
  • Cleaned up /src/core/blocks imports / exports.
  • Cleaned up src/core/validation exports.
  • De-duplicated an error code.
  • Removed duplicate code.
  • extracted logic from BlockSuggestionsPresenter.tsx so the presenter only presents.
  • used a store subscriber in PureBlockSuggestionsPresenter to update the suggestions as they change.
  • added new selectors: getValidationResultForClientId,getInnerblockValidations
  • added some defensive input checks
  • new helpder function recursivelyfind to navigate the tree of BlockValidationResults using a predicate.
  • fine-tuned validation logic of some instructions to match new (default-) validation logic
  • unit tests.

Test instructions

This PR can be tested by following these steps:

  • Add a job block to a new post
  • See that most of the items do not have a green checkmark in the sidebar. The analysis conclusion is still RED.
  • complete the template for all required blocks shown in the sidebar. Check marks should appear instantly when a non-whitespace character is added.
  • When all required blocks are completed, verify that the good job congratulation is shown.

Impact check

  • This PR affects the following parts of the plugin, which may require extra testing:
    *

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Quality assurance

  • I have tested this code to the best of my abilities
  • I have added unittests to verify the code works as intended

Fixes #

@andizer andizer added innovation changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog labels Apr 7, 2021
@andizer andizer added changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog and removed changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog labels Apr 8, 2021
Andy Meerwaldt added 4 commits April 8, 2021 10:29
…-786-only-render-ok-when-block-is-valid

# Conflicts:
#	packages/schema-blocks/src/functions/validators/index.ts
…-786-only-render-ok-when-block-is-valid

# Conflicts:
#	packages/schema-blocks/src/functions/presenters/BlockSuggestionsPresenter.tsx
#	packages/schema-blocks/tests/functions/presenters/BlockSuggestions.test.ts
@johannadevos
Copy link
Contributor

johannadevos commented Apr 9, 2021

Acceptance: 🚧

  • When I add the Job Posting block, all the recommended blocks shown an OK although they are empty, as well as the Location block:

Screenshot 2021-04-09 at 08 45 21

With regard to the Location block, I think you need the code from #1142 / P2-807.

  • When I add text to the Job title and Job description, OK appears immediately, and disappears again when I remove the text.

@andizer Did you test your code again after pushing the latest changes?

Andy Meerwaldt and others added 14 commits April 12, 2021 08:51
…-786-only-render-ok-when-block-is-valid
…-786-only-render-ok-when-block-is-valid

# Conflicts:
#	packages/schema-blocks/src/functions/presenters/BlockSuggestionsPresenter.tsx
#	packages/schema-blocks/tests/functions/presenters/__snapshots__/BlockSuggestions.test.ts.snap
Might need some additional work
# Conflicts:
#	packages/schema-blocks/src/functions/presenters/BlockSuggestionsPresenter.tsx
#	packages/schema-blocks/src/functions/presenters/SidebarWarningPresenter.ts
#	packages/schema-blocks/tests/functions/presenters/SidebarWarningPresenter.test.ts
@increddibelly
Copy link
Contributor

closed existing comments as this PR needs a thorough re-review.

increddibelly and others added 3 commits May 6, 2021 11:34
…nsPresenter.tsx

Co-authored-by: Hans-Christiaan Braun <hans-christiaan@yoast.com>
…nsPresenter.tsx

Co-authored-by: Hans-Christiaan Braun <hans-christiaan@yoast.com>
…lt.ts

Co-authored-by: Hans-Christiaan Braun <hans-christiaan@yoast.com>
@increddibelly
Copy link
Contributor

Acceptance: 🚧

  • When I add the Job Posting block, all the recommended blocks shown an OK although they are empty, as well as the Location block:
Screenshot 2021-04-09 at 08 45 21

With regard to the Location block, I think you need the code from #1142 / P2-807.

  • When I add text to the Job title and Job description, OK appears immediately, and disappears again when I remove the text.

@andizer Did you test your code again after pushing the latest changes?

we have not yet fixed all of these; we'd have to add a validation method ( or use the defaultValidation function ) in each specific block's instruction code. As we're moving focus away from the job posting block to the to the bigger issue of UX and discovery of desired features, we will not be fixing them all right now but only as needed in the future.

@hansjovis
Copy link
Contributor

CR: 👍

  • I did simplify a couple of lines of code. (since we already check whether isValid is true, we do not the second check a few lines before).

@increddibelly increddibelly merged commit 565f0c1 into develop May 10, 2021
@increddibelly increddibelly deleted the P2-786-only-render-ok-when-block-is-valid branch May 10, 2021 10:11
@increddibelly increddibelly added this to the 16.4 milestone May 18, 2021
@increddibelly increddibelly added UI change PRs that result in a change in the UI changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog and removed changelog: bugfix Needs to be included in the 'Bugfixes' category in the changelog labels May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog innovation UI change PRs that result in a change in the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants