Commit graph

4 commits

Author SHA1 Message Date
Jeremy Friesen
1b2aa68a4d
Ensuring confirmation and flash message for spaces (#17072)
* Ensuring confirmation and flash message for spaces

This change delivers an accessible form, and while it doesn't remove the
Save button nor produce a modal it does deliver the minimum viable
functionality.

In conversations with Suzanne, we spent an hour looking at how we might
make an accessible modal with the checkbox and state management
required as we as removing save buttons.

There are two paths:

1. Extend the current, yet deprecated, stimulus modal controller.
2. Extend the Preact modal work done for the Members Detail View.

We spent about 15 minutes pursuing the stimulus modal controller route,
and realized how much cruft it added to the system.  Not ideal and very
opaque in it's interaction.

The second one we talked about, but for our alloted time was inadequate
to begin further work.  To deliver on that generalized preact modal will
require at least an afternoon of work.

Closes forem/forem#17032

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

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

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

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

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2022-04-04 11:49:15 -04:00
Jeremy Friesen
6049271dcb
Bust cache when changing spaces (#17040)
In the [app/views/layouts/application.html.erb][1] we use
[ApplicationHelper#release_adjusted_cache_key][2] to define a cache
key.  That cache key includes the
`Settings::General.admin_action_taken_at` time field.

The [ApplicationController#bust_content_change_caches][3] method is
responsible for updating the `Settings::General.admin_action_taken_at` column.

[1]:f5ae2900b5/app/views/layouts/application.html.erb (L48)
[2]:f5ae2900b5/app/helpers/application_helper.rb (L193-L198)
[3]:f5ae2900b5/app/controllers/application_controller.rb (L255-L258)

This relates to forem/forem#16606 and may be necessary for the
following:

- forem/forem#16783
- forem/forem#16836
- forem/forem#16837
- forem/forem#16965
- forem/forem#17008
2022-03-29 11:09:09 -04:00
Jeremy Friesen
e2940e75ca
Adding :internal auditing for admin/spaces#update (#17010)
There are two existing listeners for the `Audit::Logger`: `:moderator`
and `:internal`.  (Note: during tests we ignore the :moderator and
:internal logs as defined in [config/initializers/audit_events.rb][1].)

Using `rg "Audit::Logger\.log\(:internal," --files-with-matches`, the
`:internal` listener is found in:

- app/controllers/admin/secrets_controller.rb
- app/controllers/admin/settings/base_controller.rb
- app/controllers/admin/settings/general_settings_controller.rb

Using `rg "Audit::Logger\.log\(:moderator," --files-with-matches`, the
`:moderator` listener is used in:

- app/controllers/rating_votes_controller.rb
- app/controllers/comments_controller.rb
- app/controllers/stories/pinned_articles_controller.rb
- app/controllers/admin/response_templates_controller.rb
- app/controllers/admin/tags_controller.rb
- app/controllers/admin/articles_controller.rb
- app/controllers/admin/users_controller.rb
- app/controllers/admin/reactions_controller.rb
- app/controllers/admin/tags/moderators_controller.rb
- app/controllers/tag_adjustments_controller.rb
- app/controllers/reactions_controller.rb

The `admin/spaces#update` action is most similar to the `admin#settings`
actions, which is why I chose `:internal`.  I am looking for further
guidance on documenting this little area of the application (in
particular providing a data dictionary of :internal and :moderator).

Closes forem/forem#16957

[1]:https://github.com/forem/forem/blob/main/config/initializers/audit_events.rb#L9-L11
2022-03-25 14:25:13 -04:00
Jeremy Friesen
88f4daf952
Penciling in a Default Spaces section (#16897)
* Penciling in a Default Spaces section

This delivers two primary things:

1.  Extracting shared policy examples
2.  Providing a functioning skeleton for toggling on the
    "limit_post_creation_to_admins" feature.

Important is that once merged, it would be possible for this code to
"leak" out.  But how that leaks out is also how you can test that the
feature works.

First, to orient, there is a constraint for a new route.  That
constraint checks if the feature flag exists (e.g. has been explicitly
enabled or explicitly disabled).  In other words, at this point, you
can't accidentally enable the feature via the UI.  But once you have
enabled the feature, you can then toggle the feature on and off.

So, to test this in the browser:

1. Pull down this branch
2. Run `rails runner "FeatureFlag.disable(:limit_post_creation_to_admins)"`
3. Startup your the web server.
4. Login as an administrator
5. Goto /admin/content_manager/spaces
   a. Bask in the glory of a plain HTML form
6. With another browser, login as another non-admin user
7. Go to /settings/extensions, you should see a section Publishing from RSS.
8. Now with the admin's session, update the form to turn on
  "limit_post_creation_to_admins"
9. Back to the non-admin browser, refresh /settings/extensions, you
   should no longer see the section Publishing from RSS.

Note: I have not included an admin menu item as that is related to and
dependent on some refactors I'm working on (see forem/forem#16888 and
forem/forem#16847).  So a bit of "security through obsurity"

Note: In the future, once we resolve forem/forem#16490, we'll start
toggling the "Create a Post" button.

Note: I am not including Cypress tests nor request tests for this
feature because the implementation details related to the testing via
that approach are a little too volitale.

Related to forem/forem#16842

* Updating copy based on forem/forem#16893

* styles

* styles

* dark styles

Co-authored-by: Paweł Ludwiczak <ludwiczakpawel@gmail.com>
2022-03-21 09:56:12 -04:00