Commit graph

6540 commits

Author SHA1 Message Date
Mac Siri
441a76972b
Refactor: Move onboarding routes out of UsersController (#17189) 2022-04-13 14:20:16 -04:00
dependabot[bot]
3f3b13f382
Bump @testing-library/user-event from 13.5.0 to 14.1.0 (#17253)
* Bump @testing-library/user-event from 13.5.0 to 14.1.0

Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 13.5.0 to 14.1.0.
- [Release notes](https://github.com/testing-library/user-event/releases)
- [Changelog](https://github.com/testing-library/user-event/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/user-event/compare/v13.5.0...v14.1)

---
updated-dependencies:
- dependency-name: "@testing-library/user-event"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

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

* refactor to account for breaking changes

* remove redundant cleanup

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-13 10:41:08 -06:00
Suzanne Aitchison
64ed2c6dec
move showModal helper into its own pack file (#17266) 2022-04-13 14:15:07 +01:00
Ridhwana
44c9535d06
chore: typo (#17258) 2022-04-12 22:14:59 +02:00
Julianna Tetreault
760a51f5f7
Refactor Member Index View Users Query (#17251)
* Moves eager loading from _member_index view to Admin::UsersController

* Adds .registered to Admin::UsersQuery
2022-04-12 11:20:28 -06:00
Julianna Tetreault
471472d0b0
Add Internationalization to Admin::UsersController Success Messages (#17252)
* Adds internationalization to Admin::UsersController success messages

* Adds a new line at the end of en.yml and fr.yml

* Removes perriod from update_success message
2022-04-12 09:00:55 -06:00
Ridhwana
aff29406ac
First version of exporting the Users to a CSV (#17217)
* feat: add the export route

* feat: base export csv

* refactor: move the svg into its own file

* feat: add the export partial

* feat: export teh correct fields etc. for the csv

* user status helper

* feat: ensure that we format the time

* feat: add a spec for the CSV

* remove space

* remove puts

* chore: remove blank space

* feat: update traits

* Update app/views/admin/users/export.csv.erb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* Update spec/requests/admin/users/users_export_spec.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* Update spec/requests/admin/users/users_export_spec.rb

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>

* fix: export should not error for unregistered users

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
2022-04-12 15:24:32 +02:00
Suzanne Aitchison
b1e7d8a5ec
Member index (phase 2) - Search invitations (#17210)
* add ability to search invitations

* add an invited scope

* add a cypress test
2022-04-12 10:40:44 +01:00
Takuya N
038d355422
Tweak z-index for buttons in liquid tags (#17196)
* Tweak z-index for buttons in liquid tags

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>

* Tweak z-index for buttons in liquid tags more simply

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2022-04-12 09:48:27 +02:00
Jeremy Friesen
61ccc29fed
Conditionally disabling Listings (Waiting on Product but technically Good to Go) (#16437)
* Conditionally disabling Listings

Prior to this commit, we were assuming everyone still had the Listing's
feature turned on.

With this commit, we move from the "implicitly on" nature of
`FeatureFlag.accessible?` to the "explicitly off" nature of
`FeatureFlag.enabled?`.  The key differentiator is that we are not
"pushing out a feature flag setting to other forems."  Listings now
become an "opt-in".

This requires a few things:

1) Ensure that DEV.to enables the `:listing_feature` before we deploy
   this branch.
2) Communicate this change to other Forem adopters and provide a
   timeline for when we'll deploy this change.
3) Documentation.  Given that we have this feature, but it will be
   disabled by default, we want to look into communicating what it is
   and how to enable it.

Further, I chose to do the least effort change on our specs.  Namely to
treat the specs as though someone fully enabled the listing feature.

This pull request is a "competetor" to #16423.

Closes forem/rfcs#291

Relates to #16420 and #16461.

* Favoring only setting feature for specific tests.

* Adjusting cypress to avoid listing check

* Removing redundant test based on feedback

* Fixing feature spec

* Fixing cypress test
2022-04-11 20:23:56 -04:00
Suzanne Aitchison
c8b5282337
Admin member index: invitations table (#17180)
* basic table cols

* more detailed member col, overflow menu

* bottom pagination

* replace with partial
2022-04-11 19:36:55 +01:00
Suzanne Aitchison
a44d09e71a
Update table style for member index view (#17207)
* add minimal table style

* tweak table style vs member index specific style

* rename

* replace padding for smaller screens
2022-04-11 19:07:59 +01:00
Jeremy Friesen
e2618c50f5
Adding logic to hide Create Post on empty dashboard (#17149)
* Adding logic to hide Create Post on empty dashboard

As implemented, folks won't see this page if they can't create a post.
However, as our implementation drifts, we should continue to apply the
same policy.

See forem/forem#16999 for the conditional logic that redirects users.

* Adding a hack to fix a unit test
2022-04-11 13:52:35 -04:00
Julianna Tetreault
f6d7d431b5
Updates the role tooltip within _member_data.html.erb (#17218) 2022-04-11 11:50:55 -06:00
Jeremy Friesen
f790c3c0c1
Encapsulating the "why we hide/show" something (#17166)
* Encapsulating the "why we hide/show" something

Prior to this commit, we were relying on our views/templates to
understand why it might want to append the "hidden" dom class.  That is
not ideal, because it required repeating knowledge about the conditions
of the policy outside of the policy's domain.

With this commit, we're removing a duplication of knowledge; or more
appropriately asking the steward responsible for the knowledge to
produce the answer.

* Refining the note to not describe a course of action
2022-04-11 13:40:16 -04:00
Jeremy Friesen
02ff835e7f
Conditionally removing listing reference (#17211)
* Conditionally removing listing reference

Prior to this commit, our notifications would send listing related information.

* Update app/views/mailers/notify_mailer/new_badge_email.html.erb

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2022-04-11 13:02:17 -04:00
Takuya N
3edffcbb22
Replace #to_s(:format) with #to_fs (#17219)
https://github.com/rails/rails/pull/43772
https://github.com/rails/rails/pull/44354

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2022-04-11 12:59:54 -04:00
Julianna Tetreault
bf67ae2fbb
Refactor Member Index View Tooltips (#17170)
* Adjusts Member Index View tooltips to include resource type

* Adds .compact to the list of resource_types in #format_role_tooltip

* Updates users_helper.rb#format_role_tooltip tests

* right align tooltip

* Update app/views/admin/users/_member_index.html.erb

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

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-11 09:20:26 -06:00
Takuya N
8bed053f85
Remove unused articles/_splash.html.erb (#17198)
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2022-04-11 08:26:05 -06:00
Takuya N
b5ea75cf39
Use correct trademarks in supported embeds (#17195)
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2022-04-11 07:32:45 -06:00
ludwiczakpawel
cc6679f194
box sizing (#17185) 2022-04-11 12:16:58 +02:00
Miguel Nieto A
13c433cd56
fix: 🐛 Fix Color displaying over button in settings (#17172) 2022-04-11 10:59:57 +02:00
ludwiczakpawel
d6f204afc1
Toggle component (#17126)
* toggle

* box-sizing

* fixes

* whoopsy

* add specs for toggle component

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-11 09:44:43 +02:00
Jeremy Friesen
168698fe28
Conditionally removing listing from Admin > Consumer Apps menu (#17182)
Related to forem/forem#16437
2022-04-08 21:55:45 -04:00
Daniel Uber
7f1fdc7324
Produce a meaningful slug from podcast episode title (#17184)
* Use sluggerize to produce a slug from podcast episode title

This is essentially the process we use for Article#title_to_slug
without the random trailing bits on the end (since podcast episodes
had not worked that way previously).

* Add test case for slug generation

* Oh, the test only works if you checkin the fixture, too
2022-04-08 16:30:16 -05:00
Daniel Uber
2ddefcbba5
Remove guard clauses and update expectations (#17138) 2022-04-08 15:20:19 -05:00
Suzanne Aitchison
dcb46e088b
bring repeating layout code to partials (#17179) 2022-04-08 17:52:18 +01:00
Jeremy Friesen
1d2ecc64f0
Removing Listing rate limiting when feature disabled (#17181)
* Removing Listing rate limiting when feature disabled

Closes forem/forem#17175

* Fixing tests
2022-04-08 11:59:23 -04:00
Suzanne Aitchison
bd097bca25
Member index: add copy email to clipboard functionality (#17146)
* functioning on large screen view

* layout tweak

* tidy up

* remove redundant change

* refocus dropdown button when clipboard copy executes and closes dropdown

* add cypress test

* add missed attr

* implement in responsive layouts

* use runtime copy utility
2022-04-08 14:08:15 +01:00
Suzanne Aitchison
b6e2a735b7
stop capitalizing table headers (#17178) 2022-04-08 14:07:27 +01:00
Ridhwana
83104f8d2b
Refactor the way we show organizations on the member index view (#17177) 2022-04-08 14:48:39 +02:00
Dwight Scott
dfdae481e4
cache open graph response (#17157)
* Trigger Build

* Cache the HTML response for quicker previews

* remove unnecessary comments
2022-04-07 13:53:20 -04:00
Arit Amana
e4446a778c
Revalidate embedded links that redirect (#17150)
* complete implementation and add specs

* delete irrelevant spec and comment

* refactor validate_link method to return passed-in url

* better naming

* handle NotAllowed status in link validation
2022-04-07 13:32:07 -04:00
Suzanne Aitchison
be64f43c1a
Refactor runtime to webpacker JS (#17142)
* add runtime utilities in webpack land, refactor webpack JS using old class

* access Runtime in legacy JS code via window.Forem namespace

* refactor

* make sure data-runtime added only after page does initial load
2022-04-07 15:39:38 +01:00
Suzanne Aitchison
eae8557cf1
Admin member index: update responsive layouts (#17124)
* add an xl breakpoint and use in member index view

* expand search controls at medium breakpoint

* tweak small screen layout options per breakpoint, add overflow button

* small fix

* switch where role appears depending on breakpoint

* adjust for smallest layout

* tweaks for medium layout

* tweaks for large layout

* tweaks for XL table
2022-04-07 14:36:43 +01:00
Jeremy Friesen
07983e38be
Adjusting conditional create post rendering (#17132)
* Revert "conditionally render create post button for admins #16490 (#16606)"

This reverts commit 1cb45995cb.

* Adding conditional create post rendering

This pull request does two things:

- Reverts the forem/forem#16606
- Replaces the conditional rendering with the approach from forem/forem#17076

What to consider:

- How does this impact Cumulative Layout Shift (CLS).  Prior to this
  commit, we didn't "flicker" the "Create Post" button into view if the
  site didn't have the conditional.
- In reverting forem/forem#16606 we remove a dependency on Turbo.
- We reduce one network call, relying instead on the async_info to carry
  the visible/hidden logic.

If the "flicker" is a problem we could add a conditional in the page for
if the site has enabled that feature.  However, that's a place holder as
we're looking at possible other reasons for allowing/disabling the
create a post.

This is a non-blocking PR, as in we can merge or not merge this and
proceed with what we have.  Instead the main goal is to "unify" our approach.

* Update cypress/integration/seededFlows/policyFlows/limitPostCreationToAdmins.spec.js

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

* Leveraging change from forem/forem#17143

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-07 09:11:37 -04:00
Jeremy Friesen
674a971887
Adding link to Spaces admin guide (#17156)
* Adding link to Spaces admin guide

This commit presently links to a missing page, but in consultation with
Ella, she'll be putting the page at the linked URL.

The original copy was:

> Want to learn more about spaces? Check [Admin Guide]

I chose to go with the following, as assistive technology will announce
the link's text as "more about Spaces in the Admin Guide", which I find
more a11y oriented.

> Learn [more about Spaces in the Admin Guide]

Closes forem/forem#17148

* Update app/views/admin/spaces/index.html.erb

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

* Bringing the Learning inside the Linking

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-07 09:10:50 -04:00
Mac Siri
d28aa37ed2
Add Oauth check to AwardContributorFromGithub (#17155)
* Add oauth check to AwardContributorFromGithub

* Add spec

* Simplify spec
2022-04-06 15:41:20 -04:00
Jeremy Friesen
a9a5ad214b
Narrowing when we apply "hidden" by policy attributes (#17143)
Prior to this commit, we always assumed a policy based attribute would
have the "hidden" class and then we'd rely on JavaScript to toggle the
visibility.

With this approach, we are "cheating" a bit by specifically referencing
a feature flag that is the driver for the visibility behavior.

This mirrors the one-off behavior of forem/forem#16606.  Namely, when
the flag is off, we render without default hiding.  And when it's on, we
include the "hidden" attribute.

In both cases, we will still leveraged the [applyApplicationPolicyToggles.js][1]
introduced in forem/forem#17076.

An impact could be that if multiple flags are fiddling with the policy,
we could see an area disappear or wrongly remain present.  This would be
a warning to fix (the server would still enforce correct policies so
this would be a bit of a "heads up we have a mismatch in understanding
that happens to impact UI behavior").

[1]:https://github.com/forem/forem/blob/main/app/javascript/packs/applyApplicationPolicyToggles.js
2022-04-06 13:57:01 -04:00
Julianna Tetreault
ccf33c50a0
Add Data (User Details, Status, etc.) to the Member Index View Columns (#17033)
* Adds data to the member column in Member Index View

* Adds roles, statuses, and latest activity to Member Index views

* Adds the list of orgs a user belongs to in Member Index view

* Updates the image URL to link to each users member detail view

* Adds comment_suspended to user current_status and makes roles prettier

* Fixes bullet warning and encapsulates org logic in method

* Properly displays today and yesterday in words

* Refactors #current_organizations to use ternary

* Updates user.rb Member Index View-related methods

* Adjusts the styling of user roles and adds tooltip to roles

* Updates Member Index View to be mobile-friendly

* Updates userIndexView.spec.js

* Updates capitalization within userIndexView.spec.js

* Updates Member Index View per mobile designs and feedback

* Adds member status logic inline with SVGs

* Updates the status column for mobile layout

* Adjust current_role tooltips for Member Index View

* Adds organization name tooltip to member orgas

* Adds organization pics to Member Index View and cleans up helpers

* Addresses PR review feedback (Thanks, Suzanne!)

* Uses CSS in place of SVGs for member statuses

* Adds E2E test for and removes link to org page from Member Index View

* Addresses PR feedback comments by refactoring Member Index View code

* Removes leftover code in user.rb

* Update method that tooltips rely on

* Spells regular correctly :

* Adds a spec that tests Admin::UsersHelper#format_last_activity_timestamp

* Adjusts #cascading_high_level_roles logic and roles

* Adds a spec for #cascading_high_level_roles

* Adds a #last_activity spec to the User model

* Adjusts code a bit per PR feedback. Thanks, Ridhwana! :)

* Updates specs for Member Index View helpers

* Adds Timecop.freeze to help with timestamp failure in user_spec.rb
2022-04-06 11:48:25 -06:00
Jeremy Friesen
8c2b1276a4
Adding copy to assist with space toggle decision (#17147)
This commit adds instruction as to what's happening when a person
toggles on this feature.  So as to not repeat knowlege, I added a
`NUMBER_OF_MINUTES_FOR_CACHE_EXPIRY` constant so the UI can reference that
instead of dropping a hard-coded 15 in the UI.

Closes forem/forem#17097
2022-04-06 11:07:21 -04:00
Jeremy Friesen
faaf2ec028
Favoring explicit declaration over inferrence (#17089)
This commit does three things:

1. Documents a method
3. Implies the question: "Do we want to use class_attribute in Forem's codebase?"
2. Switches from an inferrence to an explicit (and configurable)

In my experience, I want to favor "explicit" declarations instead of
inferring what they should be.  In this case, the inferrence is perhaps
adequate.  But as I look to `ApplicationController::PUBLIC_CONTROLLERS`,
I think that is a prime case for a `class_attribute`.  (The `api_action`
happened to be the lowest hanging fruit to begin the conversation.)

We still need some clarity into the `verify_private_forem` method as it
looks like it's doing a few different things.

There is precedence for using `class_attribute` found in
[`UniqueCrossModelSlugValidator.model_and_attribute_name_for_uniqueness_test`][1] (also
introduced by me).

[1]:https://github.com/forem/forem/blob/main/app/validators/unique_cross_model_slug_validator.rb
2022-04-06 10:42:08 -04:00
Arit Amana
5cf2229b58
Better Error Msg when Listing URL embedded and Listings are disabled (#17116)
* complete implementations and specs

* remove unused error msgs

* add "listing" and "listings" as ReservedWords
2022-04-06 08:38:53 -04:00
ludwiczakpawel
73d6d9802e
fix (#17141) 2022-04-06 11:13:44 +02:00
Jeremy Friesen
eef989cabf
Conditionally rendering "Search > My Posts" by policy (#17113)
When a user does not have any posts NOR can they create posts, we are to
hide the "Search > My Posts" section.

I have chosen not to write a test for this as it's exercising a well
tested policy and we don't have a unit test for this view.  As part of
forem/forem#17076 I introduced some cypress tests.  But that feels like
quite a bit of overkill for this feature.

Closes forem/forem#16837
Related to forem/forem#16821
2022-04-05 16:18:09 -04:00
Jeremy Friesen
7fade0f1f1
Re-arranging method to be less surprising (#17128)
* Re-arranging method to be less surprising

Prior to this commit we hand an unless code block with a return then we
set an instance variable.

On a quick scan I didn't notice the return but saw the render followed
later by the instance variable.

This change is logically the same, my hope is that it's just a bit more legible.

* Bump for travis
2022-04-05 15:49:19 -04:00
Jeremy Friesen
c3c884f4d0
Conditional rendering of "Create Post" link (#17076)
* WIP - Conditional rendering of "Create Post" link

This PR builds on the conversation from forem/forem#17056 and moves in a
slightly different direction.

Important in all of this is that the ability to create a post is
enforced on the server.  If the "Create Post" button were to be visible
but the user couldn't create a post when they clicked the button, they
would get an authorization error (or some such response).

This PR posits a different and perhaps competing approach to
forem/forem#16606.  This PR provides a general approach in which we add
class attributes in our HTML erb files.

Note: I have not included Cypress tests as I don't want to yet commit
that time.  I'm also wondering if this is the "right" thing to do.  I
definitely think we want to add some JS tests.  But could we do JS and
unit tests?  (How do we reach consensus regarding our test approach?)

Again, thank you for the conversation and expect an even more "complete"
PR after we have our discussion.

* Extracting AsyncInfo model to ease testing

* Renaming forbidden to visible

* Adding cypress test to assert no 'Create Post'

These are always treacherous.  What happens when we rename the button?
The test will continue to work.

* Apply suggestions from code review

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

* Switching to pack file for policy

Follows on [Suzanne's comment](https://github.com/forem/forem/pull/17076#issuecomment-1088567286)

* Update app/javascript/packs/applyApplicationPolicyToggles.js

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

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-05 12:47:12 -04:00
Jeremy Friesen
3c1206cf8f
Ensuring users can preview already published posts (#17123)
Prior to this commit

This would have been a bug, if someone had:

1. Toggled on the :limit_post_creation_to_admins feature flag
2. Wasn't an admin
3. Already had a published post
4. Went to edit the post and attempted to preview it

Related to the following issues:

- forem/forem#16908
- forem/forem#16944
- forem/forem#16837
- forem/forem#16942
2022-04-05 12:31:02 -04:00
Jeremy Friesen
78933d0636
Applying more liberal editor config policy (#17125)
Prior to this commit, only those who could create posts could edit their confi

However, we are allowing users who can't create posts to edit posts.  So
we want to allow for them to change their editor configuration.

Revisits
- forem/forem#16516

Supplants
- forem/forem#16778

Related to
- forem/forem#17123
- forem/forem#16908
2022-04-05 11:38:41 -04:00
Suzanne Aitchison
87dc5da17b
tweak crayons layout for admin section (#17122) 2022-04-05 13:14:50 +01:00