Commit graph

82 commits

Author SHA1 Message Date
Ben Halpern
f88784cc35
Add configuration for admins to specify compliant email strategies (#20663)
* Add configuration for admins to specify compliant email strategies

* Add keys for test
2024-02-21 08:27:26 -08:00
Mac Siri
6fb30bcb3c
Update user_data cache key (#19101) 2023-02-15 14:11:39 -05:00
Ridhwana
6cb97eeb01
Async Hamburger Menu Implementation + Caching Optimizations (#18818) 2022-12-20 20:00:08 +02:00
Jeremy Friesen
8c2b1276a4
Adding copy to assist with space toggle decision (#17147)
This commit adds instruction as to what's happening when a person
toggles on this feature.  So as to not repeat knowlege, I added a
`NUMBER_OF_MINUTES_FOR_CACHE_EXPIRY` constant so the UI can reference that
instead of dropping a hard-coded 15 in the UI.

Closes forem/forem#17097
2022-04-06 11:07:21 -04:00
Jeremy Friesen
7fade0f1f1
Re-arranging method to be less surprising (#17128)
* Re-arranging method to be less surprising

Prior to this commit we hand an unless code block with a return then we
set an instance variable.

On a quick scan I didn't notice the return but saw the render followed
later by the instance variable.

This change is logically the same, my hope is that it's just a bit more legible.

* Bump for travis
2022-04-05 15:49:19 -04:00
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
Jamie Gaskins
9240b34aba
Fix NoMethodError on User#email (#16591)
The email field is not guaranteed to be populated.
2022-02-15 10:50:10 -05:00
Suzanne Aitchison
3982b389f1
Rework user subscription liquid tag to avoid errors (#16460)
* move script to packs, strip ids

* make sure userdata is available before determining ui

* stop working around old html, fix duplicate ID errors

* skip login modal

* remove DEV hard coding

* replace system spec with cypress spec

* update base_data to include apple auth info, add to cypress tests

* add initial version of DUS to resave HTML

* remove data update script
2022-02-15 09:14:03 +00:00
Julianna Tetreault
8d00e27b69
Remove Creator Onboarding Feature Flags from Codebase (#15982)
* Removes FeatureFlag.enabled?(:creator_onboarding) from codebase

* Removes FeatureFlag.enabled?(:creator_onboarding) from specs

* Further cleanup, removal, and spec fixes

* Fixes the user_request_confirmation_spec.rb

* Reverts change to confirmation email button

* Revert revert after looking at designs again :(

* Removes redundant logo_png field from config + fixes test

* Rewords an expectation in user_uses_the_editor_spec.rb

* Revert removal of logo_png from Config images

* Removes CSS class from user_uses_the_editor_spec.rb

* Removes test from user_uses_the_editor_sepc.rb

* Removes unnecessary else from _logo.html.erb

* Adds back removed system spec

* Removes SVG-related code from _logo.html.erb

* Removes AsyncInfoController#use_creator_onboarding

* Fixes spec failues due to removed code

* Removes svg-related code (that I thought I removed already :/ )

* Re-removes FeatureFlag and logo_svg from _images.html.erb

* Remove newest instances of FeatureFlag(:creator_onboarding)

* remove instances where we use the creator_onboarding field from the base_data

* fix: redirect to the correct path in the reguistrations controller based on whether the user is a creator or not

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2022-01-31 11:30:43 -07:00
Jeremy Friesen
2b3f4e1342
Refactoring cached_followed_tags (#16175)
* Refactoring cached_followed_tags

This refactor consolidates two queries and a loop into a single query.

One thing that is unclear is if we're ever really clearing the cache of
the user by id?

What follows is un-related to the refactor but appears to be related to #14937.

> First, I see we set a cache here:
>
> ebdaaaf15b/app/decorators/user_decorator.rb (L23-L34)
>
> But when I look at what busts the user cache, it doesn’t look like we’re busting it for the above cached location:
>
> ebdaaaf15b/app/services/edge_cache/bust_user.rb (L3-L22)
>
> What if anything am I missing in regards to cache busting?

* Adding some deprecated methods

* Updating documentation

* Bump for travis

* Bump for travis

* Updating comments to fix confusion

NOTE: I might be introducing more confusion, but at least
I'm addressing the prior confusion.

* Bump for travis

* Updating so we don't cache ActiveRecord objects

* Selecting only applicable attributes for caching

* Apply suggestions from code review

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Adjusting code based on feedback

* Bump for travis

* Bump for travis

* Update app/decorators/user_decorator.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

Co-authored-by: Michael Kohl <citizen428@forem.com>
2022-01-24 19:53:48 -05:00
Jeremy Friesen
a65954107f
Refactoring to add helper method (#16064)
* Refactoring to add helper method

Prior to this commit, we made view level calls to service modules.  This
refactor provides convenience methods on the model.

Furthermore, it addresses a few Rubocop violations that "come along for
the ride."

* Ensuring cached entity squaks like User

* Fixing broken spec

* Fixing typo
2022-01-12 11:21:44 -05:00
Jeremy Friesen
c1e5d4884d
Deprecating User#trusted in favor of User#trusted? (#15639)
`User#trusted?` is more Ruby idiomatic than `User#trusted`.  This helps
align the various "User#question?" methods.

I've added a deprecation warning, but don't believe that this is active
in the code-base.
2021-12-02 08:54:58 -05:00
Julianna Tetreault
4a9f442354
Creator Onboarding: Creator Setup View (#14728)
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Yhëhtozr <conlang2012@outlook.com>
Co-authored-by: yheuhtozr <84892012+yheuhtozr@users.noreply.github.com>
Co-authored-by: Nick Taylor <nick@dev.to>
2021-11-01 15:50:08 -04:00
Michael Kohl
baa94a0abd
Various cleanups (#14616)
* Remove unused constant

* Remove unused column from OrganizationMembership

* Remove outdated comment

* Remove references to no longer existing roles

* Remove legacy service worker code

* Remove duration_in_seconds_column from podcast_episodes

* Remove app_bundle from devices
2021-08-31 09:17:24 +07:00
Michael Kohl
6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00
Vaidehi Joshi
95055b2a89
Remove pro role + expose analytics to all users via dashboard (#13156)
* Remove pro role on user, expose pro dashboard to all users as analytics

* Remove pro from Elasticsearch mappings

* Update user role docs to use :trusted over :pro

* Remove pro from Role model spec

* Remove more references to pro, as noted by @rhymes
2021-03-30 15:02:18 -07:00
Ben Halpern
73125c0795
Reduce service worker functionality to minimal offline page (#12834)
* Reduce service worker functionality to minimal offline page

* Update docs for service workers

* Add comment to fix test

* Include incrementable static cache

* Add TODO comments about removal

* Fix trailing whitespace
2021-03-01 19:29:26 -05:00
Ben Halpern
472c3d2922
Fix and refactor hide user content (#12307) 2021-01-18 11:08:23 -05:00
Alex
01a4b41fed
Fix shell version logic in async info controller (#12262)
* Add .to_s to ForemInstance.deployed_at

* test: could it possibly be holding onto the cached value across the tests

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2021-01-13 13:20:34 -05:00
Ridhwana
4549144fbb
Refactor deployed_at and latest_commit_id code (#12224)
* WIP: release footprint in the admin UI

* feat: show the commit ID and the date

* chore: change env optional to empty string

* fix: change the FOREM_BUILD_DATE to RELEASE_FOOTPRINT

* feat: add Not Available as a last option

* test: last deployed time and latest commit id

* feat: update the way we change the env variable!

* fix: we need to set the RELEASE FOOTPRINT so that this clause is not hit - `return path if release_footprint.blank?`

* feat: add a Forem Instance Model

* chore: rename variable

* feat: use the new model that we created

* feat: Update the Forem Instance model to remove Not available from the model method and add it to the view layer

* test: Forem Instance model to return the correct values when present

* feat: use Forem.deployed_at instead of the Application config directly

* chore: remove the initializer

* feat: rename the data keys to reflect what it does

* fix: oops evaluate the var

* refactor: static values that can never change during the lifetime of the app should be constants

* chore: setup the test to have a release footprint before the test gets executed

* chore: remove the methods

* revert to method + cache

* revert to using method

* reset the instance variable
2021-01-13 16:53:59 +02:00
Ben Halpern
dfc3d96286
Update shell version when admin action taken (#11343)
* Update shell version when admin action taken

* Update app/controllers/admin/application_controller.rb

Co-authored-by: Alex <alexandersmith223@gmail.com>

Co-authored-by: Alex <alexandersmith223@gmail.com>
2020-11-09 15:31:54 -05:00
Molly Struve
3c6b8adc3c
[deploy] Refactor:Remove Rails Env Prod Check when Setting Shell Version (#11162) 2020-10-29 12:44:01 -05:00
Molly Struve
bd96abcd1e
[deploy] Fix Reading List Counter Without last_reacted_at Default (#10933) 2020-10-19 13:26:19 -05:00
Molly Struve
4dbfc21407
[deploy] Revert "Fix reading list counter (#10763)" (#10932)
This reverts commit 1f17451c8e.
2020-10-19 12:54:31 -05:00
ludwiczakpawel
95619a9c92
Adding admin link for admins (#10926)
* adding admin link for admins

* ok, workaround
2020-10-19 12:44:17 -04:00
Takuma
1f17451c8e
[deploy] Fix reading list counter (#10763) 2020-10-19 11:22:57 -05:00
Takuma
fb707621d0
[deploy] Fix unable to unfollow tags (#10324) 2020-09-25 13:00:55 -05:00
Molly Struve
7520caf0e2
[deploy] Refactor:Remove ReadingList Labor Class, Replace with user Method (#10322) 2020-09-14 11:37:59 -05:00
Ben Halpern
3a469a99e2
[deploy] Enable admin-configured app_domain (#10206)
* Move app_domain from env var to siteconfig *within app area*

* Fix SiteConfig

* Don't change URL.domain yet

* Not use in fastly cache purge yet

* Session store magoo

* Revert domain issue

* Add SetCookie middleware

* Temporarily remove cookie middleware and release tasks

* Re-enable SetCookieDomain

* Add some more comments, get it ready for testing

* Remove host from url options and temporarily show errors

* Allow forwarded host to be cookie

* Fix typo

* Change invalidAuthenticityToken

* Properly set app domain

* Proper Fastly cache

* Remove config.app_domain

* Remove config.app_domain

* Explicitely set remember_user_token

* More play with cookies

* Fiddle with remember_user_token

* Add remember_user_token changes

* Monkeypatch devise

* Sessions controller

* Include rememberable

* Include rememberable

* Proper cookie monkeypatch

* Proper cookie monkeypatch

* Proper cookie monkeypatch

* Remove extra cookie code

* User sign in tweak

* Close the loop

* Experiment with carrierwave public_url

* Finalize carrierwave monkeypatch

* Remove async controller specs

* Change some tests

* Update domain test

* Remove temporary production.rb change

* modify cookie logic

* Remove unneeded changes

* Remove unneeded changes

* Explicitely pass host

* Fix linting

* Fix social image test

* Add some cookie tests

* Modify article url

* Fix canonical urls

* Fix typo

* Remove sessions controller

* Remove devise monkeypatch

* Add monkeypatch

* Remove elsif

* Update spec/helpers/application_helper_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Adjust remember_cookie_sync

* Remember user token experimentation

* Fiddle with devise

* Properly configure devise

* Fix typo

* Fix formatting issue

* Add comment about middleware

* Fix typo

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Remove commented-out code

Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2020-09-11 09:38:34 -04:00
Mac Siri
9ebd742712
[deploy] Reintroduce sticky_nav changes (ab81f36 & 7f92855) (#10263)
* Revert "[deploy] Revert removal of unneeded eager load (if needed) (#10179)"

This reverts commit 11c7b148da.

* Revert "[deploy] Revert "Migrate ProfileImage to Images::Profile (#10055)" (#10149)"

This reverts commit 5657067e55.
2020-09-09 15:33:13 -04:00
Molly Struve
5657067e55
[deploy] Revert "Migrate ProfileImage to Images::Profile (#10055)" (#10149)
This reverts commit ab81f36a38.
2020-09-01 18:28:58 -05:00
Mac Siri
ab81f36a38
[deploy] Migrate ProfileImage to Images::Profile (#10055) 2020-09-01 17:16:03 -04:00
Ben Halpern
45fb6504dc
[deploy] Replace HEROKU_SLUG_COMMIT with custom footprint (naive) (#9904)
* Replace HEROKU_SLUG_COMMIT with custom footprint (naive)

* Fully set RELEASE_FOOTPRINT with the expectation of setting it before launch

* Change tests

* Fix cache
2020-08-25 13:47:14 -04:00
Ben Halpern
986eb87ce8
[deploy] Remove unneeded Analytics update script (#9852)
* Remove unneeded Analytics update script

* Remove constants
2020-08-19 15:57:27 -04:00
rhymes
5b62811c98
[deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
Ben Halpern
cfa5e882ce
[deploy] Add SiteConfig for feed style (#8721)
* Add SiteConfig for feed style

* Merge master

* Merge master

* Fix typo
2020-06-24 12:14:33 -04:00
Molly Struve
b16606e613
[deploy] Optimization: Remove followed_user_ids from Async User Data Hash (#8837) 2020-06-22 18:45:16 -04:00
Julianna Tetreault
b4b10a0cd7
Allow Users to Opt-out of Announcements (#8343) [deploy]
* Add display_announcements boolean to Users table
  * Adds a boolean with a default of true to Users

* Add display_announcements to #user_data and user_policy.rb
  * Adds display_announcements to #user_data in AsyncInfoController
  * Adds display_announcements to PERMITTED_ATTRIBUTES

* Add display_announcements to _misc.html.erb

* Adjust submit data request button and adjust Announcements heading
  * Adjusts submit data request button to follow button capitalization
  * Adjusts announcements heading to read Announcements not Sponsors

* Add copy to _misc.html.erb to add context around Announcement toggle

* Add request and system specs around Announcements
  * Adds a test for announcements to user_settings_spec.rb
  * Adds a system spec for updating announcements

* Add user_updates_announcements_spec file and remove old spec from users_settings_spec

* Fix spec weirdness

* Add tests around misc tab and Announcement toggle to user_settings_spec.rb
  * Tests that misc tab renders properly
  * Tests that display_announcements toggle updates a users settings properly
  * Removes user_updates_announcements_spec.rb
  * Adjusts Export Content capitalization in _misc.html.erb

* Resolve DB conflicts
2020-06-09 13:44:10 -06:00
Vaidehi Joshi
defab11a4d
Provide default crayon styles when creating banners (#8361) [deploy]
* Provide default crayon styles when creating banners

* Import crayons styles into /internal pages.
* Allow admins to use crayons banner styles when creating broadcasts.
* Preview banner styles with crayons.

* Use constant and helper for broadcast banner styles

* Add VALID_BANNER_STYLES frozen constant to Broadcast class.
* Add banner_style helper for determining banner style class.
2020-06-09 11:26:14 -07:00
Vaidehi Joshi
f04b0a7336
Display site-wide announcements (#8301)
* Serialize broadcast_data within AsyncInfoController::base_data

Adds a `broadcast:` key to our `base_data`, regardless of whether a user is logged in or not.
If a broadcast is not present, passes along a `nil` value.

* Initialize active broadcast (if present) when rendering main page

* Allow admins to preview a broadcast's processed_html when editing

* Add some fixed position styling to active broadcast

* Add system specs around broadcasts on homepage

* Use sanitize in place of html_safe when previewing broadcast

* Do not initialize broadcast if no broadcastData available

* Render default value on broadcast in options_for_select

* JS cleanup

* Unset fixed positioning for static navbar config

Also add some default styling for an active broadcast
2020-06-08 13:52:53 -04:00
Molly Struve
38634e5316
[deploy] Optimization: Remove Comment Count From Aysnc user_data (#8174) 2020-06-01 10:38:57 -05:00
Molly Struve
8e0828d86b
[deploy] Optimization: Remove Unused Fields From Async user_data, optimize a couple other methods (#8173) 2020-05-31 13:21:32 -05:00
Molly Struve
b6a88778ad
Optimization:Remove followed_organization_ids from Async user_data (#8176) 2020-05-30 11:40:21 +02:00
Molly Struve
15d2dd0b3a
Remove cached_followed_tag_names From Async User Data (#8148) 2020-05-29 10:24:26 -04:00
Mac Siri
4edf1c5ada
[deploy] Create onboarding task card (#7369) 2020-04-22 11:46:49 -04:00
Vaidehi Joshi
b72fc4c9f8
Remove variants from backend portion of onboarding (#7118) [deploy]
* Remove variants from backend portion of onboarding

Since we're no longer using variants in onboarding, we don't need this code anymore!

* Ignore unused column on user, onboarding_variant_version
2020-04-06 16:30:11 -07:00
Sebastien
665f5aac0f
Refactor ProfileImage (#5803) 2020-02-07 08:56:16 -05:00
Michael Kohl
728a05c476 Move from env variables to SiteConfig (#5385) [deploy]
* Move from env variables to SiteConfig

Related to #5384

This PR only deals with the first remaining part outlined in the issue, starting to use existing SiteConfig keys instead of the env variables.

* Restore Envfile to original version for now
2020-01-07 16:36:24 -05:00
Molly Struve
c1638cfd33
Create UpdateAnalyticsWorker to replace UpdateAnalyticsJob (#5331) 2020-01-02 13:05:12 -05:00
Ben Halpern
630c1b7425
Migrate to streaming app shell via serviceworkers (#5020) [deploy]
* Initial work for streaming app shell way of using serviceworkers

* Close in on serviceworker adjustment finalization

* Add docs and loading indicator

* Remove useless code

* Don't run on API

* Update app/javascript/contentDisplayPolicy/hideBlockedContent.js

* Fix small details

* Don't run serviceworker.js code in test env

* Fix JS in serviceworker

* Move private keyword to proper place in async controller

* Change shell_version to HEROKU_SLUG_COMMIT

* Update caching config

* Add test for async_info/shell_version
2019-12-16 12:21:33 -05:00