-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Templating: Prevent editing of templates and partial views in production runtime mode (closes #21564) #21600
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
base: main
Are you sure you want to change the base?
Templating: Prevent editing of templates and partial views in production runtime mode (closes #21564) #21600
Conversation
… and verify for partial views and templates with integration tests.
… production runtime mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Prevents editing of templates and partial views when Umbraco is running in Production runtime mode, enforcing restrictions both server-side (services/API) and client-side (backoffice UI), with added integration tests.
Changes:
- Add new operation statuses and enforce production-mode restrictions in
TemplateServiceandPartialViewService(plus API error mapping). - Update backoffice templating editors/actions to become read-only and hide/disable save and editing affordances in production mode.
- Add integration tests for production-mode behavior and extend repository tests around file writing behavior by runtime mode.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/TemplateServiceTests.cs | Adds production-mode service tests for template create/delete/update behavior. |
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/TemplateRepositoryTest.cs | Adds runtime-mode-dependent repository save tests (file write suppression in production). |
| tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs | Updates repository construction and adds runtime-mode-dependent file write tests for partial views. |
| tests/Umbraco.Tests.Integration/Umbraco.Core/Services/PartialViewServiceTests.cs | Adds production-mode service tests for partial view create/update/delete/rename behavior. |
| src/Umbraco.Web.UI.Client/src/packages/templating/workspace-editor-styles.ts | Introduces shared templating workspace editor styles and production warning banner styles. |
| src/Umbraco.Web.UI.Client/src/packages/templating/templates/workspace/template-workspace-editor.element.ts | Makes template editor read-only in production and adds warning banner + disables actions. |
| src/Umbraco.Web.UI.Client/src/packages/templating/templates/workspace/manifests.ts | Hides/disables template save workspace action in production via condition. |
| src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/workspace/partial-view-workspace-editor.element.ts | Makes partial view editor read-only in production and adds warning banner + disables actions. |
| src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/workspace/manifests.ts | Hides/disables partial view save workspace action in production via condition. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/server.context.ts | Adds server information fetching and derives an isProductionMode observable for UI gating. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/manifests.ts | Registers server-related condition manifests. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/index.ts | Exports server conditions for consumption by other packages. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/conditions/types.ts | Adds config typing for “is production mode” condition. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/conditions/manifests.ts | Registers “Server Is Production Mode” condition. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/conditions/is-production-mode.condition.ts | Implements condition logic for extension gating based on production mode. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/conditions/index.ts | Exports condition constants/types. |
| src/Umbraco.Web.UI.Client/src/packages/core/server/conditions/constants.ts | Defines the production-mode condition alias constant. |
| src/Umbraco.Web.UI.Client/src/packages/core/manifests.ts | Wires server manifests into the core manifest bundle. |
| src/Umbraco.Web.UI.Client/src/assets/lang/en.ts | Adds localized string for production-mode non-editable warning. |
| src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewRepository.cs | Injects runtime settings and prevents filesystem writes for partial views in production mode. |
| src/Umbraco.Core/Services/TemplateService.cs | Adds runtime-mode checks to block create/delete and block content changes on update in production. |
| src/Umbraco.Core/Services/PartialViewService.cs | Adds runtime-mode checks to block create/update/delete/rename in production. |
| src/Umbraco.Core/Services/OperationStatus/TemplateOperationStatus.cs | Adds production-mode-related operation statuses for templates. |
| src/Umbraco.Core/Services/OperationStatus/PartialViewOperationStatus.cs | Adds production-mode-related operation status for partial views. |
| src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs | Updates DI registration to use ActivatorUtilities to support new constructors. |
| src/Umbraco.Cms.Api.Management/Controllers/Template/TemplateControllerBase.cs | Maps new template operation statuses to 400 responses with clearer problem details. |
| src/Umbraco.Cms.Api.Management/Controllers/PartialView/PartialViewControllerBase.cs | Maps new partial view operation status to 400 response with problem details. |
Description
This PR addresses #21564 which points out that we don't have the same behaviour in 17 as we do in 13 when it comes to surfacing information about templates and partial views being restricted for editing when running in production runtime mode.
The following updates are introduced:
Change Details
Server-side
NotAllowedInProductionModestatus toPartialViewOperationStatus.NotAllowedInProductionModeandContentChangeNotAllowedInProductionModestatuses toTemplateOperationStatus.PartialViewServiceto check runtime mode and block modifications in production.TemplateServiceto check runtime mode, blocking create/delete fully and content changes on update.Client-side
IsProductionModecondition for workspace actions.Tests
PartialViewServiceproduction mode behaviour.TemplateServiceproduction mode behaviour.UX
For the warning message, I couldn't find an existing example to copy styling-wise, so have used the available colour variables to make something that looks good (to my eyes at least).
However in FE review it could be you'll want to change this, either stylistically or to make consistent with some other similar informational label.
Testing
To set up for testing:
Umbraco:CMS:Runtime:ModetoProductioninappsettings.jsonRuntimeModeValidationService.Validateto early return withvalidationErrorMessage = null; return true;.Then you can check the following:
Normal editing should work when production mode is not enabled.