Commit graph

6734 commits

Author SHA1 Message Date
Suzanne Aitchison
189e933202
add a description to the modal (#18097) 2022-07-13 11:58:44 -04:00
Suzanne Aitchison
5166581a34
remove filter by last activity, fix close modal bug (#18081) 2022-07-13 13:58:14 +01:00
Suzanne Aitchison
02bba1c943
skip flaky date range picker spec (#18076) 2022-07-12 10:06:52 -06:00
Jeremy Friesen
0ef5bc6351
Ensuring we delete podcasts when we banish a user (#18063)
Prior to this commit, we may have left lingering podcast entries that
required manual cleanup.  As a bonus, I also added deleting podcasts
when we delete users.

Closes forem/forem#18041

In addition I adjusted rubocop to not complain about the require method call

```
spec/services/users/delete_spec.rb:1:1: C: \
  Style/TopLevelMethodDefinition: \
  Do not define methods at the top-level. \
  (https://rubystyle.guide#top-level-methods)
require "rails_helper"
^^^^^^^^^^^^^^^^^^^^^^
```
2022-07-12 09:18:06 -04:00
Joshua Wehner
5dee4a11c1
Allow trusted user to access response templates (#17978)
* Allow trusted user to access response templates

* Add request specs for trusted user templates

* WIP: was just investigating...

* Move permission check to authorizer

* Revert "WIP: was just investigating..."

This reverts commit c38c60f7ab19ce43c174729c2542a9041e9322e2.

* Improved accessibility

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

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-07-12 11:37:59 +02:00
Suzanne Aitchison
2f436731a7
Add markdown toolbar to comments (#18062)
* show the toolbar (WIP - includes some hacks and todos)

* allow calling component to pass additional toolbar elements

* add templates behaviour

* get templates working

* tweaks following mention autocomplete refactor

* remove image upload handler no longer needed

* rename method

* some small refactors

* only comment text area controls visibility of templates area

* fix error in role name

* fix mobile view

* update specs
2022-07-12 09:02:53 +01:00
Suzanne Aitchison
75d6e60a95
✂️ Remove reach combobox ✂️ (#17728)
* WIP: new autocomplete, search executed, dropdown positioned

* WIP: most features working in Editor

* handle textarea blur

* fix bug with id not attached to textarea

* updates to textAreaUtils tests

* aria live, fix border style

* replace comment text area

* fix some height and style issues

* update preact tests

* clean up styles, rename files, use portal for popover

* clean up styles, rename files, use portal for popover

* scroll popover items into view if necessary

* refactor cypress specs

* actually remove the package

* add some more specs

* remove storybook stories for now

* remove relative class causing issues

* small fixes for cypress specs

* make live region assertive to ensure change to combobox is known

* some comments

* add a storybook story

* replace % font size, add explainer to story
2022-07-11 12:50:52 +01:00
Fernando Valverde
b8abbda72e
Unpublish post service class + V1 API endpoint (#18031)
* Unpublish post service + API

* Apply PR feedback

* Use module_function on service class
2022-07-08 09:08:55 -06:00
Anna Buianova
80ce8909ec
Fixed most rubocop issues (#18048)
* Fixed most rubocop issues

* Fixed accidental schema changes

* Fixed Vault specs
2022-07-07 14:36:08 -06:00
yheuhtozr
64dd92d60d
Supplement some new i18n keys (#18034)
* missing i18n updates

* i18n key typo hotfix

* more on actions panel template
2022-07-07 09:38:29 -06:00
Anna Buianova
ff76cdd3c5
Scheduling articles (#17939)
* Article query spec for scheduled articles

* Added scheduled article badge on the user dashboard

* Added published_at field to editor options

* Accept and validate published_at from editor

* Refactor published_at validation

* Allow 1-minute difference in published_at

* Notice on an unpublished article page

* Added specs for 'Click to edit' link on scheduled article preview page

* ContextNotification model

* Articles::Publish worker

* Added specs for articles publish worker

* Schedule publish articles worker

* Added tests to check for scheduled posts in feeds

* Don't allow managing scheduled articles

* Don't send notifications for scheduled articles

* Set published_at in Articles::Updater when publishing

* Published_at value in post options

* Pass timezone and set published_at accordingly

* Limit setting published_at to the future

* Readonly published_at for articles that were already published

* Chagning published_at format in editor v1 (start)

* Changed published_at format in frontmatter, specs

* Added specs for updating published_at from frontmatter

* Fixed accepting past published_at for articles published_from_feed

* Enabled published_at validation: don't allow updating published_at for already published articles

* Validate published_at on create

* Added a spec for updating published_at for exported articles

* Fixed specs related to creating articles with past published_at

* Fixed specs related to past published_at for articles

* Added a hack so that admins would be able to update published_at

* Switch button text schedule/publish when changin publishedAt

* Fixed saving published_at with timezone

* Added a feature flag for scheduling articles

* Default text in markdown editor depends on feature flag

* Enable article editor cache again

* Fixed the default value in the markdown editor

* Fix sitemaps spec

* Removed tooltip

* Fixed articles update specs

* Added missing locales

* Fixed article create specs

* Fixed spec

* Removed commented code

* Returned enabling extensions in the schema

* Returned accidentally deleted constraint

* Make articles query spec more stable

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

* Removed commented code

* Removed unused code

* A clearer policy

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

* Use StringInquirer for article current state

* Added a note and todo to articles factory past trait

* Remove duplicated PropType

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

* Refactor query in the Articles::PublishWorker

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Refactor articleForm.jsx

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Removed specs that are no longer relevant

* Removed useless onKeyUp on a hidden input

* Refactored articleForm

* Hide scheduling from post options when published_at is readonly

* Run sends notifications worker every 5 minutes instead of every minute

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2022-07-07 17:32:49 +03:00
Joshua Wehner
5e916b74c1
Possibly fixes style injection? (#18053)
See https://github.com/forem/forem-internal-eng/issues/480
2022-07-07 16:05:33 +02:00
Rajat Talesra
5966960c04
Create Preview Loading screen (#17914)
* Minor changes

* Basic implementation with some bugs

* Removed files

* Correct tab selection

* Added tests

* Disabled bottom bar buttons on preview loading

* Applied other changes

* Added tests for PageTitle

* Added tests for LoadingPreview

* Added test for Options.jsx

* Removed comments

* Fixed CSS

* Removed unused code

* Fixed test failure

* Added aria-live

* Nit fixe

* Fixed tests

* Applied suggested changes
2022-07-07 19:21:50 +05:30
Anna Buianova
6a229f00b7
Fixed removing notifications on admin unpublishing (#18047) 2022-07-06 18:35:20 +03:00
Rajat Talesra
bc0e5ced6c
Used PreactModal for unpublish-post feature (#18019)
* Used preact modal

* Minor fix

* UI fix

* Appplied minor suggestions
2022-07-06 16:29:08 +05:30
Andrew Bone
04ebdbab1c
Typo (#18046)
Yikes, I made a typo
2022-07-06 09:25:34 +01:00
Andrew Bone
4489b9a23f
Truncation long text on profile screen (#18038)
* Allow truncation

* Allow truncation

* Allow truncation
2022-07-05 12:59:15 -06:00
Suzanne Aitchison
9bb600168b
filter xss on user name (#18026) 2022-07-01 16:03:07 +01:00
Andrew Bone
419a63862d
update aspect ratio to reflect cover image size (#17734)
* Prevent cover images from scaling down

* Update aspect ratio
2022-06-30 14:59:40 +02:00
Suzanne Aitchison
d806393642
Validate date format and min/max in date range picker component (#18006)
* add validation behaviour

* add specs

* refactor into a hook
2022-06-30 10:08:06 +01:00
Dwight Scott
50e2131079
mod panel update unpublish all posts action 17709 (#17923) 2022-06-27 16:50:31 -04:00
Arit Amana
750d379807
Allow ModRole & Admin to Suspend & Unsuspend User (#17946)
* gotta commit at some point

* out of gas

* IT'S WORKING NOW! 💥

* Cypress tests

* fix Travis failures

* incorporate PR review suggestions

* fix one failing Cypress test

* update API call

* add Unsuspend flow; fix Travis failures

* add tests for unsuspend flow

* remove unnecessary atrribute

* add article_policy spec

* fix failing Travis

* nudge Travis

* fix apparent typo  o o 🤷

* refactor a bunch of duplication

* nudge Travis

* fix Cypress failure related to authorizing moderator for user_status action

* rename modal partial

* remove unnecessary button-exists check

* address PR review suggestions

* hide suspend user btn after action

* toggle btn based on author suspension status

* add data-testids

* use data-testids

* controller refactor
2022-06-27 12:45:35 -04:00
Jeremy Friesen
b8533172e3
Introducing a quick and dirty fix for abtests/admin (#17982)
This is a "quick and dirty" hack.  Do I like it?  No.  Do I want to delve
into further debugging/refactoring of [a 72 line method][1]?  Not at the
moment.  There are a few pathways forward, but for now, this is the
pathway to hopefully give us insight into the

**Why will this likely address the issue?**

Prior to this commit, for an experiment we would render each of the
goals (anywhere from 8 to 11); each of which would require 2 expensive
queries; which means about 16 expensive queries.

After this commit, the experiment page has none of those expensive
queries; instead each goal now runs the 2 expensive queries.

The hope is that this will help us show the results (albeit on multiple
pages) while coming in under the response time out handlers we have in
place.

**Why no tests?**

Ugh; I know right?!?  I'm beginning to ask that myself.  But for now,
because this is only visible to tech_admins, the consequences of
breaking are limited.  In otherwords, this is not a customer facing
feature, so it can be a bit less robust in it's testing.  At least
that's the rationalization I'm establishing.

Further, local tests would not reveal the production environment
complications of large data sets.  The aforementioned expensive queries
are blisteringly fast on my local machine...in part because I don't much
field_test experiment data.

Closes forem/forem#17981

Related to:

- forem/forem#17895
- forem/forem#17869

[1]:ab2d7d29d0/lib/field_test/experiment.rb (L98-L160)
2022-06-24 09:26:46 -04:00
Julianna Tetreault
ec55329a3a
Member Index View Actions: "Adjust Credit Balance" (#17974)
* Adds the Adjust credit balance modal to index view

* Adds e2e tests for adjusting credit balances via modal

* Adds the ability to update credits to #user_status

* Adjusts the e2e to address failures
2022-06-23 14:30:10 -06:00
Fernando Valverde
1eafd7388e
Fix email confirmation logic when registering via Omniauth (#17878)
* Move .skip_confirmation! call to .find_or_create_user! method

* Add regression tests to avoid email confirmation delivery

* Keep the original place where we had user.skip_confirmation! too

* Update logic to require email confirmation from omniauth

* test confirmation is required with SMTP

* Keep :notice instead of :global_notice

* Forem Account bypass email confirmation reorg

* inline comment reorder + clarification

* Apply suggestions from code review

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

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2022-06-23 16:26:26 -04:00
Fernando Valverde
8c836430ca
API V1 transition (#17835)
* API Articles v0-v1 restructure

* Remove unused helper

* Bulk move API controllers into concerns + add V1 controllers

* Extract API routes + some fixes

* Fix v1 api_controller authenticate! + add more article_controller specs

* Completed spec/requests/api/v1/articles_spec.rb

* specs up to listings

* All v1 specs except for 9 skips

* mime_types cleanup + authenticate! relocation

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2022-06-23 14:26:00 -06:00
Suzanne Aitchison
213fcb956d
Member index: Show applied org filters (#17977)
* show applied org filters

* correct casing
2022-06-23 18:14:41 +01:00
Mac Siri
2f029fe896
Enable Rails framework 7.0's isolation_level, partial_inserts, & raise_on_open_redirects (#17970) 2022-06-23 10:30:58 -04:00
Ridhwana
abeff25ec0
BETA version 2 of the Storybook Multi Input (Editing and Accessibility) (#17894)
* refactor: use the DefaultSelectionTemplate to list out the items

* refactor: rename function so that we map it to the deselect item event

* feat: first pass of adding edit functionality

* feat: update the name of the function from clearSelection to clearInput

* feat: setup the edit state by ensuring that we set the editValue and the inputPosition and then use useEffect to monitor changes

* chore: remove the old method in favour of a shared component

* feat: set the order of the items

* refactor: rename handleBlur function name to handleInputBlur

* feat: ensure that the edit field gets resized according to its current input

* feat: oops add inputSizerRef

* feat: when an item is being edited we need to ensure that it gets set back into the correct position and that we clear the previous state

* feat: handle the actual resizing fo the field on an input edit

* feat: use a shared DefaultSelectionTemplate for both the multiautocomplete and the multiinput component

* feat: make the defaultSelectionTemplate customizable based on the variant adn the classname

* feat: pressing backspace will start editing a previous selection if there is one

* feat: read out the selected items as its removed or edited

* feat: pass the regex through as a prop

* feat: move the functions around

* feat: add screen-reader only class

* Update app/javascript/crayons/MultiInput/__stories__/MultiInput.stories.jsx

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

* Update app/javascript/crayons/MultiInput/MultiInput.jsx

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

* feat: add the props to JSDoc

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-06-23 15:41:45 +02:00
Jeremy Friesen
5867557582
Adding parameter to abtest show page (#17968)
Without this parameter, we're not showing the full picture of the feed
variant configuration.

Related to forem/forem#17895
2022-06-22 10:17:43 -04:00
Suzanne Aitchison
8bd7e4eba9
Member index: Show applied roles filters (#17954)
* show the pills

* clicking pills removes filter

* add some more spacing

* another alignment tweak

* add cypress spec

* put it behind the feature flag

* make the clear all link a button for consistency

* tweak to comment for clarity
2022-06-21 16:27:26 +01:00
Suzanne Aitchison
26077f3e1f
Rename base_roles ui labels (#17938)
* rename base_roles ui labels

* update some specs

* fix missed strings in cypress spec
2022-06-21 16:17:35 +01:00
Josh Puetz
bb4f8fa2b5
Track clicks and views in comments on article page (#17886)
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-06-21 09:19:55 -05:00
Suzanne Aitchison
d57e4cabb7
Member index: filter by organizations (#17943)
* show the organizations checkboxes

* apply clear filter button and indicator

* filter by org in users query

* add some rspec tests

* add cypress specs

* correct cypress spec

* Fixing UsersQuery to ensure singular user by organization

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
2022-06-21 13:32:50 +01:00
Suzanne Aitchison
48818a96b7
Member index: controls layout refactor (#17927)
* tweak for smallest viewport

* layout essentially there

* conditionally toggle what the filter button triggers

* contain width of filter section on large screens

* reinstate old view depending on feature flag status

* add type: button (woops)
2022-06-17 10:33:43 +01:00
João Gabriel Quaresma
a0d3a2a200
feat: tagged articles page title can render tag pretty name (#17944) 2022-06-17 10:30:50 +01:00
Jeremy Friesen
7a4dd3286d
Adding VariantQuery reseed randomization option (#17942)
Prior to this change, we setup our feed variant query to have a cached
randomization seed.  For a given user this seed is cached for 15
minutes.  The goal of this is to provide mostly consistent sort orders
on the feed articles during that 15 minute window.

With this change, we allow for a feed variant to say ignore the cached
seed and generate a new one for this call.

I have also added explicit settings to each of the feed variants to
reflect our desired intentions for those features.

Relates to

- forem/forem#17833
- forem/forem#17826

Closes forem/forem#17940
2022-06-16 15:04:08 -04:00
Suzanne Aitchison
1eefc3d3cd
remove storybook addon-links (#17935) 2022-06-16 15:03:47 -04:00
Suzanne Aitchison
b94c5deea6
Admin member index: filter by member roles (#17884)
* prevent ID conflicts in filters modal by caching content

* show roles with expandable section

* minor tweak

* don't use the hidden field

* send array of role

* role -> roles. small refactor

* set initial checked status

* show an indicator when a filter is applied

* add JS to toggle filter clear buttons and indicators

* update some comments, make sure users only appear once in list

* add some cypress specs, fix some bugs
2022-06-16 15:06:35 +01:00
Joshua Wehner
07e1364f54
Trusted users can view & use moderator response templates (#17867)
* Trusted users can use moderator response templates

* Iron out container reveal logic

* Explanatory comment on controller endpoint confusion
2022-06-16 14:05:49 +02:00
Jeremy Friesen
b4f17ed7dc
Allowing UserQuery to filter on multiple roles (#17919)
I had looked at using `User.with_any_roles` but that creates one User
query per role passed.  Which is not ideal, given that we want to have
an ActiveRecord::Relation object on which we'd paginate.

This adjustment does it's best to mimic Forem's role structure and
adhear to how Rolify builds the underlying query.

An astute reader will notice that in these specs we use `role: "admin"`
and `roles: ["Admin"]`; the primary reason relates the user interface
being worked on in forem/forem#17884.  It is my understanding that the
`role` approach and `roles` approach will be separated by a feature
flag (we're rolling out the `roles` approach).

Related to
- forem/forem#17491
- forem/forem#17884
2022-06-15 08:50:03 -04:00
Arit Amana
d15d36da54
Allow Moderator Role to adjust post tags (#17858)
* building

* Implement flow; tests pending

* complete backend work

* add e2e tests

* fix error in specs

* address Pr review comments

* add specs for article_policy changes

* method refactor

* refactors

* add max_tag_List_size constant

* destroy all test tags

* test db cleaned!

* COMPLETED T THE SPECS!!! 💃💃

* optimization

* reverse "optimization" 😅
2022-06-14 10:55:19 -04:00
Julianna Tetreault
379a5fd3dd
Member Index View Actions: "Add Organization" (#17879)
* Adds an Add Organization modal and e2e tests for the modal

* Conditionally redirects to the correct view upon adding org

* Combines modal tests within userIndexView.spec.js

* Removes redundant code and switches assign role and add org button positions

* Updates RSpec tests to account for conditional redirection

* Lowercases the o in organization within _user_actions_dropdown.html.erb

* Fixes failing e2e tests
2022-06-14 08:31:51 -06:00
Jeremy Friesen
234fd8b08d
Adjusting field_test index and show page (#17895)
This change introduces several things things:

1. Fixes the performance of the `/admin/abtests` page; instead of
   rendering all of the experiment results, just render the overview.
2. Adjust the show page for an experiment to show the summary of
   results.
3. Favor the existing "started_at" and "ended_at" attributes of
   FieldTest (see https://github.com/ankane/field_test#config)
4. Update the field test experiments to include the `started_at` and
   `ended_at` attributes.
5. Skip processing all non-active experiments in our conversion handler.

Why are there no tests?  This is a page that is Admin only and is only
visible for reporting purposes.  So, it's not quite worth writing tests
as you'd need lots of data.  So we'll assume the logic from the upstream
[field_test gem][1] is adequate.

Closes forem/forem#17869

[1]:https://github.com/ankane/field_test
2022-06-13 12:22:36 -04:00
Fernando Valverde
6b073d078b
Enable clickOutsideDeactivates on Onboarding FocusTrap (#17885) 2022-06-13 08:23:46 -06:00
Jeremy Friesen
736079e28c
Adding additional order by levers (#17847)
In the general sense we have an existing `order by` that follows the
following format: `order(x) = f(x) * rand() ^ ( 1 / g(x))`

For the present [20220603-variant-b][1], `g(x)` is the article’s score.
And `f(x)` is 1.

This pull request introduces a few named variations for the above
`order(x)` formula.

The three named formats each use a different `g(x)` function; namely
`greatest(0.1, ln(1 + greatest(0, public_reactions_count)))`.  The more
public_reactions the article has the closer to zero the resulting
positive number will be.  And raising a random number, with range
`(0..1)`, to the inverse of that number will tend to mean that artciles
with many reactions will tend to group towards the higher end of the
random range, whereas articles with few reactions will have a more even
distribution across the range.

Further the `ln` function helps dampen the weight we give to reactions.

The variation within these three order levers is on the `f(x)` portion:

1. Using `published_at`
2. Using `last_commented_at`
3. Using a mix of `published_at` and `last_commented_at`

In all cases, those dates are converted to an integer.  A date 2 weeks
ago will result in a number less than a date 1 week ago which will be
less than a today.

The idea for the mix of `published_at` and `last_commented_at` is to see
a mix of things where some “older” articles (from the underlying result
set) will get a chance to show up earlier in the feed.

My rational for this order structure is because the `RANDOM() ^ (1 /
score)` is showing possible success in a current experiment.  And in
past trials long past, it rose to the top as a likely and viable
contender.

These new `order_by` lever patterns introduce three things:

1. A variable based on a date in time
2. A dampening of what can be a large number; (we have scores in the
   publication range that are between -200 and 750 so I think it is
   important to apply a dampening.  For example `(0.1 ^ (1/100)) =
   0.977` and `(0.01 ^ (1/100)) = 0.955`; in other words these large
   scores aggressively pushed their corresponding posts to the top of
   the relevance; even as we weren't explicitly querying for those
   scores.
3. With the score being quasi-magical, it doesn’t make sense to sort on
   that value but to instead sort on a property that represents what
   we’re setting as our experiment goals (e.g. publishing something or
   commenting on something and/or reacting to something)

Note: it would be feasible to extract these into a singular order lever
that we would configure.  But that's a future concern.

Also note, none of these are yet part of any experiment, but are instead
being "queued up" to add to our available corpus.

Closes forem/forem#17834

Related to:

- forem/forem#17827
- forem/forem#17826
- forem/forem#17833
- forem/forem#16128 :: for past order queries to seek as inspiration

[1]:https://github.com/forem/forem/blob/main/config/feed-variants/20220603-variant-b.json
2022-06-10 16:37:21 -04:00
Julianna Tetreault
8e4b6581e2
Member Index View Actions: "Assign Role" (#17866)
* Adds the Assign Role modal to the Member Index View

* Adds e2e tests for the Assign role modal

* WIP: Conditionally redirects to the correct view upon assigning a role

* Conditionally renders the redirect in the correct method :|

* Adjusts the conditional redirect to account for ID

* Adds an even more explicit check for the correct refferer
2022-06-10 07:22:03 -06:00
Rajat Talesra
27c6f07686
Feature/add embed icon to editor toolbar (#17781)
* Finished task 1 and task 3

* Task 2:  If the user already has text selected inside syntax

* Added comments

* Tests added

* Nit fixes

* Code optimisation

* Nit fixes

* Fix typo

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

* Removed console log statements

* Minor fix

* Simplified code

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-06-10 17:33:23 +05:30
Josh Puetz
77a00d242a
Move API keys from Account tab to Extensions tab in settings (#17862) 2022-06-09 09:44:50 -05:00
Jeremy Friesen
a1b17200c0
✂✂✂ Removing Spam::ArticleHandler (#17860)
This is uncalled code.  We instead use
`Spam::Handler.handle_article!` (see
[Article#create_conditional_autovomits][1]) for usage.

```shell
❯ rg ArticleHandler; echo $?
1
```

The above command shows for the "after this commit" state that there are
no mentions of the `ArticleHandler`.  The `1` is the exit status of the
`rg` (e.g. `ripgrep`).  A 1 exit status means no matches found.

[1]:bea711310e/app/models/article.rb (L915-L917)

Relates to forem/forem#15412
2022-06-08 16:34:29 -04:00