Skip to content

Commit

Permalink
Cp::readOnlyNoticeHtml(), readOnlyNotice()
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 7, 2025
1 parent 1a81b86 commit 3f3a6dd
Show file tree
Hide file tree
Showing 32 changed files with 31 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/controllers/EntryTypesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function actionEdit(?int $entryTypeId = null, ?EntryType $entryType = nul
'retainScroll' => true,
]);
} else {
$response->noticeHtml(Cp::allowAdminChangesReadOnlyNotice());
$response->noticeHtml(Cp::readOnlyNoticeHtml());
}

if ($entryType->id) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/FieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function actionEditField(?int $fieldId = null, ?FieldInterface $field = n
])
->editUrl($field->id ? "settings/fields/edit/$field->id" : null);
} else {
$response->noticeHtml(Cp::allowAdminChangesReadOnlyNotice());
$response->noticeHtml(Cp::readOnlyNoticeHtml());
}

$response
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/FsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function actionEdit(?string $handle = null, ?Fs $filesystem = null): Resp
'retainScroll' => true,
]);
} else {
$response->noticeHtml(Cp::allowAdminChangesReadOnlyNotice());
$response->noticeHtml(Cp::readOnlyNoticeHtml());
}

return $response;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/VolumesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function actionEditVolume(?int $volumeId = null, ?Volume $volume = null):
])
->editUrl($volume->getCpEditUrl());
} else {
$response->noticeHtml(Cp::allowAdminChangesReadOnlyNotice());
$response->noticeHtml(Cp::readOnlyNoticeHtml());
}

return $response;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,7 @@ public static function requestedSite(): ?Site
* @return string
* @since 5.6.0
*/
public static function allowAdminChangesReadOnlyNotice(): string
public static function readOnlyNoticeHtml(): string
{
return
Html::beginTag('div', [
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/assets/transforms/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]) %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/assets/transforms/_settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% import '_includes/forms.twig' as forms %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/assets/volumes/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
]) %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/categories/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% set headlessMode = craft.app.config.general.headlessMode %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/categories/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
] %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/email/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/entry-types/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{% endblock %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/fields/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{% endblock %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/filesystems/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% endblock %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/general/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{% from _self import configWarning %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/globals/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/globals/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{% endblock %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% set readOnly = not craft.app.config.general.allowAdminChanges %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/plugins/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{% set disabledPlugins = craft.app.config.general.disabledPlugins %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/routes.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div id="routes">
{% if readOnly %}
<div id="content-notice">
{{ craft.cp.allowAdminChangesReadOnlyNotice()|raw }}
{{ readOnlyNotice()|raw }}
</div>
{% endif %}
{% for route in routes %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/sections/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{% set headlessMode = craft.app.config.general.headlessMode %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/sections/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% endblock %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/sites/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% import '_includes/forms.twig' as forms %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/sites/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{% endblock %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/tags/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% import '_includes/forms.twig' as forms %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/tags/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
] %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/users/fields.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% set readOnly = not craft.app.config.general.allowAdminChanges %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/users/groups/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% set fullPageForm = not readOnly %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/users/groups/_index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% set groups = craft.app.userGroups.getAllGroups() %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/settings/users/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{% endmacro %}

{% if readOnly %}
{% set contentNotice = craft.cp.allowAdminChangesReadOnlyNotice() %}
{% set contentNotice = readOnlyNotice() %}
{% endif %}

{% block content %}
Expand Down
1 change: 1 addition & 0 deletions src/web/twig/CpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function getFunctions(): array
new TwigFunction('iconSvg', [Cp::class, 'iconSvg'], ['is_safe' => ['html']]),
new TwigFunction('siteMenuItems', [Cp::class, 'siteMenuItems']),
new TwigFunction('statusIndicator', [Cp::class, 'statusIndicatorHtml'], ['is_safe' => ['html']]),
new TwigFunction('readOnlyNotice', [Cp::class, 'readOnlyNoticeHtml'], ['is_safe' => ['html']]),
];
}

Expand Down
12 changes: 0 additions & 12 deletions src/web/twig/variables/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -1107,16 +1107,4 @@ public function fieldLayoutDesigner(FieldLayout $fieldLayout, array $config = []
{
return CpHelper::fieldLayoutDesignerHtml($fieldLayout, $config);
}

/**
* Returns the notice that should show when admin is viewing the available settings pages
* while `allowAdminChanges` is set to false.
*
* @return string
* @since 5.6.0
*/
public function allowAdminChangesReadOnlyNotice(): string
{
return CpHelper::allowAdminChangesReadOnlyNotice();
}
}

0 comments on commit 3f3a6dd

Please sign in to comment.