docbrown/app/views
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
..
admin Display analytics up to yesterday instead of today (#17064) 2022-04-04 15:17:32 -04:00
api/v0 Add ability to bulk search tags by name or id (#16671) 2022-02-24 12:34:50 -05:00
articles Revert "Added a way to sort comments on an article (#16686)" (#17093) 2022-04-04 08:36:34 -04:00
authorization/articles conditionally render create post button for admins #16490 (#16606) 2022-03-29 13:04:57 -04:00
badges views/badges etc i18n (#15021) 2021-10-20 09:36:30 -06:00
collections Page headers unified (#15158) 2021-10-25 21:41:29 +02:00
comments Revert "Added a way to sort comments on an article (#16686)" (#17093) 2022-04-04 08:36:34 -04:00
credits Add a contact email address to the /admin/customization/config (#16497) 2022-02-15 17:37:08 +02:00
dashboards Conditionally reducing dashboard chatter for users (#16999) 2022-03-25 13:59:53 -04:00
deep_links Add a contact email address to the /admin/customization/config (#16497) 2022-02-15 17:37:08 +02:00
devise Remove Creator Onboarding Feature Flags from Codebase (#15982) 2022-01-31 11:30:43 -07:00
email_subscriptions I18nize views misc & non-HTML templates (#15136) 2021-12-08 11:28:16 -05:00
feedback_messages views/feedback_messages i18n (#15038) 2021-10-27 12:34:56 +01:00
fields views/tags etc i18n (#15039) 2021-10-20 08:13:51 -06:00
followings Move HexComparer to Hex::Comparer service (#12202) 2021-01-12 11:34:30 -05:00
github_repos
homepage
kaminari Admin member index: Update pagination layout & styles (#16995) 2022-03-25 07:50:50 +00:00
layouts Conditional rendering of "Create Post" link (#17076) 2022-04-05 12:47:12 -04:00
liquid_embeds Move work from template to controller (#16092) 2022-01-18 11:21:25 -05:00
liquids OpenGraph fallback for Embeds (merge-by-any-core) (#17001) 2022-04-04 15:31:38 -04:00
listings Replace listings tag component (#16855) 2022-03-30 16:51:40 +01:00
mailers Add a contact email address to the /admin/customization/config (#16497) 2022-02-15 17:37:08 +02:00
moderations Filter admin users by status (#16238) 2022-03-02 11:13:59 -05:00
notifications Revert ERB comment tag work-around from #17012 (#17035) 2022-03-28 15:16:24 -05:00
onboardings Ensuring that body.dataset is JSON parsable (#16441) 2022-02-08 07:30:43 -05:00
open_search Add a contact email address to the /admin/customization/config (#16497) 2022-02-15 17:37:08 +02:00
organizations Revert ERB comment tag work-around from #17012 (#17035) 2022-03-28 15:16:24 -05:00
pages Implement Loom Embed (not merging now) (#16633) 2022-02-22 09:05:55 -05:00
podcast_episodes Always show the browse section of podcasts regardless of featured (#16329) 2022-03-22 12:56:54 -04:00
podcasts views/podcasts, views/podcast_episodes i18n (#15020) 2021-10-25 14:32:51 +01:00
profile_field_groups
profile_preview_cards Profile attribute names should be unique and non-empty (#16396) 2022-04-04 12:14:02 -05:00
reading_list_items views/reading_list_items i18n (#15041) 2021-10-18 11:32:57 -07:00
response_templates
service_worker Revert "Revert "Removed service worker (#12974)" (#13014)" (#13015) 2021-03-17 10:57:56 -04:00
shared Profile attribute names should be unique and non-empty (#16396) 2022-04-04 12:14:02 -05:00
sidebars fix grid col overflow in right sidebar in safari (#16771) 2022-03-03 07:51:16 -06:00
sitemaps Fix legacy sitemap logic (#14926) 2021-10-07 08:59:16 -04:00
social_previews Render social previews for tags with one of the two custom colors set (#16557) 2022-02-15 09:56:57 -06:00
stories Use the canonical URLs to link from sorted pages (#16928) 2022-03-22 14:51:36 +00:00
tags Use the Preact ColorPicker in creator onboarding (#16731) 2022-03-03 08:22:10 +00:00
users Applying more liberal editor config policy (#17125) 2022-04-05 11:38:41 -04:00
videos Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00