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

Comments

Show an orange bullet in the sidebar analysis when a recommended block is removed#1116

Merged
johannadevos merged 31 commits intodevelopfrom
P2-706-orange-analysis
Mar 29, 2021
Merged

Show an orange bullet in the sidebar analysis when a recommended block is removed#1116
johannadevos merged 31 commits intodevelopfrom
P2-706-orange-analysis

Conversation

@johannadevos
Copy link
Contributor

@johannadevos johannadevos commented Mar 23, 2021

Summary

This PR can be summarized in the following changelog entry:

  • [schema-blocks] Adds an orange bullet to the Analysis in the side bar when a recommended block is removed.

Relevant technical choices:

  • I added an enum Blocktype in BlockValidationResult.ts, which holds the different block types (required, recommended, optional, and for the time being, also unknown).
  • I added a blockType parameter to the BlockValidationResult class, with the type being BlockType.
  • As a result, everywhere where the BlockVariationResult class is instantiated, it needs to be passed a blockType parameter.
  • This is why I also added unknown as a value to the enum; I'm passing unknown to all instantiations of BlockValidationResult which are outside the scope of this PR. We could look into fixing this, but I'm not sure it worth the time investment right now. The thing is that we don't know the block type for many block instances, since the block templates themselves don't pass their own block type (instead, it is listed in job-posting.block.php what is the block type for each block).
  • The validateInnerBlocks function in innerBlocksValid.ts now also calls the findMissingBlocks function for recommended blocks (it used to call this function only for required blocks).
  • I did some renames in the findMissingBlocks function to reflect this.
  • For each missing/removed block, the findMissingBlocks function adds the block type to the BlockValidationResult. These results will be used in the sidebar (as the status of the messageData in SidebarWarningPresenter.ts) to show the appropriate warning.

Test instructions

This PR can be tested by following these steps:

  • Add the Yoast Job Posting block.
  • See that there are no orange bullets in the Analysis in the side bar, because all the recommended blocks are present upon initialization.
  • You should see a red bullet saying "Not all required blocks are complete! No job posting schema will be generated for your page." (this is because title, description and location have not yet been filled in).

Test scenario 7

  • Remove a recommended block, for example the 'Requirements'.

  • See an orange bullet and the text: "The 'Requirements' block is recommended but missing.":
    Screenshot 2021-03-23 at 15 21 24

  • See that the Requirements block is greyed out and can be added:
    Screenshot 2021-03-23 at 15 21 49

  • Remove another recommended block and see another orange bullet appear (with the right text).

  • The red bullet saying "Not all required blocks are complete! No job posting schema will be generated for your page." should still be present.

Test scenario 8

  • Fill in the title, description and location.
  • The red bullet should become green and say: "Good job! All required blocks are complete.".
  • You should still see one or more orange bullets corresponding to the recommended blocks you have removed.
  • Remove a required block and see that there are now two red bullets: one saying which block is missing, and one saying that not all required blocks are completed.

Test Schema output

  • Fill in a recommended block and see that it is present in the Schema output.

Note that scenarios 7 and 8 both contain a line regarding the color of the emoticon in the pre-publish check; I didn't solve that yet as there is a separate ticket for this task: https://yoast.atlassian.net/browse/P2-789.

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 https://yoast.atlassian.net/browse/P2-706

@johannadevos johannadevos added innovation changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog labels Mar 23, 2021
@johannadevos johannadevos added this to the 16.2 milestone Mar 23, 2021
@johannadevos johannadevos added the UI change PRs that result in a change in the UI label Mar 23, 2021
Copy link
Contributor

@increddibelly increddibelly left a comment

Choose a reason for hiding this comment

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

zie opmerkingen; het zou nog zeer waardevol zijn om dit deel over te dragen aan de onderliggende functie dwz dat daar de splitsing op recommended / required wordt gemaakt, maar alleen als het in een uur of twee kost.

Copy link
Contributor

@andizer andizer left a comment

Choose a reason for hiding this comment

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

CR done

return warning.replace( "{parent}", __( issue.parent, "wpseo-schema-blocks" ) )
.replace( "{child}", __( issue.name, "wpseo-schema-blocks" ) )
.replace( "{status}", __( issue.status, "wpseo-schema-blocks" ) );
.replace( "{presence}", __( issue.presence, "wpseo-schema-blocks" ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this will cause merge conflicts with #1127 where this logic (replaceVariables) has been removed.

Also please not that dynamic arguments for translations aren't translatable. The potfile builder will take issue.presence as value to translate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know!

issue.result === BlockValidation.MissingAttribute ) ) {
return {
text: __( "Not all required blocks are completed! No " + issues[ 0 ].parent +
text: __( "Not all required blocks have been completed! No " + issues[ 0 ].parent +
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic has also been changed in #1127


const messages = messageData.map( msg => {
return { text: replaceVariables( msg ), color: "red" } as sidebarWarning;
return { text: replaceVariables( msg ), color: ( msg.presence === BlockPresence.Recommended ? "orange" : "red" ) } as sidebarWarning;
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip: I would make this more readable by adding newlines. Especially the conditional makes this all hard to read/process

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. But I believe this code has been changed in #1127 anyway.

@johannadevos
Copy link
Contributor Author

I'm merging this PR with the blessing of the other devs in the team.

It has already been acceptance tested in a demo with @dariaknl.

The comments from @andizer's CR all relate to conflicts with #1127. We will resolve those conflicts after this PR has been merged to develop.

@johannadevos johannadevos merged commit 5f32614 into develop Mar 29, 2021
@johannadevos johannadevos deleted the P2-706-orange-analysis branch March 29, 2021 12:51
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.

3 participants