docbrown/app/javascript/packs
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 Admin member index: show/hide search and filter controls (#17009) 2022-03-29 15:37:37 +01:00
actionsPanel.js [deploy] New Feature: Mod Actions Panel (#7777) 2020-06-08 13:24:18 -04:00
admin.js Revise skip link behaviour (#15401) 2021-11-18 13:45:08 +00:00
analyticsArticle.js Updates ESLint rules to error on default imports (#12512) 2021-02-02 10:24:03 -05:00
analyticsDashboard.js add org analytics menu if user has organizations (#13995) 2021-06-23 14:35:23 +02:00
applyApplicationPolicyToggles.js Conditional rendering of "Create Post" link (#17076) 2022-04-05 12:47:12 -04:00
articleForm.jsx ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
articleModerationTools.js Only init mod tools if we're still on article page (#16733) 2022-03-01 16:59:28 +00:00
articlePage.jsx handle getElementById failures in articlePage (#16743) 2022-03-02 09:56:53 -06:00
base.jsx Use the Preact ColorPicker in creator onboarding (#16731) 2022-03-03 08:22:10 +00:00
commentDropdowns.js Revert "Added a way to sort comments on an article (#16686)" (#17093) 2022-04-04 08:36:34 -04:00
commentModPage.js Fix broken experience level button in moderation panel (#11797) 2020-12-08 10:20:35 +01:00
commentsDisplay.js Remove defer attributes from inline scripts - gist embeds (#13407) 2021-06-11 08:22:50 +01:00
confirmationEmail.js Creator Onboarding Confirmation Page (#14259) 2021-08-03 14:21:56 +02:00
contentDisplayPolicy.js Updates ESLint rules to error on default imports (#12512) 2021-02-02 10:24:03 -05:00
dashboardDropdowns.js Optimise dropdowns for accessibility: Dashboard and Manage pages (#13909) 2021-06-04 10:19:56 +01:00
dashboardTagsDisableUnchangedButtons.js [15 Minute Fix] Added the prefer-const eslint rule (#13098) 2021-03-23 16:29:56 -04:00
enhanceColorPickers.jsx Use the Preact ColorPicker in creator onboarding (#16731) 2022-03-03 08:22:10 +00:00
feedPreviewCards.jsx Add author profile preview cards to feed (#14340) 2021-08-13 10:55:43 +07:00
flagUserModal.jsx Modals fixes (#16310) 2022-01-27 16:24:23 +01:00
followButtons.js Favor using existing variable over re-parsing (#15995) 2022-01-10 12:33:31 -05:00
foremCreatorSignup.js Add toggle button to 'New Forem Secret' form (#17016) 2022-03-29 08:29:29 -06:00
fullScreenModeControl.js Updates ESLint rules to error on default imports (#12512) 2021-02-02 10:24:03 -05:00
githubRepos.jsx Upgrade to Preact 10.4.4 (#8739) 2020-06-18 10:07:17 -04:00
homePage.jsx add temporary ahoy stats for tag sidebar clicks (#14688) 2021-09-09 08:31:27 -05:00
homePageFeed.jsx Improvements to home feed profile preview card cypress spec (#17011) 2022-03-25 13:57:48 -04:00
homePageFeedShortcuts.jsx Provide skip links: Tweak skip link style, refactor main area ID (#12694) 2021-02-17 10:15:31 +00:00
listingDashboard.jsx Upgrade to Preact 10.4.4 (#8739) 2020-06-18 10:07:17 -04:00
listingForm.jsx Updates ESLint rules to error on default imports (#12512) 2021-02-02 10:24:03 -05:00
listings.jsx Upgrade to Preact 10.4.4 (#8739) 2020-06-18 10:07:17 -04:00
modCenter.jsx Mod Center MVP 🎉 (#8744) 2020-06-23 14:58:16 -04:00
notificationPage.js Remove defer attributes from inline scripts - gist embeds (#13407) 2021-06-11 08:22:50 +01:00
notificationSubscriptionHandler.js improve keyboard accessibility of modals 12427 10610 (#12511) 2021-02-24 16:01:10 +00:00
Onboarding.jsx ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
onboardingRedirectCheck.jsx Remove Creator Onboarding Feature Flags from Codebase (#15982) 2022-01-31 11:30:43 -07:00
orgCreditsSelector.js Crayonsification of Listings form (#10429) 2020-09-30 09:14:48 +02:00
postCommentsPage.js Remove defer attributes from inline scripts - gist embeds (#13407) 2021-06-11 08:22:50 +01:00
profileDropdown.js Optimise dropdowns for accessibility - Profile page (#13916) 2021-06-14 12:31:23 +01:00
readingList.jsx Add Snackbar component on reading list (#15235) 2021-11-15 13:06:21 +02:00
responseTemplates.js [deploy] Finalize and add response templates feature (#7068) 2020-04-16 15:53:29 -04:00
runtimeBanner.jsx ForemMobile namespaced functions (#15212) 2021-11-23 15:25:29 -06:00
Search.jsx Crayons: Buttons vs CTAs (#15311) 2021-11-30 20:40:32 +01:00
searchParams.js Spelling (#15702) 2021-12-07 06:59:10 -07:00
sidebarWidget.jsx Updates ESLint rules to error on default imports (#12512) 2021-02-02 10:24:03 -05:00
signupModalShortcuts.jsx Use faster JS selection methods (#11409) 2020-11-16 17:35:50 +01:00
stickySaveFooter.js Use faster JS selection methods (#11409) 2020-11-16 17:35:50 +01:00
storiesList.js stories list script as separate js file - defer attribute (#13993) 2021-06-21 10:59:30 +07:00
userProfileSettings.js fix character limits i18n (#15830) 2021-12-21 07:15:21 -05:00
validateFileInputs.js [deploy] Add valiation for file name length to file uploads (#6918) 2020-03-27 18:54:27 -04:00
webShare.js Use navigator.share on mobile devices (#13809) 2021-06-15 06:39:33 -06:00