Commit graph

6329 commits

Author SHA1 Message Date
Ridhwana
32abc2160e
Update the directory structure for Admin Member View (#16608)
* feat: update the directory structure for partial

* feat: update the current tab
2022-02-17 14:37:17 +02:00
Arit Amana
29bb7b4e75
Complete implementation and add specs (#16615) 2022-02-16 18:10:58 -05:00
Arit Amana
846ef0cbba
Unified Embed Documentation (#16601)
* starting doc update

* ongoing

* progressing

* still updating

* continue doc update

* note about old liqtags

* add link to create bug-issue

* remove tabular list of supported embeds

* do away with the table!

* address PR review comments

* nudge Travis
2022-02-16 13:15:15 -05:00
Ridhwana
b21397a8c6
"Reply to" and "From" Email addresses for SMTP Configurations (#16499)
* feat: create a from_email_address and a reply_to_email_address

* feat: update other mailers with the new SMTP email settings

* test: update all spec files

* fix: use the SMTP::Settings value

* fix tests

* spec: fix the comma

* feat: tighten some logic

* fix: test

* fix tests

* fix tests

* final fix test commit

* fix test

* fix test

* oops

* feat: add a reply_to for Devise Mailer

* chore: update the description

* use a proc for reply_to

* feat: update text

* Update spec/mailers/digest_mailer_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update spec/mailers/verification_mailer_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update spec/mailers/shared_examples/renders_proper_email_headers.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* refactor: move OPTIONS to a helper as its only being used in the view layer

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2022-02-16 16:14:54 +02:00
Jeremy Friesen
955d9ee51a
Plumbing application for probable AuthN/Z changes (#16571)
* Plumbing application for probable AuthN/Z changes

For further details, core members can read:

- [Forem Article Authorization Discrepencies][1]
- [Forem Authentication and Authorization Principles][2]

(Note: there's nothing "private" about these articles, I happened to
post them on https://forem.team for internal discussion.)

Related to #16529

[1]:https://forem.team/jeremy/forem-article-authorization-discrepencies-45df
[2]:https://forem.team/jeremy/forem-authentication-and-authorization-principles-58l3

* Adding changes based on feedback
2022-02-16 09:10:18 -05:00
Suzanne Aitchison
4d07a1ef7b
Tweaks to the admin flash messages flow (#16582)
* Focus flash message button on load

* update specs

* Update app/javascript/packs/admin/flashMessages.js

Co-authored-by: Nick Taylor <nick@iamdeveloper.com>

* Update app/javascript/packs/admin/flashMessages.js

Co-authored-by: Nick Taylor <nick@iamdeveloper.com>

Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
2022-02-16 10:07:21 +00:00
ludwiczakpawel
dc0693e0f4
Admin Articles view update (#16359)
* individual_article

* .

* fix

* .

* add a js-class since it was depending on a markup class that has changed

* pin/unpin

* speC

* .

* fixes

* Update app/views/admin/articles/_individual_article.html.erb

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

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-02-16 09:00:07 +01:00
Suzanne Aitchison
e601b7b7ba
hide icon (#16599) 2022-02-15 17:14:13 +00:00
Nick Taylor
06122daa27
✂️✂️ Removed the pusher-js dependency ✂️✂️ (#16597) 2022-02-15 11:50:54 -05:00
Ridhwana
1025900d16
Improve the UX of the SMTP Section (#16223)
* feat: allow reply_to and email_from to be set for an SMTP config

* feat: use these SMTP values in the mailers

* spec: test the application_mailer

* fix: validate with email, and not url

* feat: mimic macs changes from https://github.com/forem/forem/pull/16216 to use in this PR

* setup packs for admin

* refactor: order the keys and add a const for the auth methods

* feat: rename the header to a more user friendlly name

* chore: move the section with Emails

* feat: add a toggle that will show and hide the SMTP form under certain conditions

* feat: add the javaScript to handle the toggles

* feat: add a better description until we convert to a dropdown

* feat: ensure that we have declared sendgrid_enabled

* chore: add  anote to the config controller

* chore: remove references of the email addresses to keep brnach scoped

* feat: tweak js

* test: cypress workflow to update smtp settings

* feat : update the smtp tests

* remove comments

* update test

* chore: rename NOTE

* feat: polisha dn test ForemInstance.only_sendgrid_enabled?

* chore: remove specs

* Update app/lib/constants/settings/smtp.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update spec/system/admin/config/admin_updates_smtp_settings_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update spec/system/admin/config/admin_updates_smtp_settings_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update spec/system/admin/config/admin_updates_smtp_settings_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update app/javascript/packs/admin/config/smtp.js

Co-authored-by: Nick Taylor <nick@iamdeveloper.com>

* refactor js as per comments

* refactor as per comments

* Update cypress/integration/seededFlows/adminFlows/config/emailServerSettingsSection.spec.js

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

* refactor: update the Cypress tests

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-02-15 18:40:14 +02:00
Daniel Uber
2fbfd68172
Render social previews for tags with one of the two custom colors set (#16557)
* Initialize compare hex once in controller, fallback if color missing

This PR adds a fallback color choice when there are missing
bg_color_hex or text_color_hex (this is likely going to become more
common as we only show the bg_color_hex in the form).

The choices (black and white) may not be correct - this "custom, or
default" value choice should likely be made in a decorator or on the
model instead.

Addresses an error reported in
https://app.honeybadger.io/projects/66984/faults/83671065

* typo: Attribute name is text_color_hex
2022-02-15 09:56:57 -06: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
Ridhwana
5e93d3a25e
Add a contact email address to the /admin/customization/config (#16497)
* feat: remove the default email and cobine the periodic digest and the contact email under the Email section

* refactor: rename  the email_link to contact link and use the contact_email as a default and fallback to the ForemInstance.email

* chore: alignment

* feat: use the contact_email helper

* feat: move the contact_email to the ForemInstance model

* feat: use ForemInstance.contact_email instead of the application helper method

* removed the application Helper

* feat: set the dafault on the contact_email

* fix: cypress tests

* Update app/lib/constants/settings/general.rb

Co-authored-by: Michael Kohl <me@citizen428.net>

Co-authored-by: Michael Kohl <me@citizen428.net>
2022-02-15 17:37:08 +02:00
Daniel Uber
afa214ac52
Require profile fields to belong to a group (#16390)
* Require profile fields to belong to a group

Remove the empty group dropdown from the group select tag

Remove the optional: true from the belongs_to validation (raise a
validation error on save if the group is not provided)

Update test to remove belongs_to's optional setting

* Update ProfileFields::Add spec to include profile field group

* update factory to ensure a non-empty profile field group

* Add required profile field group to seeded profile fields

Since profile field is required, create was failing (silently).

Add required field so these are available in e2e tests.

* Use factory `association` to create a profile field group

https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#explicit-definition

* provide required profile field group when posting data

* Fix one spec, drop another

Both of these scripts will be removed in the other branch (changing
the attribute name) - dropping the test here seems lower trouble than
modifying an out of data data update script to pass.

* skip test slated for removal

Similar to the last commit - this test exercises a script about to be
archived in the other branch.
2022-02-15 09:27:18 -06:00
Taylor Hunt
b61e238f8a
Fix tall aspect-ratio images getting squashed (#16554)
* Fix tall aspect-ratio images getting squashed 

When the `max-height` kicks in, the `width` attribute needs to be overridden, just like `max-width` needs `height: auto`.

* Prefer `object-fit` to `width`

Avoids clashing with GIF-pausing library that sets `.ff-container`

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

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-02-15 15:04:06 +00:00
Nick Taylor
4d8792402a
Now the credit amount max toggles when switching between adding/removing credits. (#16568) 2022-02-15 07:18:22 -05:00
Jeremy Friesen
663a712a10
Removing deprecation warning (#16572)
Prior to this commit, I saw the following in the Rails test log:

```
DEPRECATION WARNING: 'include Pundit' is deprecated. Please use 'include Pundit::Authorization' instead.
 (called from include at ./app/controllers/application_controller.rb:12)
 ```
2022-02-15 05:02:47 -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
Michael Kohl
d5ecf61ee4
Admin API use case 1: endpoint to create users (#16520) 2022-02-15 09:30:00 +07:00
Mac Siri
6feefe6694
Apply safe navigation to Reactions::Send (#16570) 2022-02-14 16:41:53 -05:00
Marcelo Kopmann
292383175b
Fix Github Liquid Tag from repositories with dot character (#16551)
* fix: add dot character in github liquid tag regex

* fix: remove redundant escape inside regexp literal
2022-02-14 16:15:09 -05:00
Jamie Gaskins
66846c7a17
Fix NoMethodError on Nil for article preview (#16569)
* Fix NoMethodError on Nil for article preview

* Remove commented out debugging code
2022-02-14 14:38:29 -05:00
Jeremy Friesen
cf53758476
Removing Articles::Builder making policy decision (#16536)
* Removing Articles::Builder making policy decision

This change is a refactoring through triangulation.  Given that
`ArticlePolicy#new?` returned true, I'm prepared to assume that calling
`authorize(Article)` in all cases is acceptable.

So to narrow the Builder making a policy decision I renamed the returned
value to reflect what it was actually doing in the logic.  And in
renaming, flipped the polarity of the boolean.  Why the flip?  Because
`needs_authorization == !store_location`.

In consultation with Allison and Jennie, I'm proceeding with a short-cut
to get me unstuck.  That unstuck is namely "I need to ensure that the
articles#new action can go through authorization."

Given that I'll be spending time in the authorization layer, I hope
these noted short-cuts and comments will be useful in future spelunking
efforts regarding authorization.

Closes #16529

* Update app/policies/article_policy.rb

Co-authored-by: Michael Kohl <me@citizen428.net>

* Disabling spec

* Update app/policies/article_policy.rb

Co-authored-by: Dwight Scott <dwight@forem.com>

* Update app/policies/article_policy.rb

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: Dwight Scott <dwight@forem.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-14 11:39:22 -05:00
ludwiczakpawel
5baa099f33
Spec fix (#16431) 2022-02-14 13:17:14 +01:00
Suzanne Aitchison
29b17e4bf9
Admin member area a11y fixes: Overview page (#16524)
* quick fixes on the overview page

* more overview fixes

* put stats in a descrition list

* fix error in twitter link

* fix some more svgs

* disable the remove tag pills

* link description in merge user modal

* link some other descriptions

* prevent duplicate IDs in edit org description label

* fix badly resolved conflict

* updates after merged changes
2022-02-14 08:08:19 +00:00
Suzanne Aitchison
e38688af42
let ff-container receive all normal image styles (#16541) 2022-02-11 14:16:26 +00:00
Jeremy Friesen
c70d3f759c
Renaming policy methods for consistency (#16523)
Our domain of "admin?" method names is already a bit confounding.  The
policy methods renamed the existing Policy::Authorizer methods, and
further obfuscated and confused intention.

This refactor aligns the policy methods with the Policy::Authorizer
methods.  It is a non-breaking change, but one that may add warnings in
the logs.  If you see those, resolve them per instructions.

Related to #16483
2022-02-11 09:10:54 -05:00
Jeremy Friesen
6e485a55a2
Documenting ApplicationPolicy (#16527)
The comments speak for themselves

Related to #16483

In support of https://github.com/orgs/forem/projects/46
2022-02-11 08:51:52 -05:00
Nick Taylor
7e1869f1d1
Added E2E tests for new admin member details view (#16513) 2022-02-11 08:47:01 -05:00
Suzanne Aitchison
2f64ba88e7
Minor accessibility fixes for member detail views (#16538)
* minor fixes for other member detail views

* tidy up redundant spaces
2022-02-11 13:35:06 +00:00
Nick Taylor
bfbe90cfbe
Now Bg color hex is labeled Tag Color (#16492) 2022-02-11 08:31:57 -05:00
Julianna Tetreault
8d1eb6f225
Adds flash messages when adding and removing credits from a User (#16531) 2022-02-11 06:14:09 -07:00
Michael Kohl
a91e505051
Add FeatureFlag.all (#16496) 2022-02-11 13:38:17 +07:00
Julianna Tetreault
961f0a695a
Removes leftover comments from Admin::UsersController (#16530) 2022-02-10 10:50:43 -07:00
Jeremy Friesen
87e1622e6b
Favoring method aliasing over explicit delegation (#16526)
Prior to this commit many of the policy methods were of the form:

```
def create?
  edit?
end
```

The above works, but introduces a place for code drift.

We can shorten this to:

```
alias create? edit?
```

This helps keep the policy methods compact and scannable.  All things
authorization policy related should create narrow surface areas.  By
hand-crafting methods, it is easier for "slippage" to occur.

Another advantage of `alias` is it's use is reflected in API
documentation.  With alias you need only write documentinig comments for
one method and the doc generators will relate the alias and the original
method.

If you "hand craft" a method using explicit delegation, the API
documentation won't pick up that two methods are aliases.

Further, I believe we should be moving towards parity between the
GET/POST/PUT methods that are related (e.g. the create/new pair and the
update/edit pair).  This is not the case, as we "silently" suspend
folks.  As we move through the [authorization work][1], we will start
hiding the links/buttons when a user can't take the action.

Related to #16483 and #16523

[1]:https://github.com/orgs/forem/projects/46
2022-02-10 11:09:17 -05:00
Julianna Tetreault
89706527b0
Remove "New Admin Member"-Related Code (#16475)
* Removes code behind new_admin_members feature flag

* Removes components/admin/users/tools/* and the tools components

* Removes unused /admin/users/tools/* controllers, comments, and routes

* Removes New Member View-related E2E and RSpec specs

* Remove admin_users_tools.rb frin spec/support/shared_examples/

* Removes remaining component-related specs

* Removes the view_component gem and test helper

* Resolve merge conflicts in Admin::UsersController

* Removes the view_component gem, as it is no longer used

* Removes view_component from Gemfile.lock
2022-02-10 06:42:56 -07:00
Jeremy Friesen
e6244b7f7e
Adding feature flag for Authorization 1-1 (#16518)
As written in the comments, we're looking at making the smallest change
to deliver on the feature.  The other goal is to move from our
`user.admin?` paradigm towards leveraging Pundit policies.

If we need to move beyond Pundit, it will be easier once we've moved
all of our `user.something_something?` to policy questions.  And please
note, I don't know if we'll move past pundit.

See [Authorization System: use case 1-1 project][1] for details on the
project.

Closes #16483

[1]:https://github.com/orgs/forem/projects/46/views/1
2022-02-10 08:13:41 -05:00
Jeremy Friesen
30ff24393c
Allowing dependency injection for LiquidTag policy (#16511)
This is the least effort I can presently think of to allow for us to
reprocess user article's and handle the scenario in which the user may
have once had permission to the liquid tag but no longer.

This DI is not something I imagine using, but may highlight a better
approach for liquid tag permissions.

Related to #12146 and #16460
2022-02-10 07:47:16 -05:00
Arit Amana
ddfdecfab9
Implement Unified Embeds for Forem-specific URLs (#16512)
* complete implementation; specs and refactor remain

* add specs (failing right now)

* complete implementation; add spec

* fix failing spec

* missed some specs that needed to go

* PR review comments

* specs covering forem_tag.rb
2022-02-09 18:35:14 -05:00
Dwight Scott
509e7d0e78
Modify tags api index to allow for bulk GET of tags (#16417) 2022-02-09 15:30:15 -05:00
Ben Halpern
a43d25f6fe
Add Disallow URLs to robots.txt for uselessly crawled endpoints (#16501) 2022-02-09 12:19:28 -05:00
Jeremy Friesen
42b39da1a8
Ensuring an admin can confirm delete a user's post (#16485)
Prior to this commit, the admin could delete the post but were blocked
by the "delete confirm".  The blocker was because we scoped the finding
of an article to the current user.

With this commit, the admin should be able to confirm the deletion of an
article.

Closes #16461
2022-02-09 11:28:58 -05:00
Alex
f071903176
Remove counts from instance API (#16479) 2022-02-09 11:07:44 -05:00
ludwiczakpawel
50a4f0422b
Admin's Member view (#16174)
* init

* .

* partials

* few extras

* revert indicators in favor of separate PR

* stuff

* .

* stuff

* whoops

* .

* .

* .

* .

* opacity

* partial

* cosmetics

* move actions to a partial

* whoopsy

* Added an @admin alias for the frontend and removed the @admin-controllers alias.

* Added modal support for admin user actions.

* Added modal support for more parts of the user admin.

* pills

* pills

* pills

* Added optional chaining for when the overview panel isn't loaded.

* styling updates

* fix

* modals

* pass size

* tags

* .

* balance modal

* comment

* fixes

* Improved modal trigger implementation.

* Removed default value for dataset.

* Moved prevent default to after modal trigger check so forms still submit.

* Update app/views/admin/users/widgets/_credits.html.erb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Update app/views/admin/users/reports/_index.html.erb

* Apply suggestions from code review

* Apply suggestions from code review

* Update app/views/admin/users/actions/_export.html.erb

* Update app/views/admin/users/widgets/_tag_moderation.html.erb

* Update app/views/admin/users/actions/_merge.html.erb

* Removed <AdminUserActionsModal /> component as it wasn't necessary.

* Fixed duplicate ID errors detected by Axe.

* Redirects to the Show page rather than the Edit page

* Adjusts quotations within _social_accounts.html.erb

* Ensures that Learn More links open in new tab

* updates with latests and greatest

* .

* fixes

* wip. Fixed some issues in the credits form.

* Changed Subtract to Remove for credits dropdown.

* Cleaned up the edits form.

* Wraps functionality in feature flag and calls #set_user_details

* Wraps /admin/users/show.html.erb in feature flag

* wip: Got credit params form working.

* empty select

* responsiveness

* empty commiit

* Updates redirects in spec and controller to show rather than edit

* Updates tag moderation copy in Admin Member Detail View

* Now the note is saved when changing credits.

* Fixed label for attributes as it was affecting writing tests and a11y.

* Removes unused index.js component

* Refactored credit params.

* chore: move method under private and update comment

* verified email responsiveness

* better opacity variables

* better org logo

* indicators

* refactor the credits method

Co-authored-by: Nick Taylor <nick@dev.to>
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Nick Taylor <nick@forem.com>
Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2022-02-09 14:33:01 +01:00
Nick Taylor
32e1b3f228
Removed colour picker from onboarding as it's never used. (#16491) 2022-02-09 06:17:16 -05:00
lionel-rowe
f72e60b15d
Add color-scheme: dark to dark.css (#16493) 2022-02-09 08:52:46 +01:00
Ben Halpern
84379574d5
Feed experiment 6: recency (#16438)
* Feed experiment 6: recency

* Update app/services/articles/feeds/weighted_query_strategy.rb

Co-authored-by: Michael Kohl <me@citizen428.net>

* Update app/services/articles/feeds/weighted_query_strategy.rb

Co-authored-by: Michael Kohl <me@citizen428.net>

Co-authored-by: Michael Kohl <me@citizen428.net>
2022-02-08 15:01:18 -05:00
Jeremy Friesen
d19dad3b28
Ensuring optionally rendering dashboard listings (#16467)
Relates to forem/rfcs#291, #16420, #16437, #16423, and #16461.
2022-02-08 13:41:22 -05:00
Jamie Gaskins
5d00a4d967
Show image-upload errors on /admin/advanced/tools (#16448)
* Show image-upload errors on /admin/advanced/tools

* Simplify error handling

This also makes the error message consistent with the rest of the admin
validation errors, so it's probably better even if it doesn't look as
flashy.

* Remove obsolete clearTimeout call

We aren't setting this timer anymore
2022-02-08 10:41:54 -05:00
Daniel Uber
39c5bcd518
remove activex fallback for internet explorer (#16453)
* remove IE6 XHR support

IE7 and later support XMLHttpRequest natively, and most of the rest of
the code base uses fetch() which may not work in any version of IE

Drop the conditional here in the assumption that this would only be
the first of many problems for a user with an unsupported browser.
2022-02-08 08:36:04 -06:00