summaryrefslogtreecommitdiff
path: root/Pages/Component/AclDialog.razor
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-10-05 16:47:49 +1100
committerJake Mannens <jake@asger.xyz>2023-10-05 16:47:49 +1100
commit2c6e3aa4456811a3d6412fc10019012a900eb6a0 (patch)
treed0616bbe573a4abe5aaf9f80e7960a40352967b8 /Pages/Component/AclDialog.razor
parent035d2e3858dd55580c294031573c3be9e1999449 (diff)
parent3d5f6e47bd74ce77d5ec253f51b7cef1b42099ef (diff)
Merged security
Diffstat (limited to 'Pages/Component/AclDialog.razor')
-rw-r--r--Pages/Component/AclDialog.razor97
1 files changed, 73 insertions, 24 deletions
diff --git a/Pages/Component/AclDialog.razor b/Pages/Component/AclDialog.razor
index 7c3267d..6df9320 100644
--- a/Pages/Component/AclDialog.razor
+++ b/Pages/Component/AclDialog.razor
@@ -2,37 +2,81 @@
@inject IDbContextFactory<HBContext> dbFactory;
@implements IDialog
-<Dialog Title="Edit permissions" @ref=dialog>
- @if(obj?.Acl is not null) {
- <table class="data-table">
- <tr>
- <th>Action</th>
- <th>Subject</th>
- <th>Permissions</th>
- </tr>
- @foreach(var rule in Object.Acl.Rules) {
- <tr>
- <td style="font-family:'lucida console';font-size:10pt;">@rule.Action.ToString()</td>
- <td style="font-family:'lucida console';font-size:10pt;">@rule.Principal.ToString()</td>
- <td style="font-family:'lucida console';font-size:10pt;">@GetActivePermissions(rule)</td>
- </tr>
- }
- </table>
- <ButtonContainer>
- <button class="secondary" @onclick=Hide>Cancel</button>
- </ButtonContainer>
- } else {
- <center><i>This item does not have any permissions set!</i></center>
+<Dialog HeightPixels=500 WidthPixels=900 Title="Edit permissions" @ref=dialog>
+ <div class="vcontainer">
+ <div class="hcontainer">
+ <div>
+ @if(obj?.Acl is not null) {
+ <label>
+ Owner
+ <input type="text" autocomplete="off"/>
+ </label>
+ <table class="data-table">
+ <tr>
+ <th>Action</th>
+ <th>Subject</th>
+ <th colspan="2">Permissions</th>
+ </tr>
+ @foreach(var rule in obj.Acl.Rules.OrderByDescending(r => r.Action)) {
+ <tr>
+ <td><div><AclActionSwitch InitialValue=@(rule.Action == AclRuleAction.Allow)/></div></td>
+ <td>
+ @(WellKnownSid.TranslateSid(rule.Principal) ?? rule.Principal.ToString())
+ </td>
+ <td>@GetActivePermissions(rule)</td>
+ <td>
+ <a title="Edit" href="javascript:;">&#x1F589</a>
+ <a title="Delete" href="javascript:;">&#x2716</a>
+ </td>
+ </tr>
+ }
+ </table>
+ <br/>
+ <center><a href="javascript:;">Add new</a></center>
+ } else {
+ <p><i>This item does not have any permissions set!</i></p>
+ }
+ </div>
+ <div>
+ @if(obj?.Acl is not null) {
+ <div class="principal-select">
+ <label>
+ Subject
+ <input type="text" autocomplete="off"/>
+ </label>
+ <button>Submit</button>
+ </div>
+ var permissions = Acl.GetPermissionDescriptions(obj)
+ .OrderByDescending(kv => BitOperations.PopCount(kv.Value))
+ .ThenBy(kv => kv.Value);
+ foreach(var kv in permissions) {
+ <label>
+ <input type="checkbox"/>
+ @kv.Key
+ </label>
+ }
+ } else {
+ <p><i>Click Edit next to an ACL to edit it's permissions</i></p>
+ }
+ </div>
+ </div>
<ButtonContainer>
<button class="secondary" @onclick=Hide>Cancel</button>
+ @if(obj?.Acl is not null) {
+ <button data-keyboard-shortcut="a" @onclick=Hide><u>A</u>pply</button>
+ }
</ButtonContainer>
- }
+ </div>
</Dialog>
@code {
public bool Visible {
get => dialog.Visible;
- set => dialog.Visible = value;
+ set {
+ dialog.Visible = value;
+ if(value)
+ StateHasChanged();
+ }
}
private HBObject? obj;
@@ -42,6 +86,11 @@
public void Show() => Visible = true;
public void Hide() => Visible = false;
+ public void Show(HBObject obj) {
+ Object = obj;
+ Show();
+ }
+
public HBObject? Object {
get => obj;
set {
@@ -81,7 +130,7 @@
return string.Join(", ", perms
.OrderByDescending(kv => BitOperations.PopCount(kv.Value))
- .ThenByDescending(kv => kv.Value)
+ .ThenBy(kv => kv.Value)
.Select(kv => kv.Key));
}
} \ No newline at end of file