docbrown/app/models
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
..
ahoy Favoring delete_all on user relationships (#15443) 2021-11-23 11:50:12 -05:00
articles Refactoring to add helper method (#16064) 2022-01-12 11:21:44 -05:00
concerns Remove CustomProfileField (#14286) 2021-07-22 10:05:39 +07:00
liquid_tags
settings Make onboarding_background_image nullable (#17045) 2022-03-29 11:47:17 -04:00
users app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
ab_experiment.rb Refactor AB Experiments and exercise all variants in rspec (#16236) 2022-01-24 17:03:58 -05:00
admin_menu.rb feat: change people to members (#16994) 2022-03-24 15:44:46 +02:00
announcement.rb
api_secret.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
application_record.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
article.rb Ensuring article's cache updates on org image update (#17052) 2022-04-01 10:54:55 -04:00
async_info.rb Conditional rendering of "Create Post" link (#17076) 2022-04-05 12:47:12 -04:00
audit_log.rb Favoring constant over magic string (#15852) 2021-12-27 11:31:29 -05:00
badge.rb Refactor cache purging (#12811) 2021-03-02 10:09:05 -05:00
badge_achievement.rb Extracting container for allowed tags & attrs (#15338) 2021-12-16 12:24:45 -05:00
banished_user.rb
broadcast.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
campaign.rb [Small win] Add display name to campaign settings (#16653) 2022-02-22 10:01:52 -05:00
collection.rb Series count to only include non empty series (#16130) 2022-01-18 10:22:34 +07:00
comment.rb Revert "Added a way to sort comments on an article (#16686)" (#17093) 2022-04-04 08:36:34 -04:00
config.rb
consumer_app.rb Fixes a name conflict in Rpush models (#15978) 2022-01-07 09:38:16 -06:00
creator_setting.rb Creator Onboarding: Creator Setup View (#14728) 2021-11-01 15:50:08 -04:00
credit.rb Favor repurposing existing scope (#15914) 2022-01-03 09:30:34 -05:00
data_update_script.rb
device.rb Spelling (#15702) 2021-12-07 06:59:10 -07:00
discussion_lock.rb Renaming method for clarity (#16791) 2022-03-07 12:55:56 -05:00
display_ad.rb Extracting container for allowed tags & attrs (#15338) 2021-12-16 12:24:45 -05:00
display_ad_event.rb Extracting constants and tidying tests (#15946) 2022-01-05 09:19:39 -05:00
email_authorization.rb Refactor Admin Member Detail view - Tools section (#14283) 2021-08-17 18:55:53 +02:00
email_message.rb Delete old retained emails after certain period (#14949) 2021-10-12 16:27:13 -04:00
extension.rb Introduce "extensions" (#16840) 2022-03-18 11:22:17 +02:00
feedback_message.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
follow.rb Refactoring cached_followed_tags (#16175) 2022-01-24 19:53:48 -05:00
forem_instance.rb "Reply to" and "From" Email addresses for SMTP Configurations (#16499) 2022-02-16 16:14:54 +02:00
github_issue.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
github_repo.rb POC: use Sidekiq.perform_bulk for Github repos (#16293) 2022-01-26 09:11:07 +07:00
html_variant.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
html_variant_success.rb Appeasing Rubocop as it sneaks some changes in (#16085) 2022-01-13 07:48:01 -05:00
html_variant_trial.rb Appeasing Rubocop as it sneaks some changes in (#16085) 2022-01-13 07:48:01 -05:00
identity.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
invitation.rb
listing.rb More listings refactoring (#16343) 2022-02-23 13:44:30 +07:00
listing_category.rb
mention.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
mod.rb
moderator_action.rb
navigation_link.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
note.rb Favoring delete_all on user relationships (#15443) 2021-11-23 11:50:12 -05:00
notification.rb Ensure arguments to perform_async are json safe (#16285) 2022-01-25 18:07:40 -06:00
notification_subscription.rb Appeasing Rubocop as it sneaks some changes in (#16085) 2022-01-13 07:48:01 -05:00
organization.rb Ensuring article's cache updates on org image update (#17052) 2022-04-01 10:54:55 -04:00
organization_membership.rb Appeasing Rubocop as it sneaks some changes in (#16085) 2022-01-13 07:48:01 -05:00
overview.rb Add admin overview page (#12726) 2021-03-01 18:59:05 -06:00
page.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
page_view.rb Favoring dependent: :delete_all over :destroy (#15442) 2021-11-24 13:56:16 -05:00
permission.rb
pinned_article.rb Pin posts to feed (#13807) 2021-06-04 10:54:53 +02:00
podcast.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
podcast_episode.rb Various cleanups (#14616) 2021-08-31 09:17:24 +07:00
podcast_episode_appearance.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
podcast_ownership.rb Appeasing Rubocop as it sneaks some changes in (#16085) 2022-01-13 07:48:01 -05:00
poll.rb Refactoring poll/vote/skip logic (#15441) 2021-11-29 10:52:32 -05:00
poll_option.rb Favoring dependent: :delete_all over :destroy (#15442) 2021-11-24 13:56:16 -05:00
poll_skip.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
poll_vote.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
privileged_reaction.rb
profile.rb Profile attribute names should be unique and non-empty (#16396) 2022-04-04 12:14:02 -05:00
profile_field.rb Profile attribute names should be unique and non-empty (#16396) 2022-04-04 12:14:02 -05:00
profile_field_group.rb
profile_pin.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
rating_vote.rb Removing deprecated User methods (#16435) 2022-02-07 10:32:58 -05:00
reaction.rb Don't send notification for invalid reactions (#16721) 2022-02-28 12:36:44 -06:00
response_template.rb Removing deprecated User methods (#16435) 2022-02-07 10:32:58 -05:00
role.rb ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
secret.rb
space.rb Penciling in a Default Spaces section (#16897) 2022-03-21 09:56:12 -04:00
sponsorship.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
tag.rb Renaming method for clarity (#16791) 2022-03-07 12:55:56 -05:00
tag_adjustment.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
timeframe.rb
tool.rb
tweet.rb Better error upon Tweet embed when Twitter keys missing (#16916) 2022-03-21 16:21:37 -04:00
user.rb Reducing subtle duplication of effort/logic (#17078) 2022-04-01 13:32:44 -04:00
user_block.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
user_role.rb [Search 2.0] Users (#13453) 2021-04-24 19:06:06 +02:00
user_subscription.rb app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
welcome.rb
welcome_notification.rb