Skip to content

Commit

Permalink
*inspector dialog disposing (remove permision box from list) (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarancek authored Dec 2, 2024
1 parent 5cde056 commit fd661f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@
</WrapPanel.Resources>

<Button Visibility="{Binding Dialog._hideRetryButton.Cyclic,Converter={vortex:BooleanToVisibilityConverter},ConverterParameter=true}" Command="{Binding RetryCommand, Mode=OneWay}" Content="{x:Static s:strings.Retry}" />
<vortexs:PermissionBox Permissions="can_terminate_inspection">
<Button Visibility="{Binding Dialog._hideTerminateButton.Cyclic,Converter={vortex:BooleanToVisibilityConverter},ConverterParameter=true}" Command="{Binding TerminateCommand, Mode=OneWay}" Content="{x:Static s:strings.Terminate}" />
</vortexs:PermissionBox>
<vortexs:PermissionBox Name="PermissionBoxTerminateCommand" Permissions="can_terminate_inspection">
<Button Visibility="{Binding Dialog._hideTerminateButton.Cyclic,Converter={vortex:BooleanToVisibilityConverter},ConverterParameter=true}" Command="{Binding TerminateCommand, Mode=OneWay}" Content="{x:Static s:strings.Terminate}" />
</vortexs:PermissionBox>
<WrapPanel Visibility="{Binding Dialog._hideOverideButton.Cyclic,Converter={vortex:BooleanToVisibilityConverter},ConverterParameter=true}">
<vortexs:PermissionBox Permissions="can_override_inspection">
<vortexs:PermissionBox Name="PermissionBoxOverrideCommand" Permissions="can_override_inspection">
<Button Command="{Binding OverrideCommand, Mode=OneWay}" Content="{x:Static s:strings.Override}" />
</vortexs:PermissionBox>
</WrapPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,22 @@ public void Dispose()
this.DataContextChanged -= TcoInspectorDialogView_DataContextChanged;
if (context != null)
{
PermissionBox.RemovePermissionBox(this.PermissionBoxOverrideCommand);
try
{
PermissionBox.RemovePermissionBox(this.PermissionBoxOverrideCommand);
PermissionBox.RemovePermissionBox(this.PermissionBoxTerminateCommand);
}
catch (Exception ex)
{
}
context.CloseRequestEventHandler -= (s, ev) => this.Close();
}
}

private void HostWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Dispose();

if (webView != null)
{
webView.Dispose();
Expand Down
7 changes: 4 additions & 3 deletions src/TcoInspectors/tests/Sandbox.TcoInspectors.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,23 @@ public App()

roleGroupManager.CreateGroup("OperatorGroup");
roleGroupManager.AddRoleToGroup("OperatorGroup", "Operator");
//roleGroupManager.AddRoleToGroup("OperatorGroup", "can_terminate_inspection");
roleGroupManager.AddRoleToGroup("OperatorGroup", "can_terminate_inspection");
roleGroupManager.AddRoleToGroup("OperatorGroup", "can_override_inspection");

SecurityManager.Create(userDataRepo, roleGroupManager);
SecurityManager.Manager.GetOrCreateRole(new Role("Operator", "OperatorGroup"));

var userName = "Operator";
var password = "OperatorPassword";
userDataRepo.Create(userName, new UserData(userName, string.Empty, password, new string[] { "OperatorGroup" }, "Operator", string.Empty) { CanUserChangePassword = true });

userDataRepo.Create(userName, new UserData(userName, string.Empty, password, new string[] { "OperatorGroup" }, "Operator", string.Empty) { CanUserChangePassword = true });

LazyRenderer.Get.CreateSecureContainer = (permissions) => new PermissionBox { Permissions = permissions, SecurityMode = SecurityModeEnum.Disabled };


SecurityManager.Manager.Service.AuthenticateUser(userName, password);

SecurityManager.Manager.Service.DeAuthenticateCurrentUser();
//SecurityManager.Manager.Service.DeAuthenticateCurrentUser();
}

private static string AMS_ID = Environment.GetEnvironmentVariable("Tc3Target");
Expand Down

0 comments on commit fd661f7

Please sign in to comment.