Commit graph

2779 commits

Author SHA1 Message Date
rhymes
7ff882b8ce
Refactor Admin Member Detail view - Tools section (#14283)
* Test with Grid layout

* Use Flexbox

* Replace with utility classes

* Wire up Tools -> Emails

* Stash: will rebase with a better commit message

* Fix transition between Email and Tools component

* Refactor Verify Email Ownership button a bit

* Use respond_to for verify_email_ownership

* Wrap the Preact Snackbar controller in Stimulus and use it from users/tools/email_controller

* Add HTML5 validation to EmailComponent

* Validation and cleanup

* Add Email history list and fix styling

* Additional styling cleanups

* Add error handling

* Close panel after email operations

* Actually use <local-time> GitHub time element correctly

* Add specs for Tools component and controller

* Email to Emails

* Add tests for Admin::Users::Tools::EmailsComponent

* Fix bug with ToolsComponent instantiation in ToolsController

* Add notes to show page

* Add ToolsComponent css

* Use Rails UJS instead of manual Stimulus to connect remote helpers

* Make Notes section come alive by adding its code

* Make Credits section come alive by adding its code

* Go back to vertical flex

* Finalize small restructuring of credits code

* Simplify ToolsComponent instantiation

* Add basic Add user to org functionality

* Make update user permissions form work

* Make remove user from org work

* Use generic Stimulus AjaxController to cleanup code

* Use Stimulus AjaxController for NotesComponent

* Use Stimulus AjaxController for CreditsComponent

* Use Stimulus AjaxController for OrganizationsController

* Add Admin::Users::Tools::ReportsComponent

* Do not display snackbar message if there is no message

* Add Admin::Users::Tools::ReactionsComponent

* Fix EmailsComponent spec

* Add CreditsComponent tests

* Fix quotes

* Add OrganizationsComponent specs

* Add ReportsComponent spec

* Add ReactionsComponent spec

* Fix rubocop violation

* Fix ToolsComponent specs

* Remove unused variable

* More tests

* Use keyword argument for ToolsComponent

* Fill in Tools requests specs

* Use Rspec shared_examples for ToolsController and EmailsController

* Add tests for Admin::Users::Tools::CreditsController

* Add tests for Admin::Users::Tools::NotesController

* Add tests for Admin::Users::Tools::OrganizationsController

* Add tests for Admin::Users::Tools::ReactionsController and ReportsController

* Fix bugs and add tests to Admin::OrganizationMembershipsController

* Add comments to deprecated sections of the UsersController

* Fix bugs and add tests to Admin::UsersController #send_email and #verify_email_ownership

* Add User model tests

* Feature flag fixes

* Add Cypress Tools - Emails tests

* Add Cypress Tools - Notes tests

* Add Cypress Tools - Credits tests

* Add Cypress Tools - Organizations tests

* Add Cypress Tools - Reports and Reactions tests

* Mark the replace target as a polite region

* Update view_component gem

* Tiny fixes

* Fix spec

* Wrap component rendering in render_component

* Move user.related_negative_reactions to a Reaction scope

* Move user.reports to a FeedbackMessage scope

* Move user.last_verification_date as EmailAuthorization class method

* Revert encapsulation to private

* Fix boxes backlinks names

* Add keyboard focus styling to boxes

* Remove duplicate styling

* Remove duplicated header element

* Improve heading hiearchy

* Fix <legend> and labels

* Backlink should be Tools not Users

* Announce section change to screen reader and fix focus

* Fix specs

* Add focus style for backlinks

* Enable email sending in e2e mode

* Use Settings instead of env variable
2021-08-17 18:55:53 +02:00
Siddharth
c5c484408e
Navigation Link: fix regex to allow multiline SVG (#14481)
* Fix regex to check svg. Fixes #14334

* Add tests
2021-08-13 13:46:04 +07:00
dependabot[bot]
f0093c5338
Bump rubocop from 1.18.4 to 1.19.0 (#14489)
* Bump rubocop from 1.18.4 to 1.19.0

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.18.4 to 1.19.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.18.4...v1.19.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Rubocop autofixes

* Manually fix some Rubocop warnings/errors

* How about another coffee, Michael?

* Maybe Rubocop needs a coffee too

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-08-13 13:14:59 +07:00
Suzanne Aitchison
80096f63a7
Add author profile preview cards to feed (#14340)
* Add the preview card to logged out feed initial content

* initialise the initial dropdowns added on the logged out feed

* minor tweak to selector

* flip the follow button and the summary

* add minimal preview card to build article HTML

* WIP: data fetched an inserted into card on logged out feed

* WIP: cards added to logged in feed

* create separate profile preview card component

* small style tweak, import pack on each page that shows feed cards

* rename

* tweak some styling issues

* make sure follow buttons init in cards

* populate all matching metadata placeholders after fetch

* don't render full preview card upfront on logged out feed

* refactors from PR comments

* fix issue in person search results

* remove check for article author link that will be superseded by cypress test for preview card

* Revert "remove check for article author link that will be superseded by cypress test for preview card"

This reverts commit 9b42804ffd0f051891c87293d0b791ed2bb0367f.

* Revert "fix issue in person search results"

This reverts commit 04941e3520c0895212141193b60f2933faed5ca1.

* only show the preview cards on story cards for Posts (not users etc in search results)

* correct display on collections view

* remove link check that will be replaced by cypress test

* tweaks to small issues, add a test for the logged out feed

* add tests for logged in home feed, logged out tag index

* add search test and tag index logged in test

* fixes to preview profile spec

* tweak to followauthor spec

* add cypress test for preview on series page

* use a unique test user for series test

* correct the jsdoc comments

* tweaks following PR review

* allow feed preview cards to reposition

* move to separate file from pack
2021-08-13 10:55:43 +07:00
Andy Zhao
517c70c20c
Remove discussion locks prior to deleting an article (#14488) 2021-08-12 10:50:01 -04:00
Mac Siri
443e852091
Remove button from allowed tags (#14434) 2021-08-11 10:48:07 -04:00
zeotuan
991f8b4baa
Fix Analytics Dashboard Page missing "Back To Dashboard" button (#14310)
* fix analytic page have no back-to-dashboard button when user have no organization

* resolve conflict with main

* remove dump

* add test for back to dashboard button
2021-08-11 12:57:01 +02:00
Khadija Sidhpuri
3d1727b3a8
Delete tag colors cache on updating tags. (#14427)
* add: article cache on update tag

* minor styling fix

* add: published scope to fetch articles

* update: tag_spec:125 to not fetch articles

* modify: tag.rb:bust_cache to delete server cache

* add: tests to verify cache delete
2021-08-11 12:56:04 +02:00
Michael Kohl
7e0415c150
Make header fields in profile preview card dynamic (#14454)
* Make header fields in profile preview card dynamic

* Update comment
2021-08-11 09:34:30 +07:00
Jamie Gaskins
ad9f54dad4
Optimize tagged articles under feature flag (#14451) 2021-08-10 15:29:24 -04:00
Jamie Gaskins
b2f529573d
Handle users in Reaction#skip_notifications_for (#14450)
This method previously assumed that a reaction's `reactable` had a
`user_id` attribute, but if the reactable was a User, it wouldn't have a
`user_id`. The user id would just be `reactable.id`.
2021-08-10 10:48:52 -04:00
Michael Kohl
231ce5d3cb
[15-minute fix] Add created_at to listings API response (#14437)
* Add created_at to listings API response

* Add created_at listing attribute to org controller
2021-08-10 08:53:03 -05:00
Daniel Uber
9f2130ce32
handle openssl errors when checking podcast episode for https (#14439) 2021-08-09 12:52:20 -05:00
Suzanne Aitchison
f95841cfbc
[15 min fix] Initialize follow buttons on comment index page (#14416)
* [15 min fix] Initialize follow buttons on comment index page

* add init for newly added comments
2021-08-04 13:05:43 +01:00
Fernando Valverde
e73afa22c7
Take Apple Authentication out of Beta (#12114)
* Removing :apple_auth feature flag and debugging

* Fix tests failing due to nil in Devise initializer

* Remove db/schema.rb changes

* Devise config tweak

* cleaning up

* Fix spec + delete debug logs

* Removes temporary beta_access_providers spec + remove feature flag DUS

* Add test to avoid connecting an existing user with SIWA

* Fix merge conflict mistake + more feature flag cleanups
2021-08-03 15:04:00 -06:00
Daniel Uber
b6a1d59c28
ProfilePreviewCard serializes the user's created at, not the profile (#14392)
This matches what happens for the html preview ("Joined" is the user's
created_at timestamp), and what the json builder does:

    json.created_at utc_iso_timestamp(@user.created_at)

Update the test cases to assert the profile preview is showing the
user's created_at, not the profile's created at.

Since these are almost always the same thing, we didn't notice
this. However, if a user is created just before the second boundary,
and their profile created immediately after the second boundary (so
that the iso8601 values have distinct seconds) this could fail when
looking at the wrong objects timestamp.

To test this locally I modified the user let block to update the
timestamp to be a day earlier (this would not have happened in
practice but was sufficient to cover the use case).

     let(:user) { create(:profile).user.tap {|u| u.update(created_at: 1.day.ago) } }
2021-08-02 15:03:11 -05:00
Arit Amana
812bfa2bbf
Create Default Nav Links In New Forem (RFC #237) (#14345)
* schema file undelete description

* update with main

* update with origin

* update

* create rake task for new-forem nav links

* remove debugger

* create rake task for new-forem nav links

* remove debugger

* incorporate review feedback

* DRY image paths up

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
2021-08-02 12:52:36 -04:00
Nicolas Lepage
3e3fd76360
Fix GitHub Readme liquid tag relative URLs (#14352)
* fix: github readme liquid tag broken links in HTML

The relative links contained in the README's HTML are replaced by absolute links.

These absolute links have broken URL's: https://raw.githubusercontent.com/forem/forem/main/#what-is-forem

This commit aims to fix the links with a correct URL: https://github.com/forem/forem#what-is-forem

* Add a test for GitHub Readme with relative URLs

* Fix test for GitHub Readme with relative URLs

* Fix test for GitHub Readme with relative URLs

* Revert "Fix test for GitHub Readme with relative URLs"

This reverts commit 1b38da9132baf72f88303316ab6116eb9175909b.

* Use new cassette for for GitHub Readme with relative URLs test

* Add cassette file for GitHub Readme with relative URLs test
2021-08-02 09:05:35 -05:00
Daniel Uber
9b5512bd9f
expect to forbid, rather than expect not to permit (#14390)
I noticed a warning from rspec when this policy spec ran:

        Using expect { }.not_to permit_actions could produce
        confusing results. Please use `.to forbid_actions` instead. To
        clarify, `.not_to permit_actions` will look at all of the actions and
        checks if ANY actions fail, not if all actions fail. Therefore, you
        could result in something like this:

        it { is_expected.to permit_actions([:new, :create, :edit]) }
        it { is_expected.not_to permit_actions([:edit, :destroy]) }

        In this case, edit would be true and destroy would be false, but both
        tests would pass.

I just follow the helpful advice.
2021-07-30 11:42:47 -05:00
Khadija Sidhpuri
7567e77132
Extract search from StoriesController (#14377) 2021-07-30 10:55:00 -04:00
Michael Kohl
43ccdb31f1
Remove duplicated work display from header / profile work (#14210)
* Remove duplicated work display from header

* Update work profile field handling

* Update DUS + spec

* Delegate more carefully

* Update delegation guard

* Adapt for removed delegation

* Undo accidental schema changes

* Fix seeds

* Remove accidentaly change

* Fix User#processed_website_url

* Update guard clause

* Update profile card content

* Add Organization#profile

* Be more conservative with profile fields

* Spec fixes round 1

* Fix typo

* Update spec

* Limit number of header fields and update card content

* Decorate correct model

* Update factory

* Update schema.rb

* Fix validation

* How bad could this possibly be?

* Pretty bad, nevermind

* Remove obsolete code

* Reset profile fields during test runs

* Move profile fields back to before(:suite)

* Spec fixes

* Remove accidentally re-added files

* More spec fixes

* Specs

* Change User#tag_keywords_for_search

* More spec fixes

* Add comment

* Undo accidental schema changes

* Attempt spec fix

* Remove fix attempt

* Fix e2e test

* Update spec

* Remove guard clause

* Remove outdated guard clause

* Re-add validation

* Update header field validation

* Fix auto-complete fail
2021-07-30 12:28:40 +02:00
Daniel Uber
27059865ca
hotfix comments with link tags (#14382)
* Add a failing test case

Currently fails with the reported error

  expected no Exception, got #<ArgumentError: Requires a Node, NodeSet or String argument, and cannot accept a NilClass.

* Only replace inner html if not nil

`sub!` can return nil and you can't set an XML::Element's content to
nil (coercion fails).

* Use sub rather than sub! since we'll be using assignment

The issue we were seeing was that sub! returns nil when no change was
made, while sub always returns a string (with modificationsn made).

Remove temp variable since it's not needed when we use the other method.
2021-07-30 12:27:51 +02:00
Ridhwana
e827b8bab9
Minimal Seed Data for Admin Onboarding (#14385)
* minimal seeded flows

* fix: remove mistake

* refactor: rename the files appropriately

* feat: change some text

* fix: typo

* chore: new commit to rebuild
2021-07-29 17:08:41 +02:00
Andy Zhao
5c5d37d648
Update admin welcome checklist (#14261)
* Update admin welcome checklist

* Update invite link text in test

* Remove extraneous invite line and period

* Add overview tracking to all links in checklist

* Fix spec to check for proper link
2021-07-28 14:27:17 -04:00
Daniel Uber
c58740e2cf
hotfix dashboard spec failures (#14370)
* Tests are failing to find header:nth-child(1)

Not sure why this did not fail in the branch - but the merge build
failed

Use 'div > header' (shudder), replacing the prior 'main > header'
selection, and avoiding the nth-child pseudoclass selector, to find
the "header" in the dashboard body containing the summary statistics.

This avoids the conflict with the top header (forem logo, search,
dropdowns) from the body/summary header (post views, credits
available, etc).

* Specify which div we want to look at
2021-07-27 16:15:45 -06:00
zeotuan
989bc21b3f
Fix inappropriate landmark nesting dashboard 10873 (#14308)
* change dashboard landmark nesting

* switch to main db/schema.rb

* remove unnecessary div

* revert scema.rb to main

* fix user_visits_dashboard test

* change aside to nav, put nav back into main-content

* remove unnecessary file

* remove duplicate nav

* add id to main

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-07-27 16:03:59 -05:00
Suzanne Aitchison
7efe9159d7
Tests: Initialize follow buttons in article liquid tags (#14354)
* initialize follow buttons in articles

* add e2e tests

* fix typo in test

* add test for follow back case

* remove attribute we don't need
2021-07-27 16:28:05 +01:00
Michael Kohl
30552a5ed8
Update DiscussionLocksController (#14351) 2021-07-27 14:42:14 +02:00
Suzanne Aitchison
75b6c8ed96
Use a single listener for all follow buttons on a page (#14246)
* create new pack, handle user follow buttons, use pack on article page, remove initializeUserFollowButts

* init all follow button types, add pack to tag index and podcast episode pages

* add pack to all relevant pages, listen for newly inserted follow buttons

* change to searchParams to remove follow button initializer calls

* fix bug with tag page, add pack to notifications page

* fix issue with follow back inner text

* update cypress specs

* run the followbuttons code on sponsors page

* remove extra foreach

* add test for follow from article sidebar

* add test for follow and unfollow tag

* add test for the tag index page

* add spec for organisation profile follow

* add tests for follow buttons in search results

* add tests for notification follows

* commit missed file - woops

* show login modal if user is logged out when they click

* add cypress tests for logged out state

* change tag button initialization

* remove data-button-initialized

* init follow buttons from base pack

* handle the case where multiple follow buttons exist on a page for the same user

* account for instantclick and userdata not being defined, lower coverage for jest

* use getInstantClick

* fix issue with set initialisation

* only listen for mutations in areas we know follow buttons may be added dynamically

* small refactors
2021-07-27 10:45:50 +01:00
rhymes
0d58de830b
API: Add reading_time_minutes to /api/articles/me (#14318) 2021-07-26 17:47:50 +02:00
Michael Kohl
7a8f854d2c
Rename User.dev_account to User.staff_account (#14321) 2021-07-26 10:46:26 -04:00
Michael Kohl
813d83a854
Fix constant lookup in Admin::WelcomeController (#14320) 2021-07-26 08:12:47 -06:00
rhymes
e081551dc0
Revert "Clear recent articles cache on updating tags (#14298)" (#14330)
This reverts commit 7159199402.
2021-07-26 11:12:33 +02:00
Khadija Sidhpuri
7159199402
Clear recent articles cache on updating tags (#14298)
* add: article cache on update tag

* minor styling fix

* add: published scope to fetch articles

* update: tag_spec:125 to not fetch articles
2021-07-26 10:24:24 +02:00
Arit Amana
e589b11c77
Static Sections for Site Navigation - Pt2 (#14292)
* schema file undelete description

* update with main

* update with origin

* add sections in Admin

* Add "Section" radio btns to New-Link form

* Ensure links created in correct section

* Ensure links created in correct section pt2

* fix styling in admin

* complete section split on frontend

* start on specs

* complete specs

* remove unnecessary Cypress test file

* address all a11y comments in PR review

* fix broken specs due to a11y changes
2021-07-23 17:53:55 -04:00
Alex
7a48708156
API: Add instance endpoint and spec (#14301)
* Create /api/forem_directories endpoint and spec

* PR feedback

* Update regex in spec
2021-07-23 12:10:08 -04:00
Daniel Uber
591577e6b8
[hotfix] website_url update script should handle parse errors (#14306)
* Add additional test cases to the DUS

And then handle them.

* rubocop changes

Keep let blocks together
prefer blank? to ! + present?

* Test copied script as well

Since the file was fixed, then copied - we want to test the copy that
will actually run (these _should_ be idempotent and running both back
to back will cause no harm).
2021-07-22 14:16:43 -05:00
Daniel Uber
6f84f4afe8
Validate profile field "website url" is in fact a url (don't generate local path links). (#14302)
* Validate website_url profile field is a url

related to issue #14300

May need a data update script to (fixup? remove?) invalid profiles
since not being able to save existing profiles will cause problems.

* Check that URI is a valid url

Require the scheme to be one of https or http, not something like
mailto:// or telnet:// (nobody would do that, but don't try and link
to it if they did).

* Rubocop fixup for validation rule

URI::regexp is obsolete and should not be used. Instead, use URI::DEFAULT_PARSER.make_regexp

Prefer %w[] literals for arrays of words

Prefer the new style validations `validates :column, format: value` to validates_format_of

* Permit empty website_url fields

The previous validation was rejecting nil, which was the default. This
caused a lot of user factory calls to fail (since users didn't need
website urls in the profiles during testing unless the test was about
the website url link).

* Use :url validation as suggested

* Update validation error message

The validate_url gem gives a more complete error message to the
user. Update the spec to expect this.

* Use url_field rather than text_field in profile form

https://apidock.com/rails/v6.1.3.1/ActionView/Helpers/FormHelper/url_field

* Add data update to either fixup or clear invalid website urls

Checking blazer there are about 2600 profiles with "invalid" website
urls, typically a hostname, sometimes a hostname + path component,
which should be fixed up.

Naively add https:// to the front of the url, check that a valid
scheme and host are present on the resulting url, and save.

If an invalid url is generated (specifically, if host or scheme are
nil), just set the website url (with the invalid link) to an empty
string.

It's possible we'd want to notify users affected by this, that was not
included in this pass.

* Skip validations for intentionally invalid test cases
2021-07-22 12:02:29 -05:00
Michael Kohl
de043b3d6d
Fix brand color validation (#14303) 2021-07-22 09:35:20 +01:00
Michael Kohl
dc27f597fb
Remove CustomProfileField (#14286)
* Remove custom profile fields

* Update profile model

* Fix specs, more cleanup

* Remove no longer valid validation

* Update spec

* Update search serializer spec

* Update migration
2021-07-22 10:05:39 +07:00
Fernando Valverde
16ddcb74dc
Avoid showing social login options in ForemWebView (#14260)
* Minimal diff commit

* Add helper specs for display_social_login?

* Fixing some specs

* Fixing specs

* Add system specs for flow A vs flow B

* Add aria-live polite

* revert unnecessary change to spec

* Update spec/system/authentication/conditional_registration_spec.rb

Co-authored-by: rhymes <github@rhymes.dev>

* Tweaks to fix specs

* Apply review feedback

* Apply suggestions from code review

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

* Extract helper function + refactor Regexp from display_social_login?

* Small tweak to condition

Co-authored-by: rhymes <github@rhymes.dev>
Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-07-21 09:59:12 -06:00
rhymes
a118b9095a
Add JSON representation of Profile Preview Card info (#14296)
* Add tests and Railsify a few things

* Adds JSON representation of ProfilePreviewCardsController

* Load profile and setting eagerly

* Add profile preview card color
2021-07-21 16:23:54 +01:00
Mac Siri
b06b446176
Allow setting nil value in Settings::Upsert (#14228) 2021-07-20 10:57:09 -04:00
Khadija Sidhpuri
c4185c1339
Fix shorten_urls to not remove formatting and image tags (#14262)
* fix: shorten_urls to only shorten URLs

* revert: changes to schema.rb

* modify: test to aggregate failures

Co-authored-by: rhymes <github@rhymes.dev>

* fix: shorten_urls to only strip urls

* improve: regex and variable assignments

* remove: unnecessary var assignment

Co-authored-by: rhymes <github@rhymes.dev>
2021-07-20 10:10:34 -04:00
Khadija Sidhpuri
2ad463f078
Allow multiple users to fetch all articles from the same RSS feed (#14160)
* fix: artiles from the same feed can be fetched from multiple accounts

* undo unintentional changes to schema.rb

* modify: article_spec and import_spec tests

* fix: failing test

* modify: import_spec:213 for user.setting

* fix: failing test import_spec:213

* add: unique index on articles canonical_url where published

* revert: schema.rb

* modify: unique url error message to include admin email

* modify: custom error message

* modify: .update to .update! (bang)
2021-07-19 15:15:32 +02:00
Michael Kohl
84a85fe1a4
Remove color_field input type from profiles (#14239)
* Move brand color validation to Users::Setting

* Fix specs

* Remove color_field as ProfileField input type
2021-07-19 18:42:36 +07:00
Michael Kohl
9794305412
Remove unused profile fields (#14206)
* Remove unused profile fields

* Clean up CSV

* Account for user settings in Profiles::Update

* Move brand color validation to Users::Setting

* Fix specs
2021-07-16 09:45:12 -04:00
Suzanne Aitchison
dfc08bf5b4
Revert "Fix shorten_urls to not strip out text formatting in comments (#14240)" (#14258)
This reverts commit 315f1ec4cf.
2021-07-16 14:37:26 +01:00
Mac Siri
48e768e75f
Escape organization name in LinkTag's spec (#14249) 2021-07-15 14:34:14 -04:00
Khadija Sidhpuri
315f1ec4cf
Fix shorten_urls to not strip out text formatting in comments (#14240)
* fix: shorten_urls to only shorten URLs

* revert: changes to schema.rb

* modify: test to aggregate failures

Co-authored-by: rhymes <github@rhymes.dev>

Co-authored-by: rhymes <github@rhymes.dev>
2021-07-15 18:59:29 +02:00