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

Implemented query panel in latest posts block. #3198

Merged
merged 1 commit into from Dec 14, 2017

Conversation

@jorgefilipecosta
Member

jorgefilipecosta commented Oct 27, 2017

Description

Ths PR aims to implement the query panel specified in issue #2662.

The panel is added to latest posts block. But this leaves a discussion point, it allows, for example, to show 8 oldest posts by setting sorting from oldest to newest.
To solve this we need to make a decision :
We rename this block to "Posts" allowing to show the most recent ones or oldest or other option the user chooses.
Or we maintain the most recent posts concept, we always retrieve from the database the N most recent posts and then we sort this recent posts in accordance with the sorting criteria the user selected.
Feel free to share your options.

How Has This Been Tested?

Try to change the values of the 3 different options in the query panel. Verify that the posts in the editor update in accordance with the option selected. Save the post on each option change, and open the post, verify the server side render also shows the selected option correctly.

Screenshots (jpeg or gifs if applicable):

screen shot 2017-10-27 at 12 16 01

screen shot 2017-10-27 at 12 16 35

screen shot 2017-10-27 at 12 16 23

Notes

There is a bug where component looks like loading forever if there are no posts that become more visible with this changes (because we can more easily select options without posts). A fix is being issued in #3180.

The function buildTermsTree in utils was extracted from HierarchicalTermSelector component. As a future PR, this component will be refactored to make use of the utils function (removing the duplicate version) and will also be simplified/refactored to make use of the new component TermTreeSelect created in this PR.

@jorgefilipecosta jorgefilipecosta changed the title from Implemented query panel in latest posts block. to WIP Implemented query panel in latest posts block. Oct 27, 2017

@jorgefilipecosta jorgefilipecosta self-assigned this Oct 27, 2017

@jorgefilipecosta jorgefilipecosta requested review from youknowriad and iseulde Oct 27, 2017

@jorgefilipecosta jorgefilipecosta changed the title from WIP Implemented query panel in latest posts block. to Implemented query panel in latest posts block. Oct 27, 2017

@jorgefilipecosta jorgefilipecosta requested a review from karmatosed Oct 27, 2017

@aduth

Personally I'd have preferred to see the Latest Posts block updated to use withAPIData before enhancing it to handle additional data attributes.

Show outdated Hide outdated blocks/library/latest-posts/index.php
Show outdated Hide outdated blocks/query-panel/index.js
Show outdated Hide outdated blocks/query-panel/index.js
Show outdated Hide outdated blocks/query-panel/index.js
Show outdated Hide outdated blocks/term-tree-select/index.js
Show outdated Hide outdated blocks/term-tree-select/index.js
Show outdated Hide outdated editor/utils/terms.js
@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Oct 31, 2017

Member

Thank you for your suggestions @aduth. I think I addressed all of them excluding an alignment in a php file. I made some changes to make things look better, but type item in categories is still not aligned with other types of other attributes, as the other type elements are not siblings (they are "cousins") if we add more spaces we break a phpcs rule. Regarding the refactoring to withAPIData in latest posts, as postsCollection.fetch supported exactly the parameters we needed, I would prefer to do this change in a separate PR.

Member

jorgefilipecosta commented Oct 31, 2017

Thank you for your suggestions @aduth. I think I addressed all of them excluding an alignment in a php file. I made some changes to make things look better, but type item in categories is still not aligned with other types of other attributes, as the other type elements are not siblings (they are "cousins") if we add more spaces we break a phpcs rule. Regarding the refactoring to withAPIData in latest posts, as postsCollection.fetch supported exactly the parameters we needed, I would prefer to do this change in a separate PR.

@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Nov 8, 2017

Member

Hi @aduth, thank you for your feedback 👍 , I rebased and addressed all the points.

Member

jorgefilipecosta commented Nov 8, 2017

Hi @aduth, thank you for your feedback 👍 , I rebased and addressed all the points.

@aduth

Requests incurred from unrelated attribute changes should be addressed.

Show outdated Hide outdated blocks/library/latest-posts/index.php
Show outdated Hide outdated blocks/library/latest-posts/index.js
Show outdated Hide outdated blocks/query-panel/index.js
Show outdated Hide outdated blocks/query-panel/index.js
@karmatosed

Design wise approving. I did find a bug though in changing the number of items. It got stuck after going to higher number then 1.

@codecov

This comment has been minimized.

Show comment
Hide comment
@codecov

codecov bot Nov 13, 2017

Codecov Report

