Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Read-only settings #3846

Merged

Conversation

lukeholder
Copy link
Member

@lukeholder lukeholder commented Jan 14, 2025

WIP

Notes

Use the new disableInputs() helper if needed: return Html::disableInputs(fn() => $this->getSettingsHtml());

  • Added getReadOnlySettingsResponse() to Plugin.
  • Added \craft\commerce\Plugin::$hasReadOnlyCpSettings
  • Added \craft\commerce\controllers\BaseAdminController::isReadyOnlyScreen() helper.
  • Switched to use $this->requireAdmin(false); in BaseAdminController

Controllers

Make sure $this->isReadyOnlyScreen() is passed into templates/screens for all admin based controllers:

  • General Settings
  • Stores
  • Site Stores
  • Product Types
  • Order Field Layout
  • Order Statuses
  • Line Item Statuses
  • PDFs
  • Emails
  • Gateways
  • Subscription Field Layout
  • Transfer Field Layout

Templates

Use readOnly variable available from controller or {% set readOnly = not craft.app.config.general.allowAdminChanges %}.
Disable inputs: disabled: readOnly, or static: readOnly,.
Disable actions for admin tables

{% if readOnly %}
  {% set contentNotice = readOnlyNotice() %}
{% endif %}
  • General Settings
  • Stores Index/Edit
  • Site Stores Index/Edit
  • Product Types Index/Edit
  • Order Field Layout Edit
  • Order Statuses Index/Edit
  • Line Item Statuses Index/Edit
  • PDFs Index/Edit
  • Emails Index/Edit
  • Gateways Index/Edit
  • Subscription Field Layout Edit
  • Transfer Field Layout Edit

Fields

  • Products and Variants Field already inherit any static element context

Related issues

craftcms/cms#16265

@lukeholder lukeholder marked this pull request as ready for review January 22, 2025 14:09
@lukeholder lukeholder requested a review from a team as a code owner January 22, 2025 14:09
@lukeholder lukeholder merged commit 541f05f into 5.3 Jan 22, 2025
9 checks passed
@lukeholder lukeholder deleted the feature/show-read-only-settings-when-allowadminchanges-false branch January 22, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants