This repository has been archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
P2 786 only render ok when block is valid #1146
Merged
increddibelly
merged 41 commits into
develop
from
P2-786-only-render-ok-when-block-is-valid
May 10, 2021
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
4f15ce7
Added a method that checks if the blockValidationResult is considered…
d976c74
Adds a check to see if the added suggestion is valid
0e3a803
Updates the tests for the blocksuggestions
f772213
Improval of the test by mocking the functions directly
bc2a734
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
9eb9930
Process CR
c467972
Remove typehints in jsdoc
54dfb3a
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
cd2ea53
Check if the block validation is OK
c67c29a
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
ebfa7e5
Merge branch 'develop' of https://github.com/Yoast/javascript into P2…
8e2debd
Refactored the BlockSuggestionsPresenter a little bit
7404075
Changes the working of the validation a little bit.
51d120d
make the SidebarWarningPresenter retrieve validation for a client Id
increddibelly 74d36e4
fix unit tests
increddibelly c89071d
extract the BlockSuggestionsPresenter logic from the component
increddibelly e95a228
BlockSuggestionsPresenter allows more detailed control now; validatio…
increddibelly 565f3fe
Merge branch 'develop' into P2-786-only-render-ok-when-block-is-valid
increddibelly 0426ce0
added additional valid results and validation
increddibelly 9c10dcf
Add validation to RichtTextBase
increddibelly e251ab9
remove unused code
increddibelly 25356ce
added ValidationBlockInstruction to allow blocks to opt-in validation
increddibelly 9872f78
fixing unit tests
increddibelly cd31dfe
fixed unit tests
increddibelly 94a719f
Bump @wordpress/data to the latest version
johannadevos 87a09ca
prevent an error for missing instructions
increddibelly f9f5aaf
Merge remote-tracking branch 'origin/release/16.3' into P2-786-only-r…
increddibelly cad6799
replaced ValidatingBlockInstruction base class with single function
increddibelly 9f8404e
Merge remote-tracking branch 'origin/release/16.3' into P2-786-only-r…
increddibelly 1d0e61d
fine tune variationpicker validation
increddibelly a41779b
fix Date validation
increddibelly 3c14f53
typo
increddibelly e28dcb0
Merge remote-tracking branch 'origin/develop' into P2-786-only-render…
increddibelly 8db91db
fix Date tests.
increddibelly 318b5a3
Update packages/schema-blocks/src/functions/presenters/BlockSuggestio…
increddibelly 0f4d7b1
Update packages/schema-blocks/src/functions/presenters/BlockSuggestio…
increddibelly 94fa03a
processed CR comments
increddibelly c93634a
Update packages/schema-blocks/src/core/validation/BlockValidationResu…
increddibelly 3cfa7f1
fix CS
increddibelly a92916b
make method of reading current block content consistent with other Yo…
increddibelly 0053d33
Removed superfluous isValid check from BlockSuggestionsPresenter.
hansjovis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
extract the BlockSuggestionsPresenter logic from the component
- Loading branch information
commit c89071db5ab5b74841578c74e7826e44bf2729ba
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 38 additions & 21 deletions
59
packages/schema-blocks/src/functions/validators/validateResults.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,64 @@ | ||
import { BlockValidation } from "../../core/validation"; | ||
|
||
/** | ||
* Determines if a specific validation result is valid. | ||
* Determines if a specific validation source is valid. | ||
* | ||
* @param result The source value. | ||
* @param source The source value. | ||
* | ||
* @returns Whether the result is valid. | ||
* @returns Whether the source is valid. | ||
*/ | ||
function isValidResult( result: BlockValidation ): boolean { | ||
return result < 200; | ||
export function isValidResult( source: BlockValidation ): boolean { | ||
return source < 200; | ||
} | ||
|
||
/** | ||
* Determines if the result should lead to Schema output. | ||
* Determines if a specific validation indicates if something is missing. | ||
* | ||
* @param result The source value. | ||
* @param source The validation to check. | ||
* | ||
* @returns Whether the result should lead to Schema output. | ||
* @returns Wether the source indicates something is missing. | ||
*/ | ||
function isResultValidForSchema( result: BlockValidation ): boolean { | ||
return result < 300; | ||
export function isMissingResult( source: BlockValidation ): boolean { | ||
return [ | ||
BlockValidation.MissingRecommendedAttribute, | ||
BlockValidation.MissingRecommendedBlock, | ||
BlockValidation.MissingRecommendedVariation, | ||
|
||
BlockValidation.MissingRequiredAttribute, | ||
BlockValidation.MissingRequiredBlock, | ||
BlockValidation.MissingRequiredVariation, | ||
].includes( source ); | ||
} | ||
|
||
/** | ||
* Determines if the result is OK (in other words, would lead to an orange bullet). | ||
* Determines if the source should lead to Schema output. | ||
* | ||
* @param result The source value. | ||
* @param source The source value. | ||
* | ||
* @returns Whether the result is OK. | ||
* @returns Whether the source should lead to Schema output. | ||
*/ | ||
function isOkResult( result: BlockValidation ): boolean { | ||
return result >= 200 && result < 300; | ||
export function isResultValidForSchema( source: BlockValidation ): boolean { | ||
return source < 300; | ||
} | ||
|
||
/** | ||
* Determines if the result is invalid. | ||
* Determines if the source is OK (in other words, would lead to an orange bullet). | ||
* | ||
* @param result The source value. | ||
* @param source The source value. | ||
* | ||
* @returns Whether the result is invalid. | ||
* @returns Whether the source is OK. | ||
*/ | ||
function isInvalidResult( result: BlockValidation ): boolean { | ||
return result >= 300; | ||
export function isOkResult( source: BlockValidation ): boolean { | ||
return source >= 200 && source < 300; | ||
} | ||
|
||
export { isValidResult, isResultValidForSchema, isOkResult, isInvalidResult }; | ||
/** | ||
* Determines if the source is invalid. | ||
* | ||
* @param source The source value. | ||
* | ||
* @returns Whether the source is invalid. | ||
*/ | ||
export function isInvalidResult( source: BlockValidation ): boolean { | ||
return source >= 300; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think it will be better to not use a magic number, but to explicitly reference it.
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.
Also for the other 'status codes' in this file.