Added protection for enterprise policies

This commit is contained in:
Thorsten Sommer 2026-01-31 21:20:07 +01:00
parent 2b55099025
commit b35333a9b6
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 15 additions and 2 deletions

View File

@ -46,7 +46,7 @@ else
<MudButton OnClick="@this.AddPolicy" Variant="Variant.Filled" Color="Color.Primary"> <MudButton OnClick="@this.AddPolicy" Variant="Variant.Filled" Color="Color.Primary">
@T("Add policy") @T("Add policy")
</MudButton> </MudButton>
<MudButton OnClick="@this.RemovePolicy" Disabled="@(this.selectedPolicy?.IsProtected ?? true)" Variant="Variant.Filled" Color="Color.Error"> <MudButton OnClick="@this.RemovePolicy" Disabled="@((this.selectedPolicy?.IsProtected ?? true) || (this.selectedPolicy?.IsEnterpriseConfiguration ?? true))" Variant="Variant.Filled" Color="Color.Error">
@T("Delete this policy") @T("Delete this policy")
</MudButton> </MudButton>
</MudStack> </MudStack>

View File

@ -227,9 +227,13 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
if(this.selectedPolicy is null) if(this.selectedPolicy is null)
return; return;
// The preselected profile is always user-adjustable, even for protected policies: // The preselected profile is always user-adjustable, even for protected policies and enterprise configurations:
this.selectedPolicy.PreselectedProfile = this.policyPreselectedProfileId; this.selectedPolicy.PreselectedProfile = this.policyPreselectedProfileId;
// Enterprise configurations cannot be modified at all:
if(this.selectedPolicy.IsEnterpriseConfiguration)
return;
var canEditProtectedFields = force || (!this.selectedPolicy.IsProtected && !this.policyIsProtected); var canEditProtectedFields = force || (!this.selectedPolicy.IsProtected && !this.policyIsProtected);
if (canEditProtectedFields) if (canEditProtectedFields)
{ {
@ -307,6 +311,9 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
if(this.selectedPolicy.IsProtected) if(this.selectedPolicy.IsProtected)
return; return;
if(this.selectedPolicy.IsEnterpriseConfiguration)
return;
var dialogParameters = new DialogParameters<ConfirmDialog> var dialogParameters = new DialogParameters<ConfirmDialog>
{ {
{ x => x.Message, string.Format(T("Are you sure you want to delete the document analysis policy '{0}'?"), this.selectedPolicy.PolicyName) }, { x => x.Message, string.Format(T("Are you sure you want to delete the document analysis policy '{0}'?"), this.selectedPolicy.PolicyName) },
@ -340,6 +347,9 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
if(this.selectedPolicy.IsProtected) if(this.selectedPolicy.IsProtected)
return; return;
if(this.selectedPolicy.IsEnterpriseConfiguration)
return;
this.selectedPolicy.PolicyName = this.policyName; this.selectedPolicy.PolicyName = this.policyName;
} }
@ -348,6 +358,9 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
if(this.selectedPolicy is null) if(this.selectedPolicy is null)
return; return;
if(this.selectedPolicy.IsEnterpriseConfiguration)
return;
this.policyIsProtected = state; this.policyIsProtected = state;
this.selectedPolicy.IsProtected = state; this.selectedPolicy.IsProtected = state;
this.policyDefinitionExpanded = !state; this.policyDefinitionExpanded = !state;