docbrown/app/views/admin/settings/show.html.erb
Jeremy Friesen a40efc6bbd
Refactoring questions asked of user (#15762)
* Refactoring questions asked of user

In this pull request, I'm extracting and normalizing role-based
questions asked of the user.

Prior to this commit, our codebase has asked two very similar questions
of our user model:

- `user.has_role?(:admin)`
- `user.admin?`

In asking `has_role?(:admin)` we are relying on implementation details
of the rolify gem.  In addition, the `has_role?` question asked
throughout controllers or views means that it's harder to create
hieararchies of permissions.

In favoring `user.admin?` as our question, we can use that indirection
as an opportunity to discuss and decide "Should someone with the
`:super_admin` role be `user.admin? == true`?"

The details of this commit is to do three primary things:

1. Ask the `has_role?` questions in "one place" in the code (e.g. the
   `Authorizer` module)
2. Extract the role based questions that are on the `User` model and
   provde backwards compatable delegation.
3. Structure the code so that it's harder to accidentally call
   `user.has_role?` (e.g., make `User#has_role?` and `User#has_any_role?`
   private).

This is related to #15624 and the updates are informed by discussion in
PR #15691.  This commit supplants #15691.

* Refactoring the liquid tag policy tests

* Fixing typo

* Bump for travis
2021-12-21 12:45:12 -05:00

83 lines
2.9 KiB
Text

<div class="grid gap-6" data-controller="config">
<% unless current_user.super_admin? %>
<div class="crayons-notice crayons-notice--info" role="alert">
<p class="mb-1">
Only users with <strong>Super Admin</strong> privileges may edit this page.
</p>
</div>
<% end %>
<div id="getStarted">
<div class="card w-100">
<div
id="getStartedHeader"
class="card-header"
data-toggle="collapse"
data-target="#getStartedBodyContainer"
aria-expanded="true"
aria-controls="getStartedBodyContainer">
<h2 class="d-inline">Get Started</h2>
<button
class="crayons-btn crayons-btn--secondary float-right"
type="button"
data-action="click->config#toggleAccordionButtonLabel">
<%= VerifySetupCompleted.setup_completed? ? "Show Getting Started" : "Hide Getting Started" %>
</button>
</div>
<div
id="getStartedBodyContainer"
class="<%= VerifySetupCompleted.setup_completed? ? "hide collapse" : "show expand" %> p-3"
aria-labelledby="getStartedHeader">
<%= render partial: "forms/mandatory" %>
</div>
</div>
</div>
<div id="settings">
<div class="card w-100">
<div
id="settingsHeader"
class="card-header"
data-toggle="collapse"
data-target="#settingsBodyContainer"
aria-expanded="true"
aria-controls="settingsBodyContainer">
<h2 class="d-inline">All Settings</h2>
<button
class="crayons-btn crayons-btn--secondary float-right"
type="button"
data-action="click->config#toggleAccordionButtonLabel">
Hide Settings
</button>
</div>
<div id="settingsBodyContainer" class="show expand p-3" aria-labelledby="settingsHeader">
<%= render partial: "forms/api_tokens" %>
<%= render partial: "forms/authentication" %>
<%= render partial: "forms/campaign" %>
<%= render partial: "forms/community" %>
<%= render partial: "forms/credits" %>
<%= render partial: "forms/emails" %>
<%= render partial: "forms/email_digest_frequency" %>
<%= render partial: "forms/google_analytics" %>
<%= render partial: "forms/images", locals: { logo_allowed_types: @logo_allowed_types, logo_max_file_size: @logo_max_file_size } %>
<%= render partial: "forms/mascot" %>
<%= render partial: "forms/meta_keywords" %>
<%= render partial: "forms/monetization" %>
<%= render partial: "forms/newsletter" %>
<%= render partial: "forms/onboarding" %>
<%= render partial: "forms/rate_limit" %>
<%= render partial: "forms/smtp" %>
<%= render partial: "forms/sponsors" %>
<%= render partial: "forms/tags" %>
<%= render partial: "forms/user_experience" %>
</div>
</div>
</div>
</div>