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.
Closesforem/forem#17097
* 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
* 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>
* 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
* 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>
* 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>
* 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
`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.
* 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'
* 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
* 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
* 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>
* 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
* 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>
* Replace HEROKU_SLUG_COMMIT with custom footprint (naive)
* Fully set RELEASE_FOOTPRINT with the expectation of setting it before launch
* Change tests
* Fix cache
* 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
* 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.
* 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
* 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
* 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
* 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