docbrown/app/javascript
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
..
.storybook Now <viewbox /> is preserved in SVGs when using the inline-react-svg plugin (#16287) 2022-01-24 16:25:14 -05:00
actionsPanel Filter admin users by status (#16238) 2022-03-02 11:13:59 -05:00
admin Use the Preact ColorPicker in creator onboarding (#16731) 2022-03-03 08:22:10 +00:00
analytics Remove dots from chart when time range is Infinity (#16720) 2022-03-02 15:20:36 +00:00
article-form Bump to Rails 7.0.2.2 MVP (#15908) 2022-03-30 15:00:33 -04:00
articles Fix pinned post not showing on feed tabs (#16574) 2022-02-17 15:49:26 +00:00
colorPickers Use the Preact ColorPicker in creator onboarding (#16731) 2022-03-03 08:22:10 +00:00
CommentSubscription Update a11y of ButtonGroup component (#15765) 2021-12-15 12:52:33 +00:00
common-prop-types ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
contentDisplayPolicy Accessibility improvements for hide comments modal (#15462) 2021-11-24 09:50:27 +03:00
crayons Replace listings tag component (#16855) 2022-03-30 16:51:40 +01:00
githubRepos Updated indicators (#16190) 2022-01-20 06:25:10 +01:00
hooks Replace listings tag component (#16855) 2022-03-30 16:51:40 +01:00
leftSidebar Refactoring cached_followed_tags (#16175) 2022-01-24 19:53:48 -05:00
liquidTags Rework user subscription liquid tag to avoid errors (#16460) 2022-02-15 09:14:03 +00:00
listings Replace listings tag component (#16855) 2022-03-30 16:51:40 +01:00
mobile Update Android PN integration fixes (#15541) 2021-12-02 13:56:28 -06:00
modCenter Bump eslint-config-preact from 1.2.0 to 1.3.0 (#15834) 2021-12-21 14:42:20 +00:00
onboarding Removed colour picker from onboarding as it's never used. (#16491) 2022-02-09 06:17:16 -05:00
organization fix some prop type errors on the home page (#15314) 2021-11-10 13:47:55 +00:00
packs Conditional rendering of "Create Post" link (#17076) 2022-04-05 12:47:12 -04:00
podcasts Fixed lint:frontend npm script (#15631) 2021-12-02 07:42:30 +00:00
previewCards Add author profile preview cards to feed (#14340) 2021-08-13 10:55:43 +07:00
profileDropdown Removing a JS message about connect (#16982) 2022-03-23 12:30:59 -04:00
profilePreviewCards Generator updates (#16339) 2022-01-28 12:20:30 +01:00
readingList Storybook updates (#15848) 2022-01-14 11:06:23 +01:00
responseTemplates Edit buttons styles for Templates responses (Mod) (#14468) 2021-08-12 15:57:36 +01:00
runtimeBanner Add special case for DEV Android app (#16382) 2022-02-02 15:25:14 -06:00
Search Storybook updates (#15848) 2022-01-14 11:06:23 +01:00
searchableItemList Reading list: fix broken pagination (#14031) 2021-06-22 08:24:23 +02:00
shared/components Replace listings tag component (#16855) 2022-03-30 16:51:40 +01:00
sidebar-widget Refactoring SidebarWidget and sidebarUser (#10887) 2021-02-03 17:47:54 +00:00
Snackbar Migrate faker dependency to supported upstream (#16037) 2022-01-10 15:00:48 -06:00
topNavigation Updating header with new Crayons buttons (#15653) 2021-12-09 16:41:18 +01:00
utilities Revert "Added a way to sort comments on an article (#16686)" (#17093) 2022-04-04 08:36:34 -04:00
.eslintrc.js ✂️✂️ Removed the pusher-js dependency ✂️✂️ (#16597) 2022-02-15 11:50:54 -05:00
netlify.toml Update storybook node version (#16106) 2022-01-14 08:00:39 -05:00
routes.js.erb [15-minute fix] Add js-routes gem (#15133) 2021-11-01 10:08:15 +07:00