Commit graph

6311 commits

Author SHA1 Message Date
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
Jeremy Friesen
2fd94fcc87
Ensuring that body.dataset is JSON parsable (#16441)
Prior to this commit, if our community name included a `"` we would
encounter a parse error.  Using the [j][1] which is a terse alias for
[escape_javascript][2], we will now be escaping those characters that
cause grief in some of our parsings.

I believe there is a larger audit that needs to occur regarding all
`data-` renderings.

Hopefully this will catch a flakey test.

Closes #16440

[1]:https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-j
[2]:https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-escape_javascript
2022-02-08 07:30:43 -05:00
Arit Amana
2842bc68d6
Implement Unified Embeds for Github Repo, Issue, Pull-Request and Comment URLs (#16422)
* figuring things out

* working both ways for issues PRs except disc and PRreview

* working on repo urls

* complete implementation and check specs

* resolve Travis failures

* resolving travis failures

* Fix VCR cassette

* fix regexs

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
2022-02-07 16:38:43 -05:00
Arit Amana
63c957b12d
Implement Unified Embeds for StackExchange and StackOverflow URLs (#16415)
* complete implementation and add specs

* improvements

* more robust condition

* update API version; re-record VCR cassettes

* PR review comments
2022-02-07 11:21:11 -05:00
Mac Siri
0559a808c4
Allow nil pubDate in Podcast sorting (#16349)
* Allow nil pubDate in Podcast sorting

* Choose a shorter syntax

* Typo
2022-02-07 11:18:51 -05:00
Jeremy Friesen
30a894a6eb
Removing deprecated User methods (#16435)
* Removing deprecated User methods

Related to #15762, #15691, and #15624

* Bump for travis
2022-02-07 10:32:58 -05:00
Suzanne Aitchison
8a14504a8e
Add accessible color picker component (#16385)
* add colorpicker component

* add tests

* separate out label, change swatch border
2022-02-07 14:30:02 +00:00
Jeremy Friesen
446e74ca83
Documenting and addl testing FeatureFlag.enabled? (#16420)
Prior to this commit, we had a single test for `FeatureFlag.enabled?`,
namely that it delegates to `Flipper.enabled?`.  This commit adds some
tests to both verify behavior and communicate to developers the
intentions of the related methods:

- `FeatureFlag.enabled?`
- `FeatureFlag.accessible?`

My hope is the documentation and tests will help address the horrors
mentioned in conversation in #16416:

> I have lived the horrors of having a feature flag accidently
> flipped or incorrectly setup in the first place and half baked
> functionality going live.

Note: I'm not proposing that we test other `Flipper` methods, but
instead to ensure that we're testing and documenting the behavior of
what I believe to be the two primary mechanisms of "putting something
behind a feature flag."

Related to #16406, #16416
2022-02-07 08:53:30 -05:00
Jamie Gaskins
a9cdb2bae2
A suspended user returns 403 instead of 500 (#16408) 2022-02-04 09:42:23 -05:00
Nick Taylor
52e4e571b7
Reworked some webpack aliases as prework for #16174. (#16412) 2022-02-04 06:34:37 -05:00
ludwiczakpawel
baa4ea1ed0
Applying Crayons to Content Manager pages (#16375)
* .

* comments

* .

* badges new

* edit podcasts

* edit badges

* whoops

* fixes

* like

* like
2022-02-04 09:31:59 +01:00
Suzanne Aitchison
e8154fb19c
Copy organization secret code to clipboard (#16358)
* init copy to clipboard functionality for org secret code

* add cypress test

* woops
2022-02-04 08:22:03 +00:00
yheuhtozr
e45536af37
app/models i18n (#16124)
* app/models etc i18n

* delete ja.yml

* fix for PR review

* fix for spec

* delete ja.yml

* fix for spec updated
2022-02-03 13:41:42 -05:00
yheuhtozr
c4778d832e
app/controllers & decorators i18n (#16126)
* app/controllers (& decorators) i18n etc

* tidy key names

* update keys

* delete ja.yml

* delete an involved ja.yml

* fix for PR review

* fix for spec

* delete ja.yml
2022-02-03 13:35:56 -05:00
Suzanne Aitchison
3454750ad3
Place gifs correctly regardless of center tag (#16404)
* place gifs correctly regardless of center tag

* typo

* make sure the same gif src can be used twice in a post

* approach in css
2022-02-03 15:44:44 +00:00
Michael Kohl
a1eb6358db
Easier feature flag handling for Cypress (#16379)
* Add RailsEnvConstraint for routes

* Add feature flags API

* Add Cypress commands

* Add show action, update commands, add e2e test

* Update cypress/integration/seededFlows/toggleFeatureFlags.spec.js

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

* Move helper from command to test file

* Update documentation

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-02-03 10:42:13 -05:00
VISHAL DEEPAK
14a945326d
Add boolean attribute main_image_from_frontmatter to indicate if cove… (#16075)
* Add boolean attribute main_image_from_frontmatter to indicate if cover image was set via frontmatter

* use article model spec for main_image_from_frontmatter test cases

* Add data migration script and spec for main_image_from_frontmatter for articles

* Update app/models/article.rb

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
Co-authored-by: Michael Kohl <me@citizen428.net>
2022-02-03 09:16:48 -05:00
Suzanne Aitchison
a168f0c85a
Change UI instances of "vomit" to "flag" (#16397)
* change UI instances of vomit to flag

* update spec

* verify tests against i18n string
2022-02-03 12:22:32 +00:00
Fernando Valverde
b1c0a8d631
Add special case for DEV Android app (#16382) 2022-02-02 15:25:14 -06:00