sensei icon indicating copy to clipboard operation
sensei copied to clipboard

Hide query inherit and post type from course list block settings

Open Imran92 opened this issue 3 years ago • 2 comments

Resolves https://github.com/Automattic/sensei/issues/5415

Changes proposed in this Pull Request

  • Our Course List block, being a variation of Query Loop block was showing all the Settings of the main block. That includes a couple of settings changing which breaks the functionality of our block. So we've hidden the the "Inherit query from template" and "Post type" settings in this PR.

The solution is a bit hackish here, but GB team is working on making the settings configurable. So this is temporary and we will be able to do it the proper way later.

Testing instructions

  • Add the Course List block in the GB editor
  • Select a Course List pattern
  • Make sure the Course List block is selected
  • Make sure the settings panel on the right does not show Post type and Query Inherit configurations mentioned above
  • Add a normal Query Loop block in the GB editor
  • Make sure all the configs are available in the settings
  • Save the editor and check these behaviors again

Screenshot / Video

https://user-images.githubusercontent.com/6820724/184234374-eb1c40e2-0f25-4543-9f31-bb42085f23c9.mov

Imran92 avatar Aug 11 '22 20:08 Imran92

Codecov Report

Merging #5449 (05ded8c) into feature/courses-list (4bc979d) will increase coverage by 0.05%. The diff coverage is n/a.

Impacted file tree graph

@@                    Coverage Diff                     @@
##             feature/courses-list    #5449      +/-   ##
==========================================================
+ Coverage                   44.54%   44.60%   +0.05%     
- Complexity                   8729     8733       +4     
==========================================================
  Files                         412      413       +1     
  Lines                       31123    31152      +29     
  Branches                      234      234              
==========================================================
+ Hits                        13865    13894      +29     
  Misses                      17085    17085              
  Partials                      173      173              
Impacted Files Coverage Δ
includes/blocks/class-sensei-page-blocks.php 0.00% <0.00%> (ø)
...udes/blocks/class-sensei-continue-course-block.php 68.18% <0.00%> (ø)
...ncludes/blocks/class-sensei-block-view-results.php 58.33% <0.00%> (+58.33%) :arrow_up:

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 f1528f8...05ded8c. Read the comment docs.

codecov[bot] avatar Aug 11 '22 20:08 codecov[bot]

This wasn't working for me and I realized it's when the sidebar is hidden initially:

  • In the editor, click the gear icon to hide the settings sidebar.
  • Add the Course List block and choose the first pattern.
  • Click the gear icon to show the settings sidebar.
  • Block settings are visible.

This isn't too big of a deal, but it would be nice to fix if possible. 🙂

donnapep avatar Aug 12 '22 18:08 donnapep

This wasn't working for me and I realized it's when the sidebar is hidden initially:

  • In the editor, click the gear icon to hide the settings sidebar.
  • Add the Course List block and choose the first pattern.
  • Click the gear icon to show the settings sidebar.
  • Block settings are visible.

This isn't too big of a deal, but it would be nice to fix if possible. 🙂

A very good catch @donnapep ! Thank you! 🚀 I've updated the code here, can you kindly take a look again?

Imran92 avatar Aug 15 '22 12:08 Imran92

I agree that this is hacky and brittle. If they change the label even slightly, this will break. 🙁 Hopefully we'll be able to get rid of this workaround soon.

Yeah, I feel the same way too, hope we'll able to change it very soon.

Unfortunately, I found another scenario where this doesn't work, and that's when I collapse the Settings panel. When I expand the panel again, the settings are there.

Oho, side effect of removing setTimeout, who knew it would become so much useful :p I've changed my approach again here https://github.com/Automattic/sensei/pull/5449/commits/fb16cad08043a47761ca1f9fb9e079e3b79bbd4d. Can you kindly take a look?

Imran92 avatar Aug 16 '22 18:08 Imran92