Commit graph

300 commits

Author SHA1 Message Date
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
dependabot[bot]
deb86efb0d
Bump cypress and @knapsack-pro/cypress (#18025)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-07-06 17:53:13 -04: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
dependabot[bot]
64d970abd2
Bump cypress from 9.6.1 to 9.7.0 (#17840)
* Bump cypress from 9.6.1 to 9.7.0

Bumps [cypress](https://github.com/cypress-io/cypress) from 9.6.1 to 9.7.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js)
- [Commits](https://github.com/cypress-io/cypress/compare/v9.6.1...v9.7.0)

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

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

* update failing spec

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-06-27 15:16:07 +01: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
Suzanne Aitchison
213fcb956d
Member index: Show applied org filters (#17977)
* show applied org filters

* correct casing
2022-06-23 18:14:41 +01:00
Julianna Tetreault
9b07f138ff
Refactors the userIndexView e2e test by making it more DRY (#17965) 2022-06-22 14:12:53 -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
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
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
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
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
Joshua Wehner
8be41307cf
Unpin article should behave more like Pin article (#17798)
* Unpin article should behave more like Pin article
* Don't repeat pinned article on index
2022-06-07 14:18:43 +02:00
Arit Amana
1679fbf47d
Allow Moderator Role to Unpublish Single Post (#17795)
* relocate btn; build functionality for admin only

* remove commented code

* add explanatory comment

* refactor

* build unpublish and feature-post policies

* mod role in policies fails specs 😓

* fix failing specs

* add end-to-end tests

* fix hardcoded name in modal  😓
2022-06-03 12:48:20 -04:00
Andy Zhao
103394d5ad
Add tooltip to cover image button describing optimal image ratio (#17779)
* Add tooltip for cover image button

* Add cover img tooltip to v1 editor

* Use a slightly different message

* Fix tests

* Use proper comment syntax for front matter

* Fix Cypress test

* Use regex to find matching label
2022-06-02 17:44:34 -04:00
Suzanne Aitchison
c119b64b74
Reusable user admin modals (#17763)
* target modal content by a classname to avoid duplicate IDs

* woops - fix missed selector

* use showWindowModal in editUser

* move add org to a partial

* move add role into a partial

* move adjust credits to a partial

* move profile modals to be re-used

* generalise approach to add organisation modal

* generalise add role modal form

* generalise adjust credits modal

* rework unpublish modal

* refactor banish user modal

* refactors

* prevent issues with duplicate ids

* fix banish form action

* make sure role management specs covered in cypress

* let hidden modal content use IDs

* rename file for clarity

* add some JSDoc notes

* cleanup some redundant changes

* one more

* woops - fixed id that contained a classname
2022-06-02 09:52:26 -06:00
Julianna Tetreault
b155398f17
"Empty State" for Result-less Search and Filter (#17777)
* Adds an empty state when user search & filter returns nothing

* Addresses e2e failures for small screens
2022-06-01 06:54:39 -06:00
Julianna Tetreault
b155749db0
Searchable GDPR Delete Requests Table (#17633)
* Adds search functionality to GDPR delete requests table

* Adds e2e tests for searching GDPR delete requests

* WIP: Address PR review feedback and add a RSpec test

* Updates spec name to include _query

* Updates Adnub::GDPRDeleteRequests#index

* Adjusts expectations within gdpr_delete_requests_query_spec.rb

* Adjusts GDPR Delete Requests Query search default

* Updates gdpr_delete_requests_query_spec.rb
2022-05-31 16:22:25 -06:00
Dwight Scott
8b70e9e1f3
added ability to assign moderator role via admin/super admin (#17759)
* added ability to assign moderator role via admin/super admin

* create Mod User in seeds

* add Cypress specs

* fix failing Cypress tests

* fix failing specs by moving test Mod user to the end

* nudge Travis

* nudge Travis

Co-authored-by: Arit Amana <msarit@gmail.com>
2022-05-26 10:57:08 -04:00
Arit Amana
2fed62454d
Reposition 'Feature Post' button on Mod Panel (#17735)
* physically move btn

* fix styling

* actually fix styling 😅

* remove old button

* add cypress seed and specs

* fix E2E seeds to fix Travis failures

* refactor specs
2022-05-24 16:49:22 -04:00
Suzanne Aitchison
e62684342f
Member index view - collapse other filter sections when one is clicked (#17740)
* collapse any filter sections when a new one is clicked

* add a cypress test
2022-05-24 14:51:18 +01:00
Julianna Tetreault
79bc765f3c
"Empty State" for GDPR Delete Requests (#17583)
* Adds an empty state to the GDPR delete requests table

* Refactors and fixes gdprDeleteRequests.spec.js

* Updates aria-describedby for the GDPR delete requests table
2022-05-09 06:50:15 -06:00
Julianna Tetreault
810d5cf3a6
"Empty State" for Invited Members (#17571)
* WIP: Adds an empty state to the invitations table

* Pulls invited member empty state into partial

* WIP: Center empty state within invited members table body

* Removes partial and adjusts empty space styling

* Adds an e2e for the empty state to invitedUsers.spec.js

* Moves empty state outside of table and adds aria-describedby to table

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

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

* Adjusts ara-describedby erb tag

* Updates the route used within invitedUsers.spec.js to fix e2e failure

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-05-05 13:24:06 -06:00
Ridhwana
6f880ee5b6
Update the Sidebar to include the Member Manager (#17538)
* feat: update all the paths as a first order of business

* feat: update all the folders to no longer appear under users

* feat: update specs

* feat: update specs

* feat: remove User namespace

* feat: remove route namespace

* feat: path change

* feat: move the menu items to the sidebar

* feat: add a badge

* feat: remove tabs partial

* xs font

* feat: update describe blocks

* feat: update cypress tests

* chore: oops member_manager instead of member_management

* feat: c-indicator

* feat: update the tests

* feat: update the gdpr test

* feat: add the invitations

* chore: align

* feat: update the GDPR constant

* feat: rename to GDPR actions

* feat: add member manager route
2022-05-05 12:46:47 +02:00
Suzanne Aitchison
50d2359049
add crayons modal to gdpr confirm delete flow (#17568) 2022-05-05 08:19:34 +01:00
Suzanne Aitchison
6313114fc2
Update invitations search aria-label (#17569)
* update invitations search aria-label

* nudge Travis
2022-05-05 08:13:53 +01:00
Suzanne Aitchison
25bf8a0711
Remove name from invitation flow (#17438)
* remove name from invite user flow

* remove name from invitation instructions

* update invitations spec

* update specs and invitation actions overflow menu name

* allow users to set name when accepting invite
2022-05-03 09:33:12 +01:00
Ridhwana
994a121c62
feat: add search by email back (#17511) 2022-04-29 09:59:10 -04:00
yheuhtozr
ef290a5120
controllers/admin i18n (#17085)
* admin controllers i18n

* remove ja.yml

* fix for spec

* fix for spec 2

* Apply suggestions from code review

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

* Update config/locales/controllers/admin/fr.yml

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

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2022-04-26 09:40:09 -06:00
Ridhwana
d9ca26b521
DO NOT MERGE: Remove the Member Index View Feature Flags + old code (#17388)
* feat: remove feature flag on the member index view and re-arrange some partials

* feat: remove Feature Flag for the invitations view

* feat: remove Feature Flag for the gdpr view

* feat: remove Feature Flag for the controls

* feat: remove the feature flag in the tests

* remove extra queries that we no longer use

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

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

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

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

* Update app/views/admin/users/index/_controls.html.erb

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

* Update app/views/admin/users/gdpr_delete_requests/index.html.erb

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

* Update cypress/integration/seededFlows/adminFlows/users/userIndexView.spec.js

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

* Update cypress/integration/seededFlows/adminFlows/users/userIndexView.spec.js

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

* Update app/views/admin/users/gdpr_delete_requests/index.html.erb

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

* feat: attempt to fix Cypress test

* fix: soem other cypress tests

* fix: search bar

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-25 14:49:34 +02:00
Suzanne Aitchison
33eb6070f4
Reference checkboxes by name (#17403) 2022-04-22 10:44:25 -04:00
Daniel Uber
de1e1ea7b8
Confirm signout happened by looking for Log in link (#17392)
Similar to checking that "Unpin post" is shown after pinning, wait for
"Log in" to show after signing out before checking that signed out
users can see a pinned post.

Recommended by @aitchiss in a comment on #17385 as a way to limit
false negatives (where we check the previously signed in user's view)
2022-04-21 10:34:05 -05:00
Daniel Uber
2f4f98462e
e2e: Reload the page after changing authentication (#17387)
* Reload the config page after changing auth

When testing in Chrome (but not Firefox or Electron) I noticed this
test would fail. The issue appears to have been findByLabelText (used
to check Email enabled, Facebook enabled, etc are not visible) was not
finding the labels when the group was still hidden.

I _think_ there was a time, when this test was first written, that
submitting the form reloaded the page (simple form post), but that may
have been replaced with an xhr submission and some client side
replacement?

I tried not clicking the Authentication after enabling invite only (to
prevent hiding the form content, leaving this section expanded),
however this caused the "Email enabled" check to fail (it was still
visible). I think this means it had been passing because it was not
visible because the section was hidden, not because the label had been
updated properly after the submission.

I'm not sure if fixing the test here papers over a UI issue, but it
would be best if these tests worked consistently across browsers. I
suspect this may have behaved differently in earlier versions of
Chrome, or only been tested interactively in Chrome when the page
still reloaded, and this caused some drift.

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

prefer reload to calling visit a second time

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

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-21 09:46:17 -05:00
Daniel Uber
f6a648c607
Address a flaky spec by waiting (#17385)
We had seen an increase in CI timeouts (no output received for 10
minutes).

Running this example (signed out user sees the pinned article)
repeatedly I was able to reproduce the failure seen in Travis, and
checking the last few times this occurred it appears to be linked to
the pinArticle.spec.js last test, which fails with an
ApplicationPolicy when pinning.

The likeliest source of this issue is the POST (pin the article) is
received concurrently with the session delete (logging the admin user
out), resulting in a race. If/when the signout occurs before the
article policy is checked (does the current user have permission to
pin an article), the cypress running stalls.

This occurred both interactively (bin/e2e or cypress open) and
headless (cypress run/CI). The error went away reliably after
inserting this guard to check for the "Unpin post" link on the page,
which forces the POST to have completed and redirected back to the
admin page before logging out.

My understanding of this problem is borne out in the local test logs,
where the signout and pin requests arrive concurrently and process out
of order (and the POST gives a 404 instead of a 302).

    Started DELETE "/users/sign_out" for 127.0.0.1 at 2022-04-20 12:09:23 -0500
    Started POST "/admin/content_manager/articles/1/pin" for 127.0.0.1 at 2022-04-20 12:09:23 -0500
    Completed 204 No Content in 42ms (ActiveRecord: 6.2ms | Allocations: 6323)
    Completed 404 Not Found in 4ms (ActiveRecord: 0.4ms | Allocations: 833)
2022-04-21 09:18:08 -05:00
Suzanne Aitchison
9d9bf8763a
fix bug in search and filter indicators (#17341) 2022-04-20 17:57:57 +01:00
Suzanne Aitchison
963f0c1136
style the orgs, add cypress tests (#17370) 2022-04-20 15:37:20 +01:00
Suzanne Aitchison
b4b7d4bd39
Admin member index: invitations responsive layout (#17278)
* add expandable search control at mobile size

* add invitations smaller layout

* replace missing member image

* tweaks following merge

* minor layout tweaks

* add actions to smaller view, update cypress specs
2022-04-19 10:00:15 +01:00
Jeremy Friesen
3a37db7b30
Ensuring /new remains a call to action end point for DEV (#17294)
There are two problems engrained in this:

1. The undocumented expectation of `/new` needed to other sites linking
with prefill information.
2. The prefill parameters being lost during the authentication process.

The first bug was introduced as part forem/forem#16536.  The second is
likely introduced as part of a Rails upgrade (namely `request.path` most
likely once included the query parameters but with our current
implementation it does not).

Closes forem/forem#17292
2022-04-14 14:50:40 -04:00
Ridhwana
2746e77fd5
Adding a modal for the CSV export (#17259) 2022-04-14 18:19:28 +02:00
Suzanne Aitchison
a0a4b8a851
Member index (Phase 2) - Invitations actions (#17213)
* Add actions to invitations table

* table style tweaks

* add specs for cancel and resend actions

* rspec resend test
2022-04-14 08:26:36 +01: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
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
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
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
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
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