docbrown/app/views/layouts
Jeremy Friesen c3c884f4d0
Conditional rendering of "Create Post" link (#17076)
* WIP - Conditional rendering of "Create Post" link

This PR builds on the conversation from forem/forem#17056 and moves in a
slightly different direction.

Important in all of this is that the ability to create a post is
enforced on the server.  If the "Create Post" button were to be visible
but the user couldn't create a post when they clicked the button, they
would get an authorization error (or some such response).

This PR posits a different and perhaps competing approach to
forem/forem#16606.  This PR provides a general approach in which we add
class attributes in our HTML erb files.

Note: I have not included Cypress tests as I don't want to yet commit
that time.  I'm also wondering if this is the "right" thing to do.  I
definitely think we want to add some JS tests.  But could we do JS and
unit tests?  (How do we reach consensus regarding our test approach?)

Again, thank you for the conversation and expect an even more "complete"
PR after we have our discussion.

* Extracting AsyncInfo model to ease testing

* Renaming forbidden to visible

* Adding cypress test to assert no 'Create Post'

These are always treacherous.  What happens when we rename the button?
The test will continue to work.

* Apply suggestions from code review

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Switching to pack file for policy

Follows on [Suzanne's comment](https://github.com/forem/forem/pull/17076#issuecomment-1088567286)

* Update app/javascript/packs/applyApplicationPolicyToggles.js

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-05 12:47:12 -04:00
..
_footer.html.erb Update remaining Crayons icons (#16100) 2022-01-18 13:41:04 +07:00
_logo.html.erb Remove Creator Onboarding Feature Flags from Codebase (#15982) 2022-01-31 11:30:43 -07:00
_main_nav.html.erb Adding conditional rendering of navigation links (#16362) 2022-02-01 12:23:58 -05:00
_nav_menu.html.erb Conditional rendering of "Create Post" link (#17076) 2022-04-05 12:47:12 -04:00
_sidebar_nav_link.html.erb Adding conditional rendering of navigation links (#16362) 2022-02-01 12:23:58 -05:00
_sidebar_tags.html.erb Update remaining Crayons icons (#16100) 2022-01-18 13:41:04 +07:00
_signup_modal.html.erb views/stories, views/layouts and other homepage i18n (#15083) 2021-11-10 07:38:43 -06:00
_social_media.html.erb Update remaining Crayons icons (#16100) 2022-01-18 13:41:04 +07:00
_styles.html.erb CSS size reduce + cleanups. (#12625) 2021-02-16 13:44:26 +01:00
_top_bar.html.erb conditionally render create post button for admins #16490 (#16606) 2022-03-29 13:04:57 -04:00
_user_config.html.erb Theming cleanup (#15237) 2021-11-09 10:11:55 -05:00
admin.html.erb tweak crayons layout for admin section (#17122) 2022-04-05 13:14:50 +01:00
application.html.erb theme-color (#16651) 2022-02-22 15:52:14 +01:00
mailer.html.erb I18nize views misc & non-HTML templates (#15136) 2021-12-08 11:28:16 -05:00
mailer.text.erb