Merging #3198 into master will decrease coverage by 0.2%.
The diff coverage is 26.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3198      +/-   ##
==========================================
- Coverage   37.85%   37.65%   -0.21%     
==========================================
  Files         279      283       +4     
  Lines        6778     6748      -30     
  Branches     1240     1227      -13     
==========================================
- Hits         2566     2541      -25     
+ Misses       3547     3545       -2     
+ Partials      665      662       -3
Impacted Files Coverage Δ
blocks/library/latest-posts/data.js 0% <ø> (ø) ⬆️
blocks/term-tree-select/index.js 0% <0%> (ø)
blocks/library/latest-posts/index.js 6.38% <0%> (-3.43%) ⬇️
utils/terms.js 100% <100%> (ø)
blocks/query-panel/index.js 25% <25%> (ø)
blocks/query-panel/category-select.js 33.33% <33.33%> (ø)
components/panel/color.js 0% <0%> (-100%) ⬇️
components/panel/row.js 0% <0%> (-100%) ⬇️
editor/components/warning/index.js 0% <0%> (-100%) ⬇️
editor/utils/mobile/index.js 57.14% <0%> (-17.86%) ⬇️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d37adf...e17bef4. Read the comment docs.

codecov bot commented Nov 13, 2017

Codecov Report

Merging #3198 into master will decrease coverage by 0.2%.
The diff coverage is 26.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3198      +/-   ##
==========================================
- Coverage   37.85%   37.65%   -0.21%     
==========================================
  Files         279      283       +4     
  Lines        6778     6748      -30     
  Branches     1240     1227      -13     
==========================================
- Hits         2566     2541      -25     
+ Misses       3547     3545       -2     
+ Partials      665      662       -3
Impacted Files Coverage Δ
blocks/library/latest-posts/data.js 0% <ø> (ø) ⬆️
blocks/term-tree-select/index.js 0% <0%> (ø)
blocks/library/latest-posts/index.js 6.38% <0%> (-3.43%) ⬇️
utils/terms.js 100% <100%> (ø)
blocks/query-panel/index.js 25% <25%> (ø)
blocks/query-panel/category-select.js 33.33% <33.33%> (ø)
components/panel/color.js 0% <0%> (-100%) ⬇️
components/panel/row.js 0% <0%> (-100%) ⬇️
editor/components/warning/index.js 0% <0%> (-100%) ⬇️
editor/utils/mobile/index.js 57.14% <0%> (-17.86%) ⬇️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d37adf...e17bef4. Read the comment docs.

@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Nov 14, 2017

Member

Hi @karmatosed, I was able to replicate something similar to what you described. When increasing number of posts to show the posts were not refreshing, leaving the user to be stuck in one post if a value of one was set before. It was introduced by a typo I made while addressing the last reviews and was fixed. Thank you for reporting the problem and for reviewing the design :)

Member

jorgefilipecosta commented Nov 14, 2017

Hi @karmatosed, I was able to replicate something similar to what you described. When increasing number of posts to show the posts were not refreshing, leaving the user to be stuck in one post if a value of one was set before. It was introduced by a typo I made while addressing the last reviews and was fixed. Thank you for reporting the problem and for reviewing the design :)

@jorgefilipecosta jorgefilipecosta requested review from mcsf and gziolo Nov 22, 2017

@mcsf

I need to run, so here's a more drive-by review.

Show outdated Hide outdated blocks/library/latest-posts/index.js
Show outdated Hide outdated editor/utils/terms.js
Show outdated Hide outdated blocks/query-panel/category-select.js
Show outdated Hide outdated blocks/term-tree-select/index.js
Show outdated Hide outdated blocks/query-panel/category-select.js
Show outdated Hide outdated blocks/library/latest-posts/index.php
Show outdated Hide outdated blocks/query-panel/index.js
Show outdated Hide outdated editor/utils/terms.js
@jorgefilipecosta

This comment has been minimized.

Show comment
Hide comment
@jorgefilipecosta

jorgefilipecosta Nov 27, 2017

Member

Hi @mcsf, thank you a lot for your review, your feedback was applied.

Member

jorgefilipecosta commented Nov 27, 2017

Hi @mcsf, thank you a lot for your review, your feedback was applied.

@jorgefilipecosta jorgefilipecosta merged commit d94d742 into master Dec 14, 2017

3 checks passed

codecov/project 38.43% (+0.01%) compared to 9bb6609
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@jorgefilipecosta jorgefilipecosta deleted the add/query-panel branch Dec 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